|
|
@@ -841,6 +841,7 @@ class ShopController extends BaseController {
|
|
|
}
|
|
|
if (!$order['INVOICE_NO']) {
|
|
|
$invoiceNo = $this->generateInvoiceNo();
|
|
|
+ LoggerTool::debug('生成发票号:' . $invoiceNo);
|
|
|
Order::updateAll(['INVOICE_NO' => $invoiceNo], 'SN = :SN', [':SN' => $orderSn]);
|
|
|
}
|
|
|
|
|
|
@@ -1163,13 +1164,13 @@ class ShopController extends BaseController {
|
|
|
->orderBy(['INVOICE_NO' => SORT_DESC])
|
|
|
->one();
|
|
|
|
|
|
- if ($order && !empty($order->INVOICE_NO)) {
|
|
|
+ if (!$order || !$order->INVOICE_NO) {
|
|
|
+ // 如果今天没有生成过发票号或没有符合条件的订单,从00001开始
|
|
|
+ $no = '00001';
|
|
|
+ } else {
|
|
|
$invoiceNo = $order->INVOICE_NO;
|
|
|
// 截取最后5位数字部分并+1
|
|
|
$no = sprintf('%05d', intval(substr($invoiceNo, -5)) + 1);
|
|
|
- } else {
|
|
|
- // 如果今天没有生成过发票号或没有符合条件的订单,从00001开始
|
|
|
- $no = '00001';
|
|
|
}
|
|
|
|
|
|
return $prefix . $currentDate . $no;
|