From e287e8c1524f4de2cc47f61323d757f662701d84 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Tue, 3 Dec 2024 10:24:56 +0800 Subject: [PATCH] /1 --- .../bweb/controller/FileUploadController.java | 4 +- .../com/bweb/controller/TestController.java | 130 ++- bweb/src/main/resources/pre/application.yml | 39 +- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../com/cweb/controller/CommonController.java | 5 +- .../controller/cms/CmsContentController.java | 1 + .../goods/DeliveryAddressController.java | 50 +- .../goods/ShoppingCartController.java | 3 +- cweb/src/main/resources/pre/application.yml | 37 +- .../src/main/resources/pre/application.yml | 2 +- .../OrderAfterSalesApplyController.java | 46 +- .../order/controller/OrderPayController.java | 23 +- .../business/BsOrderGoodsController.java | 89 +- order/src/main/resources/dev/application.yml | 1 + order/src/main/resources/pre/application.yml | 39 +- .../com/hfkj/schedule/JdGoodsSchedule.java | 53 ++ .../src/main/resources/pre/application.yml | 2 +- .../java/com/hfkj/jd/Impl/JdServiceImpl.java | 846 +++++++++++++----- .../main/java/com/hfkj/jd/JdPostService.java | 131 ++- .../src/main/java/com/hfkj/jd/JdService.java | 99 ++ .../service/goods/BsOrderGoodsService.java | 18 + .../hfkj/service/goods/GoodsBrandService.java | 1 + .../hfkj/service/goods/GoodsMsgService.java | 2 + .../hfkj/service/goods/GoodsTypeService.java | 1 + .../goods/impl/BsOrderGoodsServiceImpl.java | 10 + .../goods/impl/GoodsBrandServiceImpl.java | 13 + .../goods/impl/GoodsMsgServiceImpl.java | 14 + .../goods/impl/GoodsSpecsServiceImpl.java | 6 + .../goods/impl/GoodsTypeServiceImpl.java | 14 + ...BsOrderAfterSalesAddressRecordService.java | 18 + .../order/BsOrderAfterSalesApplyService.java | 12 + .../service/order/OrderCreateService.java | 11 +- .../service/order/OrderPaySuccessService.java | 8 +- ...derAfterSalesAddressRecordServiceImpl.java | 35 + .../BsOrderAfterSalesApplyServiceImpl.java | 114 +++ .../order/impl/BsOrderChildServiceImpl.java | 13 - .../order/impl/BsOrderServiceImpl.java | 9 +- .../order/OrderAfterSalesApplyStatusEnum.java | 4 + .../order/OrderAfterSalesApplyTypeEnum.java | 2 + .../resources/pre/commonConfig.properties | 96 ++ user/src/main/resources/pre/application.yml | 39 +- 41 files changed, 1693 insertions(+), 348 deletions(-) create mode 100644 schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java create mode 100644 service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesAddressRecordService.java create mode 100644 service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesAddressRecordServiceImpl.java diff --git a/bweb/src/main/java/com/bweb/controller/FileUploadController.java b/bweb/src/main/java/com/bweb/controller/FileUploadController.java index 898b421..df5f146 100644 --- a/bweb/src/main/java/com/bweb/controller/FileUploadController.java +++ b/bweb/src/main/java/com/bweb/controller/FileUploadController.java @@ -40,9 +40,7 @@ public class FileUploadController { @Resource private SysConfig sysConfig; - @Resource - private FileUploadService fileUploadService; - + @RequestMapping(value="/uploadfile",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "文件上传") diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index f1c1de6..d1fa36f 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -6,6 +6,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.*; import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.GoodsUserAddress; import com.hfkj.jd.JdPostService; @@ -18,12 +19,15 @@ import com.hfkj.service.coupon.channel.YouTuCouponService; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.hlt.HuiLianTongUnionCardService; +import com.hfkj.service.order.BsOrderRefundService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.OrderPayService; import com.hfkj.service.pay.huift.TradeService; import com.jd.open.api.sdk.domain.vopsp.CategoryInfoGoodsProvider.response.getCategoryInfoList.GetCategoryInfoGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuDetailInfo.GetSkuPoolInfoGoodsResp; +import com.jd.open.api.sdk.domain.vopxx.MsgRecordProvider.response.queryTransByVopNormal.VopBizTransMessage; import com.jd.open.api.sdk.response.vopdz.VopAddressConvertFourAreaByDetailStrResponse; +import com.jd.open.api.sdk.response.vopxx.VopMessageQueryTransByVopNormalResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -60,6 +64,12 @@ public class TestController { @Resource private GoodsUserAddressService goodsUserAddressService; + @Resource + private BsOrderRefundService orderRefundService; + + @Resource + private BsOrderService orderService; + @RequestMapping(value="/thirdPayResult",method = RequestMethod.GET) @ResponseBody @@ -216,6 +226,40 @@ public class TestController { } } + @RequestMapping(value="/queryTransByVopNormal",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "消息消费") + public ResponseData queryTransByVopNormal() { + try { + + + jdService.deleteMsg(); + + return ResponseMsgUtil.success("成功!"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/tradeOrderRefund",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "手动退款") + public ResponseData tradeOrderRefund(@RequestParam(value = "orderNo" , required = true) String orderNo) { + try { + + + orderRefundService.tradeOrderRefund(orderNo,"手动退款"); + + return ResponseMsgUtil.success("成功!"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/confirmReceipt",method = RequestMethod.GET) @ResponseBody @@ -327,6 +371,85 @@ public class TestController { } + @RequestMapping(value="/checkGoods",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "校验商品是否正确") + public ResponseData checkGoods(@RequestParam(value = "orderNo", required = false) String orderNo) { + try { + + BsOrder order = orderService.getOrder(orderNo); + + return ResponseMsgUtil.success(jdService.checkGoods(order)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/queryOrderDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单") + public ResponseData queryOrderDetail(@RequestParam(value = "orderNo", required = false) String orderNo) { + try { + + BsOrderGoods order = getOrderGoodsService.findGoodsOrder(orderNo); + + return ResponseMsgUtil.success(jdService.queryOrderDetail(order)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/confirmOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "确认订单") + public ResponseData confirmOrder(@RequestParam(value = "orderNo", required = false) String orderNo) { + try { + + BsOrderGoods order = getOrderGoodsService.findGoodsOrder(orderNo); + jdService.confirmOrder(order); + return ResponseMsgUtil.success(""); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/queryDeliveryInfo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询物流信息") + public ResponseData queryDeliveryInfo(@RequestParam(value = "orderNo", required = false) String orderNo) { + try { + + BsOrderGoods order = getOrderGoodsService.findGoodsOrder(orderNo); + return ResponseMsgUtil.success(jdService.queryDeliveryInfo(order)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/cancelOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "取消订单") + public ResponseData cancelOrder(@RequestParam(value = "childNo", required = false) String childNo) { + try { + + jdService.cancelOrder(childNo); + return ResponseMsgUtil.success(""); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getGoodsUpdate",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "更新商品") @@ -334,19 +457,18 @@ public class TestController { try { Map map = new HashMap<>(); - map.put("status" , 2); + map.put("status" , 3); List orderGoodsList = getOrderGoodsService.getList(map); - List userAddresses = goodsUserAddressService.getList(new HashMap<>()); + for (BsOrderGoods orderGoods : orderGoodsList) { - GoodsUserAddress address = userAddresses.stream().filter(x -> Objects.equals(x.getId(), orderGoods.getGoodsId())).findFirst().orElse(null); + GoodsUserAddress address = goodsUserAddressService.queryDetail(orderGoods.getDeliveryAddressId()); if (address != null) { orderGoods.setDeliveryAddress(address.getRegionName() + "-" + address.getAddress() + "-" + address.getConsignee() + "-" + address.getPhone()); getOrderGoodsService.update(orderGoods); } - } return ResponseMsgUtil.success(""); diff --git a/bweb/src/main/resources/pre/application.yml b/bweb/src/main/resources/pre/application.yml index 23f62ce..2fe21d2 100644 --- a/bweb/src/main/resources/pre/application.yml +++ b/bweb/src/main/resources/pre/application.yml @@ -1,7 +1,7 @@ server: - port: 9301 + port: 9702 servlet: - context-path: /crest + context-path: /brest #配置是否为debug模式,debug模式下,不开启权限校验 debug: false @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -54,3 +54,36 @@ pagehelper: reasonable: true supportMethodsArguments: true params: count=countSql + +rocketmq: + name-server: 139.9.154.68:9876 + producer: + access-key: huifukeji + secret-key: HF123456. + #必须指定group + group: default-group + consumer: + access-key: huifukeji + secret-key: HF123456. + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.9.154.68 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index ff6e08e..8814050 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -94,6 +94,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/cinema/*") .excludePathPatterns("/starbucks/*") .excludePathPatterns("/meiTuan/*") + .excludePathPatterns("/jd/*") ; } diff --git a/cweb/src/main/java/com/cweb/controller/CommonController.java b/cweb/src/main/java/com/cweb/controller/CommonController.java index 169d92a..542e8f7 100644 --- a/cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/cweb/src/main/java/com/cweb/controller/CommonController.java @@ -66,7 +66,7 @@ public class CommonController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } */ - JSONObject refundObj = HuiLianTongUnionCardService.refund("R240816093659997", "240808134614258487"); + JSONObject refundObj = HuiLianTongUnionCardService.refund("R241202115359997", "241130223414212711"); if (!refundObj.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refundObj.getString("respMessage")); } @@ -187,8 +187,7 @@ public class CommonController { JSONObject params = commonService.locateByLngAndLat(lng + "," + lat); - System.out.println(params); - + log.info("locateByLngAndLat!", params); if (params.getInteger("status") == 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询到任何城市!"); } diff --git a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java index 0c39096..5025619 100644 --- a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java +++ b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java @@ -68,6 +68,7 @@ public class CmsContentController { if (cmsContent.getShowType() != null) { Map goodsMap = new HashMap<>(); + goodsMap.put("status" , 1); List goodsMsgs = new ArrayList<>(); diff --git a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java index b5d225f..a1d9c93 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/DeliveryAddressController.java @@ -93,18 +93,23 @@ public class DeliveryAddressController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); - - // 判断response是否为空,并且response的OpenRpcResult的success属性是否为true - if (response != null && response.getOpenRpcResult().getSuccess()) { - deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); - deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); - deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); - deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); - } +// VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); +// +// +// +// // 判断response是否为空,并且response的OpenRpcResult的success属性是否为true +// if (response != null && response.getOpenRpcResult().getSuccess()) { +// deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); +// deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); +// deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); +// deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); +// } else { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); +// } deliveryAddress.setUserId(userSession.getUser().getId()); + deliveryAddress.setStatus(1); deliveryAddress.setCreateTime(new Date()); deliveryAddress.setUpdateTime(new Date()); deliveryAddressService.create(deliveryAddress); @@ -149,20 +154,23 @@ public class DeliveryAddressController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前收货地址异常!"); } - VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); - - if (response != null && response.getOpenRpcResult().getSuccess()) { - deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); - deliveryAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); - deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); - deliveryAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); - deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); - deliveryAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); - deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); - deliveryAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); - } +// VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , deliveryAddress.getRegionName() + deliveryAddress.getAddress()); +// +// if (response != null && response.getOpenRpcResult().getSuccess()) { +// deliveryAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); +// deliveryAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); +// deliveryAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); +// deliveryAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); +// deliveryAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); +// deliveryAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); +// deliveryAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); +// deliveryAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); +// } else { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); +// } deliveryAddress.setUserId(userSession.getUser().getId()); + deliveryAddress.setStatus(1); deliveryAddress.setCreateTime(goodsDeliveryAddress.getCreateTime()); deliveryAddress.setUpdateTime(new Date()); deliveryAddressService.update(deliveryAddress); diff --git a/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java b/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java index b1db22e..e590463 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/ShoppingCartController.java @@ -75,7 +75,8 @@ public class ShoppingCartController { if (goodsSpecs.getStatus().equals(0)) { shoppingCart.setLoseEfficacy(true); } - if (jdService.checkSkuSale(goodsMsg)) { + + if (goodsMsg.getThirdId() != null && jdService.checkSkuSale(goodsMsg)) { shoppingCart.setLoseEfficacy(true); } shoppingCart.setUpdateTime(new Date()); diff --git a/cweb/src/main/resources/pre/application.yml b/cweb/src/main/resources/pre/application.yml index 23f62ce..2d1e615 100644 --- a/cweb/src/main/resources/pre/application.yml +++ b/cweb/src/main/resources/pre/application.yml @@ -1,5 +1,5 @@ server: - port: 9301 + port: 9701 servlet: context-path: /crest @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -54,3 +54,36 @@ pagehelper: reasonable: true supportMethodsArguments: true params: count=countSql + +rocketmq: + name-server: 139.9.154.68:9876 + producer: + access-key: huifukeji + secret-key: HF123456. + #必须指定group + group: default-group + consumer: + access-key: huifukeji + secret-key: HF123456. + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.9.154.68 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 diff --git a/openapi/src/main/resources/pre/application.yml b/openapi/src/main/resources/pre/application.yml index 23f62ce..ad471f0 100644 --- a/openapi/src/main/resources/pre/application.yml +++ b/openapi/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/order/src/main/java/com/order/controller/OrderAfterSalesApplyController.java b/order/src/main/java/com/order/controller/OrderAfterSalesApplyController.java index 4b6d970..53f82e4 100644 --- a/order/src/main/java/com/order/controller/OrderAfterSalesApplyController.java +++ b/order/src/main/java/com/order/controller/OrderAfterSalesApplyController.java @@ -13,6 +13,7 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrderAfterSalesApply; import com.hfkj.entity.FileRecords; +import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.UserSessionObject; @@ -64,6 +65,8 @@ public class OrderAfterSalesApplyController { private BsOrderChildService orderChildService; @Resource private FileRecordsService fileRecordsService; + @Resource + private JdService jdService; @RequestMapping(value="/calculate",method = RequestMethod.GET) @ResponseBody @@ -151,11 +154,22 @@ public class OrderAfterSalesApplyController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - orderAfterSalesApplyService.audit( - body.getString("applyNo"), - body.getBoolean("auditStatus"), - body.getString("remarks"), - secUserSessionObject.getAccount().getId()); + if (body.getInteger("jdAuditStatus") == null) { + orderAfterSalesApplyService.audit( + body.getString("applyNo"), + body.getBoolean("auditStatus"), + body.getString("remarks"), + secUserSessionObject.getAccount().getId()); + } else { + orderAfterSalesApplyService.jdAudit( + body.getString("applyNo"), + body.getBoolean("auditStatus"), + body.getString("remarks"), + secUserSessionObject.getAccount().getId(), + body.getInteger("jdAuditStatus") + ); + } + return ResponseMsgUtil.success("提交成功"); } catch (Exception e) { @@ -185,6 +199,28 @@ public class OrderAfterSalesApplyController { } } + @RequestMapping(value="/createAfsApplyByJd",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "京东上门取件") + public ResponseData createAfsApplyByJd(@RequestBody JSONObject body) { + try { + if (body == null + || StringUtils.isBlank(body.getString("applyNo")) + || body.getLong("pickAddressId") == null + || body.getLong("returnAddressId") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + orderAfterSalesApplyService.createAfsApplyByJd(body.getString("applyNo"),body.getLong("pickAddressId") , body.getLong("returnAddressId")); + return ResponseMsgUtil.success("提交成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/finish",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "完成") diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index a3a364d..cbf93d6 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -8,6 +8,7 @@ import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.*; +import com.hfkj.jd.JdService; import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; @@ -72,6 +73,9 @@ public class OrderPayController { @Resource private GoodsVpdService goodsVpdService; + @Resource + private JdService jdService; + @RequestMapping(value="/wechat",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信") @@ -104,6 +108,10 @@ public class OrderPayController { body.put("appId", CommonSysConst.getSysConfig().getWechatMaAppid()); } + if (jdService.checkGoods(order)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "购买失败!"); + } + // 请求支付渠道 Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("appId"), body.getString("openId"), order); for (OrderChildModel orderChild : order.getOrderChildList()) { @@ -146,6 +154,10 @@ public class OrderPayController { if (merPay == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); } + + if (jdService.checkGoods(order)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "购买失败!"); + } // 请求支付渠道 Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), null, body.getString("openId"), order); for (OrderChildModel orderChild : order.getOrderChildList()) { @@ -190,6 +202,10 @@ public class OrderPayController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂不支持合并下单"); } + if (jdService.checkGoods(order)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "购买失败!"); + } + String shopCode = HuiftConfig.shopcode98; String signSecret = HuiftConfig.signSecret98; @@ -209,8 +225,6 @@ public class OrderPayController { } } - - // 请求支付渠道 JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order , shopCode , signSecret); for (OrderChildModel orderChild : order.getOrderChildList()) { @@ -256,6 +270,11 @@ public class OrderPayController { if (!order.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付失败!交易订单不处于待支付状态"); } + + if (jdService.checkGoods(order)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "购买失败!"); + } + Long merId = order.getOrderChildList().get(0).getMerId(); if (UserCardTypeEnum.type1.getCode() == card.getType()) { 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 6a9dad0..1c78e25 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -14,6 +14,7 @@ import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.*; +import com.hfkj.jd.JdService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.order.orderExport.OrderGoodsExportModel; @@ -72,6 +73,9 @@ public class BsOrderGoodsController { @Resource private BsOrderAfterSalesApplyService bsOrderAfterSalesApplyService; + @Resource + private JdService jdService; + @RequestMapping(value="/getListGoods",method = RequestMethod.GET) @ResponseBody @@ -342,30 +346,38 @@ public class BsOrderGoodsController { BsOrderGoods orderGoods = bsOrderGoodsService.queryDetail(id); - if (orderGoods == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); - } + if (orderGoods.getThirdOrderNo() == null) { + if (orderGoods == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); + } - if (orderGoods.getLogisticsNo() == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "待揽收!"); - } - GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo() , orderGoods.getUserPhone()); + if (orderGoods.getLogisticsNo() == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "待揽收!"); + } + + GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo() , orderGoods.getUserPhone()); + + if (logistics.getLogisticsStatus() != null) { + orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); + orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + } else { + orderGoods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); + orderGoods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + } - if (logistics.getLogisticsStatus() != null) { - orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); - orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + bsOrderGoodsService.update(orderGoods); + map.put("logistics", logistics); + JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); + map.put("logisticsTraceDetails", object); } else { - orderGoods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); - orderGoods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + GoodsLogistics logistics = jdService.updateDeliveryInfo(orderGoods); + map.put("logistics", logistics); + JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); + map.put("logisticsTraceDetails", object); } - bsOrderGoodsService.update(orderGoods); - map.put("logistics", logistics); - JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); - map.put("logisticsTraceDetails", object); - return ResponseMsgUtil.success(map); } catch (Exception e) { @@ -403,17 +415,22 @@ public class BsOrderGoodsController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息"); } - BsOrderGoods orderGoods = orderGoodsService.findGoodsOrder(orderNo); + Map map = new HashMap<>(); + map.put("orderNo", orderNo); - if (orderGoods == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "未找到相信息"); - } + List orderGoods = orderGoodsService.getList(map); + + for (BsOrderGoods orderGood : orderGoods) { + if (orderGood == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "未找到相信息"); + } - orderGoods.setDeliveryAddressId(deliveryAddress.getId()); - orderGoods.setUpdateTime(new Date()); - orderGoods.setDeliveryAddress(deliveryAddress.getAddress()); + orderGood.setDeliveryAddressId(deliveryAddress.getId()); + orderGood.setUpdateTime(new Date()); + orderGood.setDeliveryAddress(deliveryAddress.getRegionName() + "-" + deliveryAddress.getAddress() + "-" + deliveryAddress.getConsignee() + "-" + deliveryAddress.getPhone()); - orderGoodsService.update(orderGoods); + orderGoodsService.update(orderGood); + } return ResponseMsgUtil.success("成功"); @@ -423,6 +440,28 @@ public class BsOrderGoodsController { } } + + @RequestMapping(value="/getOrderGoods",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询实物订单") + public ResponseData getOrderGoods(@RequestParam(value = "childOrderNo" , required = true) String childOrderNo) { + try { + + + BsOrderGoods orderGoods = orderGoodsService.findGoodsOrderByChild(childOrderNo); + + if (orderGoods == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "未找到相信息"); + } + + return ResponseMsgUtil.success(orderGoods); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/goodsOrderCount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "待收货数量") diff --git a/order/src/main/resources/dev/application.yml b/order/src/main/resources/dev/application.yml index 85ea5c8..617c2a4 100644 --- a/order/src/main/resources/dev/application.yml +++ b/order/src/main/resources/dev/application.yml @@ -9,6 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: + url: jdbc:mysql://139.9.154.68:3306/puhui_go?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. diff --git a/order/src/main/resources/pre/application.yml b/order/src/main/resources/pre/application.yml index 23f62ce..5fb00d8 100644 --- a/order/src/main/resources/pre/application.yml +++ b/order/src/main/resources/pre/application.yml @@ -1,7 +1,7 @@ server: - port: 9301 + port: 9703 servlet: - context-path: /crest + context-path: /order #配置是否为debug模式,debug模式下,不开启权限校验 debug: false @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -54,3 +54,36 @@ pagehelper: reasonable: true supportMethodsArguments: true params: count=countSql + +rocketmq: + name-server: 139.9.154.68:9876 + producer: + access-key: huifukeji + secret-key: HF123456. + #必须指定group + group: default-group + consumer: + access-key: huifukeji + secret-key: HF123456. + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.9.154.68 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 diff --git a/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java b/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java new file mode 100644 index 0000000..25e744f --- /dev/null +++ b/schedule/src/main/java/com/hfkj/schedule/JdGoodsSchedule.java @@ -0,0 +1,53 @@ +package com.hfkj.schedule; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.entity.BsOrderCoupon; +import com.hfkj.entity.BsOrderCouponNo; +import com.hfkj.jd.JdService; +import com.hfkj.service.coupon.BsOrderCouponNoService; +import com.hfkj.service.coupon.BsOrderCouponService; +import com.hfkj.service.coupon.channel.HuiLianTongCouponService; +import com.hfkj.service.coupon.channel.YouTuCouponService; +import com.hfkj.service.hlt.HuiLianTongUnionCardService; +import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.GoodsVpdSourceEnum; +import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: 胡锐 + * @Description: 卡卷定时任务 + * @Date: 2021/3/27 15:39 + */ +@Configuration +public class JdGoodsSchedule { + + private static Logger log = LoggerFactory.getLogger(JdGoodsSchedule.class); + + + @Resource + private JdService jdService; + + //每10分钟执行一次 + @Scheduled(cron = "0 0/10 * * * ?") + public void etcCarMsg() { + try { + + jdService.deleteMsg(); + + } catch (Exception e) { + log.error("HighUserController --> findByUserId() error!", e); + } + } + +} diff --git a/schedule/src/main/resources/pre/application.yml b/schedule/src/main/resources/pre/application.yml index 7082821..bbdb5fe 100644 --- a/schedule/src/main/resources/pre/application.yml +++ b/schedule/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java index 30504e7..7366280 100644 --- a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java +++ b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java @@ -1,5 +1,6 @@ package com.hfkj.jd.Impl; +import com.alibaba.fastjson.JSONObject; import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; @@ -9,6 +10,11 @@ import com.hfkj.service.BsMerService; import com.hfkj.service.BsProductConfigService; import com.hfkj.service.goods.*; import com.hfkj.sysenum.order.OrderChildProductTypeEnum; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryDeliveryInfo.DeliveryInfoQueryOpenResp; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryDeliveryInfo.LogisticInfoOrderOpenResp; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryDeliveryInfo.TrackInfoOrderOpenResp; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryOrderDetail.QueryOrderOpenResp; +import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryOrderDetail.StateOrderOpenResp; import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSellPrice.GetSellPriceGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSellPrice.OpenRpcResult; import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuDetailInfo.GetSkuPoolInfoGoodsResp; @@ -16,10 +22,15 @@ import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImag import com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.SkuImageItemGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuPoolGoodsProvider.response.getSkuPoolInfo.GetSkuPoolInfoItemGoodsResp; import com.jd.open.api.sdk.domain.vopsp.SkuPoolGoodsProvider.response.querySkuByPage.OpenPagingResult; +import com.jd.open.api.sdk.domain.vopxx.MsgRecordProvider.response.queryTransByVopNormal.VopBizTransMessage; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryDeliveryInfoResponse; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryOrderDetailResponse; +import com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuDetailInfoResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuImageListResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuPoolInfoResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuStateListResponse; +import com.jd.open.api.sdk.response.vopxx.VopMessageQueryTransByVopNormalResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,9 +38,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.stream.Collectors; @@ -57,7 +66,22 @@ public class JdServiceImpl implements JdService { @Resource private GoodsSpecsService goodsSpecsService; - private List skuList = new ArrayList<>(); + @Resource + private BsOrderGoodsService bsOrderGoodsService; + + private final List skuListIds = new ArrayList<>(); + + + static int cpuCoreCnt = Runtime.getRuntime().availableProcessors(); //获取服务器CPU核心数 + static int corePoolSize = cpuCoreCnt; // 核心线程数 + static int maximumPoolSize = cpuCoreCnt; // 最大线程数 + static int keepAliveTime = 30; // 非核心线程的空闲存活时长(分钟) + static int queueCapacity = 9999; // 队列最大长度 + public static BlockingQueue queue = new LinkedBlockingQueue(queueCapacity); + static ThreadPoolExecutor threadPool; + static { + threadPool = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, queue); + } @Override public String getToken() throws Exception { @@ -66,252 +90,309 @@ public class JdServiceImpl implements JdService { if (token == null) { // 请求回调 会在回调存入参数 JdPostService.getAccessToken(); - getToken(); +// getToken(); } return token.toString(); } - @Override - public void getGoodsJd() throws Exception { - String token = getToken(); - // 获取京东商品池 - VopGoodsGetSkuPoolInfoResponse sku = JdPostService.getSkuPoolInfo(token); - // 获取sku列表 - List skuList = sku.getOpenRpcResult().getResult().getSkuPoolList(); -// List skuIdList; -// for (GetSkuPoolInfoItemGoodsResp skuPoolInfoItemGoodsResp : skuList) { -// skuIdList = getSkuList(token , skuPoolInfoItemGoodsResp.getBizPoolId() , 0L); -// } -// BsMer bsMer = bsMerService.getDetail("166241009282"); - - // 初始化商品信息 - GoodsMsg goodsMsg; - // 初始化商品规格 - GoodsSpecs goodsSpecs; + /** + * 处理数据 + * @param handleList + */ + public void task(List handleList , String token , BsProductConfig productConfig , BsMer bsMer) { + //处理数据 + handleList.forEach(item->{ + try { + + + for (Long aLong : handleList) { + + // 根据skuId 查询商品详情 + VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(token, aLong); + GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); + if (detail != null) { + // 根据skuId 查询商品售价 + OpenRpcResult priceResponse = JdPostService.getSellPrice(token, String.valueOf(aLong)).getOpenRpcResult(); + if (priceResponse.getSuccess()) { + GetSellPriceGoodsResp price = priceResponse.getResult().get(0); + // 根据skuId 查询商品图片 + + com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.OpenRpcResult imageListResponse = JdPostService.getSkuImageList(token, String.valueOf(aLong)).getOpenRpcResult(); + if (imageListResponse.getSuccess()) { + GetSkuImageGoodsResp img = imageListResponse.getResult().get(0); + // 查询分类 + String[] categoryS = detail.getCategory().split(";"); + + // 查询一级分类 + String category1 = JdPostService.getCategoryInfoList(token, categoryS[0]).getOpenRpcResult().getResult().get(0).getCategoryName(); + // 查询二级分类 + String category2 = JdPostService.getCategoryInfoList(token, categoryS[1]).getOpenRpcResult().getResult().get(0).getCategoryName(); + + GoodsType goodsType1 = goodsTypeService.queryDetail(category1); + GoodsType goodsType2 = goodsTypeService.queryDetail(category2); + + + // 如果goodsType1为null,则创建一个新的GoodsType对象 + if (goodsType1 == null) { + goodsType1 = new GoodsType(); + // 设置title为category1 + goodsType1.setTitle(category1); + // 设置status为1 + goodsType1.setStatus(1); + goodsType1.setBusinessType(1); + // 设置sort为8 + goodsType1.setSort(8); + // 设置createTime为当前时间 + goodsType1.setCreateTime(new Date()); + // 设置updateTime为当前时间 + goodsType1.setUpdateTime(new Date()); + // 调用goodsTypeService的create方法,将goodsType1对象保存到数据库中 + goodsTypeService.create(goodsType1); + } else { + // 设置updateTime为当前时间 + goodsType1.setUpdateTime(new Date()); + // 调用goodsTypeService的update方法,将goodsType1对象更新到数据库中 + goodsTypeService.update(goodsType1); + } + if (goodsType2 == null) { + goodsType2 = new GoodsType(); + // 设置title为category2 + goodsType2.setTitle(category2); + goodsType2.setParentId(goodsType1.getId()); + // 设置status为1 + goodsType2.setStatus(1); + // 设置businessType为1 + goodsType2.setBusinessType(1); + // 设置sort为8 + goodsType2.setSort(1); + // 设置createTime为当前时间 + goodsType2.setCreateTime(new Date()); + // 设置updateTime为当前时间 + goodsType2.setUpdateTime(new Date()); + // 调用goodsTypeService的create方法,将goodsType2对象保存到数据库中 + goodsTypeService.create(goodsType2); + } else { + goodsType2.setParentId(goodsType1.getId()); + goodsType2.setUpdateTime(new Date()); + goodsTypeService.update(goodsType2); + } + // 从brands中筛选出title等于detail.getBrandName()的元素,并返回第一个元素,如果没有找到则返回null + GoodsBrand goodsBrand = goodsBrandService.queryDetail(detail.getBrandName()); + // 如果goodsBrand为null,则创建一个新的GoodsBrand对象 + if (goodsBrand == null) { + goodsBrand = new GoodsBrand(); + // 设置title为detail.getBrandName() + goodsBrand.setTitle(detail.getBrandName()); + // 设置status为1 + goodsBrand.setStatus(1); + // 设置createTime为当前时间 + goodsBrand.setCreateTime(new Date()); + // 设置updateTime为当前时间 + goodsBrand.setUpdateTime(new Date()); + // 调用goodsBrandService的create方法,将goodsBrand对象保存到数据库中 + goodsBrandService.create(goodsBrand); + } else { + goodsBrand.setUpdateTime(new Date()); + goodsBrandService.update(goodsBrand); + } - BsMer bsMer = bsMerService.getDetail("166241009282"); - // 查询分类 - List goodsType = goodsTypeService.getList(new HashMap<>()); - List brands = goodsBrandService.getList(new HashMap<>()); - Map goodsMap = new HashMap<>(); - goodsMap.put("type", 1); - goodsMap.put("childType", 1); - List goodsMsgs = goodsMsgService.getList(goodsMap); - List goodsSpecsList = goodsSpecsService.getList(new HashMap<>()); - BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); - List skuIdList; - for (GetSkuPoolInfoItemGoodsResp skuPoolInfoItemGoodsResp : skuList) { - - skuIdList = getSkuList(token , skuPoolInfoItemGoodsResp.getBizPoolId() , 0L); - - for (Long aLong : skuIdList) { - - // 根据skuId 查询商品详情 - VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(token, aLong); - GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); - if (detail != null) { - // 根据skuId 查询商品售价 - OpenRpcResult priceResponse = JdPostService.getSellPrice(token, String.valueOf(aLong)).getOpenRpcResult(); - if (priceResponse.getSuccess()) { - GetSellPriceGoodsResp price = priceResponse.getResult().get(0); - // 根据skuId 查询商品图片 - - com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.OpenRpcResult imageListResponse = JdPostService.getSkuImageList(token, String.valueOf(aLong)).getOpenRpcResult(); - if (imageListResponse.getSuccess()) { - GetSkuImageGoodsResp img = imageListResponse.getResult().get(0); - // 查询分类 - String[] categoryS = detail.getCategory().split(";"); - - // 查询一级分类 - String category1 = JdPostService.getCategoryInfoList(token, categoryS[0]).getOpenRpcResult().getResult().get(0).getCategoryName(); - // 查询二级分类 - String category2 = JdPostService.getCategoryInfoList(token, categoryS[1]).getOpenRpcResult().getResult().get(0).getCategoryName(); - - GoodsType goodsType1 = goodsType.stream().filter(s -> s.getTitle().equals(category1)).findFirst().orElse(null); - GoodsType goodsType2 = goodsType.stream().filter(s -> s.getTitle().equals(category2)).findFirst().orElse(null); - - // 如果goodsType1为null,则创建一个新的GoodsType对象 - if (goodsType1 == null) { - goodsType1 = new GoodsType(); - // 设置title为category1 - goodsType1.setTitle(category1); - // 设置status为1 - goodsType1.setStatus(1); - goodsType1.setBusinessType(1); - // 设置sort为8 - goodsType1.setSort(8); - // 设置createTime为当前时间 - goodsType1.setCreateTime(new Date()); - // 设置updateTime为当前时间 - goodsType1.setUpdateTime(new Date()); - // 调用goodsTypeService的create方法,将goodsType1对象保存到数据库中 - goodsTypeService.create(goodsType1); - goodsType.add(goodsType1); - } - if (goodsType2 == null) { - goodsType2 = new GoodsType(); - // 设置title为category2 - goodsType2.setTitle(category2); - goodsType2.setParentId(goodsType1.getId()); - // 设置status为1 - goodsType2.setStatus(1); - // 设置businessType为1 - goodsType2.setBusinessType(1); - // 设置sort为8 - goodsType2.setSort(1); - // 设置createTime为当前时间 - goodsType2.setCreateTime(new Date()); - // 设置updateTime为当前时间 - goodsType2.setUpdateTime(new Date()); - // 调用goodsTypeService的create方法,将goodsType2对象保存到数据库中 - goodsTypeService.create(goodsType2); - goodsType.add(goodsType2); - } else { - goodsType2.setParentId(goodsType1.getId()); - goodsType2.setUpdateTime(new Date()); - goodsTypeService.update(goodsType2); - } - // 从brands中筛选出title等于detail.getBrandName()的元素,并返回第一个元素,如果没有找到则返回null - GoodsBrand goodsBrand = brands.stream().filter(s -> s.getTitle().equals(detail.getBrandName())).findFirst().orElse(null); - // 如果goodsBrand为null,则创建一个新的GoodsBrand对象 - if (goodsBrand == null) { - goodsBrand = new GoodsBrand(); - // 设置title为detail.getBrandName() - goodsBrand.setTitle(detail.getBrandName()); - // 设置status为1 - goodsBrand.setStatus(1); - // 设置createTime为当前时间 - goodsBrand.setCreateTime(new Date()); - // 设置updateTime为当前时间 - goodsBrand.setUpdateTime(new Date()); - // 调用goodsBrandService的create方法,将goodsBrand对象保存到数据库中 - goodsBrandService.create(goodsBrand); - brands.add(goodsBrand); - } + // 创建一个GoodsMsg对象 + GoodsMsg goodsMsg = goodsMsgService.queryDetail(aLong.toString()); - // 创建一个GoodsMsg对象 - goodsMsg = new GoodsMsg(); - // 设置更新时间为当前时间 - goodsMsg.setUpdateTime(new Date()); - // 设置商家ID为bsMer的ID - goodsMsg.setMerId(bsMer.getId()); - // 设置商家名称为bsMer的名称 - goodsMsg.setMerName(bsMer.getMerName()); - // 设置商品名称为detail.getGoodsName() - goodsMsg.setTitle(detail.getSkuName()); - // 设置商品类型为3 - goodsMsg.setType(1); - // 设置商品状态为1 - goodsMsg.setStatus(1); - // 设置商品子类型为1 - goodsMsg.setChildType(1); - // 设置商品品牌ID - goodsMsg.setGoodsBrand(goodsBrand.getId()); - // 设置商品品牌名称 - goodsMsg.setGoodsBrandName(goodsBrand.getTitle()); - // 设置商品类型ID - goodsMsg.setGoodsType(goodsType2.getId()); - // 设置商品类型名称 - goodsMsg.setGoodsTypeName(goodsType2.getTitle()); - // 设置商品类型父级ID - goodsMsg.setGoodsTypeParent(goodsType1.getId()); - // 设置商品类型父级名称 - goodsMsg.setGoodsTypeParentName(goodsType1.getTitle()); - goodsMsg.setThirdId(aLong.toString()); - StringBuilder imgS = new StringBuilder(); - // 遍历商品图片列表 - for (SkuImageItemGoodsResp skuImage : img.getSkuImageList()) { - // 如果图片是主图 - if (skuImage.getIsPrimary() == 1) { - // 设置主图 - goodsMsg.setListImg("https://img13.360buyimg.com/n1/" + skuImage.getShortPath()); + if (goodsMsg == null) { + goodsMsg = new GoodsMsg(); } - // 如果图片不是主图 - if (skuImage.getIsPrimary() == 0) { - - imgS.append("https://img13.360buyimg.com/n1/").append(skuImage.getShortPath()).append(","); + // 设置商家ID为bsMer的ID + goodsMsg.setMerId(bsMer.getId()); + // 设置商家名称为bsMer的名称 + goodsMsg.setMerName(bsMer.getMerName()); + // 设置商品名称为detail.getGoodsName() + goodsMsg.setTitle(detail.getSkuName()); + // 设置商品类型为1 + goodsMsg.setType(1); + // 设置商品状态为1 + goodsMsg.setStatus(1); + // 设置商品子类型为1 + goodsMsg.setChildType(1); + // 设置商品品牌ID + goodsMsg.setGoodsBrand(goodsBrand.getId()); + // 设置商品品牌名称 + goodsMsg.setGoodsBrandName(goodsBrand.getTitle()); + // 设置商品类型ID + goodsMsg.setGoodsType(goodsType2.getId()); + // 设置商品类型名称 + goodsMsg.setGoodsTypeName(goodsType2.getTitle()); + // 设置商品类型父级ID + goodsMsg.setGoodsTypeParent(goodsType1.getId()); + // 设置商品类型父级名称 + goodsMsg.setGoodsTypeParentName(goodsType1.getTitle()); + goodsMsg.setThirdId(aLong.toString()); + StringBuilder imgS = new StringBuilder(); + // 遍历商品图片列表 + for (SkuImageItemGoodsResp skuImage : img.getSkuImageList()) { + // 如果图片是主图 + if (skuImage.getIsPrimary() == 1) { + // 设置主图 + goodsMsg.setListImg("https://img13.360buyimg.com/n1/" + skuImage.getShortPath()); + } + // 如果图片不是主图 + if (skuImage.getIsPrimary() == 0) { + + imgS.append("https://img13.360buyimg.com/n1/").append(skuImage.getShortPath()).append(","); + + } } - } - if (imgS.length() > 0) { - imgS.deleteCharAt(imgS.length() - 1); - } + if (imgS.length() > 0) { + imgS.deleteCharAt(imgS.length() - 1); + } - // 设置轮播图 - goodsMsg.setBannerImg(String.valueOf(imgS)); - // 设置详情图 - goodsMsg.setDetailImg(String.valueOf(imgS)); - GoodsMsg msg = goodsMsgs.stream().filter(s -> s.getThirdId().equals(aLong.toString())).findFirst().orElse(null); - - if (msg != null) { - goodsMsg.setId(msg.getId()); - // 更新商品信息 - goodsMsgService.update(goodsMsg); - } else { - // 设置销售数量为0 - goodsMsg.setSaleNum(0); - goodsMsg.setCreateTime(new Date()); - // 创建商品信息 - goodsMsgService.create(goodsMsg); + // 设置轮播图 + goodsMsg.setBannerImg(String.valueOf(imgS)); + // 设置详情图 + goodsMsg.setDetailImg(String.valueOf(imgS)); + + if (goodsMsg.getId() != null) { + // 设置更新时间为当前时间 + goodsMsg.setUpdateTime(new Date()); + // 更新商品信息 + goodsMsgService.update(goodsMsg); + } else { + // 设置销售数量为0 + goodsMsg.setSaleNum(0); + goodsMsg.setCreateTime(new Date()); + // 创建商品信息 + goodsMsgService.create(goodsMsg); - } + } - // 创建商品规格 - goodsSpecs = new GoodsSpecs(); - // 设置商品ID - goodsSpecs.setGoodsId(goodsMsg.getId()); - // 设置商品名称 - goodsSpecs.setName(detail.getSpuName()); - // 设置更新时间 - goodsSpecs.setUpdateTime(new Date()); - // 设置采购限制 - goodsSpecs.setPurLimit(99999); - // 设置状态 - goodsSpecs.setStatus(1); - goodsSpecs.setThirdId(aLong.toString()); - // 设置库存 - goodsSpecs.setStock(10000); - BigDecimal profitPrice = price.getSalePrice().multiply(productConfig.getDiscount().divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP)); - // 设置销售价格 - goodsSpecs.setSalePrice(profitPrice.add(price.getSalePrice())); - // 设置原价 - goodsSpecs.setOriginalPrice(price.getMarketPrice()); - goodsSpecs.setThirdPrice(price.getJdPrice()); - // 设置展示图片 - goodsSpecs.setShowImg(goodsMsg.getListImg()); - - goodsSpecsList = goodsSpecsList.stream().filter(s-> s.getThirdId() != null).collect(Collectors.toList()); - - GoodsSpecs specs = goodsSpecsList.stream().filter(s -> s.getThirdId().equals(aLong.toString())).findFirst().orElse(null); - - if (specs != null) { - goodsSpecs.setId(specs.getId()); - // 更新商品规格 - goodsSpecsService.update(goodsSpecs); - } else { - // 设置创建时间 - goodsSpecs.setCreateTime(new Date()); // 创建商品规格 - goodsSpecsService.create(goodsSpecs); + GoodsSpecs goodsSpecs = goodsSpecsService.queryDetailByThirdId(aLong.toString()); + if (goodsSpecs == null) { + goodsSpecs = new GoodsSpecs(); + } + goodsSpecs.setGoodsId(goodsMsg.getId()); + // 设置商品ID + goodsSpecs.setGoodsId(goodsMsg.getId()); + // 设置商品名称 + goodsSpecs.setName(detail.getSpuName()); + // 设置更新时间 + goodsSpecs.setUpdateTime(new Date()); + // 设置采购限制 + goodsSpecs.setPurLimit(99999); + // 设置状态 + goodsSpecs.setStatus(1); + goodsSpecs.setThirdId(aLong.toString()); + // 设置库存 + goodsSpecs.setStock(10000); + BigDecimal profitPrice = price.getSalePrice().multiply(productConfig.getDiscount().divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP)); + // 设置销售价格 + goodsSpecs.setSalePrice(profitPrice.add(price.getSalePrice())); + // 设置原价 + goodsSpecs.setOriginalPrice(price.getMarketPrice()); + goodsSpecs.setThirdPrice(price.getJdPrice()); + // 设置展示图片 + goodsSpecs.setShowImg(goodsMsg.getListImg()); + + + if (goodsSpecs.getId() != null) { + // 更新商品规格 + goodsSpecsService.update(goodsSpecs); + } else { + // 设置创建时间 + goodsSpecs.setCreateTime(new Date()); + // 创建商品规格 + goodsSpecsService.create(goodsSpecs); + } } - } + } } + + } + } catch (Exception e) { + throw new RuntimeException(e); } + }); + } + + + @Override + public void getGoodsJd() throws Exception { + String token = getToken(); + // 获取京东商品池 + VopGoodsGetSkuPoolInfoResponse sku = JdPostService.getSkuPoolInfo(token); + // 获取京东商品池编码 + List skuPoolList = sku.getOpenRpcResult().getResult().getSkuPoolList(); + + + skuListIds.clear(); + + BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); + BsMer bsMer = bsMerService.getDetail("166241009282"); + + // 循环商品池变化获取sku + for (GetSkuPoolInfoItemGoodsResp skuPoolInfoItemGoodsResp : skuPoolList) { + getSkuList(token , skuPoolInfoItemGoodsResp.getBizPoolId() , 0L); + } + + System.out.println("=========================当前cpu核数:{}" + cpuCoreCnt); + //通过对核心数取余来计算每个线程需要处理的数据量大小 + int size = skuListIds.size() % cpuCoreCnt > 0 ? skuListIds.size() / cpuCoreCnt +1 : skuListIds.size() / cpuCoreCnt; + // 用于存储所有任务的Future + List futureList = new ArrayList<>(); + + // 记录开始时间 + long startTime = System.currentTimeMillis(); + + for (int i = 0; i < cpuCoreCnt; i++) { + //获取每个线程要处理的数据集 + List handleList = skuListIds.subList(i * size, Math.min(skuListIds.size(), i * size + size)); + //创建异步任务添加到线程池,这里使用jdk8的CompletableFuture + CompletableFuture completableFuture = CompletableFuture.runAsync(() -> { + //数据集处理任务 + task(handleList , token , productConfig , bsMer); + }, threadPool); + //将CompletableFuture添加到futureList用于计算耗时 + futureList.add(completableFuture); } + + // 非阻塞等待所有任务完成 + CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).thenRunAsync(() -> { + long endTime = System.currentTimeMillis(); + long totalTime = endTime - startTime; + System.out.println("处理完成,耗时: " + totalTime + "毫秒"); + //关闭线程池 + threadPool.shutdown(); + }, threadPool); + System.out.println(skuListIds.size()); + + } + /** + * @MethodName getSkuList + * @Description: 获取全量商品池 + * @param token + * @param bizPoolId + * @param offset + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/11/27 上午10:41 + */ private List getSkuList(String token , String bizPoolId , Long offset) throws Exception { OpenPagingResult result = JdPostService.querySkuByPage(token, bizPoolId, offset).getOpenRpcResult().getResult(); - skuList.addAll(result.getSkus()); - if (result.getRemainPage() > 0) { - getSkuList(token, bizPoolId, result.getOffset()); + if (result != null) { + skuListIds.addAll(result.getSkus()); + if (result.getRemainPage() > 0) { + getSkuList(token, bizPoolId, result.getOffset()); + } } - return skuList; + return skuListIds; } @Override @@ -321,37 +402,125 @@ public class JdServiceImpl implements JdService { VopGoodsGetSkuStateListResponse skuStateListResponse = JdPostService.getSkuState(getToken(), goodsMsg.getThirdId()); if (skuStateListResponse.getOpenRpcResult().getResult().get(0).getSkuState() == 0) { - // 创建线程 - ThreadPoolExecutor executor = new ThreadPoolExecutor( - 2, // 核心线程数 - 5, // 最大线程数 - 1, // 线程空闲时间 - TimeUnit.MINUTES, // 时间单位 - new ArrayBlockingQueue<>(5), // 任务队列 - new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略 - ); - // 提交任务给线程池 - executor.execute(() -> { - goodsMsg.setStatus(0); - goodsMsgService.update(goodsMsg); - }); - // 关闭线程池 - executor.shutdown(); + deleteMsg(goodsMsg.getThirdId()); return true; } - BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); + updatePrice(goodsMsg); + + return false; + } + + @Override + public Boolean checkGoods(BsOrder bsOrder) throws Exception { + + BsOrderGoods orderGoods = bsOrderGoodsService.findGoodsOrder(bsOrder.getOrderNo()); + if (orderGoods != null) { + GoodsMsg goodsMsg = goodsMsgService.queryDetail(orderGoods.getGoodsId()); + + if (orderGoods.getThirdOrderNo() == null) { + return false; + } + // 查询上游订单 + VopOrderQueryOrderDetailResponse orderDetailResponse = JdPostService.queryOrderDetail(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo()); + + QueryOrderOpenResp resp = orderDetailResponse.getOpenRpcResult().getResult().get(0); + + if (resp.getSkuInfoList().get(0).getSkuId() != Long.parseLong(goodsMsg.getThirdId())) { + JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "skuId编码错误"); + return true; + } + if (!goodsMsg.getTitle().equals(resp.getSkuInfoList().get(0).getSkuName())) { + JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "商品错误!"); + return true; + } + + if (resp.getOrderPrice().getOrderTotalPrice().compareTo(bsOrder.getTotalPrice()) > 0) { + JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "商品价格错误"); + return true; + } + } + return false; + } + + @Override + public void cancelOrder(String childNo){ + try { + BsOrderGoods orderGoods = bsOrderGoodsService.findGoodsOrderByChild(childNo); + if (orderGoods.getThirdOrderNo() != null) { + JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "取消订单!"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Override + public void deleteMsg() throws Exception { + + String token = getToken(); + + VopMessageQueryTransByVopNormalResponse msgList = JdPostService.queryTransByVopNormal(token); + + List messages = msgList.getOpenRpcResult().getResult(); + + StringBuilder stringBuffer = new StringBuilder(); + if (messages != null) { + for (VopBizTransMessage message : messages) { + + JSONObject jsonObj = JSONObject.parseObject(message.getContent()); + + //商品上下架变更消息 + if (message.getType() == 4) { + // state:1代表在主站(jd.com)上架; state:0代表下架 + if (jsonObj.getInteger("state") == 0) { + deleteMsg(jsonObj.getString("skuId")); + } + } + + // 商品池内商品添加、删除消息 + if (message.getType() == 6) { + if (jsonObj.getInteger("state") == 2) { + deleteMsg(jsonObj.getString("skuId")); + } + } + //商品信息变更消息 + if (message.getType() == 16) { + updateGoodsMsg(token , jsonObj.getLong("skuId")); + } + + + if (stringBuffer.length() == 0) { + stringBuffer.append(message.getId()); + } else { + stringBuffer.append(",").append(message.getId()); + } + } + JdPostService.deleteClientMsgByIdList(token , stringBuffer.toString()); + if (!messages.isEmpty()){ + deleteMsg(); + } + } + + } + + @Override + public void confirmOrder(BsOrderGoods orderGoods) throws Exception { + JdPostService.confirmOrder(getToken() , Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "确认订单"); + } + + // 更新商品价格 + private void updatePrice(GoodsMsg goodsMsg) throws Exception { + BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); // 查询规格 GoodsSpecs specs = goodsSpecsService.queryDetailByThirdId(goodsMsg.getThirdId()); // 根据skuId 查询商品详情 - VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(getToken(), Long.valueOf(goodsMsg.getThirdId())); - GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); // 根据skuId 查询商品售价 OpenRpcResult priceResponse = JdPostService.getSellPrice(getToken(), String.valueOf(goodsMsg.getThirdId())).getOpenRpcResult(); GetSellPriceGoodsResp price = priceResponse.getResult().get(0); - // 设置商品名称 - specs.setName(detail.getSpuName()); + // 设置涨价 BigDecimal profitPrice = price.getSalePrice().multiply(productConfig.getDiscount().divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP)); // 设置销售价格 specs.setSalePrice(profitPrice.add(price.getSalePrice())); @@ -359,8 +528,193 @@ public class JdServiceImpl implements JdService { specs.setOriginalPrice(price.getMarketPrice()); specs.setThirdPrice(price.getJdPrice()); // 设置展示图片 - specs.setShowImg(goodsMsg.getListImg()); goodsSpecsService.update(specs); - return false; + } + + @Override + public VopOrderQueryDeliveryInfoResponse queryDeliveryInfo(BsOrderGoods orderGoods) throws Exception{ + return JdPostService.queryDeliveryInfo(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo()); + } + + // 更新商品信息 + private void updateGoodsMsg(String token , Long aLong) throws Exception { + // 根据skuId 查询商品详情 + VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(token, aLong); + GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); + // 根据skuId 查询商品图片 + com.jd.open.api.sdk.domain.vopsp.SkuInfoGoodsProvider.response.getSkuImageList.OpenRpcResult imageListResponse = JdPostService.getSkuImageList(token, String.valueOf(aLong)).getOpenRpcResult(); + + // 创建一个GoodsMsg对象 + GoodsMsg goodsMsg = goodsMsgService.queryDetail(aLong.toString()); + GetSkuImageGoodsResp img = imageListResponse.getResult().get(0); + StringBuilder imgS = new StringBuilder(); + // 遍历商品图片列表 + for (SkuImageItemGoodsResp skuImage : img.getSkuImageList()) { + // 如果图片是主图 + if (skuImage.getIsPrimary() == 1) { + // 设置主图 + goodsMsg.setListImg("https://img13.360buyimg.com/n1/" + skuImage.getShortPath()); + } + // 如果图片不是主图 + if (skuImage.getIsPrimary() == 0) { + imgS.append("https://img13.360buyimg.com/n1/").append(skuImage.getShortPath()).append(","); + } + } + + if (imgS.length() > 0) { + imgS.deleteCharAt(imgS.length() - 1); + } + goodsMsg.setTitle(detail.getSkuName()); + // 设置轮播图 + goodsMsg.setBannerImg(String.valueOf(imgS)); + // 设置详情图 + goodsMsg.setDetailImg(String.valueOf(imgS)); + + // 更新商品信息 + goodsMsgService.update(goodsMsg); + + } + + + // 下架商品 + private void deleteMsg(String aLong) { + GoodsMsg goodsMsg = goodsMsgService.queryDetail(aLong); + + if (goodsMsg != null) { + goodsMsg.setStatus(0); + goodsMsg.setUpdateTime(new Date()); + goodsMsgService.update(goodsMsg); + + GoodsSpecs specs = goodsSpecsService.queryDetailByThirdId(goodsMsg.getThirdId()); + + if (specs != null) { + specs.setStatus(0); + specs.setUpdateTime(new Date()); + goodsSpecsService.update(specs); + } + } + } + + @Override + public GoodsLogistics updateDeliveryInfo(BsOrderGoods orderGoods) throws Exception { + // 查询京东物流 + VopOrderQueryDeliveryInfoResponse deliveryInfoResponse = queryDeliveryInfo(orderGoods); + com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryDeliveryInfo.OpenRpcResult result = deliveryInfoResponse.getOpenRpcResult(); + + if (result.getSuccess()) { + DeliveryInfoQueryOpenResp deliveryInfo = result.getResult(); + + // 判断物流信息是否与订单相同 + if (Objects.equals(deliveryInfo.getThirdOrderId(), orderGoods.getChildOrderNo())) { + // 查询物流信息是否存在 + if (!deliveryInfo.getTrackInfoList().isEmpty()) { + LogisticInfoOrderOpenResp logisticInfo = deliveryInfo.getLogisticInfoList().get(0); + // 查询物流信息 + GoodsLogistics logistics = bsOrderGoodsService.findGoodsLogisticsByNum(logisticInfo.getDeliveryOrderId()); + // 获取物流信息列表 + List trackInfoList = deliveryInfo.getTrackInfoList(); + // 创建一个JSON对象列表 + List objects = new ArrayList<>(); + // 遍历物流信息列表 + for (TrackInfoOrderOpenResp trackInfo : trackInfoList) { + // 创建一个JSON对象 + JSONObject object = new JSONObject(); + // 将物流信息时间放入JSON对象 + object.put("time", trackInfo.getTrackMsgTime()); + // 将物流信息内容放入JSON对象 + object.put("desc", trackInfo.getTrackContent()); + // 将JSON对象添加到列表中 + objects.add(object); + } + // 获取京东物流状态 + JSONObject jsonObject = jdLogisticsStatus(orderGoods); + // 如果物流信息为空 + if (logistics == null) { + // 创建一个新的物流信息对象 + logistics = new GoodsLogistics(); + // 设置物流信息订单号 + logistics.setNumber(logisticInfo.getDeliveryOrderId()); + // 设置物流信息任务号 + logistics.setTaskNo(logisticInfo.getJdOrderId().toString()); + // 设置物流状态 + logistics.setLogisticsStatus(jsonObject.getString("logisticsStatus")); + // 设置物流状态描述 + logistics.setLogisticsStatusDesc(jsonObject.getString("logisticsStatusDesc")); + // 设置物流跟踪详情 + logistics.setLogisticsTraceDetails(objects.toString()); + // 设置物流公司名称 + logistics.setExpressCompanyName(logisticInfo.getDeliveryCarrier()); + // 设置创建时间 + logistics.setCreateTime(new Date()); + // 创建物流信息 + bsOrderGoodsService.create(logistics); + } else { + // 设置物流状态 + logistics.setLogisticsStatus(jsonObject.getString("logisticsStatus")); + // 设置物流状态描述 + logistics.setLogisticsStatusDesc(jsonObject.getString("logisticsStatusDesc")); + // 设置物流跟踪详情 + logistics.setLogisticsTraceDetails(objects.toString()); + // 更新物流信息 + bsOrderGoodsService.update(logistics); + } + + + orderGoods.setLogisticsStatus(jsonObject.getString("logisticsStatus")); + orderGoods.setLogisticsStatusDesc(jsonObject.getString("logisticsStatusDesc")); + orderGoods.setLogisticsNo(logisticInfo.getDeliveryOrderId()); + bsOrderGoodsService.update(orderGoods); + return logistics; + } + } + } + return null; + } + + @Override + public VopOrderQueryOrderDetailResponse queryOrderDetail(BsOrderGoods orderGoods) throws Exception { + return JdPostService.queryOrderDetail(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo()); + } + + @Override + public VopAfsCreateAfsApplyResponse createAfsApply(String thirdApplyId, Integer customerExpect, Long wareId, String wareName, Integer wareNum, Long jdOrderId, String customerName, Integer pickWareProvince, Integer pickWareCounty, Integer pickWareCity, String pickWareAddress, Integer returnWareProvince, Integer returnWareCounty, Integer returnWareCity, String returnWareAddress) throws Exception { + return JdPostService.createAfsApply(getToken(), thirdApplyId, customerExpect, wareId, wareName, wareNum, jdOrderId, customerName, pickWareProvince, pickWareCounty, pickWareCity, pickWareAddress, returnWareProvince, returnWareCounty, returnWareCity, returnWareAddress); + } + + private JSONObject jdLogisticsStatus(BsOrderGoods orderGoods) throws Exception { + JSONObject jsonObject = new JSONObject(); + // 查询上游订单 + VopOrderQueryOrderDetailResponse orderDetailResponse = JdPostService.queryOrderDetail(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo()); + com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.queryOrderDetail.OpenRpcResult result = orderDetailResponse.getOpenRpcResult(); + if (result.getSuccess()) { + QueryOrderOpenResp queryOrderOpenResp = result.getResult().get(0); + StateOrderOpenResp stateOrderOpenResp = queryOrderOpenResp.getOrderState(); + // 查看订单是否已确认 + if (stateOrderOpenResp.getConfirmState() == 1) { + jsonObject.put("logisticsStatus", "SIGN"); + jsonObject.put("logisticsStatusDesc", "已签收"); + } + // 订单状态为567为待揽收 + if (stateOrderOpenResp.getConfirmState() == 5 || stateOrderOpenResp.getConfirmState() == 6 || stateOrderOpenResp.getConfirmState() == 7) { + jsonObject.put("logisticsStatus", "WAIT_ACCEPT"); + jsonObject.put("logisticsStatusDesc", "待揽收"); + } + // 订单状态为8,9,10为待发货 + if (stateOrderOpenResp.getConfirmState() == 8 || stateOrderOpenResp.getConfirmState() == 9 || stateOrderOpenResp.getConfirmState() == 10) { + jsonObject.put("logisticsStatus", "ACCEPT"); + jsonObject.put("logisticsStatusDesc", "已揽件"); + } + // 订单状态为11,12,13,14为运输中 + if (stateOrderOpenResp.getConfirmState() == 11 || stateOrderOpenResp.getConfirmState() == 12 || stateOrderOpenResp.getConfirmState() == 13 || stateOrderOpenResp.getConfirmState() == 14) { + jsonObject.put("logisticsStatus", "TRANSPORT"); + jsonObject.put("logisticsStatusDesc", "运输中"); + } + // 订单状态为16为派件中 + if (stateOrderOpenResp.getConfirmState() == 16) { + jsonObject.put("logisticsStatus", "DELIVERING"); + jsonObject.put("logisticsStatusDesc", "派件中"); + } + } + return jsonObject; } } diff --git a/service/src/main/java/com/hfkj/jd/JdPostService.java b/service/src/main/java/com/hfkj/jd/JdPostService.java index ac65870..2a67763 100644 --- a/service/src/main/java/com/hfkj/jd/JdPostService.java +++ b/service/src/main/java/com/hfkj/jd/JdPostService.java @@ -4,7 +4,6 @@ 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.entity.BsOrderGoods; import com.hfkj.entity.GoodsUserAddress; import com.jd.open.api.sdk.DefaultJdClient; import com.jd.open.api.sdk.JdClient; @@ -12,23 +11,32 @@ import com.jd.open.api.sdk.domain.vopdd.OperaOrderOpenProvider.request.submitOrd import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.AreaBaseInfoGoodsReq; import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.GetStockByIdGoodsReq; import com.jd.open.api.sdk.domain.vopkc.SkuInfoGoodsProvider.request.getNewStockById.SkuNumBaseGoodsReq; -import com.jd.open.api.sdk.request.vopdd.VopOrderSubmitOrderRequest; +import com.jd.open.api.sdk.domain.vopsh.OperaAfterSaleOpenProvider.request.createAfsApply.*; +import com.jd.open.api.sdk.request.vopdd.*; import com.jd.open.api.sdk.request.vopdz.VopAddressConvertFourAreaByDetailStrRequest; import com.jd.open.api.sdk.request.vopdz.VopAddressQueryJdAreaIdListRequest; import com.jd.open.api.sdk.request.vopdz.VopAddressVerifyAreaFourIdOpenReqRequest; import com.jd.open.api.sdk.request.vopkc.VopGoodsGetNewStockByIdRequest; +import com.jd.open.api.sdk.request.vopsh.VopAfsCreateAfsApplyRequest; import com.jd.open.api.sdk.request.vopsp.*; +import com.jd.open.api.sdk.request.vopxx.VopMessageDeleteClientMsgByIdListRequest; +import com.jd.open.api.sdk.request.vopxx.VopMessageQueryTransByVopNormalRequest; +import com.jd.open.api.sdk.response.vopdd.VopOrderConfirmOrderResponse; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryDeliveryInfoResponse; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryOrderDetailResponse; import com.jd.open.api.sdk.response.vopdd.VopOrderSubmitOrderResponse; import com.jd.open.api.sdk.response.vopdz.VopAddressConvertFourAreaByDetailStrResponse; import com.jd.open.api.sdk.response.vopdz.VopAddressQueryJdAreaIdListResponse; import com.jd.open.api.sdk.response.vopdz.VopAddressVerifyAreaFourIdOpenReqResponse; import com.jd.open.api.sdk.response.vopkc.VopGoodsGetNewStockByIdResponse; +import com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse; import com.jd.open.api.sdk.response.vopsp.*; +import com.jd.open.api.sdk.response.vopxx.VopMessageDeleteClientMsgByIdListResponse; +import com.jd.open.api.sdk.response.vopxx.VopMessageQueryTransByVopNormalResponse; import org.apache.commons.codec.digest.DigestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Resource; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -307,7 +315,124 @@ public class JdPostService { } + // 消息查询接口 + public static VopMessageQueryTransByVopNormalResponse queryTransByVopNormal(String token) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopMessageQueryTransByVopNormalRequest request=new VopMessageQueryTransByVopNormalRequest(); + return client.execute(request); + } + + // 消息删除接口 + public static VopMessageDeleteClientMsgByIdListResponse deleteClientMsgByIdList(String token , String ids) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopMessageDeleteClientMsgByIdListRequest request=new VopMessageDeleteClientMsgByIdListRequest(); + request.setId(ids); + return client.execute(request); + } + + // 查询订单详情 + public static VopOrderQueryOrderDetailResponse queryOrderDetail(String token , Long jdOrderId , String thirdOrderId) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopOrderQueryOrderDetailRequest request=new VopOrderQueryOrderDetailRequest(); + request.setThirdOrderId(thirdOrderId); + request.setJdOrderId(jdOrderId); + return client.execute(request); + } + + // 取消订单 + public static void cancelOrder(String token , Long jdOrderId , String thirdOrderId , String remarks) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopOrderCancelOrderRequest request=new VopOrderCancelOrderRequest(); + request.setThirdOrderId(thirdOrderId); + request.setJdOrderId(jdOrderId); + request.setCancelReason(remarks); + client.execute(request); + } + + // 确定订单 + public static VopOrderConfirmOrderResponse confirmOrder(String token , Long jdOrderId , String thirdOrderId , String remarks) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopOrderConfirmOrderRequest request=new VopOrderConfirmOrderRequest(); + request.setThirdOrderId(thirdOrderId); + request.setJdOrderId(jdOrderId); + request.setExtJsonString(remarks); + return client.execute(request); + } + // 查询配送信息 + public static VopOrderQueryDeliveryInfoResponse queryDeliveryInfo(String token , Long jdOrderId , String thirdOrderId) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopOrderQueryDeliveryInfoRequest request=new VopOrderQueryDeliveryInfoRequest(); + request.setThirdOrderId(thirdOrderId); + request.setJdOrderId(jdOrderId); + return client.execute(request); + } + // 申请售后 + public static VopAfsCreateAfsApplyResponse createAfsApply( + String token , String thirdApplyId , Integer customerExpect , Long wareId , + String wareName , Integer wareNum , Long jdOrderId , String customerName , + Integer pickWareProvince , Integer pickWareCounty, Integer pickWareCity ,String pickWareAddress , + Integer returnWareProvince , Integer returnWareCounty , Integer returnWareCity , String returnWareAddress + ) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopAfsCreateAfsApplyRequest request=new VopAfsCreateAfsApplyRequest(); + // 售后申请入参 + ApplyAfterSaleOpenReq applyAfterSaleOpenReq=new ApplyAfterSaleOpenReq(); + // 申请批次号 + applyAfterSaleOpenReq.setThirdApplyId(thirdApplyId); + applyAfterSaleOpenReq.setOrderId(jdOrderId); + // 是否有发票 + applyAfterSaleOpenReq.setIsHasInvoice(false); + // 参数描述 + List applyInfoItemOpenReqList=new ArrayList<>(); + ApplyInfoItemOpenReq applyInfoItemOpenReq=new ApplyInfoItemOpenReq(); + + // 客户期望售后类型。10退货,20换货,30维修 + applyInfoItemOpenReq.setCustomerExpect(customerExpect); + // 商品明细 + WareDetailInfoOpenReq wareDetailInfoOpenReq = new WareDetailInfoOpenReq(); + // skuId + wareDetailInfoOpenReq.setMainWareId(wareId); + // skuId + wareDetailInfoOpenReq.setWareId(wareId); + // 商品名称 + wareDetailInfoOpenReq.setWareName(wareName); + // 商品数量 + wareDetailInfoOpenReq.setWareNum(wareNum); + // 商品类型 + wareDetailInfoOpenReq.setWareType(10); + // 插入 + applyInfoItemOpenReq.setWareDetailInfoOpenReq(wareDetailInfoOpenReq); + applyInfoItemOpenReqList.add(applyInfoItemOpenReq); + applyAfterSaleOpenReq.setApplyInfoItemOpenReqList(applyInfoItemOpenReqList); + + // 用户信息 + CustomerInfoOpenReq customerInfoOpenReq=new CustomerInfoOpenReq(); + customerInfoOpenReq.setCustomerName(customerName); + customerInfoOpenReq.setCustomerContactName(customerName); + // 插入 + applyAfterSaleOpenReq.setCustomerInfoVo(customerInfoOpenReq); + // 取件信息 + PickupWareInfoOpenReq pickWareInfoOpenReq=new PickupWareInfoOpenReq(); + pickWareInfoOpenReq.setPickWareType(4); + pickWareInfoOpenReq.setPickWareProvince(pickWareProvince); + pickWareInfoOpenReq.setPickWareCity(pickWareCity); + pickWareInfoOpenReq.setPickWareCounty(pickWareCounty); + pickWareInfoOpenReq.setPickWareAddress(pickWareAddress); + applyAfterSaleOpenReq.setPickupWareInfoOpenReq(pickWareInfoOpenReq); + + // 返件信息 + ReturnWareInfoOpenReq returnWareInfoOpenReq=new ReturnWareInfoOpenReq(); + returnWareInfoOpenReq.setReturnWareType(10); + returnWareInfoOpenReq.setReturnWareProvince(returnWareProvince); + returnWareInfoOpenReq.setReturnWareCity(returnWareCity); + returnWareInfoOpenReq.setReturnWareCountry(returnWareCounty); + returnWareInfoOpenReq.setReturnWareAddress(returnWareAddress); + applyAfterSaleOpenReq.setReturnWareInfoOpenReq(returnWareInfoOpenReq); + + request.setApplyAfterSaleOpenReq(applyAfterSaleOpenReq); + return client.execute(request); + } } diff --git a/service/src/main/java/com/hfkj/jd/JdService.java b/service/src/main/java/com/hfkj/jd/JdService.java index 12f2843..68c69d2 100644 --- a/service/src/main/java/com/hfkj/jd/JdService.java +++ b/service/src/main/java/com/hfkj/jd/JdService.java @@ -1,6 +1,12 @@ package com.hfkj.jd; +import com.hfkj.entity.BsOrder; +import com.hfkj.entity.BsOrderGoods; +import com.hfkj.entity.GoodsLogistics; import com.hfkj.entity.GoodsMsg; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryDeliveryInfoResponse; +import com.jd.open.api.sdk.response.vopdd.VopOrderQueryOrderDetailResponse; +import com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse; public interface JdService { @@ -33,4 +39,97 @@ public interface JdService { * @Date: 2024/11/22 下午2:01 */ Boolean checkSkuSale(GoodsMsg goodsMsg) throws Exception; + + /** + * @MethodName checkGoods + * @Description: 校验商品合法性 + * @param bsOrder + * @return: java.lang.Boolean + * @Author: Sum1Dream + * @Date: 2024/11/27 下午5:31 + */ + Boolean checkGoods(BsOrder bsOrder) throws Exception; + + /** + * @MethodName cancelOrder + * @Description: 取消订单 + * @param childNo + * @Author: Sum1Dream + * @Date: 2024/11/27 下午5:31 + */ + void cancelOrder(String childNo); + + /** + * @MethodName deleteMsg + * @Description: 消费消息 + * @param + * @Author: Sum1Dream + * @Date: 2024/11/27 下午5:31 + */ + void deleteMsg() throws Exception; + + /** + * @MethodName confirmOrder + * @Description: 确认订单 + * @param orderGoods + * @Author: Sum1Dream + * @Date: 2024/11/27 下午5:31 + */ + void confirmOrder(BsOrderGoods orderGoods) throws Exception; + + /** + * @MethodName queryDeliveryInfo + * @Description: 查询物流信息 + * @param orderGoods + * @return: com.jd.open.api.sdk.response.vopdd.VopOrderQueryDeliveryInfoResponse + * @Author: Sum1Dream + * @Date: 2024/11/27 下午5:45 + */ + VopOrderQueryDeliveryInfoResponse queryDeliveryInfo(BsOrderGoods orderGoods) throws Exception; + + /** + * @MethodName updateDeliveryInfo + * @Description: + * @param orderGoods + * @Author: Sum1Dream + * @Date: 2024/11/28 上午10:51 + */ + GoodsLogistics updateDeliveryInfo(BsOrderGoods orderGoods) throws Exception; + + /** + * @MethodName queryOrderDetail + * @Description:查询订单详情 + * @param orderGoods + * @return: com.jd.open.api.sdk.response.vopdd.VopOrderQueryOrderDetailResponse + * @Author: Sum1Dream + * @Date: 2024/11/28 上午11:19 + */ + VopOrderQueryOrderDetailResponse queryOrderDetail(BsOrderGoods orderGoods) throws Exception; + + /** + * @MethodName createAfsApply + * @Description: 申请售后 + * @param thirdApplyId + * @param customerExpect + * @param wareId + * @param wareName + * @param wareNum + * @param jdOrderId + * @param customerName + * @param pickWareProvince + * @param pickWareCounty + * @param pickWareCity + * @param pickWareAddress + * @param returnWareProvince + * @param returnWareCounty + * @param returnWareCity + * @param returnWareAddress + * @return: com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse + * @Author: Sum1Dream + * @Date: 2024/11/29 下午3:08 + */ + VopAfsCreateAfsApplyResponse createAfsApply(String thirdApplyId , Integer customerExpect , Long wareId , + String wareName , Integer wareNum , Long jdOrderId , String customerName , + Integer pickWareProvince , Integer pickWareCounty, Integer pickWareCity , String pickWareAddress , + Integer returnWareProvince , Integer returnWareCounty , Integer returnWareCity , String returnWareAddress) throws Exception; } 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 26b8297..24ac6e8 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java @@ -149,4 +149,22 @@ public interface BsOrderGoodsService { * @Return com.alibaba.fastjson.JSONObject */ void confirmReceipt(Long orderGoodsId); + + /** + * @MethodName update + * @Description:更新 + * @param goodsLogistics + * @Author: Sum1Dream + * @Date: 2024/11/28 下午12:01 + */ + void update(GoodsLogistics goodsLogistics); + + /** + * @MethodName create + * @Description: 创建 + * @param goodsLogistics + * @Author: Sum1Dream + * @Date: 2024/11/28 下午12:01 + */ + void create(GoodsLogistics goodsLogistics); } diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsBrandService.java b/service/src/main/java/com/hfkj/service/goods/GoodsBrandService.java index 355c37a..9a975b3 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsBrandService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsBrandService.java @@ -53,6 +53,7 @@ public interface GoodsBrandService { * @return com.hfkj.entity.GoodsBrand */ GoodsBrand queryDetail(Long id); + GoodsBrand queryDetail(String title); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java index f1effd5..4ac19b7 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsMsgService.java @@ -57,6 +57,8 @@ public interface GoodsMsgService { */ GoodsMsg queryDetail(Long id); + GoodsMsg queryDetail(String thirdId); + /** * @Author Sum1Dream * @Name queryDetailByMap diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java b/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java index 5a80a62..61d927a 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsTypeService.java @@ -54,6 +54,7 @@ public interface GoodsTypeService { * @return com.hfkj.entity.GoodsType */ GoodsType queryDetail(Long id); + GoodsType queryDetail(String title); /** * @Author Sum1Dream 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 b1badc3..8b84e5a 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 @@ -333,4 +333,14 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { // 删除缓存 orderService.cacheDelete(orderGoods.getOrderNo()); } + + @Override + public void update(GoodsLogistics goodsLogistics) { + goodsLogisticsMapper.updateByPrimaryKeySelective(goodsLogistics); + } + + @Override + public void create(GoodsLogistics goodsLogistics) { + goodsLogisticsMapper.insert(goodsLogistics); + } } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java index f8b82df..5d29e8b 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsBrandServiceImpl.java @@ -46,6 +46,19 @@ public class GoodsBrandServiceImpl implements GoodsBrandService { return goodsBrandMapper.selectByPrimaryKey(id); } + @Override + public GoodsBrand queryDetail(String title) { + GoodsBrandExample example = new GoodsBrandExample(); + GoodsBrandExample.Criteria criteria = example.createCriteria(); + criteria.andTitleEqualTo(title); + + List goodsBrands = goodsBrandMapper.selectByExample(example); + if (!goodsBrands.isEmpty()) { + return goodsBrands.get(0); + } + return null; + } + @Override public GoodsBrand queryDetailByMap(Map map) { return null; diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java index 54800c4..c7a16f2 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java @@ -57,6 +57,20 @@ public class GoodsMsgServiceImpl implements GoodsMsgService { return goodsMsgMapper.selectByPrimaryKey(id); } + @Override + public GoodsMsg queryDetail(String thirdId) { + GoodsMsgExample example = new GoodsMsgExample(); + example.createCriteria().andThirdIdEqualTo(thirdId); + + List list = goodsMsgMapper.selectByExample(example); + + if (list != null && !list.isEmpty()) { + return list.get(0); + } + + return null; + } + @Override public GoodsMsg queryDetailByMap(Map map) { GoodsMsgExample example = new GoodsMsgExample(); diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java index 1d25044..2b421d4 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java @@ -81,6 +81,12 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService { public GoodsSpecs queryDetailByThirdId(String thirdId) { GoodsSpecsExample goodsSpecsExample = new GoodsSpecsExample(); goodsSpecsExample.createCriteria().andThirdIdEqualTo(thirdId); + List goodsSpecs = goodsSpecsMapper.selectByExample(goodsSpecsExample); + + if (!goodsSpecs.isEmpty()) { + return goodsSpecs.get(0); + } + return null; } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java index 206df15..95acb4e 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java @@ -47,6 +47,20 @@ public class GoodsTypeServiceImpl implements GoodsTypeService { return goodsTypeMapper.selectByPrimaryKey(id); } + @Override + public GoodsType queryDetail(String title) { + GoodsTypeExample example = new GoodsTypeExample(); + GoodsTypeExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); + criteria.andTitleEqualTo(title); + + List list = goodsTypeMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + @Override public GoodsType queryDetailByMap(Map map) { diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesAddressRecordService.java b/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesAddressRecordService.java new file mode 100644 index 0000000..0c60b6a --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesAddressRecordService.java @@ -0,0 +1,18 @@ +package com.hfkj.service.order; + +import com.hfkj.entity.BsOrderAfterSalesAddressRecord; +import com.hfkj.entity.GoodsUserAddress; + +public interface BsOrderAfterSalesAddressRecordService { + + /** + * @MethodName create + * @Description: 创建 + * @param afterSalesAddressRecord + * @Author: Sum1Dream + * @Date: 2024/11/29 下午4:08 + */ + void create(BsOrderAfterSalesAddressRecord afterSalesAddressRecord); + + void insertRecord(String applyNo , String type , GoodsUserAddress goodsUserAddress); +} diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesApplyService.java b/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesApplyService.java index d30b792..c486f45 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesApplyService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderAfterSalesApplyService.java @@ -39,12 +39,24 @@ public interface BsOrderAfterSalesApplyService { */ void audit(String applyNo, Boolean applyStatus, String remarks, Long opUserId); + void jdAudit(String applyNo, Boolean applyStatus, String remarks, Long opUserId , Integer jdAudit); + /** * 邮寄 * @param applyNo 申请单号 * @param sendExpressNo 快递单号 */ void sendExpress(String applyNo, String sendExpressNo); + /** + * @MethodName createAfsApplyByJd + * @Description: 京东上门取件 + * @param applyNo + * @param pickAddressId + * @param returnAddressId + * @Author: Sum1Dream + * @Date: 2024/11/29 下午3:12 + */ + void createAfsApplyByJd(String applyNo, Long pickAddressId , Long returnAddressId) throws Exception; /** * 完成 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 972e023..fde4b28 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -300,7 +300,7 @@ public class OrderCreateService { orderGoods.setGoodsSpecsName(goodsSpecs.getName()); orderGoods.setGoodsSpecsOriginalPrice(goodsSpecs.getOriginalPrice()); orderGoods.setGoodsCount(orderChild.getProductCount()); - orderGoods.setStatus(orderChild.getStatus()); + orderGoods.setStatus(1); orderGoods.setDeliveryAddress(address.getRegionName() + "-" + address.getAddress() + "-" + address.getConsignee() + "-" + address.getPhone()); orderGoods.setDeliveryAddressId(address.getId()); orderGoods.setCreateTime(new Date()); @@ -594,6 +594,7 @@ public class OrderCreateService { // 检查商品是否在指定地区限制范围内 VopGoodsCheckAreaLimitListResponse checkAreaLimitListResponse = JdPostService.checkAreaLimitList(jdService.getToken() , skuId , address.getProvinceId() , address.getCityId() , address.getCountyId() , address.getTownId()); + if (checkAreaLimitListResponse != null && checkAreaLimitListResponse.getOpenRpcResult().getSuccess()) { // 返回是否在限制范围内 if (checkAreaLimitListResponse.getOpenRpcResult().getResult().get(0).getIsAreaRestrict()) { @@ -615,11 +616,11 @@ public class OrderCreateService { VopGoodsGetNewStockByIdResponse stockResponse = JdPostService.getNewStockById(jdService.getToken() , Long.valueOf(skuId), address.getProvinceId() , address.getCityId() , address.getCountyId() , address.getTownId()); if (stockResponse != null && !stockResponse.getOpenRpcResult().getSuccess()) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "商品已售罄!" ); + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前地区,商品已售罄!" ); } if (!checkStock(stockResponse.getOpenRpcResult().getResult().get(0).getStockStateType())) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "商品已售罄!" ); + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前地区,商品已售罄!" ); } @@ -627,9 +628,9 @@ public class OrderCreateService { VopOrderSubmitOrderResponse submitOrderResponse = JdPostService.submitOrder(jdService.getToken() , address , orderNo, num , Long.valueOf(skuId) ); if (submitOrderResponse != null && !submitOrderResponse.getVopOrderRpcResult().getSuccess()) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "下单失败!" ); + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , submitOrderResponse.getVopOrderRpcResult().getResultMessage() ); } - orderGoods.setThirdOrderNo(submitOrderResponse.getVopOrderRpcResult().getResult().getThirdOrderId()); + orderGoods.setThirdOrderNo(String.valueOf(submitOrderResponse.getVopOrderRpcResult().getResult().getJdOrderId())); return orderGoods; 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 5b5f58e..a9e5107 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -9,6 +9,7 @@ import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.OrderUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.*; +import com.hfkj.jd.JdService; import com.hfkj.meituan.MeiTuanService; import com.hfkj.model.order.OrderModel; import com.hfkj.qianzhu.CinemaService; @@ -66,7 +67,8 @@ public class OrderPaySuccessService { @Resource private BsOrderMemberService bsOrderMemberService; - + @Resource + private JdService jdService; /** * 订单业务处理 * @param order @@ -260,6 +262,10 @@ public class OrderPaySuccessService { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "未查询到相关内容"); } + if (goodsOrder.getThirdOrderNo() != null) { + jdService.confirmOrder(goodsOrder); + } + goodsMsgService.editSaleNum(goodsOrder.getGoodsId() , goodsOrder.getGoodsCount() , 1); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesAddressRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesAddressRecordServiceImpl.java new file mode 100644 index 0000000..8329934 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesAddressRecordServiceImpl.java @@ -0,0 +1,35 @@ +package com.hfkj.service.order.impl; + +import com.hfkj.dao.BsOrderAfterSalesAddressRecordMapper; +import com.hfkj.entity.BsOrderAfterSalesAddressRecord; +import com.hfkj.entity.GoodsUserAddress; +import com.hfkj.service.order.BsOrderAfterSalesAddressRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; + +@Service("bsOrderAfterSalesAddressRecordService") +public class BsOrderAfterSalesAddressRecordServiceImpl implements BsOrderAfterSalesAddressRecordService { + + @Resource + private BsOrderAfterSalesAddressRecordMapper bsOrderAfterSalesAddressRecordMapper; + + @Override + public void create(BsOrderAfterSalesAddressRecord afterSalesAddressRecord) { + bsOrderAfterSalesAddressRecordMapper.insert(afterSalesAddressRecord); + } + + @Override + public void insertRecord(String applyNo, String type, GoodsUserAddress deliveryAddress) { + BsOrderAfterSalesAddressRecord record = new BsOrderAfterSalesAddressRecord(); + record.setAddress(deliveryAddress.getRegionName() + "-" + deliveryAddress.getAddress() + "-" + deliveryAddress.getConsignee() + "-" + deliveryAddress.getPhone()); + record.setApplyNo(applyNo); + record.setType(type); + record.setAddressId(deliveryAddress.getId()); + record.setCreateTime(new Date()); + record.setUpdateTime(new Date()); + record.setStatus(1L); + create(record); + } +} diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java index b230965..606c964 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java @@ -7,14 +7,19 @@ import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.RandomUtils; import com.hfkj.dao.BsOrderAfterSalesApplyMapper; import com.hfkj.entity.*; +import com.hfkj.jd.JdService; import com.hfkj.model.UserSessionObject; import com.hfkj.model.order.OrderChildModel; import com.hfkj.service.SecUserService; +import com.hfkj.service.goods.BsOrderGoodsService; +import com.hfkj.service.goods.GoodsMsgService; +import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.order.*; import com.hfkj.sysenum.order.OrderAfterSalesApplyStatusEnum; import com.hfkj.sysenum.order.OrderAfterSalesApplyTypeEnum; import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderRefundStatusEnum; +import com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -47,6 +52,16 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply private BsOrderRefundService orderRefundService; @Resource private SecUserService secUserService; + @Resource + private BsOrderGoodsService bsOrderGoodsService; + @Resource + private JdService jdService; + @Resource + private GoodsUserAddressService goodsUserAddressService; + @Resource + private GoodsMsgService goodsMsgService; + @Resource + private BsOrderAfterSalesAddressRecordService afterSalesAddressRecordService; @Override public void editData(BsOrderAfterSalesApply data) { data.setUpdateTime(new Date()); @@ -184,6 +199,45 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply editData(apply); } + @Override + public void jdAudit(String applyNo, Boolean applyStatus, String remarks, Long opUserId, Integer jdAudit) { + // 查询申请 + BsOrderAfterSalesApply apply = getDetailByApplyNo(applyNo); + if (apply == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的申请"); + } + if (OrderAfterSalesApplyStatusEnum.type1.getCode() != apply.getStatus()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "审核失败!当前申请不处于审核状态"); + } + SecUser secUser = secUserService.getDetail(opUserId); + if (secUser == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的操作人"); + } + + apply.setAuditTime(new Date()); + apply.setAuditRemarks(remarks); + + if (applyStatus.equals(true)) { + apply.setStatus(OrderAfterSalesApplyStatusEnum.type6.getCode()); + apply.setJdStatus(jdAudit); + + } else { + apply.setStatus(OrderAfterSalesApplyStatusEnum.type2.getCode()); + } + + // 操作记录 + BsOrderAfterSalesOpRecord opRecord = new BsOrderAfterSalesOpRecord(); + opRecord.setApplyNo(apply.getApplyNo()); + opRecord.setStatus(apply.getStatus()); + opRecord.setRemarks(remarks); + opRecord.setOpUserType(1); + opRecord.setOpUserId(secUser.getId()); + opRecord.setOpUserName(secUser.getUserName()); + orderAfterSalesOpRecordService.create(opRecord); + + editData(apply); + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) public void sendExpress(String applyNo, String sendExpressNo) { @@ -211,6 +265,66 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply orderAfterSalesOpRecordService.create(opRecord); } + @Override + public void createAfsApplyByJd(String applyNo, Long pickAddressId, Long returnAddressId) throws Exception { + // 查询申请 + BsOrderAfterSalesApply apply = getDetailByApplyNo(applyNo); + if (apply == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的申请"); + } + if (OrderAfterSalesApplyStatusEnum.type6.getCode() != apply.getStatus()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "审核失败!当前申请不处于待取件中"); + } + // 查询订单 + BsOrderGoods bsOrderGoods = bsOrderGoodsService.findGoodsOrderByChild(apply.getChildOrderNo()); + if (bsOrderGoods == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的申请"); + } + // 查询商品信息 + GoodsMsg goodsMsg = goodsMsgService.queryDetail(bsOrderGoods.getGoodsId()); + if (goodsMsg == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品信息错误"); + } + if (goodsMsg.getThirdId() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品信息错误"); + } + // 查询取件地址 + GoodsUserAddress pickAddress = goodsUserAddressService.queryDetail(pickAddressId); + if (pickAddress == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "取件地址错误!"); + } + afterSalesAddressRecordService.insertRecord(applyNo , "1" , pickAddress); + // 查询回寄地址 + GoodsUserAddress returnAddress = goodsUserAddressService.queryDetail(pickAddressId); + if (returnAddress == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "回寄地址错误!"); + } + afterSalesAddressRecordService.insertRecord(applyNo , "2" , pickAddress); + VopAfsCreateAfsApplyResponse response = jdService.createAfsApply(applyNo , apply.getJdStatus() , Long.valueOf(goodsMsg.getThirdId()) , goodsMsg.getTitle() , apply.getProductCount() , + Long.valueOf(bsOrderGoods.getThirdOrderNo()) , bsOrderGoods.getMerName() , + pickAddress.getProvinceId().intValue() , pickAddress.getCountyId().intValue() , pickAddress.getCityId().intValue() , pickAddress.getAddress() , + returnAddress.getProvinceId().intValue() , returnAddress.getCountyId().intValue() , returnAddress.getCityId().intValue() , returnAddress.getAddress()); + + if (response.getOpenRpcResult().getSuccess()) { + apply.setStatus(OrderAfterSalesApplyStatusEnum.type4.getCode()); + editData(apply); + + // 操作记录 + BsOrderAfterSalesOpRecord opRecord = new BsOrderAfterSalesOpRecord(); + opRecord.setApplyNo(apply.getApplyNo()); + opRecord.setStatus(apply.getStatus()); + opRecord.setRemarks("京东上门取件申请成功"); + opRecord.setOpUserType(1); + opRecord.setOpUserId(apply.getId()); + opRecord.setOpUserName(apply.getUserPhone()); + orderAfterSalesOpRecordService.create(opRecord); + } else { + apply.setAuditMsg(response.getOpenRpcResult().getResultMessage()); + editData(apply); + } + + } + @Override public void finish(String applyNo, Long opUserId) { // 查询申请 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 b9cede8..63c750f 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 @@ -125,19 +125,6 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { object.put("orderGoodsId", orderGoods.getId()); childModel.setBusiness(object); - if (orderGoods.getLogisticsStatus() != null && orderGoods.getLogisticsStatus().equals(OrderLogisticsStatusEnum.statusSIGN.getCode())) { - // 子订单完成 - 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()); - } - } } else if (childModel.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { 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 442cb00..48c1ebf 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 @@ -11,16 +11,15 @@ import com.hfkj.common.utils.RandomUtils; import com.hfkj.common.utils.RedisUtil; import com.hfkj.dao.BsOrderMapper; import com.hfkj.entity.*; +import com.hfkj.jd.JdService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.mqtopic.OrderTopic; import com.hfkj.qianzhu.CinemaService; -import com.hfkj.qianzhu.StarbucksService; import com.hfkj.service.BsProductConfigService; import com.hfkj.service.discount.CouponDiscountService; import com.hfkj.service.discount.CouponDiscountUserRelService; import com.hfkj.service.goods.BsOrderCinemaService; -import com.hfkj.service.goods.BsOrderStarbucksService; import com.hfkj.service.order.*; import com.hfkj.service.user.UserIntegralService; import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; @@ -91,7 +90,7 @@ public class BsOrderServiceImpl implements BsOrderService { @Resource private BsProductConfigService productConfigService; @Resource - private BsOrderStarbucksService orderStarbucksService; + private JdService jdService; @Override @@ -300,6 +299,9 @@ public class BsOrderServiceImpl implements BsOrderService { rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14); } else if (order.getOrderStatus().equals(OrderStatusEnum.status2.getCode())) { + if (jdService.checkGoods(order)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "购买失败!"); + } // 支付校验 orderPayBeforeService.payOrderCheck(order); // 处理业务 @@ -399,6 +401,7 @@ public class BsOrderServiceImpl implements BsOrderService { editData(order); for (BsOrderChild orderChild : order.getOrderChildList()) { + jdService.cancelOrder(orderChild.getChildOrderNo()); orderChild.setStatus(OrderChildStatusEnum.status5.getCode()); orderChildService.editData(orderChild); } diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyStatusEnum.java index 46013b8..11a48d0 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyStatusEnum.java @@ -33,6 +33,10 @@ public enum OrderAfterSalesApplyStatusEnum { * 完成 */ type5(5, "完成"), + /** + * 待取件 + */ + type6(6, "待取件"), ; private int code; diff --git a/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyTypeEnum.java index 7865a5f..5a243b4 100644 --- a/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/order/OrderAfterSalesApplyTypeEnum.java @@ -21,6 +21,8 @@ public enum OrderAfterSalesApplyTypeEnum { * 退货申请 */ type2(2, "退货申请"), + type3(3, "换货申请"), + type4(4, "维修申请"), ; private int code; diff --git a/service/src/main/resources/pre/commonConfig.properties b/service/src/main/resources/pre/commonConfig.properties index e69de29..aaff1bb 100644 --- a/service/src/main/resources/pre/commonConfig.properties +++ b/service/src/main/resources/pre/commonConfig.properties @@ -0,0 +1,96 @@ +fileUrl=/home/project/phg/filesystem +#fileUrl=/Users/chenyao/Desktop/img +domainName=https://phg.dctpay.com + +wechatMpAppid=wxa075e8509802f826 +wechatMpSecret=0e606fc1378d35e359fcf3f15570b2c51 + +wechatMaAppid=wx785ac6bc8daa0f88 +wechatMaSecret=81c5f13b7c5372b31e04814c86ae97d8 + +obsBucketName=phg-test +obsEndPoint=https://obs.cn-southwest-2.myhuaweicloud.com +obsUrl=https://phg-test.obs.cn-southwest-2.myhuaweicloud.com + +huiPayPreorderNotifyUrl=https://phgcs.dctpay.com/order/notify/huipay + +# ChongQingCNPC configuration parameters +chongQingCnpcUrl=http://121.40.235.135:9083/d/cross/api +chongQingCnpcMerNo=toywqvi14wenrhb3d9 +chongQingCnpcMerKey=n2j30jxhl3rhuoci +chongQingCnpcCouponSignKey=5ojldakiz343a6yk + +# PetroChinaYouTu configuration parameters +pcytCnpcPostUrl=https://api.coupon.shuangpenghui.com//business/entry +pcytCnpcMerchant=355920109860 +pcytCnpcSecret=Es9cshhRoDxeFAuGItLZUDi8Qj3PWrje + +# BiLingXing +blxPostUrl=https://zhctapplet.gyzhtc.com/gateway + +huiliantongUrl=https://gzapi.deepermobile.com.cn +huiliantongAppNo=guizhouhuilt +huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D +huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A +huiliantongSinopecDistributorId=aNId4A3X +huiliantongDistributorId=1JnL8YMV +huiliantongSinopecUrl=fuelCoupons + + + +scPetroUrl = http://43.136.176.177:8081/hd-api/out/ +scPetroAppid = 510000313181602615 +scPetroAppKey = 510000kA5kxtaDnx3V6HE +scPetroAesKey = AptFsUgpgAij3evH7rm4ubTKu5viSx9U + +gzPetroUrl = http://140.143.82.223:1588/gz +gzPetroAppid = F0bdoJRwt +gzPetroAppKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 +gzPetroAesKey = pIyhCbA61wwyyU371QUSnBKqbWvO8Q98 + +#ETC +etcPostUrl = https://test.djien-qr.com/ +etcChannelCode = GZETCFXQD +etcPublicKey = MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMyQb5gR1rweB5oHKqRPJtJjLQKsn5PXOVfaNdGt/2kPkHvRdN3L9zOaAvFEXcEl2V0sg3D8a+2Sfy1YANAZvjscTQYOaoFl+LVyQZvgyyX8RQw+26Jmbqh8DwenUbNf7DFYVSDxIMBLOiWPkGsYGFONjsUVmfykSeVTcEgQB3VwIDAQAB +etcPrivateKey = MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAO8+KWh/OmBahFk7TWOEjPl13BT5NdlbGvQ/311Yua6CQqul9w1DIR2TwFUUh/Bko/eVoLROfF2XVjHbw2bImTdJ7y9C3511HI59YPNzqyql0DHjLxbH0VW92eUgk8mG09wtrUMu1ImN0b7aFE3uqAgz6pwh3TUiQWsDWz+l/MG7AgMBAAECgYEA7nYsOd8OpbmzT2m/omEdTwz9993KocKgZDJCBj4InftyTrrXO93cZSm/PE6BjMgTcxUuIGpWpcbRgFLHOmzZ4Qd+k/6Yb1ErMTfdGlgrxv2B+vztWYfjmFzEiXpecFH47ED6iYrrqm14X3InpnBv4rUkGdqqNbyPGgTO2ncs/3kCQQD+xqRAQSb/TROlqJdO91y6z9v0PO2GLmokqYg444rKYZKhDE0tdJeLU/sfK8SMg5+SlwdQm4nlo8EDJ/w2CEn3AkEA8GRqVkKgIuH413/a6+luYDjlf30WY7Mi1sm3QPSZ6+eH35UwsL6mdX6mjRpUN9Hez6FMfE7s3XOldoPVMzR1XQJBAOa2VTkGhtz8HEWQZOySXfuhjSogHmu7Dk2C5CO4Eg/wycpjDGSUR0NZWnfAt60S6GbjszEQmJBGeNt10xPO78MCQQCWXwnRaZ3IFDhXfQfRWFSN5ilQ5UszFGQvnUB/ZkI+ObdZmXY6qRdxGcdPLnAN9r78fDZe7/Pk1qljCDY98IuVAkEAnSeO/221gDhL1wnbUhGuX1yo8f5Eo/wDTW5cBxXFGZeexhB8I4jnEV4E/xmikkb3jDFvmrnFk+XUtDqkrvicRQ== + +huiftReqUrl=https://gzyhmp.huift.com.cn +huiftShopCode=20240653-59c4-4181-9157-17fd4b95c3fc +huiftSignSecret=19C17F9E19B8DDDDF2FD2EE4EA9F6C61 + +#QIANZHU +qianZhuUrl=https://live.qianzhu8.com +qianzhuH5url=https://nf.qianzhu8.com/gateway +qinzhuUrlToken=https://live.qianzhu8.com/gateway +qianZhuPlatformId=10710 +qianZhuSecret=pgmh5j1cbq2brm08 +qianZhuCinemaNotify=https://phg.dctpay.com/order/cinemaNotify/notify + +#CT +ctNotifyUrl = 1 +ctApiKey=3fd74e7c16b04681a0f481c5bc0a96d3 +ctMemberId=1622808562621276161 +ctPostUrl=http://113.250.49.100:8088/recharge/ + + +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 + +yuShangAppKey=211395334 +yuShangAppSecret=VxNTJua4FkmRVgIm8HgCSg== +yuShangPostUrl=http://mbapiq.mbs.scyshy.com/ + +haiOilPostUrl = https://test-oil.dctpay.com +haiOilAppid = hf7356c71fb97ab0 +haiOilAppSecret = 8aef995ff71485dc19b36e35f04c4016 + + +jDPostUrl = https://test-oil.dctpay.com +jDAppKey = C4FF710550C43FE76D4114E1C9C6A0C9 +jDAppSecret = 873bcbc1d8d64f36832270c2ff59c194 + +ytAccessKey=9326673207264334 +ytSecretKey=VCLXFV09BNZNMERR9F21KI3LC7L101YY +ytPostUrl=https://youtu.95504.net/v4 diff --git a/user/src/main/resources/pre/application.yml b/user/src/main/resources/pre/application.yml index 23f62ce..5a0f4f6 100644 --- a/user/src/main/resources/pre/application.yml +++ b/user/src/main/resources/pre/application.yml @@ -1,7 +1,7 @@ server: - port: 9301 + port: 9704 servlet: - context-path: /crest + context-path: /user #配置是否为debug模式,debug模式下,不开启权限校验 debug: false @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.9.154.68:3306/phg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.9.154.68:3306/phg_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -54,3 +54,36 @@ pagehelper: reasonable: true supportMethodsArguments: true params: count=countSql + +rocketmq: + name-server: 139.9.154.68:9876 + producer: + access-key: huifukeji + secret-key: HF123456. + #必须指定group + group: default-group + consumer: + access-key: huifukeji + secret-key: HF123456. + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.9.154.68 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50