|
|
@ -2,9 +2,11 @@ package com.example.demo.serviceImpl; |
|
|
|
|
|
|
|
import com.example.demo.Util.BaseDES; |
|
|
|
import com.example.demo.domain.entity.DetailY; |
|
|
|
import com.example.demo.domain.entity.UserGold; |
|
|
|
import com.example.demo.domain.vo.ERP; |
|
|
|
import com.example.demo.mapper.DetailYMapper; |
|
|
|
import com.example.demo.mapper.OtherMapper; |
|
|
|
import com.example.demo.mapper.UserMapper; |
|
|
|
import com.example.demo.sevice.OtherService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -15,6 +17,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.Month; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.HashSet; |
|
|
@ -35,6 +39,7 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
private static final Set<String> typesToUpdateThree = new HashSet<>(); |
|
|
|
private final OtherMapper otherMapper; |
|
|
|
private final DetailYMapper detailYMapper; |
|
|
|
private final UserMapper userMapper; |
|
|
|
|
|
|
|
static { |
|
|
|
typesToUpdateZero.add("1"); |
|
|
@ -106,6 +111,8 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
@Override |
|
|
|
public int addERP(ERP erp) throws Exception { |
|
|
|
DetailY detailY = new DetailY(); |
|
|
|
|
|
|
|
|
|
|
|
String type = erp.getType(); |
|
|
|
String JwCode = erp.getJwcode(); |
|
|
|
BigDecimal taskJb = erp.getTaskJb(); |
|
|
@ -117,6 +124,7 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
String Way = otherMapper.selectWay(type); |
|
|
|
String country = null; |
|
|
|
String name = null; |
|
|
|
UserGold userGold = userMapper.selectGold(JwCode); |
|
|
|
|
|
|
|
BaseDES des = new BaseDES(); |
|
|
|
|
|
|
@ -188,6 +196,32 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
detailY.setUsername(name); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal buyJb =userGold.getBuyJb(); |
|
|
|
BigDecimal coreJb=userGold.getCoreJb(); |
|
|
|
buyJb = buyJb.add(rechargeJb); |
|
|
|
coreJb = coreJb.add(taskJb); |
|
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
|
userGold.setBuyJb(buyJb); |
|
|
|
userGold.setCoreJb(coreJb); |
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
// 判断当前日期是在六月之前还是之后 |
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
boolean isBeforeJune = currentMonth.getValue() < Month.JUNE.getValue(); |
|
|
|
boolean isJune = currentMonth.getValue() == Month.JUNE.getValue(); |
|
|
|
boolean isAfterJune = currentMonth.getValue() > Month.JUNE.getValue(); |
|
|
|
|
|
|
|
// 根据月份更新 free6 或 free12 |
|
|
|
if (isBeforeJune||isJune) { |
|
|
|
// 如果是六月前,更新 free6 |
|
|
|
BigDecimal free6 = userGold.getFree6().add(freeJb); |
|
|
|
userGold.setFree6(free6); |
|
|
|
} else if (isAfterJune) { |
|
|
|
// 如果是六月后,更新 free12 |
|
|
|
BigDecimal free12 = userGold.getFree12().add(freeJb); |
|
|
|
userGold.setFree12(free12); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (typesToUpdateOne.contains(type)) { |
|
|
|
System.out.println("消费------------------------------------------------------"); |
|
|
@ -204,7 +238,34 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
detailY.setConsumePlatform("ERP系统"); |
|
|
|
detailY.setConsumeType(Way); |
|
|
|
|
|
|
|
|
|
|
|
detailY.setCreateTime(erp.getCreateTime()); |
|
|
|
|
|
|
|
BigDecimal buyJb =userGold.getBuyJb(); |
|
|
|
BigDecimal coreJb=userGold.getCoreJb(); |
|
|
|
buyJb = buyJb.add(rechargeJb); |
|
|
|
coreJb = coreJb.add(taskJb); |
|
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
|
userGold.setBuyJb(buyJb); |
|
|
|
userGold.setCoreJb(coreJb); |
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
// 判断当前日期是在六月之前还是之后 |
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
boolean isBeforeJune = currentMonth.getValue() < Month.JUNE.getValue(); |
|
|
|
boolean isJune = currentMonth.getValue() == Month.JUNE.getValue(); |
|
|
|
boolean isAfterJune = currentMonth.getValue() > Month.JUNE.getValue(); |
|
|
|
|
|
|
|
// 根据月份更新 free6 或 free12 |
|
|
|
if (isBeforeJune||isJune) { |
|
|
|
// 如果是六月前,更新 free6 |
|
|
|
BigDecimal free6 = userGold.getFree6().add(freeJb); |
|
|
|
userGold.setFree6(free6); |
|
|
|
} else if (isAfterJune) { |
|
|
|
// 如果是六月后,更新 free12 |
|
|
|
BigDecimal free12 = userGold.getFree12().add(freeJb); |
|
|
|
userGold.setFree12(free12); |
|
|
|
} |
|
|
|
} else if (typesToUpdateTwo.contains(type)) { |
|
|
|
System.out.println("退款------------------------------------------------------"); |
|
|
|
detailY.setUpdateType(2); // 设置 updateType 为 2 |
|
|
@ -221,6 +282,34 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
detailY.setRefundType(Way); |
|
|
|
|
|
|
|
detailY.setCreateTime(erp.getCreateTime()); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal buyJb =userGold.getBuyJb(); |
|
|
|
BigDecimal coreJb=userGold.getCoreJb(); |
|
|
|
buyJb = buyJb.add(rechargeJb); |
|
|
|
coreJb = coreJb.add(taskJb); |
|
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
|
userGold.setBuyJb(buyJb); |
|
|
|
userGold.setCoreJb(coreJb); |
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
// 判断当前日期是在六月之前还是之后 |
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
boolean isBeforeJune = currentMonth.getValue() < Month.JUNE.getValue(); |
|
|
|
boolean isJune = currentMonth.getValue() == Month.JUNE.getValue(); |
|
|
|
boolean isAfterJune = currentMonth.getValue() > Month.JUNE.getValue(); |
|
|
|
|
|
|
|
// 根据月份更新 free6 或 free12 |
|
|
|
if (isBeforeJune||isJune) { |
|
|
|
// 如果是六月前,更新 free6 |
|
|
|
BigDecimal free6 = userGold.getFree6().add(freeJb); |
|
|
|
userGold.setFree6(free6); |
|
|
|
} else if (isAfterJune) { |
|
|
|
// 如果是六月后,更新 free12 |
|
|
|
BigDecimal free12 = userGold.getFree12().add(freeJb); |
|
|
|
userGold.setFree12(free12); |
|
|
|
} |
|
|
|
|
|
|
|
}else if (typesToUpdateThree.contains(type)) { |
|
|
|
System.out.println("其他------------------------------------------------------"); |
|
|
|
detailY.setUpdateType(3); // 设置 updateType 为 3 |
|
|
@ -237,9 +326,38 @@ public class OtherServiceImpl implements OtherService { |
|
|
|
detailY.setReson(Way); |
|
|
|
|
|
|
|
detailY.setCreateTime(erp.getCreateTime()); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal buyJb =userGold.getBuyJb(); |
|
|
|
BigDecimal coreJb=userGold.getCoreJb(); |
|
|
|
buyJb = buyJb.add(rechargeJb); |
|
|
|
coreJb = coreJb.add(taskJb); |
|
|
|
// 设置更新后的Sumgold回到user对象 |
|
|
|
userGold.setBuyJb(buyJb); |
|
|
|
userGold.setCoreJb(coreJb); |
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
// 判断当前日期是在六月之前还是之后 |
|
|
|
Month currentMonth = now.getMonth(); |
|
|
|
boolean isBeforeJune = currentMonth.getValue() < Month.JUNE.getValue(); |
|
|
|
boolean isJune = currentMonth.getValue() == Month.JUNE.getValue(); |
|
|
|
boolean isAfterJune = currentMonth.getValue() > Month.JUNE.getValue(); |
|
|
|
|
|
|
|
// 根据月份更新 free6 或 free12 |
|
|
|
if (isBeforeJune||isJune) { |
|
|
|
// 如果是六月前,更新 free6 |
|
|
|
BigDecimal free6 = userGold.getFree6().add(freeJb); |
|
|
|
userGold.setFree6(free6); |
|
|
|
} else if (isAfterJune) { |
|
|
|
// 如果是六月后,更新 free12 |
|
|
|
BigDecimal free12 = userGold.getFree12().add(freeJb); |
|
|
|
userGold.setFree12(free12); |
|
|
|
} |
|
|
|
} |
|
|
|
// 添加其他业务逻辑 |
|
|
|
System.out.println(detailY+"-----测试能否传输------"); |
|
|
|
|
|
|
|
userMapper.updateGold(userGold); |
|
|
|
return detailYMapper.add(detailY); |
|
|
|
} |
|
|
|
} |