Browse Source

积分相关优化

shish 6 năm trước cách đây
mục cha
commit
f76d5f0cbe
3 tập tin đã thay đổi với 17 bổ sung9 xóa
  1. 11 3
      app/admin/controllers/UserController.php
  2. 4 6
      biz/user/classes/UserClass.php
  3. 2 0
      sql.txt

+ 11 - 3
app/admin/controllers/UserController.php

@@ -3,6 +3,7 @@
 namespace admin\controllers;
 
 use biz\admin\services\AdminService;
+use biz\user\services\UserAssetService;
 use biz\user\services\UserService;
 use Yii;
 use common\components\stringUtil;
@@ -17,7 +18,6 @@ class UserController extends BaseController
 	public function actionGetList()
 	{
 		$get = Yii::$app->request->get();
-		
 		//组建where
 		$type = isset($get['type']) ? $get['type'] : 0;
 		$search = isset($get['search']) ? $get['search'] : '';
@@ -87,10 +87,18 @@ class UserController extends BaseController
 		$merchantId = $this->merchantId;
 		$originalInfo['merchantId'] = $merchantId;
 		$originalInfo['mobile'] = $mobile;
+		$originalInfo['realName'] = $post['realName'];
 		$userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
 		$source = $userSource['name'];
-		UserService::replaceUser($originalInfo, $source, $merchantId);
+		$user = UserService::replaceUser($originalInfo, $source, $merchantId);
+
+		$userId = $user['id'];
+		$balance = isset($post['balance']) && is_numeric($post['balance']) ? $post['balance'] : 0;
+		$memberLevel = isset($post['memberLevel']) && is_numeric($post['memberLevel']) ? $post['memberLevel'] : 0;
+		$data = ['balance' => $balance, 'memberLevel' => $memberLevel];
+		UserAssetService::updateByUserId($userId, $data);
+
 		util::ok();
 	}
-	
+
 }

+ 4 - 6
biz/user/classes/UserClass.php

@@ -71,20 +71,21 @@ class UserClass extends BaseClass
 		$data = self::groupUserBaseInfo($list);
 		return current($data);
 	}
-
+	
 	//根据手机号查询客户 shish 2019.12.1
 	public static function getByMobile($mobile)
 	{
 		$merchantId = Yii::$app->params['merchantId'];
 		return self::getByCondition(['merchantId' => $merchantId, 'mobile' => $mobile]);
 	}
-
+	
 	public static function generateUser($getUserInfo, $merchantId)
 	{
 		//替换掉微信不支持的图片
 		$date = date("Y-m-d H:i:s");
 		$time = time();
 		$getUserInfo['userName'] = isset($getUserInfo['userName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getUserInfo['userName']) : '';
+		$getUserInfo['realName'] = isset($getUserInfo['realName']) && !empty($getUserInfo['realName']) ? $getUserInfo['realName'] : '';
 		$getUserInfo['sex'] = isset($getUserInfo['sex']) ? $getUserInfo['sex'] : 0;//未知
 		$getUserInfo['isMember'] = 0;
 		$getUserInfo['identity'] = 0;
@@ -93,10 +94,7 @@ class UserClass extends BaseClass
 		$getUserInfo['merchantId'] = $merchantId;
 		$getUserInfo['status'] = 0;
 		//默认没有完整用户信息
-		$isFull = 0;
-		if (isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl'])) {
-			$isFull = 1;
-		}
+		$isFull = isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl']) ? 1 : 0;
 		$getUserInfo['isFull'] = $isFull;
 		$getUserInfo['createTime'] = $date;
 		$getUserInfo['avatar'] = '';

+ 2 - 0
sql.txt

@@ -1,5 +1,7 @@
 2019.12.1
 ALTER TABLE `xhUser` ADD INDEX mobile(merchantId,`mobile`);
+ALTER TABLE xhUserAsset DROP COLUMN `point`;
+ALTER TABLE xhUserAsset MODIFY `integral` INT NOT NULL DEFAULT 0 COMMENT '积分';
 
 shish 2019.11.30
 ALTER TABLE xhGoods DROP COLUMN `multiPrice`;