|
|
@@ -195,20 +195,8 @@ class OrderService extends BaseService
|
|
|
//欠款记录 ssh 2021.2.4
|
|
|
public static function getDebtOrderList($where)
|
|
|
{
|
|
|
- $list = OrderClass::getAllList(['id', 'orderSn', 'actPrice', 'addTime'], $where, 'addTime DESC');
|
|
|
+ $list = OrderClass::getAllList(['id', 'orderSn', 'realPrice', 'actPrice', 'addTime'], $where, 'addTime DESC');
|
|
|
$respond['list'] = $list;
|
|
|
- $respond['num'] = 0;
|
|
|
- $respond['totalAmount'] = 0.00;
|
|
|
- if (!empty($list)) {
|
|
|
- $i = 0;
|
|
|
- $amount = 0.00;
|
|
|
- foreach ($list as $key => $val) {
|
|
|
- $i++;
|
|
|
- $amount = bcadd($amount, $val['actPrice'], 2);
|
|
|
- }
|
|
|
- $respond['num'] = $i;
|
|
|
- $respond['totalAmount'] = $amount;
|
|
|
- }
|
|
|
return $respond;
|
|
|
}
|
|
|
|
|
|
@@ -405,8 +393,16 @@ class OrderService extends BaseService
|
|
|
if (isset($order->debt) == false) {
|
|
|
util::fail('订单有问题,没有欠款项');
|
|
|
}
|
|
|
+
|
|
|
+ $customId = $order->customId;
|
|
|
+ $custom = CustomClass::getLockById($customId);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('没有找到客户信息');
|
|
|
+ }
|
|
|
+
|
|
|
/**门店资产变化**/
|
|
|
$amount = $order->actPrice ?? 0.00;
|
|
|
+ $realPrice = $order->realPrice ?? 0.00;
|
|
|
$currentShopId = $order->shopId ?? 0;
|
|
|
$shop = ShopClass::getLockById($currentShopId);
|
|
|
if (empty($shop)) {
|
|
|
@@ -420,8 +416,12 @@ class OrderService extends BaseService
|
|
|
$shop->totalIncome = $currentTotalIncome;
|
|
|
if ($payWay == dict::getDict('payWay', 'debtPay')) {
|
|
|
//客户欠款支付会增加【应收客户款】
|
|
|
- $currentGathering = bcadd($shop->mayGathering, $amount, 2);
|
|
|
+ $currentGathering = bcadd($shop->mayGathering, $realPrice, 2);
|
|
|
$shop->mayGathering = $currentGathering;
|
|
|
+ //客户第一次欠款的增加一个欠款客户
|
|
|
+ if ($custom->debtNum == 0) {
|
|
|
+ $shop->mayGatheringNum += 1;
|
|
|
+ }
|
|
|
}
|
|
|
$shop->save();
|
|
|
|
|
|
@@ -451,11 +451,16 @@ class OrderService extends BaseService
|
|
|
];
|
|
|
ShopCapitalClass::addCapital($capital);
|
|
|
|
|
|
- //客户采购引起的开单,会增加余额,会增加收入
|
|
|
+ //客户采购,会增加余额,会增加收入
|
|
|
if ($isPurchase == true) {
|
|
|
//余额支付和微信支付会增加余额
|
|
|
if ($payWay == dict::getDict('payWay', 'wxPay') || $payWay == dict::getDict('payWay', 'balancePay')) {
|
|
|
- ShopClass::customKdAddBalance($shop, $amount, $order, $capitalType);
|
|
|
+ ShopClass::customKdAddBalance($shop, $realPrice, $order, $capitalType);
|
|
|
+ }
|
|
|
+ if (isset($order->discountType) && $order->discountType == dict::getDict('discountType', 'usePtCoupon')) {
|
|
|
+ //客户使用优惠券增加的余额
|
|
|
+ $theCapital = dict::getDict('capitalType', 'usePtCoupon', 'id');
|
|
|
+ ShopClass::customKdUseCouponAddBalance($shop, $order, $theCapital);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -477,15 +482,10 @@ class OrderService extends BaseService
|
|
|
StatYjClass::addYj($order);
|
|
|
|
|
|
/**客户资产变化**/
|
|
|
- $customId = $order->customId;
|
|
|
- $custom = CustomClass::getLockById($customId);
|
|
|
- if (empty($custom)) {
|
|
|
- util::fail('没有找到客户信息');
|
|
|
- }
|
|
|
if ($payWay == dict::getDict('payWay', 'debtPay')) {
|
|
|
- //欠款支付
|
|
|
+ //欠款金额
|
|
|
$custom->isDebt = CustomClass::IS_DEBT_YES;
|
|
|
- $custom->debtAmount = bcadd($custom->debtAmount, $amount, 2);
|
|
|
+ $custom->debtAmount = bcadd($custom->debtAmount, $realPrice, 2);
|
|
|
$custom->debtNum += 1;
|
|
|
}
|
|
|
$custom->buyNum += 1;
|