调整云仓商品关联
This commit is contained in:
parent
342a5b74f7
commit
913291f95f
30
app/common/dao/store/product/CloudProductDao.php
Normal file
30
app/common/dao/store/product/CloudProductDao.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\dao\store\product;
|
||||||
|
|
||||||
|
use app\common\dao\BaseDao;
|
||||||
|
use app\common\model\store\product\CloudProduct;
|
||||||
|
|
||||||
|
class CloudProductDao extends BaseDao
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function getModel(): string
|
||||||
|
{
|
||||||
|
return CloudProduct::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search(array $where)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
app/common/model/store/product/CloudProduct.php
Normal file
30
app/common/model/store/product/CloudProduct.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\model\store\product;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class CloudProduct extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): string
|
||||||
|
{
|
||||||
|
return 'mer_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'cloud_product';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,6 +28,11 @@ use app\common\repositories\store\StoreActivityRepository;
|
|||||||
class Merchant extends BaseModel
|
class Merchant extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const TypeStore = 10; //镇街店铺
|
||||||
|
const TypeCloudWarehouse = 11; //里海云仓
|
||||||
|
const TypeSupplyChain = 12; //市级供应链
|
||||||
|
const TypePlatform = 13; //供销平台
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
* @author xaboy
|
* @author xaboy
|
||||||
|
@ -241,8 +241,8 @@ class ProductRepository extends BaseRepository
|
|||||||
$product['mer_labels'] = $data['mer_labels'];
|
$product['mer_labels'] = $data['mer_labels'];
|
||||||
app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType);
|
app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType);
|
||||||
}
|
}
|
||||||
$product = $result;
|
// $product = $result;
|
||||||
event('product.create',compact('product'));
|
// event('product.create',compact('product'));
|
||||||
return $result->product_id;
|
return $result->product_id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1568,6 +1568,7 @@ class ProductRepository extends BaseRepository
|
|||||||
Db::rollback();
|
Db::rollback();
|
||||||
throw new ValidateException('商品spu更新出错');
|
throw new ValidateException('商品spu更新出错');
|
||||||
}else{
|
}else{
|
||||||
|
event('product.sell', ['source_mer_id' => $merId, 'product_id' => $id, 'status' => $status]);
|
||||||
if ($product->product_type==0){
|
if ($product->product_type==0){
|
||||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||||
if ($status==1){
|
if ($status==1){
|
||||||
|
@ -120,6 +120,9 @@ class StoreProduct extends BaseController
|
|||||||
$data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1;
|
$data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1;
|
||||||
$data['mer_id'] = $merId;
|
$data['mer_id'] = $merId;
|
||||||
$this->repository->edit($id, $data, $merId, 0, 1);
|
$this->repository->edit($id, $data, $merId, 0, 1);
|
||||||
|
if ($data['status'] == 0) {
|
||||||
|
event('product.sell', ['source_mer_id' => $merId, 'product_id' => $id, 'status' => $data['status']]);
|
||||||
|
}
|
||||||
return app('json')->success('编辑成功');
|
return app('json')->success('编辑成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ return [
|
|||||||
'community_address'=>[\app\listener\CommunityAddress::class],
|
'community_address'=>[\app\listener\CommunityAddress::class],
|
||||||
// 'order.paySuccess'=>[\app\listener\OrderPaySuccess::class],
|
// 'order.paySuccess'=>[\app\listener\OrderPaySuccess::class],
|
||||||
'product.create'=>[\app\listener\ProductCreate::class],
|
'product.create'=>[\app\listener\ProductCreate::class],
|
||||||
|
'product.sell'=>[\app\listener\CloudProduct::class], //商品上下架
|
||||||
],
|
],
|
||||||
|
|
||||||
'subscribe' => [],
|
'subscribe' => [],
|
||||||
|
22
app/listener/CloudProduct.php
Normal file
22
app/listener/CloudProduct.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types=1);
|
||||||
|
|
||||||
|
namespace app\listener;
|
||||||
|
|
||||||
|
use app\common\dao\store\product\CloudProductDao;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
|
||||||
|
class CloudProduct
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$merchant = Merchant::getDB()->where('mer_id', $event['source_mer_id'])->find();
|
||||||
|
$cloudMerchant = Merchant::getDB()->where(['type_id' => Merchant::TypeCloudWarehouse, 'category_id' => $merchant->category_id, 'status' => 1, 'mer_state' => 1])->value('mer_id');
|
||||||
|
$where = ['mer_id' => $cloudMerchant, 'source_mer_id' => $event['source_mer_id'], 'product_id' => $event['product_id']];
|
||||||
|
$cloudProduct = app()->make(CloudProductDao::class)->findOrCreate($where);
|
||||||
|
$cloudProduct->save(['status' => $event['status']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user