【修复】订单号生成bug
This commit is contained in:
parent
49f02b26a7
commit
18f9eb8751
|
|
@ -44,15 +44,10 @@ Trait OrderCreateTool
|
||||||
*/
|
*/
|
||||||
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 . $member_id . sprintf('%03d', $max_no);
|
|
||||||
Cache::set($site_id . '_' . $member_id . '_' . $time_str, $max_no);
|
|
||||||
return $order_no;
|
return $order_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue