From 80fbf4ae2a0d685e3ee9f0ab7a6fb7678bbf882c Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Fri, 10 Jun 2022 16:56:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=AF=9D=E8=B4=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighTestController.java | 2 +- .../com/hai/common/exception/ErrorCode.java | 4 +- .../java/com/hai/common/utils/WxUtils.java | 31 +++ .../config/HuiLianTongUnionCardConfig.java | 12 + .../hai/dao/ApiProductConfigMapperExt.java | 30 +++ .../com/hai/service/ApiMerchantsService.java | 21 +- .../hai/service/ApiOrderRecordService.java | 25 ++ .../com/hai/service/SecConfigService.java | 13 + .../service/impl/ApiMerchantsServiceImpl.java | 18 ++ .../impl/ApiOrderRecordServiceImpl.java | 39 +++ .../service/impl/SecConfigServiceImpl.java | 17 ++ .../v1/controller/GzSinopecController.java | 206 +++++++++++++++ .../controller/RechargeProductController.java | 234 ++++++++++++++++++ 13 files changed, 648 insertions(+), 4 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java create mode 100644 v1/src/main/java/com/v1/controller/GzSinopecController.java create mode 100644 v1/src/main/java/com/v1/controller/RechargeProductController.java 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 754e6ba4..daae226e 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.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 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); } } } \ 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.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 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); } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index 861a9056..b41cbc2f 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -128,7 +128,9 @@ public enum ErrorCode { REQUEST_ERROR("3005","请求错误"), REQUEST_TIMED_OUT("3006","请求超时,请稍后重试"), - MSG_EVENT_NULL("2999","消息类型为空"), + SIGN_VERIFY("6001","签名校验失败"), + + MSG_EVENT_NULL("2999","消息类型为空"), USE_VISIT_ILLEGAL("4001","用户身份错误"), RC_VISIT_ERROR("2998",""), UNKNOW_ERROR("999999","未知异常"), diff --git a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java index 02c33605..948e1b2c 100644 --- a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java @@ -438,5 +438,36 @@ public class WxUtils { } } + /** + * 生成签名. + * + * @param data 待签名数据 + * @param key API密钥 + * @param signType 签名方式 + * @return 签名 + */ + public static String generateSignApi(final Map data, String key, WXPayConstants.SignType signType) throws Exception { + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN)) { + continue; + } + if (data.get(k) != null) // 参数值为空,则不参与签名 + sb.append(k).append("=").append(data.get(k)).append("&"); + } + sb.append("apiKey=").append(key); + if (WXPayConstants.SignType.MD5.equals(signType)) { + return MD5(sb.toString() , true); + } + else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) { + return HMACSHA256(sb.toString(), key); + } + else { + throw new Exception(String.format("Invalid sign_type: %s", signType)); + } + } } diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index d1b731f4..b3832626 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -284,6 +284,18 @@ public class HuiLianTongUnionCardConfig { } + /** + * @Author Sum1Dream + * @name submitSms.java + * @Description // 同步加油券订单 + * @Date 10:08 上午 2022/1/13 + * @Param [java.lang.String] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject syncPayOrder(Map map) throws Exception { + return request("fuelCouponsTest/syncPayOrder", map); + } + } diff --git a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java index ab7ee319..ff51e1af 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java @@ -44,4 +44,34 @@ public interface ApiProductConfigMapperExt { }) List getListMerchProduct(Long merchantsId); + @Select(value = { + "" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_platform", property="rechargePlatform", jdbcType=JdbcType.VARCHAR), + @Result(column="phone_recharge_type", property="phoneRechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL), + @Result(column="product_id", property="productId", jdbcType=JdbcType.BIGINT), + @Result(column="api_config_product_id", property="apiConfigProductId", jdbcType=JdbcType.BIGINT), + @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER), + @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL), + @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL), + @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="config_status", property="configStatus", 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 getMerchProduct(Long merchantsId , Integer rechargeType); + } diff --git a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java index 167fbd74..0ba4971a 100644 --- a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java +++ b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java @@ -59,6 +59,16 @@ public interface ApiMerchantsService { */ ApiMerchants findById(Long id); + /** + * @Author Sum1Dream + * @name findByMchId.java + * @Description // 根据商户号查询商户 + * @Date 10:05 2022/6/10 + * @Param [java.lang.String] + * @return com.hai.entity.ApiMerchants + */ + ApiMerchants findByMchId(String mchId); + /** * @Author Sum1Dream * @name recharge.java @@ -89,8 +99,15 @@ public interface ApiMerchantsService { */ List getListMerchProduct(Long merchantId); - - + /** + * @Author Sum1Dream + * @name getListMerchProduct.java + * @Description // 查询商户可用产品 + * @Date 10:10 2022/6/9 + * @Param [java.lang.Long] + * @return java.util.List + */ + List getMerchProduct(Long merchantId , Integer rechargeType); } diff --git a/hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java b/hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java new file mode 100644 index 00000000..42c4f97a --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java @@ -0,0 +1,25 @@ +package com.hai.service; + +import com.hai.entity.ApiOrderRecord; + +import java.util.Map; + +/** + * @serviceName ApiOrderRecordService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 订单记录查询 + * @createTime 15:17 2022/6/10 + **/ +public interface ApiOrderRecordService { + + /** + * @Author Sum1Dream + * @name queryOrderResult.java + * @Description // 查询订单详情 + * @Date 15:18 2022/6/10 + * @Param [java.util.Map] + * @return com.hai.entity.ApiOrderRecord + */ + ApiOrderRecord queryOrderResult(Map map); +} diff --git a/hai-service/src/main/java/com/hai/service/SecConfigService.java b/hai-service/src/main/java/com/hai/service/SecConfigService.java index 55cfb33b..8e112743 100644 --- a/hai-service/src/main/java/com/hai/service/SecConfigService.java +++ b/hai-service/src/main/java/com/hai/service/SecConfigService.java @@ -2,6 +2,9 @@ package com.hai.service; import com.hai.entity.SecConfig; +import java.util.Map; +import java.util.SortedMap; + /** * @ClassName SecConfigService.java * @author Sum1Dream @@ -48,4 +51,14 @@ public interface SecConfigService { */ Boolean isConfig(String codeType , String codeValue); + /** + * @Author Sum1Dream + * @name SignVerify.java + * @Description // 校验签名 + * @Date 09:33 2022/6/10 + * @Param [java.util.Map] + * @return java.lang.Boolean + */ + Boolean isSignVerify(Map map) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java index 74eb336c..fb3b2eb1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java @@ -78,6 +78,18 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { return apiMerchantsMapper.selectByPrimaryKey(id); } + @Override + public ApiMerchants findByMchId(String mchId) { + ApiMerchantsExample example = new ApiMerchantsExample(); + example.createCriteria().andMchIdEqualTo(mchId).andStatusEqualTo(100); + + List list = apiMerchantsMapper.selectByExample(example); + if (list.size() > 0) { + return apiMerchantsMapper.selectByExample(example).get(0); + } + return null; + } + @Override @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) public void recharge(Long merchantId, BigDecimal amount, Map otherParam) { @@ -145,4 +157,10 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { return apiProductConfigMapper.getListMerchProduct(merchantId); } + @Override + public List getMerchProduct(Long merchantId , Integer rechargeType) { + return apiProductConfigMapper.getMerchProduct(merchantId , rechargeType); + } + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java new file mode 100644 index 00000000..07a148a8 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java @@ -0,0 +1,39 @@ +package com.hai.service.impl; + +import com.hai.dao.ApiOrderRecordMapper; +import com.hai.entity.ApiOrderRecord; +import com.hai.entity.ApiOrderRecordExample; +import com.hai.service.ApiOrderRecordService; +import com.itextpdf.text.pdf.qrcode.MaskUtil; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("apiOrderRecordService") +public class ApiOrderRecordServiceImpl implements ApiOrderRecordService { + + @Resource + private ApiOrderRecordMapper apiOrderRecordMapper; + + + @Override + public ApiOrderRecord queryOrderResult(Map map) { + + ApiOrderRecordExample example = new ApiOrderRecordExample(); + ApiOrderRecordExample.Criteria criteria = example.createCriteria(); + + criteria.andSourceOrderNoEqualTo(MapUtils.getString(map , "sourceOrderNo")); + criteria.andMchIdEqualTo(MapUtils.getString(map , "merchId")); + + List list = apiOrderRecordMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } else { + return null; + } + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java index 8531688e..d43804af 100644 --- a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java @@ -1,15 +1,21 @@ package com.hai.service.impl; +import com.hai.common.pay.util.sdk.WXPayConstants; +import com.hai.common.utils.WxUtils; import com.hai.dao.SecConfigMapper; import com.hai.entity.SecConfig; import com.hai.entity.SecConfigExample; import com.hai.entity.SecDictionary; import com.hai.entity.SecDictionaryExample; +import com.hai.service.ApiMerchantsService; import com.hai.service.SecConfigService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +import java.util.Map; +import java.util.SortedMap; @Service("secConfigServiceImpl") public class SecConfigServiceImpl implements SecConfigService { @@ -17,6 +23,9 @@ public class SecConfigServiceImpl implements SecConfigService { @Resource private SecConfigMapper secConfigMapper; + @Resource + private ApiMerchantsService apiMerchantsService; + @Override public SecConfig findById(Integer id) { return secConfigMapper.selectByPrimaryKey(id); @@ -41,4 +50,12 @@ public class SecConfigServiceImpl implements SecConfigService { List list = secConfigMapper.selectByExample(example); return list.size() > 0; } + + + @Override + public Boolean isSignVerify(Map map) throws Exception { + String sign = WxUtils.generateSignApi(map , MapUtils.getString(map , "apiKey"), WXPayConstants.SignType.MD5); + return MapUtils.getString(map, "sign").equals(sign); + } + } diff --git a/v1/src/main/java/com/v1/controller/GzSinopecController.java b/v1/src/main/java/com/v1/controller/GzSinopecController.java new file mode 100644 index 00000000..0e4721b8 --- /dev/null +++ b/v1/src/main/java/com/v1/controller/GzSinopecController.java @@ -0,0 +1,206 @@ +package com.v1.controller; + +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.ResponseMsgUtil; +import com.hai.config.HuiLianTongConfig; +import com.hai.entity.HighUser; +import com.hai.model.ResponseData; +import com.hai.service.HighOpenApiService; +import com.hai.service.HighUserService; +import com.hai.service.SecConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/gzSinopec") +@Api(value = "贵州中石化") +public class GzSinopecController { + + private static Logger log = LoggerFactory.getLogger(GzSinopecController.class); + + @Resource + private HighOpenApiService highOpenApiService; + + @Resource + private HighUserService highUserService; + + @Resource + private SecConfigService secConfigService; + + @Resource + private HuiLianTongConfig huiLianTongConfig; + + @RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取专属优惠券") + public ResponseData getUserExclusiveDiscount(@RequestParam(name = "useScope", required = false) Integer useScope, + @RequestParam(name = "phone", required = true) String phone, + @RequestParam(name = "year", required = false) String year) { + try { + + HighUser highUser = highUserService.findByPhone(phone); + + if (highUser == null || highUser.getStatus() == 0) { + log.error("getUserOrderPreList error!", "未找到用户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前手机号暂无用户"); + } + + Map map = new HashMap<>(); + map.put("userId", highUser.getId()); + map.put("useScope", useScope); + if (year != null) { + map.put("createTimeS", year + "-01-01 00:00:00"); + map.put("createTimeE", year + "-12-31 23:59:59"); + } + + return ResponseMsgUtil.success(highOpenApiService.getUserCouponsList(map)); + + } catch (Exception e) { + log.error("HighOpenApiController --> getGuizhouSinopecList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getGuizhouSinopecList",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取贵州中石化电子卡券") + public ResponseData getGuizhouSinopecList(HttpServletRequest request) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + // 获取token + String token = huiLianTongConfig.getToken(); + + // 查询电子卡券类型 + JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token); + System.out.println(corpCouTypes.toJSONString()); + if (!corpCouTypes.getString("result").equals("success")) { + 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); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/checkCouponStatus",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询电子券状态") + public ResponseData checkCouponStatus(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + // 获取token + String token = huiLianTongConfig.getToken(); + + // 查询电子卡券类型 + JSONObject data = HuiLianTongConfig.getCouState(token, object.getString("couNo")); + if (!data.getString("result").equals("success")) { + 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); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/couJointDist",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "商户派发电子券") + public ResponseData couJointDist(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("couJointDist error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + // 获取token + String token = huiLianTongConfig.getToken(); + + // 商户派发电子券 + 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!","商户派发电子券失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败"); + } + + return ResponseMsgUtil.success(returnParam.getJSONArray("data")); + } catch (Exception e) { + log.error("HighOpenApiController -> couJointDist() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/test",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "测试") + public ResponseData test(HttpServletRequest request) { + try { + + String ip = ""; + + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } + ip = request.getHeader("x-forwarded-for"); + + return ResponseMsgUtil.success(ip); + } catch (Exception 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 new file mode 100644 index 00000000..16d80ced --- /dev/null +++ b/v1/src/main/java/com/v1/controller/RechargeProductController.java @@ -0,0 +1,234 @@ +package com.v1.controller; + +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.ResponseMsgUtil; +import com.hai.entity.ApiMerchants; +import com.hai.entity.ApiOrderRecord; +import com.hai.entity.HighUser; +import com.hai.entity.OutRechargeOrder; +import com.hai.model.ResponseData; +import com.hai.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import jdk.jfr.consumer.RecordedObject; +import org.apache.commons.collections4.MapUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +/** + * @serviceName rechargeProductController.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 充值产品接口 + * @createTime 17:14 2022/6/9 + **/ +@Controller +@RequestMapping(value = "/rechargeProduct") +@Api(value = "充值产品接口") +public class RechargeProductController { + + private static Logger log = LoggerFactory.getLogger(GzSinopecController.class); + + @Resource + private ApiMerchantsService apiMerchantsService; + + @Resource + private SecConfigService secConfigService; + + @Resource + private OutRechargeOrderService outRechargeOrderService; + + @Resource + private ApiOrderRecordService apiOrderRecordService; + + @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取充值产品") + public ResponseData getRechargeProduct(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + if (object.getString("apiKey") == null || + object.getString("merchId") == null || + object.getString("sign") == null || + object.getInteger("rechargeType") == null + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "商户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + map.put("rechargeType" , object.getString("type")); + map.put("sign" , object.getString("sign")); + + if (!secConfigService.isSignVerify(map)) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + return ResponseMsgUtil.success(apiMerchantsService.getMerchProduct(apiMerchants.getId() , object.getInteger("rechargeType"))); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询帐户余额") + public ResponseData checkAccountBalance(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + if (object.getString("apiKey") == null || + object.getString("sign") == null || + object.getString("merchId") == null + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "商户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + map.put("sign" , object.getString("sign")); + + if (!secConfigService.isSignVerify(map)) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + return ResponseMsgUtil.success(apiMerchants.getAmounts()); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/queryOrderResult", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询订单结果") + public ResponseData queryOrderResult(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + } + + if (object.getString("apiKey") == null || + object.getString("merchId") == null || + object.getString("sign") == null || + object.getString("sourceOrderNo") == null + + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "商户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + map.put("sourceOrderNo" , object.getString("sourceOrderNo")); + map.put("sign" , object.getString("sign")); + + if (!secConfigService.isSignVerify(map)) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + + ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(map); + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(apiOrderRecord.getOrderNo()); + + JSONObject returnObject = new JSONObject(); + returnObject.put("sourceOrderNo" , apiOrderRecord.getSourceOrderNo()); + returnObject.put("callbackStatus" , apiOrderRecord.getStatus()); + returnObject.put("goodsId" , 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("createTimed" , rechargeOrder.getCreateTimed()); + returnObject.put("payStatus" , rechargeOrder.getPayStatus()); + returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus()); + + + return ResponseMsgUtil.success(returnObject); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } +}