修改用户收货地址

This commit is contained in:
2023-04-12 13:34:05 +08:00
parent 2b48b9cc9e
commit 189dc54d55
5 changed files with 64 additions and 16 deletions
+55 -10
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'],"药品订单退款");
// 清空缓存
$redis->del($redis_key);
Db::commit();
continue;
}
}
Db::commit();
} catch (\Exception $e) {
Db::rollBack();
// 记录失败次数
$this->line("商品订单上报处方平台失败:失败原因" . $e->getMessage());
}
// 处理上报处方平台问题
try {
// 上报处方平台
$orderPrescriptionService = new OrderPrescriptionService();
$orderPrescriptionService->reportPrescription($item['order_product_id']);
$res = $orderPrescriptionService->reportPrescription($item['order_product_id']);
if (!$res){
// 上报失败
$this->line("上报失败");
continue;
}
// 存储上报成功
$this->savaReportSuccess($item['order_product_id']);
// 清空缓存
$redis->del($redis_key);
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);
}
}