diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index db96b0d..b8603aa 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -6,9 +6,21 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.*; import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsMerPayConfig; +import com.hfkj.entity.BsOrder; +import com.hfkj.entity.BsUserCard; +import com.hfkj.jd.JdService; +import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.ResponseData; +import com.hfkj.model.order.OrderModel; +import com.hfkj.qianzhu.CinemaService; +import com.hfkj.service.card.BsUserCardService; +import com.hfkj.service.hlt.HuiLianTongUnionCardService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.OrderPayService; import com.hfkj.service.pay.huift.TradeService; +import com.hfkj.sysenum.mer.PayPlatformEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -19,6 +31,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; @@ -29,7 +42,14 @@ public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Resource private TradeService huiftTradeService; - + @Resource + private BsOrderService orderService; + @Resource + private BsMerPayConfigService merPayConfigService; + @Resource + private OrderPayService orderPayService; + @Resource + private BsUserCardService userCardService; @RequestMapping(value="/thirdPayResult",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询V家园订单交易状态") @@ -70,4 +90,46 @@ public class TestController { } } + @RequestMapping(value="/refundMovieOrder",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "refundMovieOrder") + public ResponseData refundMovieOrder(@RequestParam(value = "orderNo" , required = true) String orderNo, + @RequestParam(value = "payRealPrice" , required = true) BigDecimal payRealPrice, + @RequestParam(value = "cardNo" , required = true) String cardNo) { + try { + + + // 工会卡支付 + JSONObject consumption = HuiLianTongUnionCardService.consumption(orderNo, cardNo, payRealPrice, "HiSen_phg_goods", "11101608", "", "241001130753599939订单扣款"); + if (!consumption.getString("respCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); + } + // 响应参数 + JSONObject consumptionResult = HuiLianTongUnionCardService.resolveResponse(consumption.getString("data")); + if (consumptionResult.getBoolean("success") != true) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); + } + + return ResponseMsgUtil.success(consumptionResult); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getAccessToken",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "getAccessToken") + public ResponseData getAccessToken() { + try { + + return ResponseMsgUtil.success(JdService.getAccessToken()); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + } 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/lib/open-api-sdk-2.0-jd.jar b/order/lib/open-api-sdk-2.0-jd.jar new file mode 100644 index 0000000..6c1b46c Binary files /dev/null and b/order/lib/open-api-sdk-2.0-jd.jar differ diff --git a/order/pom.xml b/order/pom.xml index 350cc1d..0eac16d 100644 --- a/order/pom.xml +++ b/order/pom.xml @@ -32,6 +32,13 @@ 1.0.21 ${basedir}/lib/open-platform-sdk-1.0.21.jar + + jd.skd + jd-open-sdk + system + 2.0 + ${basedir}/lib/open-api-sdk-2.0-jd.jar + diff --git a/order/src/main/java/com/order/config/AuthConfig.java b/order/src/main/java/com/order/config/AuthConfig.java index 162eeb5..0c44c5c 100644 --- a/order/src/main/java/com/order/config/AuthConfig.java +++ b/order/src/main/java/com/order/config/AuthConfig.java @@ -87,6 +87,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/**/springfox-swagger-ui/**") .excludePathPatterns("/**/swagger-ui.html") .excludePathPatterns("/notify/*") + .excludePathPatterns("/jdNotify/*") .excludePathPatterns("/cqNotify/*") .excludePathPatterns("/meiTuan/*") .excludePathPatterns("/orderCinema/queryOrder") 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..d575013 --- /dev/null +++ b/order/src/main/java/com/order/controller/business/OrderSettlementController.java @@ -0,0 +1,455 @@ +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(MerOrderSettlementDetailModel.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, 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.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(OrderSettlementModel.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, 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.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(OrderSettlementSumModel.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/JdNotify.java b/order/src/main/java/com/order/controller/notify/JdNotify.java new file mode 100644 index 0000000..061f66c --- /dev/null +++ b/order/src/main/java/com/order/controller/notify/JdNotify.java @@ -0,0 +1,69 @@ +package com.order.controller.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.config.CommonSysConst; +import com.hfkj.jd.JdService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +@Controller +@RequestMapping(value = "/jdNotify") +@Api(value = "京东回调") +public class JdNotify { + private static final Logger log = LoggerFactory.getLogger(JdService.class); + + @RequestMapping(value = "/notify", method = RequestMethod.POST) + @ApiOperation(value = "回调") + @ResponseBody + public void notify(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { + try { + + JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); + + log.info("============回调任务Start============="); + log.info("尖椒订单充值-回调参数: " + dataObject); + log.info("============回调任务End============="); + + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + @RequestMapping(value = "/callbackToken", method = RequestMethod.GET) + @ApiOperation(value = "token回调") + @ResponseBody + public void notify(@RequestParam("code") String code) { + try { + + log.info("============token回调任务Start============="); + log.info("token回调-回调参数: " + code); + JSONObject object = new JSONObject(); + object.put("app_key", CommonSysConst.getSysConfig().getJDAppKey()); + object.put("app_secret", CommonSysConst.getSysConfig().getJDAppSecret()); + object.put("code", code); + object.put("grant_type", "authorization_code"); + JSONObject jsonObject = HttpsUtils.doGet("https://open-oauth.jd.com/oauth2/authorizeForVOP", object); + log.info("token回调-回调参数: " + jsonObject); + log.info("============token回调任务End============="); + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", 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..bb881d0 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/order/src/main/resources/dev/logback.xml b/order/src/main/resources/dev/logback.xml index 9d782ad..63b61cb 100644 --- a/order/src/main/resources/dev/logback.xml +++ b/order/src/main/resources/dev/logback.xml @@ -311,4 +311,26 @@ + + + + log/JdLog.log + + log/JdLog/JdLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/service/lib/open-api-sdk-2.0-jd.jar b/service/lib/open-api-sdk-2.0-jd.jar new file mode 100644 index 0000000..6c1b46c Binary files /dev/null and b/service/lib/open-api-sdk-2.0-jd.jar differ diff --git a/service/pom.xml b/service/pom.xml index 7945b8d..4218c49 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -263,6 +263,13 @@ 1.0.21 ${basedir}/lib/open-platform-sdk-1.0.21.jar + + jd.skd + jd-open-sdk + system + 2.0 + ${basedir}/lib/open-api-sdk-2.0-jd.jar + diff --git a/service/src/main/java/com/hfkj/common/utils/DateUtil.java b/service/src/main/java/com/hfkj/common/utils/DateUtil.java index b654326..0b77791 100644 --- a/service/src/main/java/com/hfkj/common/utils/DateUtil.java +++ b/service/src/main/java/com/hfkj/common/utils/DateUtil.java @@ -48,7 +48,7 @@ public class DateUtil { return str; } - public static Date long2Date(Long time) throws Exception{ + public static Date long2Date(Long time){ if(time != null){ return new Date(time); }else{ diff --git a/service/src/main/java/com/hfkj/common/utils/RsaCoderUtils.java b/service/src/main/java/com/hfkj/common/utils/RsaCoderUtils.java new file mode 100644 index 0000000..d8b7616 --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/RsaCoderUtils.java @@ -0,0 +1,113 @@ +package com.hfkj.common.utils; + +import javafx.util.Pair; +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; + +public final class RsaCoderUtils { + + /** + * 生成公私钥 + * + * @return + * @throws NoSuchAlgorithmException + */ + public static Pair genKeyPair() throws NoSuchAlgorithmException { + // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象 + KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); + // 初始化密钥对生成器,密钥大小为96-1024位 + keyPairGen.initialize(1024, new SecureRandom()); + // 生成一个密钥对,保存在keyPair中 + KeyPair keyPair = keyPairGen.generateKeyPair(); + // 得到私钥 + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + // 得到公钥 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + String publicKeyString = new String(Base64.encodeBase64(publicKey.getEncoded())); + // 得到私钥字符串 + String privateKeyString = new String(Base64.encodeBase64((privateKey.getEncoded()))); + return new Pair<>(publicKeyString, privateKeyString); + } + + /** + * RSA私钥加密 + * + * @param str 加密字符串 + * @param privateKey 私钥 + * @return 密文 + * @throws Exception 加密过程中的异常信息 + */ + public static String encryptByPrivateKey(String str, String privateKey) throws Exception { + //base64编码的公钥 + byte[] decoded = Base64.decodeBase64(privateKey); + RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); + //RSA解密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, priKey); + return Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); + } + + /** + * RSA公钥加密 + * + * @param str 加密字符串 + * @return 密文 + * @throws Exception 加密过程中的异常信息 + */ + public static String encryptByPublicKey(String str, String publicKey) throws Exception { + //base64编码的公钥 + byte[] decoded = Base64.decodeBase64(publicKey); + RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); + //RSA加密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, pubKey); + return Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); + } + + /** + * RSA公钥解密 + * + * @param str 加密字符串 + * @param publicKey 公钥 + * @return 铭文 + * @throws Exception 解密过程中的异常信息 + */ + public static String decryptByPublicKey(String str, String publicKey) throws Exception { + //64位解码加密后的字符串 + byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); + //base64编码的私钥 + byte[] decoded = Base64.decodeBase64(publicKey); + RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); + //RSA加密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, pubKey); + return new String(cipher.doFinal(inputByte)); + } + + /** + * RSA私钥解密 + * + * @param str 加密字符串 + * @return 铭文 + * @throws Exception 解密过程中的异常信息 + */ + public static String decryptByPrivateKey(String str, String privateKey) throws Exception { + //64位解码加密后的字符串 + byte[] inputByte = Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)); + //base64编码的私钥 + byte[] decoded = Base64.decodeBase64(privateKey); + RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); + //RSA解密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, priKey); + return new String(cipher.doFinal(inputByte)); + } +} + diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index 123f966..201da5a 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; @@ -153,4 +153,11 @@ public class CommonSysConfig { private String haiOilAppid; private String haiOilAppSecret; + /** + * 京东请求参数 + */ + private String jDPostUrl; + private String jDAppKey; + private String jDAppSecret; + } diff --git a/service/src/main/java/com/hfkj/jd/JdService.java b/service/src/main/java/com/hfkj/jd/JdService.java new file mode 100644 index 0000000..46143bc --- /dev/null +++ b/service/src/main/java/com/hfkj/jd/JdService.java @@ -0,0 +1,63 @@ +package com.hfkj.jd; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.common.utils.RsaCoderUtils; +import com.hfkj.config.CommonSysConst; +import com.hfkj.meituan.MeiTuanService; +import com.jd.open.api.sdk.DefaultJdClient; +import com.jd.open.api.sdk.JdClient; +import org.apache.commons.codec.digest.DigestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URLEncoder; +import java.util.Map; + +/** + * @ClassName JdService + * @Author Sum1Dream + * @Description 京东服务 + * @Date 2024/10/11 下午3:25 + **/ +public class JdService { + private static Logger log = LoggerFactory.getLogger(JdService.class); + + /** + * UTF_8 + */ + public static final String UTF_8 = "utf-8"; + /** + * 用户名 + */ + private static final String USERNAME = "惠兑重庆VOP", + /** + * 明文密码,后续需要通过RSA加密 + */ + PLAINTEXT_PASSWORD = "hdcs1234", + /** + * 回调地址,注册应用时配置的授权回调地址 + */ + REDIRECT_URI = CommonSysConst.getSysConfig().getDomainName() + "/order/jdNotify/callbackToken", + /** + * RSA私钥 + */ + PRIVATE_RSA_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMEtt0kF02YBxPXzXyqzCtr1zkuj8NXLiqqSCDAfU6zWB1T1GUEpCfNukPBeZ9nXGj+jbTom8RFllNXbnOkW01Zn2VoyePh8TRWQbToXi+i/JQ162GzpF0GdPsUhJSrB5Z2QzK4UVXXkpPHhQHR8NKQhvTRkoRLfOy+oXWL8PS2hAgMBAAECgYBySo/j/jRiZ62WLlUhuCg1/7P8AJSeiPwTiq6Zeg9RdJeF5jT43kTq54GNFO2wbpkzCYe4Hg4GUulJ1dLx/PUvYquRpM4jGznxDxBA10mNyjx0O+SHcY+ZlOYWIKhEq4MeeJhtHhoFrlgcMNIyofhRDbFzrRak48GrcZDQC4/cIQJBAPwxtEwMnetPveLExR1UsygdVKwoWoGNL5Hkhcx6b2N2Qapk5aHB5haUEXeg1ShrL4C/kE1lsMAIdpVS9lWd4x0CQQDEGASnnB2oPHjvNfj88klpYTvPJRi3ORQPtlfz36kv+29QFxB9Mt1u39ttopw5G2x7QvTtL542w878brrmS8lVAkEA4k7QFjZ0N8cVBLvCjrGFG4hGhT6pCPxjJa5GCtoLvttNzdRA5EkVaklw60LeRSj6NbSxj2Kjm498qj8KYoYOWQJATJhRISMy1mcgmdeMNUlycW4gjY4g9FigRG7mNgU0MeDVnwQTVcQLiGZ6cH2m5guXOSJzRz5lX2DmteWOrawGrQJBAMKLfeTnYkVpXw9MABcR/9L9myG3FKwOHBIqD0wK+QVahi9byFk8GFXD4OlBQ1ZSxHqsUuxWqLVSa3sWBCKpLo8="; + + public static JSONObject getAccessToken() throws Exception { + String encodeRedirectUri = URLEncoder.encode(REDIRECT_URI, UTF_8); + String encodeUsername = URLEncoder.encode(USERNAME, UTF_8); + String md5Password = DigestUtils.md5Hex(PLAINTEXT_PASSWORD); + String ciphertextPassword = RsaCoderUtils.encryptByPrivateKey(md5Password, PRIVATE_RSA_KEY); + String encodePassword = URLEncoder.encode(ciphertextPassword, UTF_8); + + JSONObject object = new JSONObject(); + object.put("app_key", CommonSysConst.getSysConfig().getJDAppKey()); + object.put("redirect_uri", encodeRedirectUri); + object.put("username", encodeUsername); + object.put("password", encodePassword); + object.put("response_type", "code"); + object.put("scope", "snsapi_base"); + return HttpsUtils.doGet("https://open-oauth.jd.com/oauth2/authorizeForVOP", object); + } +} 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..f2be9c2 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.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andCreateTimeLessThan(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..b1badc3 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); } @@ -308,7 +326,9 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { orderService.childOrderComplete(orderGoods.getChildOrderNo()); orderGoods.setStatus(OrderChildStatusEnum.status3.getCode()); orderGoods.setUpdateTime(new Date()); - orderGoods.setFinishTime(new Date()); + if (orderGoods.getFinishTime() == null) { + orderGoods.setFinishTime(new Date()); + } update(orderGoods); // 删除缓存 orderService.cacheDelete(orderGoods.getOrderNo()); 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..5553bf7 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.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS"))); + } + if (MapUtils.getLong(map, "finishTimeE") != null) { + criteria.andCreateTimeLessThan(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..ffb9fd1 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -22,6 +22,8 @@ import com.hfkj.service.goods.*; import com.hfkj.service.goods.impl.BsOrderStarbucksServiceImpl; import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.sysenum.GoodsVpdSourceEnum; +import com.hfkj.sysenum.UserLoginPlatform; +import com.hfkj.sysenum.mer.PayPlatformEnum; import com.hfkj.sysenum.order.*; import com.hfkj.yushang.YuShangService; import org.slf4j.Logger; @@ -119,30 +121,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 { // 查询卡券订单的卡密 @@ -368,6 +371,12 @@ public class OrderPaySuccessService { orderMeiTuan.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice()); orderMeiTuan.setPayRealPrice(childOrder.getSurplusRefundPrice()); orderMeiTuan.setPayChannel(order.getPayChannel()); + if (order.getPayType() == OrderPayTypeEnum.type3.getCode()) { + orderMeiTuan.setPlatformCode(UserLoginPlatform.VFAMILY.getCode()); + } + if (order.getPayType() == OrderPayTypeEnum.type4.getCode()) { + orderMeiTuan.setPlatformCode(UserLoginPlatform.WXAPPLETS.getCode()); + } orderMeiTuan.setPayType(order.getPayType()); orderMeiTuan.setPaySerialNo(order.getPaySerialNo()); orderMeiTuan.setPayTime(order.getPayTime()); 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..69b8d96 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 @@ -106,7 +108,7 @@ public class OrderRefundSuccessService { if (orderCinema != null) { Map map = new HashMap<>(); - map.put("orderNo", childOrder.getOrderNo()); + map.put("orderNo", orderCinema.getChannelOrderNo()); CinemaService.refundMovieOrder(map); orderCinema.setStatus(-5); orderCinema.setExceptionStatus(false); @@ -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..b9cede8 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 @@ -90,7 +97,7 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { BeanUtils.copyProperties(orderChild, childModel); if (childModel.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { - BsOrderGoods orderGoods = orderGoodsService.findGoodsOrder(orderNo); + BsOrderGoods orderGoods = orderGoodsService.findGoodsOrderByChild(childModel.getChildOrderNo()); if (orderGoods != null) { GoodsUserAddress address; if (orderGoods.getDeliveryAddressId() != null) { @@ -111,7 +118,9 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { // 查询商品虚拟信息 GoodsJump goodsJump = goodsJumpService.queryDetailBySpecsId(orderChild.getProductSpecId()); - object.put("goodsJump", goodsJump); + if (goodsJump != null && goodsJump.getJumpType() != null) { + object.put("goodsJump", goodsJump); + } object.put("address", address); object.put("orderGoodsId", orderGoods.getId()); childModel.setBusiness(object); @@ -121,6 +130,9 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { orderService.childOrderComplete(orderGoods.getChildOrderNo()); orderGoods.setStatus(OrderChildStatusEnum.status3.getCode()); orderGoods.setUpdateTime(new Date()); + if (orderGoods.getFinishTime() == null) { + orderGoods.setFinishTime(new Date()); + } orderGoodsService.update(orderGoods); // 删除缓存 orderService.cacheDelete(orderGoods.getOrderNo()); @@ -128,7 +140,20 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { } } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { - childModel.setBusiness(goodsVpdService.queryDetailBySpecsId(childModel.getProductSpecId())); + + + if (!childModel.getProductSpecId().equals(999999L)) { + 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 +225,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..9acdc3a 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); + BigDecimal price = orderChild.getProductActualPrice().multiply(proportion).setScale(2 , RoundingMode.HALF_UP); - if (price.compareTo(new BigDecimal("0.01")) < 0) { - price = new BigDecimal(0); - } - - // 插入退款积分 - 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,12 +346,11 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { editData(orderRefund); + // 资金退款 + orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); - if (orderRefund.getRefundPrice().compareTo(new BigDecimal(0)) > 0) { - // 资金退款 - orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode()); - } else { - orderRefund.setRefundStatus(OrderRefundStatusEnum.status2.getCode()); + if (orderRefund.getRefundStatus() == OrderRefundStatusEnum.status2.getCode()) { + orderRefund.setFinishTime(new Date()); } editData(orderRefund); @@ -368,20 +358,19 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { // 退款成功 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..c77270a --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/impl/OrderSettlementServiceImpl.java @@ -0,0 +1,370 @@ +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.order.OrderPayTypeEnum; +import org.apache.commons.collections4.MapUtils; +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(DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeS")) , DateUtil.Y_M_D) + "-" + DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeE")) , DateUtil.Y_M_D)); + } + 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(DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeS")) , DateUtil.Y_M_D) + "-" + DateUtil.date2String(DateUtil.long2Date(MapUtils.getLong(map , "finishTimeE")) , DateUtil.Y_M_D)); + } + 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("未知"); + } + + model.setFinishTime(DateUtil.date2String(orderCinema.getCreateTime() , 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.getCreateTime() , 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.setBusiness(orderMeiTuan.getSqtBizOrderId()); + 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..1b6df48 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -1,4 +1,5 @@ fileUrl=/home/project/phg/filesystem +#fileUrl=/Users/chenyao/Desktop/img domainName=https://phgcs.dctpay.com wechatMpAppid=wxa075e8509802f826 @@ -72,7 +73,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 @@ -84,3 +85,8 @@ yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/ haiOilPostUrl = https://test-oil.dctpay.com haiOilAppid = hf7356c71fb97ab0 haiOilAppSecret = 8aef995ff71485dc19b36e35f04c4016 + + +jDPostUrl = https://test-oil.dctpay.com +jDAppKey = C4FF710550C43FE76D4114E1C9C6A0C9 +jDAppSecret = 873bcbc1d8d64f36832270c2ff59c194 diff --git a/service/src/main/resources/prod/commonConfig.properties b/service/src/main/resources/prod/commonConfig.properties index b5a0f84..0f63b39 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 @@ -70,6 +77,10 @@ HgApiKey=3fd74e7c16b04681a0f481c5bc0a96d3 HgMemberId=1622808562621276161 HgPostUrl=http://113.250.49.100:8088/recharge/ +yuShangAppKey=211394653 +yuShangAppSecret=cyQpQKMaGUG186iEZRt1uQ== +yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/ + haiOilPostUrl = https://oil.dctpay.com haiOilAppid = hf166f4b2ed75e71 diff --git a/user/src/main/java/com/user/controller/BsUserController.java b/user/src/main/java/com/user/controller/BsUserController.java index a2a54a6..52da6dd 100644 --- a/user/src/main/java/com/user/controller/BsUserController.java +++ b/user/src/main/java/com/user/controller/BsUserController.java @@ -207,7 +207,7 @@ public class BsUserController { try { Map other = new HashMap<>(); - return ResponseMsgUtil.success(userService.login(UserLoginPlatform.H5, UserLoginType.SMS, "18090580471", "123456", other)); + return ResponseMsgUtil.success(userService.login(UserLoginPlatform.H5, UserLoginType.SMS, "13985476824", "123456", other)); } catch (Exception e) { log.error("LoginController --> phone() error!", e);