From f40f180d8ea8086e5fbc40c01daa56e9d6b3092d Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 7 Jun 2024 17:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E5=95=86=E6=88=B7?= =?UTF-8?q?=E8=BF=9B=E8=B4=A7=E5=A4=8D=E5=88=B6=E5=95=86=E5=93=81=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BB=91=E5=AE=9A=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E5=93=81=E7=89=8C=E9=A2=9D=E5=BA=A6=E5=8F=8A=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/product/WineProductRepository.php | 26 ++++++++++++++++++- app/listener/exchangeQuota/OrderTakeEvent.php | 10 +++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/common/repositories/store/product/WineProductRepository.php b/app/common/repositories/store/product/WineProductRepository.php index 3325a21..a6351eb 100644 --- a/app/common/repositories/store/product/WineProductRepository.php +++ b/app/common/repositories/store/product/WineProductRepository.php @@ -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(); + } + } + diff --git a/app/listener/exchangeQuota/OrderTakeEvent.php b/app/listener/exchangeQuota/OrderTakeEvent.php index 3b35e7f..05f5f7d 100644 --- a/app/listener/exchangeQuota/OrderTakeEvent.php +++ b/app/listener/exchangeQuota/OrderTakeEvent.php @@ -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{