From 49f02b26a7a96dbec7790d99835f5da755b7b0b2 Mon Sep 17 00:00:00 2001 From: liqianjin <949671634@qq.com> Date: Fri, 21 Jul 2023 18:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=B7=E7=94=9F=E6=88=90bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/blindbox/model/BlindboxOrder.php | 11 +++-------- addon/giftcard/model/GiftCard.php | 11 +++-------- addon/giftcard/model/order/GiftCardOrderCreate.php | 13 ++++--------- addon/pointexchange/model/OrderCreate.php | 11 +++-------- addon/saasagent/model/OrderCreate.php | 11 +++-------- addon/saasagent/model/WeappletReg.php | 11 +++-------- addon/supermember/model/MemberLevelOrder.php | 11 +++-------- app/model/order/OrderCommon.php | 13 ++++--------- app/model/order/OrderCreate.php | 11 +++-------- app/pay/controller/LqjTest.php | 8 ++++++++ 10 files changed, 37 insertions(+), 74 deletions(-) diff --git a/addon/blindbox/model/BlindboxOrder.php b/addon/blindbox/model/BlindboxOrder.php index 8d3ada3f..cb907bb3 100644 --- a/addon/blindbox/model/BlindboxOrder.php +++ b/addon/blindbox/model/BlindboxOrder.php @@ -228,15 +228,10 @@ class BlindboxOrder extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } diff --git a/addon/giftcard/model/GiftCard.php b/addon/giftcard/model/GiftCard.php index 11ba9d23..7c4382a4 100644 --- a/addon/giftcard/model/GiftCard.php +++ b/addon/giftcard/model/GiftCard.php @@ -808,15 +808,10 @@ class GiftCard extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } diff --git a/addon/giftcard/model/order/GiftCardOrderCreate.php b/addon/giftcard/model/order/GiftCardOrderCreate.php index f76a3e31..31f043b4 100644 --- a/addon/giftcard/model/order/GiftCardOrderCreate.php +++ b/addon/giftcard/model/order/GiftCardOrderCreate.php @@ -254,15 +254,10 @@ class GiftCardOrderCreate extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . '_' . $member_id . '_' . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } 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); + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); + $order_no = $time_str . $member_id . sprintf("%03d", $max_no); return $order_no; } } diff --git a/addon/pointexchange/model/OrderCreate.php b/addon/pointexchange/model/OrderCreate.php index 98acbb7e..754c53bd 100644 --- a/addon/pointexchange/model/OrderCreate.php +++ b/addon/pointexchange/model/OrderCreate.php @@ -584,15 +584,10 @@ class OrderCreate extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } diff --git a/addon/saasagent/model/OrderCreate.php b/addon/saasagent/model/OrderCreate.php index 99046822..657af5cd 100644 --- a/addon/saasagent/model/OrderCreate.php +++ b/addon/saasagent/model/OrderCreate.php @@ -137,15 +137,10 @@ class OrderCreate extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } } \ No newline at end of file diff --git a/addon/saasagent/model/WeappletReg.php b/addon/saasagent/model/WeappletReg.php index 425a4036..95bf8f0a 100644 --- a/addon/saasagent/model/WeappletReg.php +++ b/addon/saasagent/model/WeappletReg.php @@ -86,15 +86,10 @@ class WeappletReg extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } } \ No newline at end of file diff --git a/addon/supermember/model/MemberLevelOrder.php b/addon/supermember/model/MemberLevelOrder.php index c2ca05a1..0f6793eb 100644 --- a/addon/supermember/model/MemberLevelOrder.php +++ b/addon/supermember/model/MemberLevelOrder.php @@ -242,15 +242,10 @@ class MemberLevelOrder extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } diff --git a/app/model/order/OrderCommon.php b/app/model/order/OrderCommon.php index 683537aa..e57efe83 100644 --- a/app/model/order/OrderCommon.php +++ b/app/model/order/OrderCommon.php @@ -281,15 +281,10 @@ class OrderCommon extends BaseModel */ public function createOrderNo($site_id) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . '_' . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } - $order_no = $time_str . sprintf('%04d', $max_no); - Cache::set($site_id . '_' . $time_str, $max_no); + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "__" . $time_str,1); + Cache::handler()->expire($site_id . "__" . $time_str,120); + $order_no = $time_str . sprintf("%03d", $max_no); return $order_no; } /**********************************************************************************订单操作基础方法(订单关闭,订单完成,订单调价)开始********/ diff --git a/app/model/order/OrderCreate.php b/app/model/order/OrderCreate.php index bd5171e0..458c5853 100644 --- a/app/model/order/OrderCreate.php +++ b/app/model/order/OrderCreate.php @@ -382,15 +382,10 @@ class OrderCreate extends BaseModel */ public function createOrderNo($site_id, $member_id = 0) { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . "_" . $member_id . "_" . $time_str); - if (!isset($max_no) || empty($max_no)) { - $max_no = 1; - } else { - $max_no = $max_no + 1; - } + $time_str = date('YmdHis'); + $max_no = Cache::handler()->incr($site_id . "_" . $member_id . "_" . $time_str,1); + Cache::handler()->expire($site_id . "_" . $member_id . "_" . $time_str,120); $order_no = $time_str . $member_id . sprintf("%03d", $max_no); - Cache::set($site_id . "_" . $member_id . "_" . $time_str, $max_no); return $order_no; } diff --git a/app/pay/controller/LqjTest.php b/app/pay/controller/LqjTest.php index a55140fa..d52cf0eb 100644 --- a/app/pay/controller/LqjTest.php +++ b/app/pay/controller/LqjTest.php @@ -14,6 +14,8 @@ namespace app\pay\controller; use app\Controller; use addon\aliapp\model\CloudPay; +use app\model\order\OrderCreate; + class LqjTest extends Controller { @@ -91,4 +93,10 @@ class LqjTest extends Controller var_dump($res); } } + + public function testCreateOrderNo(){ + $BlindboxOrderCreateModel = new OrderCreate(); + echo $BlindboxOrderCreateModel->createOrderNo(1,2); + exit(); + } } \ No newline at end of file