From 9b06c4ffa2b4c44998b251f3036b3877bc1306e6 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 21 Aug 2020 10:28:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89ordernum=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Request/OrderOnlineRequest.php | 1 - app/Service/OrderService.php | 21 +++++++++------------ app/Service/OrderServiceInterface.php | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/Request/OrderOnlineRequest.php b/app/Request/OrderOnlineRequest.php index 019cc99..b02144f 100644 --- a/app/Request/OrderOnlineRequest.php +++ b/app/Request/OrderOnlineRequest.php @@ -20,7 +20,6 @@ class OrderOnlineRequest extends BaseFormRequest public function rules(): array { return [ - 'order_num' => 'nonempty', 'delivery_no' => '', 'dada_fee' => 'nonempty', 'market_id' => 'required|nonempty|integer', diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index 3eab4a9..10a9936 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -40,17 +40,14 @@ class OrderService implements OrderServiceInterface { bcscale(6); - - // 订单判重 $dataMain = $data; - if ($orderMainId = $this->existsByOrderNum($data['order_num'])) { - return $orderMainId; - } - Db::beginTransaction(); try { + // TODO 这个字段后续可能不用了,之前由达达订单号从前端传上来 + $dataMain['order_num'] = 'o'.date('YmdHis').mt_rand(1000,9999); + // 计算当前订单可用红包优惠金额 $couponMoney = 0; $receiveCouponIds = []; @@ -403,7 +400,7 @@ class OrderService implements OrderServiceInterface 'code' => $globalRrderId, 'jj_note' => '', 'uniacid' => 2, - 'order_num' => 'dm'.date('YmdHis', time()) . rand(1111, 9999), + 'order_num' => 'dm'.date('YmdHis') . mt_rand(1000, 9999), 'money' => $data['money'], 'user_id' => $data['user_id'], 'store_ids' => $data['store_id'], @@ -417,7 +414,7 @@ class OrderService implements OrderServiceInterface // 子订单模型保存 $dataChild = [ 'uniacid' => 1, - 'order_num' => 's'.date('YmdHis', time()) . rand(1111, 9999), + 'order_num' => 's'.date('YmdHis') . mt_rand(1000, 9999), 'user_id' => $orderMain->user_id, 'store_id' => $data['store_id'], 'order_main_id' => $orderMainId, @@ -526,11 +523,11 @@ class OrderService implements OrderServiceInterface /** * 订单是否存在 - * @param $orderNum - * @return \Hyperf\Utils\HigherOrderTapProxy|mixed|void|null + * @param $global_order_id + * @return mixed|void|null */ - public function existsByOrderNum($orderNum) + public function existsByGlobalOrderId($global_order_id) { - return OrderMain::query()->where(['order_num' => $orderNum])->value('id'); + return OrderMain::query()->where(['order_num' => $global_order_id])->value('id'); } } \ No newline at end of file diff --git a/app/Service/OrderServiceInterface.php b/app/Service/OrderServiceInterface.php index 0d5e0a2..f059a31 100644 --- a/app/Service/OrderServiceInterface.php +++ b/app/Service/OrderServiceInterface.php @@ -21,9 +21,9 @@ interface OrderServiceInterface /** * 订单是否已经存在 - * @param $orderNum + * @param $global_order_id * @return mixed */ - public function existsByOrderNum($orderNum); + public function existsByGlobalOrderId($global_order_id); } \ No newline at end of file