Browse Source

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

林琦海 5 years ago
parent
commit
c96235fd9b

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

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\admin\classes\AdminClass;
 use bizHd\admin\classes\ShopAdminClass;
 use bizGhs\shop\services\ShopAdminService;
 use bizGhs\admin\services\AdminService;
@@ -154,19 +155,17 @@ class AuthController extends PublicController
         if (empty($password)) {
             util::fail('请输入密码');
         }
-        $admin = AdminService::getByCondition(['mobile' => $mobile]);
+        $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_GHS]);
         if (password_verify($password, $admin['password']) == false) {
             util::fail('密码错误');
         }
         $adminId = $admin['id'];
-        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId]);
+        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0]);
         $merchantId = isset($shopAdmin['merchantId']) ? $shopAdmin['merchantId'] : 0;
-        $shopId = isset($shopAdmin['shopId']) ? $shopAdmin['shopId'] : 0;
+        $shopId = $shopAdmin['shopId'] ?? 0;
         if (empty($shopId)) {
             util::fail('您不是管理员');
         }
-        //管理员关联门店
-        Yii::$app->redis->executeCommand('SET', ['LOGIN_ADMIN_SHOP' . $adminId, $shopId]);
         //获取token
         $token = jwt::getNewToken($adminId);
         util::success(['token' => $token, 'account' => $merchantId, 'shopId' => $shopId]);

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

@@ -114,7 +114,7 @@ class OrderController extends BaseController
             util::success($return);
         } catch (\Exception $e) {
             $transaction->rollBack();
-            Yii::info("下单报错:" . $e->getMessage());
+            Yii::info("下单失败原因:" . $e->getMessage());
             util::fail('下单失败');
         }
     }

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

@@ -153,14 +153,14 @@ class AuthController extends PublicController
         if (empty($password)) {
             util::fail('请输入密码');
         }
-        $admin = AdminService::getByCondition(['style' => AdminClass::STYLE_HD, 'mobile' => $mobile]);
+        $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_HD]);
         if (password_verify($password, $admin['password']) == false) {
             util::fail('密码错误');
         }
         $adminId = $admin['id'];
-        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId]);
+        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0]);
         $merchantId = isset($shopAdmin['merchantId']) ? $shopAdmin['merchantId'] : 0;
-        $shopId = isset($shopAdmin['shopId']) ? $shopAdmin['shopId'] : 0;
+        $shopId = $shopAdmin['shopId'] ?? 0;
         if (empty($shopId)) {
             util::fail('您不是管理员');
         }

+ 7 - 2
app-mall/controllers/BaseController.php

@@ -17,7 +17,7 @@ class BaseController extends PublicController
     public $validate = true;
     public $guestAccessAction = [];
     public $userId = 0, $user, $shopId;
-    public $sjId, $sj, $sjExtend, $customId = 0;
+    public $sjId, $sj, $sjExtend, $customId = 0, $custom = [];
     public $isWx;
 
     public function beforeAction($action)
@@ -56,7 +56,12 @@ class BaseController extends PublicController
                 util::fail('没有用户信息');
             }
             $this->user = $userInfo;
-            $customId = CustomClass::getCurrentCustomId($sjId, $userInfo);
+            $custom = CustomClass::getCurrentCustom($sjId, $userInfo);
+            if (empty($custom)) {
+                util::fail('没有找到客户');
+            }
+            $this->custom = $custom;
+            $customId = $custom['id'] ?? 0;
             $this->customId = $customId;
         }
         //游客可以访问的方法

+ 97 - 93
app-mall/controllers/OrderController.php

@@ -7,6 +7,7 @@ use bizMall\merchant\services\ExpressService;
 use bizMall\merchant\services\MerchantExtendService;
 use bizMall\merchant\services\MerchantService;
 use bizMall\merchant\services\ShopService;
+use bizMall\order\classes\OrderClass;
 use bizMall\order\services\OrderGoodsService;
 use bizMall\order\services\OrderService;
 use bizMall\promote\services\CouponService;
@@ -45,85 +46,98 @@ class OrderController extends BaseController
         //运费计算方式
         $freightType = isset($goodsInfo['freightType']) ? $goodsInfo['freightType'] : 0;
 
-        $post['userId'] = $this->userId;
-        $user = $this->user;
-        $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
-        $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
-        $post['bookMobile'] = $bookMobile;
-
-        $post['payWay'] = $this->isWx == true ? 0 : 1;
-        $defaultShopId = MerchantService::getDefaultShopId($this->sj);
-        if (empty($defaultShopId)) {
-            util::fail('没有找到门店');
-        }
-        //计算运费
-        $post['sendDistance'] = isset($post['sendDistance']) ? $post['sendDistance'] : 0;
-        $sendCost = 0;
-        //按距离计算运费并且客户要求送的
-        if ($freightType == 0 && $needSend == 1) {
-            $lat = $post['latitude'];//收货人纬度
-            $lng = $post['longitude'];//收货人经度
-            $respond = ExpressService::getUserDistance($lng, $lat, $defaultShopId, $this->sjExtend);
-            $sendCost = isset($respond['fee']) ? $respond['fee'] : 0;
-        }
-        $post['sendCost'] = $sendCost;
-        $post['merchantId'] = $this->sjId;
-        $post['shopId'] = $defaultShopId;
-
-        //计算总金额
-        $unitPrice = $goodsInfo['price'];
-        $goodsStyleList = isset($goodsInfo['goodsStyleList']) ? $goodsInfo['goodsStyleList'] : [];
-        if (!empty($goodsStyleId)) {
-            if (empty($goodsStyleList)) {
-                util::fail('商品款式没有找到');
+        //事务处理
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+
+            $post['userId'] = $this->userId;
+            $user = $this->user;
+            $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
+            $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
+            $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
+            $post['bookMobile'] = $bookMobile;
+
+            $post['payWay'] = $this->isWx == true ? 0 : 1;
+            $defaultShopId = MerchantService::getDefaultShopId($this->sj);
+            if (empty($defaultShopId)) {
+                util::fail('没有找到门店');
             }
-            $styleIdList = array_keys($goodsStyleList);
-            if (in_array($goodsStyleId, $styleIdList) == false) {
-                util::fail('商品款式没有找到!');
+            //计算运费
+            $post['sendDistance'] = isset($post['sendDistance']) ? $post['sendDistance'] : 0;
+            $sendCost = 0;
+            //按距离计算运费并且客户要求送的
+            if ($freightType == 0 && $needSend == 1) {
+                $lat = $post['latitude'];//收货人纬度
+                $lng = $post['longitude'];//收货人经度
+                $respond = ExpressService::getUserDistance($lng, $lat, $defaultShopId, $this->sjExtend);
+                $sendCost = isset($respond['fee']) ? $respond['fee'] : 0;
             }
-            $unitPrice = isset($goodsStyleList[$goodsStyleId]['price']) ? $goodsStyleList[$goodsStyleId]['price'] : 9999;
-        }
-        $goodsPrice = $unitPrice * $goodsNum;
-        $prePrice = stringUtil::calcAdd($sendCost, $goodsPrice);
-        //非门店订单
-        $store = 0;
-        $post['store'] = $store;
-        //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
-        $sourceType = $this->isWx ? 0 : 1;
-        if (httpUtil::isMiniProgram()) {
-            $sourceType = 2;
+            $post['sendCost'] = $sendCost;
+            $post['merchantId'] = $this->sjId;
+            $post['shopId'] = $defaultShopId;
+
+            //计算总金额
+            $unitPrice = $goodsInfo['price'];
+            $goodsStyleList = isset($goodsInfo['goodsStyleList']) ? $goodsInfo['goodsStyleList'] : [];
+            if (!empty($goodsStyleId)) {
+                if (empty($goodsStyleList)) {
+                    util::fail('商品款式没有找到');
+                }
+                $styleIdList = array_keys($goodsStyleList);
+                if (in_array($goodsStyleId, $styleIdList) == false) {
+                    util::fail('商品款式没有找到!');
+                }
+                $unitPrice = isset($goodsStyleList[$goodsStyleId]['price']) ? $goodsStyleList[$goodsStyleId]['price'] : 9999;
+            }
+            $goodsPrice = $unitPrice * $goodsNum;
+            $prePrice = stringUtil::calcAdd($sendCost, $goodsPrice);
+            //非门店订单
+            $store = 0;
+            $post['store'] = $store;
+            //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
+            $sourceType = $this->isWx ? 0 : 1;
+            if (httpUtil::isMiniProgram()) {
+                $sourceType = 2;
+            }
+            $couponId = isset($post['couponId']) && !empty($post['couponId']) ? $post['couponId'] : 0;
+            $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->userId]);
+            $actPrice = $discountData['price'];
+            $post['discountType'] = $discountData['discountType'];
+            $post['discountAmount'] = $discountData['discountAmount'];
+
+            $now = time();
+            $expireTime = $now + 1800;//订单30分钟后过期
+            $post['deadline'] = $expireTime;
+            $post['fromType'] = 1;//商城
+            $post['prePrice'] = $prePrice;
+            $post['actPrice'] = $actPrice;
+            $order = OrderClass::addOrder($post);
+            $orderId = $order['id'];
+            $orderSn = $order['orderSn'];
+            $data = [
+                'orderId' => $orderId,
+                'goodsId' => $goodsId,
+                'userId' => $this->userId,
+                'merchantId' => $this->sjId,
+                'title' => $goodsInfo['goodsName'],
+                'cover' => isset($goodsInfo['shortImgList']) && !empty($goodsInfo['shortImgList']) ? current($goodsInfo['shortImgList']) : '',
+                'unitPrice' => $unitPrice,
+                'num' => $goodsNum,
+                'goodsStyleName' => isset($goodsInfo['goodsStyleList'][$goodsStyleId]['title']) ? $goodsInfo['goodsStyleList'][$goodsStyleId]['title'] : '',
+                'goodsStyleId' => $goodsStyleId,
+                'createTime' => date("Y-m-d H:i:s"),
+            ];
+            OrderGoodsService::add($data);//创建订单商品列表
+
+            $transaction->commit();
+            util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice, 'couponId' => $couponId]);
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            Yii::info("下单失败原因:" . $e->getMessage());
+            util::fail('下单失败');
         }
-        $couponId = isset($post['couponId']) && !empty($post['couponId']) ? $post['couponId'] : 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->userId]);
-        $actPrice = $discountData['price'];
-        $post['discountType'] = $discountData['discountType'];
-        $post['discountAmount'] = $discountData['discountAmount'];
 
-        $now = time();
-        $expireTime = $now + 1800;//订单30分钟后过期
-        $post['deadline'] = $expireTime;
-        $post['fromType'] = 1;//商城
-        $post['prePrice'] = $prePrice;
-        $post['actPrice'] = $actPrice;
-        $order = OrderService::addOrder($post);
-        $orderId = $order['id'];
-        $orderSn = $order['orderSn'];
-        $data = [
-            'orderId' => $orderId,
-            'goodsId' => $goodsId,
-            'userId' => $this->userId,
-            'merchantId' => $this->sjId,
-            'title' => $goodsInfo['goodsName'],
-            'cover' => isset($goodsInfo['shortImgList']) && !empty($goodsInfo['shortImgList']) ? current($goodsInfo['shortImgList']) : '',
-            'unitPrice' => $unitPrice,
-            'num' => $goodsNum,
-            'goodsStyleName' => isset($goodsInfo['goodsStyleList'][$goodsStyleId]['title']) ? $goodsInfo['goodsStyleList'][$goodsStyleId]['title'] : '',
-            'goodsStyleId' => $goodsStyleId,
-            'createTime' => date("Y-m-d H:i:s"),
-        ];
-        OrderGoodsService::add($data);//创建订单商品列表
-        util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice, 'couponId' => $couponId]);
     }
 
     //下单要用到的相关信息 shish 2019.12.6
@@ -262,11 +276,7 @@ class OrderController extends BaseController
         $store = isset($post['store']) ? $post['store'] : 1;
         $post['store'] = $store;
         //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
-        $sourceType = $this->isWx ? 0 : 1;
-        if (httpUtil::isMiniProgram()) {
-            $sourceType = 2;
-        }
-        $sourceType = isset($post['sourceType']) ? $post['sourceType'] : 0;
+        $sourceType = isset($post['sourceType']) ? $post['sourceType'] : 2;
         //兼容旧系统sourceType=3表示朋友圈来源
         $fromType = $sourceType == 3 ? 2 : 0;
         $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
@@ -297,7 +307,7 @@ class OrderController extends BaseController
         $post['sourceType'] = $sourceType;
         $post['goodsNum'] = 1;
         $post['fromType'] = $fromType;
-        $order = OrderService::addOrder($post);
+        $order = OrderClass::addOrder($post);
         $orderId = $order['id'];
         $orderSn = $order['orderSn'];
         $sjId = $this->sjId;
@@ -306,13 +316,10 @@ class OrderController extends BaseController
             $name = '购买商品';
             $totalFee = $actPrice;
             $user = UserService::getById($this->userId);
-            $openId = isset($user['openId']) ? $user['openId'] : 0;
-            if (httpUtil::isMiniProgram()) {
-                //小程序使用miniOpenId
-                $openId = $user['miniOpenId'];
-            }
+            //小程序使用miniOpenId
+            $openId = $user['miniOpenId'];
             if (empty($openId)) {
-                util::fail('没有找到客户的openId');
+                util::fail('没有找您的微信ID');
             }
             $typeList = dict::getConfig('capitalType');
             $capitalType = $typeList['xhOrder']['id'];
@@ -336,13 +343,10 @@ class OrderController extends BaseController
             $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
             $input->SetTrade_type("JSAPI");
 
-            //花卉宝代为申请的微信支付
             $sjExtend = $this->sjExtend;
-            if ($sjExtend['wxPayApply'] == 1) {
-                $input->SetSub_openid($openId);
-            } else {
-                $input->SetOpenid($openId);
-            }
+            //花卉宝代为申请的微信支付
+            //$input->SetSub_openid($openId);
+            $input->SetOpenid($openId);
             //小程序使用miniAppId
             if (httpUtil::isMiniProgram()) {
                 $sjExtend['wxAppId'] = $sjExtend['miniAppId'];

+ 2 - 2
app-mall/controllers/UserController.php

@@ -164,8 +164,8 @@ class UserController extends BaseController
     //用户基本信息和资产 shish 2019.12.19
     public function actionMyProfile()
     {
-        $user = UserService::getUserInfo($this->userId);
-        $growth = $user['userAsset']['growth'];
+        $user = $this->custom;
+        $growth = $user['growth'] ?? 0;
         $extend = $this->sjExtend;
         $grade = MerchantExtendService::getGradeList($extend, 'asc');
         //下个等级的积分

+ 9 - 6
biz-hd/custom/classes/CustomClass.php

@@ -19,19 +19,22 @@ class CustomClass extends BaseClass
         return 'hd_custom_key_' . $sjId . '_' . $userId;
     }
 
-    public static function getCurrentCustomId($sjId, $user)
+    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)) {
-            return $currentId;
+            $info = self::getById($currentId);
         }
-        $info = self::getByCondition(['sjId' => $sjId, 'userId' => $userId]);
-        if (!empty($info)) {
-            return $info['id'];
+        if (empty($info)) {
+            $info = self::getByCondition(['sjId' => $sjId, 'userId' => $userId]);
+        } else {
+            $id = $info['id'];
+            Yii::$app->redis->executeCommand('SET', [$key, $id]);
         }
-        return 0;
+        return $info;
     }
 
     //创建获取客户信息 shish 2021.3.19

+ 2 - 13
biz-mall/order/classes/OrderClass.php

@@ -3,18 +3,11 @@
 namespace bizMall\order\classes;
 
 use bizMall\merchant\classes\MerchantAssetClass;
-use bizMall\merchant\classes\MerchantClass;
-use bizMall\message\classes\InformAdminClass;
-use bizMall\message\classes\InformUserClass;
 use bizMall\stat\classes\StatOrderClass;
 use bizMall\stat\classes\StatOrderCountClass;
-use bizMall\stat\classes\StatOrderMonthClass;
 use bizMall\user\classes\UserClass;
 use common\components\miniUtil;
-use common\components\stringUtil;
-use common\services\xhOrderDayNumService;
-use common\services\xhOrderMonthNumService;
-use Yii;
+use common\components\orderSn;
 use bizMall\base\classes\BaseClass;
 
 class OrderClass extends BaseClass
@@ -64,13 +57,9 @@ class OrderClass extends BaseClass
     //添加订单 shish 2019.12.5
     public static function addOrder($data)
     {
-        $date = date("Y-m-d H:i:s");
         $merchantId = $data['merchantId'];
-        $data['orderSn'] = stringUtil::generateOrderNo($merchantId, $data['userId']);
+        $data['orderSn'] = orderSn::getOrderSn();
         $data['payStatus'] = 0;
-        $data['createTime'] = $date;
-        $data['addTime'] = time();
-
         $month = date("Ym");
         $riseNum = StatOrderCountClass::addOrder($month, $merchantId);
         //将花店每月的总订单数作为编号

+ 0 - 6
biz-mall/order/services/OrderService.php

@@ -23,12 +23,6 @@ class OrderService extends BaseService
 
     public static $baseFile = '\bizMall\order\classes\OrderClass';
 
-    //添加订单
-    public static function addOrder($data)
-    {
-        return OrderClass::addOrder($data);
-    }
-
     //获取订单信息 shish 2019.11.28
     public static function getOrderList($where)
     {

+ 12 - 0
biz-mall/renew/classes/RenewSnClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizMall\renew\classes;
+
+use bizMall\base\classes\BaseClass;
+
+class RenewSnClass extends BaseClass
+{
+
+    public static $baseFile = '\bizMall\renew\models\RenewSn';
+
+}

+ 15 - 0
biz-mall/renew/models/RenewSn.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizMall\renew\models;
+
+use bizMall\base\models\Base;
+
+class RenewSn extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhRenewSn';
+    }
+
+}

+ 12 - 0
biz-mall/renew/services/RenewSnService.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizMall\renew\services;
+
+use bizMall\base\services\BaseService;
+
+class RenewSnService extends BaseService
+{
+	
+	public static $baseFile = '\bizMall\renew\classes\RenewSnClass';
+
+}

+ 41 - 41
biz-mall/saas/classes/RenewClass.php

@@ -4,51 +4,51 @@ namespace bizMall\saas\classes;
 
 use bizMall\merchant\classes\MerchantClass;
 use bizMall\user\classes\UserClass;
+use common\components\orderSn;
 use common\components\stringUtil;
 use Yii;
 use bizMall\base\classes\BaseClass;
 
 class RenewClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizMall\saas\models\Renew';
-	
-	public static function getRenewList($where)
-	{
-		$data = self::getList('*', $where, 'addTime DESC');
-		$list = isset($data['list']) ? $data['list'] : [];
-		if (empty($list)) {
-			return $data;
-		}
-		$ids = array_column($list, 'merchantId');
-		$merchant = MerchantClass::getMerchantByIds($ids);
-		$userIdList = array_column($list, 'userId');
-		$user = UserClass::getUserByIds($userIdList);
-		$setIds = array_column($list, 'setId');
-		$setIds = array_filter(array_unique($setIds));
-		$set = SetMealClass::getSetByIds($setIds);
-		foreach ($list as $key => $val) {
-			$merchantId = $val['merchantId'];
-			$userId = $val['userId'];
-			$setId = $val['setId'];
-			$list[$key]['merchantName'] = isset($merchant[$merchantId]['merchantName']) ? $merchant[$merchantId]['merchantName'] : '';
-			$list[$key]['userName'] = isset($user[$userId]['userName']) ? $user[$userId]['userName'] : '';
-			$list[$key]['mobile'] = isset($user[$userId]['mobile']) ? $user[$userId]['mobile'] : '';
-			$list[$key]['setName'] = isset($set[$setId]['name']) ? $set[$setId]['name'] : '';
-		}
-		$data['list'] = $list;
-		return $data;
-	}
-	
-	//增加续费订单 shish 2020.1.14
-	public static function addOrder($data)
-	{
-		$merchantId = $data['merchantId'];
-		$data['orderSn'] = stringUtil::generateOrderNo($merchantId, $data['userId']);
-		$data['payStatus'] = 0;
-		$data['addTime'] = time();
-		$return = self::add($data);
-		return $return;
-	}
-	
+
+    public static $baseFile = '\bizMall\saas\models\Renew';
+
+    public static function getRenewList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $ids = array_column($list, 'merchantId');
+        $merchant = MerchantClass::getMerchantByIds($ids);
+        $userIdList = array_column($list, 'userId');
+        $user = UserClass::getUserByIds($userIdList);
+        $setIds = array_column($list, 'setId');
+        $setIds = array_filter(array_unique($setIds));
+        $set = SetMealClass::getSetByIds($setIds);
+        foreach ($list as $key => $val) {
+            $merchantId = $val['merchantId'];
+            $userId = $val['userId'];
+            $setId = $val['setId'];
+            $list[$key]['merchantName'] = isset($merchant[$merchantId]['merchantName']) ? $merchant[$merchantId]['merchantName'] : '';
+            $list[$key]['userName'] = isset($user[$userId]['userName']) ? $user[$userId]['userName'] : '';
+            $list[$key]['mobile'] = isset($user[$userId]['mobile']) ? $user[$userId]['mobile'] : '';
+            $list[$key]['setName'] = isset($set[$setId]['name']) ? $set[$setId]['name'] : '';
+        }
+        $data['list'] = $list;
+        return $data;
+    }
+
+    //增加续费订单 shish 2020.1.14
+    public static function addOrder($data)
+    {
+        $data['orderSn'] = orderSn::getRenewSn();
+        $data['payStatus'] = 0;
+        $data['addTime'] = time();
+        $return = self::add($data);
+        return $return;
+    }
+
 }

+ 183 - 167
common/components/orderSn.php

@@ -9,177 +9,193 @@ use bizGhs\check\classes\CheckSnClass;
 use bizGhs\order\classes\OrderSnClass;
 use bizGhs\order\classes\PurchaseSnClass;
 use bizHd\px\classes\PxApplySnClass;
+use bizMall\renew\classes\RenewSnClass;
 use Yii;
 use yii\imagine\Image;
 
 //订单号生成 shish 2021.1.19
 class orderSn
 {
-	
-	//供货商订单号生成 shish 2021.1.19
-	public static function getGhsOrderSn()
-	{
-		$prefix = 'XSD_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'XSD';
-		}
-		$respond = OrderSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('订单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//零售商订单号生成 shish 2021.1.19
-	public static function getOrderSn()
-	{
-		$prefix = 'KD_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'KD';
-		}
-		$respond = \bizHd\order\classes\OrderSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('订单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//供货商采购单号 shish 2021.1.19
-	public static function getGhsPurchaseSn()
-	{
-		$prefix = 'PH_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'PH';
-		}
-		$respond = PurchaseSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('采购单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//供货商盘点单号 shish 2021.1.19
-	public static function getGhsCheckSn()
-	{
-		$prefix = 'PD_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'PD';
-		}
-		$respond = CheckSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('盘点单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//零售商采购单号 shish 2021.1.19
-	public static function getPurchaseSn()
-	{
-		$prefix = 'CG_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'CG';
-		}
-		$respond = \bizHd\purchase\classes\PurchaseSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('采购单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//零售商采购单号 shish 2021.1.19
-	public static function getPurchaseClearSn()
-	{
-		$prefix = 'PC_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'PC';
-		}
-		$respond = PurchaseClearSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//供货商入库订单号 linqh 2021.1.23
-	public static function getGhsStockInSn()
-	{
-		$prefix = 'RK_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'RK';
-		}
-		$respond = \bizGhs\order\classes\StockInSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('入库单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//供货商出库订单号 linqh 2021.1.23
-	public static function getGhsStockOutSn()
-	{
-		$prefix = 'CK_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'CK';
-		}
-		$respond = \bizGhs\order\classes\StockOutSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('出库单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//充值单号 shish 2021.2.20
-	public static function getRechargeSn()
-	{
-		$prefix = 'CZ_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'CZ';
-		}
-		$respond = RechargeSnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('充值单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
-	//供货商批量结算订单号 shish 2021.3.15
-	public static function getGhsOrderClearSn()
-	{
-		// BOC batchOrderClear
-		$prefix = 'BOC_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'BOC';
-		}
-		$respond = OrderClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('订单号没有生成');
-		}
-		return $prefix . $id;
-	}
-
-	//培训报名订单号 shish 2021.3.17
-	public static function getPxApplySn()
-	{
-		$prefix = 'PX_CS';
-		if (getenv('YII_ENV', 'local') == 'production') {
-			$prefix = 'PX';
-		}
-		$respond = PxApplySnClass::add(['id' => null]);
-		$id = $respond['id'] ?? 0;
-		if (empty($id)) {
-			util::fail('订单号没有生成');
-		}
-		return $prefix . $id;
-	}
-	
+
+    //供货商订单号生成 shish 2021.1.19
+    public static function getGhsOrderSn()
+    {
+        $prefix = 'XSD_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'XSD';
+        }
+        $respond = OrderSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //零售商订单号生成 shish 2021.1.19
+    public static function getOrderSn()
+    {
+        $prefix = 'KD_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'KD';
+        }
+        $respond = \bizHd\order\classes\OrderSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //供货商采购单号 shish 2021.1.19
+    public static function getGhsPurchaseSn()
+    {
+        $prefix = 'PH_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'PH';
+        }
+        $respond = PurchaseSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('采购单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //供货商盘点单号 shish 2021.1.19
+    public static function getGhsCheckSn()
+    {
+        $prefix = 'PD_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'PD';
+        }
+        $respond = CheckSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('盘点单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //零售商采购单号 shish 2021.1.19
+    public static function getPurchaseSn()
+    {
+        $prefix = 'CG_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'CG';
+        }
+        $respond = \bizHd\purchase\classes\PurchaseSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('采购单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //零售商采购单号 shish 2021.1.19
+    public static function getPurchaseClearSn()
+    {
+        $prefix = 'PC_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'PC';
+        }
+        $respond = PurchaseClearSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //供货商入库订单号 linqh 2021.1.23
+    public static function getGhsStockInSn()
+    {
+        $prefix = 'RK_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'RK';
+        }
+        $respond = \bizGhs\order\classes\StockInSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('入库单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //供货商出库订单号 linqh 2021.1.23
+    public static function getGhsStockOutSn()
+    {
+        $prefix = 'CK_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'CK';
+        }
+        $respond = \bizGhs\order\classes\StockOutSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('出库单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //充值单号 shish 2021.2.20
+    public static function getRechargeSn()
+    {
+        $prefix = 'CZ_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'CZ';
+        }
+        $respond = RechargeSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('充值单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //供货商批量结算订单号 shish 2021.3.15
+    public static function getGhsOrderClearSn()
+    {
+        // BOC batchOrderClear
+        $prefix = 'BOC_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'BOC';
+        }
+        $respond = OrderClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //培训报名订单号 shish 2021.3.17
+    public static function getPxApplySn()
+    {
+        $prefix = 'PX_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'PX';
+        }
+        $respond = PxApplySnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
+    //获取花店续费订单号 shish 2021.3.24
+    public static function getRenewSn()
+    {
+        $prefix = 'RN_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'RN';
+        }
+        $respond = RenewSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
 }

+ 12 - 1
sql.sql

@@ -1710,4 +1710,15 @@ ALTER TABLE xhCustom CHANGE `adminId` `userId` INT(11) NOT NULL DEFAULT '0' COMM
 ALTER TABLE xhCustom ADD UNIQUE INDEX custom(`sjId`,`userId`);
 ALTER TABLE xhShop ADD `cashAccount` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '支付宝提现帐号' AFTER `cancelOrder`;
 ALTER TABLE xhShop ADD `cashName` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '支付宝提现姓名' AFTER `cashAccount`;
-ALTER TABLE xhShopAdmin ADD avatar VARCHAR(800) NOT NULL DEFAULT '' COMMENT '头像' AFTER `adminId`;
+ALTER TABLE xhShopAdmin ADD avatar VARCHAR(800) NOT NULL DEFAULT '' COMMENT '头像' AFTER `adminId`;
+
+确认三个公众号的模板消息已经导入完整
+
+ALTER TABLE xhRenew CHANGE `payCode` `returnCode` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '支付返回数据';
+DROP TABLE IF EXISTS `xhRenewSn`;
+CREATE TABLE IF NOT EXISTS `xhRenewSn` (
+  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) AUTO_INCREMENT=18623508 COMMENT='续费订单号';
+ALTER TABLE xhOrder DROP COLUMN `createTime`;
+ALTER TABLE xhAdmin ADD INDEX `admin`(`mobile`,`style`);