|
|
@ -174,4 +174,93 @@ public class ConsumeServiceImpl implements ConsumeService { |
|
|
|
// } |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//新增消耗 |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
public Result addRefund(ConsumeUser consumeUser) { |
|
|
|
if (consumeUser.getTaskGold() == null || consumeUser.getFreeGold() == null || consumeUser.getPermanentGold() == null) { |
|
|
|
return Result.error("金币数量不能为空"); |
|
|
|
} |
|
|
|
if (consumeUser.getTaskGold().compareTo(BigDecimal.ZERO) < 0 || consumeUser.getFreeGold().compareTo(BigDecimal.ZERO) < 0 || consumeUser.getPermanentGold().compareTo(BigDecimal.ZERO) < 0) { |
|
|
|
return Result.error("金币不能为负数"); |
|
|
|
} |
|
|
|
if(consumeUser.getJwcode()<10000000||consumeUser.getJwcode()>99999999) |
|
|
|
{ |
|
|
|
return Result.error("精网号位数小于8位或大于8位"); |
|
|
|
} |
|
|
|
if(consumeUser.getAdminName()==null){ |
|
|
|
return Result.error("管理员不能为空"); |
|
|
|
} |
|
|
|
GoldUser goldUser = userMapper.selectUser(consumeUser.getJwcode().toString()); |
|
|
|
if (goldUser == null) { |
|
|
|
return Result.error("用户不存在"); |
|
|
|
} |
|
|
|
UserGoldRecord userGoldRecord = new UserGoldRecord(); |
|
|
|
|
|
|
|
String orderNumber = UUID.randomUUID().toString().replaceAll("-", ""); |
|
|
|
//订单号生成 |
|
|
|
userGoldRecord.setOrderCode("TKCZ_" + orderNumber); |
|
|
|
userGoldRecord.setJwcode(consumeUser.getJwcode()); |
|
|
|
userGoldRecord.setGoodsName(consumeUser.getGoodsName()); |
|
|
|
userGoldRecord.setSumGold(-consumeUser.getSumGold().intValue()); |
|
|
|
userGoldRecord.setPermanentGold(-consumeUser.getPermanentGold().intValue()); |
|
|
|
// 获取当前月份(1-12) |
|
|
|
int currentMonth = LocalDate.now().getMonthValue(); |
|
|
|
GoldUser gold = userMapper.selectGold(consumeUser.getJwcode().toString()); |
|
|
|
if (consumeUser.getFreeGold().compareTo(gold.getNowFreeDecember().add(gold.getNowFreeJune())) > 0 |
|
|
|
|| consumeUser.getPermanentGold().compareTo(gold.getNowPermanentGold()) > 0 |
|
|
|
|| consumeUser.getTaskGold().compareTo(gold.getNowTaskGold()) > 0) { |
|
|
|
return Result.error("金币数量不足"); |
|
|
|
} |
|
|
|
// 根据当前月份设置对应字段 |
|
|
|
if (currentMonth >= 1 && currentMonth <= 6) { |
|
|
|
// 1-6月:设置6月额度,12月保持默认值 |
|
|
|
if (consumeUser.getFreeGold().compareTo(gold.getNowFreeJune()) > 0) { |
|
|
|
userGoldRecord.setFreeJune(-gold.getNowFreeJune().intValue()); |
|
|
|
userGoldRecord.setFreeDecember(-(consumeUser.getFreeGold().subtract(gold.getNowFreeJune())).intValue()); |
|
|
|
} else { |
|
|
|
userGoldRecord.setFreeJune(-consumeUser.getFreeGold().intValue()); |
|
|
|
userGoldRecord.setFreeDecember(0); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 7-12月:设置12月额度,6月保持默认值 |
|
|
|
if (consumeUser.getFreeGold().compareTo(gold.getNowFreeDecember()) > 0) { |
|
|
|
userGoldRecord.setFreeDecember(-gold.getNowFreeDecember().intValue()); |
|
|
|
userGoldRecord.setFreeJune(-(consumeUser.getFreeGold().subtract(gold.getNowFreeDecember())).intValue()); |
|
|
|
} else { |
|
|
|
userGoldRecord.setFreeDecember(-consumeUser.getFreeGold().intValue()); |
|
|
|
userGoldRecord.setFreeJune(0); |
|
|
|
} |
|
|
|
} |
|
|
|
//信息输入 |
|
|
|
userGoldRecord.setTaskGold(-consumeUser.getTaskGold().intValue()); |
|
|
|
userGoldRecord.setRemark(consumeUser.getRemark()); |
|
|
|
userGoldRecord.setType((byte) 2); |
|
|
|
userGoldRecord.setAuditStatus(0); |
|
|
|
userGoldRecord.setPayPlatform("金币系统"); |
|
|
|
userGoldRecord.setAdminId(consumeUser.getAdminId()); |
|
|
|
userGoldRecord.setCreateTime(new Date()); |
|
|
|
userGoldRecord.setPayTime(new Date()); |
|
|
|
consumeMapper.add(userGoldRecord); |
|
|
|
consumeMapper.updateUserGold(userGoldRecord); |
|
|
|
User user = new User(); |
|
|
|
user.setJwcode(userGoldRecord.getJwcode()); |
|
|
|
user.setCurrentPermanentGold(BigDecimal.valueOf(gold.getNowPermanentGold().intValue() - consumeUser.getPermanentGold().intValue())); |
|
|
|
user.setCurrentFreeJune(BigDecimal.valueOf(gold.getNowFreeJune().intValue() + userGoldRecord.getFreeJune())); |
|
|
|
user.setCurrentFreeDecember(BigDecimal.valueOf(gold.getNowFreeDecember().intValue() + userGoldRecord.getFreeDecember())); |
|
|
|
user.setCurrentTaskGold(BigDecimal.valueOf(gold.getNowTaskGold().intValue() - consumeUser.getTaskGold().intValue())); |
|
|
|
user.setConsumeNum(gold.getConsumeNum().intValue() + 1); |
|
|
|
user.setSumConsumePermanent(BigDecimal.valueOf(-consumeUser.getPermanentGold().intValue())); |
|
|
|
user.setSumConsumeFree(BigDecimal.valueOf(-consumeUser.getFreeGold().intValue())); |
|
|
|
user.setSumConsumeTask(BigDecimal.valueOf(-consumeUser.getTaskGold().intValue())); |
|
|
|
userMapper.updateGold(user); |
|
|
|
// if(consumeUser.getJwcode().equals(94226013)){ |
|
|
|
GoldTistV2.addCoinNew(userGoldRecord.getJwcode().toString(), 65, |
|
|
|
(double) (userGoldRecord.getPermanentGold() + userGoldRecord.getFreeDecember() + userGoldRecord.getFreeJune() + userGoldRecord.getTaskGold()) / 100, |
|
|
|
userGoldRecord.getRemark(), ((double) userGoldRecord.getPermanentGold() / 100), consumeUser.getAdminName(), userGoldRecord.getGoodsName()); |
|
|
|
// } |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
} |