zoujiajian 1 jaar geleden
bovenliggende
commit
13ed6033b8

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/UserWhoami.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.dto;
 
+import com.ejlchina.searcher.bean.DbIgnore;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.experimental.Accessors;
@@ -51,4 +52,10 @@ public class UserWhoami implements Serializable {
      * 是否是未下单的用户
      */
     private Boolean isPay;
+
+    /**
+     * 是否渠道配置了优惠码
+     */
+    @DbIgnore
+    private Boolean ccCode;
 }

+ 0 - 7
netflix-dao/src/main/java/com/cyksj/model/entity/User.java

@@ -112,13 +112,6 @@ public class User extends BaseEntity implements Serializable{
     @DbIgnore
     private Long phoneUserId;
 
-    /**
-     * 是否渠道配置了优惠码
-     */
-    @TableField(exist = false)
-    @DbIgnore
-    private Boolean ccCode = false;
-
     /**
      * 是否是谷歌授权登录
      */

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/user/UserService.java

@@ -22,7 +22,7 @@ public interface UserService extends IService<User> {
 
 	User saveAuth(GzhOAuth2UserInfo userinfo, AuthRedirect re, User.RegisterEnv registerEnv) throws Exception;
 
-    UserWhoami whoami(long userId);
+	UserWhoami whoami(long userId, Boolean ccCode);
 
     User getSyncUser(String openId, String unionId, WxSyncLog wxSyncLog);
 

+ 21 - 17
netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java

@@ -30,6 +30,7 @@ import com.cyksj.mapper.station.CollegeStudentStationUserRelateMapper;
 import com.cyksj.mapper.vip.VipUserMapper;
 import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
+import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.request.LoginReq;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
@@ -251,14 +252,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 	}
 
 	@Override
-    public UserWhoami whoami(long userId) {
-	    User user = this.getById(userId);
-	    Assert.notNull(user, "业务处理失败,请联系客服");
-	    UserWhoami userWhoami = new UserWhoami();
-	    if (StrUtil.isEmpty(user.getShowId())) {
-		    user.setShowId(userCommonService.getUserShowId(userId));
-	    }
-	    BeanUtil.copyProperties(user, userWhoami);
+	public UserWhoami whoami(long userId, Boolean ccCode) {
+		User user = this.getById(userId);
+		Assert.notNull(user, "业务处理失败,请联系客服");
+		UserWhoami userWhoami = new UserWhoami();
+		if (StrUtil.isEmpty(user.getShowId())) {
+			user.setShowId(userCommonService.getUserShowId(userId));
+		}
+		BeanUtil.copyProperties(user, userWhoami);
 
 		UserBindDetail bindPhone = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
 				.eq(StrUtil.isNotEmpty(user.getUnionid()), UserBindDetail::getUserId, userId)
@@ -269,13 +270,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 			userWhoami.setBindPhone(bindPhone.getPhone());
 			userWhoami.setBindEmail(bindPhone.getEmail());
 		}
-	    Integer type = 3;
-	    if (StrUtil.isNotBlank(user.getLoginPhone())) {
-		    type = 1;
-	    } else if (StrUtil.isNotBlank(user.getEmail())) {
-		    type = 2;
-	    }
-	    userWhoami.setType(type);
+		Integer type = 3;
+		if (StrUtil.isNotBlank(user.getLoginPhone())) {
+			type = 1;
+		} else if (StrUtil.isNotBlank(user.getEmail())) {
+			type = 2;
+		}
+		userWhoami.setType(type);
 		//是否加过企业微信
 		String unionId = user.getUnionid();
 		if (StrUtil.isEmpty(unionId)) {
@@ -304,8 +305,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 				.in(OrderDon::getUserId, userIdList)
 				.notIn(OrderDon::getStatus, Constant.noOrderStatus));
 		userWhoami.setIsPay(selectCount > 0);
+		if (ccCode != null) {
+			Number number = beanSearcher.searchCount(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getUserId, userId).field(GroupsRelationView::getAqType, 2).field(GroupsRelationView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).build());
+			userWhoami.setCcCode(number.intValue() > 0);
+		}
 		return userWhoami;
-    }
+	}
 
     @Override
     public User getSyncUser(String openId, String unionId, WxSyncLog wxSyncLog) {
@@ -593,7 +598,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 						if (!claudeCodeService.checkClaudeCodeUser(user.getId())) {
 							//发送claude code 体验卡
 							groupRelationFrontService.getTrialTicketByUserIdAndGoodsId(user.getId(), Constant.DISTRIBUTE_CLAUDE_CODE_TRIAL_SKU_ID, 2);
-							user.setCcCode(Boolean.TRUE);
 						}
 					}
 				} else {

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/user/UserController.java

@@ -106,10 +106,10 @@ public class UserController {
     private final UserGalaxyCoinRecordMapper userGalaxyCoinRecordMapper;
 
     @GetMapping(value = "/wx/whoami")
-    public Result<UserWhoami> whoami() {
+    public Result<UserWhoami> whoami(Boolean ccCode) {
         long userId = StpUserUtil.getLoginIdAsLong();
 
-        UserWhoami userWhoami = userService.whoami(userId);
+        UserWhoami userWhoami = userService.whoami(userId, ccCode);
 
         return GatewayResponse.SUCCESS.newBuilder().toResult(userWhoami);
     }