lisy
2023-07-25 e61275c2e77d27e299e74d84568bedd43b6d82ca
cloud-server-account/src/main/java/com/dsh/account/service/impl/RechargeRecordsServiceImpl.java
@@ -16,12 +16,17 @@
import com.dsh.account.mapper.TAppUserMapper;
import com.dsh.account.model.vo.userBenefitDetail.RechargeDetailsVo;
import com.dsh.account.model.vo.userBenefitDetail.RechargePayRequest;
import com.dsh.account.model.vo.userBenefitDetail.RechargesDetail;
import com.dsh.account.service.RechargeRecordsService;
import com.dsh.account.util.DateTimeHelper;
import com.dsh.account.util.PayMoneyUtil;
import com.dsh.account.util.ResultUtil;
import com.dsh.account.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -67,9 +72,8 @@
    @Override
    public RechargeDetailsVo getAppUserRechargeRecord(String yearMonth, Integer recordId, Integer appUserId) {
        RechargeDetailsVo vo = new RechargeDetailsVo();
        List<RechargeDetailsVo.RechargesDetail> details = new ArrayList<>();
    public List<RechargesDetail> getAppUserRechargeRecord(String yearMonth, Integer recordId, Integer appUserId,Integer pageNum,Integer pageSize) {
        List<RechargesDetail> details = new ArrayList<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm");
        Date monthStart = null;
@@ -82,17 +86,11 @@
            monthEnd = DateTimeHelper.getCurrentMouthEnd();
        }
        TAppUser tAppUser = tappMapper.selectById(appUserId);
        if (null != tAppUser){
            vo.setWpGold(tAppUser.getPlayPaiCoins());
        }else {
            vo.setWpGold(0);
        }
//            1.赛事报名
        List<PaymentCompetition> playPaiFGoldPayRecord = deducClient.getPlayPaiFGoldPayRecord(appUserId);
        if (playPaiFGoldPayRecord.size() > 0 ){
            for (PaymentCompetition competition : playPaiFGoldPayRecord) {
                RechargeDetailsVo.RechargesDetail consumeDetail = new RechargeDetailsVo.RechargesDetail();
                RechargesDetail consumeDetail = new RechargesDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.EVENT_REGISTRATION.getMsg() );
                consumeDetail.setConsumeTime(simpleDateFormat.format(competition.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + competition.getAmount());
@@ -103,7 +101,7 @@
        List<TCoursePackagePayment> appuserCourseList = cpClient.getAppuserCourseList(appUserId);
        if (appuserCourseList.size() > 0){
            for (TCoursePackagePayment tCoursePackagePayment : appuserCourseList) {
                RechargeDetailsVo.RechargesDetail consumeDetail = new RechargeDetailsVo.RechargesDetail();
                RechargesDetail consumeDetail = new RechargesDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.COURSE_PACKAGE_PURCHASE.getMsg() );
                consumeDetail.setConsumeTime(simpleDateFormat.format(tCoursePackagePayment.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + tCoursePackagePayment.getPlayPaiCoin());
@@ -114,7 +112,7 @@
        List<SiteBooking> siteBookings = stClient.wanpaiGoldSiteBookingList(appUserId);
        if (siteBookings.size() > 0 ){
            for (SiteBooking booking : siteBookings) {
                RechargeDetailsVo.RechargesDetail consumeDetail = new RechargeDetailsVo.RechargesDetail();
                RechargesDetail consumeDetail = new RechargesDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.VENUE_RESERVATION.name());
                consumeDetail.setConsumeTime(simpleDateFormat.format(booking.getInsertTime()));
                consumeDetail.setConsumeAmount("-" + booking.getPayMoney());
@@ -130,7 +128,7 @@
                .between("insertTime", monthStart, monthEnd));
        if (rechargeRecords.size() > 0) {
            for (RechargeRecords rechargeRecord : rechargeRecords) {
                RechargeDetailsVo.RechargesDetail consumeDetail = new RechargeDetailsVo.RechargesDetail();
                RechargesDetail consumeDetail = new RechargesDetail();
                consumeDetail.setConsumeName(RechargeRecordEnum.RECHARGE.name() + ":" + rechargeRecord.getPlayPaiCoins());
                consumeDetail.setConsumeTime(simpleDateFormat.format(rechargeRecord.getInsertTime()));
                consumeDetail.setConsumeAmount("+" + rechargeRecord.getAmount());
@@ -138,9 +136,9 @@
            }
        }
        if (details.size() > 0 ){
            Collections.sort(details, new Comparator<RechargeDetailsVo.RechargesDetail>() {
            Collections.sort(details, new Comparator<RechargesDetail>() {
                @Override
                public int compare(RechargeDetailsVo.RechargesDetail o1, RechargeDetailsVo.RechargesDetail o2) {
                public int compare(RechargesDetail o1, RechargesDetail o2) {
                    try {
                        Date date1 = simpleDateFormat.parse(o1.getConsumeTime());
                        Date date2 = simpleDateFormat.parse(o2.getConsumeTime());
@@ -152,8 +150,9 @@
                }
            });
        }
        vo.setDetailList(details);
        return vo;
        Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
        Page<RechargesDetail> page = getPage(details, pageable);
        return page.getContent();
    }
    @Override
@@ -164,15 +163,19 @@
        RechargeRecords rechargeRecords = new RechargeRecords();
        rechargeRecords.setCode(code);
        rechargeRecords.setAppUserId(userIdFormRedis);
        rechargeRecords.setAmount(request.getPayAmount());
        List<Map<String, Object>> rechargeConfig = reconMapper.getRechargeConfig();
        BigDecimal amount = BigDecimal.ZERO;
        if (rechargeConfig.size() > 0){
            for (Map<String, Object> stringObjectMap : rechargeConfig) {
                Object o = stringObjectMap.get("money");
                if (o.equals(request.getPayAmount())){
                    if (tAppUser.getIsVip() == 1){
                Integer chargeId = (Integer) stringObjectMap.get("chargeId");
                if (chargeId.equals(request.getChargeId())) {
                    Long o = (Long) stringObjectMap.get("money");
                    amount = BigDecimal.valueOf(o);
                    rechargeRecords.setAmount(BigDecimal.valueOf(o));
                    if (tAppUser.getIsVip() == 1) {
                        rechargeRecords.setPlayPaiCoins((Integer) stringObjectMap.get("MemberCoins"));
                    }else {
                    } else {
                        rechargeRecords.setPlayPaiCoins((Integer) stringObjectMap.get("usersCoins"));
                    }
                }
@@ -185,9 +188,9 @@
        try {
            switch (request.getPayType()){
                case 1:
                    return WeChatPayment(code,request.getPayAmount());
                    return WeChatPayment(code,amount);
                case 2:
                    return AlipayPayment(code,request.getPayAmount());
                    return AlipayPayment(code,amount);
                default:
                    break;
            }
@@ -332,4 +335,11 @@
        return null;
    }
    // 对数据进行分页处理的方法
    private static Page<RechargesDetail> getPage(List<RechargesDetail> dataList, Pageable pageable) {
        int start = (int) pageable.getOffset();
        int end = Math.min((start + pageable.getPageSize()), dataList.size());
        return new PageImpl<>(dataList.subList(start, end), pageable, dataList.size());
    }
}