订单配送订阅消息参数有误修改
修改文件:app\services\order\StoreOrderDeliveryServices
修改方法:doDelivery()
public function doDelivery(int $id, $orderInfo, array $data)
{
$type = (int)$data['type'];
unset($data['type']);
//获取购物车内的商品标题
/** @var StoreOrderCartInfoServices $orderInfoServices */
$orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
$storeName = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo['id']);
//修改返回数据
$res = [];
switch ($type) {
case 1://快递发货
$res = $this->orderDeliverGoods($id, $data, $orderInfo, $storeName);
if (isset($res['kuaidinum']) && $res['kuaidinum']) {
$data['delivery_id'] = $res['kuaidinum'];
}
break;
case 2://配送
$data['delivery_name'] = $data['sh_delivery_name'];
$data['delivery_id'] = $data['sh_delivery_id'];
$data['delivery_uid'] = $data['sh_delivery_uid'];
$this->orderDelivery($id, $data, $orderInfo);
break;
case 3://虚拟发货
$this->orderVirtualDelivery($id, $data);
break;
case 4://门店收银订单自动发货
$this->dao->update($orderInfo['id'], ['delivery_type' => 'cashier']);
/** @var StoreOrderStatusServices $statusService */
$statusService = app()->make(StoreOrderStatusServices::class);
$statusService->save([
'oid' => $orderInfo['id'],
'change_type' => 'delivery_cashier',
'change_message' => '门店收银台核销',
'change_time' => time()
]);
break;
default:
throw new ValidateException('暂时不支持其他发货类型');
}
//跟新完成后重新赋值订单信息
$orderInfo = $this->dao->get($id, ['*'], ['pink']);
event('order.delivery', [$orderInfo, $storeName, $data, $type]);
return $res;
}
修改文件:app\services\order\StoreOrderDeliveryServices
修改方法:orderDelivery()
public function orderDelivery(int $id, array $data, $orderInfo = [])
{
$delivery_type = $data['delivery_type'] ?? 1;
$delivery_type = $delivery_type ? $delivery_type : 1;
$station_type = $data['station_type'] ?? 1;
unset($data['delivery_type'], $data['station_type']);
switch ($delivery_type) {
case 1://自己配送
if (!$data['delivery_name']) {
throw new ValidateException('请输入送货人姓名');
}
if (!$data['delivery_id']) {
throw new ValidateException('请输入送货人电话号码');
}
if (!$data['delivery_uid']) {
throw new ValidateException('请输入送货人信息');
}
if (!check_phone($data['delivery_id'])) {
throw new ValidateException('请输入正确的送货人电话号码');
}
//获取核销码
/** @var StoreOrderCreateServices $storeOrderCreateService */
$storeOrderCreateService = app()->make(StoreOrderCreateServices::class);
$data['verify_code'] = $storeOrderCreateService->getStoreCode();
$data['delivery_type'] = 'send';
break;
case 2://第三方配送
if (!isset($data['cargo_weight']) || !$data['cargo_weight']) {
throw new ValidateException('请填写配送商品重量');
}
$data['delivery_type'] = 'city_delivery';
/** @var StoreDeliveryOrderServices $storeDeliverOrderServices */
$storeDeliverOrderServices = app()->make(StoreDeliveryOrderServices::class);
$storeDeliverOrderServices->create($id, $data, $station_type, $orderInfo);
break;
}
$data['status'] = 1;
unset($data['sh_delivery_name'], $data['sh_delivery_id'], $data['sh_delivery_uid'], $data['delivery_remark']);
/** @var StoreOrderStatusServices $services */
$services = app()->make(StoreOrderStatusServices::class);
$this->transaction(function () use ($id, $data, $services, $delivery_type, $station_type) {
//修改订单发货信息
$this->dao->update($id, $data);
if ($delivery_type == 1) {
$message = '已配送 发货人:' . $data['delivery_name'] . ' 发货人电话:' . $data['delivery_id'];
} else {
$message = '已'. ($station_type == 1 ? '达达' : 'UU跑腿') .'同城配送';
}
//记录订单状态
$services->save([
'oid' => $id,
'change_type' => $delivery_type == 1 ? 'delivery' : 'city_delivery',
'change_time' => time(),
'change_message' => $message
]);
});
return true;
}