diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java new file mode 100644 index 00000000..7d826eb5 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java @@ -0,0 +1,27 @@ +package com.bweb.controller.ApiMchProduct; + +import com.hai.common.security.UserCenter; +import com.hai.openApi.service.ApiMchProductService; +import io.swagger.annotations.Api; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.annotation.Resource; + +@Controller +@RequestMapping(value = "/apiMchProduct") +@Api(value = "API商户产品配置") +public class ApiMchProductController { + + Logger log = LoggerFactory.getLogger(ApiMchProductController.class); + + @Resource + private ApiMchProductService apiMchProductService; + + @Autowired + private UserCenter userCenter; + +} 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 6e967205..82526ab3 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.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; @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(); JSONObject object; for (HighOrder order: highOrders) { object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); try { 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()); outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else { if (outRechargeOrder.getOutRechargeChildOrders().get(0).getStatus() != 101) { // 龙阅 if (outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform() == 2) { object.put("out_trade_nums" , outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } else { // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } else if (objectData.getInteger("state") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , outRechargeOrder.getOutRechargeChildOrders().get(0)); } } } } } } } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); } } return ResponseMsgUtil.success("null"); } @RequestMapping(value = "/checkOrderByLy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "龙阅话费查询") public ResponseData checkOrderByLy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder outRechargeChildOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); object.put("out_trade_nums" , outRechargeChildOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else { if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else if (objectData.getInteger("state") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , outRechargeChildOrder); } } return ResponseMsgUtil.success(objectJSONArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkOrderByLyDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "龙阅话费查询") public ResponseData checkOrderByLyDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder outRechargeChildOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); object.put("out_trade_nums" , outRechargeChildOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { return ResponseMsgUtil.success("无订单退款"); } else { if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { return ResponseMsgUtil.success("退款"); } else if (objectData.getInteger("state") == 1) { return ResponseMsgUtil.success("完成订单"); } } return ResponseMsgUtil.success(objectJSONArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ 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.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; @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(); JSONObject object; for (HighOrder order: highOrders) { object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); try { 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()); outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else { if (childOrder.getStatus() != 101) { // 龙阅 if (childOrder.getRechargePlatform() == 2) { object.put("out_trade_nums" , childOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); } else { // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); } else if (objectData.getInteger("state") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , childOrder); } } } // 嗨购 if (childOrder.getRechargePlatform() == 4) { object.put("orderid" , childOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); if (jsonObject.getJSONArray("data") == null) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); } else { JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData; for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; // 充值中1成功2失败3已取消4部分充值5缓存订单 if (objectData.getInteger("status") == 2 || objectData.getInteger("status") == 3) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); } else if (objectData.getInteger("status") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , childOrder); } } } } } } } } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); } } return ResponseMsgUtil.success("null"); } @RequestMapping(value = "/checkOrderByLy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "龙阅话费查询") public ResponseData checkOrderByLy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder outRechargeChildOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); object.put("out_trade_nums" , outRechargeChildOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else { if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); } else if (objectData.getInteger("state") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , outRechargeChildOrder); } } return ResponseMsgUtil.success(objectJSONArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkOrderByLyDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "龙阅话费查询") public ResponseData checkOrderByLyDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder outRechargeChildOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); object.put("out_trade_nums" , outRechargeChildOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } if (objectData.size() == 0) { return ResponseMsgUtil.success("无订单退款"); } else { if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { return ResponseMsgUtil.success("退款"); } else if (objectData.getInteger("state") == 1) { return ResponseMsgUtil.success("完成订单"); } } return ResponseMsgUtil.success(objectJSONArray); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderMigration", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单迁移") public ResponseData phoneBillOrderMigration() { try { Map map = new HashMap<>(); map.put("productType" , 9); List list = highOrderService.getOrderList(map); for (HighOrder order : list) { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); order.setTitle(outRechargeOrder.getRechargeContent() + order.getTitle()); highOrderService.updateOrder(order); } return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/resources/dev/logback.xml b/hai-bweb/src/main/resources/dev/logback.xml index a7602e3d..e1b0fbf5 100644 --- a/hai-bweb/src/main/resources/dev/logback.xml +++ b/hai-bweb/src/main/resources/dev/logback.xml @@ -56,7 +56,60 @@ UTF-8 - + + + + + log/wechatPay.log + + log/wechatPayLog/wechatPayLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/RechargeLog.log + + log/RechargeLog/RechargeLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/HltCardLog.log + + log/hlt/hltcard.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + @@ -69,4 +122,17 @@ + + + + + + + + + + + + + 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 f58f4f1b..92e261ef 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 @@ -61,6 +61,7 @@ public class OrderMobileRechargeController { public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, @RequestParam(name = "memPhone", required = false) String memPhone, @RequestParam(name = "memCardNo", required = false) String memCardNo, + @RequestParam(name = "title", required = false) String title, @RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "companyId", required = false) Long companyId, @@ -92,6 +93,7 @@ public class OrderMobileRechargeController { map.put("payTimeS", payTimeS); map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); + map.put("title", title); map.put("finishTimeE", finishTimeE); map.put("orderNo", orderNo); map.put("memPhone", memPhone); @@ -119,6 +121,7 @@ public class OrderMobileRechargeController { @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "title", required = false) String title, @RequestParam(name = "createTimeE", required = false) Long createTimeE, @RequestParam(name = "payTimeS", required = false) Long payTimeS, @RequestParam(name = "payTimeE", required = false) Long payTimeE, @@ -145,6 +148,7 @@ public class OrderMobileRechargeController { map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); map.put("finishTimeE", finishTimeE); + map.put("title", title); map.put("orderNo", orderNo); map.put("memPhone", memPhone); map.put("memCardNo", memCardNo); 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 106e29c1..805de457 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/5 * * * ?") //每5分钟执行一次 + @Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次 public void initRechargeOrder() { Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); @@ -79,7 +79,8 @@ public class HighRechargeOrderSchedule { outRechargeOrderService.pollRequest(order); continue; } - outRechargeOrderService.refundOrder(order.getId() , childOrderList.get(0)); + + outRechargeOrderService.rechargeOrderHandle(order , childOrderList.get(0)); } } catch (Exception e) { @@ -90,90 +91,25 @@ public class HighRechargeOrderSchedule { System.out.println("话费定时任务 -> 结束任务"); } - @Scheduled(cron = "0 0/3 * * * ?") //每30分钟执行一次 + @Scheduled(cron = "0 0/30 * * * ?") //每30分钟执行一次 public void failRechargeOrder() { List highOrders = orderService.phoneErrorOrder(); - JSONObject object; for (HighOrder order: highOrders) { try { - object = new JSONObject(); - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); 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()); - - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); - } else { - if (childOrder.getStatus() != 101) { - // 龙阅 - if (childOrder.getRechargePlatform() == 2) { - - object.put("out_trade_nums" , childOrder.getOrderNo()); - - JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); - - JSONArray objectJSONArray = jsonObject.getJSONArray("data"); - JSONObject objectData = new JSONObject(); - for (Object objects : objectJSONArray) { - objectData = (JSONObject) objects; - } - if (objectData.size() == 0) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); - } else { - // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 - if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); - } else if (objectData.getInteger("state") == 1) { - outRechargeOrderService.completeOrder(outRechargeOrder , childOrder); - } - } - - } - // 嗨购 - if (childOrder.getRechargePlatform() == 4) { - object.put("orderid" , childOrder.getOrderNo()); - - JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); - if (jsonObject.getJSONArray("data") == null) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); - } else { - JSONArray objectJSONArray = jsonObject.getJSONArray("data"); - JSONObject objectData; - for (Object objects : objectJSONArray) { - objectData = (JSONObject) objects; - // 充值中1成功2失败3已取消4部分充值5缓存订单 - if (objectData.getInteger("status") == 2 || objectData.getInteger("status") == 3) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); - } else if (objectData.getInteger("status") == 1) { - outRechargeOrderService.completeOrder(outRechargeOrder , childOrder); - } - } - } - } - } - } + outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder); + - } } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } - - } } diff --git a/hai-schedule/src/main/resources/dev/logback.xml b/hai-schedule/src/main/resources/dev/logback.xml index a7602e3d..1530667e 100644 --- a/hai-schedule/src/main/resources/dev/logback.xml +++ b/hai-schedule/src/main/resources/dev/logback.xml @@ -56,7 +56,59 @@ UTF-8 - + + + + log/wechatPay.log + + log/wechatPayLog/wechatPayLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/RechargeLog.log + + log/RechargeLog/RechargeLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/HltCardLog.log + + log/hlt/hltcard.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + @@ -69,4 +121,17 @@ + + + + + + + + + + + + + diff --git a/hai-schedule/src/main/resources/prod/logback.xml b/hai-schedule/src/main/resources/prod/logback.xml index f33cbad8..6474b2f9 100644 --- a/hai-schedule/src/main/resources/prod/logback.xml +++ b/hai-schedule/src/main/resources/prod/logback.xml @@ -57,6 +57,58 @@ UTF-8 + + + log/wechatPay.log + + log/wechatPayLog/wechatPayLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/RechargeLog.log + + log/RechargeLog/RechargeLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/HltCardLog.log + + log/hlt/hltcard.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + @@ -69,4 +121,17 @@ + + + + + + + + + + + + + diff --git a/hai-service/src/main/java/com/hai/common/utils/ArrayUtils.java b/hai-service/src/main/java/com/hai/common/utils/ArrayUtils.java new file mode 100644 index 00000000..fd573334 --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/ArrayUtils.java @@ -0,0 +1,16 @@ +package com.hai.common.utils; + +public class ArrayUtils { + + public static int arrayIndex(String [] array , String s) { + for (int i = 0; i < array.length; i++) { + if (s.equals(array[i])) { + if (i == array.length -1) { + return 0; + } + return i + 1; + } + } + return 0; + } +} 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 34be3a2f..637ac8df 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -225,7 +225,7 @@ public class RechargeConfig { paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId()); paramMap.put("phone" , object.getString("phone")); paramMap.put("orderid" , object.getString("orderid")); - paramMap.put("price" , object.getBigDecimal("price")); + paramMap.put("price" , object.getInteger("price").toString()); paramMap.put("product_id" , object.getString("product_id")); paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl()); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index e03119b2..62e6e8b2 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1224,7 +1224,7 @@ public interface HighOrderMapperExt { List getApiThirdOrderByList(@Param("map") Map map); - @Select("SELECT * FROM high_order WHERE create_time < NOW()-INTERVAL 3 day and product_type = 9 and order_status = 2 and pay_type = 4 group by create_time asc;") + @Select("SELECT * FROM high_order WHERE create_time < NOW()-INTERVAL 3 day and product_type = 9 and order_status = 2 group by create_time asc;") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), diff --git a/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java b/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java new file mode 100644 index 00000000..b4b3d283 --- /dev/null +++ b/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java @@ -0,0 +1,55 @@ +package com.hai.openApi.service; + +import com.hai.entity.ApiMchProduct; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName ApiMchProductService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 商户产品配置 + * @createTime 11:51 2023/2/15 + **/ +public interface ApiMchProductService { + + /** + * @Author Sum1Dream + * @Name insertMchProduct + * @Description // 新增商户产品 + * @Date 11:55 2023/2/15 + * @Param [apiMchProduct] + * @Return void + */ + void insertMchProduct(ApiMchProduct apiMchProduct); + /** + * @Author Sum1Dream + * @Name updateMchProduct + * @Description // 更新商户产品 + * @Date 11:55 2023/2/15 + * @Param [apiMchProduct] + * @Return void + */ + void updateMchProduct(ApiMchProduct apiMchProduct); + + /** + * @Author Sum1Dream + * @Name getListMchProduct + * @Description // 查询商户产品列表 + * @Date 11:55 2023/2/15 + * @Param [map] + * @Return java.util.List + */ + List getListMchProduct(Map map); + + /** + * @Author Sum1Dream + * @Name findById + * @Description // 根据id 查询商户产品 + * @Date 11:55 2023/2/15 + * @Param [id] + * @Return com.hai.entity.ApiMchProduct + */ + ApiMchProduct findById(Long id); +} diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java new file mode 100644 index 00000000..338aed5a --- /dev/null +++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java @@ -0,0 +1,37 @@ +package com.hai.openApi.service.impl; + +import com.hai.dao.ApiMchProductMapper; +import com.hai.entity.ApiMchProduct; +import com.hai.openApi.service.ApiMchProductService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("apiMchProductService") +public class ApiMchProductServiceImpl implements ApiMchProductService { + + @Resource + private ApiMchProductMapper apiMchProductMapper; + + @Override + public void insertMchProduct(ApiMchProduct apiMchProduct) { + apiMchProductMapper.insert(apiMchProduct); + } + + @Override + public void updateMchProduct(ApiMchProduct apiMchProduct) { + apiMchProductMapper.updateByPrimaryKey(apiMchProduct); + } + + @Override + public List getListMchProduct(Map map) { + return null; + } + + @Override + public ApiMchProduct findById(Long id) { + return apiMchProductMapper.selectByPrimaryKey(id); + } +} 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 0eac3919..52313892 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -60,8 +60,6 @@ public interface OutRechargeOrderService { **/ void updateOrder(OutRechargeOrder outRechargeOrder); - void updateOrderList(List rechargeOrders) throws Exception; - /** * @Author Sum1Dream * @Description //取消订单 Administrator @@ -87,15 +85,6 @@ public interface OutRechargeOrderService { */ List getOrderCount(Map map) throws Exception; - /** - * @Author Sum1Dream - * @Description //查询订单未支付数量 Administrator - * @Date 10:53 2021/6/14 - * @Param [] - * @return java.lang.Integer - **/ - Long CountOrder(); - /** * @Author Sum1Dream * @Description //TODO Administrator @@ -114,26 +103,6 @@ public interface OutRechargeOrderService { **/ List getUserCountList(Map map) throws Exception; - /** - * @Author Sum1Dream - * @name hltUnionCardPay.java - * @Description // 汇联通支付 - * @Date 17:21 2022/5/25 - * @Param [java.lang.Long, com.hai.entity.OutRechargeOrder] - * @return void - */ - void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception; - - - /** - * @Author Sum1Dream - * @name getOutRechargeOrderList.java - * @Description // 查询话费充值超过15分钟订单 - * @Date 3:34 下午 2021/12/10 - * @Param [] - * @return java.util.List - */ - List getOutRechargeOrderList(); /** * @Author Sum1Dream @@ -185,25 +154,6 @@ public interface OutRechargeOrderService { */ void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder); - /** - * @Author Sum1Dream - * @name rechargeOrderNum.java - * @Description // 查询充值订单待支付数量 - * @Date 17:49 2022/5/30 - * @Param [java.lang.Long] - * @return java.lang.Integer - */ - Integer rechargeOrderNum(Long userId); - - /** - * @Author Sum1Dream - * @name integralRebateRechargeOrder.java - * @Description // 查询话费未返利订单 - * @Date 17:49 2022/5/30 - * @Param [java.lang.Long] - * @return java.lang.Integer - */ - List integralRebateRechargeOrder(); /** * @Author Sum1Dream @@ -226,4 +176,24 @@ public interface OutRechargeOrderService { */ void editOutRechargeOrder(HighOrder order); + /** + * @Author Sum1Dream + * @Name refundLegality + * @Description // 话费订单处理 + * @Date 14:45 2023/2/15 + * @Param [outRechargeOrder, childOrder] + * @Return void + */ + void rechargeOrderHandle(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; + + /** + * @Author Sum1Dream + * @Name getRechargeOrderLegality + * @Description // 判断话费订单合法性 + * @Date 15:57 2023/2/15 + * @Param [object] + * @Return void + */ + Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; + } 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 f1a627b0..2ad9c977 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,6 +1,7 @@ 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; @@ -47,6 +48,7 @@ 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 { @@ -414,19 +416,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); } - @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) - public void updateOrderList(List rechargeOrders) throws Exception { - for (OutRechargeOrder list : rechargeOrders) { -// if (list.getStatus() == 3) { -// outRechargeOrderMapper.updateByPrimaryKey(list); -// } else if (list.getStatus() == 6) { -// rechargeOrderToRefund(list.getId()); -// } - - } - } - @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void cancelOrder(Long orderId) { @@ -495,12 +484,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.selectOrderCount(map); } - @Override - public Long CountOrder() { - OutRechargeOrderExample example = new OutRechargeOrderExample(); -// example.createCriteria().andStatusEqualTo(2); - return outRechargeOrderMapper.countByExample(example); - } @Override public List getListOrderCount(Map map) throws Exception { @@ -580,231 +563,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapperExt.getListUserCount(fTimeS, fTimeE); } - @Override - public void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception { - - String goodsDesc = "充值话费"; - String tranDesc = order.getRechargeContent() + "充值" + order.getPayRealPrice() + "元话费"; - String instCode = "11101527"; - String businessType = "hisen_consume"; - - // 工会卡支付 - JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc); - System.out.println("工会卡支付响应参数" + consumption.toJSONString()); - - Map dataMap = new HashMap<>(); - dataMap.put("orderNo", order.getOrderNo()); - dataMap.put("cardType", "ghk"); - dataMap.put("cardNo", userCard.getCardNo()); - dataMap.put("checkPassword", "N"); - dataMap.put("tranAmount", order.getPayRealPrice()); - dataMap.put("tranChannel", "HiSen"); - dataMap.put("businessType", businessType); - dataMap.put("instCode", instCode); - dataMap.put("goodsDesc", goodsDesc); - dataMap.put("tranDesc", tranDesc); - HighGasOrderPush payPush = new HighGasOrderPush(); - payPush.setType(OrderPushType.type5.getType()); - payPush.setOrderNo(order.getOrderNo()); - payPush.setCreateTime(new Date()); - payPush.setCode(consumption.getString("respCode")); - payPush.setRequestContent(JSON.toJSONString(dataMap)); - payPush.setReturnContent(consumption.toJSONString()); - highGasOrderPushMapper.insert(payPush); - - if (!consumption.getString("respCode").equals("0000")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); - } - JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); - if (!consumptionResult.getBoolean("success")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); - } - order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 - order.setPayRealPrice(order.getPayRealPrice()); // 实付金额 - order.setPayStatus(102); - order.setRechargeStatus(204); - order.setLaborUnionCard(userCard.getCardNo()); - order.setPayType(3); - order.setPayTime(new Date()); // 支付时间 - updateOrder(order); - outRechargeOrderService.pollRequest(order); - - } - - @Override - public List getOutRechargeOrderList() { - return outRechargeOrderMapper.getCloseOrder(); - } - @Override public OrderCountModel rechargeOrderByIndex(Integer code) { return outRechargeOrderMapper.rechargeOrderByIndex(code); } - - @Override public void rechargeOrderToRefund(Long orderId) throws Exception { - OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); - - // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getPayStatus() != 102) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); - } - - // 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 - if (order.getRechargeStatus() == 201) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态"); - } - - // 微信退款 - if (order.getPayType() == 2) { - Map param = new HashMap<>(); - param.put("appid", "wx637bd6f7314daa46"); - param.put("mch_id", "1289663601"); - param.put("sub_mch_id", "1614670195"); - param.put("nonce_str", WxUtils.makeNonStr()); - param.put("transaction_id", order.getPaySerialNo()); - param.put("out_refund_no", "HFR" + new Date().getTime()); - param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); - param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); - param.put("sign_type", "HMAC-SHA256"); - - String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); - param.put("sign", signStr); - - String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); - OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); - if (orderRefundModel.getResult_code().equals("SUCCESS")) { - order.setPayStatus(105); - order.setRechargeStatus(203); - order.setRefundTime(new Date()); - order.setOutRefundNo(orderRefundModel.getOut_refund_no()); - order.setRefundId(orderRefundModel.getRefund_id()); - order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); - outRechargeOrderService.updateOrder(order); - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:" + orderRefundModel.getErr_code() + ",错误描述" + orderRefundModel.getErr_code_des()); - } - } - - // 工会卡退款 - if (order.getPayType() == 3) { - JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); - - if (jsonObject == null) { - jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); - } - - JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); - - if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { - order.setPayStatus(105); - order.setRechargeStatus(203); - order.setRefundTime(new Date()); - order.setOutRefundNo("HFR" + new Date().getTime()); - order.setRefundFee(order.getPayRealPrice()); - order.setRefundId(dataObject.getString("orderId")); - outRechargeOrderService.updateOrder(order); - - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); - } - - // 商户预充值 帐户退款 - if (order.getPayType() == 6) { - - Map map = new HashMap<>(); - map.put("orderNo" , order.getOrderNo()); - map.put("amountType" , 1); - map.put("sourceType" , 2); - - if ( apiAmountRecordService.getApiAmountRecordByList(map).size() == 1) { - - ApiMerchants apiMerchants = apiMerchantsService.findByMchId(order.getMerchId()); - // 插入金额记录 - // 变更前金额 - BigDecimal beforeAmount = apiMerchants.getAmounts(); - // 计算金额 - apiMerchants.setAmounts(apiMerchants.getAmounts().add(order.getPayPrice())); - // 变更后金额 - BigDecimal afterAmount = apiMerchants.getAmounts(); - - apiMerchantsService.updateApiMerchants(apiMerchants); - - ApiAmountRecord apiAmountRecord = new ApiAmountRecord(); - - apiAmountRecord.setCreateTime(new Date()); - apiAmountRecord.setUpdateTime(new Date()); - apiAmountRecord.setMchId(order.getMerchId()); - - apiAmountRecord.setStatus(100); - apiAmountRecord.setAmount(order.getPayPrice()); - apiAmountRecord.setAfterAmount(afterAmount); - apiAmountRecord.setBeforeAmount(beforeAmount); - apiAmountRecord.setAmountType(1); - apiAmountRecord.setSourceType(2); - apiAmountRecord.setSourceOrderNo(order.getOrderNo()); - apiAmountRecord.setSourceId(order.getId()); - apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|订单退款" + order.getPayPrice()); - - apiAmountRecordService.insertAmountRecord(apiAmountRecord); - - Map orderMap = new HashMap<>(); - orderMap.put("orderId" , order.getId()); - - // 查询是否用重复订单 - ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); - - apiOrderRecord.setStatus(100); - apiOrderRecord.setRequestTime(new Date()); - apiOrderRecordService.updateOrderRecord(apiOrderRecord); - } - - } - } - - // 银联退款 - if (order.getPayType() == 4) { - // 订单退款 - JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); - if (!refund.getString("resultcode").equals("W6")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); - } - order.setPayStatus(105); - order.setRechargeStatus(203); - order.setRefundTime(new Date()); - order.setOutRefundNo(refund.getString("oriwtorderid")); - order.setRefundFee(order.getPayRealPrice()); - outRechargeOrderService.updateOrder(order); - } - - - if (order.getMemDiscountId() != null) { - HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); - if (rel != null) { - rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - rel.setUseTime(null); - highDiscountUserRelService.updateDiscountUserRel(rel); - - HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); - code.setStatus(2); - highDiscountAgentCodeService.updateCode(code); - } - } - - - // 退还积分 - if (order.getIntegralNum().compareTo(new BigDecimal(0)) > 0) { - String remark = "话费订单" + order.getOrderNo() + "退款,退还积分:" + order.getIntegralNum().intValue(); - highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId() , remark); - if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { - order.setPayStatus(105); - order.setRechargeStatus(203); - order.setRefundTime(new Date()); - outRechargeOrderService.updateOrder(order); - } - } } @@ -841,87 +606,51 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeChildOrderService.updateOrder(childOrder); } - public String doRefundRequest(String mchId, String data) throws Exception { - - //小程序退款需要调用双向证书的认证 - CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); - try { - HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 - httpost.addHeader("Connection", "keep-alive"); - httpost.addHeader("Accept", "*/*"); - httpost.addHeader("Content-Type", "text/xml"); - httpost.addHeader("Host", "api.mch.weixin.qq.com"); - httpost.addHeader("X-Requested-With", "XMLHttpRequest"); - httpost.addHeader("Cache-Control", "max-age=0"); - httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); - httpost.setEntity(new StringEntity(data, "UTF-8")); - CloseableHttpResponse response = httpClient.execute(httpost); - try { - HttpEntity entity = response.getEntity(); - String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); - EntityUtils.consume(entity); - return jsonStr; - } finally { - response.close(); - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - httpClient.close(); - } - } @Override public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { // 查询充值产品 OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); - // 查询充值子订单 + + // 查询充值子订单列表 + // 定义子订单请求map Map childOrderMap = new HashMap<>(); - // 添加查询是否存在充值中的子订单 + // 组装查询子订单数据 childOrderMap.put("parent_order_id", outRechargeOrder.getId()); - childOrderMap.put("status", 102); + // 添加查询是否存在充值中的子订单 List childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); // 定义新的子订单对象 OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - // 1:尖椒 2:龙阅 3:畅停 4.嗨购 - int type = 0; - // 定义新增子订单充值平台 - int rechargePlatformType = 0; + // 初始化充值平台 1:尖椒 2:龙阅 3:畅停 4.嗨购 + int platformType = 0; // 判断子订单是否存在充值中订单 if (childOrderList.size() > 0) { + // 修改之前的自订单充值记录 childOrder = childOrderList.get(0); + + // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法 + Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); + if (status == 0 || status == 3 || status == 99) { + return; + } else if (status == 1) { + completeOrder(outRechargeOrder , childOrder); + } + childOrder.setStatus(103); childOrder.setUpdateTime(new Date()); outRechargeChildOrderService.updateOrder(childOrder); - type = childOrder.getRechargePlatform(); - - } else { - // 查询充值状态为103充值失败的子订单 - Map childOrderMap103 = new HashMap<>(); - - childOrderMap103.put("parent_order_id", outRechargeOrder.getId()); - childOrderMap103.put("status", 103); + platformType = childOrder.getRechargePlatform(); - List childOrderList103 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap103); - if (childOrderList103.size() > 0) { - type = childOrderList103.get(0).getRechargePlatform(); - } - } - - if (type == 3) { - type = 1; - } else { - type++; } JSONObject object = new JSONObject(); - // 定义订单哈 + // 定义充值订单号 String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); // 查询平台 @@ -930,7 +659,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 判断平台只定义一个那么类型就是唯一 if (string.length() == 1) { - type = Integer.parseInt(string); + platformType = Integer.parseInt(string); + } else { + if (platformType == 0) { + platformType = Integer.parseInt(rechargePlatform[0]); + } else { + platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); + } + } // 定义查询充值产品编码 @@ -939,7 +675,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { for (String s : rechargePlatform) { // 尖椒充值 - if (s.equals("1") && type == 1) { + if (s.equals("1") && platformType == 1) { object.put("out_order_id", orderNo); object.put("amount", outRechargePrice.getRechargePrice()); object.put("mobile", outRechargeOrder.getRechargeContent()); @@ -951,14 +687,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } else { childOrder.setStatus(103); } - rechargePlatformType = 1; + childOrder.setRechargePlatform(1); break; } // 龙阅充值 - if (s.equals("2") && type == 2) { + if (s.equals("2") && platformType == 2) { map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , type); + map.put("rechargePlatform" , platformType); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); object.put("out_trade_num", orderNo); object.put("product_id", rechargeCode.getGoodsId()); @@ -971,14 +707,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } else { childOrder.setStatus(103); } - rechargePlatformType = 2; + childOrder.setRechargePlatform(2); break; } // 城宇充值 - if (s.equals("3") && type == 3) { + if (s.equals("3") && platformType == 3) { map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , type); + map.put("rechargePlatform" , platformType); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); object.put("agentOrderId", orderNo); object.put("productId", rechargeCode.getGoodsId()); @@ -990,14 +726,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } else { childOrder.setStatus(103); } - rechargePlatformType = 3; + childOrder.setRechargePlatform(3); break; } // 嗨购充值 - if (s.equals("4") && type == 4) { + if (s.equals("4") && platformType == 4) { map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , type); + map.put("rechargePlatform" , platformType); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); object.put("orderid", orderNo); object.put("product_id", rechargeCode.getGoodsId()); @@ -1010,7 +746,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } else { childOrder.setStatus(103); } - rechargePlatformType = 4; + childOrder.setRechargePlatform(4); break; } } @@ -1018,7 +754,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { childOrder.setOrderNo(orderNo); childOrder.setCreateTime(new Date()); childOrder.setParentOrderId(outRechargeOrder.getId()); - childOrder.setRechargePlatform(rechargePlatformType); childOrder.setUpdateTime(new Date()); outRechargeChildOrderService.insertOrder(childOrder); @@ -1057,20 +792,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeChildOrderService.updateOrder(childOrder); } - @Override - public Integer rechargeOrderNum(Long userId) { - OutRechargeOrderExample example = new OutRechargeOrderExample(); - OutRechargeOrderExample.Criteria criteria = example.createCriteria(); - - criteria.andUserIdEqualTo(userId); - criteria.andPayStatusEqualTo(101); - return outRechargeOrderMapper.selectByExample(example).size(); - } - - @Override - public List integralRebateRechargeOrder() { - return outRechargeOrderMapper.integralRebateRechargeOrder(); - } @Override public void editOutRechargeOrder(HighOrder orderData) { @@ -1096,4 +817,85 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.getApiRechargePhoneByList(map); } + @Override + public void rechargeOrderHandle(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { + 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()); + + refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); + } else { + // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 + Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); + if (status == 2 || status == -1) { + refundOrder(outRechargeOrder.getId() , childOrder); + } else if (status == 1) { + completeOrder(outRechargeOrder , childOrder); + } + } + + } + } + + + @Override + public Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { + JSONObject object = new JSONObject(); + // 龙阅 + if (childOrder.getRechargePlatform() == 2) { + + object.put("out_trade_nums" , childOrder.getOrderNo()); + + JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); + + JSONArray objectJSONArray = jsonObject.getJSONArray("data"); + JSONObject objectData = new JSONObject(); + for (Object objects : objectJSONArray) { + objectData = (JSONObject) objects; + } + if (objectData.size() == 0) { + return 2; + } else { + // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 + return objectData.getInteger("state"); + } + + } + // 嗨购 + if (childOrder.getRechargePlatform() == 4) { + object.put("orderid" , childOrder.getOrderNo()); + + JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); + if (jsonObject.getJSONArray("data") == null) { + return -1; + } else { + JSONArray objectJSONArray = jsonObject.getJSONArray("data"); + JSONObject objectData; + for (Object objects : objectJSONArray) { + objectData = (JSONObject) objects; + // 充值中1成功2失败3已取消4部分充值5缓存订单 + // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 + + if (objectData.getInteger("status") == 1 || objectData.getInteger("status") == 5) { + return 0; + } else if (objectData.getInteger("status") == 2) { + return 1; + } else if (objectData.getInteger("status") == 3) { + return -1; + } else if (objectData.getInteger("status") == 4) { + return 3; + } + + } + } + } + return 99; + } }