|
|
@@ -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);
|
|
|
}
|
|
|
|
|
|
}
|