diff --git a/app/Model/v3/OrderMain.php b/app/Model/v3/OrderMain.php index fa61000..99ccb29 100644 --- a/app/Model/v3/OrderMain.php +++ b/app/Model/v3/OrderMain.php @@ -58,7 +58,8 @@ class OrderMain extends Model 'pay_time_text', 'pay_type_text', 'shipping_type_text', - 'complete_time_text' + 'complete_time_text', + 'delivery_time_text', ]; protected $casts = [ @@ -85,6 +86,11 @@ class OrderMain extends Model return date('Y-m-d H:i:s', $this->attributes['complete_time']); } + public function getDeliveryTimeTextAttribute() + { + return date('Y-m-d H:i:s', $this->attributes['delivery_time']); + } + public function getStateTextAttribute() { if ($this->attributes['state'] == OrderState::DELIVERY) { diff --git a/app/Service/v3/Implementations/MiniprogramService.php b/app/Service/v3/Implementations/MiniprogramService.php index a8074bd..db845bc 100644 --- a/app/Service/v3/Implementations/MiniprogramService.php +++ b/app/Service/v3/Implementations/MiniprogramService.php @@ -36,7 +36,7 @@ class MiniprogramService implements MiniprogramServiceInterface $order = OrderMain::query()->where(['global_order_id' => $globalOrderId])->first()->toArray(); $payTypes = ['1' => '微信支付', '2' => '余额支付', '3' => '积分支付', '4' => '货到付款']; - $address_store = $order['address'] . ';' .$order['name']. ';'. substr_replace($order['tel'],'****',3,4); + $address_store = $order['address'] . ';' .$order['name']. ';'. mb_substr_replace($order['tel'],'****',3,4); $address = $order['address'] . ';' .$order['name']. ';'. $order['tel']; // 查询子订单,用于发消息给商户 @@ -56,8 +56,8 @@ class MiniprogramService implements MiniprogramServiceInterface $goods_temp = []; foreach ($order_goods as $k => &$goods) { - array_push($goods_temp, $goods['name']."*".$goods['number']."/".($goods['goods_unit'])); - array_push($goods_temp_all, $goods['name']."*".$goods['number']."/".($goods['goods_unit'])); + array_push($goods_temp, $goods['name']."*".$goods['number']); + array_push($goods_temp_all, $goods['name']."*".$goods['number']); } // 商户/门店的openid @@ -93,9 +93,9 @@ class MiniprogramService implements MiniprogramServiceInterface [ 'amount1' => $item->money, 'character_string2' => $item->order_num, - 'date3' => $item->created_at_text??'', - 'thing4' => implode(";", $goods_temp_all), - 'thing7' => $item->note?:'无备注', + 'date3' => $item->created_at_text?:date('Y-m-d H:i:s'), + 'thing4' => mb_substr(implode(";", $goods_temp_all),0,18).'..', + 'thing7' => mb_substr(($item->note?:'无备注'), 0, 18).'..', ], $page ); @@ -167,10 +167,10 @@ class MiniprogramService implements MiniprogramServiceInterface $tmplId, [ 'amount1' => $item['money'], - 'thing2' => $store['name'], - 'thing3' => Payment::getMessage($orderMain->pay_type), + 'thing2' => mb_substr($store['name'], 0, 18).'..', + 'thing3' => mb_substr(Payment::getMessage($orderMain->pay_type), 0, 18).'..', 'character_string4' => $item['order_num'], - 'time5' => $item['created_at_text']??'', + 'time5' => $item['created_at_text']??date('Y-m-d H:i:s'), ], $page ); @@ -224,10 +224,10 @@ class MiniprogramService implements MiniprogramServiceInterface $tmplId, [ 'character_string7' => $order->order_num, - 'thing10' => implode(';', $goodsInfo), + 'thing10' => mb_substr(implode(';', $goodsInfo),0,18).'..', 'amount3' => $refundStoreAmount, - 'date4' => $order->updated_at_text ?? '', - 'thing5' => $note ?: '退款', + 'date4' => $order->updated_at_text ?? date('Y-m-d H:i:s'), + 'thing5' => mb_substr($note ?: '退款', 0, 18).'..', ], $page ); @@ -245,8 +245,8 @@ class MiniprogramService implements MiniprogramServiceInterface } // 订单商品 - $orderIds = Order::query()->where(['order_main_id' => $globalOrderId])->pluck('id'); - $goodsInfo = OrderGoods::query()->whereIn('order_id', $orderIds)->pluck('name'); + $orderIds = Order::query()->where(['order_main_id' => $globalOrderId])->pluck('id')->toArray(); + $goodsInfo = OrderGoods::query()->whereIn('order_id', $orderIds)->pluck('name')->toArray(); // 骑手信息 $horseman = Employees::query()->where(['id' => $orderMain->horseman_id])->whereJsonContains('position', [(string)Employee::TYPE_HORSEMAN])->first(); @@ -261,8 +261,8 @@ class MiniprogramService implements MiniprogramServiceInterface $userTmplId, [ 'character_string6' => $orderMain->global_order_id, - 'thing8' => implode(';', $goodsInfo), - 'thing7' => $horseman->name.'(电话:'.$horseman->tel.')', + 'thing8' => mb_substr(implode(';', $goodsInfo), 0, 18).'..', + 'thing7' => mb_substr(($horseman->name.'|电话'.$horseman->tel), 0, 18).'..', 'date3' => $orderMain->updated_at_text ?? '', 'thing4' => '骑手开始配送,请您耐心等待,感谢使用!', ], @@ -274,15 +274,24 @@ class MiniprogramService implements MiniprogramServiceInterface $horsemanTmplId = '6gxjnBZ4bLnaMC0g8wRaP46jGUZU7YqfYb1FPpJVr50'; $horsemanPage = 'pages/deliverymanOrdersDetail/deliverymanOrdersDetail?global_order_id=' . $globalOrderId . '&employees_id=' . $horseman->id; $horsemanOpenid = User::query()->where(['id' => $horseman->user_id])->value('openid'); + $deliveryNote = $orderMain->delivery_start_time ? date('Y-m-d H:i:s', $orderMain->delivery_start_time+1800) : date('Y-m-d H:i:s', time()+1800); + + if (strpos($orderMain->delivery_time_note, ' - ') !== false) { + $arr = explode(' - ', $orderMain->delivery_time_note); + if (is_array($arr) && isset($arr[0]) && $arr[0]) { + $deliveryNote = date('Y-m-d').' '.$orderMain->delivery_time_note.':00'; + } + } + $this->sendSubscribeMessage( $horsemanOpenid, $horsemanTmplId, [ 'character_string1' => $orderMain->global_order_id, - 'thing8' => implode(';', $goodsInfo), - 'thing9' => $orderMain->name . ' - ' . $orderMain->address . '(电话:'.$orderMain->tel.')', - 'time17' => $orderMain->delivery_time_note ?? '尽快送达', - 'thing4' => '后台已经派发此订单给您,请注意及时取货配送,您可以点击订单详情查看,辛苦了!', + 'thing8' => mb_substr(implode(';', $goodsInfo),0,18).'..', + 'thing9' => mb_substr(($orderMain->name.'|'.$orderMain->tel.'|'.$orderMain->address), 0, 18).'..', + 'time17' => $deliveryNote, + 'thing11' => '有新配送订单,请注意及时取货,辛苦了!', ], $horsemanPage ); @@ -317,9 +326,9 @@ class MiniprogramService implements MiniprogramServiceInterface [ 'character_string2' => $orderMain->global_order_id, 'amount5' => $orderMain->money, - 'thing3' => $orderMain->name . ' - ' . $orderMain->address . '(电话:'.$orderMain->tel.')', - 'thing4' => $horseman->name.'(电话:'.$horseman->tel.')', - 'time6' => date('Y-m-d H:i:s', $orderMain->complete_time_text), + 'thing3' => mb_substr(($orderMain->name.'|'.$orderMain->tel.'|'.$orderMain->address),0,18).'..', + 'thing4' => mb_substr($horseman->name.'|电话'.$horseman->tel, 0, 18).'..', + 'time6' => $orderMain->delivery_time_text?:date('Y-m-d H:i:s'), ], $userPage );