等级晋升条件可配置

master
胡锐 3 weeks ago
parent 686c24790f
commit 39e77f116c
  1. 5
      bweb/src/main/java/com/hfkj/controller/BsUserController.java
  2. 15
      cweb/src/main/java/com/hfkj/controller/UserController.java
  3. 2
      service/src/main/java/com/hfkj/common/QRCodeGenerator.java
  4. 141
      service/src/main/java/com/hfkj/dao/BsUserPlatformAuthorizeMapper.java
  5. 7
      service/src/main/java/com/hfkj/dao/BsUserPlatformAuthorizeMapperExt.java
  6. 388
      service/src/main/java/com/hfkj/dao/BsUserPlatformAuthorizeSqlProvider.java
  7. 296
      service/src/main/java/com/hfkj/entity/BsUserPlatformAuthorize.java
  8. 1273
      service/src/main/java/com/hfkj/entity/BsUserPlatformAuthorizeExample.java
  9. 26
      service/src/main/java/com/hfkj/service/user/BsUserPlatformAuthorizeService.java
  10. 162
      service/src/main/java/com/hfkj/service/user/impl/BsUserContributeServiceImpl.java
  11. 56
      service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java
  12. 38
      service/src/main/java/com/hfkj/service/user/impl/BsUserPlatformAuthorizeServiceImpl.java
  13. 17
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  14. 29
      service/src/main/java/com/hfkj/sysenum/user/UserAuthorizePlatformEnum.java

@ -12,6 +12,7 @@ import com.hfkj.entity.BsUserParentRel;
import com.hfkj.model.ResponseData;
import com.hfkj.service.user.BsUserGradeService;
import com.hfkj.service.user.BsUserParentRelService;
import com.hfkj.service.user.BsUserPlatformAuthorizeService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.sysenum.user.UserGradeEnum;
import io.swagger.annotations.Api;
@ -42,6 +43,8 @@ public class BsUserController {
private BsUserGradeService userGradeService;
@Resource
private BsUserParentRelService userParentRelService;
@Resource
private BsUserPlatformAuthorizeService userPlatformAuthorizeService;
@RequestMapping(value="/gradeAdjust",method = RequestMethod.POST)
@ResponseBody
@ -110,7 +113,7 @@ public class BsUserController {
Map<String,Object> param = new HashMap<>();
param.put("user", user);
// 授权
param.put("platform_authorize", new ArrayList<>());
param.put("platform_authorize", userPlatformAuthorizeService.getUserAuth(userId));
// 邀请人
param.put("inviteUser", user.getInviteUserId()!=null?userService.getUser(user.getInviteUserId()):null);
// 贡献关系

@ -10,10 +10,13 @@ import com.hfkj.common.utils.*;
import com.hfkj.config.CommonSysConst;
import com.hfkj.config.SysConfig;
import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserPlatformAuthorize;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.BsUserPlatformAuthorizeService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.sysenum.user.UserAuthorizePlatformEnum;
import com.hfkj.sysenum.user.UserLoginType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -47,6 +50,8 @@ public class UserController {
@Resource
private BsUserService userService;
@Resource
private BsUserPlatformAuthorizeService userPlatformAuthorizeService;
@Resource
private RedisUtil redisUtil;
@Autowired
private UserCenter userCenter;
@ -366,6 +371,16 @@ public class UserController {
user.setWechatUnionid(userinfo.getString("unionid"));
userService.updateInfo(user);
// 授权信息
BsUserPlatformAuthorize authorize = new BsUserPlatformAuthorize();
authorize.setUserId(user.getId());
authorize.setPlatformCode(UserAuthorizePlatformEnum.type2.getType());
authorize.setPlatformName(UserAuthorizePlatformEnum.type2.getName());
authorize.setAvatar(userinfo.getString("headimgurl"));
authorize.setNickName(userinfo.getString("nickname"));
authorize.setOpenId(user.getWechatOpenId());
userPlatformAuthorizeService.edit(authorize);
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);

@ -63,7 +63,7 @@ public class QRCodeGenerator {
public static String overlapImage(String path ,String number) {
try {
// 创建BufferedImage对象
int width = 100;
int width = 115;
int height = 45;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

@ -0,0 +1,141 @@
package com.hfkj.dao;
import com.hfkj.entity.BsUserPlatformAuthorize;
import com.hfkj.entity.BsUserPlatformAuthorizeExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface BsUserPlatformAuthorizeMapper extends BsUserPlatformAuthorizeMapperExt {
@SelectProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="countByExample")
long countByExample(BsUserPlatformAuthorizeExample example);
@DeleteProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="deleteByExample")
int deleteByExample(BsUserPlatformAuthorizeExample example);
@Delete({
"delete from bs_user_platform_authorize",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into bs_user_platform_authorize (user_id, platform_code, ",
"platform_name, open_id, ",
"avatar, nick_name, ",
"gender, province, city, ",
"`status`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{userId,jdbcType=BIGINT}, #{platformCode,jdbcType=INTEGER}, ",
"#{platformName,jdbcType=VARCHAR}, #{openId,jdbcType=VARCHAR}, ",
"#{avatar,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, ",
"#{gender,jdbcType=BIT}, #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsUserPlatformAuthorize record);
@InsertProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(BsUserPlatformAuthorize record);
@SelectProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="platform_code", property="platformCode", jdbcType=JdbcType.INTEGER),
@Result(column="platform_name", property="platformName", jdbcType=JdbcType.VARCHAR),
@Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR),
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR),
@Result(column="nick_name", property="nickName", jdbcType=JdbcType.VARCHAR),
@Result(column="gender", property="gender", jdbcType=JdbcType.BIT),
@Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
@Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<BsUserPlatformAuthorize> selectByExample(BsUserPlatformAuthorizeExample example);
@Select({
"select",
"id, user_id, platform_code, platform_name, open_id, avatar, nick_name, gender, ",
"province, city, `status`, create_time, update_time, ext_1, ext_2, ext_3",
"from bs_user_platform_authorize",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="platform_code", property="platformCode", jdbcType=JdbcType.INTEGER),
@Result(column="platform_name", property="platformName", jdbcType=JdbcType.VARCHAR),
@Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR),
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR),
@Result(column="nick_name", property="nickName", jdbcType=JdbcType.VARCHAR),
@Result(column="gender", property="gender", jdbcType=JdbcType.BIT),
@Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
@Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
BsUserPlatformAuthorize selectByPrimaryKey(Long id);
@UpdateProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") BsUserPlatformAuthorize record, @Param("example") BsUserPlatformAuthorizeExample example);
@UpdateProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") BsUserPlatformAuthorize record, @Param("example") BsUserPlatformAuthorizeExample example);
@UpdateProvider(type=BsUserPlatformAuthorizeSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(BsUserPlatformAuthorize record);
@Update({
"update bs_user_platform_authorize",
"set user_id = #{userId,jdbcType=BIGINT},",
"platform_code = #{platformCode,jdbcType=INTEGER},",
"platform_name = #{platformName,jdbcType=VARCHAR},",
"open_id = #{openId,jdbcType=VARCHAR},",
"avatar = #{avatar,jdbcType=VARCHAR},",
"nick_name = #{nickName,jdbcType=VARCHAR},",
"gender = #{gender,jdbcType=BIT},",
"province = #{province,jdbcType=VARCHAR},",
"city = #{city,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP},",
"ext_1 = #{ext1,jdbcType=VARCHAR},",
"ext_2 = #{ext2,jdbcType=VARCHAR},",
"ext_3 = #{ext3,jdbcType=VARCHAR}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(BsUserPlatformAuthorize record);
}

@ -0,0 +1,7 @@
package com.hfkj.dao;
/**
* mapper扩展类
*/
public interface BsUserPlatformAuthorizeMapperExt {
}

@ -0,0 +1,388 @@
package com.hfkj.dao;
import com.hfkj.entity.BsUserPlatformAuthorize;
import com.hfkj.entity.BsUserPlatformAuthorizeExample.Criteria;
import com.hfkj.entity.BsUserPlatformAuthorizeExample.Criterion;
import com.hfkj.entity.BsUserPlatformAuthorizeExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class BsUserPlatformAuthorizeSqlProvider {
public String countByExample(BsUserPlatformAuthorizeExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("bs_user_platform_authorize");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(BsUserPlatformAuthorizeExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("bs_user_platform_authorize");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(BsUserPlatformAuthorize record) {
SQL sql = new SQL();
sql.INSERT_INTO("bs_user_platform_authorize");
if (record.getUserId() != null) {
sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}");
}
if (record.getPlatformCode() != null) {
sql.VALUES("platform_code", "#{platformCode,jdbcType=INTEGER}");
}
if (record.getPlatformName() != null) {
sql.VALUES("platform_name", "#{platformName,jdbcType=VARCHAR}");
}
if (record.getOpenId() != null) {
sql.VALUES("open_id", "#{openId,jdbcType=VARCHAR}");
}
if (record.getAvatar() != null) {
sql.VALUES("avatar", "#{avatar,jdbcType=VARCHAR}");
}
if (record.getNickName() != null) {
sql.VALUES("nick_name", "#{nickName,jdbcType=VARCHAR}");
}
if (record.getGender() != null) {
sql.VALUES("gender", "#{gender,jdbcType=BIT}");
}
if (record.getProvince() != null) {
sql.VALUES("province", "#{province,jdbcType=VARCHAR}");
}
if (record.getCity() != null) {
sql.VALUES("city", "#{city,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}");
}
return sql.toString();
}
public String selectByExample(BsUserPlatformAuthorizeExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("user_id");
sql.SELECT("platform_code");
sql.SELECT("platform_name");
sql.SELECT("open_id");
sql.SELECT("avatar");
sql.SELECT("nick_name");
sql.SELECT("gender");
sql.SELECT("province");
sql.SELECT("city");
sql.SELECT("`status`");
sql.SELECT("create_time");
sql.SELECT("update_time");
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
sql.FROM("bs_user_platform_authorize");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
BsUserPlatformAuthorize record = (BsUserPlatformAuthorize) parameter.get("record");
BsUserPlatformAuthorizeExample example = (BsUserPlatformAuthorizeExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("bs_user_platform_authorize");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getUserId() != null) {
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
}
if (record.getPlatformCode() != null) {
sql.SET("platform_code = #{record.platformCode,jdbcType=INTEGER}");
}
if (record.getPlatformName() != null) {
sql.SET("platform_name = #{record.platformName,jdbcType=VARCHAR}");
}
if (record.getOpenId() != null) {
sql.SET("open_id = #{record.openId,jdbcType=VARCHAR}");
}
if (record.getAvatar() != null) {
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}");
}
if (record.getNickName() != null) {
sql.SET("nick_name = #{record.nickName,jdbcType=VARCHAR}");
}
if (record.getGender() != null) {
sql.SET("gender = #{record.gender,jdbcType=BIT}");
}
if (record.getProvince() != null) {
sql.SET("province = #{record.province,jdbcType=VARCHAR}");
}
if (record.getCity() != null) {
sql.SET("city = #{record.city,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("bs_user_platform_authorize");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
sql.SET("platform_code = #{record.platformCode,jdbcType=INTEGER}");
sql.SET("platform_name = #{record.platformName,jdbcType=VARCHAR}");
sql.SET("open_id = #{record.openId,jdbcType=VARCHAR}");
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}");
sql.SET("nick_name = #{record.nickName,jdbcType=VARCHAR}");
sql.SET("gender = #{record.gender,jdbcType=BIT}");
sql.SET("province = #{record.province,jdbcType=VARCHAR}");
sql.SET("city = #{record.city,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
BsUserPlatformAuthorizeExample example = (BsUserPlatformAuthorizeExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(BsUserPlatformAuthorize record) {
SQL sql = new SQL();
sql.UPDATE("bs_user_platform_authorize");
if (record.getUserId() != null) {
sql.SET("user_id = #{userId,jdbcType=BIGINT}");
}
if (record.getPlatformCode() != null) {
sql.SET("platform_code = #{platformCode,jdbcType=INTEGER}");
}
if (record.getPlatformName() != null) {
sql.SET("platform_name = #{platformName,jdbcType=VARCHAR}");
}
if (record.getOpenId() != null) {
sql.SET("open_id = #{openId,jdbcType=VARCHAR}");
}
if (record.getAvatar() != null) {
sql.SET("avatar = #{avatar,jdbcType=VARCHAR}");
}
if (record.getNickName() != null) {
sql.SET("nick_name = #{nickName,jdbcType=VARCHAR}");
}
if (record.getGender() != null) {
sql.SET("gender = #{gender,jdbcType=BIT}");
}
if (record.getProvince() != null) {
sql.SET("province = #{province,jdbcType=VARCHAR}");
}
if (record.getCity() != null) {
sql.SET("city = #{city,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, BsUserPlatformAuthorizeExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,296 @@
package com.hfkj.entity;
import java.io.Serializable;
import java.util.Date;
/**
* bs_user_platform_authorize
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class BsUserPlatformAuthorize implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 平台代码
*/
private Integer platformCode;
/**
* 平台名称
*/
private String platformName;
/**
* 平台open_id
*/
private String openId;
/**
* 头像
*/
private String avatar;
/**
* 昵称
*/
private String nickName;
/**
* 性别 0 1
*/
private Boolean gender;
/**
*
*/
private String province;
/**
*
*/
private String city;
/**
* 状态 0删除 1正常
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private String ext1;
private String ext2;
private String ext3;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Integer getPlatformCode() {
return platformCode;
}
public void setPlatformCode(Integer platformCode) {
this.platformCode = platformCode;
}
public String getPlatformName() {
return platformName;
}
public void setPlatformName(String platformName) {
this.platformName = platformName;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public Boolean getGender() {
return gender;
}
public void setGender(Boolean gender) {
this.gender = gender;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
BsUserPlatformAuthorize other = (BsUserPlatformAuthorize) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getPlatformCode() == null ? other.getPlatformCode() == null : this.getPlatformCode().equals(other.getPlatformCode()))
&& (this.getPlatformName() == null ? other.getPlatformName() == null : this.getPlatformName().equals(other.getPlatformName()))
&& (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName()))
&& (this.getGender() == null ? other.getGender() == null : this.getGender().equals(other.getGender()))
&& (this.getProvince() == null ? other.getProvince() == null : this.getProvince().equals(other.getProvince()))
&& (this.getCity() == null ? other.getCity() == null : this.getCity().equals(other.getCity()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getPlatformCode() == null) ? 0 : getPlatformCode().hashCode());
result = prime * result + ((getPlatformName() == null) ? 0 : getPlatformName().hashCode());
result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode());
result = prime * result + ((getGender() == null) ? 0 : getGender().hashCode());
result = prime * result + ((getProvince() == null) ? 0 : getProvince().hashCode());
result = prime * result + ((getCity() == null) ? 0 : getCity().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", platformCode=").append(platformCode);
sb.append(", platformName=").append(platformName);
sb.append(", openId=").append(openId);
sb.append(", avatar=").append(avatar);
sb.append(", nickName=").append(nickName);
sb.append(", gender=").append(gender);
sb.append(", province=").append(province);
sb.append(", city=").append(city);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,26 @@
package com.hfkj.service.user;
import com.hfkj.entity.BsUserPlatformAuthorize;
import java.util.List;
/**
* @className: BsUserPlatformAuthorizeService
* @author: HuRui
* @date: 2024/11/6
**/
public interface BsUserPlatformAuthorizeService {
/**
* 编辑数据
* @param data
*/
void edit(BsUserPlatformAuthorize data);
/**
* 查询用户授权
* @param userId
* @return
*/
List<BsUserPlatformAuthorize> getUserAuth(Long userId);
}

@ -53,8 +53,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
BigDecimal selfPurchaseReward = new BigDecimal(secDictionaryService.getDictionary("SELF_PURCHASE_REWARD", user.getGrade()+"").getCodeName());
// 元宝汇率
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 合伙人权益加成
BigDecimal partnerIncomePer = user.getPartnerIncomePer()!=null?user.getPartnerIncomePer():new BigDecimal("0");
// 获得元宝数量 (返利金额 * 元宝汇率) * 等级自购奖励比例
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate)).multiply(selfPurchaseReward.divide(new BigDecimal("100"))).setScale(6, BigDecimal.ROUND_HALF_DOWN);
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply((selfPurchaseReward.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
Map<String, Object> userRechargeParam = new HashMap<>();
userRechargeParam.put("sourceId", MapUtils.getLong(otherParam, "sourceId"));
@ -103,6 +107,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 直属贡献比例
BigDecimal directlyContributeRate = new BigDecimal("0");
// 合伙人权益加成
BigDecimal partnerIncomePer = new BigDecimal("0");
BsUser parentUserId = userService.getUser(parentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode())
|| UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) {
@ -124,7 +134,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
}
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
if (parentRel != null) {
// 上级账户
@ -138,9 +148,16 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (channel != null) {
// 贡献比例 9%
directlyContributeRate = new BigDecimal("9");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
BsUser channelUserId = userService.getUser(parentRel.getParentUserId());
if (channelUserId != null) {
partnerIncomePer = channelUserId.getPartnerIncomePer()!=null?channelUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -165,6 +182,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 直属贡献比例
BigDecimal directlyContributeRate = new BigDecimal("0");
// 合伙人权益加成
BigDecimal partnerIncomePer = new BigDecimal("0");
BsUser parentUserId = userService.getUser(parentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
if (UserGradeEnum.grade1.getCode().equals(userGrade.getCode())
|| UserGradeEnum.grade2.getCode().equals(userGrade.getCode())) {
@ -177,7 +200,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
}
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
BigDecimal goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 上级账户
@ -196,9 +219,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (UserGradeEnum.grade3.getCode().equals(userParentRel.getParentUserGrade())) {
// 贡献比例 10%
directlyContributeRate = new BigDecimal("10");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -213,9 +242,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (userParentRel != null) {
// 贡献比例 13%
directlyContributeRate = new BigDecimal("13");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -229,9 +264,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
} else if (UserGradeEnum.grade4.getCode().equals(userParentRel.getParentUserGrade())) {
// 贡献比例 23%
directlyContributeRate = new BigDecimal("23");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -246,9 +287,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (channel != null) {
// 贡献比例 9%
directlyContributeRate = new BigDecimal("9");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -296,11 +343,17 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
// 递归判断找到渠道
BsUserParentRel userParentRel = userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade4),parentRel.getParentUserId());
if (userParentRel != null) {
// 贡献比例 10%
// 贡献比例 13%
directlyContributeRate = new BigDecimal("13");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -315,9 +368,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (channel != null) {
// 贡献比例 9%
directlyContributeRate = new BigDecimal("9");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道贡献
parentUserParam.clear();
@ -339,6 +398,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 直属贡献比例
BigDecimal directlyContributeRate = new BigDecimal("0");
// 合伙人权益加成
BigDecimal partnerIncomePer = new BigDecimal("0");
BsUser parentUserId = userService.getUser(parentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献元宝
BigDecimal goldCoin = new BigDecimal("0");
@ -352,7 +417,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 上级账户
@ -382,9 +447,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
directlyContributeRate = new BigDecimal("21.6");
parentUserParam.put("sourceContent", "非直属会员贡献");
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 团长账户
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam);
@ -414,9 +485,16 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
parentUserParam.put("sourceContent", "非直属团长团队贡献");
}
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(channel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道账户
@ -439,9 +517,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
directlyContributeRate = new BigDecimal("55");
parentUserParam.put("sourceContent", "非直属会员贡献");
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道账户
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam);
@ -451,9 +535,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (channel != null) {
// 贡献比例 9%
directlyContributeRate = new BigDecimal("9");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(channel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 贡献
parentUserParam.clear();
@ -476,6 +566,12 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 直属贡献比例
BigDecimal directlyContributeRate = new BigDecimal("0");
// 合伙人权益加成
BigDecimal partnerIncomePer = new BigDecimal("0");
BsUser parentUserId = userService.getUser(parentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献元宝
BigDecimal goldCoin = new BigDecimal("0");
@ -489,7 +585,7 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
// 直属贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 上级账户
@ -519,9 +615,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
directlyContributeRate = new BigDecimal("21.6");
parentUserParam.put("sourceContent", "非直属会员贡献");
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(parentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 团长账户
userAccountService.recharge(userParentRel.getUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam);
@ -551,9 +653,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
parentUserParam.put("sourceContent", "非直属团长团队贡献");
}
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(channel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道账户
@ -576,9 +684,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
directlyContributeRate = new BigDecimal("55");
parentUserParam.put("sourceContent", "非直属会员贡献");
}
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(userParentRel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate.add(partnerIncomePer)).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 渠道账户
userAccountService.recharge(userParentRel.getParentUserId(), goldCoin, UserAccountRecordSourceTypeEnum.type1, parentUserParam);
@ -588,9 +702,15 @@ public class BsUserContributeServiceImpl implements BsUserContributeService {
if (channel != null) {
// 贡献比例 9%
directlyContributeRate = new BigDecimal("9");
// 合伙人权益加成
partnerIncomePer = new BigDecimal("0");
parentUserId = userService.getUser(channel.getParentUserId());
if (parentUserId != null) {
partnerIncomePer = parentUserId.getPartnerIncomePer()!=null?parentUserId.getPartnerIncomePer():new BigDecimal("0");
}
// 贡献 = (返利金额 * 元宝汇率) * 直属贡献
goldCoin = (rebateAmount.multiply(goldCoinExchangeRate))
.multiply(directlyContributeRate.divide(new BigDecimal("100")))
.multiply((directlyContributeRate).add(partnerIncomePer).divide(new BigDecimal("100")))
.setScale(6, BigDecimal.ROUND_HALF_DOWN);
// 贡献
parentUserParam.clear();

@ -4,6 +4,7 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserGradeConfig;
import com.hfkj.model.UserTeamModel;
import com.hfkj.service.user.*;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -34,6 +36,8 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
private BsUserAccountRecordService userAccountRecordService;
@Resource
private BsUserParentRelService userParentRelService;
@Resource
private BsUserGradeConfigService userGradeConfigService;
@Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
@ -96,17 +100,24 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
if (!UserGradeEnum.grade1.getCode().equals(user.getGrade())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "只有“见习会员”才能进行购买");
}
// 获取晋升配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade1);
Map<String,Object> otherParam = new HashMap<>();
otherParam.put("sourceContent", "升级优淘会员");
// 支付3元宝
userAccountService.consume(user.getId(),new BigDecimal("3"), UserAccountRecordSourceTypeEnum.type2, otherParam);
// 支付元宝
userAccountService.consume(user.getId(),config.getPromotionConditions1(), UserAccountRecordSourceTypeEnum.type2, otherParam);
}
@Override
public Map<String, Object> promoteGrade2Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
map.put("condition1", false);
// 获取配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade2);
Map<String,Object> map = new LinkedHashMap<>();
map.put("conditionTarget1", config.getPromotionConditions1());
map.put("conditionTarget2", config.getPromotionConditions2());
map.put("condition1", false);
// 条件一(支付3元宝)
Map<String,Object> accountRecordParam = new HashMap<>();
accountRecordParam.put("userId", userId);
@ -124,7 +135,12 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
@Override
public Map<String, Object> promoteGrade3Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
// 获取配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade3);
Map<String,Object> map = new LinkedHashMap<>();
map.put("conditionTarget1", config.getPromotionConditions1());
map.put("conditionTarget2", config.getPromotionConditions2());
map.put("conditionTarget3", config.getPromotionConditions3());
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", userId);
@ -145,7 +161,12 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
@Override
public Map<String, Object> promoteGrade4Progress(Long userId) {
Map<String,Object> map = new HashMap<>();
// 获取配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade4);
Map<String,Object> map = new LinkedHashMap<>();
map.put("conditionTarget1", config.getPromotionConditions1());
map.put("conditionTarget2", config.getPromotionConditions2());
map.put("conditionTarget3", config.getPromotionConditions3());
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", userId);
@ -175,6 +196,9 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean payCondition = false;
boolean profitCondition = false;
// 获取等级晋升配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade2);
// 完成进度
Map<String, Object> map = promoteGrade2Progress(user.getId());
@ -184,7 +208,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
}
// 条件二(元宝收益达到5元宝)
if (new BigDecimal(MapUtils.getString(map, "condition2")).compareTo(new BigDecimal("5")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition2")).compareTo(config.getPromotionConditions2()) >= 1) {
profitCondition = true;
}
// 满足其中条件一项
@ -202,19 +226,22 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean nonDirect = false; // 非直属
boolean profitCondition = false; // 元宝收益
// 获取等级晋升配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade3);
// 完成进度
Map<String, Object> map = promoteGrade3Progress(user.getId());
// 条件一(直属正式会员达到30人)
if (MapUtils.getInteger(map, "condition1") >= 30) {
if (MapUtils.getInteger(map, "condition1") >= config.getPromotionConditions1().intValue()) {
directlyUnder = true;
}
// 条件二(非直属正式会员达到100人)
if (MapUtils.getInteger(map, "condition2") >= 100) {
if (MapUtils.getInteger(map, "condition2") >= config.getPromotionConditions2().intValue()) {
nonDirect = true;
}
// 条件三(累计元宝收益达到100元宝)
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(new BigDecimal("100")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(config.getPromotionConditions3()) >= 1) {
profitCondition = true;
}
// 满足全部条件
@ -232,19 +259,22 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
boolean nonDirect = false; // 非直属
boolean profitCondition = false; // 元宝收益
// 获取等级晋升配置
BsUserGradeConfig config = userGradeConfigService.getConfig(UserGradeEnum.grade4);
// 完成进度
Map<String, Object> map = promoteGrade3Progress(user.getId());
// 条件一(直属团长达到100人)
if (MapUtils.getInteger(map, "condition1") >= 100) {
if (MapUtils.getInteger(map, "condition1") >= config.getPromotionConditions1().intValue()) {
directlyUnder = true;
}
// 条件二(非直属团长达到300人)
if (MapUtils.getInteger(map, "condition2") >= 300) {
if (MapUtils.getInteger(map, "condition2") >= config.getPromotionConditions2().intValue()) {
nonDirect = true;
}
// 条件三(累计元宝收益达到10000元宝)
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(new BigDecimal("10000")) >= 1) {
if (new BigDecimal(MapUtils.getString(map, "condition3")).compareTo(config.getPromotionConditions3()) >= 1) {
profitCondition = true;
}
return (directlyUnder && nonDirect && profitCondition);

@ -0,0 +1,38 @@
package com.hfkj.service.user.impl;
import com.hfkj.dao.BsUserPlatformAuthorizeMapper;
import com.hfkj.entity.BsUserPlatformAuthorize;
import com.hfkj.service.user.BsUserPlatformAuthorizeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @className: BsUserPlatformAuthorizeServiceImpl
* @author: HuRui
* @date: 2024/11/6
**/
@Service("userPlatformAuthorizeService")
public class BsUserPlatformAuthorizeServiceImpl implements BsUserPlatformAuthorizeService {
@Resource
private BsUserPlatformAuthorizeMapper userPlatformAuthorizeMapper;
@Override
public void edit(BsUserPlatformAuthorize data) {
data.setUpdateTime(new Date());
if (data.getId() == null) {
data.setStatus(1);
data.setCreateTime(new Date());
userPlatformAuthorizeMapper.insert(data);
} else {
userPlatformAuthorizeMapper.updateByPrimaryKey(data);
}
}
@Override
public List<BsUserPlatformAuthorize> getUserAuth(Long userId) {
return null;
}
}

@ -11,10 +11,7 @@ import com.hfkj.dao.BsUserMapper;
import com.hfkj.entity.*;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.*;
import com.hfkj.sysenum.user.UserAccountStatusEnum;
import com.hfkj.sysenum.user.UserGradeEnum;
import com.hfkj.sysenum.user.UserLoginType;
import com.hfkj.sysenum.user.UserStatusEnum;
import com.hfkj.sysenum.user.*;
import org.apache.catalina.User;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -54,6 +51,8 @@ public class BsUserServiceImpl implements BsUserService {
private BsUserParentRelService userParentRelService;
@Resource
private BsUserGradeService userGradeService;
@Resource
private BsUserPlatformAuthorizeService userPlatformAuthorizeService;
private final static String CACHE_KEY = "USER";
/**
@ -298,6 +297,16 @@ public class BsUserServiceImpl implements BsUserService {
editData(bsUser);
// 创建账户余额
userAccountService.create(bsUser.getId());
// 授权信息
BsUserPlatformAuthorize authorize = new BsUserPlatformAuthorize();
authorize.setUserId(user.getId());
authorize.setPlatformCode(UserAuthorizePlatformEnum.type2.getType());
authorize.setPlatformName(UserAuthorizePlatformEnum.type2.getName());
authorize.setAvatar(user.getHeadImg());
authorize.setNickName(user.getName());
authorize.setOpenId(user.getWechatOpenId());
userPlatformAuthorizeService.edit(authorize);
} else {
bsUser.setHeadImg(user.getHeadImg());
bsUser.setName(user.getName());

@ -0,0 +1,29 @@
package com.hfkj.sysenum.user;
import lombok.Getter;
/**
* 用户账户记录来源
* @author hurui
*/
@Getter
public enum UserAuthorizePlatformEnum {
/**
* 支付宝
*/
type1(1 , "支付宝"),
/**
* 微信
*/
type2(2 , "微信"),
;
private Integer type;
private String name;
UserAuthorizePlatformEnum(int type , String name) {
this.type = type;
this.name = name;
}
}
Loading…
Cancel
Save