Parcourir la source

支付回调问题

shish il y a 5 ans
Parent
commit
fd93f316cc

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

@@ -6,14 +6,11 @@ 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\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 +158,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;
@@ -216,11 +213,12 @@ 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);
@@ -229,7 +227,7 @@ class AuthController extends PublicController
             'admin' => $admin,
             'shopAdminId' => $shopAdminId,
             'shopId' => $currentShopId,
-            'super' => $super,
+            'switchShop' => $switchShop,
             'openShop' => $openShop,
         ]);
     }

+ 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);

+ 4 - 4
app-hd/controllers/AuthController.php

@@ -6,7 +6,6 @@ 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\httpUtil;
@@ -210,18 +209,19 @@ 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]);
+        util::success(['token' => $token, 'admin' => $admin, 'shopId' => $shopId, 'shopAdminId' => $shopAdminId, 'switchShop' => $switchShop]);
     }
 
 }

+ 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:
-        }
-    }
-
 }

+ 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);

+ 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";
+    }
+
 }

+ 1 - 1
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);

+ 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);

+ 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);
+    }
+
 }

+ 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;

+ 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:
+        }
+    }
+
+}