Эх сурвалжийг харах

下拉建立 供货商 和 客户 关系

shish 5 жил өмнө
parent
commit
533f93cd46

+ 123 - 125
app/shop/controllers/NoticeController.php

@@ -6,133 +6,131 @@ use Yii;
 use common\components\util;
 use common\services\xhPayToolService;
 use bizTy\sj\services\MerchantExtendService;
-use common\services\xhUserAssetService;
-use common\services\xhUserService;
 use common\services\xhOrderService;
-use common\components\configDict;
-use common\services\xhMerchantService;
 
 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::weixinPay($callbackParams, $orderId, $totalFee, $capitalType, $couponId);//支付回调流程
-		if ($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 actionAlipayCallback()
-	{
-		header("Content-type: text/html; charset=utf-8");
-		$alipayWap = 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'];//商户订单号
-		$merchantId = isset($pay['merchantId']) ? $pay['merchantId'] : 0;
-		$extend = MerchantExtendService::getByMerchantId($merchantId);
-		$config = [
-			//应用ID,您的APPID。
-			'app_id' => $extend['alipayPId'],
-			//商户私钥,您的原始格式RSA私钥
-			'merchant_private_key' => $extend['alipayKey'],
-			//异步通知地址
-			'notify_url' => Yii::$app->params['frontUrl'] . "/notice/alipay-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($alipayWap . '/wappay/service/AlipayTradeService.php');
-		require_once($alipayWap . '/wappay/buildermodel/AlipayTradeQueryContentBuilder.php');//查询接口
-		
-		$arr = $_POST;
-		$alipaySevice = new \AlipayTradeService($config);
-		$alipaySevice->writeLog(var_export($_POST, true));
-		$result = $alipaySevice->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 = $alipaySevice->Query($RequestBuilder);
-			$alipayId = $queryResult->buyer_user_id;
-			$alipayAccount = $queryResult->buyer_logon_id;//买家的支付宝帐号,不完整,带*号
-			$alipayParams = ['alipayId' => $alipayId, 'alipayAccount' => $alipayAccount];
-			
-			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, $alipayParams);//支付回调流程
-				if ($return['code'] == 'A0002') {
-					Yii::warning('callback exec and failed,capitalType:' . $capitalType . ' orderId:' . $orderId);
-					util::end();
-				}
-			}
-			//请不要修改或删除
-			echo "success";
-			util::end();
-		}
-		//请不要修改或删除
-		echo "fail";
-	}
-	
+
+    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::weixinPay($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 actionAlipayCallback()
+    {
+        header("Content-type: text/html; charset=utf-8");
+        $alipayWap = 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'];//商户订单号
+        $merchantId = isset($pay['merchantId']) ? $pay['merchantId'] : 0;
+        $extend = MerchantExtendService::getByMerchantId($merchantId);
+        $config = [
+            //应用ID,您的APPID。
+            'app_id' => $extend['alipayPId'],
+            //商户私钥,您的原始格式RSA私钥
+            'merchant_private_key' => $extend['alipayKey'],
+            //异步通知地址
+            'notify_url' => Yii::$app->params['frontUrl'] . "/notice/alipay-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($alipayWap . '/wappay/service/AlipayTradeService.php');
+        require_once($alipayWap . '/wappay/buildermodel/AlipayTradeQueryContentBuilder.php');//查询接口
+
+        $arr = $_POST;
+        $alipaySevice = new \AlipayTradeService($config);
+        $alipaySevice->writeLog(var_export($_POST, true));
+        $result = $alipaySevice->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'];
+        $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 = $alipaySevice->Query($RequestBuilder);
+        $alipayId = $queryResult->buyer_user_id;
+        $alipayAccount = $queryResult->buyer_logon_id;//买家的支付宝帐号,不完整,带*号
+        $alipayParams = ['alipayId' => $alipayId, 'alipayAccount' => $alipayAccount];
+
+        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, $alipayParams);//支付回调流程
+            if ($return['code'] == 'A0002') {
+                Yii::warning('callback exec and failed,capitalType:' . $capitalType . ' orderId:' . $orderId);
+                util::end();
+            }
+        }
+        //请不要修改
+        echo "success";
+    }
+
 }

+ 3 - 1
biz-ghs/merchant/classes/SupplierClass.php

@@ -10,7 +10,9 @@ class SupplierClass extends BaseClass
 {
 	
 	public static $baseFile = '\bizGhs\merchant\models\Supplier';
-	
+
+	public static function
+
 	//根据xhSupplier的id数组 取供货商信息 shish 2021.1.18
 	public static function getSupplierByIds($ids)
 	{

+ 51 - 3
biz/purchase/classes/PurchaseClass.php

@@ -5,7 +5,9 @@ namespace biz\purchase\classes;
 use biz\merchant\classes\ShopClass;
 use biz\order\classes\OrderClass;
 use bizGhs\admin\classes\AdminClass;
+use bizGhs\custom\classes\CustomClass;
 use bizGhs\merchant\classes\SupplierClass;
+use bizTy\sj\classes\MerchantClass;
 use common\components\orderSn;
 use common\components\stringUtil;
 use common\components\util;
@@ -26,9 +28,9 @@ class PurchaseClass extends BaseClass
     //未知
     const DEBT_UNKNOWN = 0;
     //欠款
-	const DEBT_YES = 1;
-	//没有欠款
-	const DEBT_NO = 2;
+    const DEBT_YES = 1;
+    //没有欠款
+    const DEBT_NO = 2;
 
     //添加采购 shish 2021.1.18
     public static function addPurchase($data)
@@ -144,4 +146,50 @@ class PurchaseClass extends BaseClass
         util::fail('没有权限操作');
     }
 
+    //采购订单支付成功后回调处理流程
+    public static function complete($purchase)
+    {
+        $supplierId = $purchase->supplierId;
+        if (empty($supplierId)) {
+
+            //补充供货商关系
+            $upId = $purchase->upId;
+            $supplierSj = MerchantClass::getMerchantById($upId);
+            $upName = $supplierSj['merchantName'] ?? '';
+            $upShopId = $purchase->upShopId;
+            $shopId = $purchase->shopId;
+            $merchantId = $purchase->merchantId;
+            $py = !empty($upName) ? stringUtil::getSpelling($upName) : '';
+            $has = SupplierClass::getByCondition(['merchantId' => $merchantId, 'upId' => $upId, 'upShopId' => $upShopId]);
+            if (empty($has)) {
+                $supplierData = [
+                    'upId' => $upId,
+                    'name' => $upName,
+                    'py' => $py,
+                    'upShopId' => $upShopId,
+                    'merchantId' => $merchantId,
+                ];
+                SupplierClass::add($supplierData);
+            }
+
+            //补充客户关系
+            $customSj = MerchantClass::getMerchantById($merchantId);
+            $customSjName = $customSj['merchantName'] ?? '';
+            $py = !empty($customSjName) ? stringUtil::getSpelling($customSjName) : '';
+            $has = CustomClass::getByCondition(['sjId' => $upId, 'customSjId' => $merchantId, 'customShopId' => $shopId]);
+            if (empty($has)) {
+                $customData = [
+                    'customSjId' => $merchantId,
+                    'customShopId' => $shopId,
+                    'sjId' => $upId,
+                    'name' => $customSjName,
+                    'mobile' => 0,
+                    'isOpen' => 0,
+                    'py' => $py,
+                ];
+                CustomClass::add($customData);
+            }
+        }
+    }
+
 }

+ 3 - 0
common/components/configDict.php

@@ -107,6 +107,8 @@ class configDict
             'xhRenew' => ['id' => 9, 'name' => 'xhRenew'],
             //供货商订单
             'xhGhsOrder' => ['id' => 10, 'name' => 'xhGhsOrder'],
+            //花店采购
+            'xhPurchase' => ['id' => 11, 'name' => 'xhPurchase'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail'],
@@ -118,6 +120,7 @@ class configDict
             8 => ['link' => '/capital/merge-user', 'name' => '帐号合并', 'orderLink' => ''],
             9 => ['link' => '/capital/renew', 'name' => '续费', 'orderLink' => ''],
             10 => ['link' => '/capital/order-detail', 'name' => '订单', 'orderLink' => ''],
+            11 => ['link' => '/capital/purchase-detail', 'name' => '订单', 'orderLink' => ''],
         ],
         "imgSavePath" => [//图片保存目录
             'wxUserAvatar' => 'weixinUserAvatar',//微信用户头像

+ 20 - 6
common/services/xhPayToolService.php

@@ -5,12 +5,11 @@ namespace common\services;
 use biz\coupon\classes\CouponClass;
 use biz\merchant\classes\ShopClass;
 use biz\order\classes\OrderClass;
-use biz\order\classes\OrderSendClass;
-use biz\order\services\OrderService;
-use biz\recharge\classes\RechargeClass;
+use biz\purchase\classes\PurchaseClass;
 use biz\user\classes\UserClass;
 use biz\user\services\UserAssetService;
 use biz\user\services\UserService;
+use bizTy\recharge\classes\RechargeClass;
 use common\components\noticeUtil;
 use common\components\stringUtil;
 use common\components\util;
@@ -67,8 +66,7 @@ class xhPayToolService
     //充值回调处理 shish 2021.2.21
     public static function recharge($transaction, $callbackParams, $orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams)
     {
-
-        $recharge = RechargeClass::getByCondition(['orderSn' => $orderSn],true);
+        $recharge = RechargeClass::getByCondition(['orderSn' => $orderSn], true);
         if (empty($recharge)) {
             noticeUtil::push('充值付款成功,收到回调,但没有找到充值记录,orderSn:' . $orderSn, '15280215347');
             return ['amount' => $totalFee];
@@ -77,7 +75,7 @@ class xhPayToolService
             noticeUtil::push("充值付款成功,收到回调,但金额不一致 {$totalFee} {$recharge->amount},orderSn:" . $orderSn, '15280215347');
             return ['amount' => $totalFee];
         }
-        if($recharge->payStatus == RechargeClass::PAY_STATUS_HAS_PAY){
+        if ($recharge->payStatus == RechargeClass::PAY_STATUS_HAS_PAY) {
             noticeUtil::push("充值付款成功,收到回调,但订单是已经支付过了,orderSn:" . $orderSn, '15280215347');
             return ['amount' => $totalFee];
         }
@@ -89,6 +87,17 @@ class xhPayToolService
         return ['amount' => $totalFee];
     }
 
+    //零售采购回调 shish 2021.2.28
+    public static function retailPurchase($transaction, $callbackParams, $orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams)
+    {
+        $purchase = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($purchase)) {
+            return [];
+        }
+        PurchaseClass::complete($purchase);
+        $transaction->commit();
+    }
+
     /**
      * 基础支付
      * $capitalType 需要支付订单来源:xhOrder xhActiveOrder xhApplyOrder
@@ -122,6 +131,11 @@ class xhPayToolService
                     return self::ghsOrderPay($transaction, $callbackParams, $orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams);
                     Yii::$app->end();
                     break;
+                case $capitalTypeList['xhGhsOrder']['id']:
+                    //零售店采购
+                    return self::retailPurchase($transaction, $callbackParams, $orderSn, $totalFee, $capitalType, $couponId, $payWay, $alipayParams);
+                    Yii::$app->end();
+                    break;
                 default:
                     Yii::warning('获取订单信息失败,回调传过来的 capitalType 不符合要求,capitalType:' . $capitalType . ' orderSn:' . $orderSn);
                     util::fail('订单流水类型不明确');

+ 6 - 1
sql.sql

@@ -1279,4 +1279,9 @@ ALTER TABLE xhApply MODIFY `introStyle` TINYINT(4) NOT NULL DEFAULT '0' COMMENT
 ALTER TABLE xhApply ADD introSjName VARCHAR(100) NOT NULL DEFAULT '' COMMENT '商家名称' AFTER `introStyle`;
 ALTER TABLE xhApply ADD introShopId INT NOT NULL DEFAULT 0 COMMENT '引荐商家的门店' AFTER `introSjName`;
 ALTER TABLE xhApply ADD customId INT NOT NULL DEFAULT 0 COMMENT '客户id' AFTER `introShopId`;
-ALTER TABLE xhApply ADD shopAdminId INT NOT NULL DEFAULT 0 COMMENT '员工id' AFTER `customId`;
+ALTER TABLE xhApply ADD shopAdminId INT NOT NULL DEFAULT 0 COMMENT '员工id' AFTER `customId`;
+
+需要哪些供货商要跟纯彩花艺收集好并且导入
+
+ALTER TABLE xhGhsCustom ADD `py` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '拼音首字母' AFTER `name`;
+ALTER TABLE xhCustom ADD `py` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '拼音首字母' AFTER `name`;