刘帅
2026-09-08 572df690f72ed4a077d934823f261dec39b3cc7d
cloud-server-activity/src/main/java/com/dsh/activity/service/impl/PayHuiminServiceImpl.java
@@ -9,6 +9,7 @@
import com.dsh.activity.entity.THuiminRecord;
import com.dsh.activity.entity.TPayHuimin;
import com.dsh.activity.entity.TStudent;
import com.dsh.activity.enums.HuiminCardPaymentTypeEnum;
import com.dsh.activity.feignclient.account.AppUserClient;
import com.dsh.activity.feignclient.account.StudentClient;
import com.dsh.activity.feignclient.account.model.AppUser;
@@ -19,8 +20,10 @@
import com.dsh.activity.util.DateUtil;
import com.dsh.activity.util.PayMoneyUtil;
import com.dsh.activity.util.ResultUtil;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -53,27 +56,49 @@
                    .eq(THuiminRecord::getPayId, record.getId()));
            record.setUseTimes(list.size());
        }
        if (CollUtil.isNotEmpty(records)){
            List<Integer> appUserIdList = records.stream().map(SalesDetailVO::getAppUserId).collect(Collectors.toList());
            List<AppUser> appUserList = appUserClient.queryAppUserBatch(appUserIdList);
            Map<Integer, AppUser> appUserMap = appUserList.stream().collect(Collectors.toMap(AppUser::getId, appUser -> appUser));
            records.forEach(item->{
                AppUser appUser = appUserMap.get(item.getAppUserId());
                if (Objects.nonNull(appUser)){
                    item.setUserName(appUser.getName());
                    item.setPhone(appUser.getPhone());
        for (SalesDetailVO record : records) {
            AppUser appUser = appUserClient.queryAppUser(record.getAppUserId());
            if (Objects.nonNull(appUser)){
                record.setUserName(appUser.getName());
                record.setPhone(appUser.getPhone());
            }
            StringBuilder stringBuilder = new StringBuilder();
            String[] split = record.getStudentId().split(",");
            for (String s : split) {
                String replace = s.replace(" ", "");
                List<TStudent> studentById = studentClient.getStudentByIds(replace);
                if (!studentById.isEmpty()){
                    stringBuilder.append(studentById.get(0).getName()+",");
                }
                List<TStudent> studentList = studentClient.getStudentByIds(item.getStudentId());
                if (CollUtil.isNotEmpty(studentList)){
                    item.setStudentName(studentList.stream().map(TStudent::getName).collect(Collectors.joining(",")));
                }
            });
            }
            String string = stringBuilder.toString();
            if (StringUtils.hasLength(string)) {
                String stringWithoutLastCharacter = string.substring(0, string.length() - 1);
                record.setStudentName(stringWithoutLastCharacter);
            }
        }
//        if (CollUtil.isNotEmpty(records)){
//            List<Integer> appUserIdList = records.stream().map(SalesDetailVO::getAppUserId).collect(Collectors.toList());
//            List<AppUser> appUserList = appUserClient.queryAppUserBatch(appUserIdList);
//            Map<Integer, AppUser> appUserMap = appUserList.stream().collect(Collectors.toMap(AppUser::getId, appUser -> appUser));
//            records.forEach(item->{
//                AppUser appUser = appUserMap.get(item.getAppUserId());
//                if (Objects.nonNull(appUser)){
//                    item.setUserName(appUser.getName());
//                    item.setPhone(appUser.getPhone());
//                }
//                List<TStudent> studentList = studentClient.getStudentByIds(item.getStudentId());
//                if (CollUtil.isNotEmpty(studentList)){
//                    item.setStudentName(studentList.stream().map(TStudent::getName).collect(Collectors.joining(",")));
//                }
//            });
//        }
        return salesDetailVOPage;
    }
    @Override
    public Map<String, BigDecimal> getStaticsData(HuiminPayQuery query) {
        query.setGiftPaymentType(HuiminCardPaymentTypeEnum.GIFT.getCode());
        return baseMapper.getStaticsData(query);
    }
@@ -81,6 +106,10 @@
    public ResultUtil<?> refund(Integer id) throws AlipayApiException {
        TPayHuimin payHuimin = this.getById(id);
        if (Objects.nonNull(payHuimin)) {
            // 赠送订单不产生支付金额,禁止退款。
            if (HuiminCardPaymentTypeEnum.isGift(payHuimin.getPaymentType())){
                throw new IllegalArgumentException("赠送惠民卡不允许退款");
            }
            Integer count = huiminRecordService.lambdaQuery()
                    .eq(THuiminRecord::getPayId, payHuimin.getId())
                    .count();