From c68e2d6b08218f5b83d0633f534342f6b2de7ba9 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 9 Sep 2024 15:24:54 +0800 Subject: [PATCH 1/7] /1 --- .../com/order/controller/OrderController.java | 81 ++++++++++++++++++- order/src/main/resources/dev/logback.xml | 43 ++++++++++ order/src/main/resources/prod/logback.xml | 28 ++++++- .../com/hfkj/common/utils/SignatureUtil.java | 78 ++++++++++++++++++ .../java/com/hfkj/config/CommonSysConfig.java | 8 ++ .../java/com/hfkj/haioil/HaiOilService.java | 67 +++++++++++++++ .../orderExport/OrderGoodsExportModel.java | 2 +- .../com/hfkj/service/SecConfigService.java | 52 ++++++++++++ .../service/impl/SecConfigServiceImpl.java | 34 ++++++++ .../resources/dev/commonConfig.properties | 6 +- 10 files changed, 390 insertions(+), 9 deletions(-) create mode 100644 service/src/main/java/com/hfkj/common/utils/SignatureUtil.java create mode 100644 service/src/main/java/com/hfkj/haioil/HaiOilService.java create mode 100644 service/src/main/java/com/hfkj/service/SecConfigService.java create mode 100644 service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index 41fd029..2a8f010 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -9,23 +9,30 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.common.utils.SignatureUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrder; +import com.hfkj.entity.BsOrderChild; +import com.hfkj.entity.BsOrderGoods; +import com.hfkj.entity.GoodsSpecs; +import com.hfkj.haioil.HaiOilService; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; +import com.hfkj.service.goods.BsOrderGoodsService; +import com.hfkj.service.goods.GoodsSpecsService; import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.impl.BsOrderChildServiceImpl; import com.hfkj.service.pay.HuiPayService; import com.hfkj.sysenum.UserStatusEnum; -import com.hfkj.sysenum.order.OrderChildProductTypeEnum; -import com.hfkj.sysenum.order.OrderPayChannelEnum; -import com.hfkj.sysenum.order.OrderPayTypeEnum; -import com.hfkj.sysenum.order.OrderStatusEnum; +import com.hfkj.sysenum.order.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -49,6 +56,12 @@ public class OrderController { private UserCenter userCenter; @Resource private BsOrderService orderService; + @Resource + private BsOrderChildServiceImpl orderChildService; + @Resource + private GoodsSpecsService goodsSpecsService; + @Resource + private BsOrderGoodsService orderGoodsService; @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @@ -265,4 +278,64 @@ public class OrderController { } } + @RequestMapping(value="/completeActivation",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "完成激活") + public ResponseData completeActivation(@RequestBody JSONObject body) { + try { + + if (body == null|| StringUtils.isBlank(body.getString("childOrderNo"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + BsOrderChild bsOrderChild = orderChildService.getDetail(body.getString("childOrderNo")); + + if (bsOrderChild.getStatus() != OrderChildStatusEnum.status2.getCode()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不可完成激活!"); + } + // 子订单完成 + orderService.childOrderComplete(bsOrderChild.getChildOrderNo()); + + // 赠送优惠券包 + GoodsSpecs goodsSpecs = goodsSpecsService.queryDetailByGoodsId(bsOrderChild.getProductSpecId()); + + BsOrderGoods orderGoods = orderGoodsService.findGoodsOrderByChild(bsOrderChild.getChildOrderNo()); + + Map map = new HashMap<>(); + map.put("discountPkNo" , goodsSpecs.getExt1()); + map.put("number" , bsOrderChild.getProductCount()); + map.put("phone" , orderGoods.getUserPhone()); + HaiOilService.pushPk(map); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/haiOilLogin",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "嗨加油登陆参数") + public ResponseData haiOilLogin(@RequestBody JSONObject body) { + try { + + if (body == null|| StringUtils.isBlank(body.getString("phone"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + Map map = new HashMap<>(); + map.put("appId" , CommonSysConst.getSysConfig().getHaiOilAppid()); + map.put("phone" , body.getString("phone")); + map.put("sign" , SignatureUtil.createSign(map , CommonSysConst.getSysConfig().getHaiOilAppSecret())); + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/order/src/main/resources/dev/logback.xml b/order/src/main/resources/dev/logback.xml index 5f39830..9d782ad 100644 --- a/order/src/main/resources/dev/logback.xml +++ b/order/src/main/resources/dev/logback.xml @@ -268,4 +268,47 @@ + + + log/YuShangLog.log + + log/YuShangLog/YuShangLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + + + log/HaiOilLog.log + + log/HaiOilLog/HaiOilLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/order/src/main/resources/prod/logback.xml b/order/src/main/resources/prod/logback.xml index 1430fc5..5309354 100644 --- a/order/src/main/resources/prod/logback.xml +++ b/order/src/main/resources/prod/logback.xml @@ -267,7 +267,7 @@ - + log/YuShangLog.log @@ -276,7 +276,7 @@ 64 MB - 7 + %d %p (%file:%line\)- %m%n @@ -287,6 +287,28 @@ - + + + + + log/HaiOilLog.log + + log/HaiOilLog/HaiOilLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/service/src/main/java/com/hfkj/common/utils/SignatureUtil.java b/service/src/main/java/com/hfkj/common/utils/SignatureUtil.java new file mode 100644 index 0000000..f4b5dee --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/SignatureUtil.java @@ -0,0 +1,78 @@ +package com.hfkj.common.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import java.security.MessageDigest; +import java.util.Arrays; +import java.util.Map; +import java.util.Set; + +public class SignatureUtil { + /** + * 参数签名 + * @param param 参数 + * @param key 秘钥 + * @return + * @throws Exception + */ + public static String createSign(Object param, String key) throws Exception { + Map map = JSONObject.parseObject(JSONObject.toJSONString(param), Map.class); + return md5Encode(paramSort(map, key).getBytes()); + } + + /** + * 验证签名 + * @param checkSign 需验证的签名字符串 + * @param param 参数 + * @param key 秘钥 + * @return + * @throws Exception + */ + public static Boolean checkSign(String checkSign,Object param, String key) throws Exception { + Map map = JSONObject.parseObject(JSONObject.toJSONString(param), Map.class); + // 去除签名 + map.remove("sign"); + if (checkSign.equals(createSign(map, key))) { + return true; + } + return false; + } + + /** + * 参数排序 + * @param param + * @return + */ + public static String paramSort(final Map param, String key) { + Set keySet = param.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(param.get(k)); + } else { + sb.append("&").append(k).append("=").append(param.get(k)); + } + } + sb.append("&key=").append(key); + return sb.toString(); + } + + /** + * MD5加密 + * @param data + * @return + * @throws Exception + */ + public static String md5Encode(byte[] data) throws Exception { + // 初始化MessageDigest + MessageDigest md = MessageDigest.getInstance("MD5"); + // 执行摘要信息 + byte[] digest = md.digest(data); + // 将摘要信息转换为32位的十六进制字符串 + return new String(new HexBinaryAdapter().marshal(digest)); + } +} diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index 5ec73be..123f966 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -145,4 +145,12 @@ public class CommonSysConfig { private String yuShangAppKey; private String yuShangAppSecret; private String yuShangPostUrl; + + /** + * 嗨加油请求参数 + */ + private String haiOilPostUrl; + private String haiOilAppid; + private String haiOilAppSecret; + } diff --git a/service/src/main/java/com/hfkj/haioil/HaiOilService.java b/service/src/main/java/com/hfkj/haioil/HaiOilService.java new file mode 100644 index 0000000..ef02a5b --- /dev/null +++ b/service/src/main/java/com/hfkj/haioil/HaiOilService.java @@ -0,0 +1,67 @@ +package com.hfkj.haioil; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.common.utils.SignatureUtil; +import com.hfkj.config.CommonSysConst; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.Map; +import java.util.Objects; + +public class HaiOilService { + + private static Logger log = LoggerFactory.getLogger(HaiOilService.class); + + + /** + * @MethodName pushPk + * @Description: 推送优惠券包 + * @param map + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/9 下午2:57 + */ + public static JSONObject pushPk(Map map) throws Exception { + + JSONObject object = request("/openapi/discount/pushPk" , map); + + if (Objects.equals(object.getString("return_code"), "000000")) { + return object; + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + + } + + /** + * 请求 + * @param postUrl 接口请求地址 + * @param param 参数 + * @return + * @throws Exception + */ + public static JSONObject request(String postUrl, Map param) throws Exception { + + log.info("============ 嗨加油请求-START ============="); + param.put("appId", CommonSysConst.getSysConfig().getHaiOilAppid()); + param.put("reqId", new Date().getTime()); + param.put("sign", SignatureUtil.createSign(param , CommonSysConst.getSysConfig().getHaiOilAppSecret())); + + log.info("请求接口:" + postUrl); + log.info("请求参数:" + JSONObject.toJSONString(param)); + + JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getHaiOilPostUrl()+ postUrl, JSONObject.toJSONString(param)); + + log.info("响应参数:" + response.toJSONString()); + log.info("============ 嗨加油请求-END =============="); + return response; + + } + +} diff --git a/service/src/main/java/com/hfkj/model/order/orderExport/OrderGoodsExportModel.java b/service/src/main/java/com/hfkj/model/order/orderExport/OrderGoodsExportModel.java index 20ec74a..aff4506 100644 --- a/service/src/main/java/com/hfkj/model/order/orderExport/OrderGoodsExportModel.java +++ b/service/src/main/java/com/hfkj/model/order/orderExport/OrderGoodsExportModel.java @@ -113,7 +113,7 @@ public class OrderGoodsExportModel { public Date updateTime; @ColumnWidth(20) - @ExcelProperty("签收时间") + @ExcelProperty("确认收货时间") public Date finishTime; diff --git a/service/src/main/java/com/hfkj/service/SecConfigService.java b/service/src/main/java/com/hfkj/service/SecConfigService.java new file mode 100644 index 0000000..b3d0cc4 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/SecConfigService.java @@ -0,0 +1,52 @@ +package com.hfkj.service; +import com.hfkj.entity.SecConfig; + +/** + * @ClassName SecConfigService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description //TODO + * @createTime 17:29 2021/6/23 + **/ +public interface SecConfigService { + + /** + * @Author Sum1Dream + * @Name create + * @Description // 创建 + * @Date 15:11 2024/4/19 + * @Param GoodsBrand + * @return void + */ + void create(SecConfig secConfig); + + /** + * @Author Sum1Dream + * @Name update + * @Description // 修改 + * @Date 15:12 2024/4/19 + * @Param GoodsBrand + * @return void + */ + void update(SecConfig secConfig); + + /** + * @Author Sum1Dream + * @Name delete + * @Description // 修改 + * @Date 15:12 2024/4/19 + * @Param id + * @return void + */ + void delete(Integer id); + + /** + * @Author Sum1Dream + * @Name queryDetail + * @Description // 根据ID查询产品类型详情 + * @Date 15:12 2024/4/19 + * @Param id + * @return com.hfkj.entity.GoodsBrand + */ + SecConfig queryDetail(Integer id); +} diff --git a/service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java new file mode 100644 index 0000000..ecc0cb1 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java @@ -0,0 +1,34 @@ +package com.hfkj.service.impl; + +import com.hfkj.dao.SecConfigMapper; +import com.hfkj.entity.SecConfig; +import com.hfkj.service.SecConfigService; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; + +@Service("secConfigService") +public class SecConfigServiceImpl implements SecConfigService { + + @Resource + private SecConfigMapper secConfigMapper; + + @Override + public void create(SecConfig secConfig) { + secConfigMapper.insert(secConfig); + } + + @Override + public void update(SecConfig secConfig) { + secConfigMapper.updateByPrimaryKeySelective(secConfig); + } + + @Override + public void delete(Integer id) { + secConfigMapper.deleteByPrimaryKey(id); + } + + @Override + public SecConfig queryDetail(Integer id) { + return secConfigMapper.selectByPrimaryKey(id); + } +} diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index 98be49b..ad37f73 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -79,4 +79,8 @@ mtPostUrl=https://waimai-openapi.apigw.test.meituan.com/api/sqt/open/login/h5/lo yuShangAppKey=211394653 yuShangAppSecret=cyQpQKMaGUG186iEZRt1uQ== -yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/ \ No newline at end of file +yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/ + +haiOilPostUrl = https://test-oil.dctpay.com +haiOilAppid = hf7356c71fb97ab0 +haiOilAppSecret = 8aef995ff71485dc19b36e35f04c4016 From db24c7231d8c7eec9ab8ef18acffdc13fac2ec00 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 9 Sep 2024 15:52:42 +0800 Subject: [PATCH 2/7] /1 --- .../java/com/hfkj/service/order/OrderPaySuccessService.java | 5 +++-- service/src/main/java/com/hfkj/yushang/YuShangService.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index c69b2e4..a348871 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -119,11 +119,12 @@ public class OrderPaySuccessService { Map map = new HashMap<>(); map.put("productCode" , vpd.getKey()); + map.put("AppKey" , CommonSysConst.getSysConfig().getYuShangAppKey()); map.put("BuyCount" , childOrder.getProductCount()); map.put("MOrderID" , childOrder.getChildOrderNo()); map.put("ChargeAccount" , childOrder.getChildOrderNo()); - // 推送给汇联通 todo dingdan shangsong -// JSONObject returnParam = YuShangService.insertV2(couponNo.getChannelOrderNo()); + // 推送给娱尚 + YuShangService.insertV2(map); } else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { // 推送给汇联通 diff --git a/service/src/main/java/com/hfkj/yushang/YuShangService.java b/service/src/main/java/com/hfkj/yushang/YuShangService.java index fb494d7..9b8f5a5 100644 --- a/service/src/main/java/com/hfkj/yushang/YuShangService.java +++ b/service/src/main/java/com/hfkj/yushang/YuShangService.java @@ -71,7 +71,7 @@ public class YuShangService { param.put("AppKey", CommonSysConst.getSysConfig().getYuShangAppKey()); param.put("timestamp", new Date().getTime()); param.put("CustomerIP", "127.0.0.1"); - param.put("sign", MD5Util.encode(GenerateSign.paramSortYuShang(param,CommonSysConst.getSysConfig().getQianZhuSecret()).getBytes()).toLowerCase()); + param.put("sign", MD5Util.encode(GenerateSign.paramSortYuShang(param,CommonSysConst.getSysConfig().getYuShangAppSecret()).getBytes()).toLowerCase()); log.info("请求接口:" + postUrl); log.info("请求参数:" + JSONObject.toJSONString(param)); From aa43445bcc69dc96bd1f338b9b8fbdcbdac1e19c Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 11 Sep 2024 10:39:25 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hfkj/service/pay/huift/TradeService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java index 7a42ea0..6d652e4 100644 --- a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java +++ b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java @@ -5,6 +5,7 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.common.utils.RandomUtils; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrder; import com.hfkj.model.order.OrderModel; @@ -39,7 +40,7 @@ public class TradeService { public JSONObject thirdPreOrder(OrderModel order) throws Exception { Map param = new HashMap<>(); param.put("shopCode", HuiftConfig.shopcode); - param.put("outTradeNo", order.getOrderNo()); + param.put("outTradeNo", order.getOrderNo()+"_"+RandomUtils.number(3,true)); param.put("transAmt", order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()); param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/order/notify/huiftPay"); // param.put("remark", ""); // 备注 From 6a9c160ba31985a80c78d281b27b190f8ffc49c8 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 11 Sep 2024 10:47:46 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hfkj/service/pay/huift/TradeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java index 58de550..1741d24 100644 --- a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java +++ b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java @@ -46,7 +46,7 @@ public class TradeService { param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/order/notify/huiftPay"); // param.put("remark", ""); // 备注 // param.put("outAppId", ""); - param.put("outRedirectPath", CommonSysConst.getSysConfig().getDomainName()+"/cweb/#/order/order/orderList"); + param.put("outRedirectPath", CommonSysConst.getSysConfig().getDomainName()+"/outside/#/order/order/orderList"); param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, signSecret).getBytes()).toLowerCase()); JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPreOrder", JSONObject.toJSONString(param)); if (response.getString("status").equals("ok")) { From 5381dce6a843c08c1a6f525add5f65d36a9a8556 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 11 Sep 2024 11:38:40 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/TestController.java | 19 +++++++++++++++++++ .../order/controller/OrderPayController.java | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index b9f5238..639d012 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -18,6 +18,8 @@ import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.hlt.HltCanteenService; import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.service.pay.huift.TradeService; +import com.hfkj.service.pay.huift.config.HuiftConfig; import com.hfkj.sysenum.order.OrderLogisticsStatusEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -60,6 +62,23 @@ public class TestController { @Resource private GoodsUserAddressService addressService; + @Resource + private TradeService huiftTradeService; + @RequestMapping(value="/thirdPayResult",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询V家园订单交易状态") + public ResponseData thirdPayResult(@RequestParam(value = "preOrderNo" , required = true) String preOrderNo, + @RequestParam(value = "shopCode" , required = true) String shopCode, + @RequestParam(value = "signSecret" , required = true) String signSecret) { + try { + + return ResponseMsgUtil.success(huiftTradeService.thirdPayResult(preOrderNo,shopCode,signSecret)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } @RequestMapping(value="/canteenConsume",method = RequestMethod.GET) @ResponseBody diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index 17957a1..208b579 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -207,8 +207,8 @@ public class OrderPayController { // 请求支付渠道 JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order , shopCode , signSecret); for (OrderChildModel orderChild : order.getOrderChildList()) { - orderChild.setSettleAccount(HuiftConfig.shopcode); - orderChild.setSettleAccountKey(HuiftConfig.signSecret); + orderChild.setSettleAccount(shopCode); + orderChild.setSettleAccountKey(signSecret); orderChildService.editData(orderChild); } From 733cc0acdd4e37ae544b9aade1ea99181034d80c Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 11 Sep 2024 14:25:26 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/order/controller/OrderPayNotifyController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/order/src/main/java/com/order/controller/OrderPayNotifyController.java b/order/src/main/java/com/order/controller/OrderPayNotifyController.java index 13d1088..dbbb2ed 100644 --- a/order/src/main/java/com/order/controller/OrderPayNotifyController.java +++ b/order/src/main/java/com/order/controller/OrderPayNotifyController.java @@ -104,7 +104,7 @@ public class OrderPayNotifyController { log.info("开始处理订单: " + body.getString("outTradeNo")); // 查询订单信息 - OrderModel order = orderService.getDetail(body.getString("outTradeNo")); + OrderModel order = orderService.getDetail(body.getString("outTradeNo").split("_")[0]); if (order != null && order.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) { log.info("开始处理业务"); // 处理订单业务 From 05b91a28c9eb182961094c31e0d76a2f50af5ab5 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 11 Sep 2024 17:12:10 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/impl/BsOrderRefundServiceImpl.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index ed828bd..acbe6b7 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -8,10 +8,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.RandomUtils; import com.hfkj.dao.BsOrderRefundMapper; -import com.hfkj.entity.BsMerPayConfig; -import com.hfkj.entity.BsOrder; -import com.hfkj.entity.BsOrderRefund; -import com.hfkj.entity.BsOrderRefundExample; +import com.hfkj.entity.*; import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; @@ -39,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @className: BsOrderRefundServiceImpl @@ -229,8 +227,17 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { // 退款业务处理 orderRefundSuccessService.orderRefundHandle(orderChild); - orderChildService.editData(orderChild); + + // 查询子订单已全部退款 + Map map = new HashMap<>(); + map.put("orderNo", orderChild.getOrderNo()); + List orderChildList = orderChildService.getList(map); + if (orderChildList.size() == orderChildList.stream().filter(o->o.getStatus().equals(OrderChildStatusEnum.status4.getCode())).collect(Collectors.toList()).size()) { + order.setOrderStatus(OrderStatusEnum.status4.getCode()); + order.setRefundTime(new Date()); + orderService.editData(order); + } } // 删除缓存