Browse Source

mall相关结合

shish 5 years ago
parent
commit
8b54d8ef1e
34 changed files with 739 additions and 732 deletions
  1. 1 1
      app/ghs/controllers/AdminController.php
  2. 2 2
      app/ghs/controllers/BaseController.php
  3. 1 1
      app/ghs/controllers/OrderController.php
  4. 1 1
      app/ghs/controllers/TestController.php
  5. 1 1
      app/ghs/controllers/UploadController.php
  6. 2 2
      app/mall/controllers/BaseController.php
  7. 1 1
      app/mall/controllers/MapController.php
  8. 1 1
      app/mall/controllers/OrderController.php
  9. 1 1
      app/mall/controllers/PayController.php
  10. 1 1
      app/mall/controllers/TestController.php
  11. 1 1
      app/mall/controllers/UploadController.php
  12. 2 2
      app/saas/controllers/BaseController.php
  13. 1 1
      app/saas/controllers/CsController.php
  14. 1 1
      app/saas/controllers/GhsController.php
  15. 1 1
      app/saas/controllers/MainController.php
  16. 1 1
      app/saas/controllers/MerchantController.php
  17. 2 2
      app/saas/controllers/PlatformController.php
  18. 1 1
      app/saas/controllers/WxOpenController.php
  19. 1 1
      app/saas/controllers/ZhhController.php
  20. 1 1
      app/shop/controllers/AdminController.php
  21. 35 28
      app/shop/controllers/BaseController.php
  22. 1 1
      app/shop/controllers/CategoryController.php
  23. 2 2
      app/shop/controllers/ExpressController.php
  24. 2 2
      app/shop/controllers/GoodsController.php
  25. 1 1
      app/shop/controllers/InformUserController.php
  26. 1 1
      app/shop/controllers/InviteController.php
  27. 61 62
      app/shop/controllers/MainController.php
  28. 1 1
      app/shop/controllers/MapController.php
  29. 3 3
      app/shop/controllers/MerchantController.php
  30. 596 594
      app/shop/controllers/OrderController.php
  31. 2 2
      app/shop/controllers/ShopController.php
  32. 1 1
      app/shop/controllers/TestController.php
  33. 1 1
      app/shop/controllers/UploadController.php
  34. 8 9
      app/shop/controllers/UserController.php

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

@@ -14,7 +14,7 @@ use biz\user\classes\UserClass;
 class AdminController extends BaseController
 {
 	
-	public $withoutLogin = [];
+	public $withoutLoginAction = [];
 	
 	//获取登陆员工的权限 shish 2019.11.24
 	public function actionLoginAuth()

+ 2 - 2
app/ghs/controllers/BaseController.php

@@ -21,7 +21,7 @@ class BaseController extends PublicController
 	public $appId;
 	public $isWx = false;
 	public $isLogin = false;
-	public $withoutLogin = [];//不需要登陆的方法名
+	public $withoutLoginAction = [];//不需要登陆的方法名
 	public $validate = true;
 	
 	//shish 2020.3.8
@@ -59,7 +59,7 @@ class BaseController extends PublicController
 			$this->shopId = $shopId;
 		}
 		//游客可以访问的方法
-		if (in_array($action->id, $this->withoutLogin)) {
+		if (in_array($action->id, $this->withoutLoginAction)) {
 			$this->validate = true;
 		}
 		if ($this->validate == false) {

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

@@ -24,7 +24,7 @@ use common\components\stringUtil;
 class OrderController extends BaseController
 {
 
-    public $withoutLogin = ['order-relate', 'fast-pay'];
+    public $withoutLoginAction = ['order-relate', 'fast-pay'];
 
     //订单列表 shish 2021.1.20
     public function actionList()

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

@@ -14,7 +14,7 @@ use common\components\util;
 class TestController extends BaseController
 {
 
-	public $withoutLogin = ['inform', 'notice','order-query','add-order'];
+	public $withoutLoginAction = ['inform', 'notice','order-query','add-order'];
 
 	public function actionIndex()
     {

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

@@ -15,7 +15,7 @@ use yii\imagine\Image;
 class UploadController extends BaseController
 {
 	
-	public $withoutLogin = [];
+	public $withoutLoginAction = [];
 	
 	//上传图片接口
 	public function actionSaveImg()

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

@@ -21,7 +21,7 @@ class BaseController extends PublicController
 {
 	
 	public $validate = true;
-	public $withoutLogin = [];//不需要登陆可以访问的方法
+	public $withoutLoginAction = [];//不需要登陆可以访问的方法
 	public $userId = 0, $user, $shopId;
 	public $merchantId, $merchant, $merchantExtend;
 	public $isWx;
@@ -74,7 +74,7 @@ class BaseController extends PublicController
 			}
 		}
 		//游客可以访问的方法
-		if (in_array($action->id, $this->withoutLogin)) {
+		if (in_array($action->id, $this->withoutLoginAction)) {
 			$this->validate = true;
 		}
 		

+ 1 - 1
app/mall/controllers/MapController.php

@@ -9,7 +9,7 @@ use Yii;
 class MapController extends BaseController
 {
 	
-	public $withoutLogin = ['suggestion'];
+	public $withoutLoginAction = ['suggestion'];
 	
 	//腾讯地图关键词输入提醒 shish 2020.1.21
 	public function actionSuggestion()

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

@@ -27,7 +27,7 @@ use common\components\util;
 class OrderController extends BaseController
 {
 
-    public $withoutLogin = ['order-relate', 'fast-pay'];
+    public $withoutLoginAction = ['order-relate', 'fast-pay'];
 
     //商城下单操作 shish 2019.12.3
     public function actionCreateOrder()

+ 1 - 1
app/mall/controllers/PayController.php

@@ -29,7 +29,7 @@ use common\components\configDict;
 class PayController extends BaseController
 {
 
-	public $withoutLogin = ['get-params'];
+	public $withoutLoginAction = ['get-params'];
 
 	
 

+ 1 - 1
app/mall/controllers/TestController.php

@@ -12,7 +12,7 @@ use Yii;
 class TestController extends PublicController
 {
 
-	public $withoutLogin = ['index'];
+	public $withoutLoginAction = ['index'];
 
 	public function actionIndex()
 	{

+ 1 - 1
app/mall/controllers/UploadController.php

@@ -8,7 +8,7 @@ use common\components\util;
 class UploadController extends BaseController
 {
 	
-	public $withoutLogin = [];
+	public $withoutLoginAction = [];
 	
 	//上传图片接口
 	public function actionSaveImg()

+ 2 - 2
app/saas/controllers/BaseController.php

@@ -14,7 +14,7 @@ class BaseController extends PublicController
 	
 	public $staff, $staffId, $userId, $user;
 	public $isLogin = false;
-	public $withoutLogin = [];//不需要登陆的方法名
+	public $withoutLoginAction = [];//不需要登陆的方法名
 	public $validate = true;
 	
 	public function beforeAction($action)
@@ -27,7 +27,7 @@ class BaseController extends PublicController
 			$this->validate = false;
 		}
 		//游客可以访问的方法
-		if (in_array($action->id, $this->withoutLogin)) {
+		if (in_array($action->id, $this->withoutLoginAction)) {
 			$this->validate = true;
 		}
 		if ($this->validate == false) {

+ 1 - 1
app/saas/controllers/CsController.php

@@ -10,7 +10,7 @@ use Yii;
 
 class CsController extends BaseController
 {
-	public $withoutLogin = ['index'];
+	public $withoutLoginAction = ['index'];
 	
 	public function actionIndex()
 	{

+ 1 - 1
app/saas/controllers/GhsController.php

@@ -13,7 +13,7 @@ use common\services\xhMerchantService;
 class GhsController extends BaseController
 {
 
-    public $withoutLogin = ['bind-open'];
+    public $withoutLoginAction = ['bind-open'];
 
     //商家列表 shish 2019.12.20
     public function actionList()

+ 1 - 1
app/saas/controllers/MainController.php

@@ -14,7 +14,7 @@ use common\services\xhWxOpenAdminService;
 class MainController extends PlatformController
 {
 	
-	public $withoutLogin = ['login', 'logout', 'check-login'];
+	public $withoutLoginAction = ['login', 'logout', 'check-login'];
 	
 	public function actionIndex()
 	{

+ 1 - 1
app/saas/controllers/MerchantController.php

@@ -17,7 +17,7 @@ use common\services\xhMerchantService;
 class MerchantController extends BaseController
 {
 	
-	public $withoutLogin = ['bind-open'];
+	public $withoutLoginAction = ['bind-open'];
 	
 	//商家列表 shish 2019.12.20
 	public function actionList()

+ 2 - 2
app/saas/controllers/PlatformController.php

@@ -13,7 +13,7 @@ class PlatformController extends PublicController
 {
 	
 	public $isLogin = false;
-	public $withoutLogin = [];//不需要登陆的方法名
+	public $withoutLoginAction = [];//不需要登陆的方法名
 	public $admin, $adminId, $menuList, $subMenuList;
 	
 	public function beforeAction($action)
@@ -26,7 +26,7 @@ class PlatformController extends PublicController
 		$this->subMenuList = PlatMenuService::getSubMenu($controllerName, $actionName);
 		
 		$this->isLogin = xhWxOpenAdminService::isLogin();
-		if (!in_array($action->id, $this->withoutLogin) && $this->isLogin == false) {
+		if (!in_array($action->id, $this->withoutLoginAction) && $this->isLogin == false) {
 			$this->redirect(['main/login']);
 			Yii::$app->end();
 		}

+ 1 - 1
app/saas/controllers/WxOpenController.php

@@ -23,7 +23,7 @@ use common\services\xhWxOpenService;
 class WxOpenController extends PublicController
 {
 
-    public $withoutLogin = ['bind-open'];
+    public $withoutLoginAction = ['bind-open'];
 
     public function actionBindOpen()
     {

+ 1 - 1
app/saas/controllers/ZhhController.php

@@ -10,6 +10,6 @@ use common\services\xhWxOpenAdminService;
 class ZhhController extends PlatformController
 {
 
-	public $withoutLogin = [];
+	public $withoutLoginAction = [];
 
 }

+ 1 - 1
app/shop/controllers/AdminController.php

@@ -13,7 +13,7 @@ use biz\user\classes\UserClass;
 class AdminController extends BaseController
 {
 
-    public $withoutLogin = [];
+    public $withoutLoginAction = [];
 
     //获取登陆员工的权限 shish 2019.11.24
     public function actionLoginAuth()

+ 35 - 28
app/shop/controllers/BaseController.php

@@ -4,11 +4,14 @@ namespace shop\controllers;
 
 use biz\admin\classes\AdminClass;
 use biz\admin\services\ShopAdminService;
+use biz\merchant\classes\MerchantExtendClass;
+use biz\merchant\classes\ShopClass;
 use biz\merchant\services\AdminService;
 use biz\merchant\services\MerchantExtendService;
 use biz\merchant\services\MerchantService;
 use biz\merchant\services\ShopService;
 use biz\wx\services\WxOpenService;
+use common\components\httpUtil;
 use common\components\jwt;
 use Yii;
 use common\components\util;
@@ -16,11 +19,14 @@ use common\components\util;
 class BaseController extends PublicController
 {
     public $admin, $adminId, $adminAvatar, $account;
-    public $sjId = 0, $sj, $sjExtend, $signPackage, $shopId = 0;
+    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0;
     public $appId;
     public $isWx = false;
     public $isLogin = false;
-    public $withoutLogin = [];//不需要登陆的方法名
+    //不需要登陆的方法名
+    public $withoutLoginAction = [];
+    //需求带account请求头才能访问的方法
+    public $needShopIdAction = [];
     public $validate = true;
 
     //shish 2020.3.8
@@ -29,46 +35,47 @@ class BaseController extends PublicController
         //token验证
         //$adminId = jwt::getLoginId();
         $adminId = 18569;
-        $sjId = 0;
-        $sj = [];
-        $sjExtend = [];
-        $admin = [];
-        if (empty($adminId)) {
-            $this->validate = false;
-        } else {
-            $admin = AdminClass::getAdminById($adminId, true);
-            if (empty($admin)) {
-                util::fail('帐号无效');
+        $admin = AdminClass::getAdminById($adminId, true);
+        if (empty($admin)) {
+            util::fail('帐号无效');
+        }
+        $adminId = $admin['id'];
+        $header = httpUtil::getHeader();
+        $shopId = $header['shop-id'] ?? 0;
+        if (!empty($shopId)) {
+            $shop = ShopClass::getById($shopId);
+            if (empty($shop)) {
+                util::fail('没有找到店铺');
             }
-            $adminId = $admin['id'];
-            $shopId = Yii::$app->redis->executeCommand('GET', ['LOGIN_ADMIN_SHOP' . $adminId]);
-            //取不到门店id可能被清缓存,需要重新登陆,$shopId = 0 则表示非管理员,没有关联的门店,只可以访问官网
-            if (is_numeric($shopId) == false) {
-                util::notLogin('登陆已失效,请重新登陆');
+            $sjId = $shop['merchantId'] ?? 0;
+            $this->sjId = $sjId;
+            $sj = MerchantService::getMerchantById($sjId);
+            $this->sj = $sj;
+            $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId);
+        } else {
+            if (in_array($action->id, $this->needShopIdAction)) {
+                util::fail('您正在访问店铺,但没有找到店铺id');
             }
+            $shopId = $admin['currentShopId'] ?? 0;
             if (!empty($shopId)) {
                 $shop = ShopService::getById($shopId);
-                if (empty($shop)) {
-                    util::fail('您所管理的门店已经跑到月球上去了');
-                }
                 $sjId = $shop['merchantId'];
                 $sj = MerchantService::getMerchantById($sjId);
-                $sjExtend = MerchantExtendService::getByMerchantId($sjId);
+                $this->sj = $sj;
+                $this->shopId = $shopId;
+                $this->sjId = $sjId;
+                $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId);
             }
-            $this->shopId = $shopId;
         }
+        $this->admin = $admin;
+        $this->adminId = $adminId;
         //游客可以访问的方法
-        if (in_array($action->id, $this->withoutLogin)) {
+        if (in_array($action->id, $this->withoutLoginAction)) {
             $this->validate = true;
         }
         if ($this->validate == false) {
             util::notLogin();
         }
-        $this->admin = $admin;
-        $this->adminId = $adminId;
-        $this->sjId = $sjId;
-        $this->sj = $sj;
-        $this->sjExtend = $sjExtend;
         return parent::beforeAction($action);
     }
 

+ 1 - 1
app/shop/controllers/CategoryController.php

@@ -105,7 +105,7 @@ class CategoryController extends BaseController
 	//获取分类 shish 2019.12.2
 	public function actionMallList()
 	{
-		$return = CategoryService::getEnableList($this->merchantId);
+		$return = CategoryService::getEnableList($this->sjId);
 		util::success($return);
 	}
 

+ 2 - 2
app/shop/controllers/ExpressController.php

@@ -21,8 +21,8 @@ class ExpressController extends BaseController
 		if (empty($lng) || empty($lat)) {
 			util::fail('经度或纬度不能为空');
 		}
-		$shopId = ShopService::getDefaultShopId($this->merchant);
-		$respond = ExpressService::getUserDistance($lng, $lat, $shopId, $this->merchantExtend);
+		$shopId = ShopService::getDefaultShopId($this->sj);
+		$respond = ExpressService::getUserDistance($lng, $lat, $shopId, $this->sjExtend);
 		util::success($respond);
 	}
 

+ 2 - 2
app/shop/controllers/GoodsController.php

@@ -176,8 +176,8 @@ class GoodsController extends BaseController
 	{
 		$id = Yii::$app->request->get('id', 0);
 		$info = GoodsService::getGoodsInfo($id);
-		GoodsService::valid($info, $this->merchantId);
-		$setting = GoodsSettingService::getByCondition(['merchantId' => $this->merchantId]);
+		GoodsService::valid($info, $this->sjId);
+		$setting = GoodsSettingService::getByCondition(['merchantId' => $this->sjId]);
 		$commonIntro = isset($setting['goodsIntroduce']) ? $setting['goodsIntroduce'] : '';
 		$info['commonIntro'] = $commonIntro;
 		util::success($info);

+ 1 - 1
app/shop/controllers/InformUserController.php

@@ -34,7 +34,7 @@ class InformUserController extends BaseController
 		} else {
 			util::fail('发送失败');
 		}
-		sms::send($mobile, $msg, $this->merchant);
+		sms::send($mobile, $msg, $this->sj);
 		util::complete('已发送');
 	}
 

+ 1 - 1
app/shop/controllers/InviteController.php

@@ -83,7 +83,7 @@ class InviteController extends BaseController
 	public function actionProfile()
 	{
 		$stat = InviteStatService::getStat($this->adminId);
-		$asset = InviteAssetService::getAsset($this->merchantId);
+		$asset = InviteAssetService::getAsset($this->sjId);
 		util::success(['stat' => $stat, 'asset' => $asset]);
 	}
 	

+ 61 - 62
app/shop/controllers/MainController.php

@@ -2,74 +2,73 @@
 
 namespace shop\controllers;
 
-use Yii;
 use GatewayClient\Gateway;
 use biz\ad\services\AdService;
 use biz\goods\services\CategoryService;
 use biz\goods\services\GoodsCategoryService;
-use yii\web\Controller;
 use common\components\util;
 
 class MainController extends BaseController
 {
-	
-	public function actionDemo()
-	{
-		return $this->renderPartial('demo');
-	}
-	
-	
-	//首页 shish 2019.12.2
-	public function actionIndex()
-	{
-		$where = ['merchantId' => $this->merchantId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
-		$adRespond = AdService::getAdList($where);
-		$ad = [];
-		if (isset($adRespond['list']) && !empty($adRespond['list'])) {
-			foreach ($adRespond['list'] as $single) {
-				$ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
-			}
-		}
-		$category = CategoryService::getTopThreeCategory($this->merchantId);
-		$categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
-		$data = ['ad' => $ad, 'category' => $categoryList, 'columnStyle' => rand(1, 2)];
-		util::success($data);
-	}
-	
-	//新客户 shish 2019.12.29
-	public function actionVisit()
-	{
-		$data = json_encode(array(
-			'type' => 'msg',
-			'msg' => 'aaaa',
-		));
-		
-		$id = 'merchantConsole_' . $this->sjId;
-		$online = Gateway::getClientIdByUid($id);
-		if ($online) {
-			//直接发送
-			Gateway::sendToUid($id, json_encode($data));
-		} else {
-			//保存
-		}
-	}
-	
-	//新订单 shish 2019.12.29
-	public function actionOrder()
-	{
-		$data = json_encode(array(
-			'type' => 'msg',
-			'msg' => 'aaaa',
-		));
-		
-		$id = 'merchantConsole_' . $this->sjId;
-		$online = Gateway::getClientIdByUid($id);
-		if ($online) {
-			//直接发送
-			Gateway::sendToUid($id, json_encode($data));
-		} else {
-			//保存
-		}
-	}
-	
+
+    public $needShopIdAction = ['index'];
+
+    public function actionDemo()
+    {
+        return $this->renderPartial('demo');
+    }
+
+    //首页 shish 2019.12.2
+    public function actionIndex()
+    {
+        $where = ['merchantId' => $this->sjId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
+        $adRespond = AdService::getAdList($where);
+        $ad = [];
+        if (isset($adRespond['list']) && !empty($adRespond['list'])) {
+            foreach ($adRespond['list'] as $single) {
+                $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
+            }
+        }
+        $category = CategoryService::getTopThreeCategory($this->sjId);
+        $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
+        $data = ['ad' => $ad, 'category' => $categoryList, 'columnStyle' => rand(1, 2)];
+        util::success($data);
+    }
+
+    //新客户 shish 2019.12.29
+    public function actionVisit()
+    {
+        $data = json_encode(array(
+            'type' => 'msg',
+            'msg' => 'aaaa',
+        ));
+
+        $id = 'merchantConsole_' . $this->sjId;
+        $online = Gateway::getClientIdByUid($id);
+        if ($online) {
+            //直接发送
+            Gateway::sendToUid($id, json_encode($data));
+        } else {
+            //保存
+        }
+    }
+
+    //新订单 shish 2019.12.29
+    public function actionOrder()
+    {
+        $data = json_encode(array(
+            'type' => 'msg',
+            'msg' => 'aaaa',
+        ));
+
+        $id = 'merchantConsole_' . $this->sjId;
+        $online = Gateway::getClientIdByUid($id);
+        if ($online) {
+            //直接发送
+            Gateway::sendToUid($id, json_encode($data));
+        } else {
+            //保存
+        }
+    }
+
 }

+ 1 - 1
app/shop/controllers/MapController.php

@@ -9,7 +9,7 @@ use Yii;
 class MapController extends BaseController
 {
 	
-	public $withoutLogin = ['suggestion'];
+	public $withoutLoginAction = ['suggestion'];
 	
 	//腾讯地图关键词输入提醒 shish 2020.1.21
 	public function actionSuggestion()

+ 3 - 3
app/shop/controllers/MerchantController.php

@@ -118,7 +118,7 @@ class MerchantController extends BaseController
 	//当前用户获取门店信息
 	public function actionGetShopInfo()
 	{
-		$merchant = $this->merchant;
+		$merchant = $this->sj;
 		$merchant['defaultShop'] = ShopService::getDefaultShopInfo($merchant);
 		util::success($merchant);
 	}
@@ -126,14 +126,14 @@ class MerchantController extends BaseController
 	//当前用户获取商家信息
 	public function actionGetInfo()
 	{
-		$merchant = MerchantService::getInfo($this->merchant, $this->merchantExtend);
+		$merchant = MerchantService::getInfo($this->sj, $this->sjExtend);
 		util::success($merchant);
 	}
 	
 	//客户的会员等级 shish 2020.1.2
 	public function actionUserGrade()
 	{
-		$list = MerchantExtendService::getGradeList($this->merchantExtend, 'asc', false);
+		$list = MerchantExtendService::getGradeList($this->sjExtend, 'asc', false);
 		util::success($list);
 	}
 	

+ 596 - 594
app/shop/controllers/OrderController.php

@@ -28,599 +28,601 @@ use yii\web\Controller;
 
 class OrderController extends BaseController
 {
-	
-	public $withoutLogin = ['order-relate', 'fast-pay'];
-
-	//商城下单操作 shish 2019.12.3
-	public function actionCreateOrder()
-	{
-		$post = Yii::$app->request->post();
-		$goodsId = isset($post['goodsId']) ? $post['goodsId'] : 0;
-		$goodsStyleId = isset($post['goodsStyleId']) ? $post['goodsStyleId'] : 0;
-		$goodsNum = isset($post['goodsNum']) && $post['goodsNum'] > 0 ? $post['goodsNum'] : 1;
-		$needSend = isset($post['needSend']) && is_numeric($post['needSend']) ? $post['needSend'] : 1;
-		if (empty($goodsId)) {
-			util::fail('请选择商品');
-		}
-		$goodsInfo = GoodsService::getGoodsInfo($goodsId);
-		if (empty($goodsInfo)) {
-			util::fail('没有找到商品');
-		}
-		if (isset($goodsInfo['stock']) == false || $goodsInfo['stock'] == 0) {
-			util::fail('已经卖完了');
-		}
-		//运费计算方式
-		$freightType = isset($goodsInfo['freightType']) ? $goodsInfo['freightType'] : 0;
-		
-		$post['userId'] = $this->adminId;
-		$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('商品款式没有找到');
-			}
-			$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->adminId]);
-		$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->adminId,
-			'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
-	public function actionOrderRelate()
-	{
-		$regionTree = RegionService::tree();
-		$shop = ShopService::getDefaultShop($this->sj);
-		$freight = MerchantExtendService::getFreight($this->sjExtend);
-		$mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
-		$out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->sj];
-		util::success($out);
-	}
-	
-	//余额支付 shish 2019.12.6
-	public function actionBalancePay()
-	{
-		$post = Yii::$app->request->post();
-		$orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-		$payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-		$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-		
-		//验证优惠券是否还有效
-		if (!empty($couponId)) {
-			CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
-		}
-		
-		$order = OrderService::getByOrderSn($orderSn);
-		$userId = $this->adminId;
-		$user = UserService::getUserInfo($userId, false);
-		//验证支付密码是否正确
-		UserService::validPayPassword($payPassword, $user);
-		//支付前验证订单有效性
-		OrderService::checkBeforePay($order, $this->adminId);
-		$typeList = configDict::getConfig('capitalType');
-		$capitalType = $typeList['xhOrder']['id'];
-		$totalFee = $order['prePrice'];
-		$sourceType = 0;
-		$discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
-		$actPrice = $discountData['price'];
-		$callbackParams = [];
-		$respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-		$balance = isset($respond['balance']) ? $respond['balance'] : 0;
-		util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]);
-	}
-	
-	//获取商城下单要用的微信支付和小程序支付参数 shish 2019.21.3
-	public function actionWxPay()
-	{
-		ini_set('date.timezone', 'Asia/Shanghai');
-		$post = Yii::$app->request->post();
-		$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-		$orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-		$order = OrderService::getByOrderSn($orderSn);
-		$orderId = $order['id'];
-		
-		//验证优惠券是否还有效
-		if (!empty($couponId)) {
-			CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
-		}
-		
-		//支付前验证订单有效性
-		OrderService::checkBeforePay($order, $this->adminId);
-		
-		$name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
-		$totalFee = $order['actPrice'];
-		
-		//小程序使用miniOpenId
-		if (httpUtil::isMiniProgram()) {
-			$openId = $this->user['miniOpenId'];
-		} else {
-			$openId = $this->user['openId'];
-		}
-		$typeList = configDict::getConfig('capitalType');
-		$capitalType = $typeList['xhOrder']['id'];
-		//流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-		$wxPayType = 0;
-		if (httpUtil::isMiniProgram()) {
-			$wxPayType = 1;
-		}
-		$attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
-		//订单30分钟后过期
-		$now = time();
-		$expireTime = $now + 1800;
-		
-		$wx = Yii::getAlias("@vendor/weixin");
-		require_once($wx . '/lib/WxPay.Api.php');
-		require_once($wx . '/example/WxPay.JsApiPay.php');
-		$input = new \WxPayUnifiedOrder();
-		$input->SetBody($name);
-		$input->SetOut_trade_no($orderSn);
-		$input->SetTotal_fee($totalFee * 100);
-		$input->SetTime_start(date("YmdHis", $now));
-		$input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
-		$input->SetTime_expire(date("YmdHis", $expireTime));
-		$input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
-		$input->SetTrade_type("JSAPI");
-		
-		//花卉宝代为申请的微信支付
-		$merchantExtend = $this->sjExtend;
-		if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
-			$input->SetSub_openid($openId);
-		} else {
-			$input->SetOpenid($openId);
-		}
-		//小程序使用miniAppId
-		if (httpUtil::isMiniProgram()) {
-			$merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-		}
-		
-		$wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
-		$tools = new \JsApiPay();
-		$jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
-		$newParams = json_decode($jsApiParameters, true);
-		//已请求微信不能修改价格
-		$updateData = [];
-		$updateData['modPrice'] = 0;
-		if (empty($order['deadline'])) {
-			$updateData['deadline'] = $expireTime;
-		}
-		OrderService::updateById($orderId, $updateData);
-		util::success($newParams);
-	}
-	
-	//快捷付款订单
-	public function actionFastPay()
-	{
-		ini_set('date.timezone', 'Asia/Shanghai');
-		$post = Yii::$app->request->post();
-		$payWay = isset($post['payWay']) ? $post['payWay'] : 0;
-		$shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->sj);
-		//验证门店是否有效
-		$shopInfo = ShopService::getById($shopId);
-		ShopService::valid($shopInfo, $this->sjId);
-		$post['shopId'] = $shopId;
-		//默认门店订单
-		$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=3表示朋友圈来源
-		$fromType = $sourceType == 3 ? 2 : 0;
-		$fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
-		$post['userId'] = $this->adminId;
-		$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;
-		$prePrice = round($post['prePrice'], 2);
-		$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-		$discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
-		$actPrice = $discountData['price'];
-		$post['discountType'] = $discountData['discountType'];
-		$post['discountAmount'] = $discountData['discountAmount'];
-		$post['actPrice'] = $actPrice;
-		$post['payStyle'] = 0;
-		$post['merchantId'] = $this->sjId;
-		$now = time();
-		$expireTime = $now + 300;//订单5分钟后过期
-		$post['createTime'] = date("Y-m-d H:i:s", $now);
-		$post['deadline'] = $expireTime;
-		if ($actPrice <= 0) {
-			util::fail('请填写正确的金额');
-		}
-		//微信支付订单提交不能修改价格
-		$post['modPrice'] = $this->isWx ? 0 : 1;
-		$post['sourceType'] = $sourceType;
-		$post['goodsNum'] = 1;
-		$post['fromType'] = $fromType;
-		$order = OrderService::addOrder($post);
-		$orderId = $order['id'];
-		$orderSn = $order['orderSn'];
-		$merchantId = $this->sjId;
-		if ($payWay == 0) {
-			$orderId = $order['id'];
-			$name = '购买商品';
-			$totalFee = $actPrice;
-			$user = UserService::getById($this->adminId);
-			$openId = isset($user['openId']) ? $user['openId'] : 0;
-			if (httpUtil::isMiniProgram()) {
-				//小程序使用miniOpenId
-				$openId = $user['miniOpenId'];
-			}
-			if (empty($openId)) {
-				util::fail('没有找到客户的openId');
-			}
-			$typeList = configDict::getConfig('capitalType');
-			$capitalType = $typeList['xhOrder']['id'];
-			//流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
-			$wxPayType = 0;
-			if (httpUtil::isMiniProgram()) {
-				$wxPayType = 1;
-			}
-			$attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
-			$wx = Yii::getAlias("@vendor/weixin");
-			require_once($wx . '/lib/WxPay.Api.php');
-			require_once($wx . '/example/WxPay.JsApiPay.php');
-			$input = new \WxPayUnifiedOrder();
-			$input->SetBody($name);
-			$input->SetOut_trade_no($orderSn);
-			$input->SetTotal_fee($totalFee * 100);
-			$input->SetTime_start(date("YmdHis", $now));
-			$input->SetAttach($attach);
-			//设置订单有效期5分钟
-			$input->SetTime_expire(date("YmdHis", $expireTime));
-			$input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
-			$input->SetTrade_type("JSAPI");
-			
-			//花卉宝代为申请的微信支付
-			$merchantExtend = $this->sjExtend;
-			if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
-				$input->SetSub_openid($openId);
-			} else {
-				$input->SetOpenid($openId);
-			}
-			//小程序使用miniAppId
-			if (httpUtil::isMiniProgram()) {
-				$merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
-			}
-			Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
-			$wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
-			$tools = new \JsApiPay();
-			$jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
-			$newParams = json_decode($jsApiParameters, true);
-			$newParams['orderId'] = $orderId;
-			util::success($newParams);
-		} elseif ($payWay == 1) {
-			$extend = MerchantExtendService::getByMerchantId($merchantId);
-			if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
-				util::fail('支付宝付款即将开通...');
-			}
-			$config = [
-				//应用ID,您的APPID。
-				'app_id' => $extend['alipayPId'],
-				//商户私钥,您的原始格式RSA私钥
-				'merchant_private_key' => $extend['alipayKey'],
-				//异步通知地址
-				'notify_url' => Yii::$app->params['mallHost'] . "/notice/alipay-callback",
-				//同步跳转
-				'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'],
-			];
-			
-			Yii::info(json_encode($config) . ' aplipay config');
-			
-			$alipayWap = Yii::getAlias("@vendor/alipayWap");
-			require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
-			require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
-			
-			$totalFee = $order['actPrice'];
-			$out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
-			$subject = '购买商品';//订单名称,必填
-			$total_amount = $totalFee;//付款金额,必填
-			$body = '';//商品描述,可空
-			$timeout_express = "1m";//超时时间
-			
-			$typeList = configDict::getConfig('capitalType');
-			$capitalType = $typeList['xhOrder']['id'];
-			$passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
-			$passbackParams = urlencode($passbackParams);
-			
-			$payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
-			$payRequestBuilder->setBody($body);
-			$payRequestBuilder->setSubject($subject);
-			$payRequestBuilder->setOutTradeNo($out_trade_no);
-			$payRequestBuilder->setTotalAmount($total_amount);
-			$payRequestBuilder->setTimeExpress($timeout_express);
-			//在异步通知时将该参数原样返回
-			$payRequestBuilder->setPassbackParams($passbackParams);
-			//同步通知
-			$returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
-			//异步通知
-			$notifyUrl = Yii::$app->params['mallHost'] . "/notice/alipay-callback";
-			$payResponse = new \AlipayTradeService($config);
-			$result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
-			//直接将支付宝的html返回给前端
-			echo $result;
-		} elseif ($payWay == 2) {
-			//余额支付,验证支付密码是否正确
-			$payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-			$user = UserService::getUserInfo($this->adminId, false);
-			UserService::validPayPassword($payPassword, $user);
-			$typeList = configDict::getConfig('capitalType');
-			$capitalType = $typeList['xhOrder']['id'];
-			$callbackParams = [];
-			$respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-			$balance = isset($respond['balance']) ? $respond['balance'] : 0;
-			util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
-		} else {
-			util::fail('无效的支付方式');
-		}
-	}
-	
-	//订单评价
-	public function actionComment()
-	{
-		$post = Yii::$app->request->post();
-		$id = $post['id'];
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		if ($order['grade'] > 0) {
-			util::fail('您已经评过了');
-		}
-		OrderService::comment($post);
-		util::complete('提交成功');
-	}
-	
-	//订单详情 shish 2019.12.16
-	public function actionDetail()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$orderSn = Yii::$app->request->get('orderSn', '');
-		$detail = [];
-		if (!empty($id)) {
-			$detail = OrderService::getOrderById($id);
-		}
-		if (!empty($orderSn)) {
-			$detail = OrderService::getOrderBySn($orderSn);
-		}
-		OrderService::valid($detail, $this->sjId);
-		util::success($detail);
-	}
-	
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$search = isset($get['search']) ? $get['search'] : '';
-		$where = [];
-		$where['merchantId'] = $this->sjId;
-		if (isset($get['status']) && $get['status'] != -1) {
-			$where['status'] = $get['status'];
-		}
-		if (!empty($search)) {
-			if (stringUtil::isMobile($search)) {
-				$where['receiveMobile'] = $search;
-			} else {
-				$where['id'] = $search;
-			}
-		}
-		$list = OrderService::getOrderList($where);
-		$list['asset'] = MerchantAssetService::getByMerchantId($this->sjId);
-		util::success($list);
-	}
-	
-	//订单归类 shish 2019.12.17
-	public function actionClassify()
-	{
-		$post = Yii::$app->request->post();
-		$id = isset($post['id']) ? $post['id'] : 0;
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		$categoryId = isset($post['categoryId']) ? $post['categoryId'] : $post['categoryId'];
-		$usageId = isset($post['usageId']) ? $post['usageId'] : $post['usageId'];
-		OrderService::classify($id, $categoryId, $usageId);
-		util::complete();
-	}
-	
-	//更新配送单 shish 2019.12.17
-	public function actionUpdateSheet()
-	{
-		$post = Yii::$app->request->post();
-		$id = isset($post['id']) ? $post['id'] : 0;
-		unset($post['id']);
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		OrderService::updateSheet($order, $post);
-		util::complete('提交成功');
-	}
-	
-	//商家收款与发货 shish 2019.12.18
-	public function actionGathering()
-	{
-		$post = Yii::$app->request->post();
-		$price = isset($post['price']) && is_numeric($post['price']) ? $post['price'] : 0;
-		$payWay = isset($post['payWay']) && is_numeric($post['payWay']) ? $post['payWay'] : 0;
-		$userId = isset($post['userId']) ? $post['userId'] : 0;
-		$userInfo = UserService::getById($userId);
-		if (empty($userInfo) || $userInfo['merchantId'] != $this->sjId) {
-			util::fail('您选择的客户无效');
-		}
-		if ($price <= 0) {
-			util::fail('请输入金额');
-		}
-		$post['prePrice'] = $price;
-		$post['actPrice'] = $price;
-		$post['payWay'] = $payWay;
-		$post['sourceType'] = 1;
-		$post['userId'] = $userId;
-		$post['goodsNum'] = 1;
-		$post['orderName'] = '商品';
-		$shopId = MerchantService::getDefaultShopId($this->sj);
-		$post['shopId'] = $shopId;
-		$order = OrderService::addOrder($post);
-		$id = $order['id'];
-		$orderSn = $order['orderSn'];
-		
-		//流水类型列表
-		$capitalTypeList = configDict::getConfig('capitalType');
-		$capitalType = $capitalTypeList['xhOrder']['id'];
-		$callbackParams = [];
-		switch ($payWay) {
-			case 0:
-				xhPayToolService::weixinPay($callbackParams, $orderSn, $price, $capitalType, 0);
-				break;
-			case 1:
-				xhPayToolService::alipay($callbackParams, $orderSn, $price, $capitalType, 0, []);
-				break;
-			case 2:
-				xhPayToolService::balancePay($callbackParams, $orderSn, $price, $capitalType, 0);
-				break;
-			default:
-				util::fail('无效支付方式');
-		}
-		util::success($order);
-	}
-	
-	//免发货管理 shish 2020.1.6
-	public function actionWithoutSend()
-	{
-		$id = Yii::$app->request->get('id');
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		//配送流程变更
-		$currentFlow = OrderSendClass::withoutSend($order);
-		util::success(['currentFlow' => $currentFlow]);
-	}
-	
-	//修改价格 shish 2020.1.6
-	public function actionUpdatePrice()
-	{
-		$id = Yii::$app->request->get('id');
-		$price = Yii::$app->request->get('price', 1);
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		if (isset($order['modPrice']) && $order['modPrice'] == 0) {
-			util::fail('已发起支付,不能修改价格');
-		}
-		OrderService::updateById($id, ['actPrice' => $price]);
-		util::complete('修改成功');
-	}
-	
-	//配送单 shish 2020.2.29
-	public function actionGetDeliverDetail()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$order = OrderService::getById($id);
-		OrderService::valid($order, $this->sjId);
-		$reachDate = isset($order['reachDate']) && !empty($order['reachDate']) ? $order['reachDate'] : '';
-		$reachPeriodId = $order['reachPeriod'];
-		$reachPeriodArr = [0 => '上午', 1 => '下午', 2 => '晚上'];
-		$reachPeriod = isset($reachPeriodArr[$reachPeriodId]) ? $reachPeriodArr[$reachPeriodId] : '';
-		$shopId = $order['shopId'];
-		$telephone = '';
-		if (!empty($shopId)) {
-			$shop = ShopService::getById($shopId);
-		}
-		$telephone = isset($shop['telephone']) ? $shop['telephone'] : '';
-		$bookName = isset($order['bookName']) ? $order['bookName'] : '';
-		$bookMobile = isset($order['bookMobile']) ? $order['bookMobile'] : '';
-		if (isset($order['anonymity']) && $order['anonymity'] == 1) {
-			$bookName = '--';
-			$bookMobile = '--';
-		}
-		$data = [
-			'reachDate' => $reachDate . ' ' . $reachPeriod,
-			'orderSn' => $order['orderSn'],
-			'receiveUserName' => $order['receiveUserName'],
-			'receiveMobile' => $order['receiveMobile'],
-			'receiveFullAddress' => $order['receiveAddress'] . $order['receiveFloor'] . "(" . $order['receiveFullAddress'] . ")",
-			'cardInfo' => $order['cardInfo'],
-			'bookMobile' => $bookMobile,
-			'bookName' => $bookName,
-			'remark' => $order['remark'],
-			'sendNum' => $order['sendNum'],
-			'telephone' => 13600903070,
-			'printTime' => '',
-			'img' => '',
-		];
-		util::success($data);
-	}
+
+    public $withoutLoginAction = ['order-relate', 'fast-pay'];
+
+    public $needShopIdAction = ['order-relate'];
+
+    //商城下单操作 shish 2019.12.3
+    public function actionCreateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $goodsId = isset($post['goodsId']) ? $post['goodsId'] : 0;
+        $goodsStyleId = isset($post['goodsStyleId']) ? $post['goodsStyleId'] : 0;
+        $goodsNum = isset($post['goodsNum']) && $post['goodsNum'] > 0 ? $post['goodsNum'] : 1;
+        $needSend = isset($post['needSend']) && is_numeric($post['needSend']) ? $post['needSend'] : 1;
+        if (empty($goodsId)) {
+            util::fail('请选择商品');
+        }
+        $goodsInfo = GoodsService::getGoodsInfo($goodsId);
+        if (empty($goodsInfo)) {
+            util::fail('没有找到商品');
+        }
+        if (isset($goodsInfo['stock']) == false || $goodsInfo['stock'] == 0) {
+            util::fail('已经卖完了');
+        }
+        //运费计算方式
+        $freightType = isset($goodsInfo['freightType']) ? $goodsInfo['freightType'] : 0;
+
+        $post['userId'] = $this->adminId;
+        $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('商品款式没有找到');
+            }
+            $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->adminId]);
+        $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->adminId,
+            '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
+    public function actionOrderRelate()
+    {
+        $regionTree = RegionService::tree();
+        $shop = ShopService::getDefaultShop($this->sj);
+        $freight = MerchantExtendService::getFreight($this->sjExtend);
+        $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
+        $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->sj];
+        util::success($out);
+    }
+
+    //余额支付 shish 2019.12.6
+    public function actionBalancePay()
+    {
+        $post = Yii::$app->request->post();
+        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
+        $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
+        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
+
+        //验证优惠券是否还有效
+        if (!empty($couponId)) {
+            CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
+        }
+
+        $order = OrderService::getByOrderSn($orderSn);
+        $userId = $this->adminId;
+        $user = UserService::getUserInfo($userId, false);
+        //验证支付密码是否正确
+        UserService::validPayPassword($payPassword, $user);
+        //支付前验证订单有效性
+        OrderService::checkBeforePay($order, $this->adminId);
+        $typeList = configDict::getConfig('capitalType');
+        $capitalType = $typeList['xhOrder']['id'];
+        $totalFee = $order['prePrice'];
+        $sourceType = 0;
+        $discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
+        $actPrice = $discountData['price'];
+        $callbackParams = [];
+        $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
+        $balance = isset($respond['balance']) ? $respond['balance'] : 0;
+        util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]);
+    }
+
+    //获取商城下单要用的微信支付和小程序支付参数 shish 2019.21.3
+    public function actionWxPay()
+    {
+        ini_set('date.timezone', 'Asia/Shanghai');
+        $post = Yii::$app->request->post();
+        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
+        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
+        $order = OrderService::getByOrderSn($orderSn);
+        $orderId = $order['id'];
+
+        //验证优惠券是否还有效
+        if (!empty($couponId)) {
+            CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
+        }
+
+        //支付前验证订单有效性
+        OrderService::checkBeforePay($order, $this->adminId);
+
+        $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
+        $totalFee = $order['actPrice'];
+
+        //小程序使用miniOpenId
+        if (httpUtil::isMiniProgram()) {
+            $openId = $this->user['miniOpenId'];
+        } else {
+            $openId = $this->user['openId'];
+        }
+        $typeList = configDict::getConfig('capitalType');
+        $capitalType = $typeList['xhOrder']['id'];
+        //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
+        $wxPayType = 0;
+        if (httpUtil::isMiniProgram()) {
+            $wxPayType = 1;
+        }
+        $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
+        //订单30分钟后过期
+        $now = time();
+        $expireTime = $now + 1800;
+
+        $wx = Yii::getAlias("@vendor/weixin");
+        require_once($wx . '/lib/WxPay.Api.php');
+        require_once($wx . '/example/WxPay.JsApiPay.php');
+        $input = new \WxPayUnifiedOrder();
+        $input->SetBody($name);
+        $input->SetOut_trade_no($orderSn);
+        $input->SetTotal_fee($totalFee * 100);
+        $input->SetTime_start(date("YmdHis", $now));
+        $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
+        $input->SetTime_expire(date("YmdHis", $expireTime));
+        $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
+        $input->SetTrade_type("JSAPI");
+
+        //花卉宝代为申请的微信支付
+        $merchantExtend = $this->sjExtend;
+        if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
+            $input->SetSub_openid($openId);
+        } else {
+            $input->SetOpenid($openId);
+        }
+        //小程序使用miniAppId
+        if (httpUtil::isMiniProgram()) {
+            $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+        }
+
+        $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
+        $tools = new \JsApiPay();
+        $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
+        $newParams = json_decode($jsApiParameters, true);
+        //已请求微信不能修改价格
+        $updateData = [];
+        $updateData['modPrice'] = 0;
+        if (empty($order['deadline'])) {
+            $updateData['deadline'] = $expireTime;
+        }
+        OrderService::updateById($orderId, $updateData);
+        util::success($newParams);
+    }
+
+    //快捷付款订单
+    public function actionFastPay()
+    {
+        ini_set('date.timezone', 'Asia/Shanghai');
+        $post = Yii::$app->request->post();
+        $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
+        $shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->sj);
+        //验证门店是否有效
+        $shopInfo = ShopService::getById($shopId);
+        ShopService::valid($shopInfo, $this->sjId);
+        $post['shopId'] = $shopId;
+        //默认门店订单
+        $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=3表示朋友圈来源
+        $fromType = $sourceType == 3 ? 2 : 0;
+        $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
+        $post['userId'] = $this->adminId;
+        $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;
+        $prePrice = round($post['prePrice'], 2);
+        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
+        $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
+        $actPrice = $discountData['price'];
+        $post['discountType'] = $discountData['discountType'];
+        $post['discountAmount'] = $discountData['discountAmount'];
+        $post['actPrice'] = $actPrice;
+        $post['payStyle'] = 0;
+        $post['merchantId'] = $this->sjId;
+        $now = time();
+        $expireTime = $now + 300;//订单5分钟后过期
+        $post['createTime'] = date("Y-m-d H:i:s", $now);
+        $post['deadline'] = $expireTime;
+        if ($actPrice <= 0) {
+            util::fail('请填写正确的金额');
+        }
+        //微信支付订单提交不能修改价格
+        $post['modPrice'] = $this->isWx ? 0 : 1;
+        $post['sourceType'] = $sourceType;
+        $post['goodsNum'] = 1;
+        $post['fromType'] = $fromType;
+        $order = OrderService::addOrder($post);
+        $orderId = $order['id'];
+        $orderSn = $order['orderSn'];
+        $merchantId = $this->sjId;
+        if ($payWay == 0) {
+            $orderId = $order['id'];
+            $name = '购买商品';
+            $totalFee = $actPrice;
+            $user = UserService::getById($this->adminId);
+            $openId = isset($user['openId']) ? $user['openId'] : 0;
+            if (httpUtil::isMiniProgram()) {
+                //小程序使用miniOpenId
+                $openId = $user['miniOpenId'];
+            }
+            if (empty($openId)) {
+                util::fail('没有找到客户的openId');
+            }
+            $typeList = configDict::getConfig('capitalType');
+            $capitalType = $typeList['xhOrder']['id'];
+            //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
+            $wxPayType = 0;
+            if (httpUtil::isMiniProgram()) {
+                $wxPayType = 1;
+            }
+            $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
+            $wx = Yii::getAlias("@vendor/weixin");
+            require_once($wx . '/lib/WxPay.Api.php');
+            require_once($wx . '/example/WxPay.JsApiPay.php');
+            $input = new \WxPayUnifiedOrder();
+            $input->SetBody($name);
+            $input->SetOut_trade_no($orderSn);
+            $input->SetTotal_fee($totalFee * 100);
+            $input->SetTime_start(date("YmdHis", $now));
+            $input->SetAttach($attach);
+            //设置订单有效期5分钟
+            $input->SetTime_expire(date("YmdHis", $expireTime));
+            $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
+            $input->SetTrade_type("JSAPI");
+
+            //花卉宝代为申请的微信支付
+            $merchantExtend = $this->sjExtend;
+            if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
+                $input->SetSub_openid($openId);
+            } else {
+                $input->SetOpenid($openId);
+            }
+            //小程序使用miniAppId
+            if (httpUtil::isMiniProgram()) {
+                $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
+            }
+            Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
+            $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
+            $tools = new \JsApiPay();
+            $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
+            $newParams = json_decode($jsApiParameters, true);
+            $newParams['orderId'] = $orderId;
+            util::success($newParams);
+        } elseif ($payWay == 1) {
+            $extend = MerchantExtendService::getByMerchantId($merchantId);
+            if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
+                util::fail('支付宝付款即将开通...');
+            }
+            $config = [
+                //应用ID,您的APPID。
+                'app_id' => $extend['alipayPId'],
+                //商户私钥,您的原始格式RSA私钥
+                'merchant_private_key' => $extend['alipayKey'],
+                //异步通知地址
+                'notify_url' => Yii::$app->params['mallHost'] . "/notice/alipay-callback",
+                //同步跳转
+                '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'],
+            ];
+
+            Yii::info(json_encode($config) . ' aplipay config');
+
+            $alipayWap = Yii::getAlias("@vendor/alipayWap");
+            require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
+            require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
+
+            $totalFee = $order['actPrice'];
+            $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
+            $subject = '购买商品';//订单名称,必填
+            $total_amount = $totalFee;//付款金额,必填
+            $body = '';//商品描述,可空
+            $timeout_express = "1m";//超时时间
+
+            $typeList = configDict::getConfig('capitalType');
+            $capitalType = $typeList['xhOrder']['id'];
+            $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
+            $passbackParams = urlencode($passbackParams);
+
+            $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
+            $payRequestBuilder->setBody($body);
+            $payRequestBuilder->setSubject($subject);
+            $payRequestBuilder->setOutTradeNo($out_trade_no);
+            $payRequestBuilder->setTotalAmount($total_amount);
+            $payRequestBuilder->setTimeExpress($timeout_express);
+            //在异步通知时将该参数原样返回
+            $payRequestBuilder->setPassbackParams($passbackParams);
+            //同步通知
+            $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
+            //异步通知
+            $notifyUrl = Yii::$app->params['mallHost'] . "/notice/alipay-callback";
+            $payResponse = new \AlipayTradeService($config);
+            $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
+            //直接将支付宝的html返回给前端
+            echo $result;
+        } elseif ($payWay == 2) {
+            //余额支付,验证支付密码是否正确
+            $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
+            $user = UserService::getUserInfo($this->adminId, false);
+            UserService::validPayPassword($payPassword, $user);
+            $typeList = configDict::getConfig('capitalType');
+            $capitalType = $typeList['xhOrder']['id'];
+            $callbackParams = [];
+            $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
+            $balance = isset($respond['balance']) ? $respond['balance'] : 0;
+            util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
+        } else {
+            util::fail('无效的支付方式');
+        }
+    }
+
+    //订单评价
+    public function actionComment()
+    {
+        $post = Yii::$app->request->post();
+        $id = $post['id'];
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        if ($order['grade'] > 0) {
+            util::fail('您已经评过了');
+        }
+        OrderService::comment($post);
+        util::complete('提交成功');
+    }
+
+    //订单详情 shish 2019.12.16
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $orderSn = Yii::$app->request->get('orderSn', '');
+        $detail = [];
+        if (!empty($id)) {
+            $detail = OrderService::getOrderById($id);
+        }
+        if (!empty($orderSn)) {
+            $detail = OrderService::getOrderBySn($orderSn);
+        }
+        OrderService::valid($detail, $this->sjId);
+        util::success($detail);
+    }
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $search = isset($get['search']) ? $get['search'] : '';
+        $where = [];
+        $where['merchantId'] = $this->sjId;
+        if (isset($get['status']) && $get['status'] != -1) {
+            $where['status'] = $get['status'];
+        }
+        if (!empty($search)) {
+            if (stringUtil::isMobile($search)) {
+                $where['receiveMobile'] = $search;
+            } else {
+                $where['id'] = $search;
+            }
+        }
+        $list = OrderService::getOrderList($where);
+        $list['asset'] = MerchantAssetService::getByMerchantId($this->sjId);
+        util::success($list);
+    }
+
+    //订单归类 shish 2019.12.17
+    public function actionClassify()
+    {
+        $post = Yii::$app->request->post();
+        $id = isset($post['id']) ? $post['id'] : 0;
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        $categoryId = isset($post['categoryId']) ? $post['categoryId'] : $post['categoryId'];
+        $usageId = isset($post['usageId']) ? $post['usageId'] : $post['usageId'];
+        OrderService::classify($id, $categoryId, $usageId);
+        util::complete();
+    }
+
+    //更新配送单 shish 2019.12.17
+    public function actionUpdateSheet()
+    {
+        $post = Yii::$app->request->post();
+        $id = isset($post['id']) ? $post['id'] : 0;
+        unset($post['id']);
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        OrderService::updateSheet($order, $post);
+        util::complete('提交成功');
+    }
+
+    //商家收款与发货 shish 2019.12.18
+    public function actionGathering()
+    {
+        $post = Yii::$app->request->post();
+        $price = isset($post['price']) && is_numeric($post['price']) ? $post['price'] : 0;
+        $payWay = isset($post['payWay']) && is_numeric($post['payWay']) ? $post['payWay'] : 0;
+        $userId = isset($post['userId']) ? $post['userId'] : 0;
+        $userInfo = UserService::getById($userId);
+        if (empty($userInfo) || $userInfo['merchantId'] != $this->sjId) {
+            util::fail('您选择的客户无效');
+        }
+        if ($price <= 0) {
+            util::fail('请输入金额');
+        }
+        $post['prePrice'] = $price;
+        $post['actPrice'] = $price;
+        $post['payWay'] = $payWay;
+        $post['sourceType'] = 1;
+        $post['userId'] = $userId;
+        $post['goodsNum'] = 1;
+        $post['orderName'] = '商品';
+        $shopId = MerchantService::getDefaultShopId($this->sj);
+        $post['shopId'] = $shopId;
+        $order = OrderService::addOrder($post);
+        $id = $order['id'];
+        $orderSn = $order['orderSn'];
+
+        //流水类型列表
+        $capitalTypeList = configDict::getConfig('capitalType');
+        $capitalType = $capitalTypeList['xhOrder']['id'];
+        $callbackParams = [];
+        switch ($payWay) {
+            case 0:
+                xhPayToolService::weixinPay($callbackParams, $orderSn, $price, $capitalType, 0);
+                break;
+            case 1:
+                xhPayToolService::alipay($callbackParams, $orderSn, $price, $capitalType, 0, []);
+                break;
+            case 2:
+                xhPayToolService::balancePay($callbackParams, $orderSn, $price, $capitalType, 0);
+                break;
+            default:
+                util::fail('无效支付方式');
+        }
+        util::success($order);
+    }
+
+    //免发货管理 shish 2020.1.6
+    public function actionWithoutSend()
+    {
+        $id = Yii::$app->request->get('id');
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        //配送流程变更
+        $currentFlow = OrderSendClass::withoutSend($order);
+        util::success(['currentFlow' => $currentFlow]);
+    }
+
+    //修改价格 shish 2020.1.6
+    public function actionUpdatePrice()
+    {
+        $id = Yii::$app->request->get('id');
+        $price = Yii::$app->request->get('price', 1);
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        if (isset($order['modPrice']) && $order['modPrice'] == 0) {
+            util::fail('已发起支付,不能修改价格');
+        }
+        OrderService::updateById($id, ['actPrice' => $price]);
+        util::complete('修改成功');
+    }
+
+    //配送单 shish 2020.2.29
+    public function actionGetDeliverDetail()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $order = OrderService::getById($id);
+        OrderService::valid($order, $this->sjId);
+        $reachDate = isset($order['reachDate']) && !empty($order['reachDate']) ? $order['reachDate'] : '';
+        $reachPeriodId = $order['reachPeriod'];
+        $reachPeriodArr = [0 => '上午', 1 => '下午', 2 => '晚上'];
+        $reachPeriod = isset($reachPeriodArr[$reachPeriodId]) ? $reachPeriodArr[$reachPeriodId] : '';
+        $shopId = $order['shopId'];
+        $telephone = '';
+        if (!empty($shopId)) {
+            $shop = ShopService::getById($shopId);
+        }
+        $telephone = isset($shop['telephone']) ? $shop['telephone'] : '';
+        $bookName = isset($order['bookName']) ? $order['bookName'] : '';
+        $bookMobile = isset($order['bookMobile']) ? $order['bookMobile'] : '';
+        if (isset($order['anonymity']) && $order['anonymity'] == 1) {
+            $bookName = '--';
+            $bookMobile = '--';
+        }
+        $data = [
+            'reachDate' => $reachDate . ' ' . $reachPeriod,
+            'orderSn' => $order['orderSn'],
+            'receiveUserName' => $order['receiveUserName'],
+            'receiveMobile' => $order['receiveMobile'],
+            'receiveFullAddress' => $order['receiveAddress'] . $order['receiveFloor'] . "(" . $order['receiveFullAddress'] . ")",
+            'cardInfo' => $order['cardInfo'],
+            'bookMobile' => $bookMobile,
+            'bookName' => $bookName,
+            'remark' => $order['remark'],
+            'sendNum' => $order['sendNum'],
+            'telephone' => 13600903070,
+            'printTime' => '',
+            'img' => '',
+        ];
+        util::success($data);
+    }
 
 }

+ 2 - 2
app/shop/controllers/ShopController.php

@@ -133,9 +133,9 @@ class ShopController extends BaseController
 	public function actionDetail()
 	{
 		$introUserId = Yii::$app->request->get('introUserId');
-		$merchant = $this->merchant;
+		$merchant = $this->sj;
 		$shop = ShopService::getDefaultShop($merchant);
-		$ad = AdService::getValidAdList($this->merchantId);
+		$ad = AdService::getValidAdList($this->sjId);
 		
 		//新人专享礼物
 		$newUserGift = [];

+ 1 - 1
app/shop/controllers/TestController.php

@@ -13,7 +13,7 @@ use common\components\util;
 class TestController extends BaseController
 {
 
-	public $withoutLogin = ['inform', 'notice','order-query','add-order'];
+	public $withoutLoginAction = ['inform', 'notice','order-query','add-order'];
 
 	//新增订单
 	public function actionAddOrder()

+ 1 - 1
app/shop/controllers/UploadController.php

@@ -15,7 +15,7 @@ use yii\imagine\Image;
 class UploadController extends BaseController
 {
 	
-	public $withoutLogin = [];
+	public $withoutLoginAction = [];
 	
 	//上传图片接口
 	public function actionSaveImg()

+ 8 - 9
app/shop/controllers/UserController.php

@@ -260,8 +260,8 @@ class UserController extends BaseController
 		$post = Yii::$app->request->post();
 		$iv = isset($post['iv']) ? $post['iv'] : '';
 		$encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
-		$appId = $this->merchant['miniAppId'];
-		$merchantId = $this->merchantId;
+		$appId = $this->sj['miniAppId'];
+		$merchantId = $this->sjId;
 		$miniOpenId = $this->user['miniOpenId'];
 		if (empty($miniOpenId)) {
 			util::fail('mini_open_id empty');
@@ -291,8 +291,8 @@ class UserController extends BaseController
 		$post = Yii::$app->request->post();
 		$iv = $post['iv'];
 		$encryptedData = $post['encryptedData'];
-		$merchantId = $this->merchantId;
-		$merchant = $this->merchant;
+		$merchantId = $this->sjId;
+		$merchant = $this->sj;
 		$appId = $merchant['miniAppId'];
 		$miniOpenId = $this->user['miniOpenId'];
 		$user = $this->user;
@@ -375,7 +375,7 @@ class UserController extends BaseController
 		if (isset($post['birthday']) && !empty($post['birthday'])) {
 			$update['birthday'] = $post['birthday'];
 		}
-		$user = UserService::getByCondition(['merchantId' => $this->merchantId, 'mobile' => $mobile]);
+		$user = UserService::getByCondition(['merchantId' => $this->sjId, 'mobile' => $mobile]);
 		if ($userId == $user['id']) {
 			util::fail('手机号已验证');
 		}
@@ -383,7 +383,7 @@ class UserController extends BaseController
 			util::fail('手机号已经注册过了');
 		}
 		$update['mobile'] = $mobile;
-		UserService::becomeMember($this->user, $this->merchant, $update);
+		UserService::becomeMember($this->user, $this->sj, $update);
 		util::complete('注册成功');
 	}
 	
@@ -392,7 +392,7 @@ class UserController extends BaseController
 	{
 		$user = UserService::getUserInfo($this->adminId);
 		$growth = $user['userAsset']['growth'];
-		$extend = $this->merchantExtend;
+		$extend = $this->sjExtend;
 		$grade = MerchantExtendService::getGradeList($extend, 'asc');
 		//下个等级的积分
 		$nextLevelGrowth = 0;
@@ -413,6 +413,5 @@ class UserController extends BaseController
 		$user = $this->user;
 		util::success($user);
 	}
- 
- 
+
 }