|
@ -22,6 +22,8 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.Month; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.UUID; |
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
@ -41,7 +43,7 @@ public class RechargeServiceImpl implements RechargeService { |
|
|
@Override |
|
|
@Override |
|
|
@Transactional |
|
|
@Transactional |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@CacheEvict(value = "recharge",allEntries = true) |
|
|
public int add(Recharge recharge) throws Exception { |
|
|
public int add(Recharge recharge) throws Exception { |
|
|
// return rechargeMapper.insert(recharge); |
|
|
// return rechargeMapper.insert(recharge); |
|
|
|
|
|
|
|
@ -110,12 +112,30 @@ public class RechargeServiceImpl implements RechargeService { |
|
|
BigDecimal paidGold1 =recharge.getPaidGold(); |
|
|
BigDecimal paidGold1 =recharge.getPaidGold(); |
|
|
BigDecimal freeGold1 =recharge.getFreeGold(); |
|
|
BigDecimal freeGold1 =recharge.getFreeGold(); |
|
|
User user = userMapper.select(jwcode); |
|
|
User user = userMapper.select(jwcode); |
|
|
BigDecimal Sumgold =user.getSumgold(); |
|
|
|
|
|
|
|
|
BigDecimal buyJb =user.getBuyJb(); |
|
|
|
|
|
|
|
|
Sumgold = Sumgold.add(freeGold1).add(paidGold1); |
|
|
|
|
|
|
|
|
buyJb = buyJb.add(paidGold1); |
|
|
|
|
|
|
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
user.setSumgold(Sumgold); |
|
|
|
|
|
|
|
|
user.setBuyJb(buyJb); |
|
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
|
|
|
|
// 判断当前日期是在六月之前还是之后 |
|
|
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
|
|
boolean isBeforeJune = currentMonth.getValue() < Month.JUNE.getValue(); |
|
|
|
|
|
boolean isAfterJune = currentMonth.getValue() > Month.JUNE.getValue(); |
|
|
|
|
|
|
|
|
|
|
|
// 根据月份更新 free6 或 free12 |
|
|
|
|
|
if (isBeforeJune) { |
|
|
|
|
|
// 如果是六月前,更新 free6 |
|
|
|
|
|
BigDecimal free6 = user.getFree6().add(freeGold1); |
|
|
|
|
|
user.setFree6(free6); |
|
|
|
|
|
} else if (isAfterJune) { |
|
|
|
|
|
// 如果是六月后,更新 free12 |
|
|
|
|
|
BigDecimal free12 = user.getFree12().add(freeGold1); |
|
|
|
|
|
user.setFree12(free12); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
System.out.println(user+"----------------------------------------------------------"); |
|
|
System.out.println(user+"----------------------------------------------------------"); |
|
|
result = userMapper.update(user); |
|
|
result = userMapper.update(user); |
|
|
if (result != 1) { |
|
|
if (result != 1) { |
|
|