From 0e8d19229136a6330e4a8f1c1cb0f9226d5a2ecb Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 30 Sep 2024 14:10:39 +0800 Subject: [PATCH] /1 --- .../controller/meituan/MeiTuanController.java | 18 +- .../business/BsOrderGoodsController.java | 7 +- .../business/BsOrderMeiTuanController.java | 81 +++- .../business/OrderSettlementController.java | 447 ++++++++++++++++++ .../controller/notify/MeiTuanController.java | 133 +++++- .../java/com/hfkj/config/CommonSysConfig.java | 2 +- .../java/com/hfkj/meituan/MeiTuanService.java | 34 +- .../MerOrderSettlementDetailModel.java | 58 +++ .../orderExport/OrderMeiTuanExportModel.java | 120 +++++ .../orderExport/OrderSettlementModel.java | 39 ++ .../orderExport/OrderSettlementSumModel.java | 34 ++ .../service/coupon/BsOrderCouponService.java | 10 + .../coupon/impl/BsOrderCouponServiceImpl.java | 24 + .../service/goods/BsOrderCinemaService.java | 11 + .../service/goods/BsOrderGoodsService.java | 2 +- .../service/goods/BsOrderMeiTuanService.java | 32 ++ .../service/goods/BsOrderMemberService.java | 18 + .../goods/BsOrderStarbucksService.java | 9 + .../goods/impl/BsOrderCinemaServiceImpl.java | 32 +- .../goods/impl/BsOrderGoodsServiceImpl.java | 22 +- .../goods/impl/BsOrderMeiTuanServiceImpl.java | 151 +++++- .../goods/impl/BsOrderMemberServiceImpl.java | 44 ++ .../impl/BsOrderStarbucksServiceImpl.java | 25 + .../service/order/OrderCancelService.java | 47 +- .../service/order/OrderCreateService.java | 8 +- .../service/order/OrderPaySuccessService.java | 49 +- .../order/OrderRefundSuccessService.java | 26 +- .../service/order/OrderSettlementService.java | 47 ++ .../order/impl/BsOrderChildServiceImpl.java | 26 +- .../order/impl/BsOrderRefundServiceImpl.java | 46 +- .../order/impl/BsOrderServiceImpl.java | 1 + .../impl/OrderSettlementServiceImpl.java | 374 +++++++++++++++ .../com/hfkj/sysenum/UserLoginPlatform.java | 2 +- .../sysenum/fileRecords/FileRecordsEnum.java | 12 + .../resources/dev/commonConfig.properties | 2 +- .../resources/prod/commonConfig.properties | 7 + 36 files changed, 1857 insertions(+), 143 deletions(-) create mode 100644 order/src/main/java/com/order/controller/business/OrderSettlementController.java create mode 100644 service/src/main/java/com/hfkj/model/order/orderExport/MerOrderSettlementDetailModel.java create mode 100644 service/src/main/java/com/hfkj/model/order/orderExport/OrderMeiTuanExportModel.java create mode 100644 service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementModel.java create mode 100644 service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementSumModel.java create mode 100644 service/src/main/java/com/hfkj/service/order/OrderSettlementService.java create mode 100644 service/src/main/java/com/hfkj/service/order/impl/OrderSettlementServiceImpl.java diff --git a/cweb/src/main/java/com/cweb/controller/meituan/MeiTuanController.java b/cweb/src/main/java/com/cweb/controller/meituan/MeiTuanController.java index e5f5778..49a3dba 100644 --- a/cweb/src/main/java/com/cweb/controller/meituan/MeiTuanController.java +++ b/cweb/src/main/java/com/cweb/controller/meituan/MeiTuanController.java @@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.utils.RandomStringGeneratorUtil; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsOrderMeituan; import com.hfkj.meituan.MeiTuanService; import com.hfkj.model.ResponseData; +import com.hfkj.service.goods.BsOrderMeiTuanService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -16,9 +19,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.Objects; @Controller @RequestMapping(value="/meiTuan") @@ -27,20 +32,31 @@ public class MeiTuanController { private static final Logger log = LoggerFactory.getLogger(MeiTuanController.class); + @Resource + private BsOrderMeiTuanService bsOrderMeiTuanService; + @RequestMapping(value = "/loginFree", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "H5免登接口") public ResponseData loginFree(@RequestParam(name = "staffPhone", required = true) String staffPhone, + @RequestParam(name = "childNo", required = false) String childNo, @RequestParam(name = "productType", required = true) String productType) { try { Map map = new HashMap<>(); Map staffInfo = new HashMap<>(); + Map bizParam = new HashMap<>(); staffInfo.put("staffPhone", staffPhone); + if (Objects.equals(productType, "sqt_order_detail")) { + BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(childNo); + bizParam.put("sqtBizOrderId" , orderMeiTuan.getSqtBizOrderId()); + } + map.put("staffInfo", staffInfo); - map.put("entId", 104310L); + map.put("bizParam", bizParam); + map.put("entId", CommonSysConst.getSysConfig().getEntId()); map.put("ts", new Date().getTime()); map.put("productType", productType); map.put("nonce" , RandomStringGeneratorUtil.generateRandomString(36)); diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index af8a8e4..e30992c 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -151,15 +151,12 @@ public class BsOrderGoodsController { @RequestParam(value = "payType" , required = false) Integer payType, @RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "merId" , required = false) Long merId, - @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, - @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, @RequestParam(value = "createTimeS" , required = false) Long createTimeS, @RequestParam(value = "createTimeE" , required = false) Long createTimeE, HttpServletRequest request) { // 插入下载记录 FileRecords fileRecords = new FileRecords(); - - - try { SessionObject sessionObject = userCenter.getSessionObject(request); diff --git a/order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java b/order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java index 23cb2e4..6973093 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java @@ -1,16 +1,27 @@ package com.order.controller.business; +import com.alibaba.fastjson.JSONObject; +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.SessionObject; +import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsOrderMeituan; import com.hfkj.entity.SecConfig; import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.SecConfigService; +import com.hfkj.service.goods.BsOrderMeiTuanService; +import com.hfkj.service.goods.impl.BsOrderMeiTuanServiceImpl; +import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -18,7 +29,11 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.HashMap; +import java.util.Map; @Controller @RequestMapping(value="/orderMeiTuan") @@ -28,12 +43,22 @@ public class BsOrderMeiTuanController { @Resource private SecConfigService secConfigService; + @Resource + private BsOrderMeiTuanService orderMeiTuanService; + + @Resource + private UserCenter userCenter; + + private static final Logger log = LoggerFactory.getLogger(BsOrderGoodsController.class); + @Autowired + private BsOrderMeiTuanServiceImpl bsOrderMeiTuanService; @RequestMapping(value="/servicePrice",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询服务费") public ResponseData servicePrice(@RequestParam(value = "platformCode" , required = true) String platformCode, + @RequestParam(value = "tradeNo" , required = true) String tradeNo, @RequestParam(value = "price" , required = true) BigDecimal price ) { try { @@ -46,9 +71,61 @@ public class BsOrderMeiTuanController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息"); } - servicePrice = price.multiply(new BigDecimal(config.getCodeValue())); + BsOrderMeituan orderMeiTuan = orderMeiTuanService.findOrderMeiTuanByTradeNo(tradeNo); + + servicePrice = price.multiply(new BigDecimal(config.getCodeValue())).setScale(2 , RoundingMode.HALF_UP); + + + JSONObject object = new JSONObject(); + + object.put("servicePrice" , servicePrice); + object.put("goodsName" , orderMeiTuan.getGoodsName()); + object.put("tradeAmount" , orderMeiTuan.getTradeAmount()); + + return ResponseMsgUtil.success(object); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/getListMeiTuan",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询列表") + public ResponseData getListMeiTuan( + @RequestParam(value = "orderNo" , required = false) String orderNo, + @RequestParam(value = "childOrderNo" , required = false) String childOrderNo, + @RequestParam(value = "userPhone" , required = false) String userPhone, + @RequestParam(value = "goodsName" , required = false) String goodsName, + @RequestParam(value = "tradeNo" , required = false) String tradeNo, + @RequestParam(value = "payType" , required = false) Integer payType, + @RequestParam(value = "status" , required = false) Integer status, + @RequestParam(value = "createTimeS" , required = false) Long createTimeS, + @RequestParam(value = "createTimeE" , required = false) Long createTimeE, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, + @RequestParam(value = "pageNum" , required = true) Integer pageNum, + @RequestParam(value = "pageSize" , required = true) Integer pageSize) { + try { + + Map map = new HashMap<>(); + + map.put("orderNo", orderNo); + map.put("childOrderNo", childOrderNo); + map.put("userPhone", userPhone); + map.put("tradeNo", tradeNo); + map.put("goodsName", goodsName); + map.put("payType", payType); + map.put("createTimeS", createTimeS); + map.put("createTimeE", createTimeE); + map.put("finishTimeS", finishTimeS); + map.put("finishTimeE", finishTimeE); + map.put("status", status); - return ResponseMsgUtil.success(servicePrice); + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(bsOrderMeiTuanService.getOrderList(map))); } catch (Exception e) { log.error("error!",e); diff --git a/order/src/main/java/com/order/controller/business/OrderSettlementController.java b/order/src/main/java/com/order/controller/business/OrderSettlementController.java new file mode 100644 index 0000000..1fdeee3 --- /dev/null +++ b/order/src/main/java/com/order/controller/business/OrderSettlementController.java @@ -0,0 +1,447 @@ +package com.order.controller.business; + +import com.alibaba.excel.EasyExcel; +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.DateUtil; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsOrderGoods; +import com.hfkj.entity.FileRecords; +import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; + +import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; +import com.hfkj.model.order.orderExport.OrderGoodsExportModel; +import com.hfkj.model.order.orderExport.OrderSettlementModel; +import com.hfkj.model.order.orderExport.OrderSettlementSumModel; +import com.hfkj.service.file.FileRecordsService; +import com.hfkj.service.order.OrderSettlementService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.fileRecords.FileRecordsEnum; +import com.hfkj.sysenum.order.OrderChildStatusEnum; +import com.hfkj.sysenum.order.OrderPayChannelEnum; +import com.hfkj.sysenum.order.OrderPayTypeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.beanutils.BeanUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +@Controller +@RequestMapping(value="/settlement") +@Api(value="订单统计业务") +public class OrderSettlementController { + + private static final Logger log = LoggerFactory.getLogger(OrderSettlementController.class); + + @Resource + private UserCenter userCenter; + @Resource + private OrderSettlementService orderSettlementService; + @Resource + private FileRecordsService fileRecordsService; + + + @RequestMapping(value="/settlementDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "结算详情") + public ResponseData settlementDetail(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { + try { + Map param = new HashMap<>(); + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + param.put("merId", merId); + } + if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { + param.put("merId", userModel.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + return ResponseMsgUtil.success(orderSettlementService.getDetail(param)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/exportSettlementDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出结算详情") + public ResponseData exportSettlementDetail(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { + // 插入下载记录 + FileRecords fileRecords = new FileRecords(); + try { + + Map param = new HashMap<>(); + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + param.put("merId", merId); + } + if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { + param.put("merId", userModel.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); + + String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); + String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; + String pathName = filePath + FileRecordsEnum.status10.getName() + "交易数据导出" + dataSting +".xlsx"; + + if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); + } + + fileRecords.setCreateTime(new Date()); + fileRecords.setBusinessType(FileRecordsEnum.status10.getCode()); + fileRecords.setDownloadConditions(param.toString()); + fileRecords.setOpId(userModel.getAccount().getId()); + fileRecords.setOpName(userModel.getAccount().getUserName()); + fileRecords.setStatus(2); + fileRecords.setDownloadStatus(2); + fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); + fileRecords.setType("2"); + fileRecords.setTitle(FileRecordsEnum.status10.getName() + "交易数据导出" + dataSting + ".xls"); + fileRecordsService.create(fileRecords); + + // 创建线程 + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 2, // 核心线程数 + 5, // 最大线程数 + 1, // 线程空闲时间 + TimeUnit.MINUTES, // 时间单位 + new ArrayBlockingQueue<>(5), // 任务队列 + new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 + ); + + // 提交任务给线程池 + executor.execute(() -> { + + try { + + List list = orderSettlementService.getDetail(param); + + File file = new File(fileUrl + filePath); + if (!file.exists()) { + file.mkdirs(); + } + + EasyExcel.write(fileUrl+pathName) + .head(OrderGoodsExportModel.class) + .sheet(fileRecords.getTitle()) + .doWrite(list); + + fileRecords.setStatus(1); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecords.setExt1(e.toString()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + } + }); + + // 关闭线程池 + executor.shutdown(); + return ResponseMsgUtil.success(fileRecords); + + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getSettlement",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "结算详情") + public ResponseData getSettlement(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE) { + try { + Map param = new HashMap<>(); + SecUserSessionObject userSessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (SecUserObjectTypeEnum.type2.getCode() == userSessionObject.getAccount().getObjectType()) { + param.put("merId", userSessionObject.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + return ResponseMsgUtil.success(orderSettlementService.getSettlement(param)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/exportSettlement",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出结算") + public ResponseData exportSettlement(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { + // 插入下载记录 + FileRecords fileRecords = new FileRecords(); + try { + + Map param = new HashMap<>(); + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + param.put("merId", merId); + } + if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { + param.put("merId", userModel.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); + + String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); + String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; + String pathName = filePath + FileRecordsEnum.status11.getName() + "交易数据导出" + dataSting +".xlsx"; + + if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); + } + + fileRecords.setCreateTime(new Date()); + fileRecords.setBusinessType(FileRecordsEnum.status11.getCode()); + fileRecords.setDownloadConditions(param.toString()); + fileRecords.setOpId(userModel.getAccount().getId()); + fileRecords.setOpName(userModel.getAccount().getUserName()); + fileRecords.setStatus(2); + fileRecords.setDownloadStatus(2); + fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); + fileRecords.setType("2"); + fileRecords.setTitle(FileRecordsEnum.status11.getName() + "交易数据导出" + dataSting + ".xls"); + fileRecordsService.create(fileRecords); + + // 创建线程 + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 2, // 核心线程数 + 5, // 最大线程数 + 1, // 线程空闲时间 + TimeUnit.MINUTES, // 时间单位 + new ArrayBlockingQueue<>(5), // 任务队列 + new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 + ); + + // 提交任务给线程池 + executor.execute(() -> { + + try { + + List list = orderSettlementService.getSettlement(param); + + File file = new File(fileUrl + filePath); + if (!file.exists()) { + file.mkdirs(); + } + + EasyExcel.write(fileUrl+pathName) + .head(OrderGoodsExportModel.class) + .sheet(fileRecords.getTitle()) + .doWrite(list); + + fileRecords.setStatus(1); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecords.setExt1(e.toString()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + } + }); + + // 关闭线程池 + executor.shutdown(); + return ResponseMsgUtil.success(fileRecords); + + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getSum",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "结算总和") + public ResponseData getSum(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE) { + try { + Map param = new HashMap<>(); + SecUserSessionObject userSessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + if (SecUserObjectTypeEnum.type2.getCode() == userSessionObject.getAccount().getObjectType()) { + param.put("merId", userSessionObject.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + return ResponseMsgUtil.success(orderSettlementService.getSum(param)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/exportSettlementSum",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出结算总和") + public ResponseData exportSettlementSum(@RequestParam(value = "platform" , required = false) String platform, + @RequestParam(value = "merId" , required = false) Long merId, + @RequestParam(value = "payType" , required = false) Long payType, + @RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, + @RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, HttpServletRequest request) { + // 插入下载记录 + FileRecords fileRecords = new FileRecords(); + try { + + Map param = new HashMap<>(); + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + param.put("merId", merId); + } + if (SecUserObjectTypeEnum.type2.getCode() == userModel.getAccount().getObjectType()) { + param.put("merId", userModel.getAccount().getObjectId()); + } + param.put("platform", platform); + param.put("payType", payType); + param.put("finishTimeS", finishTimeS); + param.put("finishTimeE", finishTimeE); + + String dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS); + + String fileUrl = CommonSysConst.getSysConfig().getFileUrl(); + String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ; + String pathName = filePath + FileRecordsEnum.status12.getName() + "交易数据导出" + dataSting +".xlsx"; + + if (fileRecordsService.findExported(param.toString() , userModel.getAccount().getId())) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "相同导出内容请勿重复点击!"); + } + + fileRecords.setCreateTime(new Date()); + fileRecords.setBusinessType(FileRecordsEnum.status12.getCode()); + fileRecords.setDownloadConditions(param.toString()); + fileRecords.setOpId(userModel.getAccount().getId()); + fileRecords.setOpName(userModel.getAccount().getUserName()); + fileRecords.setStatus(2); + fileRecords.setDownloadStatus(2); + fileRecords.setFileUrl(CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + pathName); + fileRecords.setType("2"); + fileRecords.setTitle(FileRecordsEnum.status12.getName() + "交易数据导出" + dataSting + ".xls"); + fileRecordsService.create(fileRecords); + + // 创建线程 + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 2, // 核心线程数 + 5, // 最大线程数 + 1, // 线程空闲时间 + TimeUnit.MINUTES, // 时间单位 + new ArrayBlockingQueue<>(5), // 任务队列 + new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 + ); + + // 提交任务给线程池 + executor.execute(() -> { + + try { + + List list = orderSettlementService.getSum(param); + + File file = new File(fileUrl + filePath); + if (!file.exists()) { + file.mkdirs(); + } + + EasyExcel.write(fileUrl+pathName) + .head(OrderGoodsExportModel.class) + .sheet(fileRecords.getTitle()) + .doWrite(list); + + fileRecords.setStatus(1); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecords.setExt1(e.toString()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + } + }); + + // 关闭线程池 + executor.shutdown(); + return ResponseMsgUtil.success(fileRecords); + + } catch (Exception e) { + fileRecords.setStatus(3); + fileRecords.setUpdateTime(new Date()); + fileRecordsService.update(fileRecords); + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/order/src/main/java/com/order/controller/notify/MeiTuanController.java b/order/src/main/java/com/order/controller/notify/MeiTuanController.java index bff3c1a..0051b9f 100644 --- a/order/src/main/java/com/order/controller/notify/MeiTuanController.java +++ b/order/src/main/java/com/order/controller/notify/MeiTuanController.java @@ -19,14 +19,11 @@ import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.Date; -import java.util.Objects; +import java.math.BigDecimal; +import java.util.*; @Controller @RequestMapping(value = "/meiTuan") @@ -107,8 +104,7 @@ public class MeiTuanController { JSONObject staffInfo = jsonObject.getJSONObject("staffInfo"); object.put("thirdTradeNo", thirdTradeNo); - object.put("thirdPayUrl", "https://phgcs.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") + "&goodsName=" + - jsonObject.getString("goodsName") + + object.put("thirdPayUrl", "https://phg.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") + "&tradeAmount=" + jsonObject.getString("tradeAmount") + "&outSidePhone=" + staffInfo.getString("staffPhone") ); @@ -123,22 +119,64 @@ public class MeiTuanController { // 退款 if (Objects.equals(jsonObject.getString("method"), "trade.third.refund")) { - BsOrderRefund orderRefund = orderRefundService.meiTuanRefund( - jsonObject.getString("tradeRefundNo") , - jsonObject.getString("tradeNo") , - jsonObject.getBigDecimal("refundAmount") , - "美团退款" + // 查询退款订 + BsOrderRefund bsOrderRefund = orderRefundService.getRefundByTradeRefundNo(jsonObject.getString("tradeRefundNo")); + + if (bsOrderRefund != null) { + // 美团退款订单 + JSONObject object = new JSONObject(); + object.put("thirdRefundNo" , bsOrderRefund.getRefundOrderNo()); + log.info("美团退款订单-参数: {}", object); + JSONObject data = new JSONObject(); + data.put("status", 0); + data.put("msg", "成功"); + data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey())); + log.info("============回调任务End============="); + return data; + } else { + + BsOrderMeituan bsOrderMeituan = bsOrderMeiTuanService.findOrderMeiTuanByTradeNo(jsonObject.getString("tradeNo")); + Map refundMap = new HashMap<>(); + refundMap.put("orderNo", bsOrderMeituan.getOrderNo()); + List refundList = orderRefundService.getRefundList(refundMap); + + BigDecimal refundListPrice = new BigDecimal(0); + + for (BsOrderRefund refund : refundList) { + refundListPrice = refundListPrice.add(refund.getTradeRefundPrice()); + + } + + if (bsOrderMeituan.getTradeAmount().compareTo(refundListPrice.add(jsonObject.getBigDecimal("refundAmount"))) > -1) { + BsOrderRefund orderRefund = orderRefundService.meiTuanRefund( + jsonObject.getString("tradeRefundNo") , + jsonObject.getString("tradeNo") , + jsonObject.getBigDecimal("refundAmount") , + "美团退款" ); - // 美团退款订单 - JSONObject object = new JSONObject(); - object.put("thirdRefundNo" , orderRefund.getRefundOrderNo()); - log.info("美团关闭订单-参数: {}", object); - JSONObject data = new JSONObject(); - data.put("status", 0); - data.put("msg", "成功"); - data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey())); - log.info("============回调任务End============="); - return data; + // 美团退款订单 + JSONObject object = new JSONObject(); + object.put("thirdRefundNo" , orderRefund.getRefundOrderNo()); + log.info("美团退款订单-参数: {}", object); + JSONObject data = new JSONObject(); + data.put("status", 0); + data.put("msg", "成功"); + data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey())); + log.info("============回调任务End============="); + return data; + } else { + + JSONObject data = new JSONObject(); + data.put("status", 411); + data.put("traceId", jsonObject.getString("traceId")); + data.put("msg", "退款超额"); + data.put("data", null); + log.info("美团退款超额订单-参数: {}", data); + log.info("============回调任务End============="); + return data; + } + } + } // 交易关单 @@ -203,4 +241,53 @@ public class MeiTuanController { return e; } } + + + @RequestMapping(value = "/orderPush", method = RequestMethod.POST) + @ApiOperation(value = "订单状态变更回调") + @ResponseBody + public Object orderPush( + @RequestParam(name = "traceId", required = false) String traceId, + @RequestParam(name = "accessKey", required = false) String accessKey, + @RequestParam(name = "content", required = false) String content + ) { + try { + + log.info("============回调任务Start============="); + if (accessKey == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "accessKey错误"); + } + + if (!Objects.equals(accessKey, CommonSysConst.getSysConfig().getMtAccessKey())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "accessKey错误"); + } + + if (content == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "content错误"); + } + + + JSONObject jsonObject = JSONObject.parseObject(EncryptUtil.aesDecrypt(content, CommonSysConst.getSysConfig().getMtSecretKey()));; + log.info("美团-解密参数: {}", jsonObject); + + JSONObject object = jsonObject.getJSONObject("data"); + + BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuanBySqtBizOrderId(object.getString("sqtBizOrderId")); + + if (orderMeiTuan != null) { + bsOrderMeiTuanService.orderFinish(orderMeiTuan.getChildOrderNo()); + } + JSONObject data = new JSONObject(); + data.put("status", 0); + data.put("msg", "成功"); + data.put("data", new JSONObject()); + log.info("============回调任务End============="); + return data; + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + return e; + } + } } diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index 123f966..7cb77ae 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -134,7 +134,7 @@ public class CommonSysConfig { /** * 美团接口请求参数 */ - private String mtNotifyUrl; + private String entId; private String mtAccessKey; private String mtSecretKey; private String mtPostUrl; diff --git a/service/src/main/java/com/hfkj/meituan/MeiTuanService.java b/service/src/main/java/com/hfkj/meituan/MeiTuanService.java index 6467f28..21c0c2f 100644 --- a/service/src/main/java/com/hfkj/meituan/MeiTuanService.java +++ b/service/src/main/java/com/hfkj/meituan/MeiTuanService.java @@ -34,7 +34,7 @@ public class MeiTuanService { */ public static JSONObject loginFree(Map map) throws Exception { - JSONObject object = doPostMeiTuanUrl("https://waimai-openapi.apigw.test.meituan.com/api/sqt/open/login/h5/loginFree/redirection?test_open_swimlane=test-open" , map); + JSONObject object = doPostMeiTuanUrl("login/h5/loginFree/redirection", map); if (object.getBoolean("msg")) { return object; @@ -44,6 +44,28 @@ public class MeiTuanService { } + /** + * @MethodName queryDetail + * @Description: 查询订单 + * @param map + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/26 下午2:08 + */ + public static JSONObject queryDetail(Map map) { + + try { + JSONObject object = request(CommonSysConst.getSysConfig().getMtPostUrl() + "order/queryDetail", map); + return JSONObject.parseObject(EncryptUtil.aesDecrypt(object.getString("data") , CommonSysConst.getSysConfig().getMtSecretKey())); + + } catch (Exception e) { + log.info("响应错误信息:{}", e); + } + + return null; + + } + /** * @MethodName paySuccess * @Description: 支付成功通知接口 @@ -90,23 +112,23 @@ public class MeiTuanService { /** * @MethodName doPostMeiTuanUrl - * @Description: 美团免登陆接口 - * @param postUrl + * @Description: 请求 + * @param url * @param param * @return: com.alibaba.fastjson.JSONObject * @Author: Sum1Dream * @Date: 2024/9/18 下午5:44 */ - public static JSONObject doPostMeiTuanUrl(String postUrl, Map param) throws Exception { + public static JSONObject doPostMeiTuanUrl(String url, Map param) throws Exception { log.info("============ 美团请求-START ============="); param.put("accessKey", CommonSysConst.getSysConfig().getMtAccessKey()); param.put("content", EncryptUtil.aesEncrypt(JsonUtil.object2Json(param), CommonSysConst.getSysConfig().getMtSecretKey())); - log.info("请求接口:" + postUrl); + log.info("请求接口:" + url); log.info("请求参数:" + JSONObject.toJSONString(param)); - JSONObject response = HttpsUtils.doPostMeiTuanUrl(postUrl, JSONObject.toJSONString(param)); + JSONObject response = HttpsUtils.doPostMeiTuanUrl(CommonSysConst.getSysConfig().getMtPostUrl() + url, JSONObject.toJSONString(param)); log.info("响应参数:" + response.toJSONString()); log.info("============ 美团请求-END =============="); diff --git a/service/src/main/java/com/hfkj/model/order/orderExport/MerOrderSettlementDetailModel.java b/service/src/main/java/com/hfkj/model/order/orderExport/MerOrderSettlementDetailModel.java new file mode 100644 index 0000000..f5533af --- /dev/null +++ b/service/src/main/java/com/hfkj/model/order/orderExport/MerOrderSettlementDetailModel.java @@ -0,0 +1,58 @@ +package com.hfkj.model.order.orderExport; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @ClassName MerOrderSettlementDetailModel + * @Author Sum1Dream + * @Description 商户订单结算详情 + * @Date 2024/9/29 上午10:50 + **/ +@Data +public class MerOrderSettlementDetailModel { + + @ColumnWidth(50) + @ExcelProperty("商品名称") + public String goodsName; + + @ColumnWidth(20) + @ExcelProperty("商户名称") + public String merName; + + @ColumnWidth(20) + @ExcelProperty("业务类型") + public String businessType; + + @ColumnWidth(20) + @ExcelProperty("登录平台") + public String platform; + + @ColumnWidth(40) + @ExcelProperty("订单号") + public String orderNo; + + @ColumnWidth(15) + @ExcelProperty("子订单号") + public String childOrderNo; + + @ColumnWidth(20) + @ExcelProperty("业务信息") + public String business; + + @ColumnWidth(20) + @ExcelProperty({"支付金额"}) + public BigDecimal payRealPrice; + + @ColumnWidth(20) + @ExcelProperty({"支付方式"}) + public String payType; + + @ColumnWidth(20) + @ExcelProperty("收货时间") + public String finishTime; +} diff --git a/service/src/main/java/com/hfkj/model/order/orderExport/OrderMeiTuanExportModel.java b/service/src/main/java/com/hfkj/model/order/orderExport/OrderMeiTuanExportModel.java new file mode 100644 index 0000000..617cbc5 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/order/orderExport/OrderMeiTuanExportModel.java @@ -0,0 +1,120 @@ +package com.hfkj.model.order.orderExport; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @ClassName OrderGoodsExportModel + * @Author Sum1Dream + * @Description 实物订单导出 + * @Date 2024/8/12 下午5:07 + **/ +@Data +public class OrderMeiTuanExportModel { + + @ColumnWidth(50) + @ExcelProperty("商品名称") + public String goodsName; + + @ColumnWidth(20) + @ExcelProperty("商户名称") + public String merName; + + @ColumnWidth(20) + @ExcelProperty("类型名称") + public String goodsTypeName; + + @ColumnWidth(20) + @ExcelProperty("品牌名称") + public String goodsBrandName; + + @ColumnWidth(20) + @ExcelProperty("用户手机号") + public String userPhone; + + @ColumnWidth(40) + @ExcelProperty("订单号") + public String orderNo; + + @ColumnWidth(15) + @ExcelProperty("子订单号") + public String childOrderNo; + + @ColumnWidth(20) + @ExcelProperty("物流单号") + public String logisticsNo; + + @ColumnWidth(30) + @ExcelProperty("商品规格") + public String goodsSpecsName; + + @ColumnWidth(20) + @ExcelProperty("商品价格") + public BigDecimal goodsPrice; + + @ColumnWidth(20) + @ExcelProperty("购买数量") + public Integer 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; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付渠道"}) + public String payChannel; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付方式"}) + public String payType; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付单号"}) + public String paySerialNo; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "交易状态"}) + public String tradeStatus; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "创建时间"}) + public Date createTime; + + @ColumnWidth(20) + @ExcelProperty({"交易信息", "支付时间"}) + public Date payTime; + + @ColumnWidth(20) + @ExcelProperty("物流状态") + public String logisticsStatusDesc; + + @ColumnWidth(20) + @ExcelProperty("更新时间") + public Date updateTime; + + @ColumnWidth(20) + @ExcelProperty("确认收货时间") + public Date finishTime; + + +} diff --git a/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementModel.java b/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementModel.java new file mode 100644 index 0000000..d6106af --- /dev/null +++ b/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementModel.java @@ -0,0 +1,39 @@ +package com.hfkj.model.order.orderExport; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @ClassName MerOrderSettlementDetailModel + * @Author Sum1Dream + * @Description 商户订单结算详情 + * @Date 2024/9/29 上午10:50 + **/ +@Data +public class OrderSettlementModel { + + + @ColumnWidth(40) + @ExcelProperty("商户名称") + public String merName; + + @ColumnWidth(20) + @ExcelProperty("支付方式") + public String payType; + + @ColumnWidth(20) + @ExcelProperty("业务类型") + public String businessType; + + @ColumnWidth(20) + @ExcelProperty({"结算金额"}) + public BigDecimal payRealPrice; + + @ColumnWidth(30) + @ExcelProperty("结算日期") + public String time; +} diff --git a/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementSumModel.java b/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementSumModel.java new file mode 100644 index 0000000..2f59254 --- /dev/null +++ b/service/src/main/java/com/hfkj/model/order/orderExport/OrderSettlementSumModel.java @@ -0,0 +1,34 @@ +package com.hfkj.model.order.orderExport; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @ClassName MerOrderSettlementDetailModel + * @Author Sum1Dream + * @Description 商户订单结算详情 + * @Date 2024/9/29 上午10:50 + **/ +@Data +public class OrderSettlementSumModel { + + @ColumnWidth(20) + @ExcelProperty("业务类型") + public String businessType; + + @ColumnWidth(20) + @ExcelProperty("支付方式") + public String payType; + + @ColumnWidth(20) + @ExcelProperty({"结算金额"}) + public BigDecimal payRealPrice; + + @ColumnWidth(30) + @ExcelProperty("结算日期") + public String time; +} diff --git a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java index c8d8910..3897cac 100644 --- a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java +++ b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java @@ -41,4 +41,14 @@ public interface BsOrderCouponService { */ List getOrderList(Map param); + /** + * @MethodName getOrderCouponList + * @Description: 查询卡券订单列表 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午3:55 + */ + List getOrderCouponList(Map map); + } diff --git a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java index 145a8d5..d338822 100644 --- a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -67,5 +68,28 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService { return orderCouponMapper.getOrderList(param); } + @Override + public List getOrderCouponList(Map map) { + + BsOrderCouponExample example = new BsOrderCouponExample(); + BsOrderCouponExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andUpdateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andUpdateTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + criteria.andStatusEqualTo(2); + return orderCouponMapper.selectByExample(example); + } } diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderCinemaService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderCinemaService.java index f274be1..4b6ffb1 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderCinemaService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderCinemaService.java @@ -74,4 +74,15 @@ public interface BsOrderCinemaService { * @Date: 2024/7/4 下午2:35 */ List getList(Map map); + /** + * @MethodName getListFinish + * @Description: + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:24 + */ + List getListFinish(Map map); + + } diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java index 6cda295..26b8297 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java @@ -97,7 +97,7 @@ public interface BsOrderGoodsService { * @return java.util.List */ List getList(Map map); - List getList(); + List getListFinish(Map map); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderMeiTuanService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderMeiTuanService.java index c91156f..da7c3b5 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderMeiTuanService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderMeiTuanService.java @@ -2,6 +2,9 @@ package com.hfkj.service.goods; import com.hfkj.entity.BsOrderMeituan; +import java.util.List; +import java.util.Map; + public interface BsOrderMeiTuanService { /** @@ -62,6 +65,35 @@ public interface BsOrderMeiTuanService { */ BsOrderMeituan findOrderMeiTuanByTradeNo(String tradeNo); + /** + * @MethodName findOrderMeiTuanBySqtBizOrderId + * @Description: + * @param sqtBizOrderId + * @return: com.hfkj.entity.BsOrderMeituan + * @Author: Sum1Dream + * @Date: 2024/9/26 下午3:39 + */ + BsOrderMeituan findOrderMeiTuanBySqtBizOrderId(String sqtBizOrderId); + + /** + * @MethodName getOrderList + * @Description: 查询美团订单 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/26 下午1:45 + */ + List getOrderList(Map map); + /** + * @MethodName getOrderListFinish + * @Description: + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:34 + */ + List getOrderListFinish(Map map); + void orderFinish(String childNo); } diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderMemberService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderMemberService.java index d99bceb..2c14ec2 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderMemberService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderMemberService.java @@ -55,6 +55,15 @@ public interface BsOrderMemberService { * @Date: 2024/9/5 下午4:22 */ BsOrderMember findGoodsOrder(String orderNo); + /** + * @MethodName findGoodsOrderByChildNo + * @Description: 根据子订单号查询 + * @param childNo + * @return: com.hfkj.entity.BsOrderMember + * @Author: Sum1Dream + * @Date: 2024/9/25 上午10:50 + */ + BsOrderMember findGoodsOrderByChildNo(String childNo); /** * @MethodName queryDetailByMap @@ -75,4 +84,13 @@ public interface BsOrderMemberService { * @Date: 2024/9/5 下午4:27 */ List getList(Map map); + /** + * @MethodName getListFinish + * @Description: + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:38 + */ + List getListFinish(Map map); } diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderStarbucksService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderStarbucksService.java index 459cead..b2113ee 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderStarbucksService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderStarbucksService.java @@ -81,6 +81,15 @@ public interface BsOrderStarbucksService { * @Date: 2024/7/4 下午2:35 */ List getList(Map map); + /** + * @MethodName getListFinish + * @Description: + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:36 + */ + List getListFinish(Map map); /** * @MethodName updateOrderStatus diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java index 674a091..cc5c956 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java @@ -11,10 +11,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("bsOrderCinemaService") public class BsOrderCinemaServiceImpl implements BsOrderCinemaService { @@ -106,4 +103,31 @@ public class BsOrderCinemaServiceImpl implements BsOrderCinemaService { example.setOrderByClause("exception_status desc"); return bsOrderCinemaMapper.selectByExample(example); } + + @Override + public List getListFinish(Map map) { + BsOrderCinemaExample example = new BsOrderCinemaExample(); + BsOrderCinemaExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andUpdateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andUpdateTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + List statusList = new ArrayList<>(); + statusList.add(10); + statusList.add(15); + criteria.andStatusIn(statusList); + return bsOrderCinemaMapper.selectByExample(example); + } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java index 7a892fd..3f14474 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java @@ -194,9 +194,27 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { } @Override - public List getList() { + public List getListFinish(Map map) { BsOrderGoodsExample example = new BsOrderGoodsExample(); - + BsOrderGoodsExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } else { + criteria.andMerIdIsNotNull(); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + criteria.andStatusEqualTo(3); return bsOrderGoodsMapper.selectByExample(example); } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMeiTuanServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMeiTuanServiceImpl.java index 80f5550..e0f0ba6 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMeiTuanServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMeiTuanServiceImpl.java @@ -1,13 +1,21 @@ package com.hfkj.service.goods.impl; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.dao.BsOrderMeituanMapper; import com.hfkj.entity.BsOrderMeituan; import com.hfkj.entity.BsOrderMeituanExample; +import com.hfkj.meituan.MeiTuanService; import com.hfkj.service.goods.BsOrderMeiTuanService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.order.OrderChildStatusEnum; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.List; +import java.util.*; @Service("bsOrderMeiTuanService") public class BsOrderMeiTuanServiceImpl implements BsOrderMeiTuanService { @@ -15,6 +23,9 @@ public class BsOrderMeiTuanServiceImpl implements BsOrderMeiTuanService { @Resource private BsOrderMeituanMapper bsOrderMeituanMapper; + @Resource + private BsOrderService orderService; + @Override public void create(BsOrderMeituan orderMeiTuan) { bsOrderMeituanMapper.insert(orderMeiTuan); @@ -64,4 +75,142 @@ public class BsOrderMeiTuanServiceImpl implements BsOrderMeiTuanService { return null; } + + @Override + public BsOrderMeituan findOrderMeiTuanBySqtBizOrderId(String sqtBizOrderId) { + BsOrderMeituanExample example = new BsOrderMeituanExample(); + BsOrderMeituanExample.Criteria criteria = example.createCriteria(); + criteria.andSqtBizOrderIdEqualTo(sqtBizOrderId); + + List list = bsOrderMeituanMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + + @Override + public List getOrderList(Map map) { + BsOrderMeituanExample example = new BsOrderMeituanExample(); + BsOrderMeituanExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(map, "orderNo"))) { + criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "childOrderNo"))) { + criteria.andChildOrderNoEqualTo(MapUtils.getString(map, "childOrderNo")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "tradeNo"))) { + criteria.andChildOrderNoEqualTo(MapUtils.getString(map, "tradeNo")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(map, "userPhone"))) { + criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(map, "goodsName"))) { + criteria.andGoodsNameLike("%"+MapUtils.getString(map, "goodsName")+"%"); + } + + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (MapUtils.getLong(map, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); + } + if (MapUtils.getLong(map, "createTimeE") != null) { + criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); + } + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + example.setOrderByClause("create_time desc"); + return bsOrderMeituanMapper.selectByExample(example); + } + + @Override + public List getOrderListFinish(Map map) { + + BsOrderMeituanExample example = new BsOrderMeituanExample(); + BsOrderMeituanExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + criteria.andStatusEqualTo(3); + return bsOrderMeituanMapper.selectByExample(example); + } + + @Override + public void orderFinish(String childNo) { + + BsOrderMeituan orderMeiTuan = findOrderMeiTuan(childNo); + + if (orderMeiTuan != null) { + // 查询上游订单状态 + Map map = new HashMap<>(); + map.put("ts" , new Date().getTime()); + map.put("entId" , CommonSysConst.getSysConfig().getEntId()); + map.put("sqtBizOrderId" , orderMeiTuan.getSqtBizOrderId()); + JSONObject object = MeiTuanService.queryDetail(map); + Boolean finish = false; + Date finshDate = new Date(); + + if (object != null) { + // 订单基本信息 + JSONObject baseInfo = object.getJSONObject("baseInfo"); + // 业务信息字段 + JSONObject orderInfo = JSONObject.parseObject(object.getString("origOrderInfo")); + // 判断业务类型 + // 到店 + if (baseInfo.getString("firstBusinessType").equals("010")) { + // 判断是否完成 + if (orderInfo.getInteger("groupConsumeStatus") == 10) { + finish = true; + } + + } + // 外卖 + if (baseInfo.getString("firstBusinessType").equals("020")) { + // 判断是否完成 + if (orderInfo.getInteger("orderStatus") == 8) { + finish = true; + finshDate = DateUtil.StringToDate(orderInfo.getString("deliverTime") , "yyyy-MM-dd HH:mm:ss"); + } + } + + if (finish) { + // 子订单完成 + orderService.childOrderComplete(childNo); + orderMeiTuan.setFinishTime(finshDate); + orderMeiTuan.setUpdateTime(new Date()); + orderMeiTuan.setStatus(OrderChildStatusEnum.status3.getCode()); + update(orderMeiTuan); + } + + } + } + + + } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMemberServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMemberServiceImpl.java index 45c0389..00505b4 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMemberServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderMemberServiceImpl.java @@ -1,12 +1,17 @@ package com.hfkj.service.goods.impl; import com.hfkj.dao.BsOrderMemberMapper; +import com.hfkj.entity.BsOrderGoodsExample; import com.hfkj.entity.BsOrderMember; +import com.hfkj.entity.BsOrderMemberExample; import com.hfkj.service.goods.BsOrderMemberService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; @@ -41,6 +46,20 @@ public class BsOrderMemberServiceImpl implements BsOrderMemberService { return null; } + @Override + public BsOrderMember findGoodsOrderByChildNo(String childNo) { + BsOrderMemberExample example = new BsOrderMemberExample(); + example.createCriteria().andChildOrderNoEqualTo(childNo); + + List list = bsOrderMemberMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + @Override public BsOrderMember queryDetailByMap(Map map) { return null; @@ -48,6 +67,31 @@ public class BsOrderMemberServiceImpl implements BsOrderMemberService { @Override public List getList(Map map) { + return Collections.emptyList(); } + + @Override + public List getListFinish(Map map) { + BsOrderMemberExample example = new BsOrderMemberExample(); + BsOrderMemberExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + criteria.andStatusEqualTo(3); + return bsOrderMemberMapper.selectByExample(example); + } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java index af74557..1a59d75 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java @@ -95,6 +95,31 @@ public class BsOrderStarbucksServiceImpl implements BsOrderStarbucksService { return bsOrderStarbucksMapper.selectByExample(example); } + @Override + public List getListFinish(Map map) { + + BsOrderStarbucksExample example = new BsOrderStarbucksExample(); + BsOrderStarbucksExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "finishTimeS") != null) { + criteria.andUpdateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andUpdateTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE"))); + } + if (MapUtils.getLong(map, "merId") != null) { + criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId")); + } + if (MapUtils.getInteger(map, "payType") != null) { + criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platform"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platform")); + } + criteria.andStatusEqualTo(15); + return bsOrderStarbucksMapper.selectByExample(example); + } + @Override public void updateOrderStatus(String orderNo, Integer status) { // 查询星巴克订单 diff --git a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java index 4fedc1c..e0eb7df 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java @@ -1,18 +1,16 @@ package com.hfkj.service.order; import com.hfkj.common.utils.RedisUtil; -import com.hfkj.entity.BsOrderChild; -import com.hfkj.entity.BsOrderCoupon; -import com.hfkj.entity.BsOrderMeituan; -import com.hfkj.entity.GoodsMsg; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.*; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.service.coupon.BsOrderCouponService; -import com.hfkj.service.goods.BsOrderMeiTuanService; -import com.hfkj.service.goods.GoodsMsgService; -import com.hfkj.service.goods.GoodsSpecsService; +import com.hfkj.service.goods.*; +import com.hfkj.sysenum.GoodsVpdSourceEnum; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; +import com.hfkj.yushang.YuShangService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +21,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 取消订单业务 @@ -34,12 +34,8 @@ import java.util.List; @Component public class OrderCancelService { Logger log = LoggerFactory.getLogger(OrderCancelService.class); - @Autowired - private RedisUtil redisUtil; @Resource - private BsOrderService orderService; - @Resource - private BsOrderChildService orderChildService; + private GoodsVpdService goodsVpdService; @Resource private BsOrderCouponService orderCouponService; @Resource @@ -48,6 +44,8 @@ public class OrderCancelService { private GoodsSpecsService goodsSpecsService; @Resource private BsOrderMeiTuanService bsOrderMeiTuanService; + @Resource + private BsOrderMemberService bsOrderMemberService; /** * 订单业务处理 * @param order @@ -78,11 +76,26 @@ public class OrderCancelService { // 归库 goodsSpecsService.editStockNum(orderChild.getProductSpecId(), orderChild.getProductCount(), 1); - // 虚拟 - BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(orderChild.getChildOrderNo()); - orderCoupon.setCancelTime(new Date()); - orderCoupon.setStatus(OrderChildStatusEnum.status5.getCode()); - orderCouponService.editData(orderCoupon); + // 虚拟商品 + GoodsVpd vpd = goodsVpdService.queryDetailBySpecsId(orderChild.getProductSpecId()); + if (vpd.getSource() == GoodsVpdSourceEnum.type2.getCode()) { + BsOrderMember orderMember = bsOrderMemberService.findGoodsOrderByChildNo(orderChild.getChildOrderNo()); + + if (orderMember != null) { + orderMember.setUpdateTime(new Date()); + orderMember.setStatus(OrderChildStatusEnum.status5.getCode()); + bsOrderMemberService.update(orderMember); + } + + } else { + // 虚拟 + BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(orderChild.getChildOrderNo()); + orderCoupon.setCancelTime(new Date()); + orderCoupon.setStatus(OrderChildStatusEnum.status5.getCode()); + orderCouponService.editData(orderCoupon); + } + + } } diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index b5a68ae..5d35d79 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -20,13 +20,11 @@ import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.service.coupon.channel.HuiLianTongCouponService; import com.hfkj.service.goods.*; import com.hfkj.service.hlt.HuiLianTongUnionCardService; -import com.hfkj.service.impl.SecConfigServiceImpl; import com.hfkj.sysenum.GoodsVpdSourceEnum; import com.hfkj.sysenum.order.*; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -137,7 +135,7 @@ public class OrderCreateService { orderMember.setMerId(orderChild.getMerId()); orderMember.setPlatformCode(businessObj.getString("platformCode")); orderMember.setUserId(order.getUserId()); - orderMember.setUserPhone(order.getUserPhone()); + orderMember.setUserPhone(businessObj.getString("userPhone")); orderMember.setGoodsId(goodsMsg.getId()); orderMember.setGoodsName(goodsMsg.getTitle()); orderMember.setGoodsTypeId(goodsMsg.getGoodsType()); @@ -153,6 +151,8 @@ public class OrderCreateService { orderMember.setGoodsVpdSource(goodsVpd.getSource()); orderMember.setGoodsCount(orderChild.getProductCount()); orderMember.setStatus(OrderChildStatusEnum.status1.getCode()); + orderMember.setUpdateTime(new Date()); + orderMember.setCreateTime(new Date()); orderMemberService.create(orderMember); } @@ -541,7 +541,7 @@ public class OrderCreateService { orderChild.setMerId(productConfig.getMerId()); orderChild.setProductName(orderMeiTuan.getGoodsName()); orderChild.setProductCount(1); - orderChild.setProductImg("202409/1726638258182.png"); + orderChild.setProductImg("202409/1727150603020.png"); orderChild.setProductSpecName(orderMeiTuan.getGoodsName()); orderChild.setProductPrice(orderMeiTuan.getTotalPrice()); 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 becbe55..9b5d0f5 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -119,30 +119,31 @@ public class OrderPaySuccessService { if (vpd.getSource() == GoodsVpdSourceEnum.type2.getCode()) { - - Map map = new HashMap<>(); - map.put("productCode" , vpd.getKey()); - map.put("AppKey" , CommonSysConst.getSysConfig().getYuShangAppKey()); - map.put("BuyCount" , childOrder.getProductCount()); - map.put("MOrderID" , childOrder.getChildOrderNo()); - map.put("ChargeAccount" , childOrder.getChildOrderNo()); - // 推送给娱尚 - YuShangService.insertV2(map); - - BsOrderMember orderMember = new BsOrderMember(); - - orderMember.setTotalPrice(childOrder.getProductTotalPrice()); - orderMember.setTotalDeductionPrice(childOrder.getTotalDeductionPrice()); - orderMember.setCouponDiscountPrice(childOrder.getCouponDiscountPrice()); - orderMember.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice()); - orderMember.setPayRealPrice(childOrder.getSurplusRefundPrice()); - orderMember.setPayChannel(order.getPayChannel()); - orderMember.setPayType(order.getPayType()); - orderMember.setPaySerialNo(order.getPaySerialNo()); - orderMember.setPayTime(order.getPayTime()); - orderMember.setStatus(OrderChildStatusEnum.status3.getCode()); - orderMember.setUpdateTime(new Date()); - bsOrderMemberService.update(orderMember); + BsOrderMember orderMember = bsOrderMemberService.findGoodsOrderByChildNo(childOrder.getChildOrderNo()); + + if (orderMember != null) { + Map map = new HashMap<>(); + map.put("productCode" , vpd.getKey()); + map.put("AppKey" , CommonSysConst.getSysConfig().getYuShangAppKey()); + map.put("BuyCount" , childOrder.getProductCount()); + map.put("MOrderID" , childOrder.getChildOrderNo()); + map.put("ChargeAccount" , orderMember.getUserPhone()); + // 推送给娱尚 + YuShangService.insertV2(map); + orderMember.setTotalPrice(childOrder.getProductTotalPrice()); + orderMember.setTotalDeductionPrice(childOrder.getTotalDeductionPrice()); + orderMember.setCouponDiscountPrice(childOrder.getCouponDiscountPrice()); + orderMember.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice()); + orderMember.setPayRealPrice(childOrder.getSurplusRefundPrice()); + orderMember.setPayChannel(order.getPayChannel()); + orderMember.setPayType(order.getPayType()); + orderMember.setPaySerialNo(order.getPaySerialNo()); + orderMember.setPayTime(order.getPayTime()); + orderMember.setStatus(OrderChildStatusEnum.status3.getCode()); + orderMember.setFinishTime(new Date()); + orderMember.setUpdateTime(new Date()); + bsOrderMemberService.update(orderMember); + } } else { // 查询卡券订单的卡密 diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java index 35271d0..bd92ecc 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundSuccessService.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -36,9 +37,10 @@ public class OrderRefundSuccessService { private BsOrderCouponService orderCouponService; @Resource private BsOrderStarbucksService bsOrderStarbucksService; - @Autowired + @Resource private BsOrderMeiTuanServiceImpl bsOrderMeiTuanService; - + @Resource + private BsOrderChildService bsOrderChildService; /** * 订单业务处理 * @param orderChild @@ -129,22 +131,12 @@ public class OrderRefundSuccessService { */ public void meiTuan(BsOrderChild childOrder) { // 美团退款 - BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(childOrder.getOrderNo()); - - try { + BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(childOrder.getChildOrderNo()); - if (orderMeiTuan != null) { - Map map = new HashMap<>(); - map.put("orderNo", childOrder.getOrderNo()); - CinemaService.refundMovieOrder(map); - orderMeiTuan.setStatus(OrderChildStatusEnum.status4.getCode()); - orderMeiTuan.setRefundTime(new Date()); - orderMeiTuan.setExceptionStatus(false); - bsOrderMeiTuanService.update(orderMeiTuan); - } - } catch (Exception e) { - orderMeiTuan.setExceptionStatus(true); - orderMeiTuan.setExceptionMsg(e.getMessage()); + if (orderMeiTuan != null) { + orderMeiTuan.setStatus(OrderChildStatusEnum.status4.getCode()); + orderMeiTuan.setRefundTime(new Date()); + orderMeiTuan.setExceptionStatus(false); bsOrderMeiTuanService.update(orderMeiTuan); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderSettlementService.java b/service/src/main/java/com/hfkj/service/order/OrderSettlementService.java new file mode 100644 index 0000000..1f313f8 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/OrderSettlementService.java @@ -0,0 +1,47 @@ +package com.hfkj.service.order; + +import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; +import com.hfkj.model.order.orderExport.OrderSettlementModel; +import com.hfkj.model.order.orderExport.OrderSettlementSumModel; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName OrderSettlementService + * @Author Sum1Dream + * @Description 订单结算 + * @Date 2024/9/29 下午4:12 + **/ +public interface OrderSettlementService { + + /** + * @MethodName getDetail + * @Description: 获取结算订单详情 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:14 + */ + List getDetail(Map map); + + /** + * @MethodName getSettlement + * @Description: 结算订单 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:14 + */ + List getSettlement(Map map); + + /** + * @MethodName getSum + * @Description: 结算总和 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/9/29 下午4:14 + */ + List getSum(Map map); +} diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java index 8f8267f..1f5b990 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java @@ -3,8 +3,10 @@ package com.hfkj.service.order.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.utils.StarbucksUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.dao.BsOrderChildMapper; import com.hfkj.entity.*; +import com.hfkj.meituan.MeiTuanService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.qianzhu.StarbucksService; import com.hfkj.service.BsProductConfigService; @@ -15,6 +17,7 @@ import com.hfkj.service.order.BsOrderService; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderLogisticsStatusEnum; +import com.meituan.sqt.utils.EncryptUtil; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -50,6 +53,11 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { @Resource private BsOrderService orderService; + @Resource + private BsOrderMeiTuanService orderMeiTuanService; + + @Resource + private BsOrderMemberService orderMemberService; @Override public void editData(BsOrderChild data) { @@ -73,7 +81,6 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { return childModel; } return null; - } @Override @@ -128,7 +135,16 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { } } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { - childModel.setBusiness(goodsVpdService.queryDetailBySpecsId(childModel.getProductSpecId())); + + + GoodsVpd goodsVpd = goodsVpdService.queryDetailBySpecsId(childModel.getProductSpecId()); + if (goodsVpd.getSource() == 2) { + BsOrderMember orderMember = orderMemberService.findGoodsOrderByChildNo(childModel.getChildOrderNo()); + if (orderMember != null) { + goodsVpd.setExt1(orderMember.getUserPhone()); + } + } + childModel.setBusiness(goodsVpd); } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type4.getCode())) { BsProductConfig productConfig = bsProductConfigService.queryDetail(OrderChildProductTypeEnum.type4.getCode()); // 查询星巴克订单列表信息 @@ -200,6 +216,12 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { object.put("orderItemList", orderItemList); childModel.setBusiness(object); + } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) { + + if (childModel.getStatus().equals(OrderChildStatusEnum.status2.getCode())) { + orderMeiTuanService.orderFinish(childModel.getChildOrderNo()); + } + } orderChildModelList.add(childModel); } 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 bb9237f..9a244ea 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 @@ -255,13 +255,6 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { @Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) public BsOrderRefund meiTuanRefund(String tradeRefundNo, String tradeNo , BigDecimal refundPrice, String remark) { - // 查询退款订 - BsOrderRefund bsOrderRefund = getRefundByTradeRefundNo(tradeRefundNo); - - if (bsOrderRefund != null) { - return bsOrderRefund; - } - // 查询业务订单 BsOrderMeituan orderMeiTuan = orderMeiTuanService.findOrderMeiTuanByTradeNo(tradeNo); if (orderMeiTuan == null) { @@ -289,6 +282,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderRefund.setMerId(orderChild.getMerId()); orderRefund.setOrderNo(orderChild.getOrderNo()); orderRefund.setTradeRefundNo(tradeRefundNo); + orderRefund.setTradeRefundPrice(refundPrice); orderRefund.setOrderChildNo(orderChild.getChildOrderNo()); orderRefund.setUserId(order.getUserId()); orderRefund.setUserPhone(order.getUserPhone()); @@ -305,29 +299,26 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } else { // 部分退款 // 计算部分退款比例 - BigDecimal proportion = refundPrice.divide(orderChild.getProductTotalPrice() , 2 , RoundingMode.HALF_UP); + BigDecimal proportion = refundPrice.divide(orderMeiTuan.getTradeAmount() , 2 , RoundingMode.HALF_UP); // 退积分 Long unitPriceIntegral = new BigDecimal(orderChild.getIntegralDiscountPrice()).multiply(proportion).longValue(); // 退金额 - BigDecimal price = orderChild.getProductActualPrice().multiply(proportion); - - if (price.compareTo(new BigDecimal("0.01")) < 0) { - price = new BigDecimal(0); - } + BigDecimal price = orderChild.getProductActualPrice().multiply(proportion).setScale(2 , RoundingMode.HALF_UP); - // 插入退款积分 - if (unitPriceIntegral > orderChild.getSurplusRefundIntegral()) { + // 如果退积分大于可退那么按照可退处理 + if (unitPriceIntegral.compareTo(orderChild.getSurplusRefundIntegral()) >- 1) { + // 插入退款积分 orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral()); } else { orderRefund.setRefundIntegral(unitPriceIntegral); } - // 插入退款金额 - if (price.compareTo(orderChild.getSurplusRefundPrice()) > 0) { + // 如果退金额大于可退那么按照可退处理 + if (price.compareTo(orderChild.getSurplusRefundPrice()) >- 1) { + // 插入退款金额 orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice()); } else { orderRefund.setRefundPrice(price); } - } @@ -355,33 +346,26 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { editData(orderRefund); - - if (orderRefund.getRefundPrice().compareTo(new BigDecimal(0)) > 0) { - // 资金退款 - orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); - } else { - orderRefund.setRefundStatus(OrderRefundStatusEnum.status2.getCode()); - } - + // 资金退款 + orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); editData(orderRefund); // 退款成功 if (orderRefund.getRefundStatus().equals(OrderRefundStatusEnum.status2.getCode())) { // 修改子订单可退数量、金额、积分 -// orderChild.setSurplusRefundCount(orderChild.getSurplusRefundCount() - productCount); orderChild.setSurplusRefundPrice(orderChild.getSurplusRefundPrice().subtract(orderRefund.getRefundPrice())); orderChild.setSurplusRefundIntegral(orderChild.getSurplusRefundIntegral() - orderRefund.getRefundIntegral()); - orderChild.setStatus(orderChild.getSurplusRefundCount()==0?OrderChildStatusEnum.status4.getCode():orderChild.getStatus()); - - // 退款业务处理 - orderRefundSuccessService.orderRefundHandle(orderChild); + orderChild.setStatus(orderChild.getSurplusRefundPrice().compareTo(new BigDecimal(0)) == 0 && orderChild.getSurplusRefundIntegral() == 0?OrderChildStatusEnum.status4.getCode():orderChild.getStatus()); orderChildService.editData(orderChild); // 查询子订单已全部退款 Map map = new HashMap<>(); map.put("orderNo", orderChild.getOrderNo()); List orderChildList = orderChildService.getList(map); + if (orderChildList.size() == orderChildList.stream().filter(o->o.getStatus().equals(OrderChildStatusEnum.status4.getCode())).collect(Collectors.toList()).size()) { + // 退款业务处理 + orderRefundSuccessService.orderRefundHandle(orderChild); order.setOrderStatus(OrderStatusEnum.status4.getCode()); order.setRefundTime(new Date()); orderService.editData(order); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 9d9a78f..442cb00 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -579,6 +579,7 @@ public class BsOrderServiceImpl implements BsOrderService { } + } return orderModel; diff --git a/service/src/main/java/com/hfkj/service/order/impl/OrderSettlementServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/OrderSettlementServiceImpl.java new file mode 100644 index 0000000..ffd1630 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/impl/OrderSettlementServiceImpl.java @@ -0,0 +1,374 @@ +package com.hfkj.service.order.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.entity.*; +import com.hfkj.model.order.OrderCouponModel; +import com.hfkj.model.order.orderExport.MerOrderSettlementDetailModel; +import com.hfkj.model.order.orderExport.OrderSettlementModel; +import com.hfkj.model.order.orderExport.OrderSettlementSumModel; +import com.hfkj.service.BsMerService; +import com.hfkj.service.coupon.BsOrderCouponService; +import com.hfkj.service.goods.*; +import com.hfkj.service.order.OrderSettlementService; +import com.hfkj.sysenum.UserLoginPlatform; +import com.hfkj.sysenum.mer.PayPlatformEnum; +import com.hfkj.sysenum.order.OrderPayTypeEnum; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +@Service("orderSettlementService") +public class OrderSettlementServiceImpl implements OrderSettlementService { + + @Resource + private BsOrderCouponService orderCouponService; + @Resource + private BsOrderGoodsService goodsService; + @Resource + private BsOrderCinemaService cinemaService; + @Resource + private BsOrderStarbucksService starbucksService; + @Resource + private BsOrderMeiTuanService meiTuanService; + @Resource + private BsOrderMemberService memberService; + @Resource + private BsMerService bsMerService; + @Override + public List getDetail(Map map) { + return settlementData(map); + } + + @Override + public List getSettlement(Map map) { + + List list = settlementData(map); + + Map> merList = list.stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getMerName)); + + List settlementModels = new ArrayList<>(); + OrderSettlementModel settlementModel; + + for (String key : merList.keySet()) { + Map> detailList = merList.get(key).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getBusinessType)); + for (String key1 : detailList.keySet()) { + Map> listMap = detailList.get(key1).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getPayType)); + for (String key2 : listMap.keySet()) { + settlementModel = new OrderSettlementModel(); + if (map.get("finishTimeS") == null) { + settlementModel.setTime("全时间段"); + } else { + settlementModel.setTime(map.get("finishTimeS") + "-" + map.get("finishTimeE")); + } + settlementModel.setPayType(key2); + settlementModel.setBusinessType(key1); + settlementModel.setMerName(key); + BigDecimal reduce = listMap.get(key2).stream().map(MerOrderSettlementDetailModel::getPayRealPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + settlementModel.setPayRealPrice(reduce); + settlementModels.add(settlementModel); + } + + + } + + } + return settlementModels; + } + + + @Override + public List getSum(Map map) { + + List list = settlementData(map); + + + List sumModels = new ArrayList<>(); + OrderSettlementSumModel sumModel; + + Map> detailList = list.stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getBusinessType)); + for (String key1 : detailList.keySet()) { + Map> listMap = detailList.get(key1).stream().collect(Collectors.groupingBy(MerOrderSettlementDetailModel:: getPayType)); + for (String key2 : listMap.keySet()) { + sumModel = new OrderSettlementSumModel(); + if (map.get("finishTimeS") == null) { + sumModel.setTime("全时间段"); + } else { + sumModel.setTime(map.get("finishTimeS") + "-" + map.get("finishTimeE")); + } + sumModel.setPayType(key2); + sumModel.setBusinessType(key1); + BigDecimal reduce = listMap.get(key2).stream().map(MerOrderSettlementDetailModel::getPayRealPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + sumModel.setPayRealPrice(reduce); + sumModels.add(sumModel); + } + + + } + return sumModels; + } + + // 查询结算订单详情 + private List settlementData(Map map) { + List list = new ArrayList<>(); + // 卡券订单整合 + list = couponOrder(map , list); + // 查询实物订单 + list = goodsOrder(map , list); + // 查询电影票订单 + list = cinemaOrder(map , list); + // 查询星巴克 + list = starbucksOrder(map , list); + // 查询美团订单 + list = meiTuanOrder(map , list); + // 查询会员订单 + list = membersOrder(map , list); + + return list; + } + + // 实物订单整合 + private List goodsOrder(Map map, List list) { + // 查询实物订单 + List orderGoodsList = goodsService.getListFinish(map); + MerOrderSettlementDetailModel model; + for (BsOrderGoods orderGoods : orderGoodsList) { + model = new MerOrderSettlementDetailModel(); + model.setBusinessType("实物订单"); + model.setGoodsName(orderGoods.getGoodsName()); + model.setMerName(findMerName(orderGoods.getMerId())); + if (orderGoods.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderGoods.getPlatformCode()).getName()); + } + model.setOrderNo(orderGoods.getOrderNo()); + model.setChildOrderNo(orderGoods.getChildOrderNo()); + model.setBusiness(orderGoods.getLogisticsNo()); + if (orderGoods.getPayRealPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderGoods.getPayRealPrice()); + } + + if (orderGoods.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderGoods.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + if (orderGoods.getFinishTime() != null) { + model.setFinishTime(DateUtil.date2String(orderGoods.getFinishTime() , DateUtil.Y_M_D_HMS)); + } else { + model.setFinishTime(DateUtil.date2String(orderGoods.getUpdateTime() , DateUtil.Y_M_D_HMS)); + } + + list.add(model); + } + return list; + } + + // 卡券订单整合 + private List couponOrder(Map map , List list) { + // 查询卡券订单 + List orderCouponList = orderCouponService.getOrderCouponList(map); + Map mapCou = new HashMap<>(); + mapCou.put("couStatus", 2); + // 查询卡券订单卡密 + List orderCouponModelList = orderCouponService.getOrderList(mapCou); + + MerOrderSettlementDetailModel model; + for (BsOrderCoupon orderCoupon : orderCouponList) { + String business = couponCode(orderCoupon.getChildOrderNo() , orderCouponModelList); + if (business != null) { + model = new MerOrderSettlementDetailModel(); + model.setGoodsName(orderCoupon.getGoodsName()); + model.setBusinessType("卡券订单"); + model.setMerName(findMerName(orderCoupon.getMerId())); + if (orderCoupon.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderCoupon.getPlatformCode()).getName()); + } + model.setOrderNo(orderCoupon.getOrderNo()); + model.setChildOrderNo(orderCoupon.getChildOrderNo()); + model.setBusiness(business); + if (orderCoupon.getPayRealPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderCoupon.getPayRealPrice()); + } + if (orderCoupon.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderCoupon.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + model.setFinishTime(DateUtil.date2String(orderCoupon.getUpdateTime() , DateUtil.Y_M_D_HMS)); + list.add(model); + } + + } + + return list; + } + // 整合电影票订单 + private List cinemaOrder(Map map, List list) { + // 查询电影票订单 + List orderCinemaList = cinemaService.getListFinish(map); + MerOrderSettlementDetailModel model; + for (BsOrderCinema orderCinema : orderCinemaList) { + model = new MerOrderSettlementDetailModel(); + model.setBusinessType("电影票订单"); + model.setGoodsName(orderCinema.getGoodsName()); + model.setMerName(findMerName(orderCinema.getMerId())); + if (orderCinema.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderCinema.getPlatformCode()).getName()); + } + model.setOrderNo(orderCinema.getOrderNo()); + model.setChildOrderNo(orderCinema.getChildOrderNo()); + if (orderCinema.getPayRealPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderCinema.getPayRealPrice()); + } + if (orderCinema.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderCinema.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + if (orderCinema.getFinishTime() != null) { + model.setFinishTime(DateUtil.date2String(orderCinema.getFinishTime() , DateUtil.Y_M_D_HMS)); + } else { + model.setFinishTime(DateUtil.date2String(orderCinema.getUpdateTime() , DateUtil.Y_M_D_HMS)); + } + + list.add(model); + } + return list; + } + + // 整合星巴克订单 + private List starbucksOrder(Map map, List list) { + // 查询星巴克 + List orderStarbucksList = starbucksService.getListFinish(map); + MerOrderSettlementDetailModel model; + for (BsOrderStarbucks orderStarbucks : orderStarbucksList) { + model = new MerOrderSettlementDetailModel(); + model.setBusinessType("星巴克订单"); + model.setGoodsName(orderStarbucks.getName()); + model.setMerName(findMerName(orderStarbucks.getMerId())); + if (orderStarbucks.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderStarbucks.getPlatformCode()).getName()); + } + model.setOrderNo(orderStarbucks.getOrderNo()); + model.setChildOrderNo(orderStarbucks.getChildOrderNo()); + if (orderStarbucks.getPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderStarbucks.getPrice()); + } + if (orderStarbucks.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderStarbucks.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + model.setFinishTime(DateUtil.date2String(orderStarbucks.getUpdateTime() , DateUtil.Y_M_D_HMS)); + list.add(model); + } + return list; + } + // 整合美团订单 + private List meiTuanOrder(Map map, List list) { + // 查询美团订单 + List orderMeituanList = meiTuanService.getOrderListFinish(map); + MerOrderSettlementDetailModel model; + for (BsOrderMeituan orderMeiTuan : orderMeituanList) { + model = new MerOrderSettlementDetailModel(); + model.setBusinessType("美团订单"); + model.setGoodsName(orderMeiTuan.getGoodsName()); + model.setMerName(findMerName(orderMeiTuan.getMerId())); + if (orderMeiTuan.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderMeiTuan.getPlatformCode()).getName()); + } + model.setOrderNo(orderMeiTuan.getOrderNo()); + model.setChildOrderNo(orderMeiTuan.getChildOrderNo()); + if (orderMeiTuan.getPayRealPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderMeiTuan.getPayRealPrice()); + } + if (orderMeiTuan.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderMeiTuan.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + if (orderMeiTuan.getFinishTime() != null) { + model.setFinishTime(DateUtil.date2String(orderMeiTuan.getFinishTime() , DateUtil.Y_M_D_HMS)); + } else { + model.setFinishTime(DateUtil.date2String(orderMeiTuan.getUpdateTime() , DateUtil.Y_M_D_HMS)); + } + list.add(model); + } + return list; + } + // 整合会员订单 + private List membersOrder(Map map, List list) { + // 查询会员订单 + List orderMembersList = memberService.getListFinish(map); + MerOrderSettlementDetailModel model; + for (BsOrderMember orderMember : orderMembersList) { + model = new MerOrderSettlementDetailModel(); + model.setBusinessType("会员订单"); + model.setGoodsName(orderMember.getGoodsName()); + model.setMerName(findMerName(orderMember.getMerId())); + if (orderMember.getPlatformCode() != null) { + model.setPlatform(UserLoginPlatform.getDataByType(orderMember.getPlatformCode()).getName()); + } + model.setOrderNo(orderMember.getOrderNo()); + model.setChildOrderNo(orderMember.getChildOrderNo()); + if (orderMember.getPayRealPrice() == null) { + model.setPayRealPrice(new BigDecimal(0)); + } else { + model.setPayRealPrice(orderMember.getPayRealPrice()); + } + if (orderMember.getPayType() != null) { + model.setPayType(OrderPayTypeEnum.getData(orderMember.getPayType()).getName()); + } else { + model.setPayType("未知"); + } + if (orderMember.getFinishTime() != null) { + model.setFinishTime(DateUtil.date2String(orderMember.getFinishTime() , DateUtil.Y_M_D_HMS)); + } else { + model.setFinishTime(DateUtil.date2String(orderMember.getUpdateTime() , DateUtil.Y_M_D_HMS)); + } + list.add(model); + } + return list; + } + + + private String findMerName(Long merId) { + // 查询商户 + List bsMerList = bsMerService.getList(new HashMap<>()); + + bsMerList = bsMerList.stream().filter(s -> s.getId().equals(merId)).collect(Collectors.toList()); + + if (bsMerList.size() > 0) { + return bsMerList.get(0).getMerName(); + } + return merId.toString(); + } + + private String couponCode(String childOrderNo , List orderCouponModelList) { + + orderCouponModelList = orderCouponModelList.stream().filter(s -> s.getChildOrderNo().equals(childOrderNo)).collect(Collectors.toList()); + + if (!orderCouponModelList.isEmpty()) { + StringBuilder sb = new StringBuilder(); + + for (OrderCouponModel orderCouponModel : orderCouponModelList) { + sb.append(orderCouponModel.getCouNo()).append(","); + } + return sb.substring(0, sb.length() - 1); + } + return null; + } +} diff --git a/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java b/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java index d69d297..355630c 100644 --- a/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java +++ b/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java @@ -10,7 +10,7 @@ import java.util.Objects; **/ public enum UserLoginPlatform { H5("H5", "H5客户端"), - WXAPPLETS("WXAPPLETS", "微信小程序"), + WXAPPLETS("WXAPPLETS", "普汇GO"), VFAMILY("VFAMILY", "V家园"), GZGOV("GZGOV", "省自机关"), ; diff --git a/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java b/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java index b4da574..842d9ed 100644 --- a/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/fileRecords/FileRecordsEnum.java @@ -51,6 +51,18 @@ public enum FileRecordsEnum { * 退款记录 */ status9(9, "退款记录"), + /** + * 导出结算详情 + */ + status10(10, "结算详情"), + /** + * 导出结算统计 + */ + status11(11, "结算统计"), + /** + * 导出结算总和 + */ + status12(12, "结算总和"), ; private final int code; diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index ad37f73..68c3ad5 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -72,7 +72,7 @@ ctMemberId=1622808562621276161 ctPostUrl=http://113.250.49.100:8088/recharge/ -mtNotifyUrl = https://phg.dctpay.com/order/cinemaNotify/notify +entId=68465 mtAccessKey=DVNKSHSDHHJ6-TK mtSecretKey=lj2YDjGnqroY1OuR5zriWg== mtPostUrl=https://waimai-openapi.apigw.test.meituan.com/api/sqt/open/login/h5/loginFree/redirection?test_open_swimlane=test-open diff --git a/service/src/main/resources/prod/commonConfig.properties b/service/src/main/resources/prod/commonConfig.properties index b5a0f84..319d31b 100644 --- a/service/src/main/resources/prod/commonConfig.properties +++ b/service/src/main/resources/prod/commonConfig.properties @@ -56,6 +56,13 @@ huiftReqUrl=https://gzyhmp.huift.com.cn huiftShopCode=20240653-59c4-4181-9157-17fd4b95c3fc huiftSignSecret=19C17F9E19B8DDDDF2FD2EE4EA9F6C61 + + +entId=68465 +mtAccessKey=DYCUPRFHDVY9-TK +mtSecretKey=6TnzPWsQr/45BW4DIKZJDQ== +mtPostUrl=https://bep-openapi.meituan.com/api/sqt/open/ + #QIANZHU qianZhuUrl=https://live.qianzhu8.com qianzhuH5url=https://nf.qianzhu8.com/gateway