增加:商户进货复制商品 自动绑定对应的品牌额度及数量
This commit is contained in:
parent
7eb5e0d19b
commit
f40f180d8e
|
|
@ -10,6 +10,7 @@ use app\common\repositories\store\order\StoreOrderProductRepository;
|
||||||
use app\common\repositories\store\parameter\ParameterValueRepository;
|
use app\common\repositories\store\parameter\ParameterValueRepository;
|
||||||
use app\model\product\sku\StoreProductAttrValue;
|
use app\model\product\sku\StoreProductAttrValue;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use think\facade\Log;
|
||||||
|
|
||||||
class WineProductRepository extends BaseRepository{
|
class WineProductRepository extends BaseRepository{
|
||||||
protected $dao;
|
protected $dao;
|
||||||
|
|
@ -30,7 +31,7 @@ class WineProductRepository extends BaseRepository{
|
||||||
// 获取全部商品
|
// 获取全部商品
|
||||||
$orderProductList = app()->make(StoreOrderProductRepository::class)
|
$orderProductList = app()->make(StoreOrderProductRepository::class)
|
||||||
->getSearch([])
|
->getSearch([])
|
||||||
->field(['order_product_id','order_id','product_id','product_sku','product_num'])
|
->field(['order_product_id','order_id','product_id','product_sku','product_num','mer_quota_title','mer_quota_other'])
|
||||||
->where('order_id',$orderId)
|
->where('order_id',$orderId)
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
@ -45,6 +46,7 @@ class WineProductRepository extends BaseRepository{
|
||||||
if(($productInfo->product_id ?? 0) > 0) {
|
if(($productInfo->product_id ?? 0) > 0) {
|
||||||
// 商品已经存在
|
// 商品已经存在
|
||||||
$this->stockWithGoodsAddStock($item,$productInfo);
|
$this->stockWithGoodsAddStock($item,$productInfo);
|
||||||
|
$this->addMerQuota((int)$productInfo->product_id, (float)$item['mer_quota_title'], (float)$item['mer_quota_other']);
|
||||||
}else{
|
}else{
|
||||||
// 商品不存在
|
// 商品不存在
|
||||||
$this->stockWithGoodsCopy($item,$withGoodsMerId);
|
$this->stockWithGoodsCopy($item,$withGoodsMerId);
|
||||||
|
|
@ -104,6 +106,9 @@ class WineProductRepository extends BaseRepository{
|
||||||
->value('mer_labels');
|
->value('mer_labels');
|
||||||
app()->make(SpuRepository::class)->create($product, $result->product_id, 0, $oldGood['product_type']);
|
app()->make(SpuRepository::class)->create($product, $result->product_id, 0, $oldGood['product_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->addMerQuota((int)$result->product_id, (float)$item['mer_quota_title'], (float)$item['mer_quota_other']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,6 +187,25 @@ class WineProductRepository extends BaseRepository{
|
||||||
return $this->stockWithGoodsCopySpec($item, $productInfo);
|
return $this->stockWithGoodsCopySpec($item, $productInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 进货完成 - 增加商品绑定的品牌额度(该品牌额度在商品售出时返还给对应商户对应额度)
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2024/06/07 17:06
|
||||||
|
* @param int $productId
|
||||||
|
* @param float $merQuotaTitle
|
||||||
|
* @param float $merQuotaOther
|
||||||
|
*/
|
||||||
|
public function addMerQuota(int $productId,float $merQuotaTitle,float $merQuotaOther){
|
||||||
|
$productInfo = app()->make(ProductRepository::class)->getSearch([])->where('product_id',$productId)->findOrEmpty();
|
||||||
|
if(($productInfo->product_id ?? 0) > 0){
|
||||||
|
// 增加冠名品牌额度
|
||||||
|
if($merQuotaTitle > 0) $productInfo->mer_quota_title += $merQuotaTitle;
|
||||||
|
// 增加其他品牌额度
|
||||||
|
if($merQuotaOther > 0) $productInfo->mer_quota_other += $merQuotaOther;
|
||||||
|
$productInfo->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ class OrderTakeEvent{
|
||||||
$order = $data['order'];
|
$order = $data['order'];
|
||||||
if($order->activity_type == 35){
|
if($order->activity_type == 35){
|
||||||
// 酒道馆进货商品确认收货 复制商品||增加库存
|
// 酒道馆进货商品确认收货 复制商品||增加库存
|
||||||
Log::info('订单进入待评价 - 酒道馆进货商品处理 - 开始: '.var_export([
|
// Log::info('订单进入待评价 - 酒道馆进货商品处理 - 开始: '.var_export([
|
||||||
'order_id' => $order->order_id,
|
// 'order_id' => $order->order_id,
|
||||||
'with_goods_mer_id' => $order->with_goods_mer_id,
|
// 'with_goods_mer_id' => $order->with_goods_mer_id,
|
||||||
'activity_type' => $order->activity_type
|
// 'activity_type' => $order->activity_type
|
||||||
],1));
|
// ],1));
|
||||||
app()->make(WineProductRepository::class)->stockWithGoodsInit($order->order_id, $order->with_goods_mer_id);
|
app()->make(WineProductRepository::class)->stockWithGoodsInit($order->order_id, $order->with_goods_mer_id);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue