更新物流订单细节
This commit is contained in:
parent
5837d30284
commit
f0931c5bf2
@ -271,7 +271,9 @@ class StoreOrderRepository extends BaseRepository
|
||||
$flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//发起物流信息处理
|
||||
event('order.sendGoodsCode', $order);
|
||||
|
||||
// 商户流水账单数据
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
|
@ -66,6 +66,7 @@ return [
|
||||
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
|
||||
// 'community_address'=>[\app\listener\CommunityAddress::class],
|
||||
'order.paySuccessOrder'=>[\app\listener\paySuccessOrder::class],
|
||||
'order.sendGoodsCode'=>[\app\listener\SendGoodsCode::class],
|
||||
'product.create'=>[\app\listener\ProductCreate::class],
|
||||
'product.delivery'=>[\app\listener\DeliveryGoods::class],
|
||||
'product.sell'=>[\app\listener\CloudProduct::class], //商品上下架
|
||||
|
@ -17,7 +17,7 @@ class DeliveryGoods
|
||||
public function handle($event)
|
||||
{
|
||||
$this->event = $event;
|
||||
Log::info("============= handle监听order_id " . $this->event['order']['order_id']);
|
||||
Log::info("delivery ============= handle监听order_id " . $this->event['order']['order_id']);
|
||||
$this->event = $event;
|
||||
//发生短信包含收货码
|
||||
$this->sendLogisticsCode($this->event['order']['uid'], $this->event['order']['order_id'], $this->event['order']['order_sn']);
|
||||
|
60
app/listener/SendGoodsCode.php
Normal file
60
app/listener/SendGoodsCode.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\listener;
|
||||
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use crmeb\utils\DingTalk;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class SendGoodsCode
|
||||
{
|
||||
public $event;
|
||||
|
||||
public function handle($event)
|
||||
{
|
||||
$this->event = $event;
|
||||
Log::info("sendGoodsCode ============= handle监听order_id " . $this->event['order_id']);
|
||||
//发起物流信息返回快递员手机
|
||||
$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);
|
||||
}
|
||||
|
||||
//用户收货码
|
||||
public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {
|
||||
$code = random_int(1000, 9999);
|
||||
app()->make(StoreOrderRepository::class)->update($orderId, [
|
||||
'logistics_code' => $code,
|
||||
'logistics_phone' => $logisticsPhone
|
||||
]);
|
||||
}
|
||||
|
||||
//发送物流
|
||||
public function sendLogistics($orderId, $orderSn)
|
||||
{
|
||||
Log::info("发送物流信息 orderId: {$orderId}, orderSn: {$orderSn}");
|
||||
$postUrl = env('LOGISTICS_LOGIS_URL');
|
||||
$curlPost = [
|
||||
'order_id' => $orderId,
|
||||
'order_sn' => $orderSn,
|
||||
];
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $postUrl);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$phone = '';
|
||||
if (!empty($data) && is_string($data)) {
|
||||
$logisticsInfo = json_decode($data, true);
|
||||
$phone = $logisticsInfo['data']['phone'];
|
||||
Log::info("物流联系信息" . json_encode($logisticsInfo));
|
||||
}
|
||||
return $phone;
|
||||
}
|
||||
|
||||
}
|
@ -29,11 +29,6 @@ class paySuccessOrder
|
||||
$this->event = $event;
|
||||
$this->finance = [];
|
||||
$this->index = 1;
|
||||
//发起物流信息返回快递员手机
|
||||
$logisticsPhone = $this->sendLogistics($this->event['order']['order_id'], $this->event['order']['order_sn']);
|
||||
//生成用户的收货码
|
||||
$this->generateLogisticsCode($this->event['order']['uid'], $this->event['order']['order_id'], $this->event['order']['order_sn'], $logisticsPhone);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
|
||||
@ -144,41 +139,6 @@ class paySuccessOrder
|
||||
}
|
||||
}
|
||||
|
||||
//用户收货码
|
||||
public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {
|
||||
$code = random_int(1000, 9999);
|
||||
app()->make(StoreOrderRepository::class)->update($orderId, [
|
||||
'logistics_code' => $code,
|
||||
'logistics_phone' => $logisticsPhone
|
||||
]);
|
||||
}
|
||||
|
||||
//发送物流
|
||||
public function sendLogistics($orderId, $orderSn)
|
||||
{
|
||||
Log::info("发送物流信息 orderId: {$orderId}, orderSn: {$orderSn}");
|
||||
$postUrl = env('LOGISTICS_LOGIS_URL');
|
||||
$curlPost = [
|
||||
'order_id' => $orderId,
|
||||
'order_sn' => $orderSn,
|
||||
];
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $postUrl);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$phone = '';
|
||||
if (!empty($data) && is_string($data)) {
|
||||
$logisticsInfo = json_decode($data, true);
|
||||
$phone = $logisticsInfo['data']['phone'];
|
||||
Log::info("物流联系信息" . json_encode($logisticsInfo));
|
||||
}
|
||||
return $phone;
|
||||
}
|
||||
|
||||
public function calculate($type, $field)
|
||||
{
|
||||
$merId = Db::name('merchant')->where('type_id', $type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user