diff --git a/bweb/src/main/java/com/bweb/controller/BsTradeOrderController.java b/bweb/src/main/java/com/bweb/controller/BsTradeOrderController.java index 66137a5..b2815dd 100644 --- a/bweb/src/main/java/com/bweb/controller/BsTradeOrderController.java +++ b/bweb/src/main/java/com/bweb/controller/BsTradeOrderController.java @@ -1,17 +1,26 @@ package com.bweb.controller; +import com.alibaba.excel.EasyExcel; +import com.bweb.config.SysConst; +import com.bweb.excel.model.ExportTradeOrderModel; import com.github.pagehelper.PageHelper; 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.UserCenter; +import com.hfkj.common.utils.EasyExcelUtil; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsPayQrCode; import com.hfkj.entity.BsTradeOrder; import com.hfkj.model.ResponseData; import com.hfkj.model.UserInfoModel; import com.hfkj.service.*; +import com.hfkj.sysenum.PayQrCodeStatusEnum; import com.hfkj.sysenum.SecUserTypeEnum; +import com.hfkj.sysenum.TradeOrderPayModeEnum; +import com.hfkj.sysenum.TradeOrderStatusEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -20,6 +29,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -118,10 +129,10 @@ public class BsTradeOrderController { } } - @RequestMapping(value="/exportOrderList",method = RequestMethod.GET) + @RequestMapping(value="/exportTradeOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单列表") - public ResponseData exportOrderList(@RequestParam(value = "salesmanId" , required = false) Long salesmanId, + public ResponseData exportTradeOrder(@RequestParam(value = "salesmanId" , required = false) Long salesmanId, @RequestParam(value = "merId" , required = false) Long merId, @RequestParam(value = "merName" , required = false) String merName, @RequestParam(value = "companyId" , required = false) Long companyId, @@ -184,9 +195,35 @@ public class BsTradeOrderController { param.put("payTimeS", payTimeS); param.put("payTimeE", payTimeE); param.put("status", status); + + + List dataList = new ArrayList<>(); + ExportTradeOrderModel data; + List tradeOrderList = tradeOrderService.getTradeOrderList(param); + for (BsTradeOrder tradeOrder : tradeOrderList) { + data = new ExportTradeOrderModel(); + data.setMerName(tradeOrder.getMerName()); + data.setStoreName(tradeOrder.getStoreName()); + data.setOutTradeNo(tradeOrder.getOutTradeNo()); + data.setPayMode(TradeOrderPayModeEnum.getNameByCode(tradeOrder.getPayMode()).getName()); + data.setTradeAmount(tradeOrder.getTradeAmount()); + data.setStoreDiscountActualPrice(tradeOrder.getStoreDiscountActualPrice()); + data.setUserDiscountActualPrice(tradeOrder.getUserDiscountActualPrice()); + data.setTradeActualAmount(tradeOrder.getTradeActualAmount()); + data.setStatus(TradeOrderStatusEnum.getNameByNumber(tradeOrder.getStatus()).getName()); + data.setCreateTime(tradeOrder.getCreateTime()); + data.setPayTime(tradeOrder.getPayTime()); + data.setPlatformMerNo(tradeOrder.getPlatformMerNo()); + data.setSalesmanName(tradeOrder.getSalesmanName()); + dataList.add(data); + } - return ResponseMsgUtil.success(""); + String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx"; + EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, ExportTradeOrderModel.class) + .sheet("交易订单") + .doWrite(dataList); + return ResponseMsgUtil.success(fileName); } catch (Exception e) { log.error(e.getMessage(), e); diff --git a/bweb/src/main/java/com/bweb/excel/listener/ImportDeviceListener.java b/bweb/src/main/java/com/bweb/excel/listener/ImportDeviceListener.java index 476a93a..ba9bd38 100644 --- a/bweb/src/main/java/com/bweb/excel/listener/ImportDeviceListener.java +++ b/bweb/src/main/java/com/bweb/excel/listener/ImportDeviceListener.java @@ -61,7 +61,7 @@ public class ImportDeviceListener extends AnalysisEventListener list = deviceMapper.selectByExample(example); if (list.size() > 0) { return list.get(0); diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java index 2ac6f7b..70153c6 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java @@ -115,7 +115,7 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { tradeOrder.setStoreDiscountPrice(storeDiscount.getDiscountPrice()); if (storeDiscount.getDiscountType().equals(StoreDiscountActivityTypeEnum.type1.getNumber())) { // 未达到满减门槛 - if (tradeOrder.getTradeAmount().compareTo(storeDiscount.getDiscountCondition()) == -1) { + if (userDiscount.getDiscountCondition().compareTo(tradeOrder.getTradeAmount()) >= 0) { tradeOrder.setStoreDiscountActualPrice(new BigDecimal(0)); } else { tradeOrder.setStoreDiscountSatisfy(true); @@ -144,8 +144,8 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { tradeOrder.setUserDiscountPrice(userDiscount.getDiscountPrice()); if (userDiscount.getDiscountType().equals(UserDiscountTypeEnum.type1.getNumber())) { - if (userDiscount.getDiscountCondition().compareTo(tradeOrder.getTradeAmount()) == -1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未达到满减门槛"); + if (userDiscount.getDiscountCondition().compareTo(tradeOrder.getTradeAmount()) > 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未达到满减门槛"); } tradeOrder.setUserDiscountActualPrice(userDiscount.getDiscountPrice()); tradeOrder.setTradeActualAmount(tradeOrder.getTradeActualAmount().subtract(tradeOrder.getUserDiscountActualPrice())); @@ -196,6 +196,10 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { return returnParam; } + public static void main(String[] args) { + System.out.println(new BigDecimal("10").compareTo(new BigDecimal("10"))); + } + @Override public void paySuccess(String outTradeNo, String transactionId, PlatformTypeEnum platformType, TradeOrderPayModeEnum tradeOrderPayMode, BigDecimal tradeActualAmount, String subMchId) { // 查询订单 diff --git a/service/src/main/java/com/hfkj/sysenum/TradeOrderStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/TradeOrderStatusEnum.java index 37a721e..069060e 100644 --- a/service/src/main/java/com/hfkj/sysenum/TradeOrderStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/TradeOrderStatusEnum.java @@ -1,5 +1,7 @@ package com.hfkj.sysenum; +import java.util.Objects; + /** * 交易订单状态 * @author hurui @@ -22,6 +24,15 @@ public enum TradeOrderStatusEnum { this.name = name; } + public static TradeOrderStatusEnum getNameByNumber(Integer number) { + for (TradeOrderStatusEnum ele : values()) { + if (Objects.equals(number,ele.getNumber())) { + return ele; + } + } + return null; + } + public Integer getNumber() { return number; }