购物车悬浮
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Mini;
|
||||
|
||||
use App\Exceptions\RepositoryException;
|
||||
use App\Http\Requests\Mini\MiniOrderRequest;
|
||||
use App\Models\BillModel;
|
||||
use App\Models\CartModel;
|
||||
use App\Models\CustomerLevelModel;
|
||||
use App\Models\ProductModel;
|
||||
@@ -37,6 +38,26 @@ class OrderController extends BaseMiniController
|
||||
throw new RepositoryException('门店未设置客户等级,无法下单,请联系客服');
|
||||
}
|
||||
|
||||
// 回款周期校验:存在逾期未回款账单(未支付即拦截,含审核中)时禁止下单
|
||||
// 周期 0 天=立即结清:任何未回款账单(含当天)都拦截;周期 N≥1:账单日 + N 天 < 今天(超过回款周期)才拦截
|
||||
$cycleDays = (int) $store->payment_cycle_days;
|
||||
$overdueQuery = BillModel::query()
|
||||
->where('store_id', $store->id)
|
||||
->where('status', BillModel::STATUS_UNPAID);
|
||||
if ($cycleDays > 0) {
|
||||
$overdueQuery->whereDate('bill_date', '<', now()->subDays($cycleDays)->toDateString());
|
||||
}
|
||||
$overdue = $overdueQuery
|
||||
->selectRaw('COUNT(*) as aggregate_count, COALESCE(SUM(total_amount), 0) as aggregate_amount')
|
||||
->first();
|
||||
if ((int) $overdue->aggregate_count > 0) {
|
||||
$amountText = bcadd((string) $overdue->aggregate_amount, '0', 2);
|
||||
throw new RepositoryException($cycleDays > 0
|
||||
? '您有 ' . (int) $overdue->aggregate_count . ' 笔账单已超过回款周期未回款(合计 ¥' . $amountText . '),请先结清后再下单'
|
||||
: '您有 ' . (int) $overdue->aggregate_count . ' 笔账单未回款(合计 ¥' . $amountText . '),回款周期为当日结清,请先结清后再下单'
|
||||
);
|
||||
}
|
||||
|
||||
$items = $request->validated('items');
|
||||
$remark = (string) ($request->validated('remark') ?? '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user