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 8a07478e..00cabd48 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 = "/kfcRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "KFC退款") public ResponseData kfcRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { if (StringUtils.isNotBlank(orderNo)) { // 查询订单 HighOrder order = highOrderService.getOrderByOrderNo(orderNo); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 if (order != null && order.getOrderStatus() == 2) { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), "1609882817", order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } order.setOrderStatus(4); order.setRefundTime(new Date()); order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrder(order); return ResponseMsgUtil.success("退款成功"); } } } return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @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.HighCouponCodeOtherMapper; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; 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 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 HighCouponService highCouponService; @Resource private HighOilCardService oilCardService; @Resource private GoodsOrderServiceImpl goodsOrderService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private HighCouponCodeOtherMapper highCouponCodeOtherMapper; @Resource private HighUserCouponMapper highUserCouponMapper; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HighGasOilPriceOfficialService gasOilPriceOfficialService; @Resource private HighCouponAgentService couponAgentService; @Resource private HighCouponAgentService highCouponAgentService; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "orderNo", required = true) String orderNo, @RequestParam(name = "userPhone", required = true) String userPhone) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order != null) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); if (coupon == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); } // 获取token String token = huiLianTongConfig.getToken(); // 查询用户 HighUser highUser = highUserService.findByUserId(order.getMemId()); Map push = new HashMap<>(); push.put("token", token); push.put("couTypeCode", coupon.getCouponKey()); push.put("distCouCount", childOrder.getSaleCount()); push.put("userPhone", highUser.getPhone()); push.put("thirdUserId", highUser.getUnionId()); JSONObject returnParam = HuiLianTongConfig.couJointDist(token, orderNo, MapUtils.getString(push, "couTypeCode") , 1, userPhone, MapUtils.getString(push, "thirdUserId")); if (returnParam != null && returnParam.getString("result").equals("success")) { JSONArray dataArray = returnParam.getJSONArray("data"); for (Object data : dataArray) { JSONObject dataObject = (JSONObject) data; HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); couponCodeOther.setType(1); couponCodeOther.setOrderId(order.getId()); couponCodeOther.setChildOrderId(childOrder.getId()); couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); couponCodeOther.setCouNo(dataObject.getString("couNo")); couponCodeOther.setStatus(20); couponCodeOther.setCreateTime(new Date()); couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); highCouponCodeOtherMapper.insert(couponCodeOther); // 卡卷关联用户 HighUserCoupon highUserCoupon = new HighUserCoupon(); highUserCoupon.setMerchantId(coupon.getMerchantId()); highUserCoupon.setCouponId(coupon.getId()); highUserCoupon.setUserId(order.getMemId()); highUserCoupon.setCreateTime(new Date()); highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponMapper.insert(highUserCoupon); } } // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setType(OrderPushType.type6.getType()); highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(returnParam.getString("result")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); highGasOrderPush.setReturnContent(returnParam.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); } } else { // 查询兑换码 HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(orderNo); if (convertCode == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); } // 查询卡券 HighCoupon coupon = highCouponService.getCouponById(convertCode.getCouponId()); if (coupon == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡券"); } // 获取token String token = huiLianTongConfig.getToken(); Map push = new HashMap<>(); push.put("token", token); push.put("orderNo", convertCode.getConvertCode()); push.put("couTypeCode", coupon.getCouponKey()); push.put("distCouCount", 1); push.put("userPhone", userPhone); push.put("thirdUserId", userPhone); // 推送给高速 JSONObject returnParam = HuiLianTongConfig.couJointDist(token, MapUtils.getString(push, "orderNo"), MapUtils.getString(push, "couTypeCode"), MapUtils.getInteger(push, "distCouCount"), MapUtils.getString(push, "userPhone"), MapUtils.getString(push, "userPhone") ); if (returnParam != null && returnParam.getString("result").equals("success")) { JSONArray dataArray = returnParam.getJSONArray("data"); for (Object data : dataArray) { JSONObject dataObject = (JSONObject) data; HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); couponCodeOther.setType(1); couponCodeOther.setCouponAgentCodeId(convertCode.getId()); couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); couponCodeOther.setCouNo(dataObject.getString("couNo")); couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); couponCodeOther.setStatus(20); couponCodeOther.setCreateTime(new Date()); highCouponCodeOtherMapper.insert(couponCodeOther); } } // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setType(OrderPushType.type6.getType()); highGasOrderPush.setOrderNo(convertCode.getCouponCode()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(returnParam.getString("result")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); highGasOrderPush.setReturnContent(returnParam.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); } return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighOrderController --> couJointDist() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "KFC退款") public ResponseData kfcRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { OrderRefundModel orderRefundModel = null; if (StringUtils.isNotBlank(orderNo)) { // 查询订单 HighOrder order = highOrderService.getOrderByOrderNo(orderNo); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 if (order != null && order.getOrderStatus() == 2) { orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), "1609882817", order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } order.setOrderStatus(4); order.setRefundTime(new Date()); order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrder(order); return ResponseMsgUtil.success(orderRefundModel); } } } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @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 diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java index 3cb1fb81..344955be 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -221,10 +221,15 @@ public class OutRechargeOrderController { Map map = new HashMap<>(); + if (companyId != null) { map.put("companyId", companyId); } else if (userInfoModel.getSecRole().getRoleType() != 1){ - map.put("companyId", userInfoModel.getBsCompany().getId()); + if (userInfoModel.getSecRole().getRoleType() == 7) { + map.put("companyId", 23); + } else { + map.put("companyId", userInfoModel.getBsCompany().getId()); + } } map.put("rechargeStatus", rechargeStatus); map.put("payStatus", payStatus); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index ae1341f8..6e975f78 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -779,11 +779,11 @@ public class HighOrderServiceImpl implements HighOrderService { } String goodsDesc = ""; String tranDesc = ""; - String instCode = "11101290"; + String instCode = "11101527"; String businessType = "hisen_consume"; if (order.getHighChildOrderList().get(0).getGoodsType() == 1) { - instCode = "11101291"; + instCode = "11101526"; businessType = "sinopec_oil_code"; goodsDesc = "购买加油券"; tranDesc = order.getHighChildOrderList().get(0).getGoodsName(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java index 64177692..d2392212 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java @@ -197,10 +197,9 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService { HuiLianTongUnionCardConfig.submitSms(phone , "“E信通春节关怀”3张4元话费券、99折加油券已到账,打开“嗨森逛”微信小程序>我的>我的优惠券即可直接使用,到账之日起1月内(30天)有效。"); } else { if (equityLevel == 1) { - HuiLianTongUnionCardConfig.submitSms(phone , "“E信通会员专属”3张4元话费券、2张99折加油券已到账,打开“嗨森逛”微信小程序>我的>我的优惠券即可直接使用,到账之日起1月内(30天)有效。"); + HuiLianTongUnionCardConfig.submitSms(phone , "“E信通会员专属”3张4元话费券、2张96折加油券已到账,打开“嗨森逛”微信小程序>我的>我的优惠券即可直接使用,到账之日起1月内(30天)有效。"); } else { - - HuiLianTongUnionCardConfig.submitSms(phone , "“工会卡用户专属”2元话费券、5张98折加油券已到账,打开“嗨森逛”微信小程序>我的>我的优惠券即可直接使用,到账之日起1月内(30天)有效。"); + HuiLianTongUnionCardConfig.submitSms(phone , "“工会卡用户专属”2元话费券、2张96折加油券已到账,打开“嗨森逛”微信小程序>我的>我的优惠券即可直接使用,到账之日起1月内(30天)有效。"); } } 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..5fa951ac 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 @@ -418,19 +418,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (MapUtils.getLong(map, "createTimeS") != null) { - map.put("createTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "createTimeS")), "yyyy-MM-dd HH:mm:ss")); + map.put("createTimeS", MapUtils.getString(map, "createTimeS")); } if (MapUtils.getLong(map, "createTimeE") != null) { - map.put("createTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "createTimeE")), "yyyy-MM-dd HH:mm:ss")); + map.put("createTimeE", MapUtils.getString(map, "createTimeE")); } if (MapUtils.getLong(map, "payTimeS") != null) { - map.put("payTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "payTimeS")), "yyyy-MM-dd HH:mm:ss")); + map.put("payTimeS", MapUtils.getString(map, "payTimeS")); } if (MapUtils.getLong(map, "payTimeE") != null) { - map.put("payTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "payTimeE")), "yyyy-MM-dd HH:mm:ss")); + map.put("payTimeE", MapUtils.getString(map, "payTimeE")); } return outRechargeOrderMapper.selectOrderCount(map); @@ -526,7 +526,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { String goodsDesc = "充值话费"; String tranDesc = order.getRechargeContent() + "充值" + order.getPayRealPrice() + "元话费"; - String instCode = "11101290"; + String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 diff --git a/v1/target/classes/application.yml b/v1/target/classes/application.yml new file mode 100644 index 00000000..28b711c3 --- /dev/null +++ b/v1/target/classes/application.yml @@ -0,0 +1,74 @@ +server: + port: 9902 + servlet: + context-path: /v1 + +#配置是否为debug模式,debug模式下,不开启权限校验 +debug: false + +#datasource数据源设置 +spring: + datasource: + url: jdbc:mysql://192.168.0.63:21100/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + username: hsg + password: HUfukeji123456!@# + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver + filters: stat + maxActive: 10 + initialSize: 5 + maxWait: 60000 + minIdle: 5 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + redis: + database: 0 + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + timeout: 1000 + jedis: + pool: + max-active: 20 + max-wait: -1 + max-idle: 10 + min-idle: 0 + #thymelea模板配置 + thymeleaf: + prefix: classpath:/templates/ + suffix: .html + mode: HTML5 + encoding: UTF-8 + #热部署文件,页面不产生缓存,及时更新 + cache: false + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true + + + thymeleaf: + cache: false + prefix: classpath:/templates/ + suffix: .html + encoding: UTF-8 + content-type: text/html + mode: HTML5 + +mybatis: + mapperLocations: + - classpath*:sqlmap*/*.xml + type-aliases-package: + org.springboot.sample.entity + +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/v1/target/classes/logback.xml b/v1/target/classes/logback.xml new file mode 100644 index 00000000..516350df --- /dev/null +++ b/v1/target/classes/logback.xml @@ -0,0 +1,72 @@ + + + + + %d %p (%file:%line\)- %m%n + UTF-8 + + + + log/base.log + + log/base.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/dao.log + + log/dao.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/error.log + + log/error.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + + + + + + + + diff --git a/v1/target/hai-v1-1.0-SNAPSHOT.jar b/v1/target/hai-v1-1.0-SNAPSHOT.jar new file mode 100644 index 00000000..e3eb28ae Binary files /dev/null and b/v1/target/hai-v1-1.0-SNAPSHOT.jar differ diff --git a/v1/target/hai-v1-1.0-SNAPSHOT.jar.original b/v1/target/hai-v1-1.0-SNAPSHOT.jar.original new file mode 100644 index 00000000..cf0c8fde Binary files /dev/null and b/v1/target/hai-v1-1.0-SNAPSHOT.jar.original differ