فهرست منبع

零售业资产

shish 6 سال پیش
والد
کامیت
b04a49ccfd

+ 1 - 1
app/business/controllers/UserController.php

@@ -25,7 +25,7 @@ class UserController extends BaseController
 	{
 		$get = Yii::$app->request->get();
 		//组建where
-		$type = isset($get['type']) ? $get['type'] : 0;
+		$type = isset($get['type']) ? $get['type'] : -1;
 		$search = isset($get['search']) ? $get['search'] : '';
 		$where = ['merchantId' => $this->merchantId];
 		switch ($type) {

+ 11 - 282
app/saas/controllers/OrderController.php

@@ -1,293 +1,22 @@
 <?php
 namespace saas\controllers;
-use common\services\xhMerchantService;
-
-use common\components\configDict;
+use biz\order\services\OrderService;
+use biz\retail\services\RetailAssetService;
 use Yii;
-use yii\data\Pagination;
-use yii\helpers\Json;
-use common\models\xhOrder;
-use common\models\xhOrderGoods;
 use common\components\util;
-use common\components\stringUtil;
-use common\components\weixinUtil;
-use common\services\xhOrderService;
-use common\services\xhGoodsService;
-use common\services\xhTMessageService;
-use common\services\xhUserService;
-use common\services\xhUserAlipayService;
-use common\services\xhUserAssetService;
-use common\services\xhUserUniteService;
-use common\services\xhUserIntegralService;
-use common\services\xhMerchantCapitalService;
-use common\components\page;
 
 class OrderController extends PlatformController
 {
 
-    public function actionList()
-    {
-    	$get			= Yii::$app->request->get();
-    	$query			= xhOrder::find();
-    	if(isset($get['payStatus']) && $get['payStatus'] >= 0){
-    		$query->andWhere(['payStatus' => $get['payStatus']]);
-    	}
-    	$content		= '';
-    	if(isset($get['content']) && !empty($get['content'])){
-    		$content	= $get['content'];
-    		if(stringUtil::isMobieNumber($content)){
-    			$query->andWhere(['bookMobile' => $content]);
-    		}elseif(is_numeric($content)){
-    			$query->andWhere(['id' => $content]);
-    		}else{
-    			$query->andWhere(['like', 'bookName', $content]);
-    		}
-    	}
-    	$query->orderBy('createTime desc');
-    	$countQuery			= clone $query;
-    	$pages				= new Pagination(['totalCount' => $countQuery->count(),'pageSize' => 20]);
-    	$models				= $query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
-    	$reachPeriodName	= configDict::getConfig('reachPeriodName');
-    	$payStatusName		= configDict::getConfig('payStatusName');
-		return $this->render('list',['models' => $models,'payStatusName'=>$payStatusName,'reachPeriodName'=>$reachPeriodName,'pages' => $pages,'content' => $content]);
-    }
-
-    /**
-     * 网上订单明细
-     */
-    public function actionDetail()
-    {
-    	$get				= Yii::$app->request->get();
-    	$id					= isset($get['id']) ? $get['id'] : 0;
-    	$order				= xhOrderService::getById($id);
-    	$goodsList			= xhOrderGoods::getAllByCondition(['orderId' => $id]);
-        foreach ($goodsList as $key => $good){
-            $goodsId		= $good['goodsId'];
-            $goodsData		= xhGoodsService::getById($goodsId);
-            if($goodsData['goodsName'] != $good['title']){
-                $subTitle	= $good['title'];
-                $goodsList[$key]['title'] = $goodsData['goodsName'];
-                $goodsList[$key]['subTitle'] = $subTitle;
-            }
-        }
-    	$reachPeriodName	= configDict::getConfig('reachPeriodName');//送达时间点 上午 下午 晚上
-    	$userId				= 0;
-    	$userInfo			= [];
-    	if(!empty($order['userId'])){
-    		$userId			= $order['userId'];
-    		$userInfo		= xhUserService::getById($userId);
-    	}
-    	$merchantId			= $order['merchantId'];
-    	$payWayNameList		= configDict::getConfig('payWayName');
-    	$alipayWay			= configDict::getConfig('payWay','alipay');
-    	$alipayInfo			= [];
-    	if($order['payWay'] == $alipayWay){
-    		$alipayId		= $order['alipayId'];
-    		$alipayInfo		= xhUserAlipayService::getByIds($alipayId,$merchantId);
-    	}
-    	$merchant			= xhMerchantService::getById($merchantId);
-    	return $this->render('detail',['userInfo'=>$userInfo,'alipayWay'=>$alipayWay,'alipayInfo'=>$alipayInfo,'payWayNameList'=>$payWayNameList,'order' => $order,'reachPeriodName'=>$reachPeriodName,'goodsList' => $goodsList,'merchant' => $merchant]);
-    }
-
-    public function actionUpdatePayStatus()
-    {
-    	$get		= Yii::$app->request->get();
-    	$id			= isset($get['id']) ? $get['id'] : 0;
-    	$order		= xhOrderService::getById($id);
-    	if(empty($order) || $order['merchantId'] != $this->merchantId){
-    		util::failInfo('非法访问');
-    	}
-    	$status 	= isset($get['status']) ? $get['status'] : 0;
-    	if($order['payStatus'] == 0){
-    		//util::failInfo('客户还没有付款');
-            $userId = $order['userId'];
-            $user = xhUserService::getById($userId);
-            if(empty($user)){
-                util::failInfo('客户信息出错-用户ID未保存');
-            }
-    	}
-    	xhOrderService::updateById($id, ['sendStatus' =>$status]);
-    	if($status == 2){//已经送达,通知订花人
-    		$userId 		= $order['userId'];
-    		$user			= xhUserService::getById($userId);
-    		$openId			= $user['openId'];
-    		$merchantId		= $user['merchantId'];
-    		if(xhUserService::isSubscribe($userId)){
-    			$allTM			= xhTMessageService::getList($merchantId);
-    			$shortTempId	= 'OPENTM201205968';//订单送达通知
-    			$tempId			= $allTM[$shortTempId];
-    			$data = ["touser" => $openId,"template_id" => $tempId,
-    					"url" => Yii::$app->params['frontUrl']."/center/order-detail?id={$order['id']}&account={$this->merchantId}",
-    					"data" => [
-    					"first" => ["value" => '您的订单已送达',"color" => "#173177"],
-    					"keyword1" => ["value" => (string)$order['id'],"color" => "#173177"],
-    					"keyword2" => ["value" => $order['receiveUserName'],"color" => "#173177"],
-    					"keyword3" => ["value" => '已送达',"color" => "#173177"],
-    					"remark" => ["value" => '感谢您惠顾,祝你生活愉快!',"color" => "#173177"]]];
-    			weixinUtil::sendTaskInform($data,$this->merchant);
-    		}
-    	}
-    	echo Json::encode(['code' => 'A0001','msg' =>'操作成功','data' =>[]]);
-    }
-
-    /**
-     * 订单修改
-     * @param $id
-     */
-    public function actionEditOrder($id){
-        $orderData = xhOrderService::getById($id);
-        if(empty($orderData)){
-            util::failInfo('此订单不存在');
-        }
-        $orderData['reachTime'] = substr($orderData['reachTime'], 0, 10);
-
-        util::successInfo('获取成功', 'A0001', $orderData);
-    }
-
-    /**
-     * 保存订单修改
-     * @param $id
-     */
-    public function actionSaveEditOrder(){
-        $updateData = [];
-        $post = Yii::$app->request->post();
-        $orderData = xhOrderService::getById($post['id']);
-        if(empty($orderData)){
-            util::failInfo('此订单不存在');
-        }
-        //已付款 或 微信中打开支付链接的,不可修改价格
-        $status = $orderData['actPrice'] != $post['consumeAmount'] ? true : false;
-        if($orderData['modPrice'] == 0 && $status){
-            util::failInfo('订单已锁定,不能修改价格');
-        }else if($orderData['payStatus'] == 1 && $status){
-            util::failInfo('订单已付款,不能修改价格');
-        }
-
-        xhOrderService::formatPost($updateData, $post);
-        $re = xhOrderService::updateById($post['id'], $updateData);
-        if($re == 1){
-            $msg = '保存成功';
-        }else{
-            $msg = '表单数据未变更';
-        }
-        util::successInfo($msg, 'A0001', $orderData);
-    }
-
-	/**
-	 * 打印订单
-	 */
-    public function actionPrint()
-    {
-    	$get					= Yii::$app->request->get();
-    	$id						= isset($get['id']) ? $get['id'] : 0;
-    	$order					= xhOrderService::getById($id);
-    	if(empty($order) || $order['merchantId'] != $this->merchantId){
-    		echo '访问出错了,请联系网站管理员';
-    		Yii::$app->end();
-    	}
-    	$goodsList				= xhOrderGoods::getAllByCondition(['orderId' => $id]);
-    	$list					= [];
-    	foreach($goodsList as $val){
-    		$list[]			= ['name' => $val['title'],'num' => $val['num']];
-    	}
-    	return $this->renderPartial('print',['order' => $order,'merchant' => $this->merchant,'goodsList' => $list]);
-    }
-
-    /**
-     * 更新打印状态
-     */
-	public function actionUpdatePrintStatus()
+	public function actionList()
 	{
-		$get 		= Yii::$app->request->get();
-		$status		= isset($get['status']) ? $get['status'] : 1;
-		$id  		= isset($get['id']) ? $get['id'] : 0;
-		$order		= xhOrderService::getById($id);
-		if(empty($order) || $order['merchantId'] != $this->merchantId){
-			echo Json::encode(['code' => 'A0002','data' => '','msg' => '出错了,请联系网站管理员']);
-			Yii::$app->end();			
-		}
-		xhOrderService::updateById($id, ['printStatus' => $status]);
-		echo Json::encode(['code' => 'A0001','data' => '','msg' => 'success']);
+		$get = Yii::$app->request->get();
+		$status = isset($get['status']) ? $get['status'] : 0;
+		$where = ['status' => $status];
+		$list = OrderService::getOrderList($where);
+		$asset = RetailAssetService::getAsset();
+		$list['asset'] = $asset;
+		util::success($list);
 	}
 
-    /**
-     * 修改价格
-     */
-    public function actionModifyPrice()
-    {
-    	$get 		= Yii::$app->request->get();
-    	$actPrice	= isset($get['actPrice']) ? $get['actPrice'] : 10000;
-    	$id  		= isset($get['id']) ? $get['id'] : 0;
-    	$order		= xhOrderService::getById($id, $this->merchantId);
-    	if($order['merchantId'] != $this->merchantId){
-    		util::fail('您没有权限操作此订单');
-    	}
-    	if($order['modPrice'] == 0){
-    		util::fail('订单已锁定,不能修改价格');
-    	}
-    	$prePrice			= $order['actPrice'];
-    	xhOrderService::updateById($id, ['actPrice' => $actPrice]);
-    	$userId 			= $order['userId'];
-    	$user				= xhUserService::getById($userId);
-    	if(empty($user)){
-            echo Json::encode(['code' => 'A0001','data' => '','msg' => "修改成功"]);
-            exit();
-        }
-    	$openId 			= $user['openId'];
-    	$merchantId			= $user['merchantId'];
-
-    	//价格修改通知
-    	$allTM				= xhTMessageService::getList($merchantId);
-    	$shortTempId		= 'OPENTM401761342';
-    	$tempId				= $allTM[$shortTempId];
-    	$data 	= [
-    			"touser" => $openId,
-    			"template_id" => $tempId,//模板id,从公众平台后台取得
-    			"url" => $this->frontUrl."/center/order-detail?id={$order['id']}&account={$merchantId}",
-    			"data" => [
-    					"first" => ["value" => '您好,你购买的商品价格已修改。',"color" => "#173177"],
-    					"keyword1" => ["value" => (string)$order['id'],"color" => "#173177"],
-    					"keyword2" => ["value" => $prePrice,"color" => "#173177"],
-    					"keyword3" => ["value" => number_format($actPrice,2),"color" => "#173177"],
-    					"remark" => ["value" => '点此进行支付。',"color" => "#173177"]]];
-    	weixinUtil::sendTaskInform($data,$this->merchant);
-    	echo Json::encode(['code' => 'A0001','data' => '','msg' => "修改成功,已通知客户"]);
-    }
-
-    /**
-     * 修改商品的配送编号
-     */
-    public function actionModifySendNum()
-    {
-    	$get	= Yii::$app->request->get();
-    	$id		= isset($get['id']) ? $get['id'] : 0;
-    	$num	= isset($get['num']) ? $get['num'] : '';
-    	$order	= xhOrderService::getById($id);
-    	if($order['merchantId'] != $this->merchantId){
-    		util::failInfo('修改失败');
-    	}
-    	xhOrderService::updateById($id, ['sendNum'=>$num]);
-    	util::successInfo('修改成功');
-    }
-
-    public function actionUserOrderList()
-    {
-    	$get			= Yii::$app->request->get();
-    	$userId			= isset($get['id']) ? $get['id'] : 0;
-    	$user			= xhUserService::getById($userId,$this->merchantId);
-    	$query			= xhOrder::find();
-    	$query->where(['userId' =>$userId]);
-    	$countQuery		= clone $query;
-    	$count			= $countQuery->count();
-    	$page			= isset($get['page']) ? $get['page'] : 1;
-    	$pageSize		= 20;
-    	$offset			= ($page - 1) * $pageSize;
-    	$models			= $query->offset($offset)->orderBy('createTime desc')->limit($pageSize)->asArray()->all();
-    	$page			= new page($count,$page,$pageSize);
-    	$paging 		= $page->fpage();
-    	$reachPeriodName	= configDict::getConfig('reachPeriodName');
-    	$payStatusName		= configDict::getConfig('payStatusName');
-    	return $this->render('userOrderList',['models' => $models,'paging' => $paging,'payStatusName'=>$payStatusName,'reachPeriodName'=>$reachPeriodName]);
-    }
-
-}
+}

+ 46 - 874
app/saas/controllers/UserController.php

@@ -2,887 +2,59 @@
 
 namespace saas\controllers;
 
-use common\services\xhUserAlipayService;
-use common\services\xhUserIntegralService;
-use Yii;
-use common\services\xhTrainClassService;
-use common\services\xhOrderService;
-use common\services\xhPayToolService;
-use common\services\xhRechargeService;
-use common\services\xhMerchantExtendService;
-use common\services\xhMerchantAssetService;
-use common\services\xhUserAssetService;
-use common\services\xhCouponService;
-use common\services\xhUserTagService;
-use common\models\xhUserTag;
-use common\services\xhUserTagClassService;
-use common\models\xhTrainCourse;
-use common\models\xhTrainStudent;
-use common\models\xhUser;
-use common\models\xhUserAsset;
-use common\services\xhAdminService;
-use common\services\xhMerchantService;
-use common\components\stringUtil;
-use common\components\weixinUtil;
-use common\services\xhTMessageService;
-use common\components\configDict;
+use biz\merchant\services\MerchantAssetService;
+use biz\retail\services\RetailAssetService;
+use biz\user\services\UserService;
 use common\components\util;
-use common\components\page;
-use common\services\xhUserService;
-use common\models\xhTrainUserCourse;
-use common\services\xhUserByDayService;
-use common\models\xhUserAlipay;
-use common\services\xhUserUniteService;
-use common\services\xhMerchantCapitalService;
+use Yii;
 
-class UserController extends PlatformController
+class UserController extends BaseController
 {
 	
 	public function actionList()
 	{
 		$get = Yii::$app->request->get();
-		$query = xhUser::find();
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['mobile' => $content]);
-			} else {
-				$query->andWhere(['like', 'userName', $content]);
-			}
-		}
-		if (isset($get['class']) && $get['class'] == 1) {
-			$query->andWhere(['isMember' => 1]);
-		}
-		$countQuery = clone $query;
-		$count = $countQuery->count();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 20;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->orderBy('createTime desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		return $this->render('list', [
-			'models' => $models,
-			'pages' => $paging,
-		]);
-	}
-	
-	public function actionAlipayUser()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhUserAlipay::find();
-		$countQuery = clone $query;
-		$count = $countQuery->count();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 20;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->orderBy('updateTime desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		return $this->render('alipayUser', [
-			'models' => $models,
-			'pages' => $paging,
-		]);
-	}
-	
-	public function actionAlipayUserDetail()
-	{
-		$get = Yii::$app->request->get();
-		$alipayId = isset($get['alipayId']) ? $get['alipayId'] : '';
-		$alipay = xhUserAlipayService::getByIds($alipayId, $this->merchantId);
-		return $this->render('alipayUserDetail', ['alipay' => $alipay]);
-	}
-	
-	public function actionDetail()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$user = xhUserService::getById($id);
-		$userAsset = xhUserAssetService::getByUserId($id);
-		$merchantId = $user['merchantId'];
-		$merchant = xhMerchantService::getById($merchantId);
-		$class = xhTrainClassService::getAllByCondition(['merchantId' => $merchantId]);
-		//取商标的所有用户标签
-		$merchantTag = xhUserTagClassService::getMerchantTag($merchantId);
-		$userTag = xhUserTagService::getUserTag($id);
-		$coupon = xhCouponService::getUserCoupon($id);//取代金劵
-		$merchantExtend = xhMerchantExtendService::getByMerchantId($merchantId);
-		$memberIntegral = xhMerchantExtendService::getGradeList($merchantExtend, 'desc');
-		$freight = configDict::getConfig('freight');//运费计算
-		$alipayId = 0;
-		$alipayInfo = [];
-		if (!empty($user['alipayId'])) {
-			$alipayId = $user['alipayId'];
-			$alipayInfo = xhUserAlipayService::getByIds($alipayId, $merchantId);
-		}
-		return $this->render('detail', [
-			'merchantExtend' => $merchantExtend,
-			'userTag' => $userTag,
-			'coupon' => $coupon,
-			'merchantTag' => $merchantTag,
-			'user' => $user,
-			'class' => $class,
-			'userAsset' => $userAsset,
-			'memberIntegral' => $memberIntegral,
-			'freight' => $freight,
-			'merchant' => $merchant,
-			'alipayInfo' => $alipayInfo,
-		]);
-	}
-	
-	/**
-	 * 升级为会员
-	 */
-	public function actionUpgrade()
-	{
-		$get = Yii::$app->request->get();
-		$adminId = $this->adminId;
-		$admin = xhAdminService::getById($adminId);
-		if (isset($get['confirmPassword']) == false) {
-			util::failInfo('请填写确认密码');
-		}
-		if (isset($get['memberLevel']) == false || empty($get['memberLevel'])) {
-			util::failInfo('请选择等级数');
-		}
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$memberLevel = $get['memberLevel'];
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('客户不存在');
-		}
-		if (empty($user['mobile'])) {
-			util::failInfo('客户还没有设置手机号哦');
-		}
-		$confirmPassword = $get['confirmPassword'];
-		if (md5($confirmPassword) != $admin['confirmPassword']) {
-			util::failInfo('确认密码有误');
-		}
-		$grade = xhMerchantExtendService::getGradeList($this->merchantExtend, 'desc');
-		$newLevelPoint = $grade[$memberLevel]['point'];//升级到当前级别需要的积分数
-		$userAsset = xhUserAssetService::getByUserId($userId);//用户资产
-		if (!empty($userAsset['isMember']) && $userAsset['memberLevel'] >= $memberLevel) {
-			util::failInfo('客户已经达到此级别了');
-		}
-		$addPoint = $newLevelPoint - $userAsset['point'];
-		$upData['point'] = $newLevelPoint;//升级后的积分
-		$upData['memberLevel'] = $memberLevel;
-		$upData['isMember'] = 1;
-		xhUserAssetService::updateByUserId($userId, $upData);
-		
-		$now = time();
-		$date = date("Y-m-d H:i", $now);
-		$cashPay = configDict::getConfig('payWay', 'cashPay');
-
-		$allTM = xhTMessageService::getList($this->merchantId);
-		$openId = $user['openId'];
-		$shortTempId = 'OPENTM205211943';//升级通知
-		if (isset($allTM[$shortTempId])) {
-			$tempId = $allTM[$shortTempId];
-			$data = [
-				"touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['frontUrl'] . '/center/right?account=' . $this->merchant['id'],
-				"data" => [
-					"first" => ["value" => "恭喜,您已经升为{$memberLevel}级会员。", "color" => "#173177"],
-					"keyword1" => ["value" => $user['userName'], "color" => "#173177"],
-					"keyword2" => ["value" => $date, "color" => "#173177"],
-					"remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
-				]];
-			weixinUtil::sendTaskInform($data, $this->merchant);
-		}
-		util::successInfo();
-	}
-	
-	/**
-	 * 充值
-	 */
-	public function actionRecharge()
-	{
-		$get = Yii::$app->request->get();
-		$rechargePassword = isset($get['rechargePassword']) ? $get['rechargePassword'] : '';
-		$adminId = $this->adminId;
-		$admin = xhAdminService::getById($adminId);
-		if (empty($admin['confirmPassword'])) {
-			util::failInfo('您还没有设置确认密码');
-		}
-		if (md5($rechargePassword) != $admin['confirmPassword']) {
-			util::failInfo('确认密码有误哦');
-		}
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$rechargeAmount = isset($get['rechargeAmount']) ? $get['rechargeAmount'] : 1;
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('访问出错,请联系网站管理员');
-		}
-		$openId = $user['openId'];
-		$payPassword = $user['payPassword'];
-		$date = date("Y-m-d H:i:s");
-		$userAsset = xhUserAssetService::getByUserId($userId);
-		if (empty($userAsset)) {
-			util::failInfo('操作出错,请与网站管理员联系');
-		}
-		$totalBalance = $userAsset['balance'] + $rechargeAmount;
-		$totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
-		$upData['balance'] = $totalBalance;
-		$upData['totalRecharge'] = $totalRecharge;
-		$return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->merchant, $this->merchantExtend, $this->merchantAsset);
-		if ($return['code'] == 'A0001') {
-			util::successInfo('充值成功');
-		}
-		util::successInfo('充值失败');
-	}
-	
-	/**
-	 * 现金支付,转店主微信,转店主支付宝
-	 */
-	public function actionCashPay()
-	{
-		$post = Yii::$app->request->post();
-		$extend = $this->merchantExtend;
-		//dump($post);die;
-		$getUid = Yii::$app->request->get('userId');
-		$userId = isset($getUid) ? $getUid : 0;
-		$amount = isset($post['consumeAmount']) ? $post['consumeAmount'] : 1;
-		$couponId = isset($post['couponId']) ? $post['couponId'] : 1;
-		
-		$user = xhUserService::getById($userId, $this->merchantId);
-		/*if($user['merchantId'] != $this->merchantId){
-			util::failInfo('非法访问');
-		}*/
-		if (!empty($user) && empty($user['subscribe'])) {
-			util::failInfo('客户要关注公众号才能结算');
-		}
-		/*if(!empty($couponId)){
-			$coupon					= xhCouponService::getById($couponId);
-			if($coupon['merchantId'] != $this->merchantId){
-				util::failInfo('非法代金劵');
-			}
-			if($coupon['useStatus'] == 1 || time() > $coupon['deadline']){
-				util::failInfo('代金劵已经失效');
-			}
-			if($coupon['meetAmount'] > $amount){
-				util::failInfo('消费不足'.$coupon['meetAmount'].'元');
-			}
-		}*/
-		
-		$payWay = configDict::getConfig('payWay', 'cashPay');
-		$payStyle = configDict::getConfig('payStyle', 'cashPay');
-		$now = time();
-		$expireTime = $now + 300;//订单5分钟后过期
-		$payAdd['prePrice'] = $amount;
-		$payAdd['actPrice'] = $amount;
-		$payAdd['payWay'] = $payWay;
-		$payAdd['payStyle'] = $payStyle;
-		$payAdd['payStatus'] = 0;
-		$payAdd['userId'] = $userId;
-		$payAdd['merchantId'] = $this->merchantId;
-		$payAdd['createTime'] = date("Y-m-d H:i:s", $now);
-		$payAdd['deadline'] = $expireTime;
-		xhOrderService::formatPost($payAdd, $post);
-		$order = xhOrderService::add($payAdd);
-		$id = $order['id'];
-		
-		$typeList = configDict::getConfig('capitalType');
-		$capitalType = $typeList['xhOrder']['id'];
-		$return = xhPayToolService::cashPay($id, $amount, $capitalType, $couponId);
-		
-		if ($return['code'] == 'A0001') {
-			util::successInfo('登记成功');
-		} else {
-			Yii::warning(json_encode($return));
-		}
-		util::failInfo('登记没有成功');
-	}
-	
-	/**
-	 * 重置支付密码
-	 */
-	public function actionResetPayPassword()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$user = xhUserService::getById($id);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('没有这个客户');
-		}
-		if (empty($user['subscribe'])) {
-			util::failInfo('客户要先关注公众号哦');
-		}
-		$rand = stringUtil::getRandNum(6);
-		xhUserService::updateById($id, ['payPassword' => md5($rand)]);
-		$openId = $user['openId'];
-		$allTM = xhTMessageService::getList($this->merchantId);
-		$shortTempId = 'OPENTM207430125';
-		$tempId = $allTM[$shortTempId];
-		$url = Yii::$app->params['frontUrl'] . '/center/password?account=' . $this->merchant['id'];
-		$data = [
-			"touser" => $openId, "template_id" => $tempId, "url" => $url,
-			"data" => ["first" => ["value" => '操作成功', "color" => "#173177"],
-				"keyword1" => ["value" => "你的支付密码已经重置为:" . $rand, "color" => "#173177"],
-				"keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
-				"remark" => ["value" => "点此修改成好记的密码哦", "color" => "#173177"]]];
-		weixinUtil::sendTaskInform($data, $this->merchant);
-		util::successInfo();
-	}
-	
-	/**
-	 * 导出用户,备份用户
-	 */
-	public function actionExport()
-	{
-		$query = xhUserAsset::find();
-		$query->where(['merchantId' => $this->merchantId])->andWhere(['>', 'integral', 0]);
-		$userAsset = $query->orderBy('integral desc')->all();
-		if (empty($userAsset)) {
-			echo '没有获得积分用户';
-			Yii::$app->end();
-		}
-		$objectPHPExcel = new \PHPExcel();
-		$objectPHPExcel->setActiveSheetIndex(0);
-		
-		$memberCount = xhUserAsset::find()->andWhere(['isMember' => 1, 'merchantId' => $this->merchantId])->count('id');//会员数
-		$allUsercount = xhUserAsset::find()->andWhere(['merchantId' => $this->merchantId])->count('id');//用户数
-		
-		//报表头的输出
-		$objectPHPExcel->getActiveSheet()->mergeCells('B1:G1');
-		$objectPHPExcel->getActiveSheet()->setCellValue('B1', '用户信息表');
-		
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '用户信息表');
-		$objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getFont()->setSize(24);
-		$objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
-		
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2', '日期:' . date("Y年m月j日"));
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F2', '用户数:' . $allUsercount);
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G2', '会员数:' . $memberCount);
-		$objectPHPExcel->setActiveSheetIndex(0)->getStyle('F2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);//右居中
-		$objectPHPExcel->setActiveSheetIndex(0)->getStyle('G2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);//右居中
-		
-		//表格头的输出
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(7);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(22);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(17);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
-		$objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(22);
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3', '编号');
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3', '昵称');
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3', '会员等级');
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3', '余额');
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3', '积分');
-		$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3', '创建日期');
-		
-		//设置居中
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
-		
-		//设置边框
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getBorders()->getTop()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getBorders()->getLeft()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getBorders()->getRight()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getBorders()->getBottom()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getBorders()->getVertical()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		
-		//设置颜色
-		$objectPHPExcel->getActiveSheet()->getStyle('B3:G3')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FF66CCCC');
-		
-		foreach ($userAsset as $subKey => $subMUser) {
-			//明细的输出
-			$objectPHPExcel->getActiveSheet()->setCellValue('B' . ($subKey + 4), $subKey + 1);
-			$objectPHPExcel->getActiveSheet()->setCellValue('C' . ($subKey + 4), $subMUser->xhUser->userName);
-			$objectPHPExcel->getActiveSheet()->setCellValue('D' . ($subKey + 4), $subMUser->memberLevel);
-			$objectPHPExcel->getActiveSheet()->setCellValue('E' . ($subKey + 4), $subMUser->balance);
-			$objectPHPExcel->getActiveSheet()->setCellValue('F' . ($subKey + 4), $subMUser->integral);
-			$objectPHPExcel->getActiveSheet()->setCellValue('G' . ($subKey + 4), $subMUser->createTime);
-			//设置边框
-			$currentRowNum = $subKey + 4;
-			$objectPHPExcel->getActiveSheet()->getStyle('B' . ($subKey + 4) . ':G' . $currentRowNum)->getBorders()->getTop()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-			$objectPHPExcel->getActiveSheet()->getStyle('B' . ($subKey + 4) . ':G' . $currentRowNum)->getBorders()->getLeft()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-			$objectPHPExcel->getActiveSheet()->getStyle('B' . ($subKey + 4) . ':G' . $currentRowNum)->getBorders()->getRight()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-			$objectPHPExcel->getActiveSheet()->getStyle('B' . ($subKey + 4) . ':G' . $currentRowNum)->getBorders()->getBottom()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-			$objectPHPExcel->getActiveSheet()->getStyle('B' . ($subKey + 4) . ':G' . $currentRowNum)->getBorders()->getVertical()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
-		}
-		
-		//设置分页显示
-		//$objectPHPExcel->getActiveSheet()->setBreak( 'I55' , \PHPExcel_Worksheet::BREAK_ROW );
-		//$objectPHPExcel->getActiveSheet()->setBreak( 'I10' , \PHPExcel_Worksheet::BREAK_COLUMN );
-		$objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
-		$objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);
-		
-		ob_end_clean();
-		ob_start();
-		
-		header('Content-Type : application/vnd.ms-excel');
-		header('Content-Disposition:attachment;filename="' . $this->merchant['merchantName'] . '会员' . date("Ymj") . '.xls"');
-		$objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5');
-		$objWriter->save('php://output');
-	}
-	
-	/**
-	 * 报名培训
-	 */
-	public function actionApplyTrain()
-	{
-		$get = Yii::$app->request->get();
-		$userId = $get['userId'];
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('学员不存在');
-		}
-		if (empty($user['subscribe'])) {
-			util::failInfo('学员还没有关注公众号哦~');
-		}
-		$student = xhTrainStudent::getByCondition(['userId' => $userId, 'merchantId' => $this->merchantId]);
-		if (!empty($student)) {
-			util::failInfo('已经报过名了哦~');
-		}
-		$classId = isset($get['classId']) ? $get['classId'] : 0;
-		$class = xhTrainClassService::getById($classId);
-		if (empty($class)) {
-			util::failInfo('课程不存在哦~');
-		}
-		$nowTime = time();
-		$stuData = ['userId' => $userId, 'merchantId' => $this->merchantId, 'registerTime' => $nowTime, 'classId' => $class['id'],
-			'addTime' => $nowTime, 'modTime' => $nowTime, 'tuition' => $class['tuition'], 'className' => $class['name'], 'lesson' => $class['lesson']];
-		$student = xhTrainStudent::add($stuData);
-		$course = xhTrainCourse::getAllByCondition(['classId' => $classId]);
-		$userCourse = [];
-		foreach ($course as $key => $val) {
-			$userCourse[] = ['courseId' => $val['id'], 'courseName' => $val['name'], 'courseIntro' => $val['intro'], 'classId' => $classId, 'studentId' => $student['id'], 'userId' => $userId, 'merchantId' => $this->merchantId];
-		}
-		xhTrainUserCourse::batchAdd($userCourse);
-		xhUserService::updateById($userId, ['identity' => 1]);
-		
-		$allTM = xhTMessageService::getList($this->merchantId);
-		$openId = $user['openId'];
-		$shortTempId = 'OPENTM401027382';
-		$tempId = $allTM[$shortTempId];
-		$data = array(
-			"touser" => $openId,
-			"template_id" => $tempId,//模板id,从公众平台后台取得
-			"url" => $this->frontUrl . '/center/student-card?account=' . $this->merchant['id'],
-			"data" => array(
-				"first" => array(
-					"value" => "恭喜,您已经成功报名。",
-					"color" => "#173177"
-				),
-				"keyword1" => array(
-					"value" => $class['name'],
-					"color" => "#173177"
-				),
-				"keyword2" => array(
-					"value" => date("Y-m-d H:i"),
-					"color" => "#173177"
-				),
-				"remark" => array(
-					"value" => "您的学员卡已经激活,点此查看课程内容",
-					"color" => "#173177"
-				),
-			),
-		);
-		weixinUtil::sendTaskInform($data, $this->merchant);
-		util::successInfo('报名成功~');
-	}
-	
-	public function actionRemark()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('用户不存在');
-		}
-		$remark = isset($get['remark']) ? $get['remark'] : '';
-		xhUserService::updateById($userId, ['remark' => $remark]);
-		util::successInfo();
-	}
-	
-	public function actionTagUserList()
-	{
-		$get = Yii::$app->request->get();
-		$tagId = isset($get['tagId']) ? $get['tagId'] : 0;
-		$tagInfo = xhUserTagClassService::getByCondition(['tagId' => $tagId]);
-		if (empty($tagInfo) || $tagInfo['merchantId'] != $this->merchantId) {
-			util::stop('不合法标签');
-		}
-		$query = xhUserTag::find();
-		$query->where(['tagId' => $tagId]);
-		$query->orderBy('id desc');
-		$countQuery = clone $query;
-		$count = $countQuery->count();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 20;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->orderBy('id desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		return $this->render('tagUserList', ['models' => $models, 'paging' => $paging, 'merchantTag' => $merchantTag, 'tagInfo' => $tagInfo]);
-	}
-	
-	public function actionTag()
-	{
-		$tag = xhUserTagClassService::getAllByCondition(['merchantId' => $this->merchantId]);
-		return $this->render('tag', ['tag' => $tag]);
-	}
-	
-	/**
-	 * 添加用户标签
-	 */
-	public function actionTagAdd()
-	{
-		$post = Yii::$app->request->post();
-		if (isset($post['tagName']) == false || empty($post['tagName'])) {
-			util::failInfo('请填写标签名称');
-		}
-		$name = $post['tagName'];
-		$tagArr = xhUserTagClassService::getMerchantTag($this->merchantId);
-		if (!empty($tagArr) && in_array($name, $tagArr)) {
-			util::failInfo('标签已经存在了');
-		}
-		$return = weixinUtil::createTag($this->merchant, $name);
-		if (isset($return['errcode']) == false) {
-			$tagId = $return['tag']['id'];
-			$data = ['tagId' => $tagId, 'name' => $name, 'merchantId' => $this->merchantId];
-			xhUserTagClassService::add($data, $this->merchantId);
-			util::successInfo();
-		}
-		$errCode = $return['errcode'];
-		$errList = weixinUtil::$errCodes;
-		$msg = $errList[$errCode];
-		util::failInfo($msg);
-	}
-	
-	/**
-	 * 删除用户标签
-	 */
-	public function actionTagDel()
-	{
-		$get = Yii::$app->request->get();
-		if (isset($get['tagId']) == false || empty($get['tagId'])) {
-			util::failInfo('请选择你要删除的标签');
-		}
-		$tagId = $get['tagId'];
-		$status = xhUserTagService::getUserByTagId($tagId);
-		if ($status) {
-			util::failInfo('标签下还有用户,无法删除');
-		}
-		$tag = xhUserTagClassService::getByCondition(['tagId' => $tagId, 'merchantId' => $this->merchantId]);
-		if (empty($tag)) {
-			util::failInfo('标签不存在');
-		}
-		if ($tag['merchantId'] != $this->merchantId) {
-			util::failInfo('非法操作');
-		}
-		$wxTagId = $tag['tagId'];
-		$return = weixinUtil::delTag($this->merchant, $wxTagId);
-		if (isset($return['errcode']) && $return['errcode'] == 0) {
-			xhUserTagClassService::deleteByCondition(['tagId' => $tagId, 'merchantId' => $this->merchantId], $this->merchantId);
-			util::successInfo();
-		}
-		$errCode = $return['errcode'];
-		$errList = weixinUtil::$errCodes;
-		$msg = $errList[$errCode];
-		util::failInfo($msg);
-	}
-	
-	/**
-	 * 修改标签
-	 */
-	public function actionTagMod()
-	{
-		$get = Yii::$app->request->get();
-		if (isset($get['id']) == false || empty($get['id'])) {
-			util::failInfo('请选择标签');
-		}
-		$id = $get['id'];
-		$tag = xhUserTagClassService::getByCondition(['id' => $id]);
-		if (empty($tag)) {
-			util::failInfo('标签已删除');
-		}
-		if ($tag['merchantId'] != $this->merchantId) {
-			util::failInfo('非法访问');
-		}
-		$tagId = $tag['tagId'];
-		$name = $get['tagName'];
-		$return = weixinUtil::modTag($this->merchant, $tagId, $name);
-		if (isset($return['errcode']) && $return['errcode'] == 0) {
-			$data = ['name' => $name];
-			xhUserTagClassService::updateById($id, $data, $this->merchantId);
-			util::successInfo('操作成功');
-		}
-		$errCode = $return['errcode'];
-		$errList = weixinUtil::$errCodes;
-		$msg = $errList[$errCode];
-		util::failInfo($msg);
-	}
-	
-	/**
-	 * 对每个用户设置标签
-	 */
-	public function actionTagSet()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('非法用户');
-		}
-		$tagId = isset($get['tagId']) ? $get['tagId'] : '';
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$mTag = array_flip($merchantTag);
-		//防止非法标签id
-		if (in_array($tagId, $mTag) == false) {
-			util::failInfo('非法标签');
-		}
-		$userTag = xhUserTagService::getUserTag($userId);
-		if (count($userTag) >= 3) {
-			util::failInfo('最多只能设置三个标签哦');
-		}
-		if (in_array($tagId, $userTag)) {
-			util::failInfo('此标签已经添加过了');
-		}
-		$openIdList = [$user['openId']];
-		$return = weixinUtil::membersBatchTag($this->merchant, $openIdList, $tagId);
-		if (isset($return['errcode']) == false) {
-			util::failInfo('操作未成功,微信服务器没有返回');
-		}
-		if ($return['errcode'] != 0) {
-			$errCode = $return['errcode'];
-			$errList = weixinUtil::$errCodes;
-			$msg = isset($errList[$errCode]) ? $errList[$errCode] : '';
-			util::failInfo($msg);
-		}
-		$addTagData = ['merchantId' => $this->merchantId, 'tagId' => $tagId, 'userId' => $userId];
-		xhUserTagService::add($addTagData);
-		util::successInfo();
-	}
-	
-	/**
-	 * 删除用户的标签
-	 */
-	public function actionTagRemove()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$user = xhUserService::getById($userId);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::failInfo('非法用户');
-		}
-		$tagId = isset($get['tagId']) ? $get['tagId'] : '';
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$mTag = array_flip($merchantTag);
-		//防止非法标签id
-		if (in_array($tagId, $mTag) == false) {
-			util::failInfo('非法标签');
-		}
-		$openIdList = [$user['openId']];
-		$return = weixinUtil::membersCancelTag($this->merchant, $openIdList, $tagId);
-		if (isset($return['errcode']) == false) {
-			util::failInfo('操作未成功,微信服务器没有返回');
-		}
-		if ($return['errcode'] != 0) {
-			$errCode = $return['errcode'];
-			$errList = weixinUtil::$errCodes;
-			$msg = isset($errList[$errCode]) ? $errList[$errCode] : '';
-			util::failInfo($msg);
-		}
-		xhUserTagService::deleteByCondition(['tagId' => $tagId, 'merchantId' => $this->merchantId, 'userId' => $userId]);
-		util::successInfo('操作成功');
-	}
-	
-	/**
-	 * 给多个用户添加标签
-	 */
-	public function actionBatchAddUserTag()
-	{
-		$get = Yii::$app->request->get();
-		if (isset($get['tagId']) == false || empty($get['tagId'])) {
-			util::failInfo('请选择标签');
-		}
-		if (isset($get['userIdStr']) == false || empty($get['userIdStr'])) {
-			util::failInfo('请选择用户');
-		}
-		$tagId = $get['tagId'];
-		$userIdStr = trim($get['userIdStr']);
-		$userIdList = explode(',', $userIdStr);
-		$userIds = xhUserTagService::getUserIdByTagId($tagId, $this->merchantId);//取标签下的用户
-		$toDoIds = array_diff($userIdList, $userIds);
-		if (empty($toDoIds)) {
-			util::successInfo('全部用户已经设置此标签了~');
-		}
-		$openIdList = [];
-		$toSaveData = [];
-		foreach ($toDoIds as $doKey => $doUserId) {
-			$userInfo = xhUserService::getById($doUserId);
-			if ($userInfo['merchantId'] == $this->merchantId) {
-				$openIdList[] = $userInfo['openId'];
-				$toSaveData[] = ['merchantId' => $this->merchantId, 'tagId' => $tagId, 'userId' => $doUserId];
-			}
-		}
-		$return = weixinUtil::membersBatchTag($this->merchant, $openIdList, $tagId);//批量为用户打标签
-		if (isset($return['errcode']) == false) {
-			util::failInfo('操作失败');
-		}
-		if ($return['errcode'] == 0) {
-			xhUserTagService::batchAdd($toSaveData);
-			util::successInfo('操作成功');
-		}
-		$errCode = $return['errcode'];
-		$errList = weixinUtil::$errCodes;
-		$msg = isset($errList[$errCode]) ? $errList[$errCode] : '操作失败';
-		util::failInfo($msg);
-	}
-	
-	/**
-	 * 发放代金劵
-	 */
-	public function actionGrantCoupon()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$userInfo = xhUserService::getById($userId);
-		$merchantId = isset($userInfo['merchantId']) ? $userInfo['merchantId'] : 0;
-		if ($this->merchantId != $merchantId) {
-			util::failInfo('不是你的用户');
-		}
-		$duration = isset($get['duration']) && !empty($get['duration']) ? $get['duration'] : 60;
-		$amount = isset($get['amount']) && !empty($get['amount']) ? $get['amount'] : 5;
-		$meetAmount = isset($get['meetAmount']) && !empty($get['meetAmount']) ? $get['meetAmount'] : 150;
-		if ($meetAmount <= $amount) {
-			util::failInfo('消费金额要大于代金劵金额');
-		}
-		$get['beginTime'] = isset($get['beginTime']) && !empty($get['beginTime']) ? strtotime($get['beginTime']) : time();
-		$get['deadline'] = $get['beginTime'] + $duration * 86400;
-		$get['amount'] = $amount;
-		$get['meetAmount'] = $meetAmount;
-		$get['createTime'] = date("Y-m-d H:i:s");
-		$get['merchantId'] = $this->merchantId;
-		$get['userId'] = $userId;
-		$get['number'] = 'CO' . stringUtil::buildOrderNo($userId);//代金劵编号
-		xhCouponService::add($get, $userId);
-		$allTM = xhTMessageService::getList($this->merchantId);
-		$shortTempId = 'OPENTM207112032';//收入提醒
-		$tempId = $allTM[$shortTempId];
-		$openId = $userInfo['openId'];
-		$data = ["touser" => $openId, "template_id" => $tempId,
-			"url" => $this->frontUrl . '/center/coupon?account=' . $this->merchant['id'],
-			"data" => [
-				"first" => ["value" => "亲,您获得一张代金劵哦。", "color" => "#173177"],
-				"keyword1" => ["value" => '代金劵', "color" => "#173177"],
-				"keyword2" => ["value" => $amount . '元', "color" => "#173177"],
-				"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
-				"remark" => ["value" => "点击查看详情", "color" => "#173177"]]];
-		weixinUtil::sendTaskInform($data, $this->merchant);
-		util::successInfo();
-	}
-	
-	public function actionTrend()
-	{
-		$fans = xhUserByDayService::getLatestNum($this->merchantId, 29);
-		return $this->render('trend', ['fans' => $fans,]);
-	}
-	
-	/**
-	 * 将支付宝关联上微信号,积分迁移到微信号上
-	 */
-	public function actionRelateUser()
-	{
-		$get = Yii::$app->request->get();
-		$userId = isset($get['userId']) ? $get['userId'] : 0;
-		$alipayId = isset($get['alipayId']) ? $get['alipayId'] : 0;
-		$relation = xhUserAlipayService::getByIds($alipayId, $this->merchantId);
-		if (empty($relation)) {
-			util::failInfo('消费信息不存在');
-		}
-		if (isset($relation['userId']) && !empty($relation['userId'])) {
-			util::failInfo('帐号已经绑定过了');
-		}
-		$user = xhUserService::getById($userId);
-		if ($user['merchantId'] != $this->merchantId) {
-			util::failInfo('不是您的用户');
-		}
-		$openId = $user['openId'];
-		$userName = $user['userName'];
-		if (!empty($user['alipayId'])) {
-			util::failInfo($userName . '已经绑定过支付宝了');
-		}
-		xhUserAlipayService::updateByIds($alipayId, $this->merchantId, ['openId' => $openId, 'userId' => $userId, 'status' => 1]);
-		$merchant = $this->merchant;
-		$merchantExtend = $this->merchantExtend;
-		$merchantId = $this->merchantId;
-		$date = date("Y-m-d H:i:s");
-		$now = time();
-		$userAsset = xhUserAssetService::getByUserId($userId);
-		$capitalTypeList = configDict::getConfig('capitalType');
-		$capitalType = $capitalTypeList['xhUserUnite']['id'];
-		$point = $relation['point'];
-		$addIntegral = $point;
-		$addPoint = $point;
-		$totalExpend = $relation['totalExpend'];
-		$uniteData = [
-			'alipayId' => $alipayId,
-			'merchantId' => $this->merchantId,
-			'userId' => $userId,
-			'point' => $point,
-			'totalExpend' => $totalExpend,
-			'operateId' => $this->adminId,
-			'addTime' => time(),
-			'createTime' => $date,
-		];
-		$order = xhUserUniteService::add($uniteData);
-		$orderId = $order['id'];
-		$payWay = configDict::getConfig('payWay', 'alipay');
-		$userIntegral = stringUtil::calcAdd($userAsset['integral'], $point);
-		$userPoint = stringUtil::calcAdd($userAsset['point'], $point);
-		$totalExpend = stringUtil::calcAdd($userAsset['totalExpend'], $totalExpend);
-		$upAssetData = [];
-		$upAssetData['integral'] = $userIntegral;
-		$upAssetData['point'] = $userPoint;
-		$upAssetData['totalExpend'] = $totalExpend;
-		xhUserAssetService::ioChangeAsset($user, $userAsset, $upAssetData, $merchant, $merchantExtend, $order, $capitalType);//用户资产改变
-		
-		xhUserService::updateById($userId, ['alipayId' => $alipayId]);
-		
-		$integralData = [
-			'userId' => $userId,
-			'userName' => $userName,
-			'merchantId' => $merchantId,
-			'relateId' => (string)$orderId,
-			'integral' => $userIntegral,
-			'num' => $addIntegral,
-			'io' => 1,
-			'payWay' => $payWay,
-			'alipayId' => $alipayId,
-			'event' => '绑定支付宝帐号获得积分',
-			'operatorId' => $userId,
-			'createTime' => $date,
-			'addTime' => $now,
-			'capitalType' => $capitalType,
-		];
-		xhUserIntegralService::add($integralData);//用户兑换型积分流水增加
-		
-		
-		xhMerchantCapitalService::updateByCondition(['alipayId' => $alipayId, 'merchantId' => $this->merchantId], ['userId' => $userId, 'userName' => $userName]);
-		xhOrderService::updateByCondition(['alipayId' => $alipayId, 'merchantId' => $this->merchantId], ['userId' => $userId]);
-		util::successInfo();
-	}
-	
-	/**
-	 * 关联前获取用户信息
-	 */
-	public function actionGetUser()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$user = xhUserService::getById($id);
-		if ($user['subscribe'] == 0) {
-			util::failInfo('没有关注公众号');
-		}
-		if ($user['merchantId'] != $this->merchantId) {
-			util::failInfo('非法操作');
-		}
-		$largeImg = $user['avatar'];
-		$avatarList = xhUserService::getAvatarList($largeImg);
-		$avatar = $avatarList['small'];
-		util::successInfo('操作成功', 'A0001', ['id' => $id, 'avatar' => $avatar, 'userName' => $user['userName']]);
+		$type = isset($get['type']) ? $get['type'] : -1;
+		$where = [];
+		switch ($type) {
+			case 1:
+				//粉丝
+				$where['subscribe'] = 1;
+				break;
+			case 2:
+				//会员
+				$where['isMember'] = 1;
+				break;
+			default:
+		}
+		$list = UserService::getUserList($where);
+		$asset = RetailAssetService::getAsset();
+		$list['asset'] = $asset;
+		util::success($list);
+	}
+	
+	//客户列表 shish 2019.11.30
+	public function actionOaList()
+	{
+		$get = Yii::$app->request->get();
+		$type = isset($get['type']) ? $get['type'] : -1;
+		$merchantId = 12358;
+		$where = ['merchantId' => $merchantId];
+		switch ($type) {
+			case 1:
+				//粉丝
+				$where['subscribe'] = 1;
+				break;
+			case 2:
+				//会员
+				$where['isMember'] = 1;
+				break;
+			default:
+		}
+		$list = UserService::getUserList($where);
+		$merchantAsset = MerchantAssetService::getByMerchantId($merchantId);
+		$list['asset'] = $merchantAsset;
+		util::success($list);
 	}
 	
 }

+ 1 - 1
biz/base/classes/BaseClass.php

@@ -162,5 +162,5 @@ class BaseClass
 		$model = Yii::createObject(['class' => static::$baseFile]);
 		return $model->counters($counters, $condition, $params);
 	}
-	
+
 }

+ 19 - 0
biz/retail/classes/RetailAssetClass.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace biz\retail\classes;
+
+use biz\retail\models\RetailAsset;
+use Yii;
+use biz\base\classes\BaseClass;
+
+class RetailAssetClass extends BaseClass
+{
+
+	public static $baseFile = '\biz\retail\models\RetailAsset';
+
+	public static function getAsset()
+	{
+		return RetailAsset::find()->one();
+	}
+
+}

+ 15 - 0
biz/retail/models/RetailAsset.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\retail\models;
+
+use biz\base\models\Base;
+
+class RetailAsset extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhRetailAsset';
+	}
+
+}

+ 19 - 0
biz/retail/services/RetailAssetService.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace biz\retail\services;
+
+use biz\base\services\BaseService;
+use biz\retail\classes\RetailAssetClass;
+use Yii;
+
+class RetailAssetService extends BaseService
+{
+	
+	public static $baseFile = '\biz\retail\classes\RetailAssetClass';
+
+	public static function getAsset()
+	{
+		return RetailAssetClass::getAsset();
+	}
+	
+}

+ 29 - 0
sql.txt

@@ -1,3 +1,32 @@
+2019.12.21 10:27 平台零售业资产
+ALTER TABLE xhMerchantAsset DROP `totalWeixinFans`;
+ALTER TABLE xhMerchantAsset CHANGE `unClassifyOrder` `unClassOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '待归类订单';
+ALTER TABLE xhMerchantAsset CHANGE `totalUseRecharge` `usedRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额消费数;充值金额消耗数';
+DROP TABLE IF EXISTS `xhRetailAsset`;
+CREATE TABLE IF NOT EXISTS `xhRetailAsset` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+  `totalVisit` INT(11) NOT NULL DEFAULT '0' COMMENT '总访问量',
+  `totalUser` INT(11) NOT NULL DEFAULT '0' COMMENT '总用户;总客户数',
+  `totalMember` INT(11) NOT NULL DEFAULT '0' COMMENT '总会员',
+  `totalFans` INT(11) NOT NULL DEFAULT '0' COMMENT '总粉丝',
+  `totalIntegral` INT(11) NOT NULL DEFAULT '0' COMMENT '总积分',
+  `totalGoods` INT(11) NOT NULL DEFAULT '0' COMMENT '总计商品数量',
+  `totalRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计给用户充值金额',
+  `usedRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额消费数;充值金额消耗数',
+  `totalOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '订单总数,包括所有的',
+  `payOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '付款订单数',
+  `unClassOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '待归类订单',
+  `finishOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '完成订单数',
+  `unPayOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '待付款订单数',
+  `unSendOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '待配送订单数',
+  `sendingOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '配送中订单数',
+  `unNoticeOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '待通知订单数',
+  `cancelOrder` INT(11) NOT NULL DEFAULT '0' COMMENT '已取消订单数',
+  `totalIncome` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
+  `totalExpend` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计消费',
+  `addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间'
+) COMMENT='平台零售业资产';
+
 2019.12.19 15:22 小程序相关
 ALTER TABLE `xhMerchantExtend` ADD miniVersion INT NOT NULL DEFAULT 0 COMMENT '小程序当前版本' AFTER `miniRefreshToken`;
 DROP TABLE IF EXISTS `xhMiniUpgrade`;