This commit is contained in:
dute7liang
2024-01-20 01:43:28 +08:00
parent 168ce04086
commit 6993f764b7
6 changed files with 68 additions and 35 deletions

View File

@@ -48,6 +48,7 @@ public class AccountChangeLog implements Serializable {
* 名称 * 名称
*/ */
private String cateAdminName; private String cateAdminName;
private Integer changeType;
private Long traceId; private Long traceId;
private String traceLinkType; private String traceLinkType;
/** /**
@@ -76,6 +77,7 @@ public class AccountChangeLog implements Serializable {
public void init(AccountChangeCodeEnum change){ public void init(AccountChangeCodeEnum change){
this.setAccountType(change.getAccountType().getCode()); this.setAccountType(change.getAccountType().getCode());
this.setChangeType(change.getCode());
this.setCateId(change.getCate().getCode()); this.setCateId(change.getCate().getCode());
this.setCateAdminName(change.getText()); this.setCateAdminName(change.getText());
this.setTraceLinkType(change.getCate().name()); this.setTraceLinkType(change.getCate().name());

View File

@@ -5,41 +5,41 @@ import lombok.Getter;
@Getter @Getter
public enum AccountChangeCodeEnum { public enum AccountChangeCodeEnum {
RECHARGE(101,AccountCateEnum.RECHARGE,"余额充值",AccountTypeEnum.COIN,""), RECHARGE(101,AccountCateEnum.RECHARGE,"余额充值",AccountTypeEnum.COIN,"",null),
WITHDRAW(201,AccountCateEnum.WITHDRAW,"提现",AccountTypeEnum.INCOME_COIN,""), WITHDRAW(201,AccountCateEnum.WITHDRAW,"提现",AccountTypeEnum.INCOME_COIN,"",null),
WITHDRAW_FAIL(202,AccountCateEnum.WITHDRAW,"提现失败",AccountTypeEnum.INCOME_COIN,""), WITHDRAW_FAIL(202,AccountCateEnum.WITHDRAW,"提现失败",AccountTypeEnum.INCOME_COIN,"",null),
VIDEO_INCOME(301,AccountCateEnum.VIDEO,"视频收入",AccountTypeEnum.INCOME_COIN,""), VIDEO_INCOME(301,AccountCateEnum.VIDEO,"视频收入",AccountTypeEnum.INCOME_COIN,"",true),
VIDEO_COIN_OUT(302,AccountCateEnum.VIDEO,"视频支出",AccountTypeEnum.COIN,""), VIDEO_COIN_OUT(302,AccountCateEnum.VIDEO,"视频支出",AccountTypeEnum.COIN,"",false),
VIDEO_INCOME_COIN_OUT(303,AccountCateEnum.VIDEO,"视频支出",AccountTypeEnum.INCOME_COIN,""), VIDEO_INCOME_COIN_OUT(303,AccountCateEnum.VIDEO,"视频支出",AccountTypeEnum.INCOME_COIN,"",false),
GIFT_INCOME(401,AccountCateEnum.GIFT,"收到礼物",AccountTypeEnum.INCOME_COIN,""), GIFT_INCOME(401,AccountCateEnum.GIFT,"收到礼物",AccountTypeEnum.INCOME_COIN,"",true),
GIFT_COIN_OUT(402,AccountCateEnum.GIFT,"送出礼物",AccountTypeEnum.COIN,""), GIFT_COIN_OUT(402,AccountCateEnum.GIFT,"送出礼物",AccountTypeEnum.COIN,"",false),
GIFT_INCOME_COIN_OUT(403,AccountCateEnum.GIFT,"送出礼物",AccountTypeEnum.INCOME_COIN,""), GIFT_INCOME_COIN_OUT(403,AccountCateEnum.GIFT,"送出礼物",AccountTypeEnum.INCOME_COIN,"",false),
FAST_WITHDRAW(501,AccountCateEnum.SYSTEM,"首冲奖励",AccountTypeEnum.INCOME_COIN,""), FAST_WITHDRAW(501,AccountCateEnum.SYSTEM,"首冲奖励",AccountTypeEnum.INCOME_COIN,"",null),
RECHARGE_INVITE(502,AccountCateEnum.SYSTEM,"邀请奖励(充值)",AccountTypeEnum.INCOME_COIN,""), RECHARGE_INVITE(502,AccountCateEnum.SYSTEM,"邀请奖励(充值)",AccountTypeEnum.INCOME_COIN,"",true),
VIDEO_INVITE(503,AccountCateEnum.SYSTEM,"邀请奖励(视频)",AccountTypeEnum.INCOME_COIN,""), VIDEO_INVITE(503,AccountCateEnum.SYSTEM,"邀请奖励(视频)",AccountTypeEnum.INCOME_COIN,"",true),
GIFT_INVITE(504,AccountCateEnum.SYSTEM,"邀请奖励(礼物)",AccountTypeEnum.INCOME_COIN,""), GIFT_INVITE(504,AccountCateEnum.SYSTEM,"邀请奖励(礼物)",AccountTypeEnum.INCOME_COIN,"",true),
GUARD_INVITE(505,AccountCateEnum.SYSTEM,"邀请奖励(守护)",AccountTypeEnum.INCOME_COIN,""), GUARD_INVITE(505,AccountCateEnum.SYSTEM,"邀请奖励(守护)",AccountTypeEnum.INCOME_COIN,"",true),
REGISTER_INVITE(506,AccountCateEnum.SYSTEM,"注册奖励",AccountTypeEnum.INCOME_COIN,""), REGISTER_INVITE(506,AccountCateEnum.SYSTEM,"注册奖励",AccountTypeEnum.INCOME_COIN,"",null),
RAKE_INVITE(507,AccountCateEnum.SYSTEM,"排行榜奖励",AccountTypeEnum.INCOME_COIN,""), RAKE_INVITE(507,AccountCateEnum.SYSTEM,"排行榜奖励",AccountTypeEnum.INCOME_COIN,"",null),
IM_INCOME(701,AccountCateEnum.IM,"收到私信",AccountTypeEnum.INCOME_COIN,""), IM_INCOME(701,AccountCateEnum.IM,"收到私信",AccountTypeEnum.INCOME_COIN,"",true),
IM_COIN_OUT(702,AccountCateEnum.IM,"送出私信",AccountTypeEnum.COIN,""), IM_COIN_OUT(702,AccountCateEnum.IM,"私信支出",AccountTypeEnum.COIN,"",false),
IM_INCOME_COIN_OUT(703,AccountCateEnum.IM,"送出私信",AccountTypeEnum.INCOME_COIN,""), IM_INCOME_COIN_OUT(703,AccountCateEnum.IM,"私信支出",AccountTypeEnum.INCOME_COIN,"",false),
SYSTEM_COIN_INCS(801,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.COIN,"后台新增余额"), SYSTEM_COIN_INCS(801,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.COIN,"后台新增余额",null),
SYSTEM_COIN_DECR(802,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.COIN,"后台减少余额"), SYSTEM_COIN_DECR(802,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.COIN,"后台减少余额",null),
SYSTEM_INCOME_COIN_INCS(803,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.INCOME_COIN,"后台新增收益"), SYSTEM_INCOME_COIN_INCS(803,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.INCOME_COIN,"后台新增收益",null),
SYSTEM_INCOME_COIN_DECR(804,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.INCOME_COIN,"后台减少收益"), SYSTEM_INCOME_COIN_DECR(804,AccountCateEnum.SYSTEM_TRANS,"系统调账",AccountTypeEnum.INCOME_COIN,"后台减少收益",null),
GUARD_INCOME(901,AccountCateEnum.GUARD,"收到守护",AccountTypeEnum.INCOME_COIN,""), GUARD_INCOME(901,AccountCateEnum.GUARD,"收到守护",AccountTypeEnum.INCOME_COIN,"",true),
GUARD_COIN_OUT(902,AccountCateEnum.GUARD,"送出守护",AccountTypeEnum.COIN,""), GUARD_COIN_OUT(902,AccountCateEnum.GUARD,"送出守护",AccountTypeEnum.COIN,"",false),
GUARD_INCOME_COIN_OUT(903,AccountCateEnum.GUARD,"送出守护",AccountTypeEnum.INCOME_COIN,""), GUARD_INCOME_COIN_OUT(903,AccountCateEnum.GUARD,"送出守护",AccountTypeEnum.INCOME_COIN,"",false),
UNION_INVITE(1001,AccountCateEnum.UNION,"工会分成",AccountTypeEnum.INCOME_COIN,""), UNION_INVITE(1001,AccountCateEnum.UNION,"工会分成",AccountTypeEnum.INCOME_COIN,"",true),
; ;
@@ -52,12 +52,24 @@ public enum AccountChangeCodeEnum {
*/ */
private final AccountTypeEnum accountType; private final AccountTypeEnum accountType;
private final String desc; private final String desc;
private final Boolean in;
AccountChangeCodeEnum(Integer code, AccountCateEnum cate, String text, AccountTypeEnum accountType, String desc) { AccountChangeCodeEnum(Integer code, AccountCateEnum cate, String text, AccountTypeEnum accountType, String desc, Boolean in) {
this.code = code; this.code = code;
this.cate = cate; this.cate = cate;
this.text = text; this.text = text;
this.accountType = accountType; this.accountType = accountType;
this.desc = desc; this.desc = desc;
this.in = in;
}
public static AccountChangeCodeEnum getByCode(Integer code){
AccountChangeCodeEnum[] values = AccountChangeCodeEnum.values();
for (AccountChangeCodeEnum value : values) {
if(value.getCode().equals(code)){
return value;
}
}
return null;
} }
} }

View File

@@ -46,7 +46,7 @@ public class AccountChangeLogServiceImpl extends ServiceImpl<AccountChangeLogMap
public AccountChangeLog saveLogNoAdmin(Long userId, String usercode, AccountChangeCodeEnum change, Long price, Long traceId public AccountChangeLog saveLogNoAdmin(Long userId, String usercode, AccountChangeCodeEnum change, Long price, Long traceId
,Long tarUserId){ ,Long tarUserId){
AccountChangeLog changeLog = this.getAccountChangeLog(userId, usercode, change, price, traceId, 0); AccountChangeLog changeLog = this.getAccountChangeLog(userId, usercode, change, price, traceId, 0);
changeLog.setTarUserId(userId); changeLog.setTarUserId(tarUserId);
this.save(changeLog); this.save(changeLog);
return changeLog; return changeLog;
} }
@@ -55,7 +55,7 @@ public class AccountChangeLogServiceImpl extends ServiceImpl<AccountChangeLogMap
public AccountChangeLog saveLogNoAdmin(Long userId, String usercode, AccountChangeCodeEnum change, Long price, Long traceId public AccountChangeLog saveLogNoAdmin(Long userId, String usercode, AccountChangeCodeEnum change, Long price, Long traceId
, Long tarUserId, Gift gift){ , Long tarUserId, Gift gift){
AccountChangeLog changeLog = this.getAccountChangeLog(userId, usercode, change, price, traceId, 0); AccountChangeLog changeLog = this.getAccountChangeLog(userId, usercode, change, price, traceId, 0);
changeLog.setTarUserId(userId); changeLog.setTarUserId(tarUserId);
if(gift != null){ if(gift != null){
changeLog.setTarParam(gift.getId()+""); changeLog.setTarParam(gift.getId()+"");
changeLog.setTarImg(gift.getImg()); changeLog.setTarImg(gift.getImg());
@@ -98,12 +98,27 @@ public class AccountChangeLogServiceImpl extends ServiceImpl<AccountChangeLogMap
for (AccountChangeLog record : records) { for (AccountChangeLog record : records) {
User user = userMap.get(record.getTarUserId()); User user = userMap.get(record.getTarUserId());
if(user != null){ if(user != null){
String format = String.format("%s来自【%s】", record.getCateAdminName(), user.getNickname()); AccountChangeCodeEnum changeEnum = AccountChangeCodeEnum.getByCode(record.getChangeType());
if(changeEnum != null){
Boolean in = changeEnum.getIn();
if(in == null){
record.setShowMessage(record.getCateAdminName());
}else{
String format = String.format("%s%s%s",
record.getCateAdminName(),
in?"来自":"",
user.getNickname());
record.setShowMessage(format); record.setShowMessage(format);
}
}else{
record.setShowMessage(record.getCateAdminName());
}
}else{ }else{
record.setShowMessage(record.getCateAdminName()); record.setShowMessage(record.getCateAdminName());
} }
if(AccountCateEnum.IM.getCode().equals(record.getCateId()) if(AccountCateEnum.IM.getCode().equals(record.getCateId())
|| AccountCateEnum.VIDEO.getCode().equals(record.getCateId())
|| AccountCateEnum.GUARD.getCode().equals(record.getCateId())
|| AccountCateEnum.SYSTEM.getCode().equals(record.getCateId()) || AccountCateEnum.SYSTEM.getCode().equals(record.getCateId())
|| AccountCateEnum.UNION.getCode().equals(record.getCateId())){ || AccountCateEnum.UNION.getCode().equals(record.getCateId())){
if(record.getTarUserId() != null){ if(record.getTarUserId() != null){

View File

@@ -118,7 +118,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// 记录接收方的流水 // 记录接收方的流水
if(targetUserId != null){ if(targetUserId != null){
AccountChangeCodeEnum change = ConsumeLogType.getTargetChange(consumeLogType); AccountChangeCodeEnum change = ConsumeLogType.getTargetChange(consumeLogType);
accountChangeLogService.saveLogNoAdmin(userId, consumeLog.getSourceUsercode(), change, consumeLog.getAnchorAmount(), consumeLog.getTraceId() accountChangeLogService.saveLogNoAdmin(consumeLog.getTargetUserId(), consumeLog.getTargetUsercode(), change, consumeLog.getAnchorAmount(), consumeLog.getTraceId()
,consumeLog.getSourceUserId(),gift); ,consumeLog.getSourceUserId(),gift);
} }
// 获取分销的比例和用户 // 获取分销的比例和用户

View File

@@ -156,7 +156,7 @@ public class ConsumeLogServiceImpl extends ServiceImpl<ConsumeLogMapper, Consume
|| ConsumeLogType.VIDEO.getCode().equals(consumeLog.getType())){ || ConsumeLogType.VIDEO.getCode().equals(consumeLog.getType())){
UnionUser unionUser = unionUserService.getByUserId(targetUserId); UnionUser unionUser = unionUserService.getByUserId(targetUserId);
if(unionUser != null){ if(unionUser != null){
User user = userService.getById(unionUser.getId()); User user = userService.getById(unionUser.getUnionUserId());
if(user != null && user.getIsUnion() == 1 && user.getStatus() == 0){ if(user != null && user.getIsUnion() == 1 && user.getStatus() == 0){
Union union = unionService.getById(unionUser.getUnionId()); Union union = unionService.getById(unionUser.getUnionId());
if(union != null){ if(union != null){
@@ -172,7 +172,7 @@ public class ConsumeLogServiceImpl extends ServiceImpl<ConsumeLogMapper, Consume
}else if(ConsumeLogType.VIDEO.getCode().equals(consumeLog.getType())){ }else if(ConsumeLogType.VIDEO.getCode().equals(consumeLog.getType())){
consumeLog.setUnionRate(unionUser.getVideoDivide()); consumeLog.setUnionRate(unionUser.getVideoDivide());
} }
consumeLog.setOneAmount(NumCaUtil.coin(consumeLog.getAnchorAmount(),consumeLog.getUnionRate())); consumeLog.setUnionAmount(NumCaUtil.coin(consumeLog.getAnchorAmount(),consumeLog.getUnionRate()));
} }
} }
} }

View File

@@ -20,4 +20,8 @@ public class NumCaUtil {
BigDecimal decimal = NumberUtil.mul(value, rate); BigDecimal decimal = NumberUtil.mul(value, rate);
return decimal.setScale(0, RoundingMode.DOWN).longValue(); return decimal.setScale(0, RoundingMode.DOWN).longValue();
} }
public static void main(String[] args) {
System.out.println(coin(5200L,BigDecimal.valueOf(0.07)));
}
} }