修复一些错误
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Recon;
|
||||
use App\Exceptions\RepositoryException;
|
||||
use App\Models\BillModel;
|
||||
use App\Models\PaymentModel;
|
||||
use App\Models\StoreModel;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -112,6 +113,19 @@ class PaymentController extends BaseController
|
||||
'paid_operator_id' => $auditorId,
|
||||
'pay_remark' => $methodName . '(支付单号 ' . $payment->payment_no . ')',
|
||||
]);
|
||||
|
||||
// 按门店累加总采购金额(只统计商品金额,不含配送费/附加金额)
|
||||
foreach ($bills->groupBy('store_id')->sortKeys() as $storeId => $storeBills) {
|
||||
$amount = '0';
|
||||
foreach ($storeBills as $storeBill) {
|
||||
$amount = bcadd($amount, (string) $storeBill->product_amount, 2);
|
||||
}
|
||||
$store = StoreModel::query()->lockForUpdate()->find((int) $storeId);
|
||||
if ($store !== null) {
|
||||
$store->total_purchase_amount = bcadd((string) $store->total_purchase_amount, $amount, 2);
|
||||
$store->save();
|
||||
}
|
||||
}
|
||||
$payment->status = PaymentModel::STATUS_APPROVED;
|
||||
} else {
|
||||
// 拒绝:释放账单,门店可重新发起付款
|
||||
|
||||
Reference in New Issue
Block a user