'提交代码'

dev-discount
= 3 years ago
parent c038c77784
commit 864830e1be
  1. 1
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  2. 9
      hai-cweb/src/main/java/com/cweb/config/SysConfig.java
  3. 4
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  4. 74
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/tPigController.java
  6. 2
      hai-service/src/main/java/com/hai/common/pay/entity/OrderType.java
  7. 49
      hai-service/src/main/java/com/hai/config/QianZhuConfig.java
  8. 25
      hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java
  9. 27
      hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java

@ -113,6 +113,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/wechat/*") .excludePathPatterns("/wechat/*")
.excludePathPatterns("/tuanyou/*") .excludePathPatterns("/tuanyou/*")
.excludePathPatterns("/common/*") .excludePathPatterns("/common/*")
.excludePathPatterns("/order/qzOrderToPay")
.excludePathPatterns("/tPig/*") .excludePathPatterns("/tPig/*")
; ;
} }

@ -25,6 +25,15 @@ public class SysConfig {
private String wxUnifiedOrderUrl; private String wxUnifiedOrderUrl;
private String couponCodePath; private String couponCodePath;
private String notifyUrl; private String notifyUrl;
private String qzNotifyUrl;
public String getQzNotifyUrl() {
return qzNotifyUrl;
}
public void setQzNotifyUrl(String qzNotifyUrl) {
this.qzNotifyUrl = qzNotifyUrl;
}
public String getFileUrl() { public String getFileUrl() {
return fileUrl; return fileUrl;

@ -166,7 +166,7 @@ public class HighTestController {
@ApiOperation(value = "测试") @ApiOperation(value = "测试")
public ResponseData test1() { public ResponseData test1() {
try { try {
return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder("20210708222409597071866")); return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder("20210712232301218036376"));
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
@ -177,7 +177,7 @@ public class HighTestController {
@ApiOperation(value = "测试") @ApiOperation(value = "测试")
public ResponseData test2() { public ResponseData test2() {
try { try {
return ResponseMsgUtil.success(QianZhuConfig.getByOrderNo("20210711203753363044210")); return ResponseMsgUtil.success(QianZhuConfig.getKfcOrderByOrderNo("20210712230130341045846"));
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e); log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -16,6 +16,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.QianZhuConfig;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCoupon; import com.hai.entity.HighCoupon;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
@ -226,6 +227,79 @@ public class OrderController {
} }
} }
@RequestMapping(value="/qzOrderToPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "千猪订单支付发起支付")
public ResponseData qzOrderToPay(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
String orderNo = jsonObject.getString("orderNo");
String source = jsonObject.getString("source");
String openId = jsonObject.getString("openId");
if (StringUtils.isBlank(orderNo) || StringUtils.isBlank(source) || StringUtils.isBlank(openId)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject orderDetail = null;
if (source.equals("KFC")) {
orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo);
}
if (source.equals("CINEMA")) {
orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo);
}
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
Map<String,Object> map = new HashMap<>();
map.put("orderNo", data.getString("orderNo"));
map.put("payPrice", data.getBigDecimal("totalPrice"));
map.put("orderScene", source);
map.put("body","购买产品");
map.put("subject","购买产品");
//微信支付
String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");
// int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue();
int total_fee = 1;
WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo();
weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号
weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号
// weChatPayReqInfo.setOpenid(openId);
weChatPayReqInfo.setSub_openid(openId);
weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
weChatPayReqInfo.setTotal_fee(total_fee); //总金额
weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip
weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url
weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型
weChatPayReqInfo.setAttach(map.get("orderScene").toString());
weChatPayReqInfo.setProfit_sharing("Y");
//附加数据,区分订单类型
Map<String,String> payMap = new HashMap<>();
payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId());
payMap.put("api_key",SysConst.getSysConfig().getWxApiKey());
payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl());
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);
return ResponseMsgUtil.success(sortedMap);
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号");
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/orderToH5Pay",method = RequestMethod.POST) @RequestMapping(value="/orderToH5Pay",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "H5订单下单") @ApiOperation(value = "H5订单下单")

@ -67,7 +67,7 @@ public class tPigController {
String url = ""; String url = "";
if (token.getBoolean("success")) { if (token.getBoolean("success")) {
JSONObject data = token.getJSONObject("data"); JSONObject data = token.getJSONObject("data");
url = "https://m.qianzhu8.com/cinema/?platformId=" + CommonSysConst.getSysConfig().getQinzhuPlatformId() + "&token=" + data.getString("accessToken"); url = "https://m-test.qianzhu8.com/cinema/?platformId=" + CommonSysConst.getSysConfig().getQinzhuPlatformId() + "&token=" + data.getString("accessToken");
} }
return ResponseMsgUtil.success(url); return ResponseMsgUtil.success(url);

@ -4,6 +4,8 @@ public enum OrderType {
// 建议将支付频率高的模块放在前面 // 建议将支付频率高的模块放在前面
GOODS_ORDER("GOODS_ORDER", "goodsOrderService", "购买商品"), GOODS_ORDER("GOODS_ORDER", "goodsOrderService", "购买商品"),
RECHARGE_ORDER("RECHARGE_ORDER", "rechargeOrderService", "充值订单"), RECHARGE_ORDER("RECHARGE_ORDER", "rechargeOrderService", "充值订单"),
KFC_ORDER("KFC", "kfcOrderService", "KFC订单"),
CINEMA_ORDER("CINEMA", "cinemaOrderService", "电影票订单"),
TEST("TEST", "testPayService", "支付测试"), TEST("TEST", "testPayService", "支付测试"),
; ;

@ -42,7 +42,14 @@ public class QianZhuConfig {
} }
public static JSONObject getByOrderNo(String orderNo) throws Exception { /**
* KFC
* 根据订单号查询订单详情
* @param orderNo
* @return
* @throws Exception
*/
public static JSONObject getKfcOrderByOrderNo(String orderNo) throws Exception {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
@ -51,7 +58,13 @@ public class QianZhuConfig {
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/kfcOrders/getByOrderNo", JSONObject.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/kfcOrders/getByOrderNo", JSONObject.toJSONString(map));
} }
/**
* KFC
* 支付订单
* @param orderNo
* @return
* @throws Exception
*/
public static JSONObject payKfcOrder(String orderNo) throws Exception { public static JSONObject payKfcOrder(String orderNo) throws Exception {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
@ -62,6 +75,38 @@ public class QianZhuConfig {
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/orders/payKfcOrder", JSONObject.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/orders/payKfcOrder", JSONObject.toJSONString(map));
} }
/**
* 电影票
* 根据订单号查询订单详情
* @param orderNo
* @return
* @throws Exception
*/
public static JSONObject getCinemaOrderByOrderNo(String orderNo) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("timestamp", new Date().getTime());
map.put("orderNo", orderNo);
map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/orders/getByOrderNo", JSONObject.toJSONString(map));
}
/**
* 电影票
* 支付订单
* @param orderNo
* @return
* @throws Exception
*/
public static JSONObject payMovieOrder(String orderNo) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("timestamp", new Date().getTime());
map.put("orderNo", orderNo);
map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/orders/payMovieOrder", JSONObject.toJSONString(map));
}
/** /**
* 生成签名 * 生成签名
* @param data 数据 * @param data 数据

@ -0,0 +1,25 @@
package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.service.pay.PayService;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service("cinemaOrderService")
public class CinemaOrderService implements PayService {
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
return;
}
if (payType.equals("WechatPay")) {
JSONObject orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(map.get("out_trade_no"));
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
QianZhuConfig.payMovieOrder(data.getString("orderNo"));
}
}
}
}

@ -0,0 +1,27 @@
package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.service.pay.PayService;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service("kfcOrderService")
public class KfcOrderService implements PayService {
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
return;
}
if (payType.equals("WechatPay")) {
JSONObject orderDetail = QianZhuConfig.getKfcOrderByOrderNo(map.get("out_trade_no"));
if (orderDetail != null && orderDetail.getBoolean("success") == true) {
JSONObject data = orderDetail.getJSONObject("data");
QianZhuConfig.payKfcOrder(data.getString("orderNo"));
}
}
}
}
Loading…
Cancel
Save