|
|
@@ -21,8 +21,12 @@ class OrderClearClass extends BaseClass
|
|
|
public static $baseFile = '\bizGhs\order\models\OrderClear';
|
|
|
|
|
|
//使用余额自助结欠款 ssh 20240310
|
|
|
- public static function useBalanceClear($custom, $ghs)
|
|
|
+ public static function useBalanceClear($custom, $ghs, $shop, $staff)
|
|
|
{
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
$ghsId = $ghs->id ?? 0;
|
|
|
$customBalance = $custom->balance ?? 0;
|
|
|
@@ -44,15 +48,20 @@ class OrderClearClass extends BaseClass
|
|
|
return true;
|
|
|
}
|
|
|
$totalAmount = 0;
|
|
|
+ $need = [];
|
|
|
foreach ($orderList as $order) {
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
$remainDebtPrice = $order->remainDebtPrice ?? 0;
|
|
|
$totalAmount = bcadd($totalAmount, $remainDebtPrice, 2);
|
|
|
if ($totalAmount <= $customBalance) {
|
|
|
-
|
|
|
+ $need[] = ['id' => $orderId];
|
|
|
} else {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ if (empty($need)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
$where = ['customId' => $customId, 'status' => PurchaseClearClass::STATUS_AWAIT_PAY];
|
|
|
$list = OrderClearClass::getAllByCondition($where, null, '*', null, true);
|
|
|
@@ -64,6 +73,20 @@ class OrderClearClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $idText = json_encode($need);
|
|
|
+ $clearData = [
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'ghsShopAdminId' => $staffId,
|
|
|
+ 'ghsShopId' => $shopId,
|
|
|
+ 'ghsShopAdminName' => $staffName,
|
|
|
+ 'modifyPrice' => $totalAmount,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'complete' => 1,
|
|
|
+ ];
|
|
|
+ $clearInfo = self::clear($clearData, $idText, $sjId, $shopId);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//订单结算 ssh 2021.3.14
|