Merge remote-tracking branch 'origin/2.0-dev' into 2.0-dev

master
袁野 8 months ago
commit 4176f7d6da
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  3. 15
      hai-order/src/main/java/com/web/controller/OrderController.java
  4. 40
      hai-order/src/main/java/com/web/controller/OrderPayController.java
  5. 39
      hai-order/src/main/java/com/web/controller/OrderPayNotifyController.java
  6. 2
      hai-order/src/main/java/com/web/controller/TestController.java
  7. 2
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  8. 96
      hai-service/src/main/java/com/hai/pay/channel/huift/TradeService.java
  9. 58
      hai-service/src/main/java/com/hai/pay/channel/huift/config/HuiftConfig.java

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -416,6 +416,21 @@ public class OrderController {
} }
} }
@RequestMapping(value = "/getOrderDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询订单详情")
public ResponseData getOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) {
try {
return ResponseMsgUtil.success(orderService.getOrderDetailByNo(orderNo));
} catch (Exception e) {
log.error("HighOrderController --> getOrderDetail() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getPopularizeUserOrderList",method = RequestMethod.GET) @RequestMapping(value="/getPopularizeUserOrderList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取推广用户订单列表") @ApiOperation(value = "获取推广用户订单列表")

@ -29,6 +29,7 @@ import com.hai.order.type.OrderProductType;
import com.hai.order.type.OrderStatus; import com.hai.order.type.OrderStatus;
import com.hai.order.type.PlatformType; import com.hai.order.type.PlatformType;
import com.hai.order.utils.OrderUtil; import com.hai.order.utils.OrderUtil;
import com.hai.pay.channel.huift.TradeService;
import com.hai.pay.channel.huipay.config.HuiConfig; import com.hai.pay.channel.huipay.config.HuiConfig;
import com.hai.service.*; import com.hai.service.*;
import com.web.config.SysConst; import com.web.config.SysConst;
@ -103,6 +104,8 @@ public class OrderPayController {
@Resource @Resource
private OrderPayBeforeService orderPayBeforeService; private OrderPayBeforeService orderPayBeforeService;
private TradeService huiftTradeService;
@Resource @Resource
private SecConfigService secConfigService; private SecConfigService secConfigService;
@ -728,6 +731,43 @@ public class OrderPayController {
} }
} }
@RequestMapping(value = "/huiftPay", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "贵行V家园小程序支付")
public ResponseData huiftPay(@RequestBody JSONObject body, HttpServletRequest request) {
try {
if (body == null || StringUtils.isBlank(body.getString("orderNo"))) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo"));
if (order == null) {
log.error("OrderController --> huiftPay() ERROR", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
if (!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
log.error("OrderController --> huiftPay() ERROR", "订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
}
// 支付前业务校验
orderPayBeforeService.payOrderCheck(order);
JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order);
order.setPayChannel(3);
order.setPayChannelOrderNo(thirdPreOrder.getString("preOrderNo"));
order.setProfitSharingStatus(false);
orderService.updateOrderData(order);
return ResponseMsgUtil.success(thirdPreOrder);
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "wechatCombinePay" , method = RequestMethod.POST) @RequestMapping(value = "wechatCombinePay" , method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "微信合单支付") @ApiOperation(value = "微信合单支付")

@ -132,4 +132,43 @@ public class OrderPayNotifyController {
} }
} }
@RequestMapping(value = "/huiftPay", method = RequestMethod.POST)
@ApiOperation(value = "贵行V家园小程序支付 -> 异步回调")
public void huiftPay(@RequestBody String params, HttpServletRequest request, HttpServletResponse response) {
try {
log.info("===============贵行V家园小程序支付回调start==================");
log.info("回调参数: " + params);
if (StringUtils.isNotBlank(params)) {
// 参数解码
String paramsStr = URLDecoder.decode(params,"utf-8");
JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1));
log.info("开始处理订单: " + body.getString("outTradeNo"));
// 查询订单信息
HighOrder order = orderService.getOrderDetailByNo(body.getString("outTradeNo"));
if (order != null && order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
log.info("开始处理业务");
// 处理订单业务
paySuccessService.orderPaySuccessHandle(order.getOrderNo(),
OrderPayType.PAY_TYPE2,
body.getString("orderNo"),
order.getPayPrice(),
null,null);
}
log.info("处理业务完成");
}
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
JSONObject result = new JSONObject();
result.put("messagecode", "0");
result.put("message", "回调成功");
out.write(result.toJSONString().getBytes());
out.flush();
out.close();
} catch (Exception e) {
log.error("订单处理异常", e);
} finally {
log.info("===============贵行V家园小程序支付回调end==================");
}
}
} }

File diff suppressed because one or more lines are too long

@ -356,7 +356,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
if (gasOrder != null) { if (gasOrder != null) {
gasOrder.setMemCardType(order.getMemCardType()); gasOrder.setMemCardType(order.getMemCardType());
gasOrder.setMemCardNo(order.getMemCardNo()); gasOrder.setMemCardNo(order.getMemCardNo());
gasOrder.setPayTime(new Date()); gasOrder.setPayTime(order.getPayTime());
gasOrder.setStatus(OrderOilStatus.STATUS2.getNumber()); gasOrder.setStatus(OrderOilStatus.STATUS2.getNumber());
gasOrder.setPayType(order.getPayType()); gasOrder.setPayType(order.getPayType());
gasOrder.setPayPrice(order.getPayPrice()); gasOrder.setPayPrice(order.getPayPrice());

@ -0,0 +1,96 @@
package com.hai.pay.channel.huift;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils;
import com.hai.config.CommonSysConst;
import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund;
import com.hai.pay.channel.huift.config.HuiftConfig;
import com.hai.service.HighOrderService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* @className: TradeService
* @author: HuRui
* @date: 2024/4/7
**/
@Component
public class TradeService {
@Resource
private HighOrderService orderService;
/**
* 交易-预下单
* @param order
* @return
* @throws Exception
*/
public JSONObject thirdPreOrder(HighOrder order) throws Exception {
Map<String,Object> param = new HashMap<>();
param.put("shopCode", HuiftConfig.shopcode);
param.put("outTradeNo", order.getOrderNo());
param.put("transAmt", order.getPayablePrice().multiply(new BigDecimal("100")).intValue());
param.put("mobileNbr", order.getMemPhone()); // 用户标识
param.put("callbackUrl", CommonSysConst.getSysConfig().getHsgDomainName() + "/order/payNotify/huiftPay");
// param.put("remark", ""); // 备注
// param.put("outAppId", "");
// param.put("outRedirectPath", "");
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase());
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPreOrder", JSONObject.toJSONString(param));
if (response.getString("status").equals("ok")) {
return response.getJSONObject("data");
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , response.getString("message"));
}
/**
* 查询交易结果
* @param preOrderNo
* @return
* @throws Exception
*/
public JSONObject thirdPayResult(String preOrderNo) throws Exception {
Map<String,Object> param = new HashMap<>();
param.put("shopCode", HuiftConfig.shopcode);
param.put("preOrderNo", preOrderNo);
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase());
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayResult", JSONObject.toJSONString(param));
if (response.getString("status").equals("ok")) {
return response.getJSONObject("data");
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , response.getString("message"));
}
/**
* 交易退款
* @param orderRefund
* @return
* @throws Exception
*/
public JSONObject thirdPayRefund(HighOrderRefund orderRefund) throws Exception {
// 查询订单
HighOrder order = orderService.getOrderById(orderRefund.getId());
Map<String,Object> param = new HashMap<>();
param.put("shopCode", HuiftConfig.shopcode);
param.put("preOrderNo", order.getPayChannelOrderNo());
param.put("outRefundNo", orderRefund.getRefundOrderNo());
param.put("refundAmt", orderRefund.getRefundPrice().multiply(new BigDecimal("100")).intValue());
param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase());
JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayRefund", JSONObject.toJSONString(param));
if (response.getString("status").equals("ok")) {
return response.getJSONObject("data");
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , response.getString("message"));
}
}

@ -0,0 +1,58 @@
package com.hai.pay.channel.huift.config;
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;
/**
* @className: HuiftConfig
* @author: HuRui
* @date: 2024/4/7
**/
public class HuiftConfig {
public final static String reqUrl = "https://linktest.huift.com.cn";
public final static String shopcode = "50041b27-f985-dcb0-1cc0-f106b09bf1fe";
public final static String signSecret = "DB4D8069A9AC6DDF9D75667EE5CF182A";
/**
* 参数排序
* @param param
* @return
*/
public static String paramSort(final Map<String, Object> param, String key) {
Set<String> 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);
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));
}
}
Loading…
Cancel
Save