【修复】订单号生成bug

This commit is contained in:
liqianjin 2023-07-21 18:07:18 +08:00
parent 77f6f91cda
commit 49f02b26a7
10 changed files with 37 additions and 74 deletions

View File

@ -228,15 +228,10 @@ class BlindboxOrder extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }

View File

@ -808,15 +808,10 @@ class GiftCard extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }

View File

@ -254,15 +254,10 @@ class GiftCardOrderCreate extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . '_' . $member_id . '_' . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1; $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . sprintf('%05d', $member_id) . sprintf('%03d', $max_no);
Cache::set($site_id . '_' . $member_id . '_' . $time_str, $max_no);
return $order_no; return $order_no;
} }
} }

View File

@ -584,15 +584,10 @@ class OrderCreate extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }

View File

@ -137,15 +137,10 @@ class OrderCreate extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }
} }

View File

@ -86,15 +86,10 @@ class WeappletReg extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }
} }

View File

@ -242,15 +242,10 @@ class MemberLevelOrder extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }

View File

@ -281,15 +281,10 @@ class OrderCommon extends BaseModel
*/ */
public function createOrderNo($site_id) public function createOrderNo($site_id)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . '_' . $time_str); $max_no = Cache::handler()->incr($site_id . "__" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "__" . $time_str,120);
$max_no = 1; $order_no = $time_str . sprintf("%03d", $max_no);
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . sprintf('%04d', $max_no);
Cache::set($site_id . '_' . $time_str, $max_no);
return $order_no; return $order_no;
} }
/**********************************************************************************订单操作基础方法(订单关闭,订单完成,订单调价)开始********/ /**********************************************************************************订单操作基础方法(订单关闭,订单完成,订单调价)开始********/

View File

@ -382,15 +382,10 @@ class OrderCreate extends BaseModel
*/ */
public function createOrderNo($site_id, $member_id = 0) public function createOrderNo($site_id, $member_id = 0)
{ {
$time_str = date('YmdHi'); $time_str = date('YmdHis');
$max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1);
if (!isset($max_no) || empty($max_no)) { Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120);
$max_no = 1;
} else {
$max_no = $max_no + 1;
}
$order_no = $time_str . $member_id . sprintf("%03d", $max_no); $order_no = $time_str . $member_id . sprintf("%03d", $max_no);
Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no);
return $order_no; return $order_no;
} }

View File

@ -14,6 +14,8 @@
namespace app\pay\controller; namespace app\pay\controller;
use app\Controller; use app\Controller;
use addon\aliapp\model\CloudPay; use addon\aliapp\model\CloudPay;
use app\model\order\OrderCreate;
class LqjTest extends Controller class LqjTest extends Controller
{ {
@ -91,4 +93,10 @@ class LqjTest extends Controller
var_dump($res); var_dump($res);
} }
} }
public function testCreateOrderNo(){
$BlindboxOrderCreateModel = new OrderCreate();
echo $BlindboxOrderCreateModel->createOrderNo(1,2);
exit();
}
} }