|
@@ -7,14 +7,9 @@ import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.*;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
-import com.ym.mec.thirdparty.storage.StoragePluginContext;
|
|
|
-import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
|
-import com.ym.mec.util.upload.UploadUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
@@ -29,14 +24,11 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.system.ApplicationHome;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -137,7 +129,7 @@ public class ExportController extends BaseController {
|
|
|
@Autowired
|
|
|
private ClassGroupService classGroupService;
|
|
|
@Autowired
|
|
|
- private StoragePluginContext storagePluginContext;
|
|
|
+ private ExportService exportService;
|
|
|
|
|
|
@ApiOperation(value = "班级列表导出")
|
|
|
@PostMapping("export/classGroup")
|
|
@@ -980,7 +972,7 @@ public class ExportController extends BaseController {
|
|
|
@PostMapping("order/musicalListDetailExport")
|
|
|
@PreAuthorize("@pcs.hasPermissions('order/musicalListDetailExport')")
|
|
|
public void musicalListDetailExport(HttpServletResponse response, String musicGroupId) throws IOException {
|
|
|
- List<MusicalListDetailDto> musicalList = studentPaymentOrderDetailService.getMusicalListDetail(musicGroupId,null);
|
|
|
+ List<MusicalListDetailDto> musicalList = studentPaymentOrderDetailService.getMusicalListDetail(musicGroupId, null);
|
|
|
if (musicalList.size() > 50000) {
|
|
|
throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
}
|
|
@@ -1018,7 +1010,7 @@ public class ExportController extends BaseController {
|
|
|
if (studentApplyDetail.size() <= 0) {
|
|
|
throw new BizException("没有可导出的记录");
|
|
|
}
|
|
|
- List<MusicalListDetailDto> musicalListDetails = studentPaymentOrderDetailService.getMusicalListDetail(queryInfo.getMusicGroupId(),null);
|
|
|
+ List<MusicalListDetailDto> musicalListDetails = studentPaymentOrderDetailService.getMusicalListDetail(queryInfo.getMusicGroupId(), null);
|
|
|
for (StudentApplyDetailDto studentApplyDetailDto : studentApplyDetail) {
|
|
|
for (MusicalListDetailDto musicalListDetail : musicalListDetails) {
|
|
|
if (!musicalListDetail.getUserId().equals(studentApplyDetailDto.getStudentId())) continue;
|
|
@@ -1085,7 +1077,7 @@ public class ExportController extends BaseController {
|
|
|
@ApiOperation(value = "订单列表导出")
|
|
|
@RequestMapping("export/orderList")
|
|
|
@PreAuthorize("@pcs.hasPermissions('export/orderList')")
|
|
|
- public HttpResponseResult orderList(StudentPaymentOrderQueryInfo queryInfo) throws IOException {
|
|
|
+ public HttpResponseResult orderList(StudentPaymentOrderQueryInfo queryInfo) throws Exception {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
Employee employee = employeeDao.get(sysUser.getId());
|
|
|
if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && "3".equals(queryInfo.getOrderType())) {
|
|
@@ -1102,213 +1094,20 @@ public class ExportController extends BaseController {
|
|
|
queryInfo.setUserIds(userIds);
|
|
|
}
|
|
|
queryInfo.setPage(1);
|
|
|
- queryInfo.setRows(49999);
|
|
|
+ queryInfo.setRows(50000);
|
|
|
queryInfo.setIsExport(true);
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
- List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
|
|
|
- if (studentPaymentOrderExportDtos.size() > 50000) {
|
|
|
- throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
- }
|
|
|
- long i = 1;
|
|
|
- for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
|
|
|
- if (row.getActualAmount() == null) {
|
|
|
- row.setActualAmount(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- if (row.getBalancePaymentAmount() == null) {
|
|
|
- row.setBalancePaymentAmount(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- if (row.getMemo() == null) {
|
|
|
- row.setMemo("");
|
|
|
- }
|
|
|
- BigDecimal transferFee = BigDecimal.ZERO;
|
|
|
- if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
|
|
|
- FeeFlagNumDto countFeeFlagNum = studentPaymentRouteOrderDao.getCountFeeFlagNum(row.getOrderNo());
|
|
|
- if (countFeeFlagNum.getTotalNum() > countFeeFlagNum.getYesNum()) {
|
|
|
- transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
|
|
|
- List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(row.getOrderNo());
|
|
|
- for (StudentPaymentRouteOrder routeOrder : routeOrders) {
|
|
|
- transferFee = transferFee.add(routeOrder.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- row.setTransferFee(transferFee);
|
|
|
-
|
|
|
- String goodsName = "";
|
|
|
- if (row.getOrderDetailList() != null) {
|
|
|
- for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
|
|
|
- switch (orderDetail.getType()) {
|
|
|
- case COURSE:
|
|
|
- case CLASSROOM:
|
|
|
- case SINGLE:
|
|
|
- case MIX:
|
|
|
- case COMPREHENSIVE:
|
|
|
- case ENLIGHTENMENT:
|
|
|
- case TRAINING_SINGLE:
|
|
|
- case TRAINING_MIX:
|
|
|
- case MUSIC_NETWORK:
|
|
|
- case HIGH:
|
|
|
- case HIGH_ONLINE:
|
|
|
- case HIGH_ONLINE_COURSE:
|
|
|
- row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
|
|
|
- break;
|
|
|
- case MUSICAL:
|
|
|
- if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
|
|
|
- BigDecimal leaseFee = orderDetail.getPrice();
|
|
|
- if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
|
|
|
- }
|
|
|
- row.setLeaseFee(leaseFee);
|
|
|
- } else {
|
|
|
- row.setMusicalFee(orderDetail.getPrice());
|
|
|
- }
|
|
|
- break;
|
|
|
- case ACCESSORIES:
|
|
|
- case TEACHING:
|
|
|
- row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
|
|
|
- break;
|
|
|
- case OTHER:
|
|
|
- row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (row.getGoodsList() != null) {
|
|
|
- goodsName = row.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(goodsName)) {
|
|
|
- row.setMemo(goodsName);
|
|
|
- }
|
|
|
- //专业
|
|
|
- if (row.getGroupType().equals(GroupType.VIP)) {
|
|
|
- row.setVipCourseFee(row.getActualAmount());
|
|
|
- VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
|
|
|
- if (vipGroupInfo != null) {
|
|
|
- row.setSchoolName(vipGroupInfo.getSchoolName());
|
|
|
- row.setSubjectName(vipGroupInfo.getSubjectName());
|
|
|
- }
|
|
|
- } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
|
|
|
- //考级报名
|
|
|
- if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
|
|
|
- String[] feeTypes = row.getMemo().split(";");
|
|
|
- List<String> feeTypeList = Arrays.asList(feeTypes);
|
|
|
- for (String feeTypeStr : feeTypeList) {
|
|
|
- int index = feeTypeStr.lastIndexOf(":");
|
|
|
- if (index < 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
|
|
|
- if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
|
|
|
- }
|
|
|
- if (feeTypeStr.contains("VIP")) {
|
|
|
- row.setVipCourseFee(typeFee);
|
|
|
- } else if (feeTypeStr.contains("网管课")) {
|
|
|
- row.setPracticeCourseFee(typeFee);
|
|
|
- } else if (feeTypeStr.contains("乐理课")) {
|
|
|
- row.setTheoryCourseFee(typeFee);
|
|
|
- }
|
|
|
- }
|
|
|
- row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
|
|
|
- } else {
|
|
|
- if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
|
|
|
- row.setDegreeFee(row.getActualAmount());
|
|
|
- } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
|
|
|
- row.setPracticeCourseFee(row.getActualAmount());
|
|
|
- } else {
|
|
|
- row.setOtherFee(row.getActualAmount());
|
|
|
- }
|
|
|
- }
|
|
|
- if (row.getChargeType() != null) {
|
|
|
- for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
|
|
|
- if (!chargeType.getCode().equals(row.getChargeType())) continue;
|
|
|
- row.setSporadicType(chargeType.getMsg());
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
|
|
|
- row.setPracticeCourseFee(row.getActualAmount());
|
|
|
- PracticeCourseDto practiceGroup = practiceGroupDao.findByGroupId(Integer.parseInt(row.getMusicGroupId()));
|
|
|
- if (practiceGroup != null) {
|
|
|
- row.setSubjectName(practiceGroup.getSubjectName());
|
|
|
- }
|
|
|
- } else {
|
|
|
- StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
|
|
|
- row.setMusicalFee(feeByType.getMusicalFee());
|
|
|
- row.setTeachingFee(feeByType.getTeachingFee());
|
|
|
- row.setRepairFee(feeByType.getRepairFee());
|
|
|
- row.setOtherFee(feeByType.getOtherFee());
|
|
|
- if (row.getGroupType().equals(GroupType.MUSIC)) {
|
|
|
- StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
|
|
|
- if (studentRegistration != null) {
|
|
|
- row.setSubjectName(studentRegistration.getSubjectName());
|
|
|
- row.setSchoolName(studentRegistration.getSchoolName());
|
|
|
- row.setCooperationOrganName(studentRegistration.getRemark());
|
|
|
- }
|
|
|
- row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()));
|
|
|
- } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
|
|
|
- row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
|
|
|
- } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
|
|
|
- row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()));
|
|
|
- row.setTransferFee(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- }
|
|
|
- //如果合作单位不存在取学员的第一个乐团的合作单位和教学点
|
|
|
- if (row.getCooperationOrganName() == null) {
|
|
|
- CooperationOrgan cooperationOrgan = musicGroupDao.findUserMusicGroupCooperationOrgan(row.getUserId());
|
|
|
- if (cooperationOrgan != null) {
|
|
|
- row.setCooperationOrganName(cooperationOrgan.getName());
|
|
|
- }
|
|
|
- }
|
|
|
- if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
|
|
|
- row.setMusicGroupId("");
|
|
|
- }
|
|
|
- String paymentChannel = "";
|
|
|
- if (row.getPaymentChannel() == null) {
|
|
|
- } else if (row.getPaymentChannel().equals("YQPAY")) {
|
|
|
- paymentChannel = "双乾";
|
|
|
- } else if (row.getPaymentChannel().equals("ADAPAY")) {
|
|
|
- paymentChannel = "汇付";
|
|
|
- } else if (row.getPaymentChannel().equals("BALANCE")) {
|
|
|
- paymentChannel = "余额";
|
|
|
- }
|
|
|
- row.setPaymentChannel(paymentChannel);
|
|
|
- row.setId(i);
|
|
|
- i++;
|
|
|
+ int count = studentPaymentOrderDao.queryCount(params);
|
|
|
+ if (count <= 0) {
|
|
|
+ return failed("没有可导出的数据");
|
|
|
}
|
|
|
|
|
|
- String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath()+ "/";
|
|
|
- File file = new File(basePath+"orderList-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(file);
|
|
|
-
|
|
|
- HSSFWorkbook workbook = null;
|
|
|
- try {
|
|
|
- String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
|
|
|
- "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
|
|
|
- String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
|
|
|
- "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
|
|
|
- workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
|
|
|
- workbook.write(fileOutputStream);
|
|
|
- fileOutputStream.getFD().sync();
|
|
|
- fileOutputStream.close();
|
|
|
-
|
|
|
- String folder = UploadUtil.getFileFloder();
|
|
|
- String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,"" + folder, file);
|
|
|
- return succeed(url);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- fileOutputStream.close();
|
|
|
- workbook.close();
|
|
|
- file.delete();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ if (count > 50000) {
|
|
|
+ return failed("数据集太大,不能导出.最大数据集不能超过50000");
|
|
|
}
|
|
|
- return failed("导出失败");
|
|
|
+ exportService.orderList(params);
|
|
|
+ return succeed("导出成功,请到下载列表查看");
|
|
|
}
|
|
|
|
|
|
|