|
|
@ -1,9 +1,8 @@ |
|
|
|
package com.example.demo.serviceImpl; |
|
|
|
|
|
|
|
import com.example.demo.domain.vo.ConsumeUser; |
|
|
|
import com.example.demo.domain.vo.Gold; |
|
|
|
import com.example.demo.domain.vo.RechargeUser; |
|
|
|
import com.example.demo.domain.vo.Result; |
|
|
|
import com.example.demo.domain.entity.User; |
|
|
|
import com.example.demo.domain.entity.UserGoldRecord; |
|
|
|
import com.example.demo.domain.vo.*; |
|
|
|
import com.example.demo.mapper.ConsumeMapper; |
|
|
|
import com.example.demo.mapper.RechargeMapper; |
|
|
|
import com.example.demo.mapper.UserMapper; |
|
|
@ -13,7 +12,12 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
/** |
|
|
|
* @program: gold-java |
|
|
@ -79,6 +83,49 @@ public class RechargeServiceImpl implements RechargeService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result add(RechargeUser rechargeUser) { |
|
|
|
return null; |
|
|
|
UserGoldRecord userGoldRecord = new UserGoldRecord(); |
|
|
|
|
|
|
|
// 获取当前时间戳部分 |
|
|
|
String timestampPart = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")); |
|
|
|
|
|
|
|
// 获取自增计数器部分(三位数,不足补零) |
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0); |
|
|
|
|
|
|
|
int count = atomicInteger.getAndUpdate(c -> (c >= 999) ? 0 : c + 1); |
|
|
|
String counterPart = String.format("%03d", count); |
|
|
|
|
|
|
|
|
|
|
|
//订单号生成 |
|
|
|
userGoldRecord.setOrderCode("CZ" + timestampPart + counterPart); |
|
|
|
userGoldRecord.setJwcode(rechargeUser.getJwcode()); |
|
|
|
userGoldRecord.setActivity(rechargeUser.getActivity()); |
|
|
|
userGoldRecord.setPermanentGold(rechargeUser.getPermanentGold()); |
|
|
|
// 获取当前月份(1-12) |
|
|
|
int currentMonth = LocalDate.now().getMonthValue(); |
|
|
|
// 根据当前月份设置对应字段 |
|
|
|
if (currentMonth >= 1 && currentMonth <= 6) { |
|
|
|
// 1-6月:设置6月额度,12月保持默认值 |
|
|
|
userGoldRecord.setFreeJune(0); |
|
|
|
userGoldRecord.setFreeDecember(rechargeUser.getFreeGold()); |
|
|
|
} else { |
|
|
|
// 7-12月:设置12月额度,6月保持默认值 |
|
|
|
userGoldRecord.setFreeJune(rechargeUser.getFreeGold()); |
|
|
|
userGoldRecord.setFreeDecember(0); |
|
|
|
} |
|
|
|
userGoldRecord.setSumGold(rechargeUser.getFreeGold()+rechargeUser.getPermanentGold()); |
|
|
|
userGoldRecord.setRateId(rechargeUser.getRateId()); |
|
|
|
userGoldRecord.setMoney(rechargeUser.getMoney()); |
|
|
|
userGoldRecord.setVoucher(rechargeUser.getVoucher()); |
|
|
|
userGoldRecord.setPayPlatform("金币系统"); |
|
|
|
userGoldRecord.setPayModel(rechargeUser.getPayModel()); |
|
|
|
userGoldRecord.setPayTime(rechargeUser.getPayTime()); |
|
|
|
userGoldRecord.setRemark(rechargeUser.getRemark()); |
|
|
|
userGoldRecord.setAdminId(rechargeUser.getAdminId()); |
|
|
|
userGoldRecord.setType((byte) 0); |
|
|
|
userGoldRecord.setAuditStatus(0); |
|
|
|
userGoldRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
rechargeMapper.add(userGoldRecord); |
|
|
|
return Result.success(); |
|
|
|
} |
|
|
|
} |