提交代码

dev-discount
胡锐 3 years ago
parent 016ab5a301
commit 333f676257
  1. 1
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  2. 2
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  4. 33
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  5. 45
      hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java
  6. 6
      hai-cweb/src/test/common/test.java
  7. 50
      hai-cweb/src/test/common/test1.java
  8. 8
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  9. 2
      hai-service/src/main/java/com/hai/config/UnionPayConfig.java
  10. 34
      hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java

@ -128,6 +128,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/highBrand/*")
.excludePathPatterns("/highGoodsType/*")
.excludePathPatterns("/sendSms/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/sms/*")
.excludePathPatterns("/czOrder/*")
.excludePathPatterns("/outRechargeOrder/*")

@ -74,8 +74,6 @@ public class HighOrderController {
@Resource
private HighDiscountPackageActualService discountPackageActualService;
@Resource
private HighUserService highUserService;

File diff suppressed because one or more lines are too long

@ -102,6 +102,9 @@ public class OrderController {
@Resource
private UnionPayConfig unionPayConfig;
@Resource
private UnionStagingPayConfig unionStagingPayConfig;
/**
*
* @Title: orderToPay
@ -487,28 +490,11 @@ public class OrderController {
// 商品类型 1:卡卷 2:金币充值 3:加油站
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGiveawayType() == false && childOrder.getGoodsType() == 1) {
// 卡券详情
HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId());
// 支付类型:1.微信支付 2.金币支付
// if (coupon.getPayType() != 1) {
// log.error("OrderController --> orderToPay() ERROR", "只支持微信支持");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付");
// }
}
if (childOrder.getGoodsType() == 3) {
// 查询账号余额
JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD();
JSONArray result = accountInfo2JD.getJSONArray("result");
for (Object accountObject : result) {
JSONObject account = (JSONObject)accountObject;
// 1:汽油:2:柴油;3:天然气
if (account.getInteger("energyType").equals(childOrder.getGasOilType())) {
// 支付金额 大于 团油账号余额
if(order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) == 1){
log.error("OrderController --> orderToPay() ERROR", "无法进行支付,请联系平台客服");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服");
}
}
if (coupon == null) {
log.error("OrderController --> orderToPay() ERROR", "只支持微信支持");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付");
}
}
}
@ -518,7 +504,10 @@ public class OrderController {
+ DateUtil.format(new Date(), DateUtil.YMDHMS)
+ IDGenerator.nextId(6);
return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay(order.getOrderNo(),order.getOrderNo(),order.getPayPrice(), "","", request));
order.setPaySerialNo(orgTrace);
highOrderService.updateOrderDetail(order);
return ResponseMsgUtil.success(unionStagingPayConfig.advancePay(order.getPaySerialNo(),order.getPaySerialNo(),order.getPayPrice(), "",request));
} catch (Exception e) {
log.error("orderToPay error!", e);

@ -6,10 +6,13 @@ 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.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongConfig;
import com.hai.config.TuanYouConfig;
import com.hai.config.UnionStagingPayConfig;
import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.HighPayRecordMapper;
@ -17,6 +20,7 @@ import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*;
import com.hai.enum_type.OrderPushType;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.hai.service.pay.NotifyService;
import io.swagger.annotations.Api;
@ -413,22 +417,39 @@ public class UnionPayController {
}
}
@RequestMapping(value = "/stagingNotify", method = RequestMethod.POST)
@ApiOperation(value = "银联分期支付 -> 异步回调")
public void stagingNotify(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = "/refreshStagingOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "银联分期支付 -> 刷新分期订单")
public ResponseData refreshStagingOrder(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) {
try {
System.out.println(params);
log.info(params);
if (body == null || StringUtils.isBlank(body.getString("orderNo"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询订单信息
HighOrder order = highOrderService.getOrderByOrderNo(body.getString("orderNo"));
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款
if (order.getOrderStatus().equals(1)) {
String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4)
+CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length())
+ DateUtil.format(new Date(), DateUtil.YMDHMS)
+ IDGenerator.nextId(6);
JSONObject responseObject = UnionStagingPayConfig.queryStaging(orgTrace, order.getPaySerialNo(), "", order.getCreateTime(), request);
if (responseObject.getString("sysRetCode").equals("000000")) {
}
return ResponseMsgUtil.success(responseObject);
}
return ResponseMsgUtil.success(order);
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
JSONObject result = new JSONObject();
result.put("tradeRetCode", "000000");
out.write(result.toJSONString().getBytes());
out.flush();
out.close();
} catch (Exception e) {
log.error("UnionPayController --> stagingNotify() error!", e);
log.error("UnionPayController --> refreshStagingOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}

@ -59,8 +59,12 @@ public class test {
}
public static void main(String[] args) {
public static void main(String[] args) {
// 获取当前正在执行线程的引用,当前正在执行的线程是主线程,也就是获取主线程的引用
Thread t1 = Thread.currentThread();
System.out.println("主线程的编号是:" + t1.getId() + ", 名称是:" + t1.getName());
requestOrder();
}

@ -0,0 +1,50 @@
package common;
import com.CWebApplication;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpsUtils;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountUserRelService;
import com.hai.service.HighUserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName RegionTest
* @Description: TODO ()
* @Author 胡锐
* @Date 2020/12/29
**/
public class test1 implements Runnable {
/*
public static void main(String[] args) {
// 获取当前正在执行线程的引用,当前正在执行的线程是主线程,也就是获取主线程的引用
Runnable target;
System.out.println("主线程的编号是:" + thread.getId() + ", 名称是:" + thread.getName());
thread.setName("order1");
for (int i = 0; i <= 100; i++) {
Thread thread = new Thread();
}
}
*/
@Override
public void run() {
Thread t1 = Thread.currentThread();
System.out.println("子线程的编号是:" + t1.getId() + ", 名称是:" + t1.getName()); // 14 guanyu
t1.setName("zhangfei");
System.out.println("修改后子线程的编号是:" + t1.getId() + ", 名称是:" + t1.getName());
}
}

@ -269,4 +269,12 @@ public class HighOrderSchedule {
}
}
@Scheduled(cron="1 * * * * * ?") //每1分钟执行一次
public void unionStagingPayOrder() {
List<Map<String, Object>> mapList = highOrderService.getFinishGasOrder();
if (mapList != null && mapList.size() > 0) {
}
}
}

@ -76,6 +76,7 @@ public class UnionPayConfig {
// 记录请求参数
HighPayRecord payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setPaySerialNo(orderNo);
payRecord.setResType(1);
payRecord.setPayType(3);
payRecord.setPayMoney(payPrice);
@ -87,6 +88,7 @@ public class UnionPayConfig {
// 记录响应参数
payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setPaySerialNo(orderNo);
payRecord.setResType(3);
payRecord.setPayType(3);
payRecord.setPayMoney(payPrice);

@ -3,12 +3,16 @@ package com.hai.config;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.RequestUtils;
import com.hai.dao.HighPayRecordMapper;
import com.hai.entity.HighPayRecord;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.commons.codec.binary.Base64;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.HttpsUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.math.BigDecimal;
@ -23,19 +27,23 @@ import java.util.*;
* 银联分期
* @author hurui
*/
@Component
public class UnionStagingPayConfig {
@Resource
private HighPayRecordMapper highPayRecordMapper;
/**
* 银联分期支付H5预下单-标准
* 文档地址 https://doc.eycard.cn/web/#/222?page_id=3183
* @param prodTrace 产品流水 可重复记录订单生命周期无特殊需求同交易流水号
* @param orgTrace 订单号
* @param openId 支付宝微信云闪付用户授权唯一标识(如果没有:-)
* @param payPrice 支付金额 单位
* @return 响应信息
* @throws Exception
*/
public static JSONObject advancePay(String prodTrace, String orgTrace, BigDecimal payPrice, String openId, String notifyUrl, HttpServletRequest request) throws Exception {
public JSONObject advancePay(String prodTrace, String orgTrace, BigDecimal payPrice, String notifyUrl, HttpServletRequest request) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId());
paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode());
@ -51,12 +59,32 @@ public class UnionStagingPayConfig {
Map<String, Object> bizDataMap = new HashMap<>();
bizDataMap.put("transAmt", payPrice.multiply(new BigDecimal("100")).intValue());
bizDataMap.put("openId", openId);
bizDataMap.put("openId", "-");
bizDataMap.put("notifyUrl", notifyUrl);
paramMap.put("bizData", bizDataMap);
paramMap.put("sign", generateSign(bizDataMap));
// 记录请求参数
HighPayRecord payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setPaySerialNo(prodTrace);
payRecord.setResType(1);
payRecord.setPayType(4);
payRecord.setPayMoney(payPrice);
payRecord.setBodyInfo(JSONObject.toJSONString(paramMap));
highPayRecordMapper.insert(payRecord);
JSONObject responseParam = HttpsUtils.doPost(CommonSysConst.getSysConfig().getUnionStagingPayUrl()+"cashier/apply/advancePay", paramMap, new HashMap<>());
// 记录响应参数
payRecord = new HighPayRecord();
payRecord.setCreateTime(new Date());
payRecord.setPaySerialNo(prodTrace);
payRecord.setResType(3);
payRecord.setPayType(4);
payRecord.setPayMoney(payPrice);
payRecord.setBodyInfo(responseParam.toString());
highPayRecordMapper.insert(payRecord);
return responseParam;
}

Loading…
Cancel
Save