shish 5 vuotta sitten
vanhempi
commit
176fee1941

+ 3 - 1
app-pt/controllers/ShopYeChangeController.php

@@ -19,7 +19,9 @@ class ShopYeChangeController extends BaseController
         $tx = $get['tx'] ?? dict::getDict('yeTx', 'canNot');
         $where = [];
         $where['shopId'] = $shopId;
-        $where['tx'] = $tx;
+        if(!empty($tx)){
+            $where['tx'] = $tx;
+        }
         $list = ShopYeChangeClass::getChangeList($where);
         util::success($list);
     }

+ 50 - 0
biz/pt/classes/PtAssetClass.php

@@ -60,6 +60,56 @@ class PtAssetClass extends BaseClass
         PtYeChangeClass::addChange($change, true);
     }
 
+    //客户使用优惠券增加余额 shish 20210601
+    public static function customKdUseCouponAddBalance($shop, $order, $capitalType, $tx)
+    {
+        $amount = $order->discountAmount;
+        $ptStyle = $shop->ptStyle;
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $asset = self::getHdBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $asset = self::getGhsBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentAmount = bcadd($asset->amount, $amount, 2);
+        $asset->amount = $currentAmount;
+        $asset->save();
+
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $txAsset = self::getHdTxBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $txAsset = self::getGhsTxBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentTxBalance = $txAsset->amount;
+
+        $currentTxBalance = bcadd($currentTxBalance, $amount, 2);
+        $txAsset->amount = $currentTxBalance;
+        $txAsset->save();
+
+        $id = $order->id;
+        $event = "【{$shop->merchantName} {$shop->shopName}】的客户下单 使用平台优惠券{$amount}元 订单号:{$order->orderSn}";
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentAmount,
+            'txBalance' => $currentTxBalance,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'sjId' => $order->sjId,
+            'shopId' => $order->shopId,
+            'tx' => $tx,
+            'ptStyle' => $ptStyle,
+            'shopName' => $shop->shopName,
+            'sjName' => $shop->merchantName,
+        ];
+        PtYeChangeClass::addChange($change, true);
+    }
+
     //平台余额增加 shish 20210519
     public static function rechargeAddBalance($shop, $amount, $order, $capitalType, $tx)
     {

+ 1 - 1
biz/shop/classes/ShopClass.php

@@ -213,7 +213,7 @@ class ShopClass extends BaseClass
         ShopYeChangeClass::addChange($change, true);
 
         //平台余额增加
-        PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
+        PtAssetClass::customKdUseCouponAddBalance($shop, $order, $capitalType, $tx);
     }
 
     //客户下单引起的余额增加 shish 20210520