From 831e5c9c63f6727614cdb3b8aace6881146fe5c3 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Wed, 15 Jun 2022 16:07:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=9D=E8=B4=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighOpenApiController.java | 16 +++ .../bweb/controller/HighTestController.java | 2 +- .../controller/pay/CzOrderController.java | 17 +-- .../java/com/hai/config/RechargeConfig.java | 2 +- .../com/hai/dao/ApiAmountRecordMapperExt.java | 35 +++++- .../hai/service/ApiAmountRecordService.java | 13 ++ .../java/com/hai/service/ApiOpenService.java | 2 +- .../impl/ApiAmountRecordServiceImpl.java | 22 ++++ .../hai/service/impl/ApiOpenServiceImpl.java | 113 ++---------------- .../impl/OutRechargeOrderServiceImpl.java | 61 ++++++++++ .../v1/controller/GzSinopecController.java | 64 ++++++---- .../controller/RechargeProductController.java | 12 +- 12 files changed, 212 insertions(+), 147 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java index 3f9c50c1..14541ca2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java @@ -10,9 +10,12 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongConfig; +import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.HighCoupon; +import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighMerchant; import com.hai.entity.HighUser; +import com.hai.enum_type.OrderPushType; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.HighOpenApiService; @@ -58,6 +61,9 @@ public class HighOpenApiController { @Resource private HuiLianTongConfig huiLianTongConfig; + @Resource + private HighGasOrderPushMapper highGasOrderPushMapper; + @RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取专属优惠券") @@ -186,6 +192,16 @@ public class HighOpenApiController { // 商户派发电子券 JSONObject returnParam = HuiLianTongConfig.couJointDist(token, object.getString("orderNo"), object.getString("couTypeCode"), object.getInteger("distCouCount"), object.getString("phone"), object.getString("thirdUserId")); + System.out.println("派发电子券" + returnParam); + // 推送记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(object.getString("orderNo")); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setCode(returnParam.getString("result")); + highGasOrderPush.setRequestContent(JSONObject.toJSONString(object)); + highGasOrderPush.setReturnContent(returnParam.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); if (returnParam == null || !returnParam.getString("result").equals("success")) { log.error("HighOpenApiController -> couJointDist() error!","商户派发电子券失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败"); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index e07df1c7..27e2c958 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ -package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.google.gson.JsonObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.security.KeyStore; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private SecSinopecConfigService secSinopecConfigService; @Resource private HighCouponCodeService highCouponCodeService; @Resource private HighOilCardService oilCardService; @Resource private GoodsOrderServiceImpl goodsOrderService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private HighGasOilPriceOfficialService gasOilPriceOfficialService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refreshGasPriceOfficial", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "刷新国标价") public ResponseData refreshGasPriceOfficial() { try { gasOilPriceOfficialService.refreshPriceOfficial(); gasOilPriceOfficialService.refreshGasPriceOfficial(null, null); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分账") public ResponseData wxProfitsharing(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); BigDecimal rake = new BigDecimal("0.01"); // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部 param.put("transaction_id" , order.getPaySerialNo()); param.put("out_order_no" , order.getOrderNo()); param.put("nonce_str" , WxUtils.makeNonStr()); // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.profitsharing(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(porofitSharingAmount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); return ResponseMsgUtil.success(e); } } public String profitsharing(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sys", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "同步") public ResponseData sys(@RequestParam(name = "appId", required = true) String appId, @RequestParam(name = "appSecret", required = true) String appSecret, @RequestParam(name = "code", required = true) String code, @RequestParam(name = "signKey", required = true) String signKey ) { try { Map tokenMap = new HashMap<>(); tokenMap.put("appId", appId); tokenMap.put("appSecret", appSecret); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); log.error(jsonObject.toJSONString()); if (jsonObject != null && jsonObject.getBoolean("success") == true) { JSONObject data = jsonObject.getJSONObject("data"); String token = data.getString("token"); Calendar instance = Calendar.getInstance(); instance.set(2021,3,1); Map bodyMap = new HashMap<>(); bodyMap.put("appId", appId); bodyMap.put("pageNo", 1); bodyMap.put("pageSize", 999999); bodyMap.put("startTime", instance.getTime()); bodyMap.put("endTime", new Date().getTime()); bodyMap.put("customerCode", code); Long date = new Date().getTime(); String sha256 = encodeBySHA256(signKey + JSON.toJSONString(bodyMap) + date); JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); File file = new File("/home/data/" + System.currentTimeMillis() + ".txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(object.toJSONString()); bw.close(); //JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}"); if(Objects.equals(object.get("success"), true)) { log.error(JSONObject.toJSONString(object.get("data"))); Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data"))); JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson)); JSONArray list = dataObject.getJSONArray("list"); for (Object dataJsonObject : list) { try { JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject)); String codeId = parseObject.getString("codeId"); String nodeName = parseObject.getString("nodeName"); Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss"); highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime, nodeName); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } } return ResponseMsgUtil.success("下载成功"); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String encodeBySHA256(String str) { try{ MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.reset(); messageDigest.update(str.getBytes("UTF-8")); return getFormattedText(messageDigest.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (Exception e) { throw new RuntimeException(e); } return ""; } private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; private String getFormattedText(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); // 把密文转换成十六进制的字符串形式 for (int j=0;j> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); } return buf.toString(); } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket( @RequestParam(name = "userId", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://139.159.177.244:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("请求成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { Map map = new HashMap<>(); map.put("orderNo" , "HF2021041214054870201"); map.put("distCouCount" , "1"); map.put("phone" , "18090580471"); map.put("distributorId" , "test"); map.put("couNo" , "46444645444C47454544414C464C4D464D414C"); map.put("status" , "20"); map.put("couTypeCode" , "20JY000288"); map.put("validStartDate" , "2022-06-09 16:15:55"); map.put("validEndDate" , "2022-07-09 16:15:55"); JSONObject jsonObject = HuiLianTongUnionCardConfig.syncPayOrder(map); return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/requestCallback", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求回调") public ResponseData requestCallback(HttpServletRequest request) { try { String object = HttpsUtils.doApiPost("https://hsgcs.dctpay.com/crest/czOrder/test", "{\"amount\":200,\"app_key\":\"p429mlj3cvn5hb07\",\"official_sn\":\"\",\"out_order_id\":\"CZ2022060110331795401\",\"mobile\":\"19385406161\",\"sign\":\"88a7427f5af21a5f807b77f2c252ec92\",\"order_id\":\"22012518161389363\",\"status\":4,\"timestamp\":1643109421}"); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求Api") public ResponseData postApi(HttpServletRequest request) { try { Map map = new HashMap<>(); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("merchId" , "20220670800"); String sign = WxUtils.generateSignApi(map , MapUtils.getString(map , "apiKey"), WXPayConstants.SignType.MD5); map.put("sign" , sign); JSONObject object = HttpsUtils.doPost("http://localhost:9902/v1/rechargeProduct/checkAccountBalance" , map , new HashMap<>()); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.google.gson.JsonObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.security.KeyStore; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private SecSinopecConfigService secSinopecConfigService; @Resource private HighCouponCodeService highCouponCodeService; @Resource private HighOilCardService oilCardService; @Resource private GoodsOrderServiceImpl goodsOrderService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private HighGasOilPriceOfficialService gasOilPriceOfficialService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refreshGasPriceOfficial", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "刷新国标价") public ResponseData refreshGasPriceOfficial() { try { gasOilPriceOfficialService.refreshPriceOfficial(); gasOilPriceOfficialService.refreshGasPriceOfficial(null, null); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分账") public ResponseData wxProfitsharing(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); BigDecimal rake = new BigDecimal("0.01"); // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部 param.put("transaction_id" , order.getPaySerialNo()); param.put("out_order_no" , order.getOrderNo()); param.put("nonce_str" , WxUtils.makeNonStr()); // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.profitsharing(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(porofitSharingAmount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); return ResponseMsgUtil.success(e); } } public String profitsharing(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sys", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "同步") public ResponseData sys(@RequestParam(name = "appId", required = true) String appId, @RequestParam(name = "appSecret", required = true) String appSecret, @RequestParam(name = "code", required = true) String code, @RequestParam(name = "signKey", required = true) String signKey ) { try { Map tokenMap = new HashMap<>(); tokenMap.put("appId", appId); tokenMap.put("appSecret", appSecret); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); log.error(jsonObject.toJSONString()); if (jsonObject != null && jsonObject.getBoolean("success") == true) { JSONObject data = jsonObject.getJSONObject("data"); String token = data.getString("token"); Calendar instance = Calendar.getInstance(); instance.set(2021,3,1); Map bodyMap = new HashMap<>(); bodyMap.put("appId", appId); bodyMap.put("pageNo", 1); bodyMap.put("pageSize", 999999); bodyMap.put("startTime", instance.getTime()); bodyMap.put("endTime", new Date().getTime()); bodyMap.put("customerCode", code); Long date = new Date().getTime(); String sha256 = encodeBySHA256(signKey + JSON.toJSONString(bodyMap) + date); JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); File file = new File("/home/data/" + System.currentTimeMillis() + ".txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(object.toJSONString()); bw.close(); //JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}"); if(Objects.equals(object.get("success"), true)) { log.error(JSONObject.toJSONString(object.get("data"))); Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data"))); JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson)); JSONArray list = dataObject.getJSONArray("list"); for (Object dataJsonObject : list) { try { JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject)); String codeId = parseObject.getString("codeId"); String nodeName = parseObject.getString("nodeName"); Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss"); highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime, nodeName); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } } return ResponseMsgUtil.success("下载成功"); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String encodeBySHA256(String str) { try{ MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.reset(); messageDigest.update(str.getBytes("UTF-8")); return getFormattedText(messageDigest.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (Exception e) { throw new RuntimeException(e); } return ""; } private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; private String getFormattedText(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); // 把密文转换成十六进制的字符串形式 for (int j=0;j> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); } return buf.toString(); } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket( @RequestParam(name = "userId", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://139.159.177.244:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("请求成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { Map map = new HashMap<>(); map.put("orderNo" , "HF2021041214054870201"); map.put("distCouCount" , "1"); map.put("phone" , "18090580471"); map.put("distributorId" , "test"); map.put("couNo" , "46444645444C47454544414C464C4D464D414C"); map.put("status" , "20"); map.put("couTypeCode" , "20JY000288"); map.put("validStartDate" , "2022-06-09 16:15:55"); map.put("validEndDate" , "2022-07-09 16:15:55"); JSONObject jsonObject = HuiLianTongUnionCardConfig.syncPayOrder(map); return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/requestCallback", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求回调") public ResponseData requestCallback(HttpServletRequest request) { try { // List<> String object = HttpsUtils.doApiPost("https://hsgcs.dctpay.com/crest/czOrder/test", "{\"amount\":200,\"app_key\":\"p429mlj3cvn5hb07\",\"official_sn\":\"\",\"out_order_id\":\"CZ2022060110331795401\",\"mobile\":\"19385406161\",\"sign\":\"88a7427f5af21a5f807b77f2c252ec92\",\"order_id\":\"22012518161389363\",\"status\":4,\"timestamp\":1643109421}"); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求Api") public ResponseData postApi(HttpServletRequest request) { try { Map map = new HashMap<>(); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("merchId" , "20220670800"); map.put("apiConfigProductId" , "11"); map.put("orderNo" , "ORG12313128931283217312"); map.put("notifyUrl" , "ORG12313128931283217312"); map.put("mobile" , "18090580471"); String sign = WxUtils.generateSignApi(map , MapUtils.getString(map , "apiKey"), WXPayConstants.SignType.MD5); map.put("sign" , sign); JSONObject object = HttpsUtils.doPost("http://localhost:9902/v1/rechargeProduct/createOrder" , map , new HashMap<>()); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java index 65d29bf3..afe0d6c0 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java @@ -76,9 +76,6 @@ public class CzOrderController { @Resource private ApiOrderRecordService apiOrderRecordService; - @Resource - private ApiAmountRecordService apiAmountRecordService; - @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST) @ApiOperation(value = "龙阅充值回调") @@ -194,7 +191,9 @@ public class CzOrderController { outRechargeOrderService.updateOrder(rechargeOrder); outRechargeChildOrderService.updateOrder(childOrder); - apiOrderRecord(rechargeOrder); + if (rechargeOrder.getPayType() == 6) { + apiOrderRecord(rechargeOrder); + } } else { callbackResult(childOrder , rechargeOrder); @@ -259,7 +258,9 @@ public class CzOrderController { outRechargeOrderService.updateOrder(rechargeOrder); outRechargeChildOrderService.updateOrder(childOrder); - apiOrderRecord(rechargeOrder); + if (rechargeOrder.getPayType() == 6) { + apiOrderRecord(rechargeOrder); + } } else { callbackResult(childOrder , rechargeOrder); } @@ -299,6 +300,7 @@ public class CzOrderController { outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId()); + new Thread(() -> { HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); WxMsgConfig.rechargedFail( @@ -475,9 +477,9 @@ public class CzOrderController { } } - @RequestMapping(value="/test",method = RequestMethod.POST) + @RequestMapping(value="/apiCallBack",method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "ces") + @ApiOperation(value = "apiCallBack") public String test(@RequestBody String reqBodyStr) { try { if (StringUtils.isBlank(reqBodyStr)) { @@ -485,6 +487,7 @@ public class CzOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + System.out.println("reqBodyStr"); return "SUCCESS"; diff --git a/hai-service/src/main/java/com/hai/config/RechargeConfig.java b/hai-service/src/main/java/com/hai/config/RechargeConfig.java index 96152a5c..fcb87dbd 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -63,7 +63,7 @@ public class RechargeConfig { paramMap.put("out_trade_num" , object.getString("out_trade_num")); paramMap.put("product_id" , object.getString("product_id")); paramMap.put("mobile" , object.getString("mobile")); - paramMap.put("notify_url" , CommonSysConst.getSysConfig().getJjNotifyUrl()); + paramMap.put("notify_url" , CommonSysConst.getSysConfig().getLyNotifyUrl()); paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap); diff --git a/hai-service/src/main/java/com/hai/dao/ApiAmountRecordMapperExt.java b/hai-service/src/main/java/com/hai/dao/ApiAmountRecordMapperExt.java index 336c9f0a..9a63b152 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiAmountRecordMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/ApiAmountRecordMapperExt.java @@ -1,7 +1,40 @@ package com.hai.dao; +import com.hai.entity.ApiOrderRecord; +import com.hai.entity.OutRechargeOrder; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; + /** * mapper扩展类 */ public interface ApiAmountRecordMapperExt { -} \ No newline at end of file + + @Select({"SELECT * FROM api_order_record aor WHERE TIMESTAMPDIFF(MINUTE,aor.request_time,SYSDATE()) < 15 AND aor.status = 100"}) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="amount_type", property="amountType", jdbcType=JdbcType.INTEGER), + @Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL), + @Result(column="before_amount", property="beforeAmount", jdbcType=JdbcType.DECIMAL), + @Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL), + @Result(column="mch_id", property="mchId", jdbcType=JdbcType.VARCHAR), + @Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER), + @Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT), + @Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR), + @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), + @Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List callBackOrderList(); + +} diff --git a/hai-service/src/main/java/com/hai/service/ApiAmountRecordService.java b/hai-service/src/main/java/com/hai/service/ApiAmountRecordService.java index 7babfefe..2f9d9286 100644 --- a/hai-service/src/main/java/com/hai/service/ApiAmountRecordService.java +++ b/hai-service/src/main/java/com/hai/service/ApiAmountRecordService.java @@ -2,6 +2,9 @@ package com.hai.service; import com.hai.entity.ApiAmountRecord; +import java.util.List; +import java.util.Map; + /** * @serviceName ApiAmountRecordService.java * @author Sum1Dream @@ -31,4 +34,14 @@ public interface ApiAmountRecordService { */ ApiAmountRecord findById(Long id); + /** + * @Author Sum1Dream + * @name isRefundOrder.java + * @Description // 查询是否已经退款 + * @Date 10:35 2022/6/15 + * @Param [java.util.Map] + * @return java.lang.Boolean + */ + List getApiAmountRecordByList(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/ApiOpenService.java b/hai-service/src/main/java/com/hai/service/ApiOpenService.java index 97454e1e..af0e559d 100644 --- a/hai-service/src/main/java/com/hai/service/ApiOpenService.java +++ b/hai-service/src/main/java/com/hai/service/ApiOpenService.java @@ -22,6 +22,6 @@ public interface ApiOpenService { * @Param [com.alibaba.fastjson.JSONObject] * @return com.alibaba.fastjson.JSONObject */ - JSONObject createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception; + void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiAmountRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiAmountRecordServiceImpl.java index d08e95ce..799e427d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiAmountRecordServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiAmountRecordServiceImpl.java @@ -2,12 +2,16 @@ package com.hai.service.impl; import com.hai.dao.ApiAmountRecordMapper; import com.hai.entity.ApiAmountRecord; +import com.hai.entity.ApiAmountRecordExample; import com.hai.service.ApiAmountRecordService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; +import java.util.List; +import java.util.Map; @Service("apiAmountRecordService") public class ApiAmountRecordServiceImpl implements ApiAmountRecordService { @@ -27,4 +31,22 @@ public class ApiAmountRecordServiceImpl implements ApiAmountRecordService { public ApiAmountRecord findById(Long id) { return apiAmountRecordMapper.selectByPrimaryKey(id); } + + @Override + public List getApiAmountRecordByList(Map map) { + ApiAmountRecordExample example = new ApiAmountRecordExample(); + ApiAmountRecordExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isBlank(MapUtils.getString(map , "orderNo"))) { + criteria.andSourceOrderNoEqualTo(MapUtils.getString(map , "orderNo")); + } + if (MapUtils.getInteger(map , "amountType") == null) { + criteria.andAmountTypeEqualTo(MapUtils.getInteger(map , "amountType")); + } + if (MapUtils.getInteger(map , "sourceType") == null) { + criteria.andSourceTypeEqualTo(MapUtils.getInteger(map , "sourceType")); + } + + return apiAmountRecordMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java index 62d016c3..506f77cf 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java @@ -50,9 +50,12 @@ public class ApiOpenServiceImpl implements ApiOpenService { @Resource private BsRequestRecordService bsRequestRecordService; + @Resource + private OutRechargeOrderService outRechargeOrderService; + @Override @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) - public JSONObject createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception { + public void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception { Map orderMap = new HashMap<>(); orderMap.put("sourceOrderNo" , object.getString("orderNo")); @@ -97,7 +100,7 @@ public class ApiOpenServiceImpl implements ApiOpenService { apiAmountRecord.setSourceType(3); apiAmountRecord.setSourceOrderNo(object.getString("orderNo")); apiAmountRecord.setSourceId(apiProduct.getId()); - apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|" + object.getString("mobile") + "充值" + apiProduct.getRechargePrice()); + apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|" + object.getString("mobile") + "充值" + apiProduct.getRechargePrice() + "|扣款" + productConfig.getDiscountPrice()); apiAmountRecordService.insertAmountRecord(apiAmountRecord); @@ -126,8 +129,7 @@ public class ApiOpenServiceImpl implements ApiOpenService { outRechargeOrder.setUserId(apiMerchants.getId()); outRechargeOrderMapper.insert(outRechargeOrder); - pollRequest(outRechargeOrder); - + outRechargeOrderService.pollRequest(outRechargeOrder); // 插入订单记录 ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord(); apiOrderRecordPost.setStatus(103); @@ -136,113 +138,12 @@ public class ApiOpenServiceImpl implements ApiOpenService { apiOrderRecordPost.setCreateTime(new Date()); apiOrderRecordPost.setMchId(apiMerchants.getMchId()); apiOrderRecordPost.setOrderId(outRechargeOrder.getId()); - apiOrderRecordPost.setGoodsId(apiProduct.getId().toString()); + apiOrderRecordPost.setGoodsId(productConfig.getId().toString()); apiOrderRecordPost.setNotifyUrl(object.getString("notifyUrl")); apiOrderRecordPost.setUpdateTime(new Date()); apiOrderRecordService.insertOrderRecord(apiOrderRecordPost); - return null; } - private void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { - - // 查询充值产品 - ApiProduct apiProduct = apiProductService.findById(outRechargeOrder.getGoodsId()); - - // 查询充值子订单 - Map childOrderMap = new HashMap<>(); - - childOrderMap.put("parent_order_id", outRechargeOrder.getId()); - childOrderMap.put("status", 102); - - List childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); - - OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - - // 1:尖椒 2:龙阅 3:畅停 - int type = 0; - int rechargePlatformType = 0; - - // 判断子订单是否存在充值中订单 - if (childOrderList.size() > 0) { - childOrder = childOrderList.get(0); - childOrder.setStatus(103); - childOrder.setUpdateTime(new Date()); - outRechargeChildOrderService.updateOrder(childOrder); - type = childOrder.getRechargePlatform(); - } - - JSONObject object = new JSONObject(); - - String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); - - String[] rechargePlatform = apiProduct.getRechargePlatform().split("-"); - - for (String s : rechargePlatform) { - // 尖椒充值 - if (s.equals("1") && (type == 2 || type == 0)) { - object.put("out_order_id", orderNo); - object.put("amount", apiProduct.getRechargePrice()); - object.put("mobile", outRechargeOrder.getRechargeContent()); - if (apiProduct.getRechargeType() == 1) { - object.put("is_fast", 1); - } - JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); - object.put("return_content", returnObject); - if (returnObject != null && returnObject.getLong("code") == 200) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } - rechargePlatformType = 1; - break; - } - if (s.equals("2") && (type == 1 || type == 0)) { - object.put("out_trade_num", orderNo); - object.put("product_id", apiProduct.getProductId()); - object.put("mobile", outRechargeOrder.getRechargeContent()); - JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); - object.put("return_content", returnObject); - if (returnObject != null && returnObject.getLong("errno") == 0) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } - rechargePlatformType = 2; - break; - } - } - - childOrder.setOrderNo(orderNo); - childOrder.setCreateTime(new Date()); - childOrder.setParentOrderId(outRechargeOrder.getId()); - childOrder.setRechargePlatform(rechargePlatformType); - childOrder.setUpdateTime(new Date()); - outRechargeChildOrderService.insertOrder(childOrder); - - // 创建提交记录 - BsRequestRecord requestRecord = new BsRequestRecord(); - requestRecord.setCreateTime(new Date()); - requestRecord.setUpdateTime(new Date()); - requestRecord.setOrderNo(orderNo); - requestRecord.setRequestContent(object.toJSONString()); - requestRecord.setOperatorId(0L); - requestRecord.setOperatorName("系统生成"); - requestRecord.setSourceId(childOrder.getId().toString()); - requestRecord.setSourceType(1); - - bsRequestRecordService.insertRequestRecord(requestRecord); - - // 判断是否充值提交成功 - if (childOrder.getStatus() == 102) { - outRechargeOrder.setRechargeStatus(201); - } - - if (childOrder.getStatus() == 103) { - outRechargeOrder.setRechargeStatus(204); - } - outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); - - } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 8d402a57..353ae787 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -90,6 +90,15 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private HighUserPayPasswordService highUserPayPasswordService; + @Resource + private ApiMerchantsService apiMerchantsService; + + @Resource + private ApiAmountRecordService apiAmountRecordService; + + @Resource + private ApiOrderRecordService apiOrderRecordService; + @Override public List getListRechargeOrder(Map map) { @@ -679,6 +688,58 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); } + + // 商户预充值 帐户退款 + if (order.getPayType() == 6) { + + Map map = new HashMap<>(); + map.put("orderNo" , order.getOrderNo()); + map.put("amountType" , 1); + map.put("sourceType" , 2); + + if ( apiAmountRecordService.getApiAmountRecordByList(map).size() == 1) { + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(order.getMerchId()); + // 插入金额记录 + // 变更前金额 + BigDecimal beforeAmount = apiMerchants.getAmounts(); + // 计算金额 + apiMerchants.setAmounts(apiMerchants.getAmounts().add(order.getPayPrice())); + // 变更后金额 + BigDecimal afterAmount = apiMerchants.getAmounts(); + + apiMerchantsService.updateApiMerchants(apiMerchants); + + ApiAmountRecord apiAmountRecord = new ApiAmountRecord(); + + apiAmountRecord.setCreateTime(new Date()); + apiAmountRecord.setUpdateTime(new Date()); + apiAmountRecord.setMchId(order.getMerchId()); + + apiAmountRecord.setStatus(100); + apiAmountRecord.setAmount(order.getPayPrice()); + apiAmountRecord.setAfterAmount(afterAmount); + apiAmountRecord.setBeforeAmount(beforeAmount); + apiAmountRecord.setAmountType(1); + apiAmountRecord.setSourceType(2); + apiAmountRecord.setSourceOrderNo(order.getOrderNo()); + apiAmountRecord.setSourceId(order.getId()); + apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|订单退款" + order.getPayPrice()); + + apiAmountRecordService.insertAmountRecord(apiAmountRecord); + + Map orderMap = new HashMap<>(); + orderMap.put("orderId" , order.getId()); + + // 查询是否用重复订单 + ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); + + apiOrderRecord.setStatus(100); + apiOrderRecord.setRequestTime(new Date()); + apiOrderRecordService.updateOrderRecord(apiOrderRecord); + } + + } } diff --git a/v1/src/main/java/com/v1/controller/GzSinopecController.java b/v1/src/main/java/com/v1/controller/GzSinopecController.java index 0e4721b8..fe922367 100644 --- a/v1/src/main/java/com/v1/controller/GzSinopecController.java +++ b/v1/src/main/java/com/v1/controller/GzSinopecController.java @@ -6,7 +6,10 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongConfig; +import com.hai.dao.HighGasOrderPushMapper; +import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighUser; +import com.hai.enum_type.OrderPushType; import com.hai.model.ResponseData; import com.hai.service.HighOpenApiService; import com.hai.service.HighUserService; @@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -36,6 +40,9 @@ public class GzSinopecController { @Resource private HighUserService highUserService; + @Resource + private HighGasOrderPushMapper highGasOrderPushMapper; + @Resource private SecConfigService secConfigService; @@ -57,7 +64,7 @@ public class GzSinopecController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前手机号暂无用户"); } - Map map = new HashMap<>(); + Map map = new HashMap<>(); map.put("userId", highUser.getId()); map.put("useScope", useScope); if (year != null) { @@ -73,7 +80,7 @@ public class GzSinopecController { } } - @RequestMapping(value="/getGuizhouSinopecList",method = RequestMethod.POST) + @RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取贵州中石化电子卡券") public ResponseData getGuizhouSinopecList(HttpServletRequest request) { @@ -81,13 +88,13 @@ public class GzSinopecController { String ip = ""; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for - if (request.getHeader("x-forwarded-for") == null) { + if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); - } else { + } else { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!secConfigService.isConfig("IP_WHITE", ip)) { log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); } @@ -99,18 +106,18 @@ public class GzSinopecController { JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token); System.out.println(corpCouTypes.toJSONString()); if (!corpCouTypes.getString("result").equals("success")) { - log.error("HighOpenApiController -> getGuizhouSinopecList() error!","获取电子卡券列表失败"); + log.error("HighOpenApiController -> getGuizhouSinopecList() error!", "获取电子卡券列表失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取电子卡券列表失败"); } return ResponseMsgUtil.success(corpCouTypes.getJSONArray("data")); } catch (Exception e) { - log.error("HighCouponController -> getGuizhouSinopec() error!",e); + log.error("HighCouponController -> getGuizhouSinopec() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value="/checkCouponStatus",method = RequestMethod.POST) + @RequestMapping(value = "/checkCouponStatus", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询电子券状态") public ResponseData checkCouponStatus(@RequestBody JSONObject object, HttpServletRequest request) { @@ -118,13 +125,13 @@ public class GzSinopecController { String ip = ""; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for - if (request.getHeader("x-forwarded-for") == null) { + if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); - } else { + } else { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!secConfigService.isConfig("IP_WHITE", ip)) { log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); } @@ -135,18 +142,18 @@ public class GzSinopecController { // 查询电子卡券类型 JSONObject data = HuiLianTongConfig.getCouState(token, object.getString("couNo")); if (!data.getString("result").equals("success")) { - log.error("HighOpenApiController -> insertCoupon() error!","查询电子券状态失败"); + log.error("HighOpenApiController -> insertCoupon() error!", "查询电子券状态失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询电子券状态失败"); } return ResponseMsgUtil.success(data.getJSONObject("data")); } catch (Exception e) { - log.error("HighCouponController -> getGuizhouSinopec() error!",e); + log.error("HighCouponController -> getGuizhouSinopec() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value="/couJointDist",method = RequestMethod.POST) + @RequestMapping(value = "/couJointDist", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "商户派发电子券") public ResponseData couJointDist(@RequestBody JSONObject object, HttpServletRequest request) { @@ -154,13 +161,13 @@ public class GzSinopecController { String ip = ""; // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for - if (request.getHeader("x-forwarded-for") == null) { + if (request.getHeader("x-forwarded-for") == null) { ip = request.getRemoteAddr(); - } else { + } else { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!secConfigService.isConfig("IP_WHITE", ip)) { log.error("couJointDist error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); } @@ -170,20 +177,29 @@ public class GzSinopecController { // 商户派发电子券 JSONObject returnParam = HuiLianTongConfig.couJointDist(token, object.getString("orderNo"), object.getString("couTypeCode"), object.getInteger("distCouCount"), object.getString("phone"), object.getString("thirdUserId")); - if (returnParam == null || !returnParam.getString("result").equals("success")) { - log.error("HighOpenApiController -> couJointDist() error!","商户派发电子券失败"); + // 推送记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(object.getString("orderNo")); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setCode(returnParam.getString("result")); + highGasOrderPush.setRequestContent(JSONObject.toJSONString(object)); + highGasOrderPush.setReturnContent(returnParam.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + if (!returnParam.getString("result").equals("success")) { + log.error("HighOpenApiController -> couJointDist() error!", "商户派发电子券失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败"); } return ResponseMsgUtil.success(returnParam.getJSONArray("data")); } catch (Exception e) { - log.error("HighOpenApiController -> couJointDist() error!",e); + log.error("HighOpenApiController -> couJointDist() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value="/test",method = RequestMethod.POST) + @RequestMapping(value = "/test", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(HttpServletRequest request) { @@ -192,13 +208,13 @@ public class GzSinopecController { String ip = ""; if (request.getHeader("x-forwarded-for") == null) { - ip = request.getRemoteAddr(); + ip = request.getRemoteAddr(); } - ip = request.getHeader("x-forwarded-for"); + ip = request.getHeader("x-forwarded-for"); return ResponseMsgUtil.success(ip); } catch (Exception e) { - log.error("HighCouponController -> getGuizhouSinopec() error!",e); + log.error("HighCouponController -> getGuizhouSinopec() error!", e); return ResponseMsgUtil.exception(e); } } diff --git a/v1/src/main/java/com/v1/controller/RechargeProductController.java b/v1/src/main/java/com/v1/controller/RechargeProductController.java index 416c0232..2959dbe3 100644 --- a/v1/src/main/java/com/v1/controller/RechargeProductController.java +++ b/v1/src/main/java/com/v1/controller/RechargeProductController.java @@ -212,13 +212,13 @@ public class RechargeProductController { JSONObject returnObject = new JSONObject(); returnObject.put("sourceOrderNo" , apiOrderRecord.getSourceOrderNo()); returnObject.put("callbackStatus" , apiOrderRecord.getStatus()); - returnObject.put("goodsId" , apiOrderRecord.getGoodsId()); + returnObject.put("apiConfigProductId" , apiOrderRecord.getGoodsId()); returnObject.put("type" , rechargeOrder.getType()); returnObject.put("operatorName" , rechargeOrder.getOperatorName()); returnObject.put("rechargeType" , rechargeOrder.getRechargeType()); returnObject.put("rechargeContent" , rechargeOrder.getRechargeContent()); returnObject.put("rechargePrice" , rechargeOrder.getRechargePrice()); - returnObject.put("payRealPrice" , rechargeOrder.getPayRealPrice()); + returnObject.put("payPrice" , rechargeOrder.getPayPrice()); returnObject.put("createTimed" , rechargeOrder.getCreateTimed()); returnObject.put("payStatus" , rechargeOrder.getPayStatus()); returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus()); @@ -254,7 +254,7 @@ public class RechargeProductController { if (StringUtils.isBlank(object.getString("mobile")) || StringUtils.isBlank(object.getString("apiConfigProductId")) || - StringUtils.isBlank(object.getString("appKey")) || + StringUtils.isBlank(object.getString("apiKey")) || StringUtils.isBlank(object.getString("orderNo")) || StringUtils.isBlank(object.getString("notifyUrl")) || StringUtils.isBlank(object.getString("sign")) || @@ -285,7 +285,7 @@ public class RechargeProductController { Map map = new HashMap<>(); map.put("mobile" , object.getString("mobile")); - map.put("goodsId" , apiProductConfig.getProductId()); + map.put("apiConfigProductId" , object.getString("apiConfigProductId")); map.put("orderNo" , object.getString("orderNo")); map.put("notifyUrl" , object.getString("notifyUrl")); map.put("apiKey" , object.getString("apiKey")); @@ -295,8 +295,8 @@ public class RechargeProductController { log.error("createOrder error!", "签名校验失败!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); } - - return ResponseMsgUtil.success(apiOpenService.createOrder(object , apiMerchants , apiProductConfig)); + apiOpenService.createOrder(object , apiMerchants , apiProductConfig); + return ResponseMsgUtil.success("下单成功"); } catch (Exception e) { log.error("HighOpenApiController --> createOrder() error!", e);