增加:商户进货复制商品 自动绑定对应的品牌额度及数量
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\model\product\sku\StoreProductAttrValue;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class WineProductRepository extends BaseRepository{
|
||||
protected $dao;
|
||||
|
|
@ -30,7 +31,7 @@ class WineProductRepository extends BaseRepository{
|
|||
// 获取全部商品
|
||||
$orderProductList = app()->make(StoreOrderProductRepository::class)
|
||||
->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)
|
||||
->select()
|
||||
->toArray();
|
||||
|
|
@ -45,6 +46,7 @@ class WineProductRepository extends BaseRepository{
|
|||
if(($productInfo->product_id ?? 0) > 0) {
|
||||
// 商品已经存在
|
||||
$this->stockWithGoodsAddStock($item,$productInfo);
|
||||
$this->addMerQuota((int)$productInfo->product_id, (float)$item['mer_quota_title'], (float)$item['mer_quota_other']);
|
||||
}else{
|
||||
// 商品不存在
|
||||
$this->stockWithGoodsCopy($item,$withGoodsMerId);
|
||||
|
|
@ -104,6 +106,9 @@ class WineProductRepository extends BaseRepository{
|
|||
->value('mer_labels');
|
||||
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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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'];
|
||||
if($order->activity_type == 35){
|
||||
// 酒道馆进货商品确认收货 复制商品||增加库存
|
||||
Log::info('订单进入待评价 - 酒道馆进货商品处理 - 开始: '.var_export([
|
||||
'order_id' => $order->order_id,
|
||||
'with_goods_mer_id' => $order->with_goods_mer_id,
|
||||
'activity_type' => $order->activity_type
|
||||
],1));
|
||||
// Log::info('订单进入待评价 - 酒道馆进货商品处理 - 开始: '.var_export([
|
||||
// 'order_id' => $order->order_id,
|
||||
// 'with_goods_mer_id' => $order->with_goods_mer_id,
|
||||
// 'activity_type' => $order->activity_type
|
||||
// ],1));
|
||||
app()->make(WineProductRepository::class)->stockWithGoodsInit($order->order_id, $order->with_goods_mer_id);
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
Loading…
Reference in New Issue