dev-discount
胡锐 3 years ago
parent 0c9504a75b
commit 8095947d14
  1. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 47
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  3. 6
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  4. 65
      hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java
  5. 9
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  6. 59
      hai-service/src/main/java/com/hai/config/UnionPayConfig.java
  7. 1
      hai-service/src/main/resources/dev/commonConfig.properties
  8. 1
      hai-service/src/main/resources/pre/commonConfig.properties
  9. 11
      hai-service/src/main/resources/prod-9401/commonConfig.properties
  10. 1
      hai-service/src/main/resources/prod/commonConfig.properties

File diff suppressed because one or more lines are too long

@ -18,6 +18,8 @@ import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.*; import com.hai.common.utils.*;
import com.hai.config.CommonSysConst;
import com.hai.config.UnionPayConfig;
import com.hai.dao.SecDictionaryMapper; import com.hai.dao.SecDictionaryMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.GoodsType; import com.hai.enum_type.GoodsType;
@ -89,6 +91,9 @@ public class OutRechargeOrderController {
@Resource @Resource
private HighUserCardService highUserCardService; private HighUserCardService highUserCardService;
@Resource
private UnionPayConfig unionPayConfig;
@RequestMapping(value="/addOrder",method = RequestMethod.POST) @RequestMapping(value="/addOrder",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -412,6 +417,48 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起银联支付")
public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
if (orderId == null) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (order == null) {
log.error("hltUnionCardPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
if (order.getStatus() != 1) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
return ResponseMsgUtil.success(unionPayConfig.upPreOrder(order.getOrderNo(), order.getPayPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl()));
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "订单退款") @ApiOperation(value = "订单退款")

@ -19,6 +19,7 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MathUtils; import com.hai.common.utils.MathUtils;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.QianZhuConfig; import com.hai.config.QianZhuConfig;
import com.hai.config.TuanYouConfig; import com.hai.config.TuanYouConfig;
import com.hai.config.UnionPayConfig; import com.hai.config.UnionPayConfig;
@ -103,6 +104,9 @@ public class OrderController {
@Resource @Resource
private HighUserService highUserService; private HighUserService highUserService;
@Resource
private UnionPayConfig unionPayConfig;
/** /**
* *
* @Title: orderToPay * @Title: orderToPay
@ -445,7 +449,7 @@ public class OrderController {
} }
} }
return ResponseMsgUtil.success(UnionPayConfig.upPreOrder(order.getOrderNo(), order.getPayPrice(), "购买商品")); return ResponseMsgUtil.success(unionPayConfig.upPreOrder(order.getOrderNo(), order.getPayPrice(), "购买商品", CommonSysConst.getSysConfig().getUnionPayNotifyUrl()));
} catch (Exception e) { } catch (Exception e) {
log.error("orderToPay error!", e); log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -11,6 +11,7 @@ import com.hai.config.HuiLianTongConfig;
import com.hai.config.TuanYouConfig; import com.hai.config.TuanYouConfig;
import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.HighPayRecordMapper;
import com.hai.dao.HighUserCouponMapper; import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.OrderPushType; import com.hai.enum_type.OrderPushType;
@ -80,6 +81,12 @@ public class UnionPayController {
@Resource @Resource
private HuiLianTongConfig huiLianTongConfig; private HuiLianTongConfig huiLianTongConfig;
@Resource
private HighPayRecordMapper highPayRecordMapper;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@RequestMapping(value = "/notify", method = RequestMethod.POST) @RequestMapping(value = "/notify", method = RequestMethod.POST)
@ApiOperation(value = "银联支付 -> 异步回调") @ApiOperation(value = "银联支付 -> 异步回调")
public void notify(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) { public void notify(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) {
@ -91,6 +98,15 @@ public class UnionPayController {
if (StringUtils.isNotBlank(params)) { if (StringUtils.isNotBlank(params)) {
// 参数解码 // 参数解码
String paramsStr = URLDecoder.decode(params,"utf-8"); String paramsStr = URLDecoder.decode(params,"utf-8");
// 记录请求参数
HighPayRecord payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setResType(2);
payRecord.setPayType(3);
payRecord.setBodyInfo(paramsStr);
highPayRecordMapper.insert(payRecord);
// 转换成JSON格式 // 转换成JSON格式
JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1)); JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1));
if (StringUtils.isNotBlank(body.getString("tradetrace"))) { if (StringUtils.isNotBlank(body.getString("tradetrace"))) {
@ -271,4 +287,53 @@ public class UnionPayController {
} }
} }
@RequestMapping(value = "/notifyTel", method = RequestMethod.POST)
@ApiOperation(value = "银联支付 -> 异步回调")
public void notifyTel(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) {
try {
System.out.println(params);
log.info(params);
if (StringUtils.isNotBlank(params)) {
// 参数解码
String paramsStr = URLDecoder.decode(params,"utf-8");
// 记录请求参数
HighPayRecord payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setResType(2);
payRecord.setPayType(3);
payRecord.setBodyInfo(paramsStr);
highPayRecordMapper.insert(payRecord);
// 转换成JSON格式
JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1));
if (StringUtils.isNotBlank(body.getString("tradetrace"))) {
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace"));
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号
order.setPayRealPrice(order.getPayPrice()); // 实付金额
order.setStatus(2);
order.setPayType(4);
order.setPayTime(new Date()); // 支付时间
outRechargeOrderService.updateOrder(order);
}
}
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
JSONObject result = new JSONObject();
result.put("resultcode", "00");
out.write(result.toJSONString().getBytes());
out.flush();
out.close();
} catch (Exception e) {
log.error("UnionPayController --> notify() error!", e);
}
}
} }

@ -37,6 +37,7 @@ public class CommonSysConfig {
private String unionPayTermid; private String unionPayTermid;
private String unionPaySignKey; private String unionPaySignKey;
private String unionPayNotifyUrl; private String unionPayNotifyUrl;
private String unionPayTelNotifyUrl;
private String wx_cert; private String wx_cert;
@ -46,6 +47,14 @@ public class CommonSysConfig {
private String telUrl; private String telUrl;
private String czOrderNotify; private String czOrderNotify;
public String getUnionPayTelNotifyUrl() {
return unionPayTelNotifyUrl;
}
public void setUnionPayTelNotifyUrl(String unionPayTelNotifyUrl) {
this.unionPayTelNotifyUrl = unionPayTelNotifyUrl;
}
public String getUnionPayNotifyUrl() { public String getUnionPayNotifyUrl() {
return unionPayNotifyUrl; return unionPayNotifyUrl;
} }

@ -5,8 +5,12 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util; import com.hai.common.utils.MD5Util;
import com.hai.dao.HighPayRecordMapper;
import com.hai.entity.HighPayRecord;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@ -14,8 +18,12 @@ import java.util.*;
* 银联支付 * 银联支付
* @author hurui * @author hurui
*/ */
@Component
public class UnionPayConfig { public class UnionPayConfig {
@Resource
private HighPayRecordMapper highPayRecordMapper;
/** /**
* 注意请勿随意调用会更新签名秘钥会导致接口签名错误 * 注意请勿随意调用会更新签名秘钥会导致接口签名错误
* 更新并获取签名密钥 * 更新并获取签名密钥
@ -39,7 +47,7 @@ public class UnionPayConfig {
* @return 响应信息 * @return 响应信息
* @throws Exception * @throws Exception
*/ */
public static JSONObject upPreOrder(String orderNo, BigDecimal payPrice, String orderDesc) throws Exception { public JSONObject upPreOrder(String orderNo, BigDecimal payPrice, String orderDesc,String notifyurl) throws Exception {
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid()); paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid());
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid());
@ -49,8 +57,31 @@ public class UnionPayConfig {
paramMap.put("tradetype", "APP"); paramMap.put("tradetype", "APP");
paramMap.put("tradeamt", payPrice.multiply(new BigDecimal("100")).intValue()); paramMap.put("tradeamt", payPrice.multiply(new BigDecimal("100")).intValue());
paramMap.put("body", orderDesc); paramMap.put("body", orderDesc);
paramMap.put("notifyurl", CommonSysConst.getSysConfig().getUnionPayNotifyUrl()); paramMap.put("notifyurl", notifyurl);
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>());
String requestParam = generateRequestParam(paramMap);
// 记录请求参数
HighPayRecord payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setResType(1);
payRecord.setPayType(3);
payRecord.setPayMoney(payPrice);
payRecord.setBodyInfo(requestParam);
highPayRecordMapper.insert(payRecord);
JSONObject responseParam = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), requestParam, new HashMap<>());
// 记录响应参数
payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setResType(3);
payRecord.setPayType(3);
payRecord.setPayMoney(payPrice);
payRecord.setBodyInfo(responseParam.toString());
highPayRecordMapper.insert(payRecord);
return responseParam;
} }
/** /**
@ -66,10 +97,10 @@ public class UnionPayConfig {
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid());
paramMap.put("tradetrace", paySerialNo); paramMap.put("tradetrace", paySerialNo);
paramMap.put("opt", "tradeQuery"); paramMap.put("opt", "tradeQuery");
paramMap.put("tradetype", "samecardQuery");
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>());
} }
/** /**
* 交易退货 * 交易退货
* @param orderNo 订单号 * @param orderNo 订单号
@ -84,12 +115,30 @@ public class UnionPayConfig {
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid()); paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid());
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid()); paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid());
paramMap.put("tradetrace", orderNo); paramMap.put("tradetrace", orderNo);
paramMap.put("oritradetrace", paySerialNo); paramMap.put("oriwtorderid", paySerialNo);
paramMap.put("tradeamt", refundPrice); paramMap.put("tradeamt", refundPrice);
paramMap.put("opt", "zwrefund"); paramMap.put("opt", "zwrefund");
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>()); return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>());
} }
/**
* 交易撤销
* @param orderNo 订单号
* @param paySerialNo 第三方订单号
* @return
* @throws Exception
*/
public static JSONObject cancel(String orderNo,String paySerialNo) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("channelid", CommonSysConst.getSysConfig().getUnionPayChannelid());
paramMap.put("merid", CommonSysConst.getSysConfig().getUnionPayMerid());
paramMap.put("termid", CommonSysConst.getSysConfig().getUnionPayTermid());
paramMap.put("tradetrace", orderNo);
paramMap.put("oriwtorderid", paySerialNo);
paramMap.put("opt", "cancel");
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getUnionPayUrl(), generateRequestParam(paramMap), new HashMap<>());
}
/** /**
* 参数排序 * 参数排序
* @param param * @param param

@ -30,6 +30,7 @@ unionPayMerid=531000009488145
unionPayTermid=39339061 unionPayTermid=39339061
unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0
unionPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/notify unionPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/notify
unionPayTelNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/notifyTel
# ?????? # ??????
wx_cert=/home/project/wx_cert/ wx_cert=/home/project/wx_cert/

@ -25,6 +25,7 @@ unionPayMerid=531000012972390
unionPayTermid=W1489519 unionPayTermid=W1489519
unionPaySignKey=sa72ivadl84273dlj2kdaia2idiadik5 unionPaySignKey=sa72ivadl84273dlj2kdaia2idiadik5
unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify
unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel
wx_cert=/home/project/wx_cert/ wx_cert=/home/project/wx_cert/

@ -19,12 +19,13 @@ HuiLianTongUnionCardUrl=http://hltgz.com:4010/api/v2/execute.json
HuiLianTongUnionCardAccessCode=6FCAE1470CEF465988351BB65ABAA8AE HuiLianTongUnionCardAccessCode=6FCAE1470CEF465988351BB65ABAA8AE
HuiLianTongUnionCardSignCode=F8E91A3C HuiLianTongUnionCardSignCode=F8E91A3C
unionPayUrl=https://notify-test.eycard.cn:7443/WorthTech_Access_AppPaySystemV2/apppayacc unionPayUrl=https://open.eycard.cn:8443/WorthTech_Access_AppPaySystemV2/apppayacc
unionPayChannelid=D01X66666666761 unionPayChannelid=D01X00000801226
unionPayMerid=531000012972390 unionPayMerid=531000009488145
unionPayTermid=W1489519 unionPayTermid=39339061
unionPaySignKey=sa72ivadl84273dlj2kdaia2idiadik5 unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0
unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify
unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel
wx_cert=/home/project/wx_cert/ wx_cert=/home/project/wx_cert/

@ -25,6 +25,7 @@ unionPayMerid=531000009488145
unionPayTermid=39339061 unionPayTermid=39339061
unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0
unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify
unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel
wx_cert=/home/project/wx_cert/ wx_cert=/home/project/wx_cert/

Loading…
Cancel
Save