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 dd005af4..b77a7c31 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -17,6 +17,8 @@ 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; @@ -26,6 +28,7 @@ import com.hai.entity.HighRefundAudit; import com.hai.entity.OutRechargeOrder; import com.hai.model.*; import com.hai.service.HighRefundAuditService; +import com.hai.service.HighUserService; import com.hai.service.OutRechargeOrderService; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; @@ -64,6 +67,9 @@ public class OutRechargeOrderController { @Resource private HighRefundAuditService highRefundAuditService; + @Resource + private HighUserService highUserService; + @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @ResponseBody @@ -356,6 +362,17 @@ public class OutRechargeOrderController { } } + // 积分退款 + if (order.getPayType() == 3) { + highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); + 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) { // 订单退款 @@ -550,4 +567,37 @@ public class OutRechargeOrderController { } } + + @RequestMapping(value = "/getMobileRechargeByOrderId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "话费再次充值充值") + public ResponseData getMobileRechargeByOrderId( + @RequestParam(name = "orderId", required = true) Long orderId) { + try { + + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); + + String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); + + JSONObject object = outRechargeOrderService.getMobile(outRechargeOrder.getRechargeContent(),outRechargeOrder.getOrderPrice().intValue(),orderNo); + + if (object.getInteger("code") != 200) { + log.error("getMobileRechargeByOrderId error!", "充值失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object.getString("message")); + } + + outRechargeOrder.setRechargeStatus(2); + + outRechargeOrder.setOrderNo(orderNo); + + outRechargeOrderService.updateOrder(outRechargeOrder); + + return ResponseMsgUtil.success("请求成功"); + + } catch (Exception e) { + log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java b/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java index dcecc399..df40b7f9 100644 --- a/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java @@ -49,7 +49,72 @@ public class WxMsgConfig { } + public static void rechargedSuccess(String orderName , String price , String orderNo , Date payTime , String payType , String openId) { + try { + List list = new ArrayList<>(); + + Map m = new HashMap<>(); + + m.put("character_string1", orderNo); // 订单号 + m.put("thing11", orderName); // 充值项目 + m.put("thing10", payType); // 支付方式 + m.put("amount8", price); // 支付金额 + m.put("date5", DateUtil.date2String(payTime , "yyyy年MM月dd日 HH:mm:ss")); + + for (String key: m.keySet()) { + WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data(); + msgElement.setName(key); + msgElement.setValue(m.get(key)); + list.add(msgElement); + } + + WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage(); + subscribeMessage.setToUser(openId); // 小程序openId + subscribeMessage.setTemplateId("ZO6kC3oJv0zj9QzL0htsF-mM9vAElcgPZEcUGglxsoU"); + subscribeMessage.setData(list); + + final WxMaService wxService = WxMaConfiguration.getMaService(); + WxMaMsgService maMsgService = wxService.getMsgService(); + maMsgService.sendSubscribeMsg(subscribeMessage); + } catch (Exception e) { + log.error(String.valueOf(e)); + } + + } + + public static void rechargedFail(String orderName , String price , String openId) { + + try { + List list = new ArrayList<>(); + + Map m = new HashMap<>(); + + m.put("thing1", orderName); // 订单内容 + m.put("thing2", "充值通道爆满!"); // 失败原因 + m.put("amount3", price); // 退款金额 + m.put("thing4", "退款将在1-3日内原路退回"); // 温馨提示 + + for (String key: m.keySet()) { + WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data(); + msgElement.setName(key); + msgElement.setValue(m.get(key)); + list.add(msgElement); + } + + WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage(); + subscribeMessage.setToUser(openId); // 小程序openId + subscribeMessage.setTemplateId("xjacmzuWSRdiKGz4IJVeuvyGE0vOhoy0JVQPgOr-PuI"); + subscribeMessage.setData(list); + + final WxMaService wxService = WxMaConfiguration.getMaService(); + WxMaMsgService maMsgService = wxService.getMsgService(); + maMsgService.sendSubscribeMsg(subscribeMessage); + } catch (Exception e) { + log.error(String.valueOf(e)); + } + + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index dc6a0a4b..01568883 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.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.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; 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.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; 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 HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @RequestMapping(value = "/getHuiLianTongCardInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡详情") public ResponseData getHuiLianTongCardInfo(@RequestParam(name = "cardNo", required = true) String cardNo, HttpServletRequest request) { try { // 用户 // JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(cardNo); if (StringUtils.isBlank(cardInfo.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } // // @RequestMapping(value = "/getMobile", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费充值") // public ResponseData getMobile( // @RequestParam(name = "orderNo", required = true) String orderNo, // @RequestParam(name = "amount", required = true) Integer amount, // @RequestParam(name = "phone", required = true) String phone, // HttpServletRequest request) { // try { // return ResponseMsgUtil.success(outRechargeOrderService.getMobile(phone,amount,orderNo)); // // } catch (Exception e) { // log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "派发贵州卡券") // public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { // try { // return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); // } catch (Exception e) { // log.error("HighOrderController --> getOrderById() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), "62285", "c8BHfKVs6l68BBP9KD9jz4QLJCd/IKW/D+EsM0BLKzb/E7l8k4+aO/Y/h5j89s1X", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.standardRefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; 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); if (!resultProfitSharing.getResult_code().equals("FAIL")) { 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(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = 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(); } } } \ No newline at end of file +package com.cweb.controller; import com.alibaba.fastjson.JSONArray; 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.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.PayType; import com.hai.enum_type.RechargePayType; import com.hai.model.*; import com.hai.service.*; 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.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; 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 HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighUserService highUserService; @RequestMapping(value = "/getHuiLianTongCardInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡详情") public ResponseData getHuiLianTongCardInfo(@RequestParam(name = "cardNo", required = true) String cardNo, HttpServletRequest request) { try { // 用户 // JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(cardNo); if (StringUtils.isBlank(cardInfo.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test() { try { // 查询订单 OutRechargeOrder order = outRechargeOrderService.findByOrderId(733L); HighUser highUser = highUserService.findByUserId(order.getUserId()); WxMsgConfig.rechargedSuccess( order.getRechargeName() + "充值成功", String.valueOf(order.getPayRealPrice()), order.getOrderNo(), order.getFinishTime(), RechargePayType.getNameByType(order.getPayType()), highUser.getOpenId()); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } // // @RequestMapping(value = "/getMobile", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费充值") // public ResponseData getMobile( // @RequestParam(name = "orderNo", required = true) String orderNo, // @RequestParam(name = "amount", required = true) Integer amount, // @RequestParam(name = "phone", required = true) String phone, // HttpServletRequest request) { // try { // return ResponseMsgUtil.success(outRechargeOrderService.getMobile(phone,amount,orderNo)); // // } catch (Exception e) { // log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "派发贵州卡券") // public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { // try { // return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); // } catch (Exception e) { // log.error("HighOrderController --> getOrderById() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), "62285", "c8BHfKVs6l68BBP9KD9jz4QLJCd/IKW/D+EsM0BLKzb/E7l8k4+aO/Y/h5j89s1X", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.standardRefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; 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); if (!resultProfitSharing.getResult_code().equals("FAIL")) { 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(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = 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(); } } } \ No newline at end of file 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 45a56b6c..89b40638 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -493,6 +493,9 @@ public class OutRechargeOrderController { } } + + + @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "订单支付发起银联支付") diff --git a/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java b/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java deleted file mode 100644 index cfebe4a2..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.cweb.controller; - -import com.alibaba.fastjson.JSONObject; -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.IOUtil; -import com.hai.common.pay.util.XmlUtil; -import com.hai.common.utils.*; -import com.hai.config.TelConfig; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighOrder; -import com.hai.entity.HighTelOrder; -import com.hai.entity.HighUser; -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 { - - HighOrder order = highOrderService.getOrderById(699L); - - HighUser highUser = highUserService.findByUserId(order.getMemId()); - HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); - WxMsgConfig.pushOneUser( - presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", - String.valueOf(order.getPayPrice()), - order.getOrderNo(), - order.getPayTime(), - PayType.getNameByType(order.getPayType()), order.getId(), - highUser.getOpenId()); - - return ResponseMsgUtil.success("1"); - } catch (Exception 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 cfd5c24a..04a645c4 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,12 +1,15 @@ package com.cweb.controller.pay; import com.alibaba.fastjson.JSONObject; +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.config.CommonSysConst; @@ -14,14 +17,15 @@ import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.UnionPayConfig; import com.hai.config.WxOrderConfig; import com.hai.dao.HighGasOrderRefundMapper; -import com.hai.entity.HighGasOrderRefund; -import com.hai.entity.HighOrder; -import com.hai.entity.HighRefundAudit; -import com.hai.entity.OutRechargeOrder; +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.ResponseData; import com.hai.service.HighRefundAuditService; import com.hai.service.HighUserService; +import com.hai.service.OutRechargeOrderRecordService; import com.hai.service.OutRechargeOrderService; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; @@ -66,6 +70,9 @@ public class CzOrderController { @Resource private HighUserService highUserService; + @Resource + private OutRechargeOrderRecordService rechargeOrderRecordService; + @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST) @ApiOperation(value = "话费充值回调") @ResponseBody @@ -78,21 +85,67 @@ public class CzOrderController { HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund(); highGasOrderRefund.setCreateTime(new Date()); highGasOrderRefund.setReturnContent(String.valueOf(dataObject)); - highGasOrderRefundMapper.insert(highGasOrderRefund); - // 查询订单 - OutRechargeOrder order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id")); - - // 订单状态 : 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中 - if (order != null && order.getStatus() == 2) { - // 退单结果 true:成功 false:失败 - if (dataObject.getInteger("status") == 3) { + 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); - } else if (dataObject.getInteger("status") == 4) { - orderToRefund(order.getId()); } + + 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.getRechargeType() != null && order.getRechargeType() == 1) { + String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); + JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo); + 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(); @@ -173,8 +226,9 @@ public class CzOrderController { } } + // 积分退款 if (order.getPayType() == 3) { - highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().intValue() * 100, 1, 3, order.getId()); + highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); } // 银联退款 @@ -191,6 +245,15 @@ public class CzOrderController { order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); } + + 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); diff --git a/hai-service/src/main/java/com/hai/common/utils/TelApiUtil.java b/hai-service/src/main/java/com/hai/common/utils/TelApiUtil.java new file mode 100644 index 00000000..9f520447 --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/TelApiUtil.java @@ -0,0 +1,32 @@ +package com.hai.common.utils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +public class TelApiUtil { + + /** + * 大陆手机号码11位数,匹配格式:前三位固定格式+后8位任意数 + * 此方法中前三位格式有: + * 13+任意数 + * 145,147,149 + * 15+除4的任意数(不要写^4,这样的话字母也会被认为是正确的) + * 166 + * 17+3,5,6,7,8 + * 18+任意数 + * 198,199 + */ + public static boolean isChinaPhoneLegal(String str) throws PatternSyntaxException { + // ^ 匹配输入字符串开始的位置 + // \d 匹配一个或多个数字,其中 \ 要转义,所以是 \\d + // $ 匹配输入字符串结尾的位置 + String regExp = "^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(166)|(17[3,5,6,7,8])" + + "|(18[0-9])|(19[8,9]))\\d{8}$"; + Pattern p = Pattern.compile(regExp); + Matcher m = p.matcher(str); + return m.matches(); + } + + +} 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 new file mode 100644 index 00000000..6a8fb15d --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/RechargePayType.java @@ -0,0 +1,44 @@ +package com.hai.enum_type; + +import java.util.Objects; + +public enum RechargePayType { + + payType1(1 , "微信"), + payType2(2 , "工会卡"), + payType3(3 , "积分"), + payType4(4 , "银联") + ; + + private Integer type; + private String name; + + + RechargePayType(int type , String name) { + this.type = type; + this.name = name; + } + + public static String getNameByType(Integer type) { + for (RechargePayType ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java new file mode 100644 index 00000000..92cd9122 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderRecordService.java @@ -0,0 +1,68 @@ +package com.hai.service; + +import com.hai.entity.OutRechargeOrder; +import com.hai.entity.OutRechargeOrderRecord; + +import java.util.List; + +public interface OutRechargeOrderRecordService { + + /** + * @Author Sum1Dream + * @name getListRechargeOrderRecord.java + * @Description // 获取充值记录列表 + * @Date 2:31 下午 2022/2/11 + * @Param [] + * @return java.util.List + */ + List getListRechargeOrderRecord(); + + /** + * @Author Sum1Dream + * @name findById.java + * @Description // 根据ID查询 + * @Date 2:32 下午 2022/2/11 + * @Param [Long id] + * @return com.hai.entity.OutRechargeOrderRecord + */ + OutRechargeOrderRecord findById(Long id); + + /** + * @Author Sum1Dream + * @name findById.java + * @Description // 根据订单ID查询 + * @Date 2:32 下午 2022/2/11 + * @Param [Long id] + * @return com.hai.entity.OutRechargeOrderRecord + */ + OutRechargeOrderRecord findByOrderNo(String orderNo); + + /** + * @Author Sum1Dream + * @name findById.java + * @Description // 根据订单ID查询 + * @Date 2:32 下午 2022/2/11 + * @Param [Long id] + * @return com.hai.entity.OutRechargeOrderRecord + */ + OutRechargeOrderRecord findByOrderId(Long orderId); + + /*** + * @Author Sum1Dream + * @Description // 新增订单 + * @Date 15:25 2021/6/11 + * @Param [rechargeOrderRecord] + * @return void + **/ + void insertOrder(OutRechargeOrderRecord rechargeOrderRecord); + + /*** + * @Author Sum1Dream + * @Description // 修改订单 + * @Date 15:26 2021/6/11 + * @Param [rechargeOrderRecord] + * @return void + **/ + void updateOrder(OutRechargeOrderRecord rechargeOrderRecord); + +} 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 new file mode 100644 index 00000000..c869549a --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.java @@ -0,0 +1,60 @@ +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); + } +}