Procházet zdrojové kódy

开发规范与用户

shish před 6 roky
rodič
revize
6fc704a736

+ 2 - 1
app/admin/controllers/BaseController.php

@@ -39,7 +39,8 @@ class BaseController extends PublicController
 	public function beforeAction($action)
 	{
 		//token验证
-		$adminId = jwt::getLoginId();
+		//$adminId = jwt::getLoginId();
+		$adminId = 1;
 		if (empty($adminId)) {
 			$this->validate = false;
 		}

+ 43 - 1
app/admin/controllers/OrderController.php

@@ -39,9 +39,51 @@ class OrderController extends BaseController
 				$where['id'] = $search;
 			}
 		}
-
+		
 		$list = OrderService::getOrderList($where);
 		util::success($list);
 	}
 	
+	//发货管理 shish 2019.11.30
+	public function actionSend()
+	{
+		return [
+			'orderId' => '201911232278449',
+			'price' => '390',
+			'progress' => [
+				[
+					'name' => '下单',
+					'reach' => 1,
+					'time' => '11.20 12:30',
+					'show' => ['hint' => '已下单']
+				],
+				[
+					'name' => '打单',
+					'reach' => 1,
+					'time' => '11.20 12:30',
+					'show' => ['option' => 1, 'info' => ['收花人信息待写上'], 'hint' => '已确认'],
+				
+				],
+				[
+					'name' => '发货',
+					'reach' => 1,
+					'time' => '11.20 12:30',
+					'show' => ['option' => 0, 'info' => ['配送信息待写上'], 'hint' => '已确认'],
+				],
+				[
+					'name' => '送达',
+					'reach' => 1,
+					'time' => '11.20 12:30',
+					'show' => ['hint' => '已送达']
+				],
+				[
+					'name' => '完成',
+					'reach' => 1,
+					'time' => '11.20 12:30',
+					'show' => ['hint' => '订单已完成']
+				],
+			]
+		];
+	}
+	
 }

+ 26 - 1082
app/admin/controllers/UserController.php

@@ -3,6 +3,7 @@
 namespace admin\controllers;
 
 use biz\user\services\UserOldDataService;
+use biz\user\services\UserService;
 use common\models\xhAdmin;
 use common\models\xhStudent;
 use Yii;
@@ -37,1094 +38,37 @@ use common\services\xhUserUniteService;
 use common\services\xhMerchantCapitalService;
 use common\services\xhTMessageService;
 
-class UserController extends BackendController
+class UserController extends BaseController
 {
-	
-	public $sourceImg = [
-		0 => 'source_wx.jpg',
-		1 => 'source_zfb.jpg',
-		2 => 'source_xcx.jpg',
-	];
-	
-	/**
-	 * 学员导入
-	 * @author shish <shish@zhhinc.com>
-	 * @time 2019.5.12
-	 */
-	public function actionImport()
-	{
-		$where = ['merchantId' => $this->merchantId];
-		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 1000;
-		$data = UserOldDataService::getListData('*', $where, $page, $pageSize, 'id desc');
-		return $this->render('import', $data);
-	}
-	
-	public function actionAll()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhUser::find();
-		$query->where(['merchantId' => $this->merchantId]);
-		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 = 30;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->orderBy('visitTime desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$auth = xhMerchantService::isAuth($this->merchantId);
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$merchantAsset = xhMerchantAssetService::getByMerchantId($this->merchantId);
-		$merchantExtend = xhMerchantExtendService::getByMerchantId($this->merchantId);
-		$memberIntegral = xhMerchantExtendService::getGradeList($merchantExtend, 'desc');
-		return $this->render('all', [
-			'merchantTag' => $merchantTag,
-			'models' => $models,
-			'pages' => $paging,
-			'merchant' => $this->merchant,
-			'memberIntegral' => $memberIntegral,
-			'merchantAsset' => $merchantAsset,
-			'merchantExtend' => $merchantExtend,
-		]);
-	}
-	
-	public function actionMember()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhUser::find();
-		$query->where(['merchantId' => $this->merchantId]);
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['mobile' => $content]);
-			} else {
-				$query->andWhere(['like', 'userName', $content]);
-			}
-		}
-		$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('visitTime desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$auth = xhMerchantService::isAuth($this->merchantId);
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$merchantAsset = xhMerchantAssetService::getByMerchantId($this->merchantId);
-		$merchantExtend = xhMerchantExtendService::getByMerchantId($this->merchantId);
-		$memberIntegral = xhMerchantExtendService::getGradeList($merchantExtend, 'desc');
-		return $this->render('member', [
-			'merchantTag' => $merchantTag,
-			'models' => $models,
-			'pages' => $paging,
-			'merchant' => $this->merchant,
-			'memberIntegral' => $memberIntegral,
-			'merchantAsset' => $merchantAsset,
-			'merchantExtend' => $merchantExtend,
-		]);
-	}
-	
-	public function actionFans()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhUser::find();
-		$query->where(['merchantId' => $this->merchantId]);
-		if (isset($get['content']) && !empty($get['content'])) {
-			$content = $get['content'];
-			if (stringUtil::isMobieNumber($content)) {
-				$query->andWhere(['mobile' => $content]);
-			} else {
-				$query->andWhere(['like', 'userName', $content]);
-			}
-		}
-		$query->andWhere(['subscribe' => 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('id desc')->limit($pageSize)->asArray()->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		$auth = xhMerchantService::isAuth($this->merchantId);
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$merchantAsset = xhMerchantAssetService::getByMerchantId($this->merchantId);
-		$merchantExtend = xhMerchantExtendService::getByMerchantId($this->merchantId);
-		$memberIntegral = xhMerchantExtendService::getGradeList($merchantExtend, 'desc');
-		return $this->render('fans', [
-			'merchantTag' => $merchantTag,
-			'models' => $models,
-			'pages' => $paging,
-			'merchant' => $this->merchant,
-			'memberIntegral' => $memberIntegral,
-			'merchantAsset' => $merchantAsset,
-			'merchantExtend' => $merchantExtend,
-		]);
-	}
-	
-	public function actionAlipayUser()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhUserAlipay::find();
-		$query->where(['merchantId' => $this->merchantId]);
-		$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);
-		if (empty($user) || $user['merchantId'] != $this->merchantId) {
-			util::stop('非法访问');
-		}
-		$userAsset = xhUserAssetService::getByUserId($id);
-		//已经查看了此用户,将用户从呼叫列表删除
-		Yii::$app->redis->executeCommand('ZREM', ["merchant_{$this->merchantId}_new_call", "{$id}"]);
-		$class = xhTrainClassService::getAllByCondition(['merchantId' => $this->merchantId]);
-		//取商标的所有用户标签
-		$merchantTag = xhUserTagClassService::getMerchantTag($this->merchantId);
-		$userTag = xhUserTagService::getUserTag($id);
-		$coupon = xhCouponService::getUserCoupon($id);//取代金劵
-		$merchantExtend = xhMerchantExtendService::getByMerchantId($this->merchantId);
-		$memberIntegral = xhMerchantExtendService::getGradeList($merchantExtend, 'desc');
-		$freight = configDict::getConfig('freight');//运费计算
-		$alipayId = 0;
-		$alipayInfo = [];
-		if (!empty($user['alipayId'])) {
-			$alipayId = $user['alipayId'];
-			$alipayInfo = xhUserAlipayService::getByIds($alipayId, $this->merchantId);
-		}
-		return $this->render('detail', [
-			'merchantExtend' => $merchantExtend,
-			'userTag' => $userTag,
-			'coupon' => $coupon,
-			'merchantTag' => $merchantTag,
-			'class' => $class,
-			'user' => $user,
-			'userAsset' => $userAsset,
-			'memberIntegral' => $memberIntegral,
-			'freight' => $freight,
-			'merchant' => $this->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('客户还没有绑定手机号');
-		}
-		$mobile = $user['mobile'];
-		$oldData = UserOldDataService::getByCondition(['merchantId' => $this->merchantId, 'mobile' => $mobile]);
-		if (!empty($oldData)) {
-			util::failInfo('这个客人有老客户记录,无法手动升级');
-		}
-		
-		$confirmPassword = $get['confirmPassword'];
-		if (md5($confirmPassword) != $admin['confirmPassword']) {
-			util::failInfo('确认密码有误');
-		}
-		$grade = xhMerchantExtendService::getGradeList($this->merchantExtend, 'desc');
-		$newLevelPoint = $grade[$memberLevel]['integral'];//升级到当前级别需要的积分数
-		$userAsset = xhUserAssetService::getByUserId($userId);//用户资产
-		if (!empty($userAsset['isMember']) && $userAsset['memberLevel'] >= $memberLevel) {
-			util::failInfo('客户已经达到此级别了');
-		}
-		
-		$connection = Yii::$app->db;//事务处理
-		$transaction = $connection->beginTransaction();
-		try {
-			
-			$addPoint = $newLevelPoint - $userAsset['integral'];
-			$upData['integral'] = $newLevelPoint;//升级后的积分
-			$upData['memberLevel'] = $memberLevel;
-			$upData['isMember'] = 1;
-			xhUserAssetService::updateByUserId($userId, $upData);
-			
-			$old = ['mobile' => $mobile, 'merchantId' => $this->merchantId, 'createTime' => date("Y-m-d H:i:s"), 'integral' => $addPoint, 'status' => 1];
-			$return = UserOldDataService::add($old);
-			if (empty($return)) {
-				util::failInfo('升级失败');
-			}
-			$targetId = $return['id'];
-			$now = time();
-			$date = date("Y-m-d H:i", $now);
-			
-			$integralData = [
-				'userId' => $userId,
-				'userName' => $user['userName'],
-				'merchantId' => $this->merchantId,
-				'relateId' => (string)$targetId,
-				'integral' => $newLevelPoint,
-				'num' => $addPoint,
-				'io' => 1,
-				'payWay' => 4,
-				'alipayId' => '',
-				'event' => '店长操作升级',
-				'operatorId' => $userId,
-				'createTime' => $date,
-				'capitalType' => 0,
-				'addTime' => $now,
-			];
-			xhUserIntegralService::add($integralData);//用户兑换型积分流水增加
-			$transaction->commit();
-		} catch (Exception $e) {
-			$transaction->rollBack();
-			util::failInfo();
-		}
-		
-		$allTM = xhTMessageService::getList($this->merchantId);
-		$openId = $user['openId'];
-		$shortTempId = 'OPENTM205211943';//升级通知
-		if (isset($allTM[$shortTempId])) {
-			$tempId =  $allTM[$shortTempId];
-			$data = [
-				"touser" => $openId, "template_id" => $tempId, "url" => '',
-				"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('访问出错,请联系网站管理员');
-		}
-		$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';
-		if (isset($allTM[$shortTempId])) {
-			$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()
+
+	public function actionGetList()
 	{
 		$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 = xhStudent::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 = xhStudent::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';
-		if (isset($allTM[$shortTempId])) {
-			$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];
+		//组建where
+		$type = isset($get['type']) ? $get['type'] : 0;
+		$search = isset($get['search']) ? $get['search'] : '';
+		$where = ['merchantId' => $this->merchantId];
+		switch($type){
+			case 1:
+				//粉丝
+				$where['subscribe'] = 1;
+				break;
+			case 2:
+				//会员
+				$where['isMember'] = 1;
+				break;
+			default:
+		}
+		if (!empty($search)) {
+			if (stringUtil::isMobieNumber($search)) {
+				$where['mobile'] = $search;
+			} else {
+				$where['userName'] = ['like' => $search];
 			}
 		}
-		$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';//收入提醒
-		if (isset($allTM[$shortTempId])) {
-			$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']]);
-	}
-	
-	public function actionStudent()
-	{
-		$get = Yii::$app->request->get();
-		$query = xhStudent::find();
-		$countQuery = clone $query;
-		$count = $countQuery->count();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		$pageSize = 20;
-		$offset = ($page - 1) * $pageSize;
-		$models = $query->offset($offset)->with('xhUser')->orderBy('visitTime desc')->limit($pageSize)->all();
-		$page = new page($count, $page, $pageSize);
-		$paging = $page->fpage();
-		return $this->render('student', [
-			'models' => $models,
-			'pages' => $paging,
-		]);
-	}
-	
-	public function actionLevel()
-	{
-		$extend = xhMerchantExtendService::getByMerchantId($this->merchantId);
-		$gradeList = xhMerchantExtendService::getGradeList($extend);
-		return $this->render('level', ['extend' => $extend, 'gradeList' => $gradeList]);
-	}
-	
-	/**
-	 * 导入老客户
-	 */
-	public function actionImportOldUser()
-	{
-		$request = Yii::$app->request->get();
-		$mobile = $request['mobile'];
-		$integral = $request['integral'];
-		$balance = $request['balance'];
-		$userName = isset($request['userName']) && !empty($request['userName']) ? $request['userName'] : $mobile;
-		$confirmPassword = $request['confirmPassword'];
-		$confirmMobile = $request['confirmMobile'];
-		if ($mobile != $confirmMobile) {
-			util::failInfo('二次手机号不致');
-		}
-		if (stringUtil::isMobieNumber($mobile) == false) {
-			util::failInfo('手机号填写错误');
-		}
-		$adminId = $this->adminId;
-		$admin = xhAdminService::getById($adminId);
-		$confirmPassword = $request['confirmPassword'];
-		if (md5($confirmPassword) != $admin['confirmPassword']) {
-			util::failInfo('确认密码有误');
-		}
-		if ($integral == $balance && $balance == 0) {
-			util::failInfo('请填写积分或余额');
-		}
-		$return = UserOldDataService::couldAdd($this->merchantId, $mobile);
-		if ($return['status'] == false) {
-			util::failInfo($return['msg']);
-		}
-		$integral = isset($integral) && $integral > 0 ? $integral : 0;
-		$balance = isset($balance) && $balance > 0 ? $balance : 0;
-		$data = ['mobile' => $mobile, 'integral' => $integral, 'balance' => $balance, 'createTime' => date("Y-m-d H:i:s"), 'userName' => $userName, 'merchantId' => $this->merchantId];
-		UserOldDataService::add($data);
-		util::successInfo();
-	}
-	
-	public function actionBindMobile()
-	{
-		$userId = Yii::$app->request->get('userId');
-		$mobile = Yii::$app->request->get('mobile');
-		$info = xhUserService::getById($userId);
-		if ($info['merchantId'] != $this->merchantId) {
-			util::failInfo();
-		}
-		if ($info['subscribe'] != 1) {
-			util::failInfo('客户还没有关注公众号,无法绑定手机号');
-		}
-		if (!empty($info['mobile'])) {
-			util::failInfo('您已经有绑定手机号了');
-		}
-		$status = xhUserService::mobileNotUsed($mobile, $this->merchantId);
-		if ($status == false) {
-			util::failInfo('手机号已经被使用');
-		}
-		xhUserService::updateById($userId, ['mobile' => $mobile, 'isMember' => 1]);
-		xhUserAssetService::updateByUserId($userId, ['isMember' => 1]);
-		//绑定手机时判断是否有老客户资料
-		UserOldDataService::import($this->merchantId, $userId, $mobile);
-		util::successInfo('操作成功');
+		$list = UserService::getUserList($where);
+		util::success($list);
 	}
 	
 }

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

@@ -18,8 +18,14 @@ class BaseClass
 	}
 
 	//分页查询 shish 2019.9.21
-	public static function getList($select, $where, $page, $pageSize, $order = '', $with = '')
+	public static function getList($select, $where, $order = '', $with = '')
 	{
+		$get = Yii::$app->request->get();
+		$page = isset($get['page']) ? $get['page'] : 1;
+		Yii::$app->params['page'] = $page;
+		//pageSize 已经在common/params.php定义
+		$pageSize = isset($get['pageSize']) && !empty($get['pageSize']) ? $get['pageSize'] : Yii::$app->params['pageSize'];
+
 		$model = Yii::createObject(['class' => static::$baseFile]);
 		$return = $model->getList($select, $where, $page, $pageSize, $order, $with);
 		return $return;

+ 2 - 7
biz/base/services/BaseService.php

@@ -19,15 +19,10 @@ class BaseService
 	}
 	
 	//分页查询 shish 2019.9.21
-	public static function getList($select, $where, $order = '', $with = '', $pageSize = 0)
+	public static function getList($select, $where, $order = '', $with = '')
 	{
 		$class = static::$baseFile;
-		$get = Yii::$app->request->get();
-		$page = isset($get['page']) ? $get['page'] : 1;
-		Yii::$app->params['page'] = $page;
-		//pageSize 已经在common/params.php定义
-		$pageSize = isset($get['pageSize']) && !empty($get['pageSize']) ? $get['pageSize'] : Yii::$app->params['pageSize'];
-		return $class::getList($select, $where, $page, $pageSize, $order, $with);
+		return $class::getList($select, $where, $order, $with);
 	}
 	
 	public static function add($data, $returnObject = false)

+ 17 - 2
biz/user/classes/UserClass.php

@@ -15,8 +15,9 @@ use biz\base\classes\BaseClass;
 
 class UserClass extends BaseClass
 {
-	
+
 	public static $baseFile = '\biz\user\models\User';
+
 	//用户和收入的来源
 	public static $sourceType = [
 		2 => '朋友圈',
@@ -24,7 +25,21 @@ class UserClass extends BaseClass
 		0 => '公众号',
 		3 => '淘宝',
 	];
-	
+
+	//用户来源分类
+	public static $userSource = [
+		0 => ['name' => 'official', 'title' => '公众号'],
+		1 => ['name' => 'alipay', 'title' => '支付宝'],
+		2 => ['name' => 'mini', 'title' => '小程序'],
+	];
+
+	//用户来源分类ID
+	public static $userSourceId = [
+		'official' => ['id' => 0, 'name' => 'official'],
+		'alipay' => ['id' => 1, 'name' => 'alipay'],
+		'mini' => ['id' => 2, 'name' => 'mini'],
+	];
+
 	public static function generateUser($getUserInfo, $merchantId)
 	{
 		//替换掉微信不支持的图片

+ 5 - 0
biz/user/services/UserAssetService.php

@@ -16,6 +16,11 @@ class UserAssetService extends BaseService
 		return $class::getByUserId($userId);
 	}
 	
+	public static function getByUserIds($ids)
+	{
+		self::getAllByCondition([''])
+	}
+	
 	public static function updateByUserId($userId, $data)
 	{
 		self::updateByCondition(['userId' => $userId], $data);

+ 30 - 22
biz/user/services/UserService.php

@@ -2,40 +2,48 @@
 
 namespace biz\user\services;
 
-
 use biz\base\services\BaseService;
 use biz\merchant\classes\MerchantAssetClass;
 use biz\merchant\services\MerchantAssetService;
+use biz\user\classes\UserClass;
 use common\components\validate;
-use common\components\util;
-
 use common\services\xhMerchantService;
-use common\services\xhUserService;
 use Yii;
-use linslin\yii2\curl;
-use common\components\stringUtil;
-use common\components\configDict;
 use common\components\weixinUtil;
-use common\models\xhUser;
 
 class UserService extends BaseService
 {
 	
 	public static $baseFile = '\biz\user\classes\UserClass';
 	
-	//用户来源分类
-	public static $userSource = [
-		0 => ['name' => 'official', 'title' => '公众号'],
-		1 => ['name' => 'alipay', 'title' => '支付宝'],
-		2 => ['name' => 'mini', 'title' => '小程序'],
-	];
-	
-	//用户来源分类ID
-	public static $userSourceId = [
-		'official' => ['id' => 0, 'name' => 'official'],
-		'alipay' => ['id' => 1, 'name' => 'alipay'],
-		'mini' => ['id' => 2, 'name' => 'mini'],
-	];
+	//获取客户列表 shish 2019.11.30
+	public static function getUserList($where)
+	{
+		$data = UserClass::getList('*', $where, 'visitTime DESC');
+		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+		if (empty($list)) {
+			return $data;
+		}
+		$imgUrl = Yii::$app->params['imgUrl'];
+		if (isset($list) && !empty($list)) {
+
+			//取客户资产
+			$ids = array_column($list, 'id');
+			UserAssetService::getByIds()
+
+			foreach ($list as $key => $val) {
+				//访问时间
+				$visitTime = date("m-d H:i", $val['visitTime']);
+				if (date("m-d") == date("m-d", $val['visitTime'])) {
+					$visitTime = '今天 ' . date("H:i", $val['visitTime']);
+				}
+				$list[$key]['visitTime'] = $visitTime;
+				$list[$key]['avatar'] = $imgUrl . $val['avatar'];
+			}
+		}
+		$data['list'] = $list;
+		return $data;
+	}
 	
 	/**
 	 * 创建以及更新用户
@@ -263,5 +271,5 @@ class UserService extends BaseService
 		}
 		return $info;
 	}
-
+	
 }

+ 115 - 0
开发规范.md

@@ -0,0 +1,115 @@
+开发规范
+=========================
+
+花卉宝
+-------------------
+
+##### 常用的增删改查
+````
+service和class层都有以下通用方法可以使用
+
+增
+::add($data)
+::batchAdd($data)
+
+删
+::deleteById($id)
+::deleteByCondition($condition)
+
+改
+::updateById($id,$data)
+::updateByIds($ids,$data)
+::updateByCondition($condition,$data)
+
+查
+::getById($id,true)
+::getByCondition($condition,true);
+::getAllByCondition($condition,$order,$field,$indexBy)
+::getByIds($ids,$order,$indexBy)
+::getCount($condition)
+
+::getList()
+::getListData()
+::getAllList()
+condition支持查询条件包括
+'name'=>'john'
+'id>'=>3
+'id<'=>10
+'id'=>['in',[10,11,12]
+'age'=>['between',[20,30]
+'name'=>['like','Jack']
+````
+
+##### 命名规范
+
+######
+我们的数据库表和文件都使用驼峰式的。
+
+对于助手类文件,在TP里命名为:Helper。
+我们这里诸多技术沿用新浪,命名规范也就沿用。
+助手和工具类文件我们命名以until为结尾。通用的为util,数组类为arrayUtil,字符处理的为stringUtil,以此类推。
+
+##### 调试方法
+
+######
+Yii自带debug,它对每一次的请求,参数,插入数据库都有记录,很好进行跟踪。
+在域名尾巴增加个debug即可使用,如:http://a.huaml.com/debug
+
+
+
+##### 三级分层设计
+######
+为了保证整个技术设计能适应未来业务的发展,并且尽可能的提高代码复用,减少重复工作。
+
+我们的项目结构分为:app和biz层
+
+app主要是对外提供http接口
+biz主要提供service接口给app层调用
+
+biz层分为:service class model三层
+
+各层的调用关系如下:
+app层可以调用biz层的service
+service可以调用class
+同级之间可以互相调用,如user模块的serice可以调用order模块的service,class同理
+但底层不能调用上层,class不能调用serivce
+
+我们平时大量的工作,在做重复的增删改查代码开发,为减少这块无谓的浪费,我们在service层封装了常用的增删改查操作。
+具体可查看【常用的增删改查】
+如果你在工作中也总结出一些可以复用的方法,也可以封装进去。
+
+尽量保证service层的任何操作都有经过class层。
+未来我们要统一增加缓存,或者service层很多地方都有创建用户的方法,当我们要增加新东西时,只要在class增加一次就好
+这就是为什么我们封装的service层的增删改查,都有经过class层的增删改查。百川奔流终要归海。
+
+前期开发的时候你会发现class有点多余,但业务越来越复杂时,你就会发现class层的价值
+
+因为分层比较深,对一些各层都要使用到的参数,我们不必一直往下传。
+只要在最顶层设置一个全局的变量,底下各层各方法都可以调用。
+````
+Yii::$app->params['userId'] = 1;
+Yii::$app->params['merchantId'] = 12358;
+````
+
+##### 注释规范
+````
+开发功能,修改BUG,在别人代码上增加代码,都需要写明事项、修改人和时间。
+如:查询方法的优化 shish 2019.9.21
+````
+
+##### 统一输入输出格式
+
+````
+正确与错误输出:
+//错误状态输出
+util::fail('名称未填写');
+//只输出成功状态
+util::ok();
+//输出成功状态并带数据
+util::success(['userId'=>1],'操作成功');
+
+分页:
+page 第几页
+pageSize 每页显示数
+count 总数
+````