更新发送物流细节
This commit is contained in:
parent
78ee12fb0e
commit
a02db34d4d
@ -19,52 +19,19 @@ class DeliveryGoods
|
|||||||
$this->event = $event;
|
$this->event = $event;
|
||||||
Log::info("============= handle监听order_id " . $this->event['order']['order_id']);
|
Log::info("============= handle监听order_id " . $this->event['order']['order_id']);
|
||||||
$this->event = $event;
|
$this->event = $event;
|
||||||
//发起物流信息返回快递员手机
|
//发生短信包含收货码
|
||||||
$logisticsPhone = $this->sendLogistics($this->event['order']['order_id'], $this->event['order']['order_sn']);
|
$this->sendLogisticsCode($this->event['order']['uid'], $this->event['order']['order_id'], $this->event['order']['order_sn'], $logisticsPhone);
|
||||||
//生成用户的收货码、发生短信包含收货码
|
|
||||||
$this->generateLogisticsCode($this->event['order']['uid'], $this->event['order']['order_id'], $this->event['order']['order_sn'], $logisticsPhone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//用户收货码
|
public function sendLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {
|
||||||
public function generateLogisticsCode($uid, $orderId, $orderSn, $logisticsPhone) {
|
|
||||||
$code = random_int(1000, 9999);
|
|
||||||
$res = app()->make(StoreOrderRepository::class)->update($orderId, [
|
|
||||||
'logistics_code' => $code
|
|
||||||
]);
|
|
||||||
if ($res) {
|
|
||||||
//收货人短信
|
//收货人短信
|
||||||
$phone = StoreOrder::where('order_id', $orderId)->value('user_phone');
|
$phone = StoreOrder::where('order_id', $orderId)->value('user_phone');
|
||||||
|
$logisticsCode = StoreOrder::where('order_id', $orderId)->value('logistics_code');
|
||||||
|
$logisticsPhone = StoreOrder::where('order_id', $orderId)->value('logistics_phone');
|
||||||
if ($phone) {
|
if ($phone) {
|
||||||
Log::info("发送短信 {$phone}, orderId: {$orderId}");
|
Log::info("发送短信 {$phone}, orderId: {$orderId}");
|
||||||
SmsService::create()->send($phone, 'TAKEGOOD_CODE', ['number' => substr($orderSn, -6), 'number2' => $code, 'phone' => $logisticsPhone]);
|
SmsService::create()->send($phone, 'TAKEGOOD_CODE', ['number' => substr($orderSn, -6), 'number2' => $logisticsCode, '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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -136,9 +136,48 @@ class paySuccessOrder
|
|||||||
}
|
}
|
||||||
Log::error('订单分润出错', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]);
|
Log::error('订单分润出错', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]);
|
||||||
DingTalk::exception($e, '订单分润出错');
|
DingTalk::exception($e, '订单分润出错');
|
||||||
|
//发起物流信息返回快递员手机
|
||||||
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户收货码
|
||||||
|
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)
|
public function calculate($type, $field)
|
||||||
{
|
{
|
||||||
$merId = Db::name('merchant')->where('type_id', $type)
|
$merId = Db::name('merchant')->where('type_id', $type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user