Forráskód Böngészése

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

sorry 5 éve
szülő
commit
d43c5fd105

+ 37 - 32
app-ghs/controllers/AuthController.php

@@ -6,14 +6,12 @@ use biz\admin\classes\AdminClass;
 use bizHd\admin\classes\ShopAdminClass;
 use bizGhs\shop\services\ShopAdminService;
 use bizGhs\admin\services\AdminService;
-use bizHd\auth\services\AuthService;
 use bizHd\user\classes\UserClass;
 use bizHd\wx\classes\WxOpenClass;
-use bizHd\wx\services\WxOpenService;
+use common\components\dict;
 use common\components\httpUtil;
 use common\components\imgUtil;
 use common\components\jwt;
-use common\components\noticeUtil;
 use common\components\util;
 use Yii;
 use common\components\stringUtil;
@@ -161,7 +159,7 @@ class AuthController extends PublicController
         }
         $adminId = $admin['id'];
         $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0]);
-        if($shopAdmin['status']==0){
+        if ($shopAdmin['status'] == 0) {
             util::fail("您的账号还未激活");
         }
         $merchantId = isset($shopAdmin['merchantId']) ? $shopAdmin['merchantId'] : 0;
@@ -179,33 +177,37 @@ class AuthController extends PublicController
     {
         //供货商平台
         Yii::$app->params['ptStyle'] = 2;
-
         $code = Yii::$app->request->get('code', '');
         if (empty($code)) {
-            util::fail('没有CODE信息');
-        }
-        $wxMiniBase = WxOpenClass::getGhsWxInfo();
-        $appId = $wxMiniBase['miniAppId'];
-        $appSecret = $wxMiniBase['miniAppSecret'];
-        if (empty($appSecret)) {
-            util::fail('没有找到小程序的密钥');
-        }
-        $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
-        $curl = new curl\Curl();
-        $result = $curl->get($url);
-        $arr = Json::decode($result);
-        $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
-        $openid = $arr['openid'] ?? '';
-        $unionId = $arr['unionid'] ?? '';
-        if (empty($openid)) {
-            Yii::info(json_encode($arr));
-            util::fail('没有获取到小程序openId');
-        }
-        $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $openid;
-        Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
-        //用户来源
-        $userSource = UserClass::$userSourceId['mini']['name'];
-        $admin = AdminService::getByMiniOpenId($openid);
+            $demoId = dict::getDict('ghsDemoAdminId');
+            $admin = AdminClass::getById($demoId);
+            if (empty($admin)) {
+                util::fail('没有演示权限');
+            }
+        } else {
+            $wxMiniBase = WxOpenClass::getGhsWxInfo();
+            $appId = $wxMiniBase['miniAppId'];
+            $appSecret = $wxMiniBase['miniAppSecret'];
+            if (empty($appSecret)) {
+                util::fail('没有找到小程序的密钥');
+            }
+            $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
+            $curl = new curl\Curl();
+            $result = $curl->get($url);
+            $arr = Json::decode($result);
+            $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
+            $openid = $arr['openid'] ?? '';
+            $unionId = $arr['unionid'] ?? '';
+            if (empty($openid)) {
+                Yii::info(json_encode($arr));
+                util::fail('没有获取到小程序openId');
+            }
+            $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $openid;
+            Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
+            //用户来源
+            $userSource = UserClass::$userSourceId['mini']['name'];
+            $admin = AdminService::getByMiniOpenId($openid);
+        }
         if (empty($admin)) {
             $adminInfo = ['miniOpenId' => $openid, 'style' => 2, 'unionId' => $unionId];
             $admin = AdminService::replaceAdmin($adminInfo, $userSource);
@@ -216,21 +218,24 @@ class AuthController extends PublicController
         $currentShopId = $admin['currentShopId'] ?? 0;
         //员工id
         $shopAdminId = 0;
-        $super = 0;
+        $switchShop = 0;
         if (!empty($currentShopId)) {
             $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId]);
             $shopAdminId = $shopAdmin['id'] ?? 0;
-            $super = $shopAdmin['super'] ?? 0;
+            //是否有切换门店的权限
+            $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
         }
         $admin['avatar'] = imgUtil::getPrefix() . '/retail/default-img.png';
         $token = jwt::getNewToken($adminId);
+        $showDemo = dict::getDict('showDemo');
         util::success([
             'token' => $token,
             'admin' => $admin,
             'shopAdminId' => $shopAdminId,
             'shopId' => $currentShopId,
-            'super' => $super,
+            'switchShop' => $switchShop,
             'openShop' => $openShop,
+            'showDemo' => $showDemo,
         ]);
     }
 

+ 0 - 2
app-ghs/controllers/NoticeController.php

@@ -14,8 +14,6 @@ use biz\recharge\classes\RechargeClass;
 class NoticeController extends PublicController
 {
 
-    public $categoryList;
-
     //微信支付异步回调
     public function actionWxCallback()
     {

+ 1 - 1
app-ghs/controllers/ShopAdminController.php

@@ -139,7 +139,7 @@ class ShopAdminController extends BaseController
     {
         $id = Yii::$app->request->get('id');
         $relation = ShopAdminClass::getInfo($id);
-        if ($relation['founder'] == 2) {
+        if ($relation['super'] == 2) {
             util::fail("创始人不能删除");
         }
         ShopAdminClass::valid($relation, $this->shopId);

+ 41 - 27
app-hd/controllers/AuthController.php

@@ -6,9 +6,9 @@ use biz\admin\classes\AdminClass;
 use bizHd\admin\classes\ShopAdminClass;
 use bizHd\admin\services\ShopAdminService;
 use bizHd\admin\services\AdminService;
-use bizHd\auth\services\AuthService;
 use bizHd\user\classes\UserClass;
 use bizHd\wx\services\WxOpenService;
+use common\components\dict;
 use common\components\httpUtil;
 use common\components\imgUtil;
 use common\components\jwt;
@@ -177,30 +177,35 @@ class AuthController extends PublicController
 
         $code = Yii::$app->request->get('code', '');
         if (empty($code)) {
-            util::fail('没有CODE信息');
-        }
-        $wxMiniBase = WxOpenService::getWxMiniBase();
-        $appId = $wxMiniBase['miniAppId'];
-        $appSecret = $wxMiniBase['miniAppSecret'];
-        if (empty($appSecret)) {
-            util::fail('没有找到小程序的密钥');
-        }
-        $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
-        $curl = new curl\Curl();
-        $result = $curl->get($url);
-        $arr = Json::decode($result);
-        $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
-        $openid = $arr['openid'] ?? '';
-        $unionId = $arr['unionid'] ?? '';
-        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
-        Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
-        if (empty($openid)) {
-            Yii::info(json_encode($arr));
-            util::fail('没有获取到小程序openId');
+            $demoId = dict::getDict('hdDemoAdminId');
+            $admin = AdminClass::getById($demoId);
+            if (empty($admin)) {
+                util::fail('没有演示权限');
+            }
+        } else {
+            $wxMiniBase = WxOpenService::getWxMiniBase();
+            $appId = $wxMiniBase['miniAppId'];
+            $appSecret = $wxMiniBase['miniAppSecret'];
+            if (empty($appSecret)) {
+                util::fail('没有找到小程序的密钥');
+            }
+            $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
+            $curl = new curl\Curl();
+            $result = $curl->get($url);
+            $arr = Json::decode($result);
+            $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
+            $openid = $arr['openid'] ?? '';
+            $unionId = $arr['unionid'] ?? '';
+            $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
+            Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
+            if (empty($openid)) {
+                Yii::info(json_encode($arr));
+                util::fail('没有获取到小程序openId');
+            }
+            //用户来源
+            $userSource = UserClass::$userSourceId['mini']['name'];
+            $admin = AdminService::getByMiniOpenId($openid);
         }
-        //用户来源
-        $userSource = UserClass::$userSourceId['mini']['name'];
-        $admin = AdminService::getByMiniOpenId($openid);
         if (empty($admin)) {
             $adminInfo = ['miniOpenId' => $openid, 'style' => 1, 'unionId' => $unionId];
             $admin = AdminService::replaceAdmin($adminInfo, $userSource);
@@ -210,18 +215,27 @@ class AuthController extends PublicController
         }
         $shopId = $admin['currentShopId'] ?? 0;
         $shopAdminId = 0;
-        $super = 0;
+        $switchShop = 0;
         if (!empty($shopId)) {
             $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId]);
             $shopAdminId = $shopAdmin['id'] ?? 0;
-            $super = $shopAdmin['super'] ?? 0;
+            //是否有切换门店的权限
+            $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
         }
         //头像
         $prefix = imgUtil::getPrefix();
         $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
         $admin['avatar'] = $avatar;
         $token = jwt::getNewToken($adminId);
-        util::success(['token' => $token, 'admin' => $admin, 'shopId' => $shopId, 'shopAdminId' => $shopAdminId, 'super' => $super]);
+        $showDemo = dict::getDict('showDemo');
+        util::success([
+            'token' => $token,
+            'admin' => $admin,
+            'shopId' => $shopId,
+            'shopAdminId' => $shopAdminId,
+            'switchShop' => $switchShop,
+            'showDemo' => $showDemo
+        ]);
     }
 
 }

+ 3 - 25
app-hd/controllers/NoticeController.php

@@ -2,10 +2,8 @@
 
 namespace hd\controllers;
 
-use biz\recharge\classes\RechargeClass;
-use bizHd\purchase\classes\PurchaseClass;
-use bizHd\purchase\classes\PurchaseClearClass;
 use common\components\dict;
+use common\components\pay;
 use Yii;
 use common\components\util;
 
@@ -41,7 +39,7 @@ class NoticeController extends PublicController
 
         $wxPay = dict::getDict('payWay', 'wxPay');
         //支付成功后续流程
-        $this->_thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach);
+        pay::thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach);
 
         echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
     }
@@ -122,31 +120,11 @@ class NoticeController extends PublicController
 
             $aliPay = dict::getDict('payWay', 'alipay');
             //支付成功后续流程
-            $this->_thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach);
+            pay::thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach);
 
         }
         //请不要修改
         echo "success";
     }
 
-    public function _thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach)
-    {
-        //流水类型列表
-        switch ($capitalType) {
-            case dict::getDict('capitalType', 'xhRecharge', 'id'):
-                //充值
-                RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            case dict::getDict('capitalType', 'xhPurchase', 'id'):
-                //采购订单
-                PurchaseClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
-                //采购订单结算
-                PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
-                break;
-            default:
-        }
-    }
-
 }

+ 1 - 1
app-hd/controllers/ProductController.php

@@ -143,7 +143,7 @@ class ProductController extends BaseController
             //常用的itemIds
             $oftenItemIds = ProductClass::getOftenItemIds($shopId);
             //获取供应商下所有花材ID (itemIds)
-            $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+            $itemIdsInfo = ItemService::getGhsItemIds($sjId);
 
             //dd($itemInfoData);
             //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]

+ 2 - 2
app-hd/controllers/ShopAdminController.php

@@ -131,8 +131,8 @@ class ShopAdminController extends BaseController
     {
         $id = Yii::$app->request->get('id');
         $relation = ShopAdminClass::getInfo($id);
-        if ($relation['founder'] == 2) {
-            util::fail("创始人不能删除");
+        if ($relation['super'] == 1) {
+            util::fail("管理员不能删除");
         }
         ShopAdminClass::valid($relation, $this->shopId);
         ShopAdminClass::delRelation($relation);

+ 9 - 1
app-mall/controllers/AuthController.php

@@ -163,12 +163,20 @@ class AuthController extends PublicController
             $sjId = $shop['merchantId'] ?? 0;
         }
         $user = UserClass::replaceUser($userInfo, $userSource, $sjId);
+        $custom = $user['customInfo'] ?? [];
+        $customId = $custom['id'] ?? 0;
         $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
         Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
         $userId = $user['id'];
         $token = jwt::getNewToken($userId);
         //update = 1 表示要求启动时更新(如果需要马上应用最新版本,可以使用 wx.getUpdateManager API 进行处理。)
-        util::success(['token' => $token, 'user' => $user, 'update' => 0]);
+        util::success([
+            'token' => $token,
+            'user' => $user,
+            'update' => 0,
+            'customId' => $customId,
+            'custom' => $custom
+        ]);
     }
 
 }

+ 1 - 4
app-mall/controllers/BaseController.php

@@ -67,10 +67,7 @@ class BaseController extends PublicController
             }
             $this->user = $userInfo;
             if (in_array($action->id, $this->guestAccess) == false) {
-                $custom = CustomClass::getCurrentCustom($sjId, $userInfo);
-                if (empty($custom)) {
-                    util::fail('客户信息无效');
-                }
+                $custom = CustomClass::replaceCustom($sjId, $userInfo);
                 $this->custom = $custom;
                 $customId = $custom['id'] ?? 0;
                 $this->customId = $customId;

+ 117 - 129
app-mall/controllers/NoticeController.php

@@ -2,139 +2,127 @@
 
 namespace mall\controllers;
 
-use bizMall\merchant\services\MerchantExtendService;
+use common\components\pay;
 use Yii;
-use common\services\xhUserAssetService;
-use common\services\xhUserService;
 use common\components\util;
-use common\services\xhOrderService;
 use common\components\dict;
-use common\services\xhMerchantService;
-use common\services\xhPayToolService;
-
 
 class NoticeController extends PublicController
 {
-	
-	public $categoryList;
-	
-	
-	//微信支付异步回调
-	public function actionWxCallback()
-	{
-		$postStr = file_get_contents('php://input');//接收微信服务器返回的xml消息体
-		if (empty($postStr)) {
-			util::end();
-		}
-		$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
-		if ($postObj->return_code != 'SUCCESS') {
-			Yii::warning('return_code error:' . $postObj->return_code);
-			util::end();
-		}
-		$orderId = $postObj->out_trade_no;
-		$total_fee = $postObj->total_fee;
-		$totalFee = $total_fee / 100;
-		$attach = $postObj->attach;
-		//接收流水类型、代金劵、微信支付的细项
-		parse_str($attach);
-		$couponId = isset($couponId) ? $couponId : 0;
-		//流水类型
-		$capitalType = isset($capitalType) ? $capitalType : null;
-		$wxPayType = isset($wxPayType) ? $wxPayType : 0;
-		if (isset($capitalType) == false) {
-			Yii::warning('capitalType empty,orderId:' . $orderId);
-			util::end();
-		}
-		$callbackParams = ['wxPayType' => $wxPayType];
-		$return = xhPayToolService::wxPay($callbackParams, $orderId, $totalFee, $capitalType, $couponId);//支付回调流程
-		if (isset($return['code']) && $return['code'] == 'A0002') {
-			Yii::warning('callback exec and failed,capitalType:' . $capitalType . ' orderId:' . $orderId);
-			util::end();
-		}
-		echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
-	}
-	
-	//支付宝异步通知
-	public function actionAliCallback()
-	{
-		header("Content-type: text/html; charset=utf-8");
-		$aliWap = Yii::getAlias("@vendor/alipayWap");
-		$orderSn = $_POST['out_trade_no'];//商户订单号
-		$pay = xhOrderService::getByOrderSn($orderSn);
-		if (empty($pay)) {
-			Yii::warning('没有找到订单:orderSn:' . $orderSn);
-			util::end();
-		}
-		$orderId = $pay['id'];//商户订单号
-		$sjId = isset($pay['merchantId']) ? $pay['merchantId'] : 0;
-		$extend = MerchantExtendService::getByMerchantId($sjId);
-		$config = [
-			//应用ID,您的APPID。
-			'app_id' => $extend['alipayPId'],
-			//商户私钥,您的原始格式RSA私钥
-			'merchant_private_key' => $extend['alipayKey'],
-			//异步通知地址
-			'notify_url' => Yii::$app->params['frontUrl'] . "/notice/ali-async",
-			//同步跳转
-			'return_url' => "",
-			//编码格式
-			'charset' => "UTF-8",
-			//签名方式
-			'sign_type' => "RSA2",
-			//支付宝网关
-			'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
-			//支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
-			'alipay_public_key' => $extend['alipayPublicKey'],
-		];
-		
-		require_once($aliWap . '/wappay/service/AlipayTradeService.php');
-		require_once($aliWap . '/wappay/buildermodel/AlipayTradeQueryContentBuilder.php');//查询接口
-		
-		$arr = $_POST;
-		$aliSevice = new \AlipayTradeService($config);
-		$aliSevice->writeLog(var_export($_POST, true));
-		$result = $aliSevice->check($arr);
-		Yii::info('check:' . $result);
-		if ($result) {//验证成功
-			$tradeNo = $_POST['trade_no'];//支付宝交易号
-			$tradeStatus = $_POST['trade_status'];//交易状态
-			$totalFee = $_POST['total_amount'];
-			$appId = $_POST['app_id'];
-			$passbackParams = $_POST['passback_params'];
-			$passbackParams = urldecode($passbackParams);
-			parse_str($passbackParams);//接收流水类型、代金劵
-			$couponId = isset($couponId) ? $couponId : 0;
-			$capitalType = isset($capitalType) ? $capitalType : null;//流水类型
-			
-			$RequestBuilder = new \AlipayTradeQueryContentBuilder();
-			$RequestBuilder->setTradeNo($tradeNo);
-			$queryResult = $aliSevice->Query($RequestBuilder);
-			$aliId = $queryResult->buyer_user_id;
-			$aliAccount = $queryResult->buyer_logon_id;//买家的支付宝帐号,不完整,带*号
-			$aliParams = ['alipayId' => $aliId, 'alipayAccount' => $aliAccount];
-			
-			if (isset($capitalType) == false) {
-				Yii::warning('capitalType empty, orderId:' . $orderId);
-				util::end();
-			}
-			if ($config['app_id'] != $appId) {
-				Yii::warning('app_id disagree, orderId:' . $orderId . ' config app_id:' . $config['app_id'] . ' appId:' . $appId);
-				util::end();
-			}
-			if ($tradeStatus == 'TRADE_FINISHED' || $tradeStatus == 'TRADE_SUCCESS') {
-				$callbackParams = [];
-				$return = xhPayToolService::alipay($callbackParams, $orderSn, $totalFee, $capitalType, $couponId, $aliParams);//支付回调流程
-				if ($return['code'] == 'A0002') {
-					Yii::warning('callback exec and failed,capitalType:' . $capitalType . ' orderId:' . $orderId);
-					util::end();
-				}
-			}
-			//请不要修改或删除
-			echo "success";
-			util::end();
-		}
-		//请不要修改或删除
-		echo "fail";
-	}
-	
+
+    //微信支付异步回调
+    public function actionWxCallback()
+    {
+        $postStr = file_get_contents('php://input');//接收微信服务器返回的xml消息体
+        if (empty($postStr)) {
+            util::end();
+        }
+        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
+        if ($postObj->return_code != 'SUCCESS') {
+            Yii::warning('return_code error:' . $postObj->return_code);
+            util::end();
+        }
+        $orderSn = $postObj->out_trade_no;
+        $total_fee = $postObj->total_fee;
+        $totalFee = $total_fee / 100;
+        $attach = $postObj->attach;
+        //接收流水类型、代金劵
+        parse_str($attach);
+        //流水类型
+        $capitalType = isset($capitalType) ? $capitalType : null;
+        if (isset($capitalType) == false) {
+            Yii::warning('capitalType empty,orderSn:' . $orderSn);
+            util::end();
+        }
+
+        $wxPay = dict::getDict('payWay', 'wxPay');
+        //支付成功后续流程
+        pay::thirdPay($wxPay, $capitalType, $orderSn, $totalFee, $attach);
+
+        echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
+    }
+
+    //支付宝异步通知
+    public function actionAliCallback()
+    {
+        header("Content-type: text/html; charset=utf-8");
+        $aliWap = Yii::getAlias("@vendor/alipayWap");
+        //商户订单号
+        $orderSn = $_POST['out_trade_no'];
+
+        $aliPId = '2017041906821571';
+        $aliKey = 'MIIEpAIBAAKCAQEAvbeu6o90L+0AilI+mbhuJJH0lUv7hWQCEC+XUc+cWlC9ulKC3cSVScVLJHpUc09aj6v/iD1p9iVfgMxjeADNVKiQC2RJyRshAjzyTq+2bTcODp619iV2y4qW8UM65VcP7Ide3P0uT5xC2ReW0HpkdHZgm4F+P7mh1VhGt9qOP3hjvoraAHhtGACvsGvy8H69HhSAG+CEmFt7f2tKNWJ8xEUvkfhDvys93PfTk4xMWj048hJE2r38+2mWI/Il5dFQHWXXTVl2x9yi7uhEEW42a+7s9Q3HgqEvZiQ2NI1FTeEAPLFBApiEsNLY/smaszwqqfWGAyTMvtQ6T4K96GcTLQIDAQABAoIBAHwYTj33n9RJfnT73x7F2KXrIsUVcmyKQh88QgqtdmRNNA1QM3HESLJ8bu5pZhwW5/HaW8dOBKWRRKsHBnlUbPrXV4FcFDeLm0fPfd+iZ/2AaZ1+ix962f3BpYIiq7+f9zaMRazfnw9L8x31pByyMktLs12EkoQ0dHsMxxUzzKAOiiPnvCn8Pv+Jb2qej8GXgCjefutCVNMWGsdwJtMVXEbpdmMa48Wvw+0In5ZS/UG39YAreFzgDqI9jWHE1ZhkGmB1+8hKpeIlEeVGAeYVveUgssMORdA/YY8SWHk26KSIFXBrmdKjAcRJ8Q7ZHUmzIqAV+IMV+RD4J5mZHeJgdAECgYEA8J+Hp1M6eYbT4CPLXa//yRP6Xo+qSzrKHaRB1LRAjYhvKpx/TQetYpNCJ5bWpa+Jp0T5R21pzuYaJkPuGlNEHA13b5T3r1l2ltomSEdaShvD5EZ9WtErYV5zpSv7FjjIGkbwa0H3A8Ydnvw5z4A9TZjjHLjC2GtVGJReqHGglMECgYEAydddA4NRPxmXvIjjmLb1Ft1qwHuyv3vvWhi50foGZXNEnBcfP/OkfyBDDpOEu34GZBMXK9ykHBs1l93OEFGXh7AwW0Lp5lARahBEfBZgPjq5yPO8TOJZrb5hVcuvoDdGjxpRh93XDnQDhWS/1IvUcBLcIsTcnVvfrkX4NLxF/W0CgYEAxamG+gD4rBQBwMImsRN+/2MV7M//iEUG+0qPeXeI/7rv9wUP3etMlwl48qSKNxj37xxN2ksa/Acxu/VZhu6XqKO3VUX+IWFQdaNGh2F13iLozIDLQOtKw3WfcjOq0xpZ5pwXq0RI8iSw+IUhyD8EHNZW2qU8CiRBhyt6hsywqQECgYBa8+06FAachI/XqWfF/UvcDdJ5AkS9/L8SvmmdsSkItjSIkfLHAqdxkbwl6Vu6kUOX/PJIFZjuAWTZFl4xBFNgFYj01uZHnnT6cnIp6HteD2CAqTSFAMqgfFWoL6zoaYAmJBnxO4oZPTYI+ilnQcts5VLFaChx0GCvS2BZgy2W0QKBgQDjP2VtRq4aVSLUq2z1KIDI7GJBbOM5KSW1OEj4sfEdViozPh3Ar/FQWiij1oCZF+iJdKkonHoDbDd+Q0ykcpQ+5Gv07iiT8wJYFR/0j8g2kfql7bVQhGSBeBMS5sawKR3CvkfW73WX+CNnf0PklTY0kTyt6WRXDnKSeyxFVwSZ7g==';
+        $aliPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsz3m9juAR1xew4DY6c34gvbwNg8pZ92f932tseKs+4+pF0e+jTDiUo/xHImNDi1KXt1B+s3LxY9L/sxEksbavwmhgbz/igN1cAEwS2YM+Gnf0csDrxAPJhoKL5FTwxPEQ/8VSgroU+6GlF3LAx4VHa1qfn5MqRPfLroJcyPDyGfNe9vna2FnO4E/PH+hVbvPUAwX3XrUvJIm4OgY0JE3HYFlu+O7F4Ln6+Sl+Zv/ZE2nZAvNiyAwW5iVKhKXLieExqwd0NdrP28baBqkkIY+tmV7butGjB52iK1UbU0+1uiaPL4xBxRy6d0LZmYlvdVHp0JRUuwxBLChGgOCo/76DQIDAQAB';
+
+        $config = [
+            //应用ID,您的APP_ID
+            'app_id' => $aliPId,
+            //商户私钥,您的原始格式RSA私钥
+            'merchant_private_key' => $aliKey,
+            //异步通知地址
+            'notify_url' => Yii::$app->params['mallHost'] . "/notice/ali-async",
+            //同步跳转
+            'return_url' => "",
+            //编码格式
+            'charset' => "UTF-8",
+            //签名方式
+            'sign_type' => "RSA2",
+            //支付宝网关
+            'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
+            //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
+            'alipay_public_key' => $aliPublicKey,
+        ];
+
+        require_once($aliWap . '/wappay/service/AlipayTradeService.php');
+        require_once($aliWap . '/wappay/buildermodel/AlipayTradeQueryContentBuilder.php');//查询接口
+
+        $arr = $_POST;
+        $aliService = new \AlipayTradeService($config);
+        $aliService->writeLog(var_export($_POST, true));
+        $result = $aliService->check($arr);
+        Yii::info('check:' . $result);
+        if ($result == false) {
+            //请不要修改
+            echo "fail";
+            util::end();
+        }
+
+        //验证成功后续
+        $tradeNo = $_POST['trade_no'];//支付宝交易号
+        $tradeStatus = $_POST['trade_status'];//交易状态
+        $totalFee = $_POST['total_amount'];
+        $appId = $_POST['app_id'];
+        $attach = $_POST['passback_params'];
+        $attach = urldecode($attach);
+        //接收流水类型、代金劵
+        parse_str($attach);
+        //流水类型
+        $capitalType = isset($capitalType) ? $capitalType : null;
+
+        $RequestBuilder = new \AlipayTradeQueryContentBuilder();
+        $RequestBuilder->setTradeNo($tradeNo);
+        //$queryResult = $aliService->Query($RequestBuilder);
+        //$aliId = $queryResult->buyer_user_id;
+        //买家的支付宝帐号,不完整,带*号
+        //$aliAccount = $queryResult->buyer_logon_id;
+
+        if (isset($capitalType) == false) {
+            Yii::warning('capitalType empty, orderSn:' . $orderSn);
+            util::end();
+        }
+        if ($config['app_id'] != $appId) {
+            Yii::warning('app_id disagree, orderSn:' . $orderSn . ' config app_id:' . $config['app_id'] . ' appId:' . $appId);
+            util::end();
+        }
+        if ($tradeStatus == 'TRADE_FINISHED' || $tradeStatus == 'TRADE_SUCCESS') {
+
+            $aliPay = dict::getDict('payWay', 'alipay');
+            //支付成功后续流程
+            pay::thirdPay($aliPay, $capitalType, $orderSn, $totalFee, $attach);
+
+        }
+        //请不要修改
+        echo "success";
+    }
+
 }

+ 0 - 9
app-mall/controllers/PayController.php

@@ -6,22 +6,13 @@ use bizMall\goods\services\CategoryRelateService;
 use bizMall\goods\services\UsageRelationService;
 use bizMall\order\services\OrderService;
 use bizMall\promote\services\CouponService;
-use bizMall\user\services\UserAssetService;
-use bizMall\wx\services\WxSceneService;
-use common\components\qrCodeUtil;
-use common\models\xhOrder;
 use common\models\xhShop;
 use common\services\xhMerchantExtendService;
-use Faker\Provider\Base;
 use Yii;
-use yii\helpers\Json;
 use common\services\xhUserAssetService;
 use common\services\xhUserService;
 use common\services\xhCouponService;
-use common\services\xhPayToolService;
 use common\services\xhOrderService;
-use common\services\xhActiveService;
-use common\services\xhActiveTicketClassService;
 use common\components\util;
 use common\components\stringUtil;
 use common\components\dict;

+ 3 - 1
app-mall/controllers/UserController.php

@@ -8,6 +8,7 @@ use bizMall\message\services\SmsService;
 use bizMall\user\classes\UserClass;
 use bizMall\user\services\UserAssetService;
 use bizMall\user\services\UserService;
+use common\components\dict;
 use common\components\imgUtil;
 use common\components\stringUtil;
 use Yii;
@@ -24,7 +25,8 @@ class UserController extends BaseController
     {
         $list = UserClass::getRecentShop($this->user);
         //0最近访问的门店 1国兰门店信息
-        util::success(['list' => $list, 'showIndex' => 0]);
+        $showMallIndex = dict::getDict('showMallIndex');
+        util::success(['list' => $list, 'showIndex' => $showMallIndex]);
     }
 
     //获取登陆客户的资产 ssh 2019.11.22

+ 5 - 2
app-pt/controllers/BaseController.php

@@ -29,7 +29,10 @@ class BaseController extends PublicController
         } else {
             $staff = StaffService::getById($staffId);
             if (empty($staff)) {
-                util::fail('没有找到管理员');
+                util::logout();
+            }
+            if($staff['status']==0){
+                util::logout("账号已冻结");
             }
             $this->staff = $staff;
             $this->user = $staff;
@@ -41,4 +44,4 @@ class BaseController extends PublicController
         return parent::beforeAction($action);
     }
 
-}
+}

+ 3 - 2
biz-ghs/admin/classes/AdminClass.php

@@ -101,7 +101,7 @@ class AdminClass extends BaseClass
                     'avatar' => $avatar,
                     'name' => $name,
                     'super' => 1,
-                    'founder' => 1,
+                    'founder' => 2,
                     'mobile' => $mobile,
                 ];
                 ShopAdminClass::add($shopData);
@@ -425,7 +425,8 @@ class AdminClass extends BaseClass
     //切换门店 linqh 2021.1.31
     public static function toggleShop($admin, $toggleShopId, $sjId, $originShopAdmin)
     {
-        if (isset($originShopAdmin['super']) == false || $originShopAdmin['super'] != 1) {
+        $right = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($originShopAdmin);
+        if (empty($right)) {
             util::fail("您没有权限");
         }
         $adminId = $admin['id'];

+ 1 - 1
biz-ghs/order/classes/CheckOrderClass.php

@@ -175,7 +175,7 @@ class CheckOrderClass extends BaseClass
             $tmp['itemStock'] = $productData[$productId]['stock']??0;//当时库存
             $tmp['itemNum'] = ProductClass::mergeItemNum($v['bigNum'],$v['smallNum'],$unitNum);// 盘点数量
             $tmp['itemPrice'] =$productData[$productId]['price']??0; //当时售卖的价格
-            $tmp['profitLossNum'] = bcsub(   $tmp['itemNum']- $tmp['itemStock'],2); //盈亏数 = 盘点数-当时库存数
+            $tmp['profitLossNum'] = bcsub(   $tmp['itemNum'],$tmp['itemStock'],2); //盈亏数 = 盘点数-当时库存数
             $stockFormat= ProductClass::formatStock($tmp['itemStock'],$unitNum); // 库存总单位数量转大小单位的数量
             $itemInfo = [
                 'itemName'=> $productData[$productId]['name']??'',//花材名称

+ 0 - 1
biz-hd/admin/classes/AdminClass.php

@@ -78,7 +78,6 @@ class AdminClass extends BaseClass
                     'avatar' => $avatar,
                     'name' => $name,
                     'super' => 1,
-                    'founder' => 1,
                     'mobile' => $mobile,
                 ];
                 ShopAdminClass::add($shopData);

+ 7 - 21
biz-hd/custom/classes/CustomClass.php

@@ -20,25 +20,7 @@ class CustomClass extends BaseClass
         return 'hd_custom_key_' . $sjId . '_' . $userId;
     }
 
-    public static function getCurrentCustom($sjId, $user)
-    {
-        $userId = $user['id'];
-        $key = self::getCustomCacheKey($sjId, $userId);
-        $currentId = Yii::$app->redis->executeCommand('GET', [$key]);
-        $info = [];
-        if (!empty($currentId)) {
-            $info = self::getById($currentId);
-        }
-        if (empty($info)) {
-            $info = self::getByCondition(['sjId' => $sjId, 'userId' => $userId]);
-        } else {
-            $id = $info['id'];
-            Yii::$app->redis->executeCommand('SET', [$key, $id]);
-        }
-        return $info;
-    }
-
-    //创建获取客户信息 ssh 2021.3.19
+    //创建或获取客户信息 ssh 2021.3.19
     public static function replaceCustom($sjId, $user)
     {
         $userId = $user['id'];
@@ -47,7 +29,8 @@ class CustomClass extends BaseClass
         $key = self::getCustomCacheKey($sjId, $userId);
         $currentId = Yii::$app->redis->executeCommand('GET', [$key]);
         if (!empty($currentId)) {
-            return $currentId;
+            $info = self::getById($currentId);
+            return $info;
         }
         $info = self::getByCondition(['sjId' => $sjId, 'userId' => $userId]);
         if (empty($info)) {
@@ -63,9 +46,12 @@ class CustomClass extends BaseClass
             ];
             $info = self::addCustom($data);
         }
+        if (empty($info)) {
+            util::fail('没有生成客户信息');
+        }
         $id = $info['id'];
         Yii::$app->redis->executeCommand('SET', [$key, $id]);
-        return $id;
+        return $info;
     }
 
     //获取客户信息

+ 33 - 9
biz-hd/order/classes/OrderClass.php

@@ -2,21 +2,13 @@
 
 namespace bizHd\order\classes;
 
-use biz\shop\classes\ShopClass;
 use biz\shop\models\Shop;
-use biz\sj\classes\MerchantAssetClass;
-use biz\sj\classes\MerchantClass;
 use biz\stat\classes\StatOrderCountClass;
-use bizHd\message\classes\InformAdminClass;
-use bizHd\message\classes\InformUserClass;
 use bizHd\stat\classes\StatOrderClass;
-use bizHd\stat\classes\StatOrderMonthClass;
 use bizHd\user\classes\UserClass;
 use common\components\miniUtil;
 use common\components\orderSn;
-use common\components\stringUtil;
-use common\services\xhOrderDayNumService;
-use common\services\xhOrderMonthNumService;
+use common\components\util;
 use Yii;
 use bizHd\base\classes\BaseClass;
 
@@ -141,6 +133,21 @@ class OrderClass extends BaseClass
         self::updateById($id, ['status' => OrderClass::ORDER_STATUS_COMPLETE, 'currentFlow' => $currentFlow]);
     }
 
+    //订单完成(这个方法要跟上面的组合一起) shish 2021.4.20
+    public static function finish($order, $payWay)
+    {
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        if (isset($order->status) == false || $order->status != self::ORDER_STATUS_UN_PAY) {
+            util::fail('订单不是待付款状态');
+        }
+        $order->status = self::ORDER_STATUS_COMPLETE;
+        $order->currentFlow = self::ORDER_TOTAL_FLOW;
+        $order->payWay = $payWay;
+        $order->save();
+    }
+
     //转化出送到时间 ssh 2020.3.15
     public static function getReachTime($order)
     {
@@ -211,4 +218,21 @@ class OrderClass extends BaseClass
         }
     }
 
+    //第三方支付后回调处理流程 shish 2021.4.30
+    public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
+    {
+        $info = self::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($info)) {
+            $msg = "没有找到零售订单 orderSn:{$orderSn}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        if ($info->actPrice != $totalFee) {
+            $msg = "零售订单金额与回调通知金额不一致 orderSn:{$orderSn} {$info->actPrice} {$totalFee}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        self::finish($info, $payWay);
+    }
+
 }

+ 54 - 30
biz-hd/purchase/classes/PurchaseClass.php

@@ -4,6 +4,7 @@ namespace bizHd\purchase\classes;
 
 use biz\ghs\classes\GhsClass;
 use biz\ghs\models\Ghs;
+use biz\shop\classes\ShopClass;
 use biz\shop\models\Shop;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
@@ -13,6 +14,7 @@ use bizGhs\product\classes\ProductClass;
 use bizGhs\order\classes\OrderClass;
 use common\components\dict;
 use common\components\orderSn;
+use common\components\stringUtil;
 use common\components\util;
 use bizHd\base\classes\BaseClass;
 
@@ -40,7 +42,6 @@ class PurchaseClass extends BaseClass
         $orderSn = orderSn::getPurchaseSn();
         $data['orderSn'] = $orderSn;
         $prePrice = 0;
-        $actPrice = 0;
 
         $data['sendTimeWant'] = date("Y-m-d") . ' ' . $data['sendTime'];
         unset($data['sendTime']);
@@ -61,31 +62,31 @@ class PurchaseClass extends BaseClass
         $smallNum = 0; //总共多少支
         foreach ($productList as $key => $product) {
 
-            $bigNum += $product['bigNum']??0;
-            $smallNum += $product['smallNum']??0;
+            $bigNum += $product['bigNum'] ?? 0;
+            $smallNum += $product['smallNum'] ?? 0;
             $productList[$key]['orderSn'] = $orderSn;
             $productId = $product['productId'];
-            $ratio = $productData[$productId]['ratio']??0;
-            $itemId = $productData[$productId]['itemId']??0;
-            $rank = $productData[$productId]['rank']??'B';// 花材级别
-            $stock = $productData[$productId]['stock']??0;//当时库存
-            $stockFormat= ProductClass::formatStock($stock,$ratio);
+            $ratio = $productData[$productId]['ratio'] ?? 0;
+            $itemId = $productData[$productId]['itemId'] ?? 0;
+            $rank = $productData[$productId]['rank'] ?? 'B';// 花材级别
+            $stock = $productData[$productId]['stock'] ?? 0;//当时库存
+            $stockFormat = ProductClass::formatStock($stock, $ratio);
 
-            $itemNum =  ProductClass::mergeItemNum($product['bigNum'],$product['smallNum'],$ratio);//采购数量
+            $itemNum = ProductClass::mergeItemNum($product['bigNum'], $product['smallNum'], $ratio);//采购数量
             $price = $productData[$productId]['price']; //卖的单价
-            $sellPrice = bcmul($itemNum,$price,2); //采购总价
+            $sellPrice = bcmul($itemNum, $price, 2); //采购总价
             $itemInfo = [
-                'itemName'=> $productData[$productId]['name']??'',//花材名称
-                'itemCover'=> $productData[$productId]['cover']??'',//花材图片
-                'bigNum'=> $product['bigNum']??0,//采购数量(大单位)
-                'smallNum'=> $product['smallNum']??0,//采购数量(小单位)
-                'bigNumStock'=> $stockFormat['bigNum'],// 当时库存大单位数
-                'smallNumStock'=> $stockFormat['smallNum'],//当时库存 小单位数
-                'itemUnit'=> $ratio?2:1,//单位
-                'ratio'=>$ratio,// 比例
-                'rank'=>$rank,// 花材级别
-                'bigUnit'=> $productData[$productId]['bigUnit'],//大单位名称 扎
-                'smallUnit'=> $productData[$productId]['smallUnit'],//小单位名称 支
+                'itemName' => $productData[$productId]['name'] ?? '',//花材名称
+                'itemCover' => $productData[$productId]['cover'] ?? '',//花材图片
+                'bigNum' => $product['bigNum'] ?? 0,//采购数量(大单位)
+                'smallNum' => $product['smallNum'] ?? 0,//采购数量(小单位)
+                'bigNumStock' => $stockFormat['bigNum'],// 当时库存大单位数
+                'smallNumStock' => $stockFormat['smallNum'],//当时库存 小单位数
+                'itemUnit' => $ratio ? 2 : 1,//单位
+                'ratio' => $ratio,// 比例
+                'rank' => $rank,// 花材级别
+                'bigUnit' => $productData[$productId]['bigUnit'],//大单位名称 扎
+                'smallUnit' => $productData[$productId]['smallUnit'],//小单位名称 支
             ];
 
             $productList[$key]['itemInfo'] = json_encode($itemInfo);
@@ -94,9 +95,9 @@ class PurchaseClass extends BaseClass
             $productList[$key]['price'] = $price;
             $productList[$key]['ratio'] = $ratio;
             $productList[$key]['totalPrice'] = $sellPrice;
-            $prePrice = bcadd($prePrice,$sellPrice,2);
+            $prePrice = bcadd($prePrice, $sellPrice, 2);
         }
-        $prePrice = bcadd($prePrice,$data['sendCost'],2);
+        $prePrice = bcadd($prePrice, $data['sendCost'], 2);
         $actPrice = $prePrice;
         $data['prePrice'] = $prePrice;
         $data['actPrice'] = $actPrice;
@@ -107,7 +108,6 @@ class PurchaseClass extends BaseClass
             util::fail('请选择花材');
         }
 
-
         PurchaseItemClass::batchAdd($productList);
 
         //供货商增加订单
@@ -116,6 +116,9 @@ class PurchaseClass extends BaseClass
             util::fail('没有找到供货商');
         }
         $ghs = GhsClass::getGhsInfo($ghsId);
+        if (empty($ghs)) {
+            util::fail('还是没有找到供货商');
+        }
         $ghsSjId = $ghs['sjId'] ?? 0;
         $ghsShopId = $ghs['shopId'] ?? 0;
         $getType = $data['getType'] ?? 0;
@@ -123,7 +126,28 @@ class PurchaseClass extends BaseClass
 
         $custom = CustomClass::getByCondition(['ownSjId' => $ghsSjId, 'sjId' => $hdSjId, 'shopId' => $hdShopId]);
         if (empty($custom)) {
-            util::fail('没有找到客户');
+            $hdShop = ShopClass::getShopInfo($hdShopId);
+            $name = $hdShop['shopName'] ?? '';
+            $py = stringUtil::py($name);
+            $mobile = $hdShop['mobile'];
+            $customData = [
+                'sjId' => $hdSjId,
+                'shopId' => $hdShopId,
+                'ownSjId' => $ghsSjId,
+                'name' => $name,
+                'py' => $py,
+                'mobile' => $mobile,
+                'city' => $shop['city'] ?? '',
+                'dist' => $shop['dist'] ?? '',
+                'address' => $shop['address'] ?? '',
+                'fullAddress' => $shop['fullAddress'] ?? '',
+                'long' => $shop['long'] ?? '',
+                'lat' => $shop['lat'] ?? '',
+            ];
+            $custom = CustomClass::addCustom($customData);
+        }
+        if (empty($custom)) {
+            util::fail('还是没有找到客户');
         }
         $customId = $custom['id'] ?? 0;
         $customName = $custom['name'] ?? '';
@@ -195,18 +219,18 @@ class PurchaseClass extends BaseClass
                 $orderSn = $val['orderSn'];
                 $orderItem = PurchaseItemClass::getOrderItemDetail($orderSn);
                 $itemData = [];
-                if($orderItem) {
+                if ($orderItem) {
                     foreach ($orderItem as $v) {
-                        $info = json_decode($v['itemInfo'],true);
+                        $info = json_decode($v['itemInfo'], true);
                         $tmp = $info;
                         $tmp['cover'] = self::groupImg($info['itemCover']);
                         unset($v['itemInfo']);
                         //兼容 旧数据,没有 rank (花材等级 默认给B)
-                        if(!isset($tmp['rank'])){
-                            $tmp['rank']= 'B';
+                        if (!isset($tmp['rank'])) {
+                            $tmp['rank'] = 'B';
                         }
                         $tmp['name'] = $tmp['itemName'];
-                        $tmp = array_merge($tmp,$v);
+                        $tmp = array_merge($tmp, $v);
                         $itemData[] = $tmp;
                     }
                 }

+ 6 - 5
biz-mall/user/classes/UserClass.php

@@ -281,7 +281,7 @@ class UserClass extends BaseClass
             ]);
             $targetId = $return['id'];
 
-            $capitalType = dict::getDict('capitalType','xhMergeUser','id');
+            $capitalType = dict::getDict('capitalType', 'xhMergeUser', 'id');
             $now = time();
             $date = date("Y-m-d H:i:s");
 
@@ -570,10 +570,11 @@ class UserClass extends BaseClass
                 $user = self::generateUser($userInfo);
             }
         }
-        if (!empty($sjId)) {
-            //创建客户信息
-            CustomClass::replaceCustom($sjId, $user);
-        }
+
+        //创建客户信息
+        $custom = CustomClass::replaceCustom($sjId, $user);
+        $user['customInfo'] = $custom;
+
         return $user;
     }
 

+ 12 - 0
biz/admin/classes/AdminRoleClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace biz\admin\classes;
+
+use biz\base\classes\BaseClass;
+
+class AdminRoleClass extends BaseClass
+{
+
+    public static $baseFile = '\biz\admin\models\AdminRole';
+
+}

+ 15 - 0
biz/admin/models/AdminRole.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\admin\models;
+
+use biz\base\models\Base;
+
+class AdminRole extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhAdminRole';
+    }
+
+}

+ 11 - 0
biz/admin/services/AdminRoleService.php

@@ -0,0 +1,11 @@
+<?php
+namespace biz\admin\services;
+
+use biz\base\services\BaseService;
+
+class AdminRoleService extends BaseService
+{
+
+    public static $baseFile = '\biz\admin\classes\AdminClassRole';
+
+}

+ 20 - 0
biz/shop/classes/ShopAdminClass.php

@@ -2,6 +2,7 @@
 
 namespace biz\shop\classes;
 
+use biz\admin\classes\AdminRoleClass;
 use bizGhs\ws\services\WsService;
 use bizHd\user\classes\UserClass;
 use common\components\util;
@@ -148,4 +149,23 @@ class ShopAdminClass extends BaseClass
         return $relation;
     }
 
+    //是否有切换门店权限 0不是 1是
+    public static function hasSwitchShopRight($shopAdmin)
+    {
+        $super = 0;
+        if (isset($shopAdmin['super']) && $shopAdmin['super'] == 1) {
+            //超管
+            $super = 1;
+        } else {
+            //老板身份
+            $roleId = $shopAdmin['roleId'] ?? 0;
+            $role = AdminRoleClass::getById($roleId);
+            $authInfo = $role['auth'] ?? '';
+            if ($authInfo == '*') {
+                $super = 1;
+            }
+        }
+        return $super;
+    }
+
 }

+ 2 - 0
biz/sj/classes/SjClass.php

@@ -66,10 +66,12 @@ class SjClass extends BaseClass
     //是否有充值免费续期权限 shish 2021.4.26
     public static function hasRechargeRenewRight($sj, $ext)
     {
+        //是否参与过免费续期活动
         $rechargeRenew = $ext['rechargeRenew'] ?? 2;
         if ($rechargeRenew == 2) {
             return false;
         }
+        //是否有介绍人
         $parentId = $sj['parentId'] ?? 0;
         if (empty($parentId)) {
             return false;

+ 9 - 0
common/components/dict.php

@@ -9,6 +9,14 @@ class dict
 
     public static $data = [
 
+        //0最近访问的门店 1国兰门店信息
+        'showMallIndex' => 1,
+        //显示零售和供货商的演示入口
+        'showDemo' => 1,
+        //零售演示的管理员id
+        'hdDemoAdminId' => 138,
+        //供货商演示的管理员id
+        'ghsDemoAdminId' => 125,
         'expressList' => [
             [
                 "id" => 1,
@@ -194,6 +202,7 @@ class dict
             }
             return $respond[$first];
         }
+        return $respond;
     }
 
     //列出所有的常量 ssh 2021.3.18

+ 38 - 0
common/components/pay.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace common\components;
+
+use biz\recharge\classes\RechargeClass;
+use bizHd\order\classes\OrderClass;
+use bizHd\purchase\classes\PurchaseClass;
+use bizHd\purchase\classes\PurchaseClearClass;
+use Yii;
+
+class pay
+{
+
+    public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach)
+    {
+        //流水类型列表
+        switch ($capitalType) {
+            case dict::getDict('capitalType', 'xhRecharge', 'id'):
+                //零售和供货商充值
+                RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                break;
+            case dict::getDict('capitalType', 'xhPurchase', 'id'):
+                //零售采购订单
+                PurchaseClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                break;
+            case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
+                //零售采购订单结算
+                PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                break;
+            case dict::getDict('capitalType', 'xhOrder', 'id'):
+                //零售订单
+                OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
+                break;
+            default:
+        }
+    }
+
+}

+ 19 - 34
common/components/wxUtil.php

@@ -1376,7 +1376,7 @@ class wxUtil
             $apiUrl = Yii::$app->params['hdHost'];
         } elseif ($isOpen == 2) {
             $apiUrl = Yii::$app->params['ghsHost'];
-        }elseif($isOpen == 3){
+        } elseif ($isOpen == 3) {
             $apiUrl = Yii::$app->params['mallHost'];
         }
         $imgUrl = imgUtil::getPrefix();
@@ -1458,7 +1458,7 @@ class wxUtil
         file_put_contents($file, $result);
         //上传oss
         $obj = 'retail/miniExperience/' . $merchant['id'] . '.jpg';
-        oss::uploadImage($obj,$file);
+        oss::uploadImage($obj, $file);
         echo "<b /><img src='" . imgUtil::getPrefix() . "/retail/miniExperience/" . $merchant['id'] . ".jpg' />";
     }
 
@@ -1506,39 +1506,24 @@ class wxUtil
         $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
         $url = "https://api.weixin.qq.com/wxa/submit_audit?access_token=" . $accessToken;
         $curl = new curl\Curl();
-        if ($isOpen == 1) {
-            $data = [
-                "item_list" => [
-                    [
-                        "address" => $page,
-                        "tag" => "花卉宝 花店",
-                        "first_class" => "IT科技",
-                        "second_class" => "软件服务提供商",
-                        "first_id" => 210,
-                        "second_id" => 413,
-                        "title" => "花卉宝",
-                    ],
-                ],
-                "feedback_info" => "",
-                "feedback_stuff" => "",
-            ];
-        } else {
-            $data = [
-                "item_list" => [
-                    [
-                        "address" => $page,
-                        "tag" => "鲜花 花店",
-                        "first_class" => "商家自营",
-                        "second_class" => "鲜花/园艺/工艺品",
-                        "first_id" => 304,
-                        "second_id" => 323,
-                        "title" => "商城",
-                    ],
+
+        $data = [
+            "item_list" => [
+                [
+                    "address" => $page,
+                    "tag" => "花卉宝 花店",
+                    "first_class" => "IT科技",
+                    "second_class" => "软件服务提供商",
+                    "first_id" => 210,
+                    "second_id" => 413,
+                    "title" => "花卉宝",
                 ],
-                "feedback_info" => "",
-                "feedback_stuff" => "",
-            ];
-        }
+            ],
+            "feedback_info" => "",
+            "feedback_stuff" => "",
+            "version_desc" => "右上角若有【体验】二字,点击可登陆后台体验",
+        ];
+
         $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
         $respond = Json::decode($result);
         echo "<pre>";