From a1edf5d1982b4cbbe311cb3fc1ea784dde29ec14 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 26 May 2022 14:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighTestController.java | 2 +- .../OutRechargeOrderController.java | 306 +----- .../OutRechargePriceController.java | 164 +++- .../com/bweb/controller/TelApiController.java | 201 ---- .../main/java/com/cweb/config/AuthConfig.java | 2 +- .../OutRechargeOrderController.java | 912 +++++------------- .../OutRechargePriceController.java | 45 +- .../controller/pay/CzOrderController.java | 584 +++++------ .../controller/pay/WechatPayController.java | 13 - .../java/com/hai/common/utils/WxUtils.java | 32 + .../java/com/hai/config/CommonSysConfig.java | 77 +- .../java/com/hai/config/RechargeConfig.java | 147 +++ .../main/java/com/hai/config/TelConfig.java | 80 -- .../hai/dao/OutRechargeOrderRecordMapper.java | 2 +- .../dao/OutRechargeOrderRecordMapperExt.java | 2 +- .../OutRechargeOrderRecordSqlProvider.java | 2 +- .../hai/dao/OutRechargePriceMapperExt.java | 45 +- .../java/com/hai/entity/BsOperationLog.java | 4 +- .../hai/entity/OutRechargeOrderRecord.java | 2 +- .../entity/OutRechargeOrderRecordExample.java | 2 +- .../java/com/hai/entity/OutRechargePrice.java | 2 +- .../com/hai/enum_type/RechargePayType.java | 9 +- .../com/hai/model/OutRechargePriceModel.java | 40 + .../java/com/hai/service/BsConfigService.java | 48 + .../hai/service/BsOperationLogService.java | 36 + .../hai/service/BsRequestRecordService.java | 45 + .../java/com/hai/service/HighTestService.java | 55 -- ...java => OutRechargeChildOrderService.java} | 18 +- .../hai/service/OutRechargeOrderService.java | 41 +- .../hai/service/OutRechargePriceService.java | 27 +- .../hai/service/impl/BsConfigServiceImpl.java | 107 ++ .../impl/BsOperationLogServiceImpl.java | 30 + .../impl/BsRequestRecordServiceImpl.java | 42 + .../hai/service/impl/CommonServiceImpl.java | 2 +- .../hai/service/impl/HighTestServiceImpl.java | 176 ---- .../OutRechargeChildOrderServiceImpl.java | 64 ++ .../OutRechargeOrderRecordServiceImpl.java | 60 -- .../impl/OutRechargeOrderServiceImpl.java | 387 ++++---- .../impl/OutRechargePriceServiceImpl.java | 118 ++- .../pay/impl/RechargeOrderServiceImpl.java | 1 - .../resources/dev/commonConfig.properties | 16 +- .../resources/prod/commonConfig.properties | 12 +- 42 files changed, 1811 insertions(+), 2149 deletions(-) delete mode 100644 hai-bweb/src/main/java/com/bweb/controller/TelApiController.java create mode 100644 hai-service/src/main/java/com/hai/config/RechargeConfig.java delete mode 100644 hai-service/src/main/java/com/hai/config/TelConfig.java create mode 100644 hai-service/src/main/java/com/hai/model/OutRechargePriceModel.java create mode 100644 hai-service/src/main/java/com/hai/service/BsConfigService.java create mode 100644 hai-service/src/main/java/com/hai/service/BsOperationLogService.java create mode 100644 hai-service/src/main/java/com/hai/service/BsRequestRecordService.java delete mode 100644 hai-service/src/main/java/com/hai/service/HighTestService.java rename hai-service/src/main/java/com/hai/service/{OutRechargeOrderRecordService.java => OutRechargeChildOrderService.java} (71%) create mode 100644 hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/BsOperationLogServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/BsRequestRecordServiceImpl.java delete mode 100644 hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java delete mode 100644 hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.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 b267a080..244d40bd 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.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 HighTestService highTestService; @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 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 = "/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="/getReadFile",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "存入用户信息") public ResponseData getReadFile() { try { highTestService.getReadFile(); return ResponseMsgUtil.success(null); } 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 = "/zwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联退款") public ResponseData zwrefund( @RequestParam(name = "orderId", required = true) Long orderId , @RequestParam(name = "MER_ID", required = true) String MER_ID , @RequestParam(name = "TERM_ID", required = true) String TERM_ID , HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 订单退款 JSONObject refund = UnionPayConfig.zwrefund(MER_ID, TERM_ID, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (!refund.getString("resultcode").equals("W6")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } // order.setStatus(5); order.setRefundTime(new Date()); order.setOutRefundNo(refund.getString("oriwtorderid")); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(refund); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() 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 = "/findByLatAndLng", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取定位信息") public ResponseData findByLatAndLng( @RequestParam(name = "lng", required = true) String lng, @RequestParam(name = "lat", required = true) String lat ) { try { return ResponseMsgUtil.success(highTestService.findByLatAndLng(lng , lat)); } 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.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.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.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; 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 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 = "/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 = "/zwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联退款") public ResponseData zwrefund( @RequestParam(name = "orderId", required = true) Long orderId , @RequestParam(name = "MER_ID", required = true) String MER_ID , @RequestParam(name = "TERM_ID", required = true) String TERM_ID , HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 订单退款 JSONObject refund = UnionPayConfig.zwrefund(MER_ID, TERM_ID, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (!refund.getString("resultcode").equals("W6")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } // order.setStatus(5); order.setRefundTime(new Date()); order.setOutRefundNo(refund.getString("oriwtorderid")); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(refund); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() 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 = "/getProductsList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取产品") public ResponseData getProductsList() { try { return ResponseMsgUtil.success(RechargeConfig.getProductsListByLy()); } 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 5d57575e..ba2aa641 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -3,12 +3,10 @@ package com.bweb.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; -import com.bweb.excelListener.ImportCouponListener; import com.bweb.excelListener.ImportRechargeOrderListener; import com.bweb.model.ExportOutRechargeOrder; import com.bweb.model.ExportOutRechargeOrderCount; import com.bweb.model.ExportOutRechargeUserOrderCount; -import com.bweb.model.ImportCouponModel; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -16,21 +14,17 @@ 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.security.SessionObject; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.IDGenerator; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.UnionPayConfig; -import com.hai.entity.HighCoupon; import com.hai.entity.HighRefundAudit; import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrderRecord; import com.hai.model.*; import com.hai.service.HighRefundAuditService; import com.hai.service.HighUserService; -import com.hai.service.OutRechargeOrderRecordService; +import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeOrderService; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; @@ -73,7 +67,7 @@ public class OutRechargeOrderController { private HighUserService highUserService; @Resource - private OutRechargeOrderRecordService rechargeOrderRecordService; + private OutRechargeChildOrderService rechargeOrderRecordService; @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @@ -90,74 +84,29 @@ public class OutRechargeOrderController { } } - @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "取消订单") - public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) { - try { - - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); - -// if (outRechargeOrder.getStatus() == 1) { -// outRechargeOrderService.cancelOrder(orderId); -// } else { -// log.error("orderToPay error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); -// } - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/finishOrder", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "完成充值") - public ResponseData finishOrder(@RequestParam(name = "orderId", required = true) Long orderId) { - try { - - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); - -// if (outRechargeOrder.getStatus() == 2) { -// outRechargeOrderService.finishOrder(orderId); -// } else { -// log.error("orderToPay error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); -// } - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value="/importRechargeOrder",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "导入话费充值订单") - public ResponseData importRechargeOrder( @RequestParam(value = "file" , required = true) MultipartFile files, - HttpServletRequest request) { - try { - - ImportRechargeOrderListener importRechargeOrderListener = new ImportRechargeOrderListener(); - importRechargeOrderListener.initData(outRechargeOrderService); - EasyExcel.read(files.getInputStream(), ExportOutRechargeOrder.class, importRechargeOrderListener).sheet().doRead(); - - Map map = new HashMap<>(); - map.put("errorData", importRechargeOrderListener.getErrorData()); - map.put("errorTotal", importRechargeOrderListener.getErrorData().size()); - - return ResponseMsgUtil.success(map); - - } catch (Exception e) { - log.error("HighCouponController -> importStock() error!",e); - return ResponseMsgUtil.exception(e); - } - } +// @RequestMapping(value="/importRechargeOrder",method = RequestMethod.POST) +// @ResponseBody +// @ApiOperation(value = "导入话费充值订单") +// public ResponseData importRechargeOrder( @RequestParam(value = "file" , required = true) MultipartFile files, +// HttpServletRequest request) { +// try { +// +// ImportRechargeOrderListener importRechargeOrderListener = new ImportRechargeOrderListener(); +// importRechargeOrderListener.initData(outRechargeOrderService); +// EasyExcel.read(files.getInputStream(), ExportOutRechargeOrder.class, importRechargeOrderListener).sheet().doRead(); +// +// Map map = new HashMap<>(); +// map.put("errorData", importRechargeOrderListener.getErrorData()); +// map.put("errorTotal", importRechargeOrderListener.getErrorData().size()); +// +// return ResponseMsgUtil.success(map); +// +// } catch (Exception e) { +// log.error("HighCouponController -> importStock() error!",e); +// return ResponseMsgUtil.exception(e); +// } +// } @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) @ResponseBody @@ -226,19 +175,6 @@ public class OutRechargeOrderController { } } - @RequestMapping(value = "/countOrder", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "完成充值") - public ResponseData countOrder() { - try { - - return ResponseMsgUtil.success(outRechargeOrderService.CountOrder()); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } @RequestMapping(value = "/exportOrderList", method = RequestMethod.GET) @ResponseBody @@ -284,157 +220,6 @@ public class OutRechargeOrderController { } } - @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "订单退款") - public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId, - HttpServletRequest request) { - try { - - OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); - - HighRefundAudit highRefundAudit = highRefundAuditService.findByOrderNo(order.getOrderNo()); - - if (order == null) { - log.error("orderToPay error!", "未找到充值订单"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到充值订单"); - } - - // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中 -// if (order.getStatus() != 6) { -// log.error("orderToPay error!", "无法退款,订单不处于退款中状态"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); -// } - - // 微信退款 - if (order.getPayType() == 1) { - Map param = new HashMap<>(); - param.put("appid", "wx637bd6f7314daa46"); - param.put("mch_id", "1289663601"); - param.put("sub_mch_id" , "1614670195"); - param.put("nonce_str", WxUtils.makeNonStr()); - param.put("transaction_id", order.getPaySerialNo()); - param.put("out_refund_no", "HFR"+new Date().getTime()); - param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); - param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); - param.put("sign_type", "HMAC-SHA256"); - - String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); - param.put("sign", signStr); - - String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); - OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); -// if(orderRefundModel.getResult_code().equals("SUCCESS")) { -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo(orderRefundModel.getOut_refund_no()); -// order.setRefundId(orderRefundModel.getRefund_id()); -// order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); -// outRechargeOrderService.updateOrder(order); -// highRefundAudit.setStatus(1); -// highRefundAuditService.updateRefundAudit(highRefundAudit); -// } else { -// log.error("orderToPay error!", "退款失败"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); -// } - } - - // 工会卡退款 - if (order.getPayType() == 2) { - JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); - - if (jsonObject == null) { - log.error("orderToPay error!", "请求超时"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); - } - - JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); - -// if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo("HFR"+new Date().getTime() ); -// order.setRefundFee(order.getPayRealPrice()); -// order.setRefundId(dataObject.getString("orderId")); -// -// highRefundAudit.setStatus(1); -// highRefundAuditService.updateRefundAudit(highRefundAudit); -// outRechargeOrderService.updateOrder(order); -// -// } else { -// log.error("orderToPay error!", dataObject.getString("message")); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); -// } - } - - // 积分退款 - if (order.getPayType() == 3) { - if (highUserService.findGoldRepeat(3 , order.getId())) { - highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); - }else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); - } -// order.setStatus(5); - order.setRefundTime(new Date()); - order.setOutRefundNo("HFR"+new Date().getTime() ); - order.setRefundFee(order.getPayRealPrice()); - highRefundAudit.setStatus(1); - highRefundAuditService.updateRefundAudit(highRefundAudit); - outRechargeOrderService.updateOrder(order); - } - // 银联退款 - if (order.getPayType() == 4) { - // 订单退款 - JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); - if (!refund.getString("resultcode").equals("W6")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); - } - -// order.setStatus(5); - order.setRefundTime(new Date()); - order.setOutRefundNo(refund.getString("oriwtorderid")); - order.setRefundFee(order.getPayRealPrice()); - highRefundAudit.setStatus(1); - highRefundAuditService.updateRefundAudit(highRefundAudit); - outRechargeOrderService.updateOrder(order); - } - return ResponseMsgUtil.success("退款成功"); - } catch (Exception e) { - log.error("HighOrderController --> getUserOrderList() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - public String doRefundRequest(String mchId,String data) throws Exception { - - //小程序退款需要调用双向证书的认证 - CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); - try { - HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 - 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 = "/getOrderCountList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询时间订单统计") @@ -576,47 +361,4 @@ public class OutRechargeOrderController { } } - - @RequestMapping(value = "/getMobileRechargeByOrderId", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "话费再次充值充值") - public ResponseData getMobileRechargeByOrderId( - @RequestParam(name = "orderId", required = true) Long orderId) { - try { - - OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderId(orderId); -// if (rechargeOrderRecord == null) { -// rechargeOrderRecord = new OutRechargeOrderRecord(); -// // 查询订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// if (order.getRechargeType() == 1) { -// String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); -// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType()); -// if (object.getInteger("code") != 200) { -// order.setRechargeStatus(1); -// order.setAbnormalMsg(object.getString("message")); -// } -// outRechargeOrderService.updateOrder(order); -// rechargeOrderRecord.setRechargeOrderId(order.getId()); -// rechargeOrderRecord.setRechargeOrderNo(orderNo); -// rechargeOrderRecord.setCreateTime(new Date()); -// rechargeOrderRecord.setStatus(1); -// rechargeOrderRecordService.insertOrder(rechargeOrderRecord); -// } -// } else { -// // 查询订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); -// if (order.getStatus() == 2) { -// outRechargeOrderService.rechargeOrderToRefund(order.getId()); -// } -// } - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); - return ResponseMsgUtil.exception(e); - } - } - } diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java index 75ac6473..9d713f07 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java @@ -1,6 +1,5 @@ package com.bweb.controller; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -10,16 +9,21 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.RechargeConfig; +import com.hai.entity.BsOperationLog; import com.hai.entity.OutRechargePrice; -import com.hai.entity.SecDictionary; +import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.BsConfigService; +import com.hai.service.BsOperationLogService; import com.hai.service.CommonService; import com.hai.service.OutRechargePriceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -27,11 +31,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Controller @RequestMapping(value = "/outRechargePrice") @@ -47,7 +47,10 @@ public class OutRechargePriceController { private OutRechargePriceService outRechargePriceService; @Resource - private CommonService commonService; + private BsConfigService bsConfigService; + + @Resource + private BsOperationLogService bsOperationLogService; @RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET) @ResponseBody @@ -69,7 +72,7 @@ public class OutRechargePriceController { Map map = new HashMap<>(); map.put("operatorType", operatorType); - map.put("rechargePlatform", rechargePlatform); + map.put("rechargePlatform", "-" + rechargePlatform + "-"); map.put("rechargeType", rechargeType); map.put("rechargeWay", rechargeWay); map.put("status", status); @@ -80,7 +83,25 @@ public class OutRechargePriceController { List outRechargePrices = outRechargePriceService.getListRechargePrice(map); - return ResponseMsgUtil.success(new PageInfo<>(outRechargePrices)); + Map listMap; + + List outRechargePriceModelList = new ArrayList<>(); + + for (OutRechargePrice list : outRechargePrices) { + OutRechargePriceModel outRechargePriceModel = new OutRechargePriceModel(); + listMap = new HashMap<>(); + listMap.put("returnType", 2); + listMap.put("productType", "3"); + listMap.put("sourceId", list.getId()); + BeanUtils.copyProperties(list, outRechargePriceModel); + outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); + outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); + outRechargePriceModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap)); + outRechargePriceModelList.add(outRechargePriceModel); + + } + + return ResponseMsgUtil.success(new PageInfo<>(outRechargePriceModelList)); } catch (Exception e) { log.error("OutRechargePriceController --> getListUser() error!", e); return ResponseMsgUtil.exception(e); @@ -104,19 +125,33 @@ public class OutRechargePriceController { object.getJSONArray("productPlatform") == null || object.getInteger("rechargeType") == null || object.getJSONArray("payType") == null || - object.getInteger("rechargeWay") == null || - object.getBigDecimal("integralDiscount") == null + object.getInteger("rechargeWay") == null ) { log.error("OutRechargePriceController -> insertPrice() error!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + if (object.getBigDecimal("integralDiscount") == null) { + object.put("integralDiscount" , new BigDecimal(0)); + } + object.put("operatorId", userInfoModel.getSecUser().getId()); object.put("operatorName", userInfoModel.getSecUser().getLoginName()); object.put("companyId", userInfoModel.getBsCompany().getId()); outRechargePriceService.insertRechargePrice(object); + BsOperationLog bsOperationLog = new BsOperationLog(); + + bsOperationLog.setOperationType(1); + bsOperationLog.setBeforeContent(String.valueOf(object)); + bsOperationLog.setAfterContent("新增数据"); + bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId()); + bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName()); + bsOperationLog.setEntityName("OutRechargePrice"); + + bsOperationLogService.insertOperationLog(bsOperationLog); + return ResponseMsgUtil.success("新增成功"); } catch (Exception e) { @@ -135,52 +170,46 @@ public class OutRechargePriceController { UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); if (object == null || - object.getString("rechargePrices") == null || object.getLong("id") == null || + object.getJSONArray("rechargePrices") == null || object.getBigDecimal("discount") == null || object.getString("operatorType") == null || - object.getString("rechargePlatform") == null || + object.getJSONArray("rechargePlatform") == null || + object.getJSONArray("productPlatform") == null || object.getInteger("rechargeType") == null || - object.getString("payType") == null || - object.getString("rechargeWay") == null || - object.getString("platformType") == null || - object.getBigDecimal("integralDiscount") == null + object.getJSONArray("payType") == null || + object.getInteger("rechargeWay") == null ) { log.error("OutRechargePriceController -> insertPrice() error!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id")); + if (object.getBigDecimal("integralDiscount") == null) { + object.put("integralDiscount" , new BigDecimal(0)); + } + + OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(object.getLong("id")); if (outRechargePrice == null) { log.error("OutRechargePriceController -> updatePrice() error!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); } - outRechargePrice.setPayPrice(outRechargePrice.getRechargePrice().multiply(object.getBigDecimal("discount").divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP))); - outRechargePrice.setRechargeType(object.getInteger("rechargeType")); - outRechargePrice.setOperatorType(object.getInteger("operatorType")); - outRechargePrice.setRechargePlatform(object.getString("rechargePlatform")); - outRechargePrice.setRechargeWay(object.getInteger("rechargeWay")); - outRechargePrice.setUpdateTime(new Date()); - outRechargePrice.setStatus(3); - - outRechargePriceService.updateRechargePrice(outRechargePrice); - - JSONObject postObject = new JSONObject(); - postObject.put("payType", object.getString("payType")); - postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); - postObject.put("productPlatform", object.getString("productPlatform")); - postObject.put("operatorId", userInfoModel.getSecUser().getId()); - postObject.put("operatorName", userInfoModel.getSecUser().getLoginName()); - postObject.put("sourceId", outRechargePrice.getId()); - - // 配置支付方式 - commonService.configPayType(postObject); - // 配置积分折扣比例 - commonService.configPayType(postObject); - // 配置展示平台 - commonService.configPlatform(postObject); + object.put("operatorId", userInfoModel.getSecUser().getId()); + object.put("operatorName", userInfoModel.getSecUser().getLoginName()); + object.put("companyId", userInfoModel.getBsCompany().getId()); + outRechargePriceService.updateRechargePrice(object); + + BsOperationLog bsOperationLog = new BsOperationLog(); + + bsOperationLog.setOperationType(2); + bsOperationLog.setBeforeContent(String.valueOf(outRechargePrice)); + bsOperationLog.setAfterContent(String.valueOf(object)); + bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId()); + bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName()); + bsOperationLog.setEntityName("OutRechargePrice"); + + bsOperationLogService.insertOperationLog(bsOperationLog); return ResponseMsgUtil.success("修改成功"); @@ -196,8 +225,8 @@ public class OutRechargePriceController { public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { try { - OutRechargePrice outRechargePrice = outRechargePriceService.findById(id); - return ResponseMsgUtil.success(outRechargePrice); + OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id); + return ResponseMsgUtil.success(outRechargePriceModel); } catch (Exception e) { log.error("OutRechargePriceController --> findById() error!", e); @@ -220,16 +249,34 @@ public class OutRechargePriceController { } } - @RequestMapping(value = "/editPriceStatus", method = RequestMethod.GET) + @RequestMapping(value = "/editPriceStatus", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "修改价格状态") - public ResponseData editPriceStatus(@RequestParam(value = "id", required = true) Long id, - @RequestParam(value = "status", required = true) Integer status) { + public ResponseData editPriceStatus(@RequestBody JSONObject object, HttpServletRequest request) { try { - OutRechargePrice outRechargePrice = outRechargePriceService.findById(id); - outRechargePrice.setStatus(status); - outRechargePriceService.updateRechargePrice(outRechargePrice); + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id")); + if (object.getInteger("status") == 1 && outRechargePrice.getRechargePlatform().contains("-2-") && outRechargePrice.getGoodsId() == null) { + log.error("OutRechargePriceController -> editPriceStatus() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅平台需要输入商品编码!"); + } + + outRechargePrice.setStatus(object.getInteger("status")); + outRechargePriceService.editPriceStatus(outRechargePrice); + + BsOperationLog bsOperationLog = new BsOperationLog(); + + bsOperationLog.setOperationType(2); + bsOperationLog.setBeforeContent(String.valueOf(outRechargePrice)); + bsOperationLog.setAfterContent(String.valueOf(object)); + bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId()); + bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName()); + bsOperationLog.setEntityName("OutRechargePrice"); + + bsOperationLogService.insertOperationLog(bsOperationLog); return ResponseMsgUtil.success("修改成功"); @@ -239,4 +286,19 @@ public class OutRechargePriceController { } } + @RequestMapping(value = "/getProductsList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取产品") + public ResponseData getProductsList() { + try { + + + return ResponseMsgUtil.success(RechargeConfig.getProductsListByLy()); + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java deleted file mode 100644 index 86f1c12a..00000000 --- a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.bweb.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.pay.util.IOUtil; -import com.hai.common.pay.util.XmlUtil; -import com.hai.common.utils.*; -import com.hai.config.TelConfig; -import com.hai.entity.*; -import com.hai.enum_type.GoodsType; -import com.hai.enum_type.PayType; -import com.hai.model.ResponseData; -import com.hai.service.HighOrderService; -import com.hai.service.HighUserService; -import com.hai.service.TelApiService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; -import java.util.regex.Pattern; - -@RestController -@RequestMapping(value = "/telApi") -@Api(value = "电话费充值数据接口") -public class TelApiController { - private static Logger log = LoggerFactory.getLogger(TelApiController.class); - - @Resource - private TelApiService telApiService; - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighUserService highUserService; - - /** - * 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700,173,199 - **/ - private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|77|73|99|8[019])\\d{8}$)|(^1700\\d{7}$)"; - - /** - * 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1709 - **/ - private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)"; - - /** - * 中国移动号码格式验证 - * 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705 - **/ - private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)"; - - - @RequestMapping(value = "/telPay", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "充值话费") - public ResponseData certification(@RequestBody HighTelOrder highTelOrder) { - try { - - if (StringUtils.isBlank(highTelOrder.getTel()) || - highTelOrder.getPrice() == null - ) { - log.error("telApi -> telPay() error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - int random = (int) (1 + Math.random() * (999999 - 100000 + 1)); - - Map map = new HashMap<>(); - - String mchid = "HFb44f8_10004"; - String tel = highTelOrder.getTel(); - String orderid = "HF" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); - BigDecimal price = BigDecimal.valueOf(highTelOrder.getPrice()); - String teltype = isChinaMobilePhoneNum(highTelOrder.getTel()).toString(); - int timeout = 300; - String notify = "notify"; - String time = String.valueOf(new Date().getTime()); - String APIKEY = "483e5a68fe9bda2f7ab3f2665a0006cd"; - String sign = mchid + tel + price + orderid + teltype + notify + time + random + APIKEY; - - String param = "mchid=" + mchid + - "&tel=" + tel + - "&orderid=" + orderid + - "&price=" + price + - "&teltype=" + teltype + - "¬ify=" + notify + - "&time=" + time + - "&rand=" + random + - "&sign=" + MD5Util.encode(sign.getBytes()); - map.put("from", param); - - JSONObject object = HttpsUtils.doSmsPost("http://45.130.154.125:9998/api/telpay", map, new HashMap<>()); - return ResponseMsgUtil.success(object); - } catch (Exception e) { - log.error("HighMerchantController -> insertMerchant() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/notify", method = RequestMethod.POST) - @ApiOperation(value = "话费充值 -> 异步回调") - public void wechatNotify(HttpServletRequest request, HttpServletResponse response) { - try { - - log.info("话费充值 -> 异步通知:处理开始"); - - String notifyXml = null; // 话费充值系统发送的数据(格式) - notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8"); - - log.info("话费充值系统发送的数据:" + notifyXml); - SortedMap map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8"); - -// resXml = notifyService.wechatNotify(map); -// -// -// BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); -// out.write(resXml.getBytes()); -// out.flush(); -// out.close(); - log.info("话费充值 -> 异步通知:处理完成"); - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - /** - * 查询电话属于哪个运营商 - * - * @param tel 手机号码 - * @return 0:不属于任何一个运营商,0:移动,1:联通,2:电信 99: 什么都不是 - */ - public Integer isChinaMobilePhoneNum(String tel) { - boolean b1 = tel != null && !tel.trim().equals("") && match(CHINA_MOBILE_PATTERN, tel); - if (b1) { - return 0; - } - b1 = tel != null && !tel.trim().equals("") && match(CHINA_UNICOM_PATTERN, tel); - if (b1) { - return 1; - } - b1 = tel != null && !tel.trim().equals("") && match(CHINA_TELECOM_PATTERN, tel); - if (b1) { - return 2; - } - return 99; - } - - /** - * 匹配函数 - * - * @param regex - * @param tel - * @return - */ - private static boolean match(String regex, String tel) { - return Pattern.matches(regex, tel); - } - - - @RequestMapping(value = "/getMemberGoods", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "获取渠道商获取关联商品") - public ResponseData getMemberGoods() { - try { - - JSONObject data = TelConfig.getMemberGoods(); - - return ResponseMsgUtil.success(data); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getTest", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "测试接口") - public ResponseData getTest() { - try { - - - return ResponseMsgUtil.success("1"); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index f8d72008..8f932e5a 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -135,7 +135,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/sms/*") .excludePathPatterns("/SendSms/*") .excludePathPatterns("/czOrder/*") - .excludePathPatterns("/outRechargeOrder/*") + .excludePathPatterns("/outRechargePrice/*") .excludePathPatterns("/userDiscount/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index ca563108..fae8221e 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -1,46 +1,23 @@ package com.cweb.controller; import com.alibaba.fastjson.JSONObject; -import com.cweb.config.SysConst; -import com.cweb.config.WxMsgConfig; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.common.pay.WechatPayUtil; -import com.hai.common.pay.entity.WeChatPayReqInfo; -import com.hai.common.pay.util.HttpReqUtil; -import com.hai.common.pay.util.MD5Util; -import com.hai.common.pay.util.XmlUtil; -import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; -import com.hai.config.CommonSysConst; -import com.hai.config.UnionPayConfig; -import com.hai.dao.SecDictionaryMapper; +import com.hai.config.RechargeConfig; import com.hai.entity.*; import com.hai.enum_type.DiscountUseScope; -import com.hai.enum_type.GoodsType; -import com.hai.enum_type.PayType; -import com.hai.model.HighUserModel; -import com.hai.model.OrderRefundModel; -import com.hai.model.ResponseData; -import com.hai.model.ResultProfitSharing; +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.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -50,8 +27,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; -import java.util.concurrent.ThreadLocalRandom; @Controller @RequestMapping(value = "/outRechargeOrder") @@ -65,645 +42,278 @@ public class OutRechargeOrderController { @Resource private OutRechargeOrderService outRechargeOrderService; - @Resource - private HighOrderService highOrderService; - @Resource private OutRechargePriceService outRechargePriceService; @Resource - private WechatPayUtil wechatPayUtil; + private SecConfigService secConfigService; @Resource - private GoodsOrderServiceImpl goodsOrderService; + private HighUserCardService highUserCardService; @Resource - private HighProfitSharingRecordService highProfitSharingRecordService; + private HighUserPayPasswordService highUserPayPasswordService; @Resource - private SecConfigService secConfigService; + private HighDiscountUserRelService highDiscountUserRelService; @Resource - private HighUserCardService highUserCardService; + private BsConfigService bsConfigService; @Resource - private HighUserPayPasswordService highUserPayPasswordService; + private RechargeConfig rechargeConfig; + + @RequestMapping(value="/addOrder",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "增加订单") + public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + + if (StringUtils.isBlank(object.getString("rechargeContent")) || + StringUtils.isBlank(object.getString("regionId")) || + object.getLong("goodsId") == null + ) { + log.error("addOrder error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); + + // 产品id + Long goodsId = object.getLong("goodsId"); + + // 充值内容 + String rechargeContent = object.getString("rechargeContent"); + + // 查询产品详情 + OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId); + + Map listMap = new HashMap<>(); + listMap.put("productType", "3"); + listMap.put("returnType", 1); + listMap.put("sourceId", goodsId); + + // 查询产品积分抵扣比例 + BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap); + + // 判断充值系统是否关闭 + if (!secConfigService.isConfig("RECHARGE" , "1")) { + log.error("addOrder error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); + } + + HighDiscountUserRel highDiscountUserRel = null; + // 判断是否有优惠券 + if (object.getLong("memDiscountId") != null) { + // 卡优惠券信息 + highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId")); + if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { + log.error("HighOrderController --> addOrder() error!", "优惠券状态错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); + } + if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType()) + && !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { + log.error("HighOrderController --> addOrder() error!", "无法使用此优惠券"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券"); + } + } + + // 优惠券抵扣 + if (highDiscountUserRel != null) { + outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); + + // 卡卷类型 1:满减 2:抵扣 3:折扣 + if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { + // 如果商品支付总额 小于 满减价格 + if (outRechargePrice.getPayPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) { + log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券"); + } + // 计算支付金额 = 商品支付总额 - 满减额度 + BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); + + outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); + // 如果总额小于0 + if (payPrice.compareTo(new BigDecimal("0")) < 0) { + outRechargeOrder.setPayRealPrice(new BigDecimal("0")); + } else { + outRechargeOrder.setPayRealPrice(payPrice); + } + } + + // 卡卷类型 1:满减 2:抵扣 3:折扣 + if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { + // 计算支付金额 = 商品支付总额 - 满减额度 + BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); + outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); + + // 如果总额小于0 + if (payPrice.compareTo(new BigDecimal("0")) < 0) { + outRechargeOrder.setPayRealPrice(new BigDecimal("0")); + } else { + outRechargeOrder.setPayRealPrice(payPrice); + } + } + + // 卡卷类型 1:满减 2:抵扣 3:折扣 + if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { + BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); + // 订单总额 * 折扣 + BigDecimal payPrice = outRechargePrice.getPayPrice().multiply(discountPrice); + outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getPayPrice().subtract(payPrice)); + outRechargeOrder.setPayRealPrice(payPrice); + } + } + + // 判断积分数量是否大于0 + if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) { + + + + // 积分抵扣金额 + BigDecimal integralDeductionPrice = BigDecimal.valueOf(object.getLong("integralNum") / 100); + // 最高可抵扣金额 + BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_DOWN); + // 判读积分是否大于限制额度 + if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) > 0) { + log.error("HighOrderController --> addOrder() error!", "积分大于限制额度"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单最大抵扣积分数量" + object.getLong("integralNum")); + } + + // 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额 + if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) { + // 查询用户支付密码 + HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId()); + if (userPayPassword == null) { + log.error("orderToPay error!", "未设置支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); + } + if (StringUtils.isBlank(object.getString("password"))) { + log.error("orderToPay error!", "未输入支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); + } + // 校验支付密码 + if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) { + log.error("orderToPay error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); + } + } + + outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice); + outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice())); + + } + + outRechargeOrder.setUserId(userInfoModel.getHighUser().getId()); + outRechargeOrder.setRechargeContent(rechargeContent); + outRechargeOrder.setRegionId(object.getString("regionId")); + outRechargeOrder.setUserName(userInfoModel.getHighUser().getName()); + outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); + outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone()); + outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); + outRechargeOrder.setCreateTimed(new Date()); + + // 判断积分支付是否扣完金额 + if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { + // 201:充值中 202:充值成功 203:充值失败 204:未充值 + outRechargeOrder.setRechargeStatus(201); + // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + outRechargeOrder.setPayStatus(102); + } else { + // 201:充值中 202:充值成功 203:充值失败 204:未充值 + outRechargeOrder.setRechargeStatus(204); + // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + outRechargeOrder.setPayStatus(101); + } + + outRechargeOrderService.insertOrder(outRechargeOrder); + return ResponseMsgUtil.success(outRechargeOrder); + + } catch (Exception e) { + log.error("HighOrderController -> addOrder() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询订单详情") + public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) { + try { + + return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId)); + + } catch (Exception e) { + log.error("HighOrderController --> getOrderById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "取消订单") + public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) { + try { + + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); + + if (outRechargeOrder.getRechargeStatus() == 1) { + outRechargeOrderService.cancelOrder(orderId); + } else { + log.error("orderToPay error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("HighOrderController --> cancelOrder() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取用户订单") + public ResponseData getUserOrderList( + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "rechargeModel", required = false) String rechargeModel, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + map.put("userId", userInfoModel.getHighUser().getId().toString()); + if (status != null) { + map.put("status", status.toString()); + } + if (StringUtils.isNotBlank(orderNo)) { + map.put("orderNo", orderNo); + } + if (StringUtils.isNotBlank(rechargeModel)) { + map.put("rechargeModel", rechargeModel); + } + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map))); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } - @Resource - private UnionPayConfig unionPayConfig; - @Resource - private HighDiscountUserRelService highDiscountUserRelService; -// -// @RequestMapping(value="/addOrder",method = RequestMethod.POST) -// @ResponseBody -// @ApiOperation(value = "增加订单") -// public ResponseData addOrder(@RequestBody OutRechargeOrder outRechargeOrder, HttpServletRequest request) { -// try { -// -// // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// if (StringUtils.isBlank(outRechargeOrder.getRechargeContent()) || -// outRechargeOrder.getPayPrice() == null || -// outRechargeOrder.getObjectId() == null || -// outRechargeOrder.getOrderPrice() == null -// ) { -// log.error("addOrder error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// -// if (!secConfigService.isConfig("RECHARGE" , "1")) { -// log.error("addOrder error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); -// } -// -// String remarks = ""; -// // 支付类型 1.微信支付 -// outRechargeOrder.setPayType(1); -// // 判断充值模式:1 电信 2. 移动 3. 联通 -// // 拼接内容 -// remarks = outRechargeOrder.getRechargeContent() + "充值" + outRechargeOrder.getOrderPrice() + "元"; -// -// HighDiscountUserRel highDiscountUserRel = null; -// if (outRechargeOrder.getMemDiscountId() != null) { -// // 卡优惠券信息 -// highDiscountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); -// if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { -// log.error("HighOrderController --> addOrder() error!", "优惠券状态错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); -// } -// if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType()) -// && !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { -// log.error("HighOrderController --> addOrder() error!", "无法使用此优惠券"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券"); -// } -// } -// -// // 优惠券抵扣 -// if (highDiscountUserRel != null) { -// outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); -// -// // 卡卷类型 1:满减 2:抵扣 3:折扣 -// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { -// // 如果订单总额 小于 满减价格 -// if (outRechargeOrder.getOrderPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) { -// log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券"); -// } -// // 订单总额 - 满减额度 -// BigDecimal payPrice = outRechargeOrder.getOrderPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); -// -// outRechargeOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); -// // 如果总额小于0 -// if (payPrice.compareTo(new BigDecimal("0")) == -1) { -// outRechargeOrder.setPayPrice(new BigDecimal("0")); -// } else { -// outRechargeOrder.setPayPrice(payPrice); -// } -// } -// -// // 卡卷类型 1:满减 2:抵扣 3:折扣 -// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { -// // 订单总额 - 满减额度 -// BigDecimal payPrice = outRechargeOrder.getOrderPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); -// outRechargeOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); -// -// // 如果总额小于0 -// if (payPrice.compareTo(new BigDecimal("0")) == -1) { -// outRechargeOrder.setPayPrice(new BigDecimal("0")); -// } else { -// outRechargeOrder.setPayPrice(payPrice); -// } -// } -// -// // 卡卷类型 1:满减 2:抵扣 3:折扣 -// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { -// BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); -// // 订单总额 * 折扣 -// BigDecimal payPrice = outRechargeOrder.getOrderPrice().multiply(discountPrice); -// outRechargeOrder.setDeductionPrice(outRechargeOrder.getOrderPrice().subtract(payPrice)); -// outRechargeOrder.setPayPrice(payPrice); -// } -// } -// -// OutRechargePrice outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getObjectId().longValue()); -// -// HighUserCard highUserCard = highUserCardService.getUserHtlCardNo(userInfoModel.getHighUser().getId()); -// if (highUserCard != null) { -// outRechargeOrder.setIdCard(highUserCard.getCardNo()); -// } -// outRechargeOrder.setRemarks(remarks); -// outRechargeOrder.setRechargeName(remarks); -// outRechargeOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); -// outRechargeOrder.setUserId(userInfoModel.getHighUser().getId()); -// outRechargeOrder.setUserName(userInfoModel.getHighUser().getName()); -// outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); -// outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone()); -// -// outRechargeOrder.setCreateTimed(new Date()); -// outRechargeOrder.setStatus(1); -// outRechargeOrderService.insertOrder(outRechargeOrder); -// return ResponseMsgUtil.success(outRechargeOrder); -// -// } catch (Exception e) { -// log.error("HighOrderController -> addOrder() error!",e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// -// @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "根据id查询订单详情") -// public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) { -// try { -// -// return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId)); -// -// } catch (Exception e) { -// log.error("HighOrderController --> getOrderById() error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "取消订单") -// public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) { -// try { -// -// OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); -// -// if (outRechargeOrder.getStatus() == 1) { -// outRechargeOrderService.cancelOrder(orderId); -// } else { -// log.error("orderToPay error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); -// } -// -// return ResponseMsgUtil.success("操作成功"); -// -// } catch (Exception e) { -// log.error("HighOrderController --> cancelOrder() error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// @RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "获取用户订单") -// public ResponseData getUserOrderList( -// @RequestParam(name = "status", required = false) Integer status, -// @RequestParam(name = "orderNo", required = false) String orderNo, -// @RequestParam(name = "rechargeModel", required = false) String rechargeModel, -// @RequestParam(name = "pageNum", required = true) Integer pageNum, -// @RequestParam(name = "pageSize", required = true) Integer pageSize, -// HttpServletRequest request) { -// try { -// -// // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// -// Map map = new HashMap<>(); -// map.put("userId", userInfoModel.getHighUser().getId().toString()); -// if (status != null) { -// map.put("status", status.toString()); -// } -// if (StringUtils.isNotBlank(orderNo)) { -// map.put("orderNo", orderNo); -// } -// if (StringUtils.isNotBlank(rechargeModel)) { -// map.put("rechargeModel", rechargeModel); -// } -// -// PageHelper.startPage(pageNum,pageSize); -// return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map))); -// -// } catch (Exception e) { -// log.error("HighOrderController --> getUserOrderList() error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// -// @RequestMapping(value="/orderToPay",method = RequestMethod.POST) -// @ResponseBody -// @ApiOperation(value = "订单支付发起支付") -// public ResponseData orderToPay(@RequestBody String reqBodyStr) { -// try { -// if (StringUtils.isBlank(reqBodyStr)) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); -// Long orderId = jsonObject.getLong("orderId"); -// Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 -// String openId = jsonObject.getString("openId"); // openId -// if (orderId == null || StringUtils.isBlank(openId)) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// -// // 订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// if (order == null) { -// log.error("orderToPay error!", "未找到订单信息"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); -// } -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 -// if (order.getStatus() != 1) { -// log.error("orderToPay error!", "无法支付,订单不处于待支付状态"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); -// } -// -// Map map = new HashMap<>(); -// map.put("orderNo", order.getOrderNo()); -// map.put("payPrice", order.getPayPrice()); -// map.put("orderScene", "RECHARGE_ORDER"); -// map.put("body","充值话费"); -// map.put("subject","充值话费"); -// -// //微信支付 -// String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); -// int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); -// WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); -// weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id -// weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 -// if (openIdType != null && openIdType.equals(2)) { -// weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 -// } else { -// weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序 -// } -// weChatPayReqInfo.setSub_mch_id("1614670195"); -// weChatPayReqInfo.setSub_openid(openId); -// weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 -// weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 -// weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 -// weChatPayReqInfo.setTotal_fee(total_fee); //总金额 -// weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip -// weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url -// weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 -// weChatPayReqInfo.setAttach(map.get("orderScene").toString()); -// weChatPayReqInfo.setProfit_sharing("N"); -// //附加数据,区分订单类型 -// Map payMap = new HashMap<>(); -// -// payMap.put("app_id", weChatPayReqInfo.getSub_appid()); -// payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); -// payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); -// SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); -// return ResponseMsgUtil.success(sortedMap); -// } catch (Exception e) { -// log.error("orderToPay error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) -// @ResponseBody -// @ApiOperation(value = "工会卡支付") -// public ResponseData hltUnionCardPay(@RequestBody JSONObject body,HttpServletRequest request) { -// try { -// // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// -// if (body == null -// || body.getLong("orderId") == null -// || StringUtils.isBlank(body.getString("cardNo")) -// ) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// -// // 查询用户支付密码 -// HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId()); -// if (userPayPassword == null) { -// log.error("orderToPay error!", "未设置支付密码"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); -// } -// if (StringUtils.isBlank(body.getString("password"))) { -// log.error("hltUnionCardPay error!", "未输入支付密码"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); -// } -// // 校验支付密码是否一直 -// if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) { -// log.error("hltUnionCardPay error!", ""); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); -// } -// -// // 查询用户与卡号的关系 -// HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); -// if (userCard == null) { -// log.error("hltUnionCardPay() ERROR", "未绑定卡号"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); -// } -// -// // 订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId")); -// if (order == null) { -// log.error("hltUnionCardPay error!", "未找到订单信息"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); -// } -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 -// if (order.getStatus() != 1) { -// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); -// } -// -// outRechargeOrderService.hltUnionCardPay(userCard.getId(), order.getId()); -// -// return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId"))); -// } catch (Exception e) { -// log.error("hltUnionCardPay error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// @RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST) -// @ResponseBody -// @ApiOperation(value = "订单支付发起金币支付") -// public ResponseData orderToGoldPay(@RequestBody String reqBodyStr,HttpServletRequest request) { -// try { -// // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// -// if (StringUtils.isBlank(reqBodyStr)) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); -// Long orderId = jsonObject.getLong("orderId"); -// String password = jsonObject.getString("password"); -// -// if (orderId == null) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// -// // 查询用户支付密码 -// HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId()); -// if (userPayPassword == null) { -// log.error("orderToPay error!", "未设置支付密码"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); -// } -// if (StringUtils.isBlank(password)) { -// log.error("orderToPay error!", "未输入支付密码"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); -// } -// // 校验支付密码是否一直 -// if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) { -// log.error("orderToPay error!", ""); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); -// } -// -// // 订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// if (order == null) { -// log.error("hltUnionCardPay error!", "未找到订单信息"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); -// } -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 -// if (order.getStatus() != 1) { -// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); -// } -// -// outRechargeOrderService.goldPayOrder(userInfoModel.getHighUser().getId(), order.getId()); -// -// if (order.getRechargeType() == 1) { -// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType()); -// if (object.getInteger("code") != 200) { -// order.setRechargeStatus(1); -// order.setStatus(2); -// order.setPayType(3); -// order.setPayTime(new Date()); // 支付时间 -// order.setAbnormalMsg(object.getString("message")); -// outRechargeOrderService.updateOrder(order); -// } -// } -// -// return ResponseMsgUtil.success("充值成功"); -// } catch (Exception e) { -// log.error("orderToPay error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// -// -// -// @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) -// @ResponseBody -// @ApiOperation(value = "订单支付发起银联支付") -// public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) { -// try { -// // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// -// if (StringUtils.isBlank(reqBodyStr)) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); -// Long orderId = jsonObject.getLong("orderId"); -// -// if (orderId == null) { -// log.error("orderToPay error!", "参数错误"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// // 订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// if (order == null) { -// log.error("hltUnionCardPay error!", "未找到订单信息"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); -// } -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 -// if (order.getStatus() != 1) { -// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); -// } -// -// return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl(), request)); -// -// } catch (Exception e) { -// log.error("orderToPay error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// -// @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "分账") -// public ResponseData wxProfitsharing() { -// try { -// HighOrder order = highOrderService.getOrderByOrderNo("20211019173044475879505"); -// 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" , "1609882817"); // 个体户黎杨珍 -// 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.doRefundRequest(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); -// } -// } -// -// @RequestMapping(value = "/wxEndProfitsharing", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "完结分账") -// public ResponseData wxEndProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { -// try { -// -// HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); -// Map param = new LinkedHashMap<>(); -// param.put("appid", "wx637bd6f7314daa46"); -// param.put("mch_id", "1289663601"); -// param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 -// param.put("nonce_str" , WxUtils.makeNonStr()); -// param.put("transaction_id" , orderNo.getPaySerialNo()); -// param.put("out_order_no" , orderNo.getOrderNo()); -// param.put("description" , "系统自动完结分账"); -// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); -// param.put("sign" , signStr); -// -// String resultXmL = this.doRefundRequest2(param.get("mch_id"),"https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish", WxUtils.mapToXml(param)); -// // 请求分账返回的结果 -// ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); -// return ResponseMsgUtil.success(resultXmL); -// -// } catch (Exception e) { -// log.error("CmsContentController --> getCorporateAdvertising() error!", e); -// return ResponseMsgUtil.success(e); -// } -// } -// -// @RequestMapping(value = "/wxSelectProfitsharing", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "查询剩余分账金额") -// public ResponseData wxSelectProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { -// try { -// Map param = new LinkedHashMap<>(); -// param.put("mch_id", "1289663601"); -// //param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 -// param.put("transaction_id" , "4200001175202108102870717911"); -// ///param.put("out_order_no" , String.valueOf(new Date().getTime())); -// param.put("nonce_str" , WxUtils.makeNonStr()); -// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); -// param.put("sign", signStr); -// String unifiedXmL = WxUtils.mapToXml(param); -// return ResponseMsgUtil.success(HttpReqUtil.HttpsDefaultExecute("POST", "https://api.mch.weixin.qq.com/pay/profitsharingorderamountquery", null, unifiedXmL, null)); -// -// } catch (Exception e) { -// log.error("CmsContentController --> getCorporateAdvertising() error!", e); -// return ResponseMsgUtil.success(e); -// } -// } -// -// public String doRefundRequest(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(); -// } -// } -// -// public String doRefundRequest2(String mchId, String url, String data) throws Exception { -// -// //小程序退款需要调用双向证书的认证 -// CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); -// try { -// HttpPost httpost = new HttpPost(url); // 设置响应头信息 -// 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(); -// } -// } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java index 9eea4a2e..46cce46b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java @@ -12,6 +12,7 @@ import com.hai.entity.BsCompany; import com.hai.entity.HighAgent; import com.hai.entity.OutRechargePrice; import com.hai.entity.SecRegion; +import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.BsCompanyService; @@ -36,7 +37,7 @@ import java.util.List; import java.util.Map; @Controller - @RequestMapping(value = "/outRechargePrice") +@RequestMapping(value = "/outRechargePrice") @Api(value = "查询充值金额接口") public class OutRechargePriceController { @@ -54,39 +55,47 @@ public class OutRechargePriceController { @Resource private CommonService commonService; - @RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET) + @RequestMapping(value = "/getRechargePriceByList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询充值金额列表") - public ResponseData getListOutRechargePrice( - @RequestParam(value = "type", required = false) Integer type, + public ResponseData getRechargePriceByList( + @RequestParam(name = "platformId", required = true) Integer platformId, @RequestParam(name = "regionId", required = true) String regionId, - @RequestParam(name = "showType", required = true) Integer showType, - @RequestParam(name = "rechargeType", required = false) Integer rechargeType + @RequestParam(name = "operatorType", required = true) Integer operatorType, + @RequestParam(name = "rechargeType", required = true) Integer rechargeType ) { try { - Map map = new HashMap<>(); + + Map map = new HashMap<>(); SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId)); if (region != null) { BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); map.put("companyId", String.valueOf(bsCompany.getId())); } + map.put("platformId", platformId); + map.put("operatorType", operatorType); + map.put("rechargeType", rechargeType); - if (showType != null ) { - map.put("showType", String.valueOf(showType)); - } - if (rechargeType != null ) { - map.put("rechargeType", String.valueOf(rechargeType)); - } + return ResponseMsgUtil.success( outRechargePriceService.getRechargePriceByList(map)); + } catch (Exception e) { + log.error("OutRechargePriceController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } - if (type != null ) { - map.put("type", String.valueOf(type)); - } + @RequestMapping(value = "/findById", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询详情") + public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { + try { + + OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id); + return ResponseMsgUtil.success(outRechargePriceModel); - return ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map)); } catch (Exception e) { - log.error("OutRechargePriceController --> getListUser() error!", e); + log.error("OutRechargePriceController --> findById() error!", e); return ResponseMsgUtil.exception(e); } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java index e8f463e5..4c18fda8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java @@ -1,38 +1,29 @@ package com.cweb.controller.pay; import com.alibaba.fastjson.JSONObject; +import com.cweb.config.SysConst; import com.cweb.config.WxMsgConfig; 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.security.AESEncodeUtil; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.IDGenerator; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.common.utils.WxUtils; +import com.hai.common.pay.WechatPayUtil; +import com.hai.common.pay.entity.WeChatPayReqInfo; +import com.hai.common.pay.util.MD5Util; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.*; import com.hai.config.CommonSysConst; -import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.UnionPayConfig; -import com.hai.config.WxOrderConfig; import com.hai.dao.HighGasOrderRefundMapper; import com.hai.entity.*; -import com.hai.enum_type.GoodsType; -import com.hai.enum_type.PayType; import com.hai.enum_type.RechargePayType; -import com.hai.model.OrderRefundModel; +import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.util.EntityUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -43,10 +34,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; +import java.util.concurrent.ThreadLocalRandom; @Controller @RequestMapping(value = "/czOrder") @@ -55,6 +44,9 @@ public class CzOrderController { private static Logger log = LoggerFactory.getLogger(TuanYouController.class); + @Resource + private UserCenter userCenter; + @Resource private HighGasOrderRefundMapper highGasOrderRefundMapper; @@ -62,262 +54,312 @@ public class CzOrderController { private OutRechargeOrderService outRechargeOrderService; @Resource - private GoodsOrderServiceImpl goodsOrderService; + private OutRechargeChildOrderService outRechargeChildOrderService; + + @Resource + private BsRequestRecordService bsRequestRecordService; @Resource private HighUserService highUserService; @Resource - private HighDiscountUserRelService highDiscountUserRelService; + private UnionPayConfig unionPayConfig; @Resource - private HighDiscountAgentCodeService highDiscountAgentCodeService; + private HighUserCardService highUserCardService; @Resource - private OutRechargeOrderRecordService rechargeOrderRecordService; - -// @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST) -// @ApiOperation(value = "话费充值回调") -// @ResponseBody -// public void rechargeCallback(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { -// try { -// -// -// JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); -// -// HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund(); -// highGasOrderRefund.setCreateTime(new Date()); -// highGasOrderRefund.setReturnContent(String.valueOf(dataObject)); -// -// highGasOrderRefundMapper.insert(highGasOrderRefund); -// -// if (dataObject.getInteger("status") == 3) { -// OutRechargeOrder order; -// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id")); -// if (rechargeOrderRecord == null) { -// // 查询订单 -// order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id")); -// order.setStatus(3); -// order.setFinishTime(new Date()); -// outRechargeOrderService.updateOrder(order); -// } else { -// // 查询订单 -// order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); -// order.setStatus(3); -// order.setFinishTime(new Date()); -// outRechargeOrderService.updateOrder(order); -// } -// -// new Thread(() -> { -// HighUser highUser = highUserService.findByUserId(order.getUserId()); -// WxMsgConfig.rechargedSuccess( -// order.getRechargeName() + "充值成功", -// String.valueOf(order.getPayRealPrice()), -// order.getOrderNo(), -// order.getFinishTime(), -// RechargePayType.getNameByType(order.getPayType()), -// highUser.getOpenId()); -// }).start(); -// -// } else { -// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id")); -// if (rechargeOrderRecord == null) { -// rechargeOrderRecord = new OutRechargeOrderRecord(); -// // 查询订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id")); -// if (order.getStatus() == 2) { -// if (order.getRechargeType() == 1) { -// String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); -// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType()); -// if (object.getInteger("code") != 200) { -// order.setRechargeStatus(1); -// order.setAbnormalMsg(object.getString("message")); -// } -// outRechargeOrderService.updateOrder(order); -// rechargeOrderRecord.setRechargeOrderId(order.getId()); -// rechargeOrderRecord.setRechargeOrderNo(orderNo); -// rechargeOrderRecord.setCreateTime(new Date()); -// rechargeOrderRecord.setStatus(1); -// rechargeOrderRecordService.insertOrder(rechargeOrderRecord); -// } -// } -// -// } else { -// // 查询订单 -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); -// if (order.getStatus() == 2) { -// orderToRefund(order.getId()); -// order.setStatus(5); -// outRechargeOrderService.updateOrder(order); -// } -// } -// -// } -// -// response.setCharacterEncoding("UTF-8"); -// response.setContentType("text/html;charset=utf-8"); -// PrintWriter writer= response.getWriter(); -// writer.write("SUCCESS"); -// -// -// } catch (Exception e) { -// log.error("WechatPayController --> wechatNotify() error!", e); -// } -// } -// -// -// public Boolean orderToRefund(Long orderId) { -// try { -// -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中 -// if (order.getStatus() != 2) { -// log.error("orderToPay error!", "无法退款,订单状态错误!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); -// } -// -// // 微信退款 -// if (order.getPayType() == 1) { -// Map param = new HashMap<>(); -// param.put("appid", "wx637bd6f7314daa46"); -// param.put("mch_id", "1289663601"); -// param.put("sub_mch_id" , "1614670195"); -// param.put("nonce_str", WxUtils.makeNonStr()); -// param.put("transaction_id", order.getPaySerialNo()); -// param.put("out_refund_no", "HFR"+new Date().getTime()); -// param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); -// param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); -// param.put("sign_type", "HMAC-SHA256"); -// -// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); -// param.put("sign", signStr); -// -// String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); -// OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); -// -//// if(orderRefundModel.getResult_code().equals("SUCCESS")) { -//// order.setStatus(5); -//// order.setRefundTime(new Date()); -//// order.setOutRefundNo(orderRefundModel.getOut_refund_no()); -//// order.setRefundId(orderRefundModel.getRefund_id()); -//// order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); -//// outRechargeOrderService.updateOrder(order); -//// } else { -//// log.error("orderToPay error!", "退款失败"); -//// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); -//// } -// } -// -// // 工会卡退款 -// if (order.getPayType() == 2) { -// JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); -// -// if (jsonObject == null) { -// log.error("orderToPay error!", "请求超时"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); -// } -// -// JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); -// -// if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo("HFR"+new Date().getTime() ); -// order.setRefundFee(order.getPayRealPrice()); -// order.setRefundId(dataObject.getString("orderId")); -// outRechargeOrderService.updateOrder(order); -// -// } else { -// log.error("orderToPay error!", dataObject.getString("message")); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); -// } -// } -// -// // 积分退款 -// if (order.getPayType() == 3) { -// -// if (highUserService.findGoldRepeat(3 , order.getId())) { -// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); -// }else { -// log.error("orderToPay error!", "已有退款记录"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); -// } -// -// } -// -// // 银联退款 -// if (order.getPayType() == 4) { -// // 订单退款 -// JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); -// if (!refund.getString("resultcode").equals("W6")) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); -// } -// -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo(refund.getString("oriwtorderid")); -// order.setRefundFee(order.getPayRealPrice()); -// outRechargeOrderService.updateOrder(order); -// } -// -// if (order.getMemDiscountId() != null) { -// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); -// if (rel != null) { -// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 -// rel.setUseTime(null); -// highDiscountUserRelService.updateDiscountUserRel(rel); -// -// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); -// code.setStatus(2); -// highDiscountAgentCodeService.updateCode(code); -// } -// } -// -// new Thread(() -> { -// HighUser highUser = highUserService.findByUserId(order.getUserId()); -// WxMsgConfig.rechargedFail( -// "订单号:" + order.getOrderNo() + "-" + order.getRechargeName(), -// String.valueOf(order.getPayRealPrice()), -// highUser.getOpenId()); -// }).start(); -// -// return true; -// } catch (Exception e) { -// log.error("HighOrderController --> getUserOrderList() error!", e); -// return false; -// } -// } -// -// -// public String doRefundRequest(String mchId,String data) throws Exception { -// -// //小程序退款需要调用双向证书的认证 -// CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); -// try { -// HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 -// 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(); -// } -// } + private WechatPayUtil wechatPayUtil; + + @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) + @ApiOperation(value = "尖椒充值回调") + @ResponseBody + public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { + try { + + JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); + // 1 尖椒 2 龙阅 + dataObject.put("orderNo" , dataObject.getString("out_order_id")); + + OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id")); + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); + + BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo()); + + bsRequestRecord.setReturnContent(String.valueOf(dataObject)); + bsRequestRecord.setUpdateTime(new Date()); + bsRequestRecordService.updateRequestRecord(bsRequestRecord); + + // 判断是否充值成功 + if (dataObject.getInteger("status") == 3) { + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedSuccess( + rechargeOrder.getRechargeContent() + "充值成功", + String.valueOf(rechargeOrder.getPayRealPrice()), + rechargeOrder.getOrderNo(), + rechargeOrder.getFinishTime(), + RechargePayType.getNameByType(rechargeOrder.getPayType()), + highUser.getOpenId()); + }).start(); + } else { + callbackResult(childOrder , rechargeOrder); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + @RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST) + @ApiOperation(value = "龙阅充值回调") + @ResponseBody + public void rechargeCallbackByLy(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { + try { + JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); + // 1 尖椒 2 龙阅 + dataObject.put("orderNo" , dataObject.getString("out_trade_num")); + OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id")); + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); + + BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo()); + + bsRequestRecord.setReturnContent(String.valueOf(dataObject)); + bsRequestRecord.setUpdateTime(new Date()); + bsRequestRecordService.updateRequestRecord(bsRequestRecord); + + // 判断是否充值成功 + if (dataObject.getInteger("status") == 3) { + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedSuccess( + rechargeOrder.getRechargeContent() + "充值成功", + String.valueOf(rechargeOrder.getPayRealPrice()), + rechargeOrder.getOrderNo(), + rechargeOrder.getFinishTime(), + RechargePayType.getNameByType(rechargeOrder.getPayType()), + highUser.getOpenId()); + }).start(); + } else { + callbackResult(childOrder , rechargeOrder); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + // 回调结果处理 + private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception { + + // 101:充值成功 102: 充值中 103:充值失败 104 未充值 + // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { + + Date rechargeTime = rechargeOrder.getCreateTimed(); + Date currentTime = new Date(); + int hours = (int) ((rechargeTime.getTime() - currentTime.getTime()) / (1000 * 60 * 60)); + + // 判断快充 并且 充值时间小于6 + if (rechargeOrder.getRechargeType() == 1 && hours < 6) { + outRechargeOrderService.pollRequest(rechargeOrder); + return; + } + // 判断慢充 并且 充值时间小于72 + if (rechargeOrder.getRechargeType() == 2 && hours < 72) { + outRechargeOrderService.pollRequest(rechargeOrder); + return; + } + + outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId()); + + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedFail( + rechargeOrder.getRechargeContent() + "充值失败", + String.valueOf(rechargeOrder.getPayRealPrice()), + highUser.getOpenId()); + }).start(); + + } + + + } + + + @RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "微信订单支付发起支付") + public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) { + try { + if (StringUtils.isBlank(reqBodyStr)) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); + Long orderId = jsonObject.getLong("orderId"); + Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 + String openId = jsonObject.getString("openId"); // openId + if (orderId == null || StringUtils.isBlank(openId)) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 订单 + OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); + if (order == null) { + log.error("orderToPay error!", "未找到订单信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); + } + + // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 + if (order.getRechargeStatus() != 1) { + log.error("orderToPay error!", "无法支付,订单不处于待支付状态"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); + } + + Map map = new HashMap<>(); + map.put("orderNo", order.getOrderNo()); + map.put("payPrice", order.getPayRealPrice()); + map.put("orderScene", "RECHARGE_ORDER"); + map.put("body","充值话费"); + map.put("subject","充值话费"); + + //微信支付 + String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); + int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); + WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); + weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id + weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 + if (openIdType != null && openIdType.equals(2)) { + weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 + } else { + weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序 + } + weChatPayReqInfo.setSub_mch_id("1614670195"); + weChatPayReqInfo.setSub_openid(openId); + weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 + weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 + weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 + weChatPayReqInfo.setTotal_fee(total_fee); //总金额 + weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip + weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url + weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 + weChatPayReqInfo.setAttach(map.get("orderScene").toString()); + weChatPayReqInfo.setProfit_sharing("N"); + //附加数据,区分订单类型 + Map payMap = new HashMap<>(); + + payMap.put("app_id", weChatPayReqInfo.getSub_appid()); + payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); + payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); + SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); + return ResponseMsgUtil.success(sortedMap); + } catch (Exception e) { + log.error("orderToPay error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "工会卡支付") + public ResponseData hltUnionCardPay(@RequestBody JSONObject body,HttpServletRequest request) { + try { + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (body == null + || body.getLong("orderId") == null + || StringUtils.isBlank(body.getString("cardNo")) + ) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询用户与卡号的关系 + HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); + if (userCard == null) { + log.error("hltUnionCardPay() ERROR", "未绑定卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); + } + + // 订单 + OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId")); + + if (order == null) { + log.error("hltUnionCardPay error!", "未找到订单信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); + } + + // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 + if (order.getRechargeStatus() != 1) { + log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); + } + + outRechargeOrderService.hltUnionCardPay(userCard, order); + + return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId"))); + } catch (Exception e) { + log.error("hltUnionCardPay error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "订单支付发起银联支付") + public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) { + try { + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (StringUtils.isBlank(reqBodyStr)) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); + Long orderId = jsonObject.getLong("orderId"); + + if (orderId == null) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 订单 + OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); + if (order == null) { + log.error("hltUnionCardPay error!", "未找到订单信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); + } + + // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消 + if (order.getPayStatus() != 1) { + log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); + } + + return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl(), request)); + + } catch (Exception e) { + log.error("orderToPay error!", e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java index 2b821bb6..c9314579 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java @@ -209,17 +209,4 @@ public class WechatPayController { + body + ""; } - @RequestMapping(value = "/telApi", method = RequestMethod.GET) - @ApiOperation(value = "电话查询") - @ResponseBody - public ResponseData addLedgerReceiver(@RequestParam(value = "tel", required = true) String tel) { - try { - JSONObject jsonObject = telApiService.outApiTel(tel); - return ResponseMsgUtil.success(jsonObject.get("result")); - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - return ResponseMsgUtil.exception(e); - } - } - } 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 72794f3d..02c33605 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 @@ -406,5 +406,37 @@ public class WxUtils { } } + /** + * 生成龙阅签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 + * + * @param data 待签名数据 + * @param key API密钥 + * @param signType 签名方式 + * @return 签名 + */ + public static String generateSignatureLy(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/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 1efcef06..08e575ed 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -60,10 +60,15 @@ public class CommonSysConfig { private String telUrl; private String czOrderNotify; - private String CzNotifyUrl; - private String CzAppKey; - private String CzUrl; - private String CzAppSecret; + private String lyApiKey; + private String lyNotifyUrl; + private String lyMemberId; + private String LyPostUrl; + + private String JjNotifyUrl; + private String JjAppKey; + private String JjUrl; + private String JjAppSecret; private String unionAppId; private String unionSecret; @@ -397,36 +402,36 @@ public class CommonSysConfig { HltMembershipLevelSignCode = hltMembershipLevelSignCode; } - public String getCzNotifyUrl() { - return CzNotifyUrl; + public String getJjNotifyUrl() { + return JjNotifyUrl; } - public void setCzNotifyUrl(String czNotifyUrl) { - CzNotifyUrl = czNotifyUrl; + public void setJjNotifyUrl(String jjNotifyUrl) { + JjNotifyUrl = jjNotifyUrl; } - public String getCzAppKey() { - return CzAppKey; + public String getJjAppKey() { + return JjAppKey; } - public void setCzAppKey(String czAppKey) { - CzAppKey = czAppKey; + public void setJjAppKey(String jjAppKey) { + JjAppKey = jjAppKey; } - public String getCzUrl() { - return CzUrl; + public String getJjUrl() { + return JjUrl; } - public void setCzUrl(String czUrl) { - CzUrl = czUrl; + public void setJjUrl(String jjUrl) { + JjUrl = jjUrl; } - public String getCzAppSecret() { - return CzAppSecret; + public String getJjAppSecret() { + return JjAppSecret; } - public void setCzAppSecret(String czAppSecret) { - CzAppSecret = czAppSecret; + public void setJjAppSecret(String jjAppSecret) { + JjAppSecret = jjAppSecret; } public String getHsgDomainName() { @@ -436,4 +441,36 @@ public class CommonSysConfig { public void setHsgDomainName(String hsgDomainName) { this.hsgDomainName = hsgDomainName; } + + public String getLyApiKey() { + return lyApiKey; + } + + public void setLyApiKey(String lyApiKey) { + this.lyApiKey = lyApiKey; + } + + public String getLyMemberId() { + return lyMemberId; + } + + public void setLyMemberId(String lyMemberId) { + this.lyMemberId = lyMemberId; + } + + public String getLyPostUrl() { + return LyPostUrl; + } + + public void setLyPostUrl(String lyPostUrl) { + LyPostUrl = lyPostUrl; + } + + public String getLyNotifyUrl() { + return lyNotifyUrl; + } + + public void setLyNotifyUrl(String lyNotifyUrl) { + this.lyNotifyUrl = lyNotifyUrl; + } } diff --git a/hai-service/src/main/java/com/hai/config/RechargeConfig.java b/hai-service/src/main/java/com/hai/config/RechargeConfig.java new file mode 100644 index 00000000..96152a5c --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -0,0 +1,147 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.pay.util.sdk.WXPayConstants; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.MD5Util; +import com.hai.common.utils.WxUtils; +import com.hai.entity.OutRechargeChildOrder; +import com.hai.entity.OutRechargeOrder; +import com.hai.entity.OutRechargePrice; +import com.hai.service.OutRechargeChildOrderService; +import com.hai.service.OutRechargeOrderService; +import com.hai.service.OutRechargePriceService; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName TelConfig + * @Author Sum1Dream + * @Version 1.0.0 + * @Description // 充值接口 + * @Date 2021/7/18 14:18 + **/ +@Component +public class RechargeConfig { + + + /** + * @Author Sum1Dream + * @name getProductsList.java + * @Description // 获取龙阅产品 + * @Date 10:03 2022/5/24 + * @Param [] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getProductsListByLy() throws Exception { + Map paramMap = new HashMap<>(); + + paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); + paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); + + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/product", paramMap); + } + + /** + * @Author Sum1Dream + * @name rechargeOrderByLy.java + * @Description // 龙阅订单充值 + * @Date 09:57 2022/5/25 + * @Param [com.alibaba.fastjson.JSONObject] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject rechargeOrderByLy(JSONObject object) throws Exception { + + Map paramMap = new HashMap<>(); + + paramMap.put("out_trade_num" , object.getString("out_trade_num")); + paramMap.put("product_id" , object.getString("product_id")); + paramMap.put("mobile" , object.getString("mobile")); + paramMap.put("notify_url" , CommonSysConst.getSysConfig().getJjNotifyUrl()); + paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); + paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap); + + } + + + /** + * @Author Sum1Dream + * @name checkOrderByLy.java + * @Description // 龙阅查询订单结果 + * @Date 14:05 2022/5/24 + * @Param [com.alibaba.fastjson.JSONObject] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject checkOrderByLy(JSONObject object) throws Exception { + + Map paramMap = new HashMap<>(); + + paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); + paramMap.put("out_trade_nums" , object.getString("out_trade_nums")); + paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); + } + + /** + * @Author Sum1Dream + * @name rechargeOrderByJj.java + * @Description // 尖椒订单充值 + * @Date 09:57 2022/5/25 + * @Param [com.alibaba.fastjson.JSONObject] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject rechargeOrderByJj(JSONObject object) throws Exception { + + String timestamp = String.valueOf(System.currentTimeMillis()); + + Map map = new HashMap<>(); + map.put("mobile" , object.getString("mobile")); + map.put("amount" , object.getString("amount")); + map.put("out_order_id" , object.getString("out_order_id")); + map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey()); + map.put("timestamp" , timestamp.substring(0,timestamp.length()-3)); + map.put("is_fast" , object.getString("is_fast")); + map.put("notify_url" , CommonSysConst.getSysConfig().getJjNotifyUrl()); + + String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5); + + map.put("sign" , signStr); + + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "createOrder" , map); + + } + + /** + * @Author Sum1Dream + * @name checkOrderByJj.java + * @Description // 尖椒查询订单详情 + * @Date 09:57 2022/5/25 + * @Param [com.alibaba.fastjson.JSONObject] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject checkOrderByJj(JSONObject object) throws Exception { + + String timestamp = String.valueOf(System.currentTimeMillis()); + + Map map = new HashMap<>(); + map.put("out_order_id" , object.getString("out_order_id")); + map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey()); + map.put("timestamp" , timestamp.substring(0,timestamp.length()-3)); + map.put("notify_url" , CommonSysConst.getSysConfig().getLyNotifyUrl()); + + String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5); + + map.put("sign" , signStr); + + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "queryOrder" , map); + + } + +} diff --git a/hai-service/src/main/java/com/hai/config/TelConfig.java b/hai-service/src/main/java/com/hai/config/TelConfig.java deleted file mode 100644 index 1ccb332d..00000000 --- a/hai-service/src/main/java/com/hai/config/TelConfig.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.hai.config; - -import com.alibaba.fastjson.JSONObject; -import com.hai.common.utils.HttpsUtils; -import com.hai.common.utils.MD5Util; -import com.hai.entity.OutRechargeOrder; -import com.hai.entity.OutRechargePrice; -import com.hai.service.OutRechargeOrderService; -import com.hai.service.OutRechargePriceService; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.annotation.Resource; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @ClassName TelConfig - * @Author Sum1Dream - * @Version 1.0.0 - * @Description // 话费接口配置 - * @Date 2021/7/18 14:18 - **/ -public class TelConfig { - - public static JSONObject getMemberGoods() throws Exception { - Map map = new HashMap<>(); - - Long time = new Date().getTime(); - - String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time; - - map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey()); - map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId()); - map.put("time", time); - map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase()); - return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/getMemberGoods", map); - } - - public static JSONObject order(Map mapOrder) throws Exception { - - Map map = new HashMap<>(); - Long time = new Date().getTime(); - - String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time; - - for (Map.Entry entry : mapOrder.entrySet()) { - map.put(entry.getKey(), entry.getValue().toString()); - } - - map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey()); - map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId()); - map.put("time", time); - - map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase()); - return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/getMemberGoods", map); - } - - - public static JSONObject checkingOrder(Map mapOrder) throws Exception { - - Map map = new HashMap<>(); - Long time = new Date().getTime(); - - String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time; - - for (Map.Entry entry : mapOrder.entrySet()) { - map.put(entry.getKey(), entry.getValue().toString()); - } - - map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey()); - map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId()); - map.put("time", time); - - map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase()); - return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/order", map); - } - - -} diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapper.java b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapper.java index b749dd8f..ee3f3ae6 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapper.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapper.java @@ -106,4 +106,4 @@ public interface OutRechargeOrderRecordMapper extends OutRechargeOrderRecordMapp "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(OutRechargeOrderRecord record); -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapperExt.java b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapperExt.java index a0383b21..55d1828e 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapperExt.java @@ -4,4 +4,4 @@ package com.hai.dao; * mapper扩展类 */ public interface OutRechargeOrderRecordMapperExt { -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordSqlProvider.java b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordSqlProvider.java index c61228f9..269029f7 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordSqlProvider.java @@ -273,4 +273,4 @@ public class OutRechargeOrderRecordSqlProvider { sql.WHERE(sb.toString()); } } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java b/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java index 34643f45..4aef32e0 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java @@ -1,7 +1,50 @@ package com.hai.dao; +import com.hai.entity.OutRechargePrice; +import com.hai.entity.OutRechargePriceExample; +import com.hai.entity.SecPermission; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; +import java.util.Map; + /** * mapper扩展类 */ public interface OutRechargePriceMapperExt { -} \ No newline at end of file + + @Select({""}) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL), + @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_ platform", property="rechargePlatform", jdbcType=JdbcType.VARCHAR), + @Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_way", property="rechargeWay", jdbcType=JdbcType.INTEGER), + @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), + @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List getUserByPrice(@Param("param") Map param); + +} diff --git a/hai-service/src/main/java/com/hai/entity/BsOperationLog.java b/hai-service/src/main/java/com/hai/entity/BsOperationLog.java index 1da6ed97..a0b0708b 100644 --- a/hai-service/src/main/java/com/hai/entity/BsOperationLog.java +++ b/hai-service/src/main/java/com/hai/entity/BsOperationLog.java @@ -24,7 +24,7 @@ public class BsOperationLog implements Serializable { private String entityName; /** - * 操作类型:1;新增 2:修改 3:删除 + * 操作类型:1;新增 2:修改 3:查询 4:删除 */ private Integer operationType; @@ -238,4 +238,4 @@ public class BsOperationLog implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecord.java b/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecord.java index 01b7f927..703ecabb 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecord.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecord.java @@ -174,4 +174,4 @@ public class OutRechargeOrderRecord implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecordExample.java b/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecordExample.java index 23835dd8..120dc8d8 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecordExample.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecordExample.java @@ -740,4 +740,4 @@ public class OutRechargeOrderRecordExample { this(condition, value, secondValue, null); } } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java b/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java index 0447fc2f..0c9e21b9 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java @@ -30,7 +30,7 @@ public class OutRechargePrice implements Serializable { private Integer operatorType; /** - * 充值平台 1:尖椒 2:龙阅 (多个平台用,隔开) + * 充值平台 1:尖椒 2:龙阅 (多个平台用-隔开) */ private String rechargePlatform; diff --git a/hai-service/src/main/java/com/hai/enum_type/RechargePayType.java b/hai-service/src/main/java/com/hai/enum_type/RechargePayType.java index 6a8fb15d..30821581 100644 --- a/hai-service/src/main/java/com/hai/enum_type/RechargePayType.java +++ b/hai-service/src/main/java/com/hai/enum_type/RechargePayType.java @@ -4,10 +4,11 @@ import java.util.Objects; public enum RechargePayType { - payType1(1 , "微信"), - payType2(2 , "工会卡"), - payType3(3 , "积分"), - payType4(4 , "银联") + payType1(1 , "支付宝"), + payType2(2 , "微信"), + payType3(3 , "汇联通工会卡"), + payType4(4 , "银联"), + payType5(5 , "银联分期") ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/model/OutRechargePriceModel.java b/hai-service/src/main/java/com/hai/model/OutRechargePriceModel.java new file mode 100644 index 00000000..07147426 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/OutRechargePriceModel.java @@ -0,0 +1,40 @@ +package com.hai.model; + +import com.hai.entity.OutRechargePrice; + +import java.math.BigDecimal; + +public class OutRechargePriceModel extends OutRechargePrice { + // 抵扣比例 + private BigDecimal integralDiscount; + + // 产品展示平台 + private String productPlatformString; + + // 产品支付方式 + private String productPayTypeString; + + public BigDecimal getIntegralDiscount() { + return integralDiscount; + } + + public void setIntegralDiscount(BigDecimal integralDiscount) { + this.integralDiscount = integralDiscount; + } + + public String getProductPlatformString() { + return productPlatformString; + } + + public void setProductPlatformString(String productPlatformString) { + this.productPlatformString = productPlatformString; + } + + public String getProductPayTypeString() { + return productPayTypeString; + } + + public void setProductPayTypeString(String productPayTypeString) { + this.productPayTypeString = productPayTypeString; + } +} diff --git a/hai-service/src/main/java/com/hai/service/BsConfigService.java b/hai-service/src/main/java/com/hai/service/BsConfigService.java new file mode 100644 index 00000000..5c97c2c5 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/BsConfigService.java @@ -0,0 +1,48 @@ +package com.hai.service; + +import com.hai.entity.BsProductDiscount; +import com.hai.entity.BsProductPayType; +import com.hai.entity.BsProductPlatform; + +import java.util.Map; + +/** + * @author Sum1Dream + * @version 1.0.0 + * @serviceName BsProductDiscountService.java + * @Description // 查询配置参数 + * @createTime 14:14 2022/5/23 + **/ +public interface BsConfigService { + + /** + * @return com.hai.entity.BsProductDiscount + * @Author Sum1Dream + * @name getProductDiscountByMap.java + * @Description // 查询积分配置 + * @Date 14:16 2022/5/23 + * @Param [java.util.Map] + */ + BsProductDiscount getProductDiscountByMap(Map map); + + /** + * @return com.hai.entity.BsProductPlatform + * @Author Sum1Dream + * @name getProductPlatformByMap.java + * @Description // 查询展示平台 + * @Date 14:18 2022/5/23 + * @Param [java.util.Map] + */ + String getProductPlatformByMap(Map map); + + /** + * @Author Sum1Dream + * @name geProductPayTypeByMap.java + * @Description // 查询支付方式 + * @Date 14:20 2022/5/23 + * @Param [java.util.Map] + * @return java.lang.String + */ + String getProductPayTypeByMap(Map map); + +} diff --git a/hai-service/src/main/java/com/hai/service/BsOperationLogService.java b/hai-service/src/main/java/com/hai/service/BsOperationLogService.java new file mode 100644 index 00000000..c4fc7bb1 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/BsOperationLogService.java @@ -0,0 +1,36 @@ +package com.hai.service; + +import com.alibaba.fastjson.JSONObject; +import com.hai.entity.BsOperationLog; +import com.hai.entity.OutRechargePrice; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName BsOperationLogService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 操作日志 + * @createTime 11:02 2022/5/24 + **/ +public interface BsOperationLogService { + + /** + * @Author Sum1Dream + * @Description //查询列表 Administrator + * @Date 17:38 2021/6/12 + * @Param [map] + * @return java.util.List + **/ + List getListOperationLog(Map map); + + /** + * @Author Sum1Dream + * @Description //新增 Administrator + * @Date 17:40 2021/6/12 + * @Param [outRechargePrice] + * @return void + **/ + void insertOperationLog(BsOperationLog bsOperationLog); +} diff --git a/hai-service/src/main/java/com/hai/service/BsRequestRecordService.java b/hai-service/src/main/java/com/hai/service/BsRequestRecordService.java new file mode 100644 index 00000000..95e619ba --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/BsRequestRecordService.java @@ -0,0 +1,45 @@ +package com.hai.service; + +import com.hai.entity.BsRequestRecord; + + +/** + * @serviceName BsRequestRecordService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 请求记录 + * @createTime 11:02 2022/5/25 + **/ +public interface BsRequestRecordService { + + /** + * @Author Sum1Dream + * @name insertRequestRecord.java + * @Description // 插入请求记录 + * @Date 11:03 2022/5/25 + * @Param [com.hai.entity.BsRequestRecord] + * @return void + */ + void insertRequestRecord(BsRequestRecord bsRequestRecord); + + /** + * @Author Sum1Dream + * @name updateRequestRecord.java + * @Description // 更新请求记录 + * @Date 11:03 2022/5/25 + * @Param [com.hai.entity.BsRequestRecord] + * @return void + */ + void updateRequestRecord(BsRequestRecord bsRequestRecord); + + /** + * @Author Sum1Dream + * @name findRequestRecordBySourceId.java + * @Description // 查询请求详情 + * @Date 15:25 2022/5/25 + * @Param [java.String.String] + * @return com.hai.entity.BsRequestRecord + */ + BsRequestRecord findRequestRecordByOrderNo(String orderNo); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighTestService.java b/hai-service/src/main/java/com/hai/service/HighTestService.java deleted file mode 100644 index af3cb659..00000000 --- a/hai-service/src/main/java/com/hai/service/HighTestService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.hai.service; - -import com.alibaba.fastjson.JSONObject; - -/** - * @serviceName HltMerchantService.java - * @author Sum1Dream - * @version 1.0.0 - * @Description // 测试接口 - * @createTime 11:46 上午 2021/12/15 - **/ -public interface HighTestService { - - /** - * @Author Sum1Dream - * @name getReadFile.java - * @Description //读取文件 - * @Date 5:31 下午 2021/12/16 - * @Param [] - * @return void - */ - void getReadFile() throws Exception; - - - /** - * @Author Sum1Dream - * @name getUserDiscount.java - * @Description // 赠送用户卡券 - * @Date 7:14 下午 2021/12/24 - * @Param [] - * @return void - */ - void getUserDiscount(Long id) throws Exception; - - /** - * @Author Sum1Dream - * @name getMobile.java - * @Description // 请求话费 - * @Date 5:02 下午 2022/1/17 - * @Param [java.lang.String] - * @return com.alibaba.fastjson.JSONObject - */ - JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception; - - /** - * @Author Sum1Dream - * @name findByLatAndLng.java - * @Description // 获取定位信息 - * @Date 10:59 2022/4/2 - * @Param [java.lang.String, java.lang.String] - * @return com.alibaba.fastjson.JSONObject - */ - JSONObject findByLatAndLng( String lng , String lat) throws Exception; - -} diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java b/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java similarity index 71% rename from hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java rename to hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java index 92cd9122..86db1648 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java @@ -1,11 +1,13 @@ package com.hai.service; +import com.hai.entity.OutRechargeChildOrder; import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrderRecord; import java.util.List; +import java.util.Map; -public interface OutRechargeOrderRecordService { +public interface OutRechargeChildOrderService { /** * @Author Sum1Dream @@ -15,7 +17,7 @@ public interface OutRechargeOrderRecordService { * @Param [] * @return java.util.List */ - List getListRechargeOrderRecord(); + List getListRechargeChildOrder(Map map); /** * @Author Sum1Dream @@ -25,17 +27,17 @@ public interface OutRechargeOrderRecordService { * @Param [Long id] * @return com.hai.entity.OutRechargeOrderRecord */ - OutRechargeOrderRecord findById(Long id); + OutRechargeChildOrder findById(Long id); /** * @Author Sum1Dream * @name findById.java - * @Description // 根据订单ID查询 + * @Description // 根据订单号查询 * @Date 2:32 下午 2022/2/11 * @Param [Long id] * @return com.hai.entity.OutRechargeOrderRecord */ - OutRechargeOrderRecord findByOrderNo(String orderNo); + OutRechargeChildOrder findByOrderNo(String orderNo); /** * @Author Sum1Dream @@ -45,7 +47,7 @@ public interface OutRechargeOrderRecordService { * @Param [Long id] * @return com.hai.entity.OutRechargeOrderRecord */ - OutRechargeOrderRecord findByOrderId(Long orderId); + OutRechargeChildOrder findByOrderId(Long orderId); /*** * @Author Sum1Dream @@ -54,7 +56,7 @@ public interface OutRechargeOrderRecordService { * @Param [rechargeOrderRecord] * @return void **/ - void insertOrder(OutRechargeOrderRecord rechargeOrderRecord); + void insertOrder(OutRechargeChildOrder rechargeChildOrder); /*** * @Author Sum1Dream @@ -63,6 +65,6 @@ public interface OutRechargeOrderRecordService { * @Param [rechargeOrderRecord] * @return void **/ - void updateOrder(OutRechargeOrderRecord rechargeOrderRecord); + void updateOrder(OutRechargeChildOrder rechargeChildOrder); } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index c5bdeab8..f46d8caf 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; +import com.hai.entity.HighUserCard; import com.hai.entity.OutRechargeOrder; import com.hai.model.OrderCountModel; import com.hai.model.OutOrderModel; @@ -48,7 +49,7 @@ public interface OutRechargeOrderService { * @Param [outRechargeOrder] * @return void **/ - void insertOrder(OutRechargeOrder outRechargeOrder); + void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception; /*** * @Author Sum1Dream @@ -114,17 +115,15 @@ public interface OutRechargeOrderService { List getUserCountList(Map map) throws Exception; /** - * 汇联通支付 - * @param orderId - */ - void hltUnionCardPay(Long userCardId, Long orderId) throws Exception; + * @Author Sum1Dream + * @name hltUnionCardPay.java + * @Description // 汇联通支付 + * @Date 17:21 2022/5/25 + * @Param [java.lang.Long, com.hai.entity.OutRechargeOrder] + * @return void + */ + void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception; - /** - * 积分支付 - * @param userId - * @param orderId - */ - void goldPayOrder(Long userId, Long orderId) throws Exception; /** * @Author Sum1Dream @@ -146,16 +145,6 @@ public interface OutRechargeOrderService { */ OrderCountModel rechargeOrderByIndex(Integer code); - /** - * @Author Sum1Dream - * @name getMobile.java - * @Description // 请求话费充值 - * @Date 5:02 下午 2022/1/17 - * @Param [java.lang.String] - * @return com.alibaba.fastjson.JSONObject - */ - JSONObject getMobile(String phone , Integer amount , String orderNo , Integer isFast) throws Exception; - /** * @Author Sum1Dream * @name orderToRefund.java @@ -166,4 +155,14 @@ public interface OutRechargeOrderService { */ void rechargeOrderToRefund(Long orderId) throws Exception; + /** + * @Author Sum1Dream + * @name pollRequest.java + * @Description // 充值轮询 + * @Date 16:32 2022/5/25 + * @Param [com.hai.entity.OutRechargeOrder] + * @return void + */ + void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargePriceService.java b/hai-service/src/main/java/com/hai/service/OutRechargePriceService.java index 05d14782..f4795b61 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargePriceService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargePriceService.java @@ -2,6 +2,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.entity.OutRechargePrice; +import com.hai.model.OutRechargePriceModel; import java.util.List; import java.util.Map; @@ -24,7 +25,7 @@ public interface OutRechargePriceService { * @Param [map] * @return java.util.List **/ - List getListRechargePriceC(Map map); + List getRechargePriceByList(Map map); /** * @Author Sum1Dream @@ -33,7 +34,7 @@ public interface OutRechargePriceService { * @Param [id] * @return com.hai.entity.OutRechargePrice **/ - OutRechargePrice findById(Long id); + OutRechargePriceModel findById(Long id); /** * @Author Sum1Dream @@ -51,7 +52,17 @@ public interface OutRechargePriceService { * @Param [outRechargePrice] * @return void **/ - void updateRechargePrice(OutRechargePrice outRechargePrice); + void updateRechargePrice(JSONObject object); + + /** + * @Author Sum1Dream + * @name editPriceStatus.java + * @Description // 修改价格状态 + * @Date 18:18 2022/5/23 + * @Param [com.hai.entity.OutRechargePrice] + * @return void + */ + void editPriceStatus(OutRechargePrice outRechargePrice); /** * @Author Sum1Dream @@ -61,4 +72,14 @@ public interface OutRechargePriceService { * @return void **/ void deletePrice(Long id); + + /** + * @Author Sum1Dream + * @name getProductList.java + * @Description // 获取商品列表 + * @Date 09:56 2022/5/24 + * @Param [] + * @return com.alibaba.fastjson.JSONObject + */ + JSONObject getProductList(); } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java new file mode 100644 index 00000000..38e8f85e --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java @@ -0,0 +1,107 @@ +package com.hai.service.impl; + +import com.hai.dao.BsProductDiscountMapper; +import com.hai.dao.BsProductPayTypeMapper; +import com.hai.dao.BsProductPlatformMapper; +import com.hai.entity.*; +import com.hai.service.BsConfigService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service(value = "bsConfigService") +public class BsConfigServiceImpl implements BsConfigService { + + @Resource + private BsProductDiscountMapper bsProductDiscountMapper; + + @Resource + private BsProductPayTypeMapper bsProductPayTypeMapper; + + @Resource + private BsProductPlatformMapper bsProductPlatformMapper; + + @Override + public BsProductDiscount getProductDiscountByMap(Map map) { + BsProductDiscountExample example = new BsProductDiscountExample(); + BsProductDiscountExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map , "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType")); + } + + if (MapUtils.getLong(map , "sourceId") != null) { + criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId")); + } + + if (bsProductDiscountMapper.selectByExample(example) == null) { + return null; + } + + return bsProductDiscountMapper.selectByExample(example).get(0); + } + + @Override + public String getProductPlatformByMap(Map map) { + + BsProductPlatformExample example = new BsProductPlatformExample(); + BsProductPlatformExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map , "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType")); + } + + if (MapUtils.getLong(map , "sourceId") != null) { + criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId")); + } + + List list = bsProductPlatformMapper.selectByExample(example); + + StringBuilder string = new StringBuilder(); + StringBuilder stringName = new StringBuilder(); + + for (BsProductPlatform productPlatform : list) { + stringName.append(productPlatform.getPlatformName()).append(","); + string.append(productPlatform.getPlatformId()).append(","); + } + if (MapUtils.getInteger(map , "returnType") == 1) { + return string.toString(); + } else { + return stringName.toString(); + } + } + + @Override + public String getProductPayTypeByMap(Map map) { + BsProductPayTypeExample example = new BsProductPayTypeExample(); + BsProductPayTypeExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map , "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType")); + } + + if (MapUtils.getLong(map , "sourceId") != null) { + criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId")); + } + + List list = bsProductPayTypeMapper.selectByExample(example); + + StringBuilder stringName = new StringBuilder(); + StringBuilder string = new StringBuilder(); + + for (BsProductPayType productPayType : list) { + stringName.append(productPayType.getPayTypeName()).append(","); + string.append(productPayType.getPayTypeId()).append(","); + } + + if (MapUtils.getInteger(map , "returnType") == 1) { + return string.toString(); + } else { + return stringName.toString(); + } + + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/BsOperationLogServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsOperationLogServiceImpl.java new file mode 100644 index 00000000..38d12eda --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/BsOperationLogServiceImpl.java @@ -0,0 +1,30 @@ +package com.hai.service.impl; + +import com.hai.dao.BsOperationLogMapper; +import com.hai.entity.BsOperationLog; +import com.hai.service.BsOperationLogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service("bsOperationLogService") +public class BsOperationLogServiceImpl implements BsOperationLogService { + + @Resource + private BsOperationLogMapper bsOperationLogMapper; + + @Override + public List getListOperationLog(Map map) { + return null; + } + + @Override + public void insertOperationLog(BsOperationLog bsOperationLog) { + bsOperationLog.setCreateTime(new Date()); + bsOperationLog.setUpdateTime(new Date()); + bsOperationLogMapper.insert(bsOperationLog); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/BsRequestRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsRequestRecordServiceImpl.java new file mode 100644 index 00000000..5dedd5ba --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/BsRequestRecordServiceImpl.java @@ -0,0 +1,42 @@ +package com.hai.service.impl; + +import com.hai.dao.BsRequestRecordMapper; +import com.hai.entity.BsRequestRecord; +import com.hai.entity.BsRequestRecordExample; +import com.hai.service.BsRequestRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service("bsRequestRecordService") +public class BsRequestRecordServiceImpl implements BsRequestRecordService { + + @Resource + private BsRequestRecordMapper bsRequestRecordMapper; + + @Override + public void insertRequestRecord(BsRequestRecord bsRequestRecord) { + bsRequestRecordMapper.insert(bsRequestRecord); + } + + @Override + public void updateRequestRecord(BsRequestRecord bsRequestRecord) { + bsRequestRecordMapper.updateByPrimaryKey(bsRequestRecord); + } + + @Override + public BsRequestRecord findRequestRecordByOrderNo(String orderNo) { + BsRequestRecordExample example = new BsRequestRecordExample(); + + example.createCriteria().andOrderNoEqualTo(orderNo); + + List list = bsRequestRecordMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index 4516b8f0..e83619a0 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -659,7 +659,7 @@ public class CommonServiceImpl implements CommonService { if (list.size() > 0) { for (BsProductPlatform productPlatform : list) { - bsProductDiscountMapper.deleteByPrimaryKey(productPlatform.getId()); + bsProductPlatformMapper.deleteByPrimaryKey(productPlatform.getId()); } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java deleted file mode 100644 index c972ad19..00000000 --- a/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.hai.service.impl; - - -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.pay.util.sdk.WXPayConstants; -import com.hai.common.utils.*; -import com.hai.config.CommonSysConst; -import com.hai.dao.HighUserEtcMapper; -import com.hai.entity.HighDiscountAgentCode; -import com.hai.entity.HighUser; -import com.hai.entity.HighUserEtc; -import com.hai.service.*; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -@Service("highTestService") -public class HighTestServiceImpl implements HighTestService { - - private static Logger log = LoggerFactory.getLogger(HighTestService.class); - - @Resource - private HighUserService highUserService; - - @Resource - private HighUserEtcMapper highUserEtcMapper; - - @Resource - private HighDiscountAgentCodeService highDiscountAgentCodeService; - - - @Resource - private HighDiscountUserRelService highDiscountUserRelService; - - @Autowired - private RedisUtil redisUtil; - - @Override - @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) - public void getReadFile() throws Exception { -// BufferedReader bufferedReader = null; -// -// Map mapUser = new HashMap<>(); -// -// //cookie过期时间为7天 -// int EXPIRE = 3600*24*7; -// -// List highUsers = highUserService.getListUser(mapUser); -// -// for (HighUser user: highUsers) { -// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE); -// } -// -// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt"); -// if (fileReader == null) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据"); -// } -// -// bufferedReader = new BufferedReader(fileReader); -// String temp = bufferedReader.readLine(); -// int i = 0; -// while (temp != null) { -// i++; -// String[] arr = temp.split(";"); -// -// String phone = (String) redisUtil.get(arr[3]); -// -// if (phone == null || highUsers.size() == 0) { -// HighUser user = new HighUser(); -// -// user.setStatus(1); -// user.setInfoCompleteStatus(1); -// user.setGold(0); -// user.setRegTime(new Date()); -// user.setName(arr[2]); -// user.setPhone(arr[3]); -// user.setExt4("1"); -// -// highUserService.insertUser(user); -// -// HighUserEtc userEtc = new HighUserEtc(); -// -// userEtc.setCreateTime(new Date()); -// userEtc.setStatus(1); -// userEtc.setUserId(user.getId()); -// userEtc.setCustomerName(arr[2]); -// userEtc.setCustomerTel(arr[3]); -// userEtc.setVehicleId(arr[0]); -// userEtc.setVehiclePlate(arr[1]); -// -// highUserEtcMapper.insert(userEtc); -// -//// Map map = new HashMap<>(); -//// map.put("userId" , user.getId()); -//// map.put("userPhone" , user.getPhone()); -//// map.put("discountPackageId" , 48); -// -//// highDiscountPackageService.freeUserDiscountPackage(map); -// } -// -// temp = bufferedReader.readLine(); -// } - } - - @Override - @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) - public void getUserDiscount(Long id) throws Exception{ - List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1); - Map map = new HashMap<>(); - map.put("ext4" , "1"); - List userList = highUserService.getListUser(map); - - int num = 0; - for (HighUser user : userList) { - // 领取优惠券 - highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); - num++; - } - } - - @Override - public JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception { - - String timestamp = String.valueOf(System.currentTimeMillis()); - - Map map = new HashMap<>(); - map.put("mobile" , phone); - map.put("amount" , amount); - map.put("out_order_id" , orderNo); - map.put("app_key" , CommonSysConst.getSysConfig().getCzAppKey()); - map.put("timestamp" , timestamp.substring(0,timestamp.length()-3)); - map.put("is_fast" , "1"); - map.put("notify_url" , CommonSysConst.getSysConfig().getCzNotifyUrl()); - - String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getTelApiSecret() , WXPayConstants.SignType.MD5); - - map.put("sign" , signStr); - - return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() , map); - } - - @Override - public JSONObject findByLatAndLng(String lng, String lat) throws Exception { - - Map map = new HashMap<>();//参数 - map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");//申请百度开放平台KEY(ak) - map.put("output", "json");// 输出Json数据 - map.put("extensions_town", "true");// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据 - map.put("coordtype", "wgs84ll"); // GPS 经纬度类型 - map.put("location", lat+","+lng+"");//百度经纬度 - - String url = "http://api.map.baidu.com/reverse_geocoding/v3/"; - - return HttpsUtils.doGet(url , map); - - } -} diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java new file mode 100644 index 00000000..271e92fe --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java @@ -0,0 +1,64 @@ +package com.hai.service.impl; + +import com.hai.dao.OutRechargeChildOrderMapper; +import com.hai.dao.OutRechargeOrderRecordMapper; +import com.hai.entity.OutRechargeChildOrder; +import com.hai.entity.OutRechargeChildOrderExample; +import com.hai.entity.OutRechargeOrderRecord; +import com.hai.entity.OutRechargeOrderRecordExample; +import com.hai.service.OutRechargeChildOrderService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("outRechargeChildOrderService") +public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderService { + + @Resource + private OutRechargeChildOrderMapper rechargeChildOrderMapper; + + @Override + public List getListRechargeChildOrder(Map map) { + + OutRechargeChildOrderExample example = new OutRechargeChildOrderExample(); + OutRechargeChildOrderExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map , "parent_order_id") != null) { + criteria.andParentOrderIdEqualTo(MapUtils.getLong(map , "parent_order_id")); + } + if (MapUtils.getInteger(map , "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map , "status")); + } + + return rechargeChildOrderMapper.selectByExample(example); + } + + @Override + public OutRechargeChildOrder findById(Long id) { + return rechargeChildOrderMapper.selectByPrimaryKey(id); + } + + @Override + public OutRechargeChildOrder findByOrderNo(String orderNo) { + return null; + } + + @Override + public OutRechargeChildOrder findByOrderId(Long orderId) { + return null; + } + + @Override + public void insertOrder(OutRechargeChildOrder rechargeChildOrder) { + rechargeChildOrderMapper.insert(rechargeChildOrder); + } + + @Override + public void updateOrder(OutRechargeChildOrder rechargeChildOrder) { + rechargeChildOrderMapper.updateByPrimaryKey(rechargeChildOrder); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.java deleted file mode 100644 index c869549a..00000000 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.hai.service.impl; - -import com.hai.dao.OutRechargeOrderRecordMapper; -import com.hai.entity.OutRechargeOrderRecord; -import com.hai.entity.OutRechargeOrderRecordExample; -import com.hai.service.OutRechargeOrderRecordService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -@Service("outRechargeOrderRecordService") -public class OutRechargeOrderRecordServiceImpl implements OutRechargeOrderRecordService { - - @Resource - private OutRechargeOrderRecordMapper rechargeOrderRecordMapper; - - @Override - public List getListRechargeOrderRecord() { - return null; - } - - @Override - public OutRechargeOrderRecord findById(Long id) { - return null; - } - - @Override - public OutRechargeOrderRecord findByOrderNo(String orderNo) { - OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample(); - example.createCriteria().andRechargeOrderNoEqualTo(orderNo); - if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) { - return null; - } else { - return rechargeOrderRecordMapper.selectByExample(example).get(0); - } - } - - @Override - public OutRechargeOrderRecord findByOrderId(Long orderId) { - OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample(); - example.createCriteria().andRechargeOrderIdEqualTo(orderId); - if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) { - return null; - } else { - return rechargeOrderRecordMapper.selectByExample(example).get(0); - } - } - - - @Override - public void insertOrder(OutRechargeOrderRecord rechargeOrderRecord) { - rechargeOrderRecordMapper.insert(rechargeOrderRecord); - } - - @Override - public void updateOrder(OutRechargeOrderRecord rechargeOrderRecord) { - rechargeOrderRecordMapper.updateByPrimaryKey(rechargeOrderRecord); - } -} 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 8bac02e6..97785206 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 @@ -8,15 +8,13 @@ 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.*; -import com.hai.config.CommonSysConfig; -import com.hai.config.CommonSysConst; -import com.hai.config.HuiLianTongUnionCardConfig; -import com.hai.config.UnionPayConfig; +import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; +import com.hai.enum_type.RechargePayType; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; @@ -60,6 +58,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private OutRechargeOrderService outRechargeOrderService; + @Resource + private OutRechargePriceService outRechargePriceService; + @Resource private GoodsOrderServiceImpl goodsOrderService; @@ -69,6 +70,12 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource + private OutRechargeChildOrderService outRechargeChildOrderService; + + @Resource + private BsRequestRecordService bsRequestRecordService; + @Override public List getListRechargeOrder(Map map) { OutRechargeOrderExample example = new OutRechargeOrderExample(); @@ -128,7 +135,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Override @Transactional(propagation= Propagation.REQUIRES_NEW) - public void insertOrder(OutRechargeOrder outRechargeOrder) { + public void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception { // 使用优惠券 if (outRechargeOrder.getMemDiscountId() != null) { HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); @@ -141,6 +148,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { highDiscountAgentCodeService.updateCode(code); } outRechargeOrderMapper.insert(outRechargeOrder); + + if (outRechargeOrder.getRechargeStatus() == 201 && outRechargeOrder.getPayStatus() == 102) { + pollRequest(outRechargeOrder); + } + } @Override @@ -308,87 +320,55 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } @Override - public void hltUnionCardPay(Long userCardId, Long orderId) throws Exception { - HighUserCard userCard = highUserCardService.getDetailById(userCardId); - if(userCard == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息"); - } - OutRechargeOrder order = findByOrderId(orderId); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } + public void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception { String goodsDesc = "充值话费"; -// String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费"; + String tranDesc = order.getRechargeContent() + "充值" + order.getPayRealPrice() +"元话费"; String instCode = "11101290"; String businessType = "hisen_consume"; // 工会卡支付 -// JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc); -// System.out.println("工会卡支付响应参数" + consumption.toJSONString()); + JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc); + System.out.println("工会卡支付响应参数" + consumption.toJSONString()); Map dataMap = new HashMap<>(); dataMap.put("orderNo", order.getOrderNo()); dataMap.put("cardType", "ghk"); dataMap.put("cardNo", userCard.getCardNo()); dataMap.put("checkPassword", "N"); -// dataMap.put("tranAmount", order.getPayPrice()); + dataMap.put("tranAmount", order.getPayRealPrice()); dataMap.put("tranChannel", "HiSen"); dataMap.put("businessType", businessType); dataMap.put("instCode", instCode); dataMap.put("goodsDesc", goodsDesc); -// dataMap.put("tranDesc", tranDesc); + dataMap.put("tranDesc", tranDesc); HighGasOrderPush payPush = new HighGasOrderPush(); payPush.setType(OrderPushType.type5.getType()); payPush.setOrderNo(order.getOrderNo()); payPush.setCreateTime(new Date()); -// payPush.setCode(consumption.getString("respCode")); -// payPush.setRequestContent(JSON.toJSONString(dataMap)); -// payPush.setReturnContent(consumption.toJSONString()); + payPush.setCode(consumption.getString("respCode")); + payPush.setRequestContent(JSON.toJSONString(dataMap)); + payPush.setReturnContent(consumption.toJSONString()); highGasOrderPushMapper.insert(payPush); -// if(!consumption.getString("respCode").equals("0000")) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); -// } -// JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); -// if (!consumptionResult.getBoolean("success")) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); -// } -// order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 -// order.setPayRealPrice(order.getPayPrice()); // 实付金额 -// if (order.getRechargeType() == 1) { -// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() ,order.getRechargeType()); -// if (object.getInteger("code") != 200) { -// order.setRechargeStatus(1); -// order.setAbnormalMsg(object.getString("message")); -// } -// } -// order.setStatus(2); - order.setPayType(2); + if(!consumption.getString("respCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); + } + JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); + if (!consumptionResult.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); + } + order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 + order.setPayRealPrice(order.getPayRealPrice()); // 实付金额 + outRechargeOrderService.pollRequest(order); + order.setPayStatus(102); + order.setRechargeStatus(201); + order.setLaborUnionCard(userCard.getCardNo()); + order.setPayType(3); order.setPayTime(new Date()); // 支付时间 updateOrder(order); } - @Override - @Transactional(propagation= Propagation.REQUIRES_NEW) - public void goldPayOrder(Long userId, Long orderId) throws Exception { -// OutRechargeOrder order = findByOrderId(orderId); -// if(order == null) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); -// } -// // 查询用户 -// HighUser highUser = highUserService.findByUserId(userId); -// -// // 金币 1:100 -// Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue(); -// highUserService.goldHandle(userId, goldNum, 2, 2, order.getId()); -// order.setPayRealPrice(order.getPayPrice()); // 实付金额 -// order.setStatus(2); -// order.setPayType(3); -// order.setPayTime(new Date()); // 支付时间 -// outRechargeOrderService.updateOrder(order); - } - @Override public List getOutRechargeOrderList() { return outRechargeOrderMapper.getCloseOrder(); @@ -399,137 +379,102 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.rechargeOrderByIndex(code); } + @Override - public JSONObject getMobile(String phone , Integer amount , String orderNo , Integer isFast) throws Exception { + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void rechargeOrderToRefund(Long orderId) throws Exception { + OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); - if (isFast == 2) { - isFast = 0; + // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + if (order.getPayStatus() != 102) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); } - String timestamp = String.valueOf(System.currentTimeMillis()); + // 微信退款 + if (order.getPayType() == 1) { + Map param = new HashMap<>(); + param.put("appid", "wx637bd6f7314daa46"); + param.put("mch_id", "1289663601"); + param.put("sub_mch_id" , "1614670195"); + param.put("nonce_str", WxUtils.makeNonStr()); + param.put("transaction_id", order.getPaySerialNo()); + param.put("out_refund_no", "HFR"+new Date().getTime()); + param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); + param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); + param.put("sign_type", "HMAC-SHA256"); + + String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); + param.put("sign", signStr); + + String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); + OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); + if(orderRefundModel.getResult_code().equals("SUCCESS")) { + order.setPayStatus(105); + order.setRechargeStatus(203); + order.setRefundTime(new Date()); + order.setOutRefundNo(orderRefundModel.getOut_refund_no()); + order.setRefundId(orderRefundModel.getRefund_id()); + order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); + outRechargeOrderService.updateOrder(order); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); + } + } - Map map = new HashMap<>(); - map.put("mobile" , phone); - map.put("amount" , amount); - map.put("out_order_id" , orderNo); - map.put("app_key" , CommonSysConst.getSysConfig().getCzAppKey()); - map.put("timestamp" , timestamp.substring(0,timestamp.length()-3)); - map.put("is_fast" , isFast); - map.put("notify_url" , CommonSysConst.getSysConfig().getCzNotifyUrl()); + // 工会卡退款 + if (order.getPayType() == 2) { + JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); - String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getCzAppSecret() , WXPayConstants.SignType.MD5); + if (jsonObject == null) { + jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); + } - map.put("sign" , signStr); + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); - return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() + "createOrder" , map); - } + if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { + order.setPayStatus(105); + order.setRechargeStatus(203); + order.setRefundTime(new Date()); + order.setOutRefundNo("HFR"+new Date().getTime() ); + order.setRefundFee(order.getPayRealPrice()); + order.setRefundId(dataObject.getString("orderId")); + outRechargeOrderService.updateOrder(order); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); + } + } - @Override - public void rechargeOrderToRefund(Long orderId) throws Exception { -// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); -// -// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中 -// if (order.getStatus() != 2) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); -// } -// -// // 微信退款 -// if (order.getPayType() == 1) { -// Map param = new HashMap<>(); -// param.put("appid", "wx637bd6f7314daa46"); -// param.put("mch_id", "1289663601"); -// param.put("sub_mch_id" , "1614670195"); -// param.put("nonce_str", WxUtils.makeNonStr()); -// param.put("transaction_id", order.getPaySerialNo()); -// param.put("out_refund_no", "HFR"+new Date().getTime()); -// param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); -// param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); -// param.put("sign_type", "HMAC-SHA256"); -// -// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); -// param.put("sign", signStr); -// -// String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); -// OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); -// if(orderRefundModel.getResult_code().equals("SUCCESS")) { -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo(orderRefundModel.getOut_refund_no()); -// order.setRefundId(orderRefundModel.getRefund_id()); -// order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); -// outRechargeOrderService.updateOrder(order); -// } else { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); -// } -// } -// -// // 工会卡退款 -// if (order.getPayType() == 2) { -// JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); -// -// if (jsonObject == null) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); -// } -// -// JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); -// -// if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo("HFR"+new Date().getTime() ); -// order.setRefundFee(order.getPayRealPrice()); -// order.setRefundId(dataObject.getString("orderId")); -// outRechargeOrderService.updateOrder(order); -// -// } else { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); -// } -// } -// -// // 金币退款 -// if (order.getPayType() == 3) { -// if (highUserService.findGoldRepeat(3 , order.getId())) { -// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); -// }else { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); -// } -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo("HFR"+new Date().getTime() ); -// order.setRefundFee(order.getPayRealPrice()); -// outRechargeOrderService.updateOrder(order); -// } -// -// // 银联退款 -// if (order.getPayType() == 4) { -// // 订单退款 -// JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); -// if (!refund.getString("resultcode").equals("W6")) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); -// } -// -// order.setStatus(5); -// order.setRefundTime(new Date()); -// order.setOutRefundNo(refund.getString("oriwtorderid")); -// order.setRefundFee(order.getPayRealPrice()); -// outRechargeOrderService.updateOrder(order); -// } -// -// if (order.getMemDiscountId() != null) { -// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); -// if (rel != null) { -// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 -// rel.setUseTime(null); -// highDiscountUserRelService.updateDiscountUserRel(rel); -// -// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); -// code.setStatus(2); -// highDiscountAgentCodeService.updateCode(code); -// } -// } + // 银联退款 + if (order.getPayType() == 4) { + // 订单退款 + JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); + if (!refund.getString("resultcode").equals("W6")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); + } + order.setPayStatus(105); + order.setRechargeStatus(203); + order.setRefundTime(new Date()); + order.setOutRefundNo(refund.getString("oriwtorderid")); + order.setRefundFee(order.getPayRealPrice()); + outRechargeOrderService.updateOrder(order); + } + + if (order.getMemDiscountId() != null) { + HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); + if (rel != null) { + rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + rel.setUseTime(null); + highDiscountUserRelService.updateDiscountUserRel(rel); + + HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); + code.setStatus(2); + highDiscountAgentCodeService.updateCode(code); + } + } + } public String doRefundRequest(String mchId,String data) throws Exception { @@ -561,4 +506,88 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { httpClient.close(); } } + + @Override + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { + + // 查询充值产品 + OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId()); + + // 查询充值子订单 + Map childOrderMap = new HashMap<>(); + + childOrderMap.put("parent_order_id" , outRechargeOrder.getId()); + childOrderMap.put("status" , 102); + + List childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); + + OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); + + // 1:尖椒 2:龙阅 3:畅停 + int type = 0; + int rechargePlatformType = 0; + + // 判断子订单是否存在充值中订单 + if (childOrderList.size() > 0) { + childOrder = childOrderList.get(0); + childOrder.setStatus(103); + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.updateOrder(childOrder); + type = childOrder.getRechargePlatform(); + + } + + JSONObject object = new JSONObject(); + + String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); + + String[] rechargePlatform = outRechargePrice.getRechargePlatform().split("-"); + + for (String s : rechargePlatform) { + // 尖椒充值 + if (s.equals("1") && type == 2) { + object.put("out_order_id" ,orderNo ); + object.put("amount" , outRechargePrice.getRechargePrice()); + object.put("mobile" , outRechargeOrder.getRechargeContent()); + if (outRechargePrice.getRechargeType() == 1) { + object.put("is_fast" , 1); + } + RechargeConfig.rechargeOrderByJj(object); + rechargePlatformType = 1; + break; + } + if (s.equals("2") && (type == 1 || type == 0)) { + object.put("out_trade_num" , orderNo); + object.put("product_id" , outRechargePrice.getGoodsId()); + object.put("mobile" , outRechargeOrder.getRechargeContent()); + RechargeConfig.rechargeOrderByLy(object); + rechargePlatformType = 2; + break; + } + } + + childOrder.setOrderNo(orderNo); + childOrder.setCreateTime(new Date()); + childOrder.setParentOrderId(outRechargeOrder.getId()); + childOrder.setStatus(102); + childOrder.setRechargePlatform(rechargePlatformType); + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.insertOrder(childOrder); + + // 创建提交记录 + BsRequestRecord requestRecord = new BsRequestRecord(); + requestRecord.setCreateTime(new Date()); + requestRecord.setUpdateTime(new Date()); + requestRecord.setOrderNo(orderNo); + requestRecord.setRequestContent(String.valueOf(object)); + requestRecord.setOperatorId(0L); + requestRecord.setOperatorName("系统生成"); + requestRecord.setSourceId(childOrder.getId().toString()); + requestRecord.setSourceType(1); + + bsRequestRecordService.insertRequestRecord(requestRecord); + + + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index cf445ebd..3cde6aae 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.dao.OutRechargePriceMapper; import com.hai.entity.*; +import com.hai.model.OutRechargePriceModel; +import com.hai.service.BsConfigService; import com.hai.service.CommonService; import com.hai.service.OutRechargePriceService; import io.swagger.models.auth.In; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -16,9 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @Service("outRechargePriceServiceImpl") public class OutRechargePriceServiceImpl implements OutRechargePriceService { @@ -29,55 +30,67 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { @Resource private CommonService commonService; + @Resource + private BsConfigService bsConfigService; + @Override - public List getListRechargePrice(Map map) { + public List getListRechargePrice(Map map) { OutRechargePriceExample example = new OutRechargePriceExample(); OutRechargePriceExample.Criteria criteria = example.createCriteria(); - if (MapUtils.getLong(map , "companyId") != null) { - criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId")); + if (MapUtils.getLong(map, "companyId") != null) { + criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); } - if (MapUtils.getLong(map , "rechargePlatform") != null) { - criteria.andRechargePlatformLike("%-" +MapUtils.getLong(map , "rechargePlatform") + "-%"); + if (MapUtils.getLong(map, "rechargePlatform") != null) { + criteria.andRechargePlatformLike("%" + MapUtils.getLong(map, "rechargePlatform") + "%"); } - if (MapUtils.getLong(map , "rechargeType") != null) { - criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType")); + if (MapUtils.getLong(map, "operatorType") != null) { + criteria.andOperatorTypeEqualTo(MapUtils.getInteger(map, "operatorType")); } - if (MapUtils.getLong(map , "rechargeType") != null) { - criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType")); + if (MapUtils.getLong(map, "rechargeType") != null) { + criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map, "rechargeType")); } - - example.setOrderByClause("recharge_price asc"); - return outRechargePriceMapper.selectByExample(example); - } - @Override - public List getListRechargePriceC(Map map) { - OutRechargePriceExample example = new OutRechargePriceExample(); - OutRechargePriceExample.Criteria criteria = example.createCriteria(); - - criteria.andStatusNotEqualTo(0); - - if (StringUtils.isNotBlank(map.get("companyId"))) { - criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); + if (MapUtils.getLong(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } - if (StringUtils.isNotBlank(map.get("rechargeType"))) { - criteria.andRechargeTypeEqualTo(Integer.valueOf(map.get("rechargeType"))); + if (MapUtils.getLong(map, "rechargeWay") != null) { + criteria.andRechargeWayEqualTo(MapUtils.getInteger(map, "rechargeWay")); } example.setOrderByClause("sort asc"); return outRechargePriceMapper.selectByExample(example); } + @Override + public List getRechargePriceByList(Map map) { + + return outRechargePriceMapper.getUserByPrice(map); + } + @Override - public OutRechargePrice findById(Long id) { - return outRechargePriceMapper.selectByPrimaryKey(id); + public OutRechargePriceModel findById(Long id) { + + OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(id); + + OutRechargePriceModel outRechargePriceModel = new OutRechargePriceModel(); + BeanUtils.copyProperties(outRechargePrice, outRechargePriceModel); + + Map listMap = new HashMap<>(); + listMap.put("productType", "3"); + listMap.put("returnType", 1); + listMap.put("sourceId", outRechargePrice.getId()); + + outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); + outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); + outRechargePriceModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap)); + return outRechargePriceModel; } @Override - @Transactional(propagation= Propagation.REQUIRES_NEW) + @Transactional(propagation = Propagation.REQUIRES_NEW) public void insertRechargePrice(JSONObject object) { // 转换金额数组 @@ -95,7 +108,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { outRechargePrice.setDiscount(object.getBigDecimal("discount")); outRechargePrice.setRechargeType(object.getInteger("rechargeType")); outRechargePrice.setOperatorType(object.getInteger("operatorType")); - outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform") , "-") + "-"); + outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform"), "-") + "-"); outRechargePrice.setRechargeWay(object.getInteger("rechargeWay")); outRechargePrice.setCompanyId(object.getLong("companyId")); outRechargePrice.setCreateTime(new Date()); @@ -119,17 +132,54 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { // 配置展示平台 commonService.configPlatform(postObject); } + } - + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void updateRechargePrice(JSONObject object) { + OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(object.getLong("id")); + outRechargePrice.setPayPrice(outRechargePrice.getRechargePrice().multiply(object.getBigDecimal("discount").divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP))); + outRechargePrice.setDiscount(object.getBigDecimal("discount")); + outRechargePrice.setRechargeType(object.getInteger("rechargeType")); + outRechargePrice.setOperatorType(object.getInteger("operatorType")); + outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform"), "-") + "-"); + outRechargePrice.setRechargeWay(object.getInteger("rechargeWay")); + outRechargePrice.setCompanyId(object.getLong("companyId")); + outRechargePrice.setCreateTime(new Date()); + outRechargePrice.setUpdateTime(new Date()); + outRechargePrice.setStatus(3); + outRechargePrice.setSort(object.getInteger("sort")); + outRechargePrice.setGoodsId(object.getLong("goodsId")); + outRechargePriceMapper.updateByPrimaryKey(outRechargePrice); + JSONObject postObject = new JSONObject(); + postObject.put("payType", object.getJSONArray("payType")); + postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); + postObject.put("productPlatform", object.getJSONArray("productPlatform")); + postObject.put("operatorId", object.getLong("operatorId")); + postObject.put("operatorName", object.getString("operatorName")); + postObject.put("sourceId", outRechargePrice.getId()); + + // 配置支付方式 + commonService.configPayType(postObject); + // 配置积分折扣比例 + commonService.configIntegralDiscount(postObject); + // 配置展示平台 + commonService.configPlatform(postObject); } @Override - public void updateRechargePrice(OutRechargePrice outRechargePrice) { - outRechargePriceMapper.updateByPrimaryKey(outRechargePrice); + public void editPriceStatus(OutRechargePrice outRechargePrice) { + outRechargePriceMapper.updateByPrimaryKey(outRechargePrice); } @Override public void deletePrice(Long id) { outRechargePriceMapper.deleteByPrimaryKey(id); } + + @Override + public JSONObject getProductList() { + return null; + } + } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java index 97025893..a9675089 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java @@ -8,7 +8,6 @@ import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.WxUtils; import com.hai.config.CommonSysConst; -import com.hai.config.TelConfig; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 0d75b5d3..e71ad337 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -52,11 +52,17 @@ TelApiKey=2d01f6b520254b1a80f6b167832cea18 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelMemberId=d13091df65d64aafbf0f35d2093157b7 -// Mobile -CzNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback -CzAppKey = eaomqcbpdz7yjfih -CzUrl = https://hfcs.dmjvip.com/index.php/third/mobile/ -CzAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8 +# Jj +JjNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback +JjAppKey = eaomqcbpdz7yjfih +JjUrl = https://hfcs.dmjvip.com/index.php/third/mobile/ +JjAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8 + +#LY +LyNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback +LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU +LyMemberId=18665 +LyPostUrl=https://cz.31994.cn/yrapi.php/ unionAppId=7113783e75354df2a985efd3f31b9528 diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index bd799df7..7f8bbfd1 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -49,11 +49,15 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelMemberId=d13091df65d64aafbf0f35d2093157b7 // Mobile -CzNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallback -CzAppKey = p429mlj3cvn5hb07 -CzUrl = https://jj.dmjvip.com/index.php/third/mobile/ -CzAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij +JjNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallback +JjAppKey = p429mlj3cvn5hb07 +JjUrl = https://jj.dmjvip.com/index.php/third/mobile/ +JjAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij +#LY +LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU +LyMemberId=18665 +LyPostUrl=https://cz.31994.cn/yrapi.php/ unionAppId=ced46392acfe42be863fdfdd3e61164a unionSecret=a0f380bb22cd4ce2a8d35f3bf437d6fa