更新云商品
This commit is contained in:
parent
866e77c24c
commit
4c366096bc
@ -496,7 +496,7 @@ class Common extends BaseController
|
|||||||
//获取云店铺
|
//获取云店铺
|
||||||
public function get_cloud_shop($street_code){
|
public function get_cloud_shop($street_code){
|
||||||
//更新查询镇级供应链店铺
|
//更新查询镇级供应链店铺
|
||||||
$typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id');
|
// $typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id');
|
||||||
/*
|
/*
|
||||||
$find=DB::name('merchant')
|
$find=DB::name('merchant')
|
||||||
->alias('m')
|
->alias('m')
|
||||||
|
@ -44,51 +44,71 @@ class CloudWarehouse extends BaseController
|
|||||||
* 指定类型的云仓商品列表
|
* 指定类型的云仓商品列表
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function index()
|
// public function index()
|
||||||
{
|
// {
|
||||||
// 除了市级供应链都可以查询
|
// // 除了市级供应链都可以查询
|
||||||
$typeIdArray = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->column('mer_type_id');
|
// $typeIdArray = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->column('mer_type_id');
|
||||||
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword','page_num']);
|
// $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword','page_num']);
|
||||||
$search = [
|
// $search = [
|
||||||
// 'street_id' => $params['street_code'],
|
// // 'street_id' => $params['street_code'],
|
||||||
'type_id' => $typeIdArray ?? [],
|
// 'type_id' => $typeIdArray ?? [],
|
||||||
'status' => 1,
|
// 'status' => 1,
|
||||||
'is_del' => 0,
|
// 'is_del' => 0,
|
||||||
'mer_state' => 1,
|
// 'mer_state' => 1,
|
||||||
];
|
// ];
|
||||||
if (!empty($params['category_id'])) {
|
// if (!empty($params['category_id'])) {
|
||||||
$search['category_id'] = $params['category_id'];
|
// $search['category_id'] = $params['category_id'];
|
||||||
}
|
// }
|
||||||
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
// $merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
||||||
[$page, $limit] = $this->getPage();
|
// [$page, $limit] = $this->getPage();
|
||||||
if(isset($params['page_num'])&&$params['page_num']!=''){
|
// if(isset($params['page_num'])&&$params['page_num']!=''){
|
||||||
$page=$params['page_num'];
|
// $page=$params['page_num'];
|
||||||
}
|
// }
|
||||||
if (empty($merchantIds)) {
|
// if (empty($merchantIds)) {
|
||||||
return app('json')->success(['count' => 0, 'list' => []]);
|
// return app('json')->success(['count' => 0, 'list' => []]);
|
||||||
}
|
// }
|
||||||
// 隐藏镇级云仓
|
// // 隐藏镇级云仓
|
||||||
// $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
// // $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||||
// $entryWhere = [
|
// // $entryWhere = [
|
||||||
// 'street_id' => $params['street_code'],
|
// // 'street_id' => $params['street_code'],
|
||||||
// 'type_id' => $typeCloudWarehouseId,
|
// // 'type_id' => $typeCloudWarehouseId,
|
||||||
// 'status' => 1,
|
// // 'status' => 1,
|
||||||
// 'is_del' => 0,
|
// // 'is_del' => 0,
|
||||||
// 'mer_state' => 1,
|
// // 'mer_state' => 1,
|
||||||
// ];
|
// // ];
|
||||||
// if (!empty($params['category_id'])) {
|
// // if (!empty($params['category_id'])) {
|
||||||
// $entryWhere['category_id'] = $params['category_id'];
|
// // $entryWhere['category_id'] = $params['category_id'];
|
||||||
// }
|
// // }
|
||||||
// $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
|
// // $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
|
||||||
|
|
||||||
$where['entry_mer_id'] = 0;
|
// $where['entry_mer_id'] = 0;
|
||||||
$where['keyword'] = $params['keyword'];
|
// $where['keyword'] = $params['keyword'];
|
||||||
$where['mer_ids'] = $merchantIds;
|
// $where['mer_ids'] = $merchantIds;
|
||||||
$where['product_type'] = $params['product_type'];
|
// $where['product_type'] = $params['product_type'];
|
||||||
$where['is_gift_bag'] = 0;
|
// $where['is_gift_bag'] = 0;
|
||||||
$where['order'] = $params['order'] ?: 'sort';
|
// $where['order'] = $params['order'] ?: 'sort';
|
||||||
$products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
|
// $products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
|
||||||
return app('json')->success($products);
|
// return app('json')->success($products);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云仓商品列表
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function index($street_code,$page_num=1){
|
||||||
|
$cloud_product=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->page($page_num)->select();
|
||||||
|
if(!$cloud_product){
|
||||||
|
return app('json')->success(['count'=>0,'list'=>[]]);
|
||||||
|
}
|
||||||
|
$where=[
|
||||||
|
'is_show'=>1,
|
||||||
|
'is_used'=>1,
|
||||||
|
'status'=>1,
|
||||||
|
'is_del'=>0,
|
||||||
|
'mer_status'=>1,
|
||||||
|
];
|
||||||
|
$count=Db::name('cloud_product')->where('street_code',$street_code)->where('status',1)->count();
|
||||||
|
$select=Db::name('store_product')->whereIn('product_id',$cloud_product)->where($where)->select();
|
||||||
|
return app('json')->success(['count'=>$count,'list'=>$select]);
|
||||||
|
}
|
||||||
}
|
}
|
@ -89,9 +89,9 @@ class StoreMicro extends BaseController
|
|||||||
if ($find) {
|
if ($find) {
|
||||||
|
|
||||||
$exist = Db::name('store_product')->where('source_library_id', $id)->where('mer_id', $mer_id)->find();
|
$exist = Db::name('store_product')->where('source_library_id', $id)->where('mer_id', $mer_id)->find();
|
||||||
// if ($exist) {
|
if ($exist) {
|
||||||
// return app('json')->fail('已经导入过该商品了');
|
return app('json')->fail('已经导入过该商品了');
|
||||||
// }
|
}
|
||||||
$find['attrValue']=[
|
$find['attrValue']=[
|
||||||
['image'=>$find['image'],'price'=>$price,'cost'=>$find['cost'],'ot_price'=>$find['ot_price'],
|
['image'=>$find['image'],'price'=>$price,'cost'=>$find['cost'],'ot_price'=>$find['ot_price'],
|
||||||
'svip_price'=>0,'stock'=>$stock,'bar_code'=>$find['bar_code'],'weight'=>0,'volume'=>0,'detail'=>''
|
'svip_price'=>0,'stock'=>$stock,'bar_code'=>$find['bar_code'],'weight'=>0,'volume'=>0,'detail'=>''
|
||||||
|
58
app/listener/ProductCreate copy.php
Normal file
58
app/listener/ProductCreate copy.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\listener;
|
||||||
|
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
use app\common\repositories\store\product\ProductRepository;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备份数据请勿删除
|
||||||
|
*/
|
||||||
|
class ProductCreate
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$product = $event['product'];
|
||||||
|
$data = $event['data'];
|
||||||
|
$contentType = $event['conType'];
|
||||||
|
$merchant = Db::name('merchant')->where('status', 1)->where('is_del', 0)->where('mer_id', $product['mer_id'])->find();
|
||||||
|
if (empty($merchant)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 根据支持同步到云商的商户进行同步操作
|
||||||
|
$syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id');
|
||||||
|
if (!in_array($merchant['type_id'], $syncMerArray)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||||
|
$typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id');
|
||||||
|
if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询市级云仓
|
||||||
|
$cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', Merchant::TypePlatform)->find();
|
||||||
|
if ($cityMerchant == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', $product['bar_code'])->value('product_id');
|
||||||
|
if ($product_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['mer_id'] = $cityMerchant['mer_id'];
|
||||||
|
$data['status'] = $cityMerchant['is_audit'] ? 0 : 1;
|
||||||
|
$data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1;
|
||||||
|
$data['rate'] = 3;
|
||||||
|
// $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
|
||||||
|
// $productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0;
|
||||||
|
$productType =0;
|
||||||
|
$data['update_time'] = date('Y-m-d H:i:s');
|
||||||
|
app()->make(ProductRepository::class)->create($data, $productType, $contentType);
|
||||||
|
}
|
||||||
|
}
|
@ -14,42 +14,48 @@ class ProductCreate
|
|||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
$product = $event['product'];
|
$product = $event['product'];
|
||||||
$data = $event['data'];
|
// $data = $event['data'];
|
||||||
$contentType = $event['conType'];
|
// $contentType = $event['conType'];
|
||||||
|
//查询当前商品的店铺
|
||||||
$merchant = Db::name('merchant')->where('status', 1)->where('is_del', 0)->where('mer_id', $product['mer_id'])->find();
|
$merchant = Db::name('merchant')->where('status', 1)->where('is_del', 0)->where('mer_id', $product['mer_id'])->find();
|
||||||
if (empty($merchant)) {
|
if (empty($merchant)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if($merchant['type_id']!=Merchant::TypeTownSupplyChain){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 根据支持同步到云商的商户进行同步操作
|
// 根据支持同步到云商的商户进行同步操作
|
||||||
$syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id');
|
// $syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id');
|
||||||
if (!in_array($merchant['type_id'], $syncMerArray)) {
|
// if (!in_array($merchant['type_id'], $syncMerArray)) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
// $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||||
$typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id');
|
// $typePlatformId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypePlatform'])->value('mer_type_id');
|
||||||
if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) {
|
// if ($merchant['type_id'] == $typePlatformId || $merchant['type_id'] == $typeCloudWarehouseId) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//查询市级云仓
|
//查询市级供应链
|
||||||
$cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', Merchant::TypePlatform)->find();
|
$cityMerchant = Db::name('merchant')->where('status', 1)->where('mer_state', 1)->where('category_id', $merchant['category_id'])->where('type_id', Merchant::TypeSupplyChain)->find();
|
||||||
if ($cityMerchant == null) {
|
if ($cityMerchant == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//查询市级供应链商品
|
||||||
$product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', $product['bar_code'])->value('product_id');
|
$product_id = Db::name('store_product')->where('mer_id', $cityMerchant['mer_id'])->where('bar_code', $product['bar_code'])->value('product_id');
|
||||||
if ($product_id) {
|
if ($product_id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//添加到云仓
|
||||||
$data['mer_id'] = $cityMerchant['mer_id'];
|
$datas=[
|
||||||
$data['status'] = $cityMerchant['is_audit'] ? 0 : 1;
|
'product_id'=>$product_id,
|
||||||
$data['mer_status'] = ($cityMerchant['is_del'] || !$cityMerchant['mer_state'] || !$cityMerchant['status']) ? 0 : 1;
|
'mer_id'=>$merchant['mer_id'],
|
||||||
$data['rate'] = 3;
|
'source_mer_id'=>$cityMerchant['mer_id'],
|
||||||
// $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
|
'street_code'=>$merchant['street_id'],
|
||||||
// $productType = $cityMerchant['type_id'] == $typeSupplyChainId ? 98 : 0;
|
'weight'=>1,
|
||||||
$productType =0;
|
'status'=>1,
|
||||||
$data['update_time'] = date('Y-m-d H:i:s');
|
'create_time'=>date('Y-m-d H:i:s'),
|
||||||
app()->make(ProductRepository::class)->create($data, $productType, $contentType);
|
];
|
||||||
|
Db::name('cloud_product')->insert($datas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user