From cb37b6ea0a47d2505df1c5974a13c97e8e7a7228 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 1 Aug 2024 17:52:41 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hfkj/service/order/OrderPaySuccessService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index d65f357..e31cf64 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -25,6 +25,7 @@ import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.sysenum.GoodsVpdSourceEnum; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderCinemaStatusEnum; +import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -122,6 +123,7 @@ public class OrderPaySuccessService { JSONObject dataObject = (JSONObject) data; couponNo.setExpireTime(dataObject.getDate("validEndDate")); couponNo.setGoodsVpdSourceCouNo(dataObject.getString("couNo")); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); orderCouponNoService.editData(couponNo); } } @@ -137,6 +139,7 @@ public class OrderPaySuccessService { for (Object data : codeList) { couponNo.setExpireTime(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); couponNo.setGoodsVpdSourceCouNo(ChongQingCNPCCouponService.decryptCouponCode(String.valueOf(data))); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); orderCouponNoService.editData(couponNo); } } @@ -153,6 +156,7 @@ public class OrderPaySuccessService { JSONObject object = JSONObject.parseObject(data); couponNo.setExpireTime(vpd.getSalesEndTime()); couponNo.setGoodsVpdSourceCouNo(object.getString("voucher")); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); orderCouponService.editData(orderCoupon); } else if (vpd.getSource() == GoodsVpdSourceEnum.type10.getCode()) { @@ -164,6 +168,7 @@ public class OrderPaySuccessService { JSONObject object = jsonObject.getJSONObject("data"); couponNo.setExpireTime(vpd.getSalesEndTime()); couponNo.setGoodsVpdSourceCouNo(object.getString("couponCode")); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); orderCouponNoService.editData(couponNo); } From 5f73901b7d3abbfdb07da2b81bb934b21dcb85eb Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 1 Aug 2024 18:02:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hfkj/service/order/OrderPaySuccessService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index 4c5feaa..4a4493f 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -23,9 +23,7 @@ import com.hfkj.service.goods.GoodsVpdService; import com.hfkj.service.goods.impl.GoodsSpecsServiceImpl; import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.sysenum.GoodsVpdSourceEnum; -import com.hfkj.sysenum.order.OrderChildProductTypeEnum; -import com.hfkj.sysenum.order.OrderCinemaStatusEnum; -import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; +import com.hfkj.sysenum.order.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -188,6 +186,7 @@ public class OrderPaySuccessService { orderCoupon.setPayType(order.getPayType()); orderCoupon.setPaySerialNo(order.getPaySerialNo()); orderCoupon.setPayTime(order.getPayTime()); + orderCoupon.setStatus(OrderChildStatusEnum.status2.getCode()); orderCouponService.editData(orderCoupon); /// 增加销量 From 48431670fce15edc544819b87eb93ac4bd9066c1 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 2 Aug 2024 10:04:51 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/OrderCouponController.java | 21 +++++++++++++++++-- .../com/hfkj/dao/BsOrderCouponMapperExt.java | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index bde405a..ae4ed89 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -5,12 +5,16 @@ import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.SessionObject; +import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrderCoupon; import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.order.OrderCouponModel; import com.hfkj.service.coupon.BsOrderCouponNoService; import com.hfkj.service.coupon.BsOrderCouponService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -41,6 +45,8 @@ public class OrderCouponController { private BsOrderCouponService orderCouponService; @Resource private BsOrderCouponNoService orderCouponNoService; + @Resource + private UserCenter userCenter; @RequestMapping(value="/queryCouNo",method = RequestMethod.GET) @ResponseBody @@ -98,6 +104,12 @@ public class OrderCouponController { @RequestParam(value = "pageSize" , required = true) Integer pageSize) { try { Map param = new HashMap<>(); + SecUserSessionObject userSessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (SecUserObjectTypeEnum.type1.getCode() == userSessionObject.getAccount().getObjectType()) { + + } else if (SecUserObjectTypeEnum.type2.getCode() == userSessionObject.getAccount().getObjectType()) { + param.put("merId", userSessionObject.getAccount().getObjectId()); + } param.put("orderNo", orderNo); param.put("userPhone", userPhone); param.put("tradeStatus", tradeStatus); @@ -120,7 +132,7 @@ public class OrderCouponController { @RequestMapping(value="/export",method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "查询交易订单列表") + @ApiOperation(value = "导出订单") public ResponseData export(@RequestParam(value = "orderNo" , required = false) String orderNo, @RequestParam(value = "userPhone" , required = false) String userPhone, @RequestParam(value = "tradeStatus" , required = false) Integer tradeStatus, @@ -133,6 +145,12 @@ public class OrderCouponController { @RequestParam(value = "createTimeE" , required = false) Long createTimeE) { try { Map param = new HashMap<>(); + SecUserSessionObject userSessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (SecUserObjectTypeEnum.type1.getCode() == userSessionObject.getAccount().getObjectType()) { + + } else if (SecUserObjectTypeEnum.type2.getCode() == userSessionObject.getAccount().getObjectType()) { + param.put("merId", userSessionObject.getAccount().getObjectId()); + } param.put("orderNo", orderNo); param.put("userPhone", userPhone); param.put("tradeStatus", tradeStatus); @@ -145,7 +163,6 @@ public class OrderCouponController { param.put("createTimeE", createTimeE); List orderList = orderCouponService.getOrderList(param); - return ResponseMsgUtil.success(orderList); } catch (Exception e) { diff --git a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java index 7054385..f7b5c3e 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java @@ -43,6 +43,7 @@ public interface BsOrderCouponMapperExt { " bs_order_coupon_no a" + " LEFT JOIN bs_order_coupon b on a.coupon_order_id = b.id" + " WHERE 1 = 1" + + " and b.mer_id = #{param.merId} " + " and b.order_no like concat('%',#{param.orderNo},'%') " + " and b.child_order_no = #{param.orderChildNo} " + " and b.user_phone like concat('%',#{param.userPhone},'%') " + From f6f120d9e6733e15a091d7e755bc8616a0242dc3 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 5 Aug 2024 10:38:37 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/OrderCouponController.java | 44 ++++- service/pom.xml | 10 + .../ExcelFillCellMergeStrategyUtils.java | 107 ++++++++++ .../utils/MergeCellStrategyHandler.java | 186 ++++++++++++++++++ .../hfkj/model/order/OrderCouponModel.java | 86 +++++++- .../BsOrderAfterSalesApplyServiceImpl.java | 4 + .../sysenum/order/OrderChildStatusEnum.java | 9 + .../order/OrderCouponNoStatusEnum.java | 9 + .../sysenum/order/OrderPayChannelEnum.java | 9 + .../hfkj/sysenum/order/OrderPayTypeEnum.java | 9 + 10 files changed, 464 insertions(+), 9 deletions(-) create mode 100644 service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java create mode 100644 service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index ae4ed89..0d5ef70 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -1,5 +1,6 @@ package com.order.controller.business; +import com.alibaba.excel.EasyExcel; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; @@ -7,7 +8,10 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ExcelFillCellMergeStrategyUtils; +import com.hfkj.common.utils.MergeCellStrategyHandler; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrderCoupon; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; @@ -15,6 +19,10 @@ import com.hfkj.model.order.OrderCouponModel; import com.hfkj.service.coupon.BsOrderCouponNoService; import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.order.OrderChildStatusEnum; +import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; +import com.hfkj.sysenum.order.OrderPayChannelEnum; +import com.hfkj.sysenum.order.OrderPayTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -26,9 +34,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.io.File; +import java.util.*; /** * @className: OrderCouponController @@ -163,7 +170,36 @@ public class OrderCouponController { param.put("createTimeE", createTimeE); List orderList = orderCouponService.getOrderList(param); - return ResponseMsgUtil.success(orderList); + for (OrderCouponModel coupon : orderList) { + if (coupon.getPayChannel() != null) { + coupon.setPayChannel(OrderPayChannelEnum.getData(Integer.valueOf(coupon.getPayChannel())).getName()); + } + if (coupon.getPayType() != null) { + coupon.setPayType(OrderPayTypeEnum.getData(Integer.valueOf(coupon.getPayType())).getName()); + } + coupon.setTradeStatus(OrderChildStatusEnum.getData(Integer.valueOf(coupon.getTradeStatus())).getName()); + coupon.setCouStatus(OrderCouponNoStatusEnum.getData(Integer.valueOf(coupon.getCouStatus())).getName()); + coupon.setExceptionStatus(Boolean.getBoolean(coupon.getExceptionStatus())?"是":"否"); + } + + String fileUrl = CommonSysConst.getSysConfig().getFileUrl() + "/temporary/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } + //设置第几列开始合并 + int[] mergeColumnIndex = {0,1,2,17}; + //设置第几行开始合并 + int mergeRowIndex = 1; + + EasyExcel.write(fileUrl+pathName) + .head(OrderCouponModel.class) + .sheet("虚拟商品订单") + .registerWriteHandler(new ExcelFillCellMergeStrategyUtils(mergeRowIndex, mergeColumnIndex)) + .doWrite(orderList); + + return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("error!",e); diff --git a/service/pom.xml b/service/pom.xml index 594c1dd..3fdd8d9 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -256,5 +256,15 @@ false + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + diff --git a/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java b/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java new file mode 100644 index 0000000..440d0ae --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java @@ -0,0 +1,107 @@ +package com.hfkj.common.utils; + +import com.alibaba.excel.metadata.CellData; +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.write.handler.CellWriteHandler; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; + +import java.util.List; + +public class ExcelFillCellMergeStrategyUtils implements CellWriteHandler { + + /** + * 需要合并列的下标,从0开始 + */ + private int[] mergeColumnIndex; + /** + * 从第几行开始合并,表头下标为0 + */ + private int mergeRowIndex; + + public ExcelFillCellMergeStrategyUtils(int mergeRowIndex, int[] mergeColumnIndex) { + this.mergeRowIndex = mergeRowIndex; + this.mergeColumnIndex = mergeColumnIndex; + } + + @Override + public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { + + } + + @Override + public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean aBoolean) { + + } + + @Override + public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer integer, Boolean aBoolean) { + + } + + @Override + public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List list, Cell cell, Head head, Integer integer, Boolean aBoolean) { + //当前行 + int curRowIndex = cell.getRowIndex(); + //当前列 + int curColIndex = cell.getColumnIndex(); + + if (curColIndex == 0) { + Row preRow = cell.getSheet().getRow(curRowIndex - 1); + if (preRow == null) { + // 当获取不到上一行数据时,使用缓存sheet中数据 + preRow = writeSheetHolder.getCachedSheet().getRow(curRowIndex - 1); + } + if (preRow != null) { + if (cell.getStringCellValue().equals(preRow.getCell(0).getStringCellValue())) { + for (int i = 0; i < mergeColumnIndex.length; i++) { + if (curColIndex == mergeColumnIndex[i]) { + mergeWithPrevRow(writeSheetHolder, cell, i, i); + break; + } + } + } + } + } + // preRow.getCell(curColIndex); + +/* if (curRowIndex > mergeRowIndex) { + for (int i = 0; i < mergeColumnIndex.length; i++) { + if (curColIndex == mergeColumnIndex[i]) { + mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex); + break; + } + } + }*/ + + } + + private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) { + Sheet sheet = writeSheetHolder.getSheet(); + List mergeRegions = sheet.getMergedRegions(); + boolean isMerged = false; + for (int i = 0; i < mergeRegions.size() && !isMerged; i++) { + CellRangeAddress cellRangeAddr = mergeRegions.get(i); + // 若上一个单元格已经被合并,则先移出原有的合并单元,再重新添加合并单元 + if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) { + sheet.removeMergedRegion(i); + cellRangeAddr.setLastRow(curRowIndex); + sheet.addMergedRegion(cellRangeAddr); + isMerged = true; + } + } + // 若上一个单元格未被合并,则新增合并单元 + if (!isMerged) { + CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, + curColIndex); + sheet.addMergedRegion(cellRangeAddress); + } + + } + +} diff --git a/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java b/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java new file mode 100644 index 0000000..3213b2b --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java @@ -0,0 +1,186 @@ +package com.hfkj.common.utils; + +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.write.merge.AbstractMergeStrategy; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; + +import java.util.*; + +/** + * @className: MergeCellStrategyHandler + * @author: HuRui + * @date: 2024/8/2 + **/ +public class MergeCellStrategyHandler extends AbstractMergeStrategy { + /** + * 相同列合并 + */ + private boolean alikeColumn; + + /** + * 相同行合并 + */ + private boolean alikeRow; + + /** 开始进行合并的行index */ + private int rowIndex; + + /** 跨行合并的列index */ + private Set columns; + + private int currentRowIndex = 0; + + public MergeCellStrategyHandler(boolean alikeColumn, boolean alikeRow, int rowIndex, Set columns){ + this.alikeColumn = alikeColumn; + this.alikeRow = alikeRow; + this.rowIndex = rowIndex; + this.columns = columns; + } + + /** + * 指定是否进行跨列合并单元格 + * @param alikeColumn + * @param rowIndex + */ + public MergeCellStrategyHandler(boolean alikeColumn, int rowIndex){ + this(alikeColumn, false, rowIndex, new HashSet<>()); + } + + /** + * 指定是否进行跨行合并单元格 + * @param alikeRow + * @param rowIndex + * @param columns + */ + public MergeCellStrategyHandler(boolean alikeRow, int rowIndex, Set columns){ + this(false, alikeRow, rowIndex, columns); + } + + + @Override + protected void merge(Sheet sheet, Cell cell, Head head, Integer integer) { + int rowId = cell.getRowIndex(); + currentRowIndex = rowId == currentRowIndex ? currentRowIndex : rowId; + if (rowIndex > rowId) { + return; + } + int columnId = cell.getColumnIndex(); + // 列合并 + if (alikeColumn && columnId > 0) { + String currentCellVal = this.getCellVal(cell); + Cell preCell = cell.getRow().getCell(columnId - 1); + String preCellVal = this.getCellVal(preCell); + if (null != currentCellVal && null != preCellVal && StringUtils.isNotBlank(preCellVal) && StringUtils.isNotBlank(currentCellVal)) { + // 当前单元格内容与上一个单元格内容相等,进行合并处理 + if (preCellVal.equals(currentCellVal)) { + CellRangeAddress rangeAddress = new CellRangeAddress(currentRowIndex, currentRowIndex, columnId - 1, columnId); + rangeAddress = this.findExistAddress(sheet, rangeAddress, currentCellVal); + if (null != rangeAddress) { + sheet.addMergedRegion(rangeAddress); + } + } + } + } + // 行合并 + if (alikeRow && rowIndex < rowId && columns.contains(columnId)) { + String currentCellVal = this.getCellVal(cell); + Cell preCell = sheet.getRow(rowId - 1).getCell(columnId); + String preCellVal = this.getCellVal(preCell); + if (null != currentCellVal && null != preCellVal && !preCellVal.isBlank() && !currentCellVal.isBlank()) { + // 当前单元格内容与上一行单元格内容相等,进行合并处理 + if (preCellVal.equals(currentCellVal)) { + //sheet.validateMergedRegions(); + CellRangeAddress rangeAddress = new CellRangeAddress(currentRowIndex - 1, currentRowIndex, columnId, columnId); + rangeAddress = this.findExistAddress(sheet, rangeAddress, currentCellVal); + if (null != rangeAddress) { + sheet.addMergedRegion(rangeAddress); + } + } + } + } + + } + + /** + * 合并单元格地址范围,发现存在相同的地址则进行扩容合并 + * + * @param isColumn true:跨列合并 false:跨行合并 + * @param sheet + * @param rangeAddress : + * @param currentVal 当前单元格中的值 + * @return + */ + private CellRangeAddress findExistAddress(Sheet sheet, CellRangeAddress rangeAddress, String currentVal) { + List mergedRegions = sheet.getMergedRegions(); + int existIndex = 0; + Map existIdexMap = new LinkedHashMap<>(); + if (null != mergedRegions && !mergedRegions.isEmpty()) { + //验证当前合并的单元格是否存在重复(fixme 重复问题待处理!!!) + for (CellRangeAddress mergedRegion : mergedRegions) { + if (mergedRegion.intersects(rangeAddress)) { + existIdexMap.put(existIndex, mergedRegion); + } + existIndex++; + } + } + if (existIdexMap.isEmpty()) { + return rangeAddress; + } + List existIndexList = new ArrayList<>(existIdexMap.size()); + for (Map.Entry addressEntry : existIdexMap.entrySet()) { + CellRangeAddress exist = addressEntry.getValue(); + // 自动进行单元格合并处理 + int firstRow = rangeAddress.getFirstRow(); + int lastRow = rangeAddress.getLastRow(); + int firstColumn = rangeAddress.getFirstColumn(); + int lastColumn = rangeAddress.getLastColumn(); + + int firstRow1 = exist.getFirstRow(); + int lastRow1 = exist.getLastRow(); + int firstColumn1 = exist.getFirstColumn(); + int lastColumn1 = exist.getLastColumn(); + // 跨行合并 最后一列相等, 行不相等 + if (lastRow > lastRow1 && lastColumn == lastColumn1) { + // 检查进行跨行合并的单元格是否已经存在跨列合并 + if (lastColumn > 0 && firstColumn1 != lastColumn1) { + // 获取当前单元格的前一列单元格 + String cellVal = this.getCellVal(sheet.getRow(lastRow).getCell(lastColumn - 1)); + if (null != cellVal && cellVal.equals(currentVal)) { + exist.setLastRow(lastRow); + } + } else { + exist.setLastRow(lastRow); + } + rangeAddress = exist; + existIndexList.add(addressEntry.getKey()); + } + + // 跨列合并 行相等,列不相等 + if (lastColumn > lastColumn1 && firstRow == firstRow1 ) { + exist.setLastColumn(lastColumn); + rangeAddress = exist; + existIndexList.add(addressEntry.getKey()); + } + } + // 移除已经存在且冲突的合并数据 + if (existIndexList.isEmpty()) { + rangeAddress = null; + }else { + sheet.removeMergedRegions(existIdexMap.keySet()); + } + return rangeAddress; + } + + private String getCellVal(Cell cell) { + String val = null; + try { + val = cell.getStringCellValue(); + }catch (Exception e){ + System.out.printf("读取单元格内容失败:行%d 列%d %n", (cell.getRowIndex() + 1), (cell.getColumnIndex() + 1)); + } + return val; + } +} diff --git a/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java b/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java index ea80447..7c34453 100644 --- a/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java +++ b/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java @@ -1,5 +1,7 @@ package com.hfkj.model.order; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.Data; import java.math.BigDecimal; @@ -14,30 +16,104 @@ import java.util.Date; @Data public class OrderCouponModel { + @ColumnWidth(20) + @ExcelProperty("交易单号") public String orderNo; + + @ColumnWidth(15) + @ExcelProperty("商品单号") public String childOrderNo; + + @ColumnWidth(20) + @ExcelProperty("用户手机号") public String userPhone; + + @ColumnWidth(20) + @ExcelProperty("商品key") public String goodsKey; + + @ColumnWidth(30) + @ExcelProperty("商品名称") public String goodsName; + + @ColumnWidth(30) + @ExcelProperty("商品规格") public String goodsSpecsName; + + @ColumnWidth(20) + @ExcelProperty("商品价格") public String goodsPrice; + + @ColumnWidth(20) + @ExcelProperty("购买数量") public String goodsCount; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "订单金额"}) public BigDecimal totalPrice; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "总优惠"}) public BigDecimal totalDeductionPrice; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "优惠券优惠"}) public BigDecimal couponDiscountPrice; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "积分抵扣"}) public BigDecimal integralDiscountPrice; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "实付金额"}) public BigDecimal payRealPrice; - public Integer payChannel; - public Integer payType; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付渠道"}) + public String payChannel; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付方式"}) + public String payType; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付单号"}) public String paySerialNo; - public Integer tradeStatus; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "交易状态"}) + public String tradeStatus; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "创建时间"}) public Date createTime; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付时间"}) public Date payTime; + + @ColumnWidth(35) + @ExcelProperty("渠道订单号") public String channelOrderNo; + + @ColumnWidth(50) + @ExcelProperty("卡密") public String couNo; - public Integer couStatus; + + @ColumnWidth(20) + @ExcelProperty("卡密状态") + public String couStatus; + + @ColumnWidth(20) + @ExcelProperty("过期时间") public Date expireTime; - public String exceptionStatus; + + @ColumnWidth(20) + @ExcelProperty("完成时间") public Date finishTime; + @ColumnWidth(20) + @ExcelProperty("是否异常") + public String exceptionStatus; + } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java index bbed271..579556f 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java @@ -270,6 +270,10 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply BsOrderAfterSalesApplyExample example = new BsOrderAfterSalesApplyExample(); BsOrderAfterSalesApplyExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getLong(param, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(param, "merId")); + } + if (MapUtils.getLong(param, "userId") != null) { criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId")); } diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderChildStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderChildStatusEnum.java index 9fa6783..8164eb8 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderChildStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderChildStatusEnum.java @@ -3,6 +3,8 @@ package com.hfkj.sysenum.order; import lombok.Data; import lombok.Getter; +import java.util.Objects; + /** * @className: OrderChildStatusEnum * @author: HuRui @@ -50,4 +52,11 @@ public enum OrderChildStatusEnum { this.code = code; this.name = name; } + + public static OrderChildStatusEnum getData(Integer type) { + for (OrderChildStatusEnum ele : values()) { + if (Objects.equals(type,ele.getCode())) return ele; + } + return null; + } } diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderCouponNoStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderCouponNoStatusEnum.java index 9dd3cb1..da779e1 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderCouponNoStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderCouponNoStatusEnum.java @@ -2,6 +2,8 @@ package com.hfkj.sysenum.order; import lombok.Getter; +import java.util.Objects; + /** * 卡券编号订单状态 * @className: OrderCouponNoStatusEnum @@ -40,4 +42,11 @@ public enum OrderCouponNoStatusEnum { this.code = code; this.name = name; } + + public static OrderCouponNoStatusEnum getData(Integer type) { + for (OrderCouponNoStatusEnum ele : values()) { + if (Objects.equals(type,ele.getCode())) return ele; + } + return null; + } } diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderPayChannelEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderPayChannelEnum.java index d69b487..1bec449 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderPayChannelEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderPayChannelEnum.java @@ -2,6 +2,8 @@ package com.hfkj.sysenum.order; import lombok.Getter; +import java.util.Objects; + /** * 交易支付渠道 * @className: OrderPayModelEnum @@ -36,4 +38,11 @@ public enum OrderPayChannelEnum { this.code = code; this.name = name; } + + public static OrderPayChannelEnum getData(Integer type) { + for (OrderPayChannelEnum ele : values()) { + if (Objects.equals(type,ele.getCode())) return ele; + } + return null; + } } diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderPayTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderPayTypeEnum.java index 0c5b674..56d297d 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderPayTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderPayTypeEnum.java @@ -2,6 +2,8 @@ package com.hfkj.sysenum.order; import lombok.Getter; +import java.util.Objects; + /** * 交易支付类型 * @className: OrderPayModelEnum @@ -36,4 +38,11 @@ public enum OrderPayTypeEnum { this.code = code; this.name = name; } + + public static OrderPayTypeEnum getData(Integer type) { + for (OrderPayTypeEnum ele : values()) { + if (Objects.equals(type,ele.getCode())) return ele; + } + return null; + } } From 1802d8a469160a2daed02ae8329e3f5e4c60d4a4 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 5 Aug 2024 10:49:19 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/OrderCouponController.java | 5 +- service/pom.xml | 10 - .../ExcelFillCellMergeStrategyUtils.java | 107 ---------- .../utils/MergeCellStrategyHandler.java | 186 ------------------ 4 files changed, 1 insertion(+), 307 deletions(-) delete mode 100644 service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java delete mode 100644 service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index 0d5ef70..cb3cb98 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -6,10 +6,7 @@ import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; -import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; -import com.hfkj.common.utils.ExcelFillCellMergeStrategyUtils; -import com.hfkj.common.utils.MergeCellStrategyHandler; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrderCoupon; @@ -196,7 +193,7 @@ public class OrderCouponController { EasyExcel.write(fileUrl+pathName) .head(OrderCouponModel.class) .sheet("虚拟商品订单") - .registerWriteHandler(new ExcelFillCellMergeStrategyUtils(mergeRowIndex, mergeColumnIndex)) + //.registerWriteHandler(new ExcelFillCellMergeStrategyUtils(mergeRowIndex, mergeColumnIndex)) .doWrite(orderList); return ResponseMsgUtil.success(pathName); diff --git a/service/pom.xml b/service/pom.xml index 3fdd8d9..594c1dd 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -256,15 +256,5 @@ false - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - - diff --git a/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java b/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java deleted file mode 100644 index 440d0ae..0000000 --- a/service/src/main/java/com/hfkj/common/utils/ExcelFillCellMergeStrategyUtils.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.hfkj.common.utils; - -import com.alibaba.excel.metadata.CellData; -import com.alibaba.excel.metadata.Head; -import com.alibaba.excel.write.handler.CellWriteHandler; -import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; -import com.alibaba.excel.write.metadata.holder.WriteTableHolder; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.util.CellRangeAddress; - -import java.util.List; - -public class ExcelFillCellMergeStrategyUtils implements CellWriteHandler { - - /** - * 需要合并列的下标,从0开始 - */ - private int[] mergeColumnIndex; - /** - * 从第几行开始合并,表头下标为0 - */ - private int mergeRowIndex; - - public ExcelFillCellMergeStrategyUtils(int mergeRowIndex, int[] mergeColumnIndex) { - this.mergeRowIndex = mergeRowIndex; - this.mergeColumnIndex = mergeColumnIndex; - } - - @Override - public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { - - } - - @Override - public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean aBoolean) { - - } - - @Override - public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer integer, Boolean aBoolean) { - - } - - @Override - public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List list, Cell cell, Head head, Integer integer, Boolean aBoolean) { - //当前行 - int curRowIndex = cell.getRowIndex(); - //当前列 - int curColIndex = cell.getColumnIndex(); - - if (curColIndex == 0) { - Row preRow = cell.getSheet().getRow(curRowIndex - 1); - if (preRow == null) { - // 当获取不到上一行数据时,使用缓存sheet中数据 - preRow = writeSheetHolder.getCachedSheet().getRow(curRowIndex - 1); - } - if (preRow != null) { - if (cell.getStringCellValue().equals(preRow.getCell(0).getStringCellValue())) { - for (int i = 0; i < mergeColumnIndex.length; i++) { - if (curColIndex == mergeColumnIndex[i]) { - mergeWithPrevRow(writeSheetHolder, cell, i, i); - break; - } - } - } - } - } - // preRow.getCell(curColIndex); - -/* if (curRowIndex > mergeRowIndex) { - for (int i = 0; i < mergeColumnIndex.length; i++) { - if (curColIndex == mergeColumnIndex[i]) { - mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex); - break; - } - } - }*/ - - } - - private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) { - Sheet sheet = writeSheetHolder.getSheet(); - List mergeRegions = sheet.getMergedRegions(); - boolean isMerged = false; - for (int i = 0; i < mergeRegions.size() && !isMerged; i++) { - CellRangeAddress cellRangeAddr = mergeRegions.get(i); - // 若上一个单元格已经被合并,则先移出原有的合并单元,再重新添加合并单元 - if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) { - sheet.removeMergedRegion(i); - cellRangeAddr.setLastRow(curRowIndex); - sheet.addMergedRegion(cellRangeAddr); - isMerged = true; - } - } - // 若上一个单元格未被合并,则新增合并单元 - if (!isMerged) { - CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, - curColIndex); - sheet.addMergedRegion(cellRangeAddress); - } - - } - -} diff --git a/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java b/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java deleted file mode 100644 index 3213b2b..0000000 --- a/service/src/main/java/com/hfkj/common/utils/MergeCellStrategyHandler.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.hfkj.common.utils; - -import com.alibaba.excel.metadata.Head; -import com.alibaba.excel.write.merge.AbstractMergeStrategy; -import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.util.CellRangeAddress; - -import java.util.*; - -/** - * @className: MergeCellStrategyHandler - * @author: HuRui - * @date: 2024/8/2 - **/ -public class MergeCellStrategyHandler extends AbstractMergeStrategy { - /** - * 相同列合并 - */ - private boolean alikeColumn; - - /** - * 相同行合并 - */ - private boolean alikeRow; - - /** 开始进行合并的行index */ - private int rowIndex; - - /** 跨行合并的列index */ - private Set columns; - - private int currentRowIndex = 0; - - public MergeCellStrategyHandler(boolean alikeColumn, boolean alikeRow, int rowIndex, Set columns){ - this.alikeColumn = alikeColumn; - this.alikeRow = alikeRow; - this.rowIndex = rowIndex; - this.columns = columns; - } - - /** - * 指定是否进行跨列合并单元格 - * @param alikeColumn - * @param rowIndex - */ - public MergeCellStrategyHandler(boolean alikeColumn, int rowIndex){ - this(alikeColumn, false, rowIndex, new HashSet<>()); - } - - /** - * 指定是否进行跨行合并单元格 - * @param alikeRow - * @param rowIndex - * @param columns - */ - public MergeCellStrategyHandler(boolean alikeRow, int rowIndex, Set columns){ - this(false, alikeRow, rowIndex, columns); - } - - - @Override - protected void merge(Sheet sheet, Cell cell, Head head, Integer integer) { - int rowId = cell.getRowIndex(); - currentRowIndex = rowId == currentRowIndex ? currentRowIndex : rowId; - if (rowIndex > rowId) { - return; - } - int columnId = cell.getColumnIndex(); - // 列合并 - if (alikeColumn && columnId > 0) { - String currentCellVal = this.getCellVal(cell); - Cell preCell = cell.getRow().getCell(columnId - 1); - String preCellVal = this.getCellVal(preCell); - if (null != currentCellVal && null != preCellVal && StringUtils.isNotBlank(preCellVal) && StringUtils.isNotBlank(currentCellVal)) { - // 当前单元格内容与上一个单元格内容相等,进行合并处理 - if (preCellVal.equals(currentCellVal)) { - CellRangeAddress rangeAddress = new CellRangeAddress(currentRowIndex, currentRowIndex, columnId - 1, columnId); - rangeAddress = this.findExistAddress(sheet, rangeAddress, currentCellVal); - if (null != rangeAddress) { - sheet.addMergedRegion(rangeAddress); - } - } - } - } - // 行合并 - if (alikeRow && rowIndex < rowId && columns.contains(columnId)) { - String currentCellVal = this.getCellVal(cell); - Cell preCell = sheet.getRow(rowId - 1).getCell(columnId); - String preCellVal = this.getCellVal(preCell); - if (null != currentCellVal && null != preCellVal && !preCellVal.isBlank() && !currentCellVal.isBlank()) { - // 当前单元格内容与上一行单元格内容相等,进行合并处理 - if (preCellVal.equals(currentCellVal)) { - //sheet.validateMergedRegions(); - CellRangeAddress rangeAddress = new CellRangeAddress(currentRowIndex - 1, currentRowIndex, columnId, columnId); - rangeAddress = this.findExistAddress(sheet, rangeAddress, currentCellVal); - if (null != rangeAddress) { - sheet.addMergedRegion(rangeAddress); - } - } - } - } - - } - - /** - * 合并单元格地址范围,发现存在相同的地址则进行扩容合并 - * - * @param isColumn true:跨列合并 false:跨行合并 - * @param sheet - * @param rangeAddress : - * @param currentVal 当前单元格中的值 - * @return - */ - private CellRangeAddress findExistAddress(Sheet sheet, CellRangeAddress rangeAddress, String currentVal) { - List mergedRegions = sheet.getMergedRegions(); - int existIndex = 0; - Map existIdexMap = new LinkedHashMap<>(); - if (null != mergedRegions && !mergedRegions.isEmpty()) { - //验证当前合并的单元格是否存在重复(fixme 重复问题待处理!!!) - for (CellRangeAddress mergedRegion : mergedRegions) { - if (mergedRegion.intersects(rangeAddress)) { - existIdexMap.put(existIndex, mergedRegion); - } - existIndex++; - } - } - if (existIdexMap.isEmpty()) { - return rangeAddress; - } - List existIndexList = new ArrayList<>(existIdexMap.size()); - for (Map.Entry addressEntry : existIdexMap.entrySet()) { - CellRangeAddress exist = addressEntry.getValue(); - // 自动进行单元格合并处理 - int firstRow = rangeAddress.getFirstRow(); - int lastRow = rangeAddress.getLastRow(); - int firstColumn = rangeAddress.getFirstColumn(); - int lastColumn = rangeAddress.getLastColumn(); - - int firstRow1 = exist.getFirstRow(); - int lastRow1 = exist.getLastRow(); - int firstColumn1 = exist.getFirstColumn(); - int lastColumn1 = exist.getLastColumn(); - // 跨行合并 最后一列相等, 行不相等 - if (lastRow > lastRow1 && lastColumn == lastColumn1) { - // 检查进行跨行合并的单元格是否已经存在跨列合并 - if (lastColumn > 0 && firstColumn1 != lastColumn1) { - // 获取当前单元格的前一列单元格 - String cellVal = this.getCellVal(sheet.getRow(lastRow).getCell(lastColumn - 1)); - if (null != cellVal && cellVal.equals(currentVal)) { - exist.setLastRow(lastRow); - } - } else { - exist.setLastRow(lastRow); - } - rangeAddress = exist; - existIndexList.add(addressEntry.getKey()); - } - - // 跨列合并 行相等,列不相等 - if (lastColumn > lastColumn1 && firstRow == firstRow1 ) { - exist.setLastColumn(lastColumn); - rangeAddress = exist; - existIndexList.add(addressEntry.getKey()); - } - } - // 移除已经存在且冲突的合并数据 - if (existIndexList.isEmpty()) { - rangeAddress = null; - }else { - sheet.removeMergedRegions(existIdexMap.keySet()); - } - return rangeAddress; - } - - private String getCellVal(Cell cell) { - String val = null; - try { - val = cell.getStringCellValue(); - }catch (Exception e){ - System.out.printf("读取单元格内容失败:行%d 列%d %n", (cell.getRowIndex() + 1), (cell.getColumnIndex() + 1)); - } - return val; - } -} From ad76eb64b4425d4769b8d5e091845c725225d5b3 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 5 Aug 2024 11:17:07 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=8F=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/impl/BsOrderRefundServiceImpl.java | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index 99f8aa4..8b1a796 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -15,6 +15,7 @@ import com.hfkj.entity.BsOrderRefundExample; import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; +import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderRefundService; import com.hfkj.service.order.BsOrderService; @@ -36,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @className: BsOrderRefundServiceImpl @@ -96,12 +94,25 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } } else if (OrderPayChannelEnum.type3.getCode() == orderRefund.getRefundPayChannel()) { - // 商户退款 - JSONObject refundObj = huiftTradeService.thirdPayRefund(orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice(), orderRefund.getOrderNo()); - orderRefund.setRefundSerialNo(refundObj.getString("refundTraceNo")); - orderRefund.setRefundPayChannelOrderNo(refundObj.getString("refundOrderNo")); - return true; - } else { + // 商户退款 + JSONObject refundObj = huiftTradeService.thirdPayRefund(orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice(), orderRefund.getOrderNo()); + orderRefund.setRefundSerialNo(refundObj.getString("refundTraceNo")); + orderRefund.setRefundPayChannelOrderNo(refundObj.getString("refundOrderNo")); + return true; + + } /*else if (OrderPayChannelEnum.type4.getCode() == orderRefund.getRefundPayChannel()) { + // 商户退款 + JSONObject refundObj = HuiLianTongUnionCardService.refund(orderRefund.getRefundOrderNo(), orderRefund.getOrderNo()); + if (!refundObj.getString("respCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refundObj.getString("respMessage")); + } + JSONObject consumptionResult = HuiLianTongUnionCardService.resolveResponse(refundObj.getString("data")); + if (!(consumptionResult.getBoolean("success") || Objects.equals(consumptionResult.getString("message"), "原交易已撤销,不可再次操作"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!"+consumptionResult.getString("message")); + } + orderRefund.setRefundSerialNo(consumptionResult.getString("orderId")); + return true; + }*/ else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!该支付方式暂不支持退款"); } } catch (BaseException e) { @@ -254,6 +265,10 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { BsOrderRefundExample example = new BsOrderRefundExample(); BsOrderRefundExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getLong(param, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(param, "merId")); + } + if (StringUtils.isNotBlank(MapUtils.getString(param, "userPhone"))) { criteria.andUserPhoneEqualTo(MapUtils.getString(param, "userPhone")); }