无关风月
5 天以前 4742874ad840d7e1e3ac79dc288b38e9a642319d
cloud-server-activity/src/main/java/com/dsh/activity/service/impl/PayHuiminServiceImpl.java
@@ -19,8 +19,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,22 +55,44 @@
                    .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;
    }
@@ -81,6 +105,15 @@
    public ResultUtil<?> refund(Integer id) throws AlipayApiException {
        TPayHuimin payHuimin = this.getById(id);
        if (Objects.nonNull(payHuimin)) {
            // 后台录入订单直接修改为已退款
            if (payHuimin.getPaymentType()==3){
                payHuimin.setStatus(3);
                payHuimin.setRefundStatus(3);
                payHuimin.setRefundNumber(payHuimin.getCode());
                payHuimin.setRefundTime(new Date());
                this.updateById(payHuimin);
                return ResultUtil.success();
            }
            Integer count = huiminRecordService.lambdaQuery()
                    .eq(THuiminRecord::getPayId, payHuimin.getId())
                    .count();