修改用户收货地址

This commit is contained in:
wucongxing 2023-04-12 13:34:05 +08:00
parent 2b48b9cc9e
commit 189dc54d55
5 changed files with 64 additions and 16 deletions

View File

@ -57,45 +57,72 @@ class ReportPreProductOrderCommand extends HyperfCommand
}
foreach ($order_product_ids as $item){
$this->line("本次请求订单号:" . $item['order_product_id']);
Db::beginTransaction();
$redis_key = "ReportPreProductOrder" . $item['order_product_id'];
// 处理超出最大执行次数/退款问题
try {
$redis_value = $redis->get($redis_key);
$redis->incr($redis_key);
if(!empty($redis_value)){
// 超出最大执行次数
if ($redis_value > 2){
if ($redis_value >= 2){
// 存储上报失败
$this->savaReportFail($item['order_product_id']);
$this->savaReportFail($item['order_product_id'],"超出最大上报次数");
// 修改失败时药品订单数据
$this->savePreFailedOrderStatus($item['order_product_id'],"复核失败");
// 退款
$this->line("超出最大执行次数,执行退款");
$OrderProductService = new OrderProductService();
$OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款");
}
}
// 上报处方平台
$orderPrescriptionService = new OrderPrescriptionService();
$orderPrescriptionService->reportPrescription($item['order_product_id']);
// 存储上报成功
$this->savaReportSuccess($item['order_product_id']);
// 清空缓存
$redis->del($redis_key);
Db::commit();
continue;
}
}
Db::commit();
} catch (\Exception $e) {
Db::rollBack();
// 记录失败次数
$this->line("商品订单上报处方平台失败:失败原因" . $e->getMessage());
}
// 处理上报处方平台问题
try {
// 上报处方平台
$orderPrescriptionService = new OrderPrescriptionService();
$res = $orderPrescriptionService->reportPrescription($item['order_product_id']);
if (!$res){
// 上报失败
$this->line("上报失败");
continue;
}
// 存储上报成功
$this->savaReportSuccess($item['order_product_id']);
Db::commit();
} catch (\Exception $e) {
Db::rollBack();
// 记录失败次数
$redis->incr($redis_key);
$this->line("商品订单上报处方平台失败:商品单号" . $item['order_product_id'] . " 失败原因:" . $e->getMessage());
$this->savaReportFail($item['order_product_id'],$e->getMessage());
$this->line("商品订单上报处方平台失败:失败原因" . $e->getMessage());
}
$this->line("商品订单上报处方平台成功:商品单号" . $item['order_product_id']);
// 清空缓存
$redis->del($redis_key);
$this->line("商品订单上报处方平台成功");
}
$this->line("商品订单上报处方平台全部结束");
}
/**
@ -157,4 +184,22 @@ class ReportPreProductOrderCommand extends HyperfCommand
$data['report_pre_fail_reason'] = ""; // 上报失败原因 置为空
OrderProduct::edit($params,$data);
}
/**
* 修改失败时药品订单数据
* @param string $order_product_id
* @param string $cancel_remarks
*/
protected function savePreFailedOrderStatus(string $order_product_id,string $cancel_remarks)
{
// 订单状态1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
$params = array();
$params['order_product_id'] = $order_product_id;
$data['order_product_status'] = 5;
$data['cancel_reason'] = 2; // 订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
$data['cancel_time'] = date('Y-m-d H:i:s'); // 订单取消时间
$data['cancel_remarks'] = $cancel_remarks; // 订单取消备注(自动添加)
OrderProduct::edit($params,$data);
}
}

View File

@ -45,8 +45,11 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
$this->line("获取处方平台订单数据结束,无可执行的商品订单");
return;
}
// dump($order_product_ids);die;
foreach ($order_product_ids as $item) {
if ($item['order_product_id'] != "504371738743726081"){
continue;
}
Db::beginTransaction();
$this->line("本次请求订单号:" . $item['order_product_id']);

View File

@ -64,7 +64,7 @@ class UserRequest extends FormRequest
'consignee_name' => 'required',
'consignee_tel' => 'required',
'is_default' => ['required','numeric','min:0','max:1'],
// 'tag' => ['sometimes','required','numeric','min:1','max:4'],
'tag' => ['sometimes','required','numeric','min:1','max:4'],
];
}

View File

@ -207,17 +207,17 @@ class OrderProductService extends BaseService
}
// 检测商品订单退款状态
if ($order_product['order_product_status'] == 2){
if ($order_product['refund_status'] == 2){
// 商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
throw new BusinessException("订单退款中");
}
if ($order_product['order_product_status'] == 3){
if ($order_product['refund_status'] == 3){
// 商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
throw new BusinessException("订单已退款成功");
}
if ($order_product['order_product_status'] == 5){
if ($order_product['refund_status'] == 5){
// 商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
throw new BusinessException("订单退款关闭");
}

View File

@ -367,7 +367,7 @@ class UserService extends BaseService
$data['consignee_tel'] = $request_params['consignee_tel'];
$data['consignee_tel_mask'] = Mask::maskPhoneStr($request_params['consignee_tel']);
$data['is_default'] = $request_params['is_default'];
$data['tag'] = $request_params['tag'] ?? "";
$data['tag'] = $request_params['tag'] ?? 4;
$user_ship_address = UserShipAddress::addUserShipAddress($data);
if (empty($user_ship_address)) {
Db::rollBack();