Browse Source

余额优化

shish 5 years ago
parent
commit
29beb9d8ab

+ 5 - 7
app-ghs/controllers/RechargeController.php

@@ -38,13 +38,13 @@ class RechargeController extends BaseController
             'modPrice' => 0,
             'remark' => '',
         ];
-        $order = RechargeClass::addOrder($data);
-        $orderSn = $order['orderSn'];
-        $name = $order['orderName'] ?? '充值';
-        $totalFee = $order['amount'];
+        $order = RechargeClass::addOrder($data, true);
+        $orderSn = $order->orderSn;
+        $name = $order->orderName ?? '充值';
+        $totalFee = $order->amount;
         //强制使用小程序的miniOpenId
         $openId = $this->admin['miniOpenId'];
-        $capitalType = dict::getDict('capitalType','xhRecharge','id');
+        $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
         $wxPayType = httpUtil::isMiniProgram() ? 1 : 0;
         $attach = "couponId=0&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
@@ -65,8 +65,6 @@ class RechargeController extends BaseController
         $input->SetTrade_type("JSAPI");
 
         $merchantExtend = WxOpenClass::getGhsWxInfo();
-        //平台代为申请支付商户号时使用
-        //$input->SetSub_openid($openId);
         $input->SetOpenid($openId);
 
         //强制使用小程序的AppId

+ 12 - 18
app-hd/controllers/RechargeController.php

@@ -61,20 +61,17 @@ class RechargeController extends BaseController
             'modPrice' => 0,
             'remark' => '免费续期充值',
         ];
-        $order = RechargeClass::addOrder($data);
-        $orderSn = $order['orderSn'];
-        $name = $order['orderName'] ?? '充值';
-        $totalFee = $order['amount'];
+        $order = RechargeClass::addOrder($data, true);
+        $orderSn = $order->orderSn;
+        $name = $order->orderName ?? '充值';
+        $totalFee = $order->amount;
 
         //强制使用小程序的miniOpenId
         $openId = $this->admin['miniOpenId'];
 
-        $capitalType = dict::getDict('capitalType','xhRecharge','id');
+        $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-        $wxPayType = 0;
-        if (httpUtil::isMiniProgram()) {
-            $wxPayType = 1;
-        }
+        $wxPayType = 1;
         $attach = "couponId=0&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType . '&rechargeRenew=1';
         //订单30分钟后过期
         $now = time();
@@ -126,20 +123,17 @@ class RechargeController extends BaseController
             'modPrice' => 0,
             'remark' => '',
         ];
-        $order = RechargeClass::addOrder($data);
-        $orderSn = $order['orderSn'];
-        $name = $order['orderName'] ?? '充值';
-        $totalFee = $order['amount'];
+        $order = RechargeClass::addOrder($data, true);
+        $orderSn = $order->orderSn;
+        $name = $order->orderName ?? '充值';
+        $totalFee = $order->amount;
 
         //强制使用小程序的miniOpenId
         $openId = $this->admin['miniOpenId'];
 
-        $capitalType = dict::getDict('capitalType','xhRecharge','id');
+        $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
         //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-        $wxPayType = 0;
-        if (httpUtil::isMiniProgram()) {
-            $wxPayType = 1;
-        }
+        $wxPayType = 1;
         $attach = "couponId=0&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
         //订单30分钟后过期
         $now = time();

+ 1 - 1
biz-hd/merchant/classes/ShopClass.php

@@ -105,7 +105,7 @@ class ShopClass extends BaseClass
     }
 
     //门店增加余额 ssh 2021.2.21
-    //$fix = false 余额使用时不需要指定在谁那边
+    //$fix = true 余额只能在指定门店使
     public static function addBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
     {
         //门店余额增加

+ 2 - 2
biz/pt/classes/PtAssetClass.php

@@ -44,12 +44,12 @@ class PtAssetClass extends BaseClass
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
-            'amount' => $order->amount,
+            'amount' => $amount,
             'balance' => $currentAmount,
             'txBalance' => $currentTxBalance,
             'io' => 1,
             'payWay' => $order->payWay,
-            'event' => "商家 {$shop->merchantName} {$shop->shopName} 充值(订单:{$order->orderSn})",
+            'event' => "【{$shop->merchantName} {$shop->shopName}】充值{$amount}元(订单:{$order->orderSn})",
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
             'tx' => $tx,

+ 7 - 4
biz/recharge/classes/RechargeClass.php

@@ -26,10 +26,10 @@ class RechargeClass extends BaseClass
     }
 
     //创建订单 ssh 2021.2.21
-    public static function addOrder($data)
+    public static function addOrder($data, $returnObj = false)
     {
         $data['orderSn'] = orderSn::getRechargeSn();
-        return self::add($data);
+        return self::add($data, $returnObj);
     }
 
     //处理充值流程 ssh 2021.2.21
@@ -49,12 +49,15 @@ class RechargeClass extends BaseClass
         //门店和平台余额增加
         $tx = dict::getDict('yeTx', 'canNot');
         $capitalType = dict::getDict('capitalType', 'xhRecharge');
-        ShopClass::addBalance($shop, $amount, $recharge, $tx, $capitalType);
-
+        $fix = false;
         if ($rechargeRenew == 1) {
             $sjId = $recharge->sjId;
             SjClass::renewOneYear($sjId, 2, ['amount' => $recharge->amount, 'orderSn' => $orderSn]);
+            $fix = true;
         }
+
+        ShopClass::addBalance($shop, $amount, $recharge, $tx, $capitalType, $fix);
+
     }
 
     //第三支付后流程 shish 2021.4.27