From 3b417885e6ac184e8b2f82fa376ff05ed2e2a6a8 Mon Sep 17 00:00:00 2001 From: huangqizhen Date: Mon, 17 Feb 2025 23:11:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A5=BC=E4=B8=8A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=9B=B4=E6=96=B0userGold=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/serviceImpl/OtherServiceImpl.java | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/src/main/java/com/example/demo/serviceImpl/OtherServiceImpl.java b/src/main/java/com/example/demo/serviceImpl/OtherServiceImpl.java index 13b2080..e6ed01d 100644 --- a/src/main/java/com/example/demo/serviceImpl/OtherServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/OtherServiceImpl.java @@ -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 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); } }