Browse Source

订单号由24位改为22位

dev
李可松 4 years ago
parent
commit
ab660d4084
  1. 6
      MySQL_change.sql
  2. 2
      app/Http/Controllers/Api/OrderController.php
  3. 8
      app/Http/Controllers/Api/WxpayController.php

6
MySQL_change.sql

@ -10,7 +10,6 @@ ALTER TABLE `users`
ALTER TABLE `agents`
ADD COLUMN `type` TINYINT NOT NULL DEFAULT '0' COMMENT '1、计调版旅行社;2、供应商旅行社;3、组团版旅行社' AFTER `remember_token`;
#################################################################
# 23:25 2021/08/17
ALTER TABLE `agent_products`
ADD COLUMN `guide_id` INT NOT NULL DEFAULT 0 COMMENT '绑定地接(组团版旅行社才能绑定)' AFTER `category_id`;
@ -85,3 +84,8 @@ ENGINE=InnoDB
ALTER TABLE `agent_products`
ADD COLUMN `stock` INT(10) NOT NULL DEFAULT '0' COMMENT '库存' AFTER `sale`;
#################################################################
# 10:42 ‎2021/‎08/‎21
ALTER TABLE `orders`
CHANGE COLUMN `order_no` `order_no` CHAR(22) NOT NULL COMMENT '订单号' COLLATE 'utf8_general_ci' AFTER `agent_id`;

2
app/Http/Controllers/Api/OrderController.php

@ -387,6 +387,6 @@ class OrderController extends Controller
{
list($micro, $sec) = explode(' ', microtime());
$micro = str_pad(floor($micro * 1000000), 6, 0, STR_PAD_LEFT);
return date('YmdHis', $sec) . $micro . mt_rand(1000, 9999);
return date('ymdHis', $sec) . $micro . mt_rand(1000, 9999);
}
}

8
app/Http/Controllers/Api/WxpayController.php

@ -33,8 +33,8 @@ class WxpayController
$this->log($message);
// 请求成功
if ($message['return_code'] === 'SUCCESS') {
//订单号带有status后缀,主要是为了区分定金支付和尾款支付,前24位才是真正的订单号
$order_no = substr($message['out_trade_no'], 0, 24);
//主要是为了区分定金支付和尾款支付,订单号带有-status后缀,分割后前面才是真正的订单号
list($order_no, $status) = explode('-', $message['out_trade_no']);
$order = Order::query()
->where(['order_no' => $order_no])
->first();
@ -142,8 +142,8 @@ class WxpayController
$this->log(['message' => $message, 'reqInfo' => $reqInfo], 'refund');
// 请求成功
if ($message['return_code'] === 'SUCCESS') {
//订单号带有status后缀,主要是为了区分定金支付和尾款支付,前24位才是真正的订单号
$order_no = substr($reqInfo['out_trade_no'], 0, 24);
//主要是为了区分定金支付和尾款支付,订单号带有-status后缀,分割后前面才是真正的订单号
list($order_no, $status) = explode('-', $message['out_trade_no']);
$order = Order::query()
->where(['order_no' => $order_no])
->first();

Loading…
Cancel
Save