From ade19e00cce3928568225359391eb5f31a863ebd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 6 Dec 2023 10:57:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E5=8D=95=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/listener/SendGoodsCode.php | 38 ------------------ app/listener/paySuccess.php | 69 +++++++++++++++++++++++++-------- crmeb/jobs/SendGoodsCodeJob.php | 37 ------------------ 3 files changed, 52 insertions(+), 92 deletions(-) diff --git a/app/listener/SendGoodsCode.php b/app/listener/SendGoodsCode.php index 0b753b11..afedb671 100644 --- a/app/listener/SendGoodsCode.php +++ b/app/listener/SendGoodsCode.php @@ -21,47 +21,9 @@ class SendGoodsCode $logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']); //生成用户的收货码 $this->generateLogisticsCode($this->event['uid'], $this->event['order_id'], $this->event['order_sn'], $logisticsPhone); - //记录订单收货地址记录 - $this->recordOrderAddr($this->event); } } - //订单收货记录 - public function recordOrderAddr($order) { - //province_code . city_code . district_code . street_code . village_code . brigade_id; - //设置地址信息 - $addressInfo = explode(',', $order['user_address_code'] ?? ''); - $productOrder = [ - 'uid' => $order['uid'] ?? 0, - 'order_id' => $order['order_id'] ?? 0, - 'province_code' => $addressInfo[0] ?? '', - 'city_code' => $addressInfo[1] ?? '', - 'district_code' => $addressInfo[2] ?? '', - 'street_code' => $addressInfo[3] ?? '', - 'village_code' => $addressInfo[4] ?? '', - 'brigade_id' => $addressInfo[5] ?? 0, - 'status' => 1, - 'create_time' => date('Y-m-d H:i:s') - ]; - //商品信息 - $productInfo = Db::name('store_order_product')->where('order_id', $order['order_id'] ?? 0)->find(); - if ($productInfo) { - $productOrder['product_id'] = $productInfo['product_id'] ?? 0; - $productOrder['product_price'] = $productInfo['product_price'] ?? 0; - $productOrder['total_price'] = $productInfo['total_price'] ?? 0; - $productOrder['product_num'] = $productInfo['product_num'] ?? 0; - } - //商户信息 - $merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find(); - if ($merchantInfo) { - $productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0; - $productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0; - $productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0; - $productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0; - } - Db::name('ProductOrderLog')->insert($productOrder); - } - //用户收货码 public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) { $code = random_int(1000, 9999); diff --git a/app/listener/paySuccess.php b/app/listener/paySuccess.php index c6aac938..edc64b4b 100644 --- a/app/listener/paySuccess.php +++ b/app/listener/paySuccess.php @@ -30,31 +30,66 @@ class paySuccess public function handle($event) { - try{ + try { $orderList = $event['groupOrder']['orderList']; foreach ($orderList as $k => $order) { $merchant = Merchant::find($order['mer_id']); //添加到代发订单表里 - if($merchant['type_id']==Merchant::TypeSupplyChain){ - $codes=explode(',',$order['user_address_code']); - if(count($codes)>4){ - $merchant_two= Db::name('merchant')->where('street_id',$codes[3])->where('type_id',17)->where('category_id',$merchant['category_id'])->find(); - if($merchant_two){ - $datas=[ - 'master_mer_id'=>$order['mer_id'], - 'mer_id'=>$merchant_two['mer_id'], - 'order_id'=>$order['order_id'], - 'status'=>0 - ]; - Db::name('store_order_behalf')->insert($datas); - } - + if ($merchant['type_id'] == Merchant::TypeSupplyChain) { + $codes = explode(',', $order['user_address_code']); + if (count($codes) > 4) { + $merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find(); + if ($merchant_two) { + $datas = [ + 'master_mer_id' => $order['mer_id'], + 'mer_id' => $merchant_two['mer_id'], + 'order_id' => $order['order_id'], + 'status' => 0 + ]; + Db::name('store_order_behalf')->insert($datas); + } } } + $this->recordOrderAddr($order); } - }catch(\Exception $e){ - Log::error('支付后逻辑报错:'.$e->getMessage().'lien:'.$e->getLine()); + } catch (\Exception $e) { + Log::error('支付后逻辑报错:' . $e->getMessage() . 'lien:' . $e->getLine()); } + } + //商品订单日志 + public function recordOrderAddr($order) + { + try { + + $addressInfo = explode(',', $order['user_address_code'] ?? ''); + $productOrder = [ + 'uid' => $order['uid'] ?? 0, + 'order_id' => $order['order_id'] ?? 0, + 'province_code' => $addressInfo[0] ?? '', + 'city_code' => $addressInfo[1] ?? '', + 'district_code' => $addressInfo[2] ?? '', + 'street_code' => $addressInfo[3] ?? '', + 'village_code' => $addressInfo[4] ?? '', + 'brigade_id' => $addressInfo[5] ?? 0, + 'product_id' => 0, + 'product_price' => 0, + 'total_price' => $order['pay_price'] ?? 0, + 'product_num' => $order['total_num'] ?? 0, + 'status' => 1, + 'create_time' => date('Y-m-d H:i:s') + ]; + //商户信息 + $merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find(); + if ($merchantInfo) { + $productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0; + $productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0; + $productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0; + $productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0; + } + Db::name('ProductOrderLog')->insert($productOrder); + } catch (\Exception $e) { + Log::error('写入商品订单日志报错:' . $e->getMessage() . 'lien:' . $e->getLine()); + } } } diff --git a/crmeb/jobs/SendGoodsCodeJob.php b/crmeb/jobs/SendGoodsCodeJob.php index 21aac5ac..e8c7a209 100644 --- a/crmeb/jobs/SendGoodsCodeJob.php +++ b/crmeb/jobs/SendGoodsCodeJob.php @@ -35,8 +35,6 @@ class SendGoodsCodeJob implements JobInterface $logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']); //生成用户的收货码 $this->generateLogisticsCode($this->event['uid'], $this->event['order_id'], $this->event['order_sn'], $logisticsPhone); - //记录订单收货地址记录 - $this->recordOrderAddr($this->event); } } catch (\Exception $e) { Log::info('sendGoodsCodeJob 异常:' . $e->getMessage()); @@ -44,41 +42,6 @@ class SendGoodsCodeJob implements JobInterface $job->delete(); } - //订单收货记录 - public function recordOrderAddr($order) { - //province_code . city_code . district_code . street_code . village_code . brigade_id; - //设置地址信息 - $addressInfo = explode(',', $order['user_address_code'] ?? ''); - $productOrder = [ - 'uid' => $order['uid'] ?? 0, - 'order_id' => $order['order_id'] ?? 0, - 'province_code' => $addressInfo[0] ?? '', - 'city_code' => $addressInfo[1] ?? '', - 'district_code' => $addressInfo[2] ?? '', - 'street_code' => $addressInfo[3] ?? '', - 'village_code' => $addressInfo[4] ?? '', - 'brigade_id' => $addressInfo[5] ?? 0, - 'product_id' => 0, - 'product_price' => 0, - 'total_price' => $order['pay_price'] ?? 0, - 'product_num' => $order['total_num'] ?? 0, - 'status' => 1, - 'create_time' => date('Y-m-d H:i:s') - ]; - //商品信息 - $productInfo = Db::name('store_order_product')->where('order_id', $order['order_id'] ?? 0)->find(); - if ($productInfo) { - } - //商户信息 - $merchantInfo = Db::name('merchant')->where('mer_id', $order['mer_id'] ?? 0)->find(); - if ($merchantInfo) { - $productOrder['mer_id'] = $merchantInfo['mer_id'] ?? 0; - $productOrder['mer_category_id'] = $merchantInfo['category_id'] ?? 0; - $productOrder['mer_type_id'] = $merchantInfo['type_id'] ?? 0; - $productOrder['is_trader'] = $merchantInfo['is_trader'] ?? 0; - } - Db::name('ProductOrderLog')->insert($productOrder); - } //用户收货码 public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {