| | |
| | | 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; |
| | |
| | | List<SalesDetailVO> records = salesDetailVOPage.getRecords(); |
| | | for (SalesDetailVO record : records) { |
| | | List<THuiminRecord> list = huiminRecordService.list(new LambdaQueryWrapper<THuiminRecord>() |
| | | .eq(THuiminRecord::getAppUserId, record.getAppUserId()) |
| | | .eq(THuiminRecord::getHuiminCardId, record.getCarId())); |
| | | .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; |
| | | } |
| | | |
| | |
| | | public ResultUtil<?> refund(Integer id) throws AlipayApiException { |
| | | TPayHuimin payHuimin = this.getById(id); |
| | | if (Objects.nonNull(payHuimin)) { |
| | | Integer count = huiminRecordService.lambdaQuery().eq(THuiminRecord::getAppUserId, payHuimin.getAppUserId()) |
| | | .eq(THuiminRecord::getHuiminCardId, payHuimin.getCardId()) |
| | | .lt(THuiminRecord::getInsertTime, DateUtil.addDay(payHuimin.getPaymentTime(),7)) |
| | | // 后台录入订单直接修改为已退款 |
| | | 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(); |
| | | if (count > 0 || new Date().after(DateUtil.addDay(payHuimin.getPaymentTime(),7))) { |
| | | //超过七日或者七日内有使用记录的退款:更改状态,实际退款线下操作。 |
| | |
| | | } else { |
| | | if (payHuimin.getPaymentType() == 1) { |
| | | Map<String, String> map = payMoneyUtil.wxRefund(payHuimin.getOrderNumber(), payHuimin.getCode(), |
| | | payHuimin.getSalesMoney().toString(), payHuimin.getSalesMoney().toString(), "/base/worldCup/wxRefundWorldCupCallback"); |
| | | payHuimin.getSalesMoney().toString(), payHuimin.getSalesMoney().toString(), "/base/huimin/callBack/wxRefundHuiminCallback"); |
| | | if (!"SUCCESS".equals(map.get("return_code"))) { |
| | | System.err.println("-------------微信退款失败---------"); |
| | | System.err.println(map.get("return_msg")); |
| | |
| | | */ |
| | | @Override |
| | | public List<SalesDetailVO> exportData(HuiminPayQuery query) { |
| | | return baseMapper.exportData(query); |
| | | List<SalesDetailVO> records = baseMapper.exportData(query); |
| | | 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 records; |
| | | } |
| | | } |