shish 5 vuotta sitten
vanhempi
commit
ccf77e9324

+ 19 - 24
app-ghs/controllers/RenewController.php

@@ -7,6 +7,7 @@ use biz\sj\services\MerchantService;
 use bizHd\saas\services\RenewService;
 use bizHd\saas\services\SetMealService;
 use bizHd\user\services\UserService;
+use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\httpUtil;
 use common\components\util;
@@ -25,26 +26,24 @@ class RenewController extends BaseController
     //微信支付购买 ssh 2020.1.11
     public function actionWxPay()
     {
-        util::fail('即将开通...');
         ini_set('date.timezone', 'Asia/Shanghai');
-        $merchantId = Yii::$app->request->get('merchantId', 0);
-        $merchant = MerchantService::getMerchantById($merchantId);
-        if (empty($merchant)) {
-            util::fail('没有找到商家');
-        }
-        $setId = isset($merchant['setId']) ? $merchant['setId'] : 0;
+        $sj = $this->sj;
+        $setId = isset($sj['setId']) ? $sj['setId'] : 0;
         $set = SetMealService::getById($setId);
         if (empty($set)) {
             util::fail('没有找到套餐');
         }
-        $userId = $this->userId;
-        $addData['userId'] = $userId;
+        $shopAdminId = $this->shopAdminId;
+        $addData['shopAdminId'] = $shopAdminId;
+        $shopAdmin = $this->shopAdmin;
+        $adminName = $shopAdmin['name'] ?? '';
+        $addData['shopAdminName'] = $adminName;
         $price = $set['price'];
         $prePrice = $price;
         $actPrice = $price;
         $addData['actPrice'] = $actPrice;
         $addData['prePrice'] = $prePrice;
-        $addData['merchantId'] = $merchantId;
+        $addData['merchantId'] = $this->sjId;
         $now = time();
         $expireTime = $now + 300;//订单5分钟后过期
         $addData['deadline'] = $expireTime;
@@ -54,15 +53,11 @@ class RenewController extends BaseController
         $couponId = 0;
         $name = $set['name'] . '开通续费';
         $totalFee = $actPrice;
-        $userId = $addData['userId'];
-        $user = UserService::getById($userId);
+        $admin = $this->admin;
         //小程序使用miniOpenId
-        if (httpUtil::isMiniProgram()) {
-            $openId = $user['miniOpenId'];
-        } else {
-            $openId = $user['openId'];
-        }
-        $capitalType = dict::getDict('capitalType','xhRenew','id');
+        $openId = $admin['miniOpenId'];
+
+        $capitalType = dict::getDict('capitalType', 'xhRenew', 'id');
         $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId;//将流水类型、优惠卷传过去
         $wx = Yii::getAlias("@vendor/weixin");
         require_once($wx . '/lib/WxPay.Api.php');
@@ -78,23 +73,23 @@ class RenewController extends BaseController
         $input->SetTrade_type("JSAPI");
 
         //花卉宝代为申请的微信支付
-        $merchantExtend = MerchantExtendService::getByMerchantId($this->sjId);
-        if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
+        $sjExtend = WxOpenClass::getGhsWxInfo();
+        if (isset($sjExtend['wxPayApply']) && $sjExtend['wxPayApply'] == 1) {
             $input->SetSub_openid($openId);
         } else {
             $input->SetOpenid($openId);
         }
         //小程序使用miniAppId
         if (httpUtil::isMiniProgram()) {
-            $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+            $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
         }
 
-        $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
+        $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
         $tools = new \JsApiPay();
-        $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
+        $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend);
         $newParams = json_decode($jsApiParameters, true);
         $newParams['orderId'] = $orderId;
-        $newParams['merchantId'] = $merchantId;
+        $newParams['merchantId'] = $this->sjId;
         util::success($newParams);
     }
 

+ 4 - 0
app-ghs/controllers/ShopAdminController.php

@@ -58,6 +58,10 @@ class ShopAdminController extends BaseController
                 util::fail('您已经是别的商家员工');
             }
         }
+        $openShop = $admin['openShop'] ?? AdminClass::OPEN_SHOP_NO;
+        if ($openShop != AdminClass::OPEN_SHOP_NO) {
+            util::fail('您已申请开过店,不能成为别人的员工');
+        }
         $respond = ShopAdminService::generateAdmin($post);
         util::success($respond);
     }

+ 15 - 21
app-hd/controllers/RenewController.php

@@ -7,6 +7,7 @@ use biz\sj\services\MerchantService;
 use bizHd\saas\services\RenewService;
 use bizHd\saas\services\SetMealService;
 use bizHd\user\services\UserService;
+use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\httpUtil;
 use common\components\util;
@@ -25,26 +26,24 @@ class RenewController extends BaseController
     //微信支付购买 ssh 2020.1.11
     public function actionWxPay()
     {
-        util::fail('即将开通...');
         ini_set('date.timezone', 'Asia/Shanghai');
-        $merchantId = Yii::$app->request->get('merchantId', 0);
-        $merchant = MerchantService::getMerchantById($merchantId);
-        if (empty($merchant)) {
-            util::fail('没有找到商家');
-        }
-        $setId = isset($merchant['setId']) ? $merchant['setId'] : 0;
+        $sj = $this->sj;
+        $setId = isset($sj['setId']) ? $sj['setId'] : 0;
         $set = SetMealService::getById($setId);
         if (empty($set)) {
             util::fail('没有找到套餐');
         }
-        $userId = $this->adminId;
-        $addData['userId'] = $userId;
+        $shopAdminId = $this->shopAdminId;
+        $addData['shopAdminId'] = $shopAdminId;
+        $shopAdmin = $this->shopAdmin;
+        $adminName = $shopAdmin['name'] ?? '';
+        $addData['shopAdminName'] = $adminName;
         $price = $set['price'];
         $prePrice = $price;
         $actPrice = $price;
         $addData['actPrice'] = $actPrice;
         $addData['prePrice'] = $prePrice;
-        $addData['merchantId'] = $merchantId;
+        $addData['merchantId'] = $this->sjId;
         $now = time();
         $expireTime = $now + 300;//订单5分钟后过期
         $addData['deadline'] = $expireTime;
@@ -57,12 +56,9 @@ class RenewController extends BaseController
         $userId = $addData['userId'];
         $user = UserService::getById($userId);
         //小程序使用miniOpenId
-        if (httpUtil::isMiniProgram()) {
-            $openId = $user['miniOpenId'];
-        } else {
-            $openId = $user['openId'];
-        }
-        $capitalType = dict::getDict('capitalType','xhRenew','id');
+        $openId = $user['miniOpenId'];
+
+        $capitalType = dict::getDict('capitalType', 'xhRenew', 'id');
         $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId;//将流水类型、优惠卷传过去
         $wx = Yii::getAlias("@vendor/weixin");
         require_once($wx . '/lib/WxPay.Api.php');
@@ -78,23 +74,21 @@ class RenewController extends BaseController
         $input->SetTrade_type("JSAPI");
 
         //花卉宝代为申请的微信支付
-        $merchantExtend = MerchantExtendService::getByMerchantId($this->sjId);
+        $merchantExtend = WxOpenClass::getWxInfo();
         if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
             $input->SetSub_openid($openId);
         } else {
             $input->SetOpenid($openId);
         }
         //小程序使用miniAppId
-        if (httpUtil::isMiniProgram()) {
-            $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-        }
+        $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
 
         $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
         $tools = new \JsApiPay();
         $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
         $newParams = json_decode($jsApiParameters, true);
         $newParams['orderId'] = $orderId;
-        $newParams['merchantId'] = $merchantId;
+        $newParams['merchantId'] = $this->sjId;
         util::success($newParams);
     }
 

+ 4 - 0
app-hd/controllers/ShopAdminController.php

@@ -57,6 +57,10 @@ class ShopAdminController extends BaseController
                 util::fail('您已经是别的商家员工');
             }
         }
+        $openShop = $admin['openShop'] ?? AdminClass::OPEN_SHOP_NO;
+        if ($openShop != AdminClass::OPEN_SHOP_NO) {
+            util::fail('您已申请开过店,不能成为别人的员工');
+        }
         $respond = ShopAdminService::generateAdmin($post);
         util::success($respond);
     }

+ 5 - 1
biz/admin/classes/AdminClass.php

@@ -9,7 +9,11 @@ class AdminClass extends BaseClass
 
     public static $baseFile = '\biz\admin\models\Admin';
 
-    const STYLE_GHS =2;
+    const STYLE_GHS = 2;
     const STYLE_HD = 1;
 
+    const OPEN_SHOP_NO = 1;
+    const OPEN_SHOP_CHECK = 2;
+    const OPEN_SHOP_YES = 3;
+
 }

+ 1 - 0
biz/sj/services/MerchantService.php

@@ -153,6 +153,7 @@ class MerchantService extends BaseService
             'merchantName' => $sjName,
             'openTime' => '8:00 - 23:00',
             'telephone' => $mobile,
+            'mobile' => $mobile,
             'introduction' => '欢迎光临',
             'province' => $applyData['province'] ?? '',
             'city' => $applyData['city'] ?? '',

+ 5 - 0
sql.sql

@@ -2415,3 +2415,8 @@ ALTER TABLE xhPurchaseClear ADD ghsShopAdminName VARCHAR(50) NOT NULL DEFAULT ''
 ALTER TABLE xhPurchaseClear ADD `type` TINYINT NOT NULL DEFAULT 1 COMMENT '1客户清算 2供货商清算' AFTER `id`;
 ALTER TABLE `xhGhs` MODIFY `name` VARCHAR(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '供货商名称';
 ALTER TABLE xhGhsCustom MODIFY `name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '客户名称';
+ALTER TABLE xhRenew CHANGE userId shopAdminId INT NOT NULL DEFAULT 0 COMMENT '员工id';
+ALTER TABLE xhRenew DROP COLUMN `addTime`;
+ALTER TABLE xhRenew ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `status`;
+ALTER TABLE xhRenew ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `addTime`;
+ALTER TABLE xhRenew ADD shopAdminName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '员工名称' AFTER shopAdminId;