|
|
@@ -152,47 +152,55 @@ class CustomClass extends BaseClass
|
|
|
public static function cgDebtAmountAdd($custom, $order)
|
|
|
{
|
|
|
$amount = $order->remainDebtPrice ?? 0;
|
|
|
- $custom->isDebt = 1;
|
|
|
- $lastDebt = bcadd($custom->debtAmount, $amount, 2);
|
|
|
- $custom->debtAmount = $lastDebt;
|
|
|
+ $lastBalance = bcsub($custom->balance, $amount, 2);
|
|
|
+ $custom->balance = $lastBalance;
|
|
|
+ if ($custom->balance < 0) {
|
|
|
+ $custom->isDebt = 1;
|
|
|
+ }
|
|
|
$custom->save();
|
|
|
|
|
|
+ $hdId = $custom->hdId ?? 0;
|
|
|
+ $hd = HdClass::getLockById($hdId);
|
|
|
+ if (empty($hd)) {
|
|
|
+ util::fail('花店信息缺失');
|
|
|
+ }
|
|
|
+ $remain = bcsub($hd->balance, $amount, 2);
|
|
|
+ $hd->balance = $remain;
|
|
|
+ if ($hd->balance < 0) {
|
|
|
+ $hd->debt = 2;
|
|
|
+ }
|
|
|
+ $hd->save();
|
|
|
+
|
|
|
+ $staffId = $order->shopAdminId ?? 0;
|
|
|
+ $staffName = $order->shopAdminName ?? '';
|
|
|
$relateId = $order->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
$capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
|
|
|
- $event = '购买花材,订单号:' . $orderSn;
|
|
|
-
|
|
|
+ $event = '购买花材,单号:' . $orderSn;
|
|
|
+ $customName = $custom->name ?? '';
|
|
|
+ $onlinePay = 1;
|
|
|
+ $side = 0;
|
|
|
+ $payWay = 0;
|
|
|
$change = [
|
|
|
- 'relateId' => $relateId,
|
|
|
'customId' => $customId,
|
|
|
- 'ptStyle' => dict::getDict('ptStyle', 'hd'),
|
|
|
+ 'customName' => $customName,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => $onlinePay,
|
|
|
'capitalType' => $capitalType,
|
|
|
'amount' => $amount,
|
|
|
- 'balance' => $lastDebt,
|
|
|
- 'io' => 1,
|
|
|
- 'payWay' => $order->payWay,
|
|
|
+ 'balance' => $lastBalance,
|
|
|
+ 'io' => 0,
|
|
|
+ 'side' => $side,
|
|
|
+ 'payWay' => $payWay,
|
|
|
'event' => $event,
|
|
|
- 'sjId' => $order->sjId,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
'shopId' => $order->id,
|
|
|
'mainId' => $order->mainId,
|
|
|
+ 'remark' => '',
|
|
|
];
|
|
|
- CustomDebtRecordClass::addChange($change);
|
|
|
-
|
|
|
- $mainId = $order->mainId ?? 0;
|
|
|
- $main = MainClass::getLockById($mainId);
|
|
|
- if (empty($main)) {
|
|
|
- util::fail('没有main信息38');
|
|
|
- }
|
|
|
- $debt = $main->debt ?? 0;
|
|
|
- $remain = bcadd($debt, $amount, 2);
|
|
|
- $main->debt = $remain;
|
|
|
- $main->save();
|
|
|
-
|
|
|
- $event = $custom->name . ' 购买花材,订单号:' . $orderSn;
|
|
|
- $change['balance'] = $remain;
|
|
|
- $change['event'] = $event;
|
|
|
- TotalDebtChangeClass::addChange($change);
|
|
|
+ BalanceChangeClass::add($change, true);
|
|
|
}
|
|
|
|
|
|
//散客申请退款,零售门店欠款金额减少
|
|
|
@@ -201,7 +209,7 @@ class CustomClass extends BaseClass
|
|
|
$debtAmount = $custom->debtAmount ?? 0.00;
|
|
|
$remain = bcsub($debtAmount, $amount, 2);
|
|
|
if ($remain < 0) {
|
|
|
- noticeUtil::push("零售客户欠款总金额:{$custom->debtAmount} 本次退款金额:{$amount} 客户ID:{$custom->id} 超出了", '15280215347');
|
|
|
+ noticeUtil::push("零售客户欠款总金额:{$custom->debtAmount} 本次退款金额:{$amount} 客户ID:{$custom->id} 超出了,编号66379", '15280215347');
|
|
|
util::fail('操作失败,欠款金额会出现负数');
|
|
|
}
|
|
|
$custom->isDebt = $remain <= 0 ? 0 : 1;
|
|
|
@@ -244,53 +252,66 @@ class CustomClass extends BaseClass
|
|
|
TotalDebtChangeClass::addChange($change);
|
|
|
}
|
|
|
|
|
|
- //客户结账欠款金额减少 ssh 20220908
|
|
|
+ //客户结账欠款金额减少 ssh 20250627
|
|
|
public static function clearDebtAmountReduce($custom, $amount, $clear)
|
|
|
{
|
|
|
- $debtAmount = $custom->debtAmount ?? 0.00;
|
|
|
- $remain = bcsub($debtAmount, $amount, 2);
|
|
|
- if ($remain < 0) {
|
|
|
- noticeUtil::push("零售客户欠款总金额:{$custom->debtAmount} 本次结账金额:{$amount} 客户ID:{$custom->id} 超出了", '15280215347');
|
|
|
+ $balance = $custom->balance ?? 0.00;
|
|
|
+ $remainBalance = bcsub($balance, $amount, 2);
|
|
|
+ if ($remainBalance < 0) {
|
|
|
+ noticeUtil::push("零售客户欠款总金额:{$balance} 本次结账金额:{$amount} 客户ID:{$custom->id} 超出了,编号788965", '15280215347');
|
|
|
util::fail('操作失败,结账后欠款金额会出现负数');
|
|
|
}
|
|
|
- $custom->isDebt = $remain <= 0 ? 0 : 1;
|
|
|
- $custom->debtAmount = $remain;
|
|
|
+ $custom->balance = $remainBalance;
|
|
|
$custom->save();
|
|
|
+
|
|
|
+ $hdId = $custom->hdId ?? 0;
|
|
|
+ $hd = HdClass::getLockById($hdId);
|
|
|
+ if (empty($hd)) {
|
|
|
+ util::fail('店铺信息异常');
|
|
|
+ }
|
|
|
+ $hdName = $hd->name ?? '';
|
|
|
+ $hdBalance = $hd->balance ?? 0;
|
|
|
+ $hdRemainBalance = bcsub($hdBalance, $amount, 2);
|
|
|
+ $hd->balance = $hdRemainBalance;
|
|
|
+ $hd->save();
|
|
|
+
|
|
|
+ if (floatval($hdRemainBalance) != floatval($remainBalance)) {
|
|
|
+ util::fail('余额有问题');
|
|
|
+ }
|
|
|
+
|
|
|
$relateId = $clear->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
$capitalType = dict::getDict('capitalType', 'hdXsClear', 'id');
|
|
|
$orderSn = $clear->orderSn ?? '';
|
|
|
-
|
|
|
+ $customName = $custom->name ?? '';
|
|
|
+ $event = "结账,单号:{$orderSn}";
|
|
|
+ $staffId = $clear->hdShopAdminId ?? 0;
|
|
|
+ $staffName = $clear->hdShopAdminName ?? '';
|
|
|
+ $shopId = $clear->hdShopId ?? 0;
|
|
|
+ $mainId = $clear->mainId ?? 0;
|
|
|
+ $remark = '';
|
|
|
+ $payWay = $clear->payWay ?? 0;
|
|
|
$change = [
|
|
|
- 'relateId' => $relateId,
|
|
|
'customId' => $customId,
|
|
|
- 'ptStyle' => dict::getDict('ptStyle', 'ghs'),
|
|
|
+ 'customName' => $customName,
|
|
|
+ 'hdId' => $hdId,
|
|
|
+ 'hdName' => $hdName,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => 1,
|
|
|
'capitalType' => $capitalType,
|
|
|
'amount' => $amount,
|
|
|
- 'balance' => $remain,
|
|
|
+ 'balance' => $hdRemainBalance,
|
|
|
'io' => 0,
|
|
|
- 'payWay' => 0,
|
|
|
- 'event' => "结账,单号:{$orderSn}",
|
|
|
- 'sjId' => $clear->sjId,
|
|
|
- 'shopId' => $clear->id,
|
|
|
- 'mainId' => $clear->mainId,
|
|
|
+ 'side' => 0,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'remark' => $remark,
|
|
|
];
|
|
|
- CustomDebtRecordClass::addChange($change);
|
|
|
-
|
|
|
- $mainId = $clear->mainId ?? 0;
|
|
|
- $main = MainClass::getLockById($mainId);
|
|
|
- if (empty($main)) {
|
|
|
- util::fail('没有main信息40');
|
|
|
- }
|
|
|
- $debt = $main->debt ?? 0;
|
|
|
- $totalRemain = bcsub($debt, $amount, 2);
|
|
|
- $main->debt = $totalRemain;
|
|
|
- $main->save();
|
|
|
-
|
|
|
- $event = $custom->name . " 结账,单号:{$orderSn}";
|
|
|
- $change['balance'] = $totalRemain;
|
|
|
- $change['event'] = $event;
|
|
|
- TotalDebtChangeClass::addChange($change);
|
|
|
+ BalanceChangeClass::add($change, true);
|
|
|
}
|
|
|
|
|
|
public static function getCustomCacheKey($sjId, $shopId, $userId)
|
|
|
@@ -313,7 +334,7 @@ class CustomClass extends BaseClass
|
|
|
if (empty($shop)) {
|
|
|
return false;
|
|
|
}
|
|
|
- if($shop->ptStyle == 2){
|
|
|
+ if ($shop->ptStyle == 2) {
|
|
|
util::fail('有问题,批发店状态');
|
|
|
}
|
|
|
$salt = stringUtil::charsShuffleLowerCase(8);
|