shish 6 rokov pred
rodič
commit
b8d22306bd

+ 102 - 1
app/shop/controllers/ApplyController.php

@@ -3,12 +3,18 @@
 namespace shop\controllers;
 
 use biz\saas\services\ApplyService;
+use biz\wx\services\WxBaseService;
+use biz\wx\services\WxOpenService;
 use Yii;
 use common\components\util;
+use biz\admin\services\AdminService;
+use biz\saas\classes\ApplyClass;
+use biz\saas\services\RegionService;
+use yii\web\Controller;
 
 class ApplyController extends BaseController
 {
-
+	
 	//我的代理 shish 2019.12.26
 	public function actionList()
 	{
@@ -22,4 +28,99 @@ class ApplyController extends BaseController
 		util::success($data);
 	}
 	
+	//审核
+	public function actionCheck()
+	{
+		$id = Yii::$app->request->post('id');
+		$status = Yii::$app->request->post('status', 0);
+		$remark = Yii::$app->request->post('remark', '');
+		$apply = ApplyService::getById($id);
+		if (empty($apply)) {
+			util::fail('找不到申请记录');
+		}
+		if ($apply['status'] != 0) {
+			util::fail('已经审过了');
+		}
+		if ($status == 1) {
+			ApplyService::pass($id);
+		}
+		ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
+		util::success('操作成功');
+	}
+	
+	//申请试用 shish 2020.1.11
+	public function actionRegister()
+	{
+
+		$rand = rand(0, 1);
+		$wxBase = WxBaseService::getWxBase();
+		$wxAliasName = isset($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
+		$data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
+		if ($rand == 0) {
+			$data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
+		}
+		util::success($data);
+
+		
+		$get = Yii::$app->request->get();
+		if (isset($get['oldId']) && !empty($get['oldId'])) {
+			$get['introMerchantId'] = $get['oldId'];
+		}
+		$get['userId'] = $this->userId;
+		$get['long'] = isset($get['longitude']) ? $get['longitude'] : '';
+		$get['lat'] = isset($get['latitude']) ? $get['latitude'] : '';
+		
+		$cacheKey = 'OPEN_SHOP_APPLY_' . $this->userId;
+		$cacheCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+		if (isset($cacheCode) == false || empty($cacheCode)) {
+			util::fail('没有验证码');
+		}
+		if ($get['code'] != $cacheCode) {
+			util::fail('验证码错误');
+		}
+		
+		$apply = ApplyClass::getByCondition(['userId' => $this->userId]);
+		if (!empty($apply)) {
+			util::fail('您已经申请过了');
+		}
+		$admin = AdminService::getByCondition(['platUserId' => $this->userId]);
+		if (!empty($admin)) {
+			util::fail('您已经开店了');
+		}
+		ApplyService::addApply($get);
+		$rand = rand(0, 1);
+		$wxBase = WxBaseService::getWxBase();
+		$wxAliasName = isset($wxBase['wxAliasName']) ? $wxBase['wxAliasName'] : 'ihuahuibao';
+		$data = ['focus' => 1, 'wxAliasName' => $wxAliasName];
+		if ($rand == 0) {
+			$data = ['focus' => 0, 'wxAliasName' => $wxAliasName];
+		}
+		util::success($data);
+	}
+	
+	//申请状态
+	public function actionApplyStatus()
+	{
+		//-1申请试用 0审核中 1审核通过、试用中 2审核未通过 3已付费,立即订购 4试用到期失效,待付款,立即订购,价格不显示
+		$status = -1;
+		util::success(['status' => $status]);
+	}
+	
+	//地图相关信息 shish 2020.1.14
+	public function actionRegionRelate()
+	{
+		$regionTree = RegionService::tree();
+		$mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
+		$out = ['region' => $regionTree, 'txMapKey' => $mapKey];
+		util::success($out);
+	}
+	
+	//获取申请的验证码 shish 2020.2.23
+	public function actionGetValidateCode()
+	{
+		$mobile = Yii::$app->request->get('mobile');
+		util::success(['code' => rand(1111, 9999)]);
+	}
+	
+	
 }

+ 98 - 92
biz/wx/classes/WxBaseClass.php

@@ -11,97 +11,103 @@ use linslin\yii2\curl;
 
 class WxBaseClass extends BaseClass
 {
-
-    public static $baseFile = '\biz\wx\models\WxBase';
-
-    //保存Logo shish 2020.3.11
-    public static function saveLogo($url, $merchantId)
-    {
-        $path = dirUtil::getImgDir();
-        $middle = "/wx/merchant/logo/";
-        if (!file_exists($path . $middle)) {
-            mkdir($path . $middle, 0777, true);
-        }
-        if (empty($merchantId)) {
-            $merchantId = stringUtil::shortUniqueId($merchantId);
-        }
-        $name = $merchantId . '.jpg';
-        $fullFileName = $path . $middle . $name;
-        $fileName = $middle . $name;
-
-        if (file_exists($fullFileName)) {
-            return $fileName;
-        }
-
-        $curl = new curl\Curl();
-        $result = $curl->get($url);
-
-        $fp = @fopen($fullFileName, 'a');
-        fwrite($fp, $result);
-        fclose($fp);
-
-        $imgInfo = getimagesize($fullFileName);
-        if (empty($imgInfo) || isset($imgInfo[0]) == false) {
-            return '';
-        }
-        $width = $imgInfo[0];
-        $height = $imgInfo[1];
-
-        //生成小图 280px
-        $smallWidth = 280;
-        $smallHeight = ceil((280 * $height) / $width);
-        if ($width <= 280) {
-            $smallWidth = $width;
-            $smallHeight = $height;
-        }
-        $smallFullPathFile = $path . $middle . $merchantId . '_small.jpg';
-        Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
-        return $fileName;
-    }
-
-    //保存公众号二维码 shish 2020.3.11
-    public static function saveQrCode($url, $merchantId)
-    {
-        $path = dirUtil::getImgDir();
-        $middle = "/wx/merchant/qrCode/";
-        if (!file_exists($path . $middle)) {
-            mkdir($path . $middle, 0777, true);
-        }
-        if (empty($merchantId)) {
-            $merchantId = stringUtil::shortUniqueId($merchantId);
-        }
-        $name = $merchantId . '.jpg';
-        $fullFileName = $path . $middle . $name;
-        $fileName = $middle . $name;
-
-        if (file_exists($fullFileName)) {
-            return $fileName;
-        }
-
-        $curl = new curl\Curl();
-        $result = $curl->get($url);
-
-        $fp = @fopen($fullFileName, 'a');
-        fwrite($fp, $result);
-        fclose($fp);
-
-        $imgInfo = getimagesize($fullFileName);
-        if (empty($imgInfo) || isset($imgInfo[0]) == false) {
-            return '';
-        }
-        $width = $imgInfo[0];
-        $height = $imgInfo[1];
-
-        //生成小图 280px
-        $smallWidth = 280;
-        $smallHeight = ceil((280 * $height) / $width);
-        if ($width <= 280) {
-            $smallWidth = $width;
-            $smallHeight = $height;
-        }
-        $smallFullPathFile = $path . $middle . $merchantId . '_small.jpg';
-        Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
-        return $fileName;
-    }
+	
+	public static $baseFile = '\biz\wx\models\WxBase';
+	
+	//保存Logo shish 2020.3.11
+	public static function saveLogo($url, $merchantId)
+	{
+		$path = dirUtil::getImgDir();
+		$middle = "/wx/merchant/logo/";
+		if (!file_exists($path . $middle)) {
+			mkdir($path . $middle, 0777, true);
+		}
+		if (empty($merchantId)) {
+			$merchantId = stringUtil::shortUniqueId($merchantId);
+		}
+		$name = $merchantId . '.jpg';
+		$fullFileName = $path . $middle . $name;
+		$fileName = $middle . $name;
+		
+		if (file_exists($fullFileName)) {
+			return $fileName;
+		}
+		
+		$curl = new curl\Curl();
+		$result = $curl->get($url);
+		
+		$fp = @fopen($fullFileName, 'a');
+		fwrite($fp, $result);
+		fclose($fp);
+		
+		$imgInfo = getimagesize($fullFileName);
+		if (empty($imgInfo) || isset($imgInfo[0]) == false) {
+			return '';
+		}
+		$width = $imgInfo[0];
+		$height = $imgInfo[1];
+		
+		//生成小图 280px
+		$smallWidth = 280;
+		$smallHeight = ceil((280 * $height) / $width);
+		if ($width <= 280) {
+			$smallWidth = $width;
+			$smallHeight = $height;
+		}
+		$smallFullPathFile = $path . $middle . $merchantId . '_small.jpg';
+		Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
+		return $fileName;
+	}
+	
+	//保存公众号二维码 shish 2020.3.11
+	public static function saveQrCode($url, $merchantId)
+	{
+		$path = dirUtil::getImgDir();
+		$middle = "/wx/merchant/qrCode/";
+		if (!file_exists($path . $middle)) {
+			mkdir($path . $middle, 0777, true);
+		}
+		if (empty($merchantId)) {
+			$merchantId = stringUtil::shortUniqueId($merchantId);
+		}
+		$name = $merchantId . '.jpg';
+		$fullFileName = $path . $middle . $name;
+		$fileName = $middle . $name;
+		
+		if (file_exists($fullFileName)) {
+			return $fileName;
+		}
+		
+		$curl = new curl\Curl();
+		$result = $curl->get($url);
+		
+		$fp = @fopen($fullFileName, 'a');
+		fwrite($fp, $result);
+		fclose($fp);
+		
+		$imgInfo = getimagesize($fullFileName);
+		if (empty($imgInfo) || isset($imgInfo[0]) == false) {
+			return '';
+		}
+		$width = $imgInfo[0];
+		$height = $imgInfo[1];
+		
+		//生成小图 280px
+		$smallWidth = 280;
+		$smallHeight = ceil((280 * $height) / $width);
+		if ($width <= 280) {
+			$smallWidth = $width;
+			$smallHeight = $height;
+		}
+		$smallFullPathFile = $path . $middle . $merchantId . '_small.jpg';
+		Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
+		return $fileName;
+	}
+
+	//取公众号信息 0表示平台的公众号 shish 2020.4.26
+	public static function getWxBase($id = 0)
+	{
+		return self::getByCondition(['merchantId' => 0]);
+	}
 
 }

+ 8 - 2
biz/wx/services/WxBaseService.php

@@ -3,6 +3,7 @@
 namespace biz\wx\services;
 
 use biz\base\services\BaseService;
+use biz\wx\classes\WxBaseClass;
 use biz\wx\classes\WxMenuClass;
 use biz\wx\classes\WxOpenClass;
 use common\components\httpUtil;
@@ -11,7 +12,12 @@ use Yii;
 
 class WxBaseService extends BaseService
 {
-
+	
 	public static $baseFile = '\biz\wx\classes\WxBaseClass';
-
+	
+	public static function getWxBase($id = 0)
+	{
+		return WxBaseClass::getWxBase($id);
+	}
+	
 }