|
|
@@ -188,20 +188,24 @@ class CustomClass extends BaseClass
|
|
|
$settleId = $set->id;
|
|
|
}
|
|
|
|
|
|
- $lastBalance = bcsub($custom->balance, $amount, 2);
|
|
|
- $custom->balance = $lastBalance;
|
|
|
+ $customBalance = bcsub($custom->balance, $amount, 2);
|
|
|
+ $custom->balance = $customBalance;
|
|
|
if ($custom->balance < 0) {
|
|
|
$custom->isDebt = 1;
|
|
|
}
|
|
|
$custom->save();
|
|
|
|
|
|
- $remain = bcsub($hd->balance, $amount, 2);
|
|
|
- $hd->balance = $remain;
|
|
|
+ $hdBalance = bcsub($hd->balance, $amount, 2);
|
|
|
+ $hd->balance = $hdBalance;
|
|
|
if ($hd->balance < 0) {
|
|
|
$hd->debt = 2;
|
|
|
}
|
|
|
$hd->save();
|
|
|
|
|
|
+ if (floatval($customBalance) != floatval($hdBalance)) {
|
|
|
+ util::fail('余额有错,请联系管理员,编号' . $hdId);
|
|
|
+ }
|
|
|
+
|
|
|
$relateId = $order->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
@@ -218,14 +222,14 @@ class CustomClass extends BaseClass
|
|
|
'onlinePay' => $onlinePay,
|
|
|
'capitalType' => $capitalType,
|
|
|
'amount' => $amount,
|
|
|
- 'balance' => $lastBalance,
|
|
|
+ 'balance' => $customBalance,
|
|
|
'io' => 0,
|
|
|
'side' => $side,
|
|
|
'payWay' => $payWay,
|
|
|
'event' => $event,
|
|
|
'staffId' => $staffId,
|
|
|
'staffName' => $staffName,
|
|
|
- 'shopId' => $order->id,
|
|
|
+ 'shopId' => $shopId,
|
|
|
'mainId' => $order->mainId,
|
|
|
'settleId' => $settleId,
|
|
|
'settleNo' => $settleNo,
|
|
|
@@ -235,122 +239,70 @@ class CustomClass extends BaseClass
|
|
|
BalanceChangeClass::add($change, true);
|
|
|
}
|
|
|
|
|
|
- //散客申请退款,零售门店欠款金额减少
|
|
|
+ //欠款和余额支付的售后 ssh 20250803
|
|
|
public static function refundDebtAmountReduce($custom, $amount, $refund)
|
|
|
{
|
|
|
- $debtAmount = $custom->debtAmount ?? 0.00;
|
|
|
- $remain = bcsub($debtAmount, $amount, 2);
|
|
|
- if ($remain < 0) {
|
|
|
- noticeUtil::push("零售客户欠款总金额:{$custom->debtAmount} 本次退款金额:{$amount} 客户ID:{$custom->id} 超出了,编号66379", '15280215347');
|
|
|
- util::fail('操作失败,欠款金额会出现负数');
|
|
|
- }
|
|
|
- $custom->isDebt = $remain <= 0 ? 0 : 1;
|
|
|
- $custom->debtAmount = $remain;
|
|
|
- $custom->save();
|
|
|
- $relateId = $refund->id ?? 0;
|
|
|
- $customId = $custom->id ?? 0;
|
|
|
- $capitalType = dict::getDict('capitalType', 'hdRefund', 'id');
|
|
|
- $refundSn = $refund->refundSn ?? '';
|
|
|
-
|
|
|
- $change = [
|
|
|
- 'relateId' => $relateId,
|
|
|
- 'customId' => $customId,
|
|
|
- 'ptStyle' => dict::getDict('ptStyle', 'hd'),
|
|
|
- 'capitalType' => $capitalType,
|
|
|
- 'amount' => $amount,
|
|
|
- 'balance' => $remain,
|
|
|
- 'io' => 0,
|
|
|
- 'payWay' => 0,
|
|
|
- 'event' => "客户申请退款,退款单号:{$refundSn}",
|
|
|
- 'sjId' => $refund->sjId ?? 0,
|
|
|
- 'shopId' => $refund->shopId ?? 0,
|
|
|
- 'mainId' => $refund->mainId ?? 0,
|
|
|
- ];
|
|
|
- CustomDebtRecordClass::addChange($change);
|
|
|
-
|
|
|
- $mainId = $refund->mainId ?? 0;
|
|
|
- $main = MainClass::getLockById($mainId);
|
|
|
- if (empty($main)) {
|
|
|
- util::fail('没有main信息39');
|
|
|
+ $hdId = $custom->hdId ?? 0;
|
|
|
+ $hd = HdClass::getLockById($hdId);
|
|
|
+ if (empty($hd)) {
|
|
|
+ util::fail('花店信息缺失,编号520');
|
|
|
}
|
|
|
- $debt = $main->debt ?? 0;
|
|
|
- $totalRemain = bcsub($debt, $amount, 2);
|
|
|
- $main->debt = $totalRemain;
|
|
|
- $main->save();
|
|
|
-
|
|
|
- $event = $custom->name . "申请退款,退款单号:{$refundSn}";
|
|
|
- $change['balance'] = $totalRemain;
|
|
|
- $change['event'] = $event;
|
|
|
- TotalDebtChangeClass::addChange($change);
|
|
|
- }
|
|
|
|
|
|
- //客户结账欠款金额减少 ssh 20250627
|
|
|
- public static function clearDebtAmountReduce($custom, $amount, $clear)
|
|
|
- {
|
|
|
- $balance = $custom->balance ?? 0.00;
|
|
|
- $remainBalance = bcsub($balance, $amount, 2);
|
|
|
- if ($remainBalance < 0) {
|
|
|
- noticeUtil::push("零售客户欠款总金额:{$balance} 本次结账金额:{$amount} 客户ID:{$custom->id} 超出了,编号788965", '15280215347');
|
|
|
- util::fail('操作失败,结账后欠款金额会出现负数');
|
|
|
+ $customBalance = bcadd($custom->balance, $amount, 2);
|
|
|
+ $custom->balance = $customBalance;
|
|
|
+ if ($custom->balance < 0) {
|
|
|
+ $custom->isDebt = 1;
|
|
|
}
|
|
|
- $custom->balance = $remainBalance;
|
|
|
$custom->save();
|
|
|
|
|
|
- $hdId = $custom->hdId ?? 0;
|
|
|
- $hd = HdClass::getLockById($hdId);
|
|
|
- if (empty($hd)) {
|
|
|
- util::fail('店铺信息异常');
|
|
|
+ $hdBalance = bcadd($hd->balance, $amount, 2);
|
|
|
+ $hd->balance = $hdBalance;
|
|
|
+ if ($hd->balance < 0) {
|
|
|
+ $hd->debt = 2;
|
|
|
}
|
|
|
- $hdName = $hd->name ?? '';
|
|
|
- $hdBalance = $hd->balance ?? 0;
|
|
|
- $hdRemainBalance = bcsub($hdBalance, $amount, 2);
|
|
|
- $hd->balance = $hdRemainBalance;
|
|
|
$hd->save();
|
|
|
|
|
|
- if (floatval($hdRemainBalance) != floatval($remainBalance)) {
|
|
|
- util::fail('余额有问题');
|
|
|
+ if (floatval($customBalance) !== floatval($hdBalance)) {
|
|
|
+ util::fail('余额错误,请联系管理员,编号' . $hdId);
|
|
|
}
|
|
|
|
|
|
- $relateId = $clear->id ?? 0;
|
|
|
+ $relateId = $refund->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
- $capitalType = dict::getDict('capitalType', 'hdXsClear', 'id');
|
|
|
- $orderSn = $clear->orderSn ?? '';
|
|
|
+ $refundSn = $refund->refundSn ?? '';
|
|
|
+ $orderSn = $refund->orderSn ?? '';
|
|
|
+ $orderId = $refund->orderId ?? 0;
|
|
|
+ $staffId = $refund->shopAdminId ?? 0;
|
|
|
+ $staffName = $refund->shopAdminName ?? '';
|
|
|
+ $capitalType = dict::getDict('capitalType', 'hdRefund', 'id');
|
|
|
+ $event = "订单售后 " . $refundSn;
|
|
|
$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;
|
|
|
+ $onlinePay = 1;
|
|
|
+ $side = 0;
|
|
|
+ $payWay = 2;//余额支付
|
|
|
$change = [
|
|
|
'customId' => $customId,
|
|
|
'customName' => $customName,
|
|
|
- 'hdId' => $hdId,
|
|
|
- 'hdName' => $hdName,
|
|
|
'relateId' => $relateId,
|
|
|
- 'onlinePay' => 1,
|
|
|
+ 'relateSn' => $refundSn,
|
|
|
+ 'onlinePay' => $onlinePay,
|
|
|
'capitalType' => $capitalType,
|
|
|
'amount' => $amount,
|
|
|
- 'balance' => $hdRemainBalance,
|
|
|
- 'io' => 0,
|
|
|
- 'side' => 0,
|
|
|
+ 'balance' => $customBalance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => $side,
|
|
|
'payWay' => $payWay,
|
|
|
'event' => $event,
|
|
|
'staffId' => $staffId,
|
|
|
'staffName' => $staffName,
|
|
|
- 'shopId' => $shopId,
|
|
|
- 'mainId' => $mainId,
|
|
|
- 'remark' => $remark,
|
|
|
+ 'shopId' => $refund->shopId,
|
|
|
+ 'mainId' => $refund->mainId,
|
|
|
+ 'refundOrderId' => $orderId,
|
|
|
+ 'refundOrderSn' => $orderSn,
|
|
|
+ 'remark' => '',
|
|
|
];
|
|
|
BalanceChangeClass::add($change, true);
|
|
|
}
|
|
|
|
|
|
- public static function getCustomCacheKey($sjId, $shopId, $userId)
|
|
|
- {
|
|
|
- return 'hd_custom_key_' . $sjId . '_' . $shopId . '_' . $userId;
|
|
|
- }
|
|
|
-
|
|
|
//添加客户 ssh 2021.2.28
|
|
|
public static function addCustom($data)
|
|
|
{
|
|
|
@@ -486,19 +438,4 @@ class CustomClass extends BaseClass
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
- //更新客户信息 ssh 2021.3.23
|
|
|
- public static function updateCustomInfo($custom, $data)
|
|
|
- {
|
|
|
- $userId = $custom['userId'];
|
|
|
- $userData = [];
|
|
|
- if (!empty($data['mobile'])) {
|
|
|
- $userData['mobile'] = $data['mobile'];
|
|
|
- }
|
|
|
- if (!empty($userData)) {
|
|
|
- UserClass::updateById($userId, $userData);
|
|
|
- }
|
|
|
- $id = $custom['id'];
|
|
|
- self::updateById($id, $data);
|
|
|
- }
|
|
|
-
|
|
|
}
|