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 3674303a..0eda7eeb 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.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; 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.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Resource private OrderRefundService orderRefundService; @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 = "/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, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { Map map = new HashMap<>(); map.put("timetable" , new Date().getTime()); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("orderNo" , "20220329182036435619"); map.put("count" , "1"); map.put("couTypeCode" , "test"); map.put("phone" , "15206071196"); map.put("merchId" , "20220670800"); map.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/v1/gzSinopec/couJointDist" , map)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { List highOrders = orderService.phoneErrorOrder(); for (HighOrder order: highOrders) { try { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); } outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } return ResponseMsgUtil.success("操作成功"); } @RequestMapping(value = "/checkOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号话费查询是否可以退款") public ResponseData checkOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); } outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData orderRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Calendar createTimeS = Calendar.getInstance(); createTimeS.set(Calendar.DATE, 17); createTimeS.set(Calendar.HOUR_OF_DAY , 00); createTimeS.set(Calendar.MINUTE , 00); createTimeS.set(Calendar.SECOND , 00); Calendar createTimeE = Calendar.getInstance(); createTimeE.set(Calendar.DATE, 20); createTimeE.set(Calendar.HOUR_OF_DAY , 15); createTimeE.set(Calendar.MINUTE , 25); createTimeE.set(Calendar.SECOND , 00); Map param = new HashMap<>(); // param.put("createTimeS", createTimeS.getTimeInMillis()); // param.put("createTimeE", createTimeE.getTimeInMillis()); param.put("orderNo", orderNo); List orderRefundList = orderRefundService.getRefundOrderList(param); for (HighOrderRefund orderRefund : orderRefundList) { try { orderRefundService.refundPrice( orderRefund.getRefundOrderNo(), orderService.getOrderDetailByNo(orderRefund.getOrderNo()), OrderPayType.getDataByType(orderRefund.getPayType()), orderRefund.getRefundPrice(), orderRefund.getRefundIntegral() ); orderRefund.setExt1("true"); } catch (Exception e) { orderRefund.setExt1("false"); } finally { orderRefundService.update(orderRefund); } } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String orderTitle(OutRechargeOrder outRechargeOrder) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (outRechargeOrder.getOperatorType()) { case 1: return outRechargeOrder.getRechargeContent() + "电信话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 2: return outRechargeOrder.getRechargeContent() + "移动话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 3: return outRechargeOrder.getRechargeContent() + "联通话费充值" + outRechargeOrder.getRechargePrice() + "元"; default: return null; } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; 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.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Resource private OrderRefundService orderRefundService; @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 = "/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, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { Map map = new HashMap<>(); map.put("timetable" , new Date().getTime()); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("orderNo" , "20220329182036435619"); map.put("count" , "1"); map.put("couTypeCode" , "test"); map.put("phone" , "15206071196"); map.put("merchId" , "20220670800"); map.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/v1/gzSinopec/couJointDist" , map)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { List highOrders = orderService.phoneErrorOrder(); for (HighOrder order: highOrders) { try { outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } return ResponseMsgUtil.success("操作成功"); } @RequestMapping(value = "/checkOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号话费查询是否可以退款") public ResponseData checkOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); } outRechargeOrderService.rechargeOrderHandle(orderNo); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData orderRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Calendar createTimeS = Calendar.getInstance(); createTimeS.set(Calendar.DATE, 17); createTimeS.set(Calendar.HOUR_OF_DAY , 00); createTimeS.set(Calendar.MINUTE , 00); createTimeS.set(Calendar.SECOND , 00); Calendar createTimeE = Calendar.getInstance(); createTimeE.set(Calendar.DATE, 20); createTimeE.set(Calendar.HOUR_OF_DAY , 15); createTimeE.set(Calendar.MINUTE , 25); createTimeE.set(Calendar.SECOND , 00); Map param = new HashMap<>(); // param.put("createTimeS", createTimeS.getTimeInMillis()); // param.put("createTimeE", createTimeE.getTimeInMillis()); param.put("orderNo", orderNo); List orderRefundList = orderRefundService.getRefundOrderList(param); for (HighOrderRefund orderRefund : orderRefundList) { try { orderRefundService.refundPrice( orderRefund.getRefundOrderNo(), orderService.getOrderDetailByNo(orderRefund.getOrderNo()), OrderPayType.getDataByType(orderRefund.getPayType()), orderRefund.getRefundPrice(), orderRefund.getRefundIntegral() ); orderRefund.setExt1("true"); } catch (Exception e) { orderRefund.setExt1("false"); } finally { orderRefundService.update(orderRefund); } } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String orderTitle(OutRechargeOrder outRechargeOrder) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (outRechargeOrder.getOperatorType()) { case 1: return outRechargeOrder.getRechargeContent() + "电信话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 2: return outRechargeOrder.getRechargeContent() + "移动话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 3: return outRechargeOrder.getRechargeContent() + "联通话费充值" + outRechargeOrder.getRechargePrice() + "元"; default: return null; } } } \ No newline at end of file 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 6f31f835..b6f2624c 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java @@ -262,7 +262,7 @@ public class OutRechargePriceController { if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") ) && rechargeCodes.size() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); } for (BsRechargeCode rechargeCode : rechargeCodes) { @@ -270,11 +270,11 @@ public class OutRechargePriceController { if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4) ){ if (rechargeCode.getGoodsId() == null) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); } if (rechargeCode.getGoodsId().length() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!"); } } diff --git a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java index 8a66f8f8..391d5090 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java @@ -18,6 +18,7 @@ import com.hai.model.UserInfoModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; +import com.hai.order.type.RechargePlatformType; import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeOrderService; import com.hai.service.impl.OutRechargeOrderServiceImpl; @@ -174,6 +175,7 @@ public class OrderMobileRechargeController { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(thirdPartyModel.getOrderNo()); if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { model.setRegOrderNo(outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); + model.setRechargePlatform(RechargePlatformType.getDataByType(outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform()).getName()); } model.setMemPhone(thirdPartyModel.getMemPhone()); model.setTitle(thirdPartyModel.getTitle()); diff --git a/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java b/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java index 78c3659a..a6661e85 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java @@ -30,12 +30,14 @@ import java.io.PrintWriter; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.Objects; @Controller @RequestMapping(value = "telChargeCallback") @Api(value = "话费充值回调业务") public class OrderTelChargeCallbackController { + private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); @Resource @@ -44,18 +46,6 @@ public class OrderTelChargeCallbackController { @Resource private OutRechargeChildOrderService outRechargeChildOrderService; - @Resource - private HighUserService highUserService; - - @Resource - private ApiOrderRecordService apiOrderRecordService; - - @Resource - private HighOrderService highOrderService; - - @Resource - private OrderService orderService; - @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) @ApiOperation(value = "尖椒充值回调") @@ -69,40 +59,13 @@ public class OrderTelChargeCallbackController { log.info("尖椒订单充值-回调参数: " + dataObject); log.info("============回调任务End============="); - // 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()); - - // 判断是否充值成功 并发送微信小程序服务通知 + // 判断是否充值成功 if (dataObject.getInteger("status") == 3) { - if (rechargeOrder.getRechargeStatus() ==201) { - 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(); - } - - outRechargeOrderService.completeOrder(rechargeOrder , childOrder); - - // api商户订单 - if (rechargeOrder.getPayType() == 6) { - apiOrderRecord(rechargeOrder); - } - + // 充值成功操作 + outRechargeOrderService.completeOrder(dataObject.getString("out_order_id")); } else { // 充值失败操作 - callbackResult(childOrder , rechargeOrder); + callbackResult(dataObject.getString("out_order_id")); } response.setCharacterEncoding("UTF-8"); @@ -132,31 +95,11 @@ public class OrderTelChargeCallbackController { log.info("龙阅订单充值-回调参数: " + reqBodyStr); log.info("============回调任务End============="); - OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); - - OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - - // 判断是否充值成功 并发送微信小程序服务通知 + // 判断是否充值成功 if (state == 1) { - if (rechargeOrder.getRechargeStatus() ==201) { - 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(); - } - outRechargeOrderService.completeOrder(rechargeOrder , childOrder); - // todo 代理商话费回调 -// if (rechargeOrder.getPayType() == 6) { -// apiOrderRecord(rechargeOrder); -// } + outRechargeOrderService.completeOrder(out_trade_num); } else { - callbackResult(childOrder , rechargeOrder); + callbackResult(out_trade_num); } response.setCharacterEncoding("UTF-8"); @@ -170,55 +113,76 @@ public class OrderTelChargeCallbackController { } } - // 充值回调结果处理 - 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) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); - -// // 判断快充 并且 充值时间小于6 -// if (rechargeOrder.getRechargeType() == 1 && hours < 6) { -// outRechargeOrderService.pollRequest(rechargeOrder); -// return; -// } - // 判断慢充 并且 充值时间小于72 - if (hours < 72) { - outRechargeOrderService.pollRequest(rechargeOrder); - return; + @RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST) + @ApiOperation(value = "畅停充值回调") + @ResponseBody + public void rechargeCallbackByHg( + @RequestParam(name = "mchid", required = false) String mchid, + @RequestParam(name = "out_order_id", required = false) String out_order_id, + @RequestParam(name = "orderid", required = true) String orderid, + @RequestParam(name = "return_time", required = false) String return_time, + @RequestParam(name = "return_price", required = false) String return_price, + @RequestParam(name = "recharge_price", required = false) String recharge_price, + @RequestParam(name = "price", required = false) String price, + @RequestParam(name = "status", required = true) String status, + @RequestParam(name = "phone", required = false) String phone, + @RequestParam(name = "secret_key", required = false) String secret_key, + HttpServletResponse response) { + try { + + + + JSONObject dataObject = new JSONObject(); + + dataObject.put("mchid" , mchid); + dataObject.put("out_order_id" , out_order_id); + dataObject.put("orderid" , orderid); + dataObject.put("return_time" , return_time); + dataObject.put("return_price" , return_price); + dataObject.put("recharge_price" , recharge_price); + dataObject.put("price" , price); + dataObject.put("status" , status); + dataObject.put("phone" , phone); + dataObject.put("secret_key" , secret_key); + + log.info("============回调任务Start============="); + log.info("畅停订单充值-回调参数: " + dataObject); + log.info("============回调任务End============="); + + // 判断是否充值成功 并发送微信小程序服务通知 + if (Objects.equals(status, "1")) { + + outRechargeOrderService.completeOrder(orderid); + + } else { + // 充值失败操作 + callbackResult(orderid); } - outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("success"); - // 发送充值失败 微信小程序服务通知 - new Thread(() -> { - HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); - WxMsgConfig.rechargedFail( - rechargeOrder.getRechargeContent() + "充值失败", - String.valueOf(rechargeOrder.getPayRealPrice()), - highUser.getOpenId()); - }).start(); + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); } - } - private void apiOrderRecord(OutRechargeOrder rechargeOrder) { - Map orderMap = new HashMap<>(); - orderMap.put("orderId" , rechargeOrder.getId()); + // 充值回调结果处理 + private void callbackResult(String orderNo) { - // 查询是否用重复订单 - ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); + // 查询充值订单 + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); + OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0); - apiOrderRecord.setStatus(100); - apiOrderRecord.setRequestTime(new Date()); - apiOrderRecordService.updateOrderRecord(apiOrderRecord); + childOrder.setStatus(103); + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.updateOrder(childOrder); + rechargeOrder.setRechargeStatus(205); + outRechargeOrderService.updateOrder(rechargeOrder); } diff --git a/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java b/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java index b470195a..9a2c5b03 100644 --- a/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java +++ b/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java @@ -38,17 +38,6 @@ public class MobileRechargeNotifyController { @Resource private OutRechargeChildOrderService outRechargeChildOrderService; - @Resource - private HighUserService highUserService; - - @Resource - private ApiOrderRecordService apiOrderRecordService; - - @Resource - private HighOrderService highOrderService; - - @Resource - private OrderService orderService; @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) @ApiOperation(value = "尖椒充值回调") @@ -62,35 +51,13 @@ public class MobileRechargeNotifyController { log.info("尖椒订单充值-回调参数: " + dataObject); log.info("============回调任务End============="); - // 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()); - - // 判断是否充值成功 并发送微信小程序服务通知 + // 判断是否充值成功 if (dataObject.getInteger("status") == 3) { - if (rechargeOrder.getRechargeStatus() ==201) { - 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(); - } - - outRechargeOrderService.completeOrder(rechargeOrder , childOrder); - + // 充值成功操作 + outRechargeOrderService.completeOrder(dataObject.getString("out_order_id")); } else { // 充值失败操作 - callbackResult(childOrder , rechargeOrder); + callbackResult(dataObject.getString("out_order_id")); } response.setCharacterEncoding("UTF-8"); @@ -120,27 +87,11 @@ public class MobileRechargeNotifyController { log.info("龙阅订单充值-回调参数: " + reqBodyStr); log.info("============回调任务End============="); - OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); - - OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - - // 判断是否充值成功 并发送微信小程序服务通知 + // 判断是否充值成功 if (state == 1) { - if (rechargeOrder.getRechargeStatus() ==201) { - 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(); - } - outRechargeOrderService.completeOrder(rechargeOrder , childOrder); + outRechargeOrderService.completeOrder(out_trade_num); } else { - callbackResult(childOrder , rechargeOrder); + callbackResult(out_trade_num); } response.setCharacterEncoding("UTF-8"); @@ -155,7 +106,7 @@ public class MobileRechargeNotifyController { } @RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST) - @ApiOperation(value = "嗨购充值回调") + @ApiOperation(value = "畅停充值回调") @ResponseBody public void rechargeCallbackByHg( @RequestParam(name = "mchid", required = false) String mchid, @@ -187,42 +138,17 @@ public class MobileRechargeNotifyController { dataObject.put("secret_key" , secret_key); log.info("============回调任务Start============="); - log.info("嗨购订单充值-回调参数: " + dataObject); + log.info("畅停订单充值-回调参数: " + dataObject); log.info("============回调任务End============="); - // 1 尖椒 2 龙阅 - - // 查询充值记录订单 - OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(orderid); - - // 查询充值订单 - OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - // 判断是否充值成功 并发送微信小程序服务通知 if (Objects.equals(status, "1")) { - if (rechargeOrder.getRechargeStatus() ==201) { - 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(); - } - - outRechargeOrderService.completeOrder(rechargeOrder , childOrder); - - // api商户订单 -// if (rechargeOrder.getPayType() == 6) { -// apiOrderRecord(rechargeOrder); -// } + + outRechargeOrderService.completeOrder(orderid); } else { // 充值失败操作 - callbackResult(childOrder , rechargeOrder); + callbackResult(orderid); } response.setCharacterEncoding("UTF-8"); @@ -238,54 +164,19 @@ public class MobileRechargeNotifyController { // 充值回调结果处理 - 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) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); - -// // 判断快充 并且 充值时间小于6 -// if (rechargeOrder.getRechargeType() == 1 && hours < 6) { -// outRechargeOrderService.pollRequest(rechargeOrder); -// return; -// } - // 判断慢充 并且 充值时间小于72 - if (hours < 72) { - outRechargeOrderService.pollRequest(rechargeOrder); - return; - } + private void callbackResult(String orderNo) { - outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); + // 查询充值订单 + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); + OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0); - // 发送充值失败 微信小程序服务通知 - new Thread(() -> { - HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); - WxMsgConfig.rechargedFail( - rechargeOrder.getRechargeContent() + "充值失败", - String.valueOf(rechargeOrder.getPayRealPrice()), - highUser.getOpenId()); - }).start(); - - } + childOrder.setStatus(103); + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.updateOrder(childOrder); + rechargeOrder.setRechargeStatus(205); + outRechargeOrderService.updateOrder(rechargeOrder); } - private void apiOrderRecord(OutRechargeOrder rechargeOrder) { - Map orderMap = new HashMap<>(); - orderMap.put("orderId" , rechargeOrder.getId()); - - // 查询是否用重复订单 - ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); - - apiOrderRecord.setStatus(100); - apiOrderRecord.setRequestTime(new Date()); - apiOrderRecordService.updateOrderRecord(apiOrderRecord); - - } } diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java index ddf8e019..b2e6de2f 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java @@ -53,7 +53,7 @@ public class HighRechargeOrderSchedule { * @Date 14:18 2022/5/31 * @Param [] */ - @Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次 + @Scheduled(cron = "0 0/5 * * * ?") //每5分钟执行一次 public void initRechargeOrder() { Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); @@ -62,27 +62,20 @@ public class HighRechargeOrderSchedule { if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { - // 查询充值子订单 - Map childOrderMap = new HashMap<>(); - childOrderMap.put("parent_order_id", order.getId()); - childOrderMap.put("status", 102); - - List childOrderList = rechargeChildOrderService.getListRechargeChildOrder(childOrderMap); - - if (childOrderList.size() == 0) { - Date rechargeTime = order.getCreateTimed(); - Date currentTime = new Date(); - int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); - - // 充值时间小于72 - if (hours < 72) { - outRechargeOrderService.pollRequest(order); - continue; - } - - outRechargeOrderService.rechargeOrderHandle(order , childOrderList.get(0)); + // 定义小时数 + Date rechargeTime = order.getCreateTimed(); + Date currentTime = new Date(); + int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); + + // 查询当前订单是否超时 如果超过72小时则处理退款 + if (hours < 72) { + outRechargeOrderService.pollRequest(order); + } else { + // 话费订单处理 + outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); } + } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } @@ -91,29 +84,5 @@ public class HighRechargeOrderSchedule { System.out.println("话费定时任务 -> 结束任务"); } - @Scheduled(cron = "0 0/30 * * * ?") //每30分钟执行一次 - public void failRechargeOrder() { - List highOrders = orderService.phoneErrorOrder(); - - - for (HighOrder order: highOrders) { - - try { - - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); - - OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - - if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { - childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); - } - outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder); - - - } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", 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 52be2091..7766c62f 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 @@ -468,7 +468,7 @@ public class WxUtils { } /** - * 生成嗨购签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 + * 生成畅停签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 * * @param data 待签名数据 * @param key API密钥 diff --git a/hai-service/src/main/java/com/hai/config/RechargeConfig.java b/hai-service/src/main/java/com/hai/config/RechargeConfig.java index 637ac8df..71e40c93 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -214,7 +214,7 @@ public class RechargeConfig { /** * @Author Sum1Dream * @Name checkOrderByHg - * @Description // 查询嗨购订单下单 + * @Description // 查询畅停订单下单 * @Date 14:50 2023/2/8 * @Param [object] * @Return com.alibaba.fastjson.JSONObject @@ -231,12 +231,12 @@ public class RechargeConfig { paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); log.info("============请求任务Start============="); - log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); - System.out.println("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + System.out.println("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>()); - log.info("嗨购话费查询订单-响应参数: " + repsObject.toJSONString()); + log.info("畅停话费查询订单-响应参数: " + repsObject.toJSONString()); log.info("============请求任务End=============="); return repsObject; } @@ -244,7 +244,7 @@ public class RechargeConfig { /** * @Author Sum1Dream * @Name searchOrder - * @Description // 嗨购话费查询订单详情 + * @Description // 畅停话费查询订单详情 * @Date 11:39 2023/2/7 * @Param [object] * @Return com.alibaba.fastjson.JSONObject @@ -257,11 +257,11 @@ public class RechargeConfig { paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); log.info("============请求任务Start============="); - log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>()); - log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); + log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("============请求任务End=============="); return jsonObject; } @@ -273,11 +273,11 @@ public class RechargeConfig { paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); log.info("============请求任务Start============="); - log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "/external/api/searchProduct", paramSort(paramMap) , new HashMap<>()); - log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); + log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("============请求任务End=============="); return jsonObject; } diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargeChildOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/OutRechargeChildOrderMapperExt.java index 773f9608..675ae08d 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargeChildOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargeChildOrderMapperExt.java @@ -1,7 +1,31 @@ package com.hai.dao; +import com.hai.entity.OutRechargeChildOrder; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + /** * mapper扩展类 */ public interface OutRechargeChildOrderMapperExt { -} \ No newline at end of file + + @Select({ + "select * from out_recharge_child_order order by id desc limit 1;" + }) + @Results({ + @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), + @Result(column="parent_order_id", property="parentOrderId", jdbcType=JdbcType.BIGINT), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="recharge_platform", property="rechargePlatform", jdbcType=JdbcType.INTEGER), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="create_time", property="createTime", 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) + }) + OutRechargeChildOrder findOutRechargeChildOrderByDesc(); + +} diff --git a/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java b/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java index de18ee76..a9043da4 100644 --- a/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java +++ b/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java @@ -29,7 +29,7 @@ public class BsRechargeCode implements Serializable { private String sourceId; /** - * 充值平台:充值平台 1:尖椒 2:龙阅 3:城宇 4.嗨购 + * 充值平台:充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停 */ private Integer rechargePlatform; diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java b/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java index 9f4b07b3..f1dd325d 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java @@ -126,7 +126,7 @@ public class OutRechargeOrder implements Serializable { private Integer payStatus; /** - * 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 + * 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 205: 待充值 */ private Integer rechargeStatus; diff --git a/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java index 53ac4124..2c58d2d9 100644 --- a/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java +++ b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java @@ -24,6 +24,10 @@ public class OrderThirdPartyModel { @ExcelProperty(value = "充值订单号") private String regOrderNo; + @ColumnWidth(25) + @ExcelProperty(value = "充值平台") + private String rechargePlatform; + @ColumnWidth(15) @ExcelProperty(value = "客户电话") private String memPhone; diff --git a/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java b/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java new file mode 100644 index 00000000..d515399b --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java @@ -0,0 +1,54 @@ +package com.hai.order.type; + +import java.util.Objects; + +/** + * 子订单状态 + * @className: OrderChildGoodsType + * @author: HuRui + * @date: 2022/8/24 + **/ +public enum RechargePlatformType { + STATUS1(1, "尖椒"), + STATUS2(2, "龙阅"), + STATUS3(3, "城宇"), + STATUS4(4, "畅停"), + ; + + private Integer number; + + private String name; + + RechargePlatformType(int number, String name) { + this.number = number; + this.name = name; + } + + /** + * 根据类型查询数据 + * @param type + * @return + */ + public static RechargePlatformType getDataByType(Integer type) { + for (RechargePlatformType ele : values()) { + if(Objects.equals(type,ele.getNumber())) return ele; + } + return null; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java index 198e79f0..cb94e46c 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java @@ -77,4 +77,14 @@ public interface OutRechargeChildOrderService { **/ void updateOrder(OutRechargeChildOrder rechargeChildOrder); + /** + * @Author Sum1Dream + * @Name findOutRechargeChildOrderByDesc + * @Description //根据id 查询最后一条充值记录 + * @Date 15:29 2023/2/27 + * @Param [] + * @Return com.hai.entity.OutRechargeChildOrder + */ + OutRechargeChildOrder findOutRechargeChildOrderByDesc(); + } 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 52313892..a3ebaded 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -42,7 +42,7 @@ public interface OutRechargeOrderService { **/ OutRechargeOrder findByOrderNo(String orderNo); - /*** + /*** todo 当前接口已经废弃 * @Author Sum1Dream * @Description // 新增订单 * @Date 15:25 2021/6/11 @@ -152,7 +152,7 @@ public interface OutRechargeOrderService { * @Param [order, childOrder] * @Return void */ - void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder); + void completeOrder(String orderNo); /** @@ -184,7 +184,7 @@ public interface OutRechargeOrderService { * @Param [outRechargeOrder, childOrder] * @Return void */ - void rechargeOrderHandle(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; + void rechargeOrderHandle(String orderNo) throws Exception; /** * @Author Sum1Dream 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 index e19c5bab..10cc548d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java @@ -96,4 +96,9 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe public void updateOrder(OutRechargeChildOrder rechargeChildOrder) { rechargeChildOrderMapper.updateByPrimaryKey(rechargeChildOrder); } + + @Override + public OutRechargeChildOrder findOutRechargeChildOrderByDesc() { + return rechargeChildOrderMapper.findOutRechargeChildOrderByDesc(); + } } 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 50f9ac93..6c592414 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 @@ -1,20 +1,16 @@ package com.hai.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.alicp.jetcache.anno.CacheType; -import com.alicp.jetcache.anno.Cached; + 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.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; -import com.hai.dao.HighOrderMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.entity.*; @@ -22,33 +18,26 @@ import com.hai.enum_type.*; import com.hai.model.*; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildStatus; +import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; -import io.swagger.models.auth.In; 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.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; + @Service("outRechargeOrderService") public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @@ -213,6 +202,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrder; } + // todo 接口已经废弃 @Override @Transactional( isolation = Isolation.SERIALIZABLE, @@ -592,16 +582,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); } + // 订单处理 HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); orderService.refundOrder(highOrder, "话费自动退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); + + // 话费充值业务订单处理 outRechargeOrder.setPayStatus(105); outRechargeOrder.setRechargeStatus(203); outRechargeOrder.setRefundTime(new Date()); outRechargeOrderService.updateOrder(outRechargeOrder); - // 子订单修改状态 + // 充值订单记录修改状态 childOrder.setStatus(103); outRechargeChildOrderService.updateOrder(childOrder); } @@ -625,7 +618,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 定义新的子订单对象 OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - // 初始化充值平台 1:尖椒 2:龙阅 3:畅停 4.嗨购 + // 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停 int platformType = 0; // 判断子订单是否存在充值中订单 @@ -638,19 +631,22 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (status == 0 || status == 3 || status == 99) { return; } else if (status == 1) { - completeOrder(outRechargeOrder , childOrder); + completeOrder(outRechargeOrder.getOrderNo()); } + // 修改充值记录状态 childOrder.setStatus(103); childOrder.setUpdateTime(new Date()); outRechargeChildOrderService.updateOrder(childOrder); - platformType = childOrder.getRechargePlatform(); - } + // 获取充值平台 + platformType = getRechargePlatformType(); + + // 定义下单请求数据对象 JSONObject object = new JSONObject(); - // 定义充值订单号 + // 定义新充值订单号 String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); // 查询平台 @@ -661,9 +657,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (string.length() == 1) { platformType = Integer.parseInt(string); } else { + // 如果平台充值记录暂无 则充值第一个 if (platformType == 0) { platformType = Integer.parseInt(rechargePlatform[0]); } else { + // 获取上一条充值平台的下一个平台内容 platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); } @@ -729,7 +727,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { childOrder.setRechargePlatform(3); break; } - // 嗨购充值 + // 畅停充值 if (s.equals("4") && platformType == 4) { map.put("sourceId" , outRechargePrice.getId()); @@ -771,12 +769,20 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } @Override - public void completeOrder(OutRechargeOrder order, OutRechargeChildOrder childOrder) { + public void completeOrder(String orderNo) { + + OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); + OutRechargeChildOrder childOrder = order.getOutRechargeChildOrders().get(0); + + // 修改话费充值业务订单状态 childOrder.setStatus(101); order.setRechargeStatus(202); order.setPayStatus(100); order.setFinishTime(new Date()); + outRechargeOrderService.updateOrder(order); + outRechargeChildOrderService.updateOrder(childOrder); + // 修改订单状态 HighOrder highOrder = highOrderService.getOrderByOrderNo(order.getOrderNo()); if (highOrder != null) { highOrder.setOrderStatus(OrderStatusEnum.type3.getType()); @@ -788,8 +794,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { orderService.updateOrderData(highOrder); } - outRechargeOrderService.updateOrder(order); - outRechargeChildOrderService.updateOrder(childOrder); + + // 推送小程序消息 + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(highOrder.getMemId()); + WxMsgConfig.rechargedSuccess( + order.getRechargeContent() + "充值成功", + String.valueOf(order.getPayRealPrice()), + order.getOrderNo(), + order.getFinishTime(), + OrderPayType.getDataByType(order.getPayType()).getName(), + highUser.getOpenId()); + }).start(); + } @@ -818,18 +835,26 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } @Override - public void rechargeOrderHandle(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { + public void rechargeOrderHandle(String orderNo) throws Exception { + + // 定义话费充值业务订单模型 or 充值记录订单模型 + OutRechargeOrder outRechargeOrder = findByOrderNo(orderNo); + OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); + + // 状态需要支付状态为已充值 并且 充值状态不为 充值成功 if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { + // 判断充值记录是否存在 if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { + // OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); - outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); outRechargeChildOrder.setUpdateTime(new Date()); outRechargeChildOrder.setCreateTime(new Date()); - + outRechargeChildOrderService.insertOrder(outRechargeChildOrder); + // 话费退款 refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else { // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 @@ -837,7 +862,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (status == 2 || status == -1) { refundOrder(outRechargeOrder.getId() , childOrder); } else if (status == 1) { - completeOrder(outRechargeOrder , childOrder); + completeOrder(outRechargeOrder.getOrderNo()); } } @@ -868,7 +893,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } } - // 嗨购 + // 畅停 if (childOrder.getRechargePlatform() == 4) { object.put("orderid" , childOrder.getOrderNo()); @@ -898,4 +923,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } return 99; } + + private Integer getRechargePlatformType() { + OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc(); + + if (outRechargeChildOrder != null) { + return outRechargeChildOrder.getRechargePlatform(); + } + return 0; + } } 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 242873dd..084dd710 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 @@ -54,6 +54,7 @@ public class RechargeOrderServiceImpl implements PayService { + // todo 当前接口已经废弃 @Override public void paySuccess(Map map, String payType) throws Exception {