Browse Source

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

林琦海 5 years ago
parent
commit
62daf9ad44

+ 0 - 5
app-mall/controllers/BaseController.php

@@ -68,9 +68,7 @@ class BaseController extends PublicController
                 util::fail('没有用户信息');
             }
             $this->user = $userInfo;
-
             if (in_array($action->id, $this->guestAccess) == false) {
-
                 $custom = CustomClass::getCurrentCustom($sjId, $userInfo);
                 if (empty($custom)) {
                     util::fail('没有找到客户');
@@ -78,15 +76,12 @@ class BaseController extends PublicController
                 $this->custom = $custom;
                 $customId = $custom['id'] ?? 0;
                 $this->customId = $customId;
-
             }
-
         }
         //游客可以访问的方法
         if (in_array($action->id, $this->guestAccess)) {
             $this->validate = true;
         }
-
         if ($this->validate == false) {
             util::notLogin();
         }

+ 6 - 11
app-mall/controllers/OrderController.php

@@ -2,6 +2,7 @@
 
 namespace mall\controllers;
 
+use bizHd\wx\classes\WxOpenClass;
 use bizMall\goods\services\GoodsService;
 use bizMall\merchant\services\ExpressService;
 use bizMall\merchant\services\MerchantExtendService;
@@ -267,10 +268,7 @@ class OrderController extends BaseController
         ini_set('date.timezone', 'Asia/Shanghai');
         $post = Yii::$app->request->post();
         $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
-        $shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->sj);
-        //验证门店是否有效
-        $shopInfo = ShopService::getById($shopId);
-        ShopService::valid($shopInfo, $this->sjId);
+        $shopId = $this->shopId;
         $post['shopId'] = $shopId;
         //默认门店订单
         $store = isset($post['store']) ? $post['store'] : 1;
@@ -307,6 +305,7 @@ class OrderController extends BaseController
         $post['sourceType'] = $sourceType;
         $post['goodsNum'] = 1;
         $post['fromType'] = $fromType;
+        $post['reachDate'] = isset($post['reachDate']) && !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
         $order = OrderClass::addOrder($post);
         $orderId = $order['id'];
         $orderSn = $order['orderSn'];
@@ -343,21 +342,17 @@ class OrderController extends BaseController
             $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
             $input->SetTrade_type("JSAPI");
 
-            $sjExtend = $this->sjExtend;
-            //花卉宝代为申请的微信支付
-            //$input->SetSub_openid($openId);
+            $sjExtend = WxOpenClass::getMallWxInfo();
             $input->SetOpenid($openId);
             //小程序使用miniAppId
-            if (httpUtil::isMiniProgram()) {
-                $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
-            }
-            Yii::info('支付发起使用小程序信息' . json_encode($sjExtend));
+            $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
             $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
             $tools = new \JsApiPay();
             $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend);
             $newParams = json_decode($jsApiParameters, true);
             $newParams['orderId'] = $orderId;
             util::success($newParams);
+
         } elseif ($payWay == 1) {
             $extend = MerchantExtendService::getByMerchantId($sjId);
             if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {

+ 9 - 4
biz-mall/order/classes/OrderClass.php

@@ -2,6 +2,7 @@
 
 namespace bizMall\order\classes;
 
+use biz\shop\models\Shop;
 use bizMall\merchant\classes\MerchantAssetClass;
 use bizMall\stat\classes\StatOrderClass;
 use bizMall\stat\classes\StatOrderCountClass;
@@ -68,10 +69,14 @@ class OrderClass extends BaseClass
         $return = self::add($data);
 
         //全部订单+1,待付款订单+1
-        $merchantAsset = MerchantAssetClass::getByMerchantId($merchantId, true);
-        $merchantAsset->unPayOrder += 1;
-        $merchantAsset->totalOrder += 1;
-        $merchantAsset->save();
+        $shopId = $data['shopId'];
+        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        if (empty($shop)) {
+            util::fail('没有找到门店');
+        }
+        $shop->unPayOrder += 1;
+        $shop->totalOrder += 1;
+        $shop->save();
 
         return $return;
     }

+ 22 - 22
common/services/xhPayToolService.php

@@ -179,7 +179,7 @@ class xhPayToolService
             }
             $orderId = $order['id'];
             $orderSn = $order['orderSn'];
-            $userId = $order['userId'];
+            $userId = $order['userId'] ?? 0;
             $totalFee = $order['actPrice'];
             $merchantId = $order['merchantId'];
             $alipayId = isset($alipayParams['alipayId']) ? $alipayParams['alipayId'] : '';
@@ -236,10 +236,10 @@ class xhPayToolService
                 $userAsset = xhUserAssetService::getByUserId($userId);
             }
             if (empty($user)) {
-                util::fail('没有客户信息');
+                //util::fail('没有客户信息');
             }
 
-            $balance = $userAsset['balance'];
+            $balance = $userAsset['balance'] ?? 0;
             if ($payWay == $balancePay && $balance < $totalFee) {
                 Yii::warning('余额不足,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
                 util::fail('余额不足');
@@ -332,30 +332,30 @@ class xhPayToolService
             }
 
             //累计消费
-            $userTotalExpend = stringUtil::calcAdd($userAsset['totalExpend'], $totalFee);
+            //$userTotalExpend = stringUtil::calcAdd($userAsset['totalExpend'], $totalFee);
             //成长值增加
-            $userGrowth = $userAsset['growth'] + floor($totalFee);
-            $userTotalBuyNum = $userAsset['totalBuyNum'] + 1;
-
-            $remainBalance = $payWay == $balancePay ? stringUtil::calcSub($balance, $totalFee) : $balance;
-            $upAssetData = [];
-            $upAssetData['balance'] = $remainBalance;
-            $upAssetData['growth'] = $userGrowth;
-            $upAssetData['totalExpend'] = $userTotalExpend;
-            $upAssetData['totalBuyNum'] = $userTotalBuyNum;
-            xhUserAssetService::ioChangeAsset($user, $userAsset, $upAssetData, $merchant, $merchantExtend, $order, $capitalType);//用户资产改变
+//            $userGrowth = $userAsset['growth'] + floor($totalFee);
+//            $userTotalBuyNum = $userAsset['totalBuyNum'] + 1;
+//
+//            $remainBalance = $payWay == $balancePay ? stringUtil::calcSub($balance, $totalFee) : $balance;
+//            $upAssetData = [];
+//            $upAssetData['balance'] = $remainBalance;
+//            $upAssetData['growth'] = $userGrowth;
+//            $upAssetData['totalExpend'] = $userTotalExpend;
+//            $upAssetData['totalBuyNum'] = $userTotalBuyNum;
+            //xhUserAssetService::ioChangeAsset($user, $userAsset, $upAssetData, $merchant, $merchantExtend, $order, $capitalType);//用户资产改变
 
             $growData = [
                 'userId' => $userId,
                 'userName' => $userName,
                 'merchantId' => $merchantId,
                 'relateId' => $orderId,
-                'growth' => $userGrowth,
+                //'growth' => $userGrowth,
                 'num' => floor($totalFee),
                 'io' => 1,
                 'payWay' => $payWay,
                 'alipayId' => $alipayId,
-                'event' => $uIntegralEvent,
+                //'event' => $uIntegralEvent,
                 'operatorId' => $userId,
                 'createTime' => $date,
                 'gainType' => 1,
@@ -365,13 +365,13 @@ class xhPayToolService
 
             $userCapitalData = [
                 'relateId' => $orderId,
-                'balance' => $remainBalance,
-                'totalIncome' => $userAsset['totalIncome'],
+                //'balance' => $remainBalance,
+                'totalIncome' => $userAsset['totalIncome'] ?? 0,
                 'totalExpend' => $userTotalExpend,
                 'amount' => $totalFee,
                 'io' => 0,
                 'payWay' => $payWay,
-                'event' => $uCapitalEvent,
+                //'event' => $uCapitalEvent,
                 'merchantId' => $merchantId,
                 'userId' => $userId,
                 'alipayId' => $alipayId,
@@ -387,10 +387,10 @@ class xhPayToolService
 
             //如果是小程序支付可以获取unionId并进行更新关联
             if ($payWay == $wxWay && $wxPayType == 1) {
-                OrderClass::payToUpdateUnionId($merchant, $merchantExtend, $orderSn, $user);
+                //OrderClass::payToUpdateUnionId($merchant, $merchantExtend, $orderSn, $user);
             }
-
-            return ['balance' => $remainBalance];
+            return ['balance' => 0];
+            //return ['balance' => $remainBalance];
 
         } catch (Exception $e) {
             $transaction->rollBack();