chenbiao 2 лет назад
Родитель
Сommit
c7d7baddb6

+ 16 - 0
midjourney/src/main/java/com/yhlxj/dao/mapper/UserBindDetailMapper.java

@@ -0,0 +1,16 @@
+package com.yhlxj.dao.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yhlxj.dao.model.entity.UserBindDetail;
+
+import java.util.List;
+
+/*
+ *项目名: netflix
+ *文件名: UserBindDetailMapper
+ *创建者: JavaZou
+ *创建时间:2022/12/29 13:54
+ */
+public interface UserBindDetailMapper extends BaseMapper<UserBindDetail> {
+	List<String> selectPhones(Integer filter);
+}

+ 78 - 0
midjourney/src/main/java/com/yhlxj/dao/mapper/UserMapper.java

@@ -0,0 +1,78 @@
+package com.yhlxj.dao.mapper;
+
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yhlxj.dao.model.entity.User;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @author chan
+ * @date 2021/10/10 下午3:28
+ */
+public interface UserMapper extends BaseMapper<User> {
+
+    @Update("update user set lottery_time = lottery_time - 1 where id = #{userId} and lottery_time > 0")
+    int decrLotteryTime(@Param("userId") Long userId);
+
+    @Update("update user set lottery_time = lottery_time + 1 where id = #{id}")
+    void incrLotteryTime(@Param("id") Long userId);
+
+    @Update("update user set points = points - #{points} where id = #{id} and points >= #{points} and points > 0")
+    Integer subPoints(@Param("id") Long id, @Param("points") BigDecimal points);
+
+    @Update("update user set points = points + #{addPoints} where id = #{id} and points = #{originalPoints}")
+    Integer updatePoints(@Param("id") Long id, @Param("originalPoints") BigDecimal originalPoints, @Param("addPoints") BigDecimal addPoints);
+
+    @Update("update user set active_points = active_points - #{subPoints} where active_points > 0 and active_points >= #{subPoints} and id = #{userId}")
+    Integer subActivePoints(@Param("userId") Long userId, @Param("subPoints") BigDecimal subPoints);
+
+    @Select("select id from user where nickname like concat(#{nickname},'%')")
+    List<Long> selectListByNickname(String nickname);
+
+    @Update("update user set points = points - #{deductPoints} where id = #{id} and points = #{originalPoints}")
+    Integer subPointsNegative(@Param("id") Long userId, @Param("originalPoints") BigDecimal originalPoints, @Param("deductPoints") BigDecimal deductPoints);
+
+    @Update("update user set balance = balance - #{deduct} where id = #{userId} and balance = #{userBalance} and balance >= #{deduct}")
+    Integer deductBalance(@Param("userId") Long userId, @Param("deduct") BigDecimal deduct, @Param("userBalance") BigDecimal userBalance);
+
+    @Update("update user set balance = balance + #{returnBalance} where id = #{userId} and balance = #{userBalance}")
+    Integer returnBalance(@Param("userId") Long userId, @Param("returnBalance") BigDecimal returnBalance, @Param("userBalance") BigDecimal userBalance);
+
+    @Update("update user set balance = balance + #{addBalance} where id = #{userId} and balance = #{userBalance}")
+    Integer addUserBalance(@Param("userId") Long userId, @Param("userBalance") BigDecimal userBalance, @Param("addBalance") BigDecimal addBalance);
+
+    @Update("update user set balance = balance - #{subBalance} where id = #{userId} and balance = #{userBalance}")
+    Integer deductUserBalance(@Param("userId") Long userId, @Param("userBalance") BigDecimal userBalance, @Param("subBalance") BigDecimal subBalance);
+
+    @Select("select id from user where show_id = #{showId} limit 1")
+    Long getUserIdByShowId(String showId);
+
+    @Select("select cast(ifnull(sum(balance),0)/100 as decimal(11,2)) from user")
+	BigDecimal statisticsRemainBalance();
+
+    @Update("update user set yhs_money = yhs_money + #{addYhsMoney} where id = #{userId} and yhs_money = #{yhsMoney}")
+    Integer addYhsMoney(@Param("userId") Long id, @Param("yhsMoney") BigDecimal yhsMoney, @Param("addYhsMoney") BigDecimal addYhsMoney);
+
+    @Update("update user set yhs_money = yhs_money - #{deductMoney} where id = #{shopUserId} and yhs_money = #{yhsMoney}")
+    Integer subYhShopUserMoney(@Param("shopUserId") Long shopUserId, @Param("yhsMoney") BigDecimal yhsMoney, @Param("deductMoney") BigDecimal deductMoney);
+
+    @Update("update user set yhs_money = yhs_money - #{subMoney} where id = #{shopUserId} and yhs_money >= #{subMoney} and yhs_money > 0")
+    Integer subYhsMoney(@Param("shopUserId") Long shopUserId, @Param("subMoney") BigDecimal subMoney);
+
+	Integer selectUnBindUserNum();
+
+    Integer getLargeNewConsumer(@Param("beginOfDay") DateTime beginOfDay, @Param("largeLimit") String largeLimit);
+
+    @Update("update user set sub_apply_money = sub_apply_money - #{needApplyMoney} where id = #{id} and sub_apply_money >= #{needApplyMoney} and sub_apply_money > 0")
+    Integer suUserSubApplyMoney(@Param("id") Long id, @Param("needApplyMoney") BigDecimal needApplyMoney);
+
+    @Update("update user set sub_apply_money = sub_apply_money + #{addApplyMoney} where id = #{id} and sub_apply_money = #{subApplyMoney}")
+    Integer addDistributeSubMoney(@Param("id") Long id, @Param("subApplyMoney") BigDecimal subApplyMoney, @Param("addApplyMoney") BigDecimal addApplyMoney);
+
+    Integer getNewMaliceUser(DateTime beginOfDay);
+}

+ 128 - 0
midjourney/src/main/java/com/yhlxj/dao/model/entity/User.java

@@ -0,0 +1,128 @@
+package com.yhlxj.dao.model.entity;
+
+/**
+ * @author chan
+ * @date 2024/6/24 17:59
+ */
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.yhlxj.dao.model.BaseEntity;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author chan
+ * @date 2021/10/10 下午2:53
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+public class User extends BaseEntity implements Serializable {
+    /** 手机号;手机号 */
+    private String phone ;
+    /** 手机号登录 */
+    private String loginPhone;
+    /**
+     * 邮箱登录
+     */
+    private String email;
+    /** 昵称;昵称 */
+    private String nickname ;
+    /** 头像;头像 */
+    private String headimgurl ;
+
+    private String showId;
+
+    /** 开放平台唯一id;开放平台唯一id */
+    private String unionid ;
+
+    /**
+     * openid
+     */
+    private String openId;
+
+    /** 省份;省份 */
+    private String province ;
+    /** 国家;国家 */
+    private String country ;
+
+    /**
+     * 城市
+     */
+    private String city ;
+
+    /** 性别;性别 */
+    private Integer sex ;
+
+    private BigDecimal points;
+
+    private BigDecimal activePoints;
+
+    /**
+     * 余额 分
+     */
+    private BigDecimal balance;
+
+    /**
+     * 用户店铺提成金额
+     */
+    private BigDecimal yhsMoney;
+
+    /**
+     * 用户下级渠道提成金额
+     */
+    private BigDecimal subApplyMoney;
+
+    /**
+     * 推广id
+     */
+    private Long popularizeId;
+
+    /**
+     * 用户是否被拉黑 true是
+     */
+    private Boolean isBlack;
+
+    /**
+     * 注册环境
+     * h5:移动端浏览器登录
+     * 微信:公众号h5授权登录
+     * pc:浏览器登录,包括微信扫码在浏览器登录
+     */
+    private String registerEnv;
+
+    /**
+     * 最后登录时间
+     */
+    private Date lastTime;
+
+    @TableField(exist = false)
+    private Long emailUserId;
+
+    @TableField(exist = false)
+    private Long phoneUserId;
+
+    /**
+     * 是否是谷歌授权登录
+     */
+    private Boolean isGoogle;
+
+    @Getter
+    public enum RegisterEnv{
+        wx("公众号h5授权登录"),
+        h5("移动端浏览器登录"),
+        pc("浏览器登录,包括微信扫码在浏览器登录"),
+        ;
+        String desc;
+
+        RegisterEnv(String desc) {
+            this.desc = desc;
+        }
+    }
+}
+

+ 25 - 0
midjourney/src/main/java/com/yhlxj/dao/model/entity/UserBindDetail.java

@@ -0,0 +1,25 @@
+package com.yhlxj.dao.model.entity;
+
+import com.yhlxj.dao.model.BaseEntity;
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: UserBindDetail
+ *创建者: JavaZou
+ *创建时间:2022/12/27 13:39
+ */
+@Getter
+@Setter
+public class UserBindDetail extends BaseEntity {
+	private Long userId;
+
+	private String phone;
+
+	private Long phoneUserId;
+
+	private String email;
+
+	private Long emailUserId;
+}

+ 66 - 0
midjourney/src/main/java/com/yhlxj/service/common/EnvCommonService.java

@@ -0,0 +1,66 @@
+package com.yhlxj.service.common;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/*
+ *项目名: netflix
+ *文件名: EnvCommon
+ *创建者: JavaZou
+ *创建时间:2022/10/26 17:10
+ */
+@Component
+@Getter
+@Setter
+public class EnvCommonService {
+
+	public static final String active = "dev";
+
+	public static final String active_prd = "prd";
+
+	public static final String active_pre = "pre";
+
+	public static String DISTRIBUTE_DEFAULT_URL_PREFIX;
+
+	@Value(value = "${spring.profiles.active}")
+	private String env;
+
+	@Value(value = "${wechat.domain}")
+	private String domain;
+
+	public String getHost() {
+		if (isPreEnv()) {
+			return domain.replaceAll("8081", "8082");
+		}
+		return domain;
+	}
+
+	public String getDomain() {
+		return this.getHost().substring(0, this.getHost().indexOf("80"));
+	}
+
+	public String getDomain2() {
+		return this.getHost().substring(0, this.getHost().indexOf("/80"));
+	}
+
+	public Boolean isPrdEnv() {
+		return EnvCommonService.active_prd.equals(getEnv());
+	}
+
+	public Boolean isPreEnv() {
+		return EnvCommonService.active_pre.equals(getEnv());
+	}
+
+	@PostConstruct
+	public void getDistributeUrl() {
+		DISTRIBUTE_DEFAULT_URL_PREFIX = getDomain();
+		if (!DISTRIBUTE_DEFAULT_URL_PREFIX.endsWith("/")) {
+			DISTRIBUTE_DEFAULT_URL_PREFIX += "/";
+		}
+		DISTRIBUTE_DEFAULT_URL_PREFIX += "%s";
+	}
+}

+ 2 - 0
midjourney/src/main/java/com/yhlxj/service/midjourney/impl/MidJourneyAccountServiceImpl.java

@@ -14,11 +14,13 @@ import com.cyksj.common.util.StringUtil;
 import com.yhlxj.dao.mapper.GoodsDonSkuMapper;
 import com.yhlxj.dao.mapper.GroupsMapper;
 import com.yhlxj.dao.mapper.GroupsRelationMapper;
+import com.yhlxj.dao.mapper.UserMapper;
 import com.yhlxj.dao.mapper.midjourney.MidjourneyAccountMapper;
 import com.yhlxj.dao.mapper.midjourney.MidjourneyUserMapper;
 import com.yhlxj.dao.model.entity.*;
 import com.yhlxj.redis.RedisService;
 import com.yhlxj.service.midjourney.MidjourneyAccountService;
+import com.yhlxj.service.user.UserBindRelationService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;

+ 1 - 0
midjourney/src/main/java/com/yhlxj/service/midjourney/impl/MidjourneyServiceImpl.java

@@ -22,6 +22,7 @@ import com.yhlxj.dao.model.entity.MidjourneyUser;
 import com.yhlxj.dao.model.entity.MidjourneyUserConversation;
 import com.yhlxj.dao.model.response.SubmitResult;
 import com.yhlxj.redis.RedisService;
+import com.yhlxj.service.common.EnvCommonService;
 import com.yhlxj.service.midjourney.MidjourneyAccountService;
 import com.yhlxj.service.midjourney.MidjourneyService;
 import lombok.RequiredArgsConstructor;

+ 19 - 0
midjourney/src/main/java/com/yhlxj/service/user/UserBindRelationService.java

@@ -0,0 +1,19 @@
+package com.yhlxj.service.user;
+
+
+import com.yhlxj.dao.model.entity.User;
+
+import java.util.List;
+
+/*
+ *项目名: netflix
+ *文件名: UserBindRelationService
+ *创建者: JavaZou
+ *创建时间:2023/8/1 15:03
+ */
+public interface UserBindRelationService {
+	/**
+	 * 获取关联用户id集合
+	 */
+	List<Long> getRelationUserIdList(Long userId, User selectUser);
+}

+ 87 - 0
midjourney/src/main/java/com/yhlxj/service/user/impl/UserBindRelationServiceImpl.java

@@ -0,0 +1,87 @@
+package com.yhlxj.service.user.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.enums.GatewayApiCode;
+import com.yhlxj.dao.mapper.UserBindDetailMapper;
+import com.yhlxj.dao.mapper.UserMapper;
+import com.yhlxj.dao.model.entity.User;
+import com.yhlxj.dao.model.entity.UserBindDetail;
+import com.yhlxj.service.user.UserBindRelationService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/*
+ *项目名: netflix
+ *文件名: UserBindRelationServiceImpl
+ *创建者: JavaZou
+ *创建时间:2023/8/1 15:03
+ */
+@Service
+@RequiredArgsConstructor
+public class UserBindRelationServiceImpl implements UserBindRelationService {
+
+	private final UserBindDetailMapper userBindDetailMapper;
+
+	private final UserMapper userMapper;
+
+	@Override
+	public List<Long> getRelationUserIdList(Long userId, User selectUser) {
+		List<Long> userIds = new ArrayList<>();
+		User user = Optional.ofNullable(selectUser).orElse(userMapper.selectById(userId));
+		if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
+
+		UserBindDetail userBindDetail;
+		//微信用户
+		if (StrUtil.isNotBlank(user.getUnionid()) || StrUtil.isNotEmpty(user.getOpenId())) {
+			userIds.add(userId);
+			userBindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
+					.eq(UserBindDetail::getUserId, userId).last("limit 1"));
+			if (userBindDetail == null) {
+				return userIds;
+			}
+			if (userBindDetail.getPhoneUserId() != null) {
+				userIds.add(userBindDetail.getPhoneUserId());
+			}
+			if (userBindDetail.getEmailUserId() != null) {
+				userIds.add(userBindDetail.getEmailUserId());
+			}
+			return userIds;
+		}
+		Long phoneUserId = null;
+		Long emailUserId = null;
+		if (StrUtil.isNotBlank(user.getLoginPhone())) {
+			phoneUserId = user.getId();
+		}
+		if (StrUtil.isNotBlank(user.getEmail())) {
+			emailUserId = user.getId();
+		}
+		//非微信用户
+		userBindDetail = userBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
+				.eq(phoneUserId != null, UserBindDetail::getPhoneUserId, phoneUserId)
+				.eq(emailUserId != null, UserBindDetail::getEmailUserId, emailUserId)
+				.last("limit 1"));
+		if (userBindDetail == null) {
+			userIds.add(userId);
+			return userIds;
+		}
+		phoneUserId = userBindDetail.getPhoneUserId();
+		emailUserId = userBindDetail.getEmailUserId();
+		Long wxUserId = userBindDetail.getUserId();
+		if (wxUserId != null) {
+			userIds.add(wxUserId);
+		}
+		if (phoneUserId != null) {
+			userIds.add(phoneUserId);
+		}
+		if (emailUserId != null) {
+			userIds.add(emailUserId);
+		}
+		return userIds;
+	}
+}