更新云商品
This commit is contained in:
parent
866e77c24c
commit
4c366096bc
@ -496,7 +496,7 @@ class Common extends BaseController
|
||||
//获取云店铺
|
||||
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')
|
||||
->alias('m')
|
||||
|
@ -44,51 +44,71 @@ class CloudWarehouse extends BaseController
|
||||
* 指定类型的云仓商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 除了市级供应链都可以查询
|
||||
$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']);
|
||||
$search = [
|
||||
// 'street_id' => $params['street_code'],
|
||||
'type_id' => $typeIdArray ?? [],
|
||||
'status' => 1,
|
||||
'is_del' => 0,
|
||||
'mer_state' => 1,
|
||||
];
|
||||
if (!empty($params['category_id'])) {
|
||||
$search['category_id'] = $params['category_id'];
|
||||
}
|
||||
$merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
||||
[$page, $limit] = $this->getPage();
|
||||
if(isset($params['page_num'])&&$params['page_num']!=''){
|
||||
$page=$params['page_num'];
|
||||
}
|
||||
if (empty($merchantIds)) {
|
||||
return app('json')->success(['count' => 0, 'list' => []]);
|
||||
}
|
||||
// 隐藏镇级云仓
|
||||
// $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||
// $entryWhere = [
|
||||
// 'street_id' => $params['street_code'],
|
||||
// 'type_id' => $typeCloudWarehouseId,
|
||||
// 'status' => 1,
|
||||
// 'is_del' => 0,
|
||||
// 'mer_state' => 1,
|
||||
// ];
|
||||
// if (!empty($params['category_id'])) {
|
||||
// $entryWhere['category_id'] = $params['category_id'];
|
||||
// }
|
||||
// $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
|
||||
// public function index()
|
||||
// {
|
||||
// // 除了市级供应链都可以查询
|
||||
// $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']);
|
||||
// $search = [
|
||||
// // 'street_id' => $params['street_code'],
|
||||
// 'type_id' => $typeIdArray ?? [],
|
||||
// 'status' => 1,
|
||||
// 'is_del' => 0,
|
||||
// 'mer_state' => 1,
|
||||
// ];
|
||||
// if (!empty($params['category_id'])) {
|
||||
// $search['category_id'] = $params['category_id'];
|
||||
// }
|
||||
// $merchantIds = $this->merchantDao->search($search)->column('mer_id');
|
||||
// [$page, $limit] = $this->getPage();
|
||||
// if(isset($params['page_num'])&&$params['page_num']!=''){
|
||||
// $page=$params['page_num'];
|
||||
// }
|
||||
// if (empty($merchantIds)) {
|
||||
// return app('json')->success(['count' => 0, 'list' => []]);
|
||||
// }
|
||||
// // 隐藏镇级云仓
|
||||
// // $typeCloudWarehouseId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeCloudWarehouse'])->value('mer_type_id');
|
||||
// // $entryWhere = [
|
||||
// // 'street_id' => $params['street_code'],
|
||||
// // 'type_id' => $typeCloudWarehouseId,
|
||||
// // 'status' => 1,
|
||||
// // 'is_del' => 0,
|
||||
// // 'mer_state' => 1,
|
||||
// // ];
|
||||
// // if (!empty($params['category_id'])) {
|
||||
// // $entryWhere['category_id'] = $params['category_id'];
|
||||
// // }
|
||||
// // $where['entry_mer_id'] = $this->merchantDao->search($entryWhere)->value('mer_id');
|
||||
|
||||
$where['entry_mer_id'] = 0;
|
||||
$where['keyword'] = $params['keyword'];
|
||||
$where['mer_ids'] = $merchantIds;
|
||||
$where['product_type'] = $params['product_type'];
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['order'] = $params['order'] ?: 'sort';
|
||||
$products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
|
||||
return app('json')->success($products);
|
||||
}
|
||||
// $where['entry_mer_id'] = 0;
|
||||
// $where['keyword'] = $params['keyword'];
|
||||
// $where['mer_ids'] = $merchantIds;
|
||||
// $where['product_type'] = $params['product_type'];
|
||||
// $where['is_gift_bag'] = 0;
|
||||
// $where['order'] = $params['order'] ?: 'sort';
|
||||
// $products = $this->spuRepository->getApiCloudSearch($where, $page, $limit, false);
|
||||
// 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) {
|
||||
|
||||
$exist = Db::name('store_product')->where('source_library_id', $id)->where('mer_id', $mer_id)->find();
|
||||
// if ($exist) {
|
||||
// return app('json')->fail('已经导入过该商品了');
|
||||
// }
|
||||
if ($exist) {
|
||||
return app('json')->fail('已经导入过该商品了');
|
||||
}
|
||||
$find['attrValue']=[
|
||||
['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'=>''
|
||||
|
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)
|
||||
{
|
||||
$product = $event['product'];
|
||||
$data = $event['data'];
|
||||
$contentType = $event['conType'];
|
||||
// $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;
|
||||
}
|
||||
if($merchant['type_id']!=Merchant::TypeTownSupplyChain){
|
||||
return false;
|
||||
}
|
||||
// 根据支持同步到云商的商户进行同步操作
|
||||
$syncMerArray = Db::name('MerchantType')->where('is_sync_prod', 1)->column('mer_type_id');
|
||||
if (!in_array($merchant['type_id'], $syncMerArray)) {
|
||||
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;
|
||||
}
|
||||
// $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();
|
||||
//查询市级供应链
|
||||
$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) {
|
||||
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);
|
||||
//添加到云仓
|
||||
$datas=[
|
||||
'product_id'=>$product_id,
|
||||
'mer_id'=>$merchant['mer_id'],
|
||||
'source_mer_id'=>$cityMerchant['mer_id'],
|
||||
'street_code'=>$merchant['street_id'],
|
||||
'weight'=>1,
|
||||
'status'=>1,
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
];
|
||||
Db::name('cloud_product')->insert($datas);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user