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 821ff61e..0f849a8a 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 HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighOilCardService oilCardService; @Resource private ApiProductService apiProductService; @Resource private BsRechargeCodeService rechargeCodeService; @Resource private OutRechargePriceService rechargePriceService; @Resource private CommonService commonService; @Resource private OrderService orderService; @Resource private OrderRefundService orderRefundService; @RequestMapping(value = "/kfcRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "KFC退款") public ResponseData kfcRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { OrderRefundModel orderRefundModel = null; if (StringUtils.isNotBlank(orderNo)) { // 查询订单 HighOrder order = highOrderService.getOrderByOrderNo(orderNo); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 if (order != null && order.getOrderStatus() == 2) { orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), "1609882817", order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrderStatus(4); } order.setOrderStatus(4); //order.setRefundTime(new Date()); //order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrder(order); return ResponseMsgUtil.success(orderRefundModel); } } } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/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="/consumption",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡重新发起充值") public ResponseData consumption( @RequestParam(name = "orderNo", required = false) String orderNo ) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderNo(orderNo); String goodsDesc = "重新充值"; String tranDesc = order.getRechargeContent() + "重新充值" + order.getPayRealPrice() + "元"; String instCode = "11101527"; String businessType = "hisen_consume"; String orderNoPost = "AGAIN" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(orderNoPost, order.getLaborUnionCard(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc); JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("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"); // // String s = "HFR1"; // String s1 = "AGAIN1"; // // List list = new ArrayList<>(); // // // for (Object data : array) { // JSONObject dataObject = (JSONObject) data; // if (!StringUtils.contains(dataObject.getString("orderNo"),s) && !StringUtils.contains(dataObject.getString("orderNo"),s1)) { // list.add(dataObject); // } // return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrderStatus(4); } highOrder.setOrderStatus(4); //highOrder.setRefundTime(new Date()); //highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { String remark = "订单" + highOrder.getOrderNo() + "退款积分:" + highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(); highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId() , remark); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrderStatus(4); } highOrder.setOrderStatus(4); //highOrder.setRefundTime(new Date()); //highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "更新星巴克商品") public ResponseData getStarbucksProducts(HttpServletRequest request) { try { JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(1 , 200); JSONObject object = jsonObject.getJSONObject("data"); JSONArray array = object.getJSONArray("items"); for (Object data : array) { JSONObject dataObject = (JSONObject) data; ApiStarbucksProducts starbucksProducts = apiProductService.findStarbucksProductsByGoodsId(dataObject.getLong("id")); if (dataObject.getInteger("shelfStatus") == 5) { if (starbucksProducts == null) { starbucksProducts = new ApiStarbucksProducts(); } starbucksProducts.setCategoryName(dataObject.getString("categoryName")); starbucksProducts.setCream(dataObject.getString("cream")); starbucksProducts.setCupSize(dataObject.getString("cupSize")); starbucksProducts.setDefaultImage(dataObject.getString("defaultImage")); starbucksProducts.setDes(dataObject.getString("des")); starbucksProducts.setEspresso(dataObject.getString("espresso")); starbucksProducts.setMarketGrandePrice(dataObject.getBigDecimal("marketGrandePrice")); starbucksProducts.setMarketTallPrice(dataObject.getBigDecimal("marketTallPrice")); starbucksProducts.setMarketVentiPrice(dataObject.getBigDecimal("marketVentiPrice")); starbucksProducts.setSalesGrandePrice(dataObject.getBigDecimal("salesGrandePrice")); starbucksProducts.setSalesTallPrice(dataObject.getBigDecimal("salesTallPrice")); starbucksProducts.setSalesVentiPrice(dataObject.getBigDecimal("salesVentiPrice")); starbucksProducts.setMilk(dataObject.getString("milk")); starbucksProducts.setMilkBubble(dataObject.getString("milkBubble")); starbucksProducts.setName(dataObject.getString("name")); starbucksProducts.setTemperature(dataObject.getString("temperature")); if (starbucksProducts.getId() == null) { starbucksProducts.setCreateTime(new Date()); starbucksProducts.setOperatorId(9999L); starbucksProducts.setOperatorName("系统生成"); starbucksProducts.setStatus(100); starbucksProducts.setGoodsId(dataObject.getLong("id")); apiProductService.insertStarbucksProducts(starbucksProducts); } else { starbucksProducts.setUpdateTime(new Date()); apiProductService.updateStarbucksProducts(starbucksProducts); } } } return ResponseMsgUtil.success("商品生成成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getKfcStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData getKfcStore(HttpServletRequest request) { try { JSONObject jsonObject = QianZhuConfig.getKfcStore(); JSONArray object = jsonObject.getJSONArray("data"); for (Object data : object) { JSONObject dataObject = (JSONObject) data; Map mapStore = new HashMap<>(); mapStore.put("storeCode" , dataObject.getString("storeCode")); ApiKfcStores apiKfcStores = apiProductService.findKfcStores(mapStore); if (apiKfcStores == null) { apiKfcStores = new ApiKfcStores(); } apiKfcStores.setProvinceCode(dataObject.getString("provinceCode")); apiKfcStores.setProvinceName(dataObject.getString("provinceName")); apiKfcStores.setCityCode(dataObject.getString("cityCode")); apiKfcStores.setCityName(dataObject.getString("cityName")); apiKfcStores.setCityNameFirstLetter(dataObject.getString("cityNameFirstLetter")); apiKfcStores.setKfcCityId(dataObject.getInteger("kfcCityId")); apiKfcStores.setKfcCityCode(dataObject.getString("kfcCityCode")); apiKfcStores.setStoreName(dataObject.getString("storeName")); apiKfcStores.setStoreCode(dataObject.getString("storeCode")); apiKfcStores.setLon(dataObject.getString("lon")); apiKfcStores.setLat(dataObject.getString("lat")); apiKfcStores.setAddress(dataObject.getString("address")); apiKfcStores.setStartTime(dataObject.getString("startTime")); apiKfcStores.setEndTime(dataObject.getString("endTime")); apiKfcStores.setStoreStatus(dataObject.getInteger("storeStatus")); apiKfcStores.setShelfStatus(dataObject.getInteger("shelfStatus")); if (apiKfcStores.getId() == null) { apiKfcStores.setCreateTime(new Date()); apiKfcStores.setOperatorId(9999L); apiKfcStores.setOperatorName("系统生成"); apiKfcStores.setStatus(100); apiProductService.insertKfcStore(apiKfcStores); } else { apiKfcStores.setUpdateTime(new Date()); apiProductService.updateKfcStore(apiKfcStores); } } return ResponseMsgUtil.success("生成成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/insertCity", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "插入城市") public ResponseData insertCity(HttpServletRequest request) { try { JSONObject jsonObject = QianZhuConfig.getAllCities(); JSONArray object = jsonObject.getJSONArray("data"); for (Object data : object) { JSONObject dataObject = (JSONObject) data; ApiCity apiCity = new ApiCity(); apiCity.setCityInitial(dataObject.getString("cityInitial")); apiCity.setCityCode(dataObject.getString("cityCode")); apiCity.setCityName(dataObject.getString("cityName")); apiCity.setProvinceCode(dataObject.getString("provinceCode")); apiCity.setProvinceName(dataObject.getString("provinceName")); apiCity.setCreateTime(new Date()); apiCity.setUpdateTime(new Date()); apiCity.setOperatorId(9999L); apiCity.setOperatorName("系统生成"); apiCity.setStatus(100); apiProductService.insertCity(apiCity); } return ResponseMsgUtil.success("生成成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/updatePrice", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "更新价格") public ResponseData updatePrice() { try { List list = rechargePriceService.getListRechargePrice(new HashMap<>()); for (OutRechargePrice rechargePrice : list) { BsRechargeCode rechargeCode = new BsRechargeCode(); if (rechargePrice.getGoodsId() != null) { rechargeCode.setStatus(100); rechargeCode.setUpdateTime(new Date()); rechargeCode.setCreateTime(new Date()); rechargeCode.setGoodsId(rechargePrice.getGoodsId().toString()); rechargeCode.setOperatorName("系统自动更新"); rechargeCode.setType(1); rechargeCode.setSourceId(rechargePrice.getId().toString()); rechargeCode.setRechargePlatform(2); rechargeCodeService.insertRechargeCode(rechargeCode); } } return ResponseMsgUtil.success("生成成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestBody JSONObject object) { try { return ResponseMsgUtil.success(HuiLianTongConfig.test(object)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() 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 = "/CallTestOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费测试下单") public ResponseData CallTestOrder() { try { JSONObject object = new JSONObject(); object.put("orderid", "CZ2023020910374174002"); JSONObject objectData = RechargeConfig.checkOrderByHg(object); // JSONObject returnObject = RechargeConfig.searchProduct(); return ResponseMsgUtil.success(objectData); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/CallTestOrderLy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费测试下单") public ResponseData CallTestOrderLy() { try { JSONObject object = new JSONObject(); object.put("orderid", "CZ2023020910374174002"); JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); if (jsonObject.getJSONArray("data") == null) { return ResponseMsgUtil.success("退款成功"); } else { JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (!(objectData.getInteger("status") == 1 || objectData.getInteger("status") == 0 || objectData.getInteger("status") == 4)) { return ResponseMsgUtil.success("退款成功"); } } } return ResponseMsgUtil.success("132"); } 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); map.put("status" , "2"); List list = highOrderService.getOrderList(map); for (HighOrder order : list) { if (order.getSurplusRefundIntegral() == null) { order.setSurplusRefundIntegral(order.getPayGold()); } if (order.getSurplusRefundPrice() == null) { order.setSurplusRefundPrice(order.getPayRealPrice()); } if (order.getHighChildOrderList().get(0).getSurplusRefundIntegral() == null) { order.getHighChildOrderList().get(0).setSurplusRefundIntegral(order.getPayGold()); } if (order.getHighChildOrderList().get(0).getSurplusRefundPrice() == null) { order.getHighChildOrderList().get(0).setSurplusRefundPrice(order.getPayRealPrice()); } if (order.getHighChildOrderList().get(0).getSurplusRefundNum() == null) { order.getHighChildOrderList().get(0).setSurplusRefundNum(1); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { try { List highOrders = orderService.phoneErrorOrder(); JSONObject object; for (HighOrder order: highOrders) { object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); 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部分成功 if (!(objectData.getInteger("state") == 1 || objectData.getInteger("state") == 0 || objectData.getInteger("state") == 3)) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } } } // 嗨购 if (outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform() == 4) { object.put("orderid" , outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); if (jsonObject.getJSONArray("data") == null) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } else { JSONArray objectJSONArray = jsonObject.getJSONArray("data"); JSONObject objectData; for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (!(objectData.getInteger("status") == 1 || objectData.getInteger("status") == 0 || objectData.getInteger("status") == 4)) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } } } } } } } } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } public Integer orderStatus(Integer orderStatus) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (orderStatus) { case 101: return 1; case 102: return 2; case 100: return 3; case 104: return 5; case 105: return 4; default: return null; } } public String orderTitle(OutRechargeOrder outRechargeOrder) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (outRechargeOrder.getOperatorType()) { case 1: return "电信话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 2: return "移动话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 3: return "联通话费充值" + 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.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() { try { List highOrders = orderService.phoneErrorOrder(); JSONObject object; for (HighOrder order: highOrders) { object = new JSONObject(); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); 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) { outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); } else if (objectData.getInteger("state") == 1) { outRechargeOrderService.completeOrder(outRechargeOrder , outRechargeOrder.getOutRechargeChildOrders().get(0)); } } } } } } } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/checkOrderByLy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "龙阅话费查询") public ResponseData checkOrderByLy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); object.put("out_trade_nums" , orderNo); 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) { 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 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 56fefa4b..3166711b 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 @@ -164,9 +164,10 @@ public class OrderTelChargeCallbackController { outRechargeOrderService.updateOrder(rechargeOrder); outRechargeChildOrderService.updateOrder(childOrder); orderFinish(rechargeOrder); - if (rechargeOrder.getPayType() == 6) { - apiOrderRecord(rechargeOrder); - } + // todo 代理商话费回调 +// if (rechargeOrder.getPayType() == 6) { +// apiOrderRecord(rechargeOrder); +// } } else { callbackResult(childOrder , rechargeOrder); } diff --git a/hai-schedule/src/main/java/com/hai/schedule/ApiThirdProductSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/ApiThirdProductSchedule.java index 4d3cc088..e46378a9 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/ApiThirdProductSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/ApiThirdProductSchedule.java @@ -26,7 +26,7 @@ public class ApiThirdProductSchedule { private ApiProductService apiProductService; - @Scheduled(cron="0 0/1 * * * ?") //每10分钟执行一次 + @Scheduled(cron="0 0/30 * * * ?") //每30分钟执行一次 public void getStarbucksProducts() throws Exception { JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(1 , 200); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighIntegralSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighIntegralSchedule.java index b8a6a69e..6b3d2434 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighIntegralSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighIntegralSchedule.java @@ -30,7 +30,7 @@ public class HighIntegralSchedule { @Resource private HighUserService highUserService; - @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + @Scheduled(cron="0 0/5 * * * ?") //每1分钟执行一次 public void integralRebateOrder() { List list = highGoldRecService.selectByExpiringSoonByAll(365); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 1f4b50c8..e40dc22f 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -42,209 +42,30 @@ public class HighOrderSchedule { @Resource private HighGoldRecService highGoldRecService; - @Resource - private BsIntegralRebateService bsIntegralRebateService; @Resource private BsOrderRebateService bsOrderRebateService; - /** - * @Author 胡锐 - * @Description 取消订单 15分钟 - * @Date 2021/4/4 22:45 - **/ - @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 - public void cancelOrder() { - List orderList = highOrderService.getCloseOrder(); - if (orderList != null && orderList.size() > 0) { - for (HighOrder order : orderList) { - try { - highOrderService.cancelOrder(order.getId()); - } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", e); - } - } - } - } - - - /** - * @Author 胡锐 - * @Description 处理话费充值订单 - * @Date 2021/4/4 22:45 - **/ - @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 - public void handleMobileOrder() { - List orderList = highOrderService.getAlreadyPaidMobileOrder(); - if (orderList != null && orderList.size() > 0) { - for (HighOrder order : orderList) { - try { - HighOrder highOrder = highOrderService.getOrderById(order.getId()); - if (highOrder != null) { - JSONObject mobileOrderJson = QianZhuConfig.getMobileOrderByOrderNo(highOrder.getOrderNo()); - if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) { - JSONObject data = mobileOrderJson.getJSONObject("data"); - - // 订单状态 0:待付款 5:已支付 10:充值中 15:交易成功 -5:已取消 -10:充值失败 - if (data.getInteger("status") == 15) { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(3); - } - highOrder.setOrderStatus(3); - highOrder.setFinishTime(new Date()); - highOrderService.updateOrder(highOrder); - } - if (data.getInteger("status") == -10 || data.getInteger("status") == -5) { - if (highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) { - OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); - if (orderRefundModel.getResult_code().equals("SUCCESS")) { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(4); - } - highOrder.setOrderStatus(4); - //highOrder.setRefundTime(new Date()); - //highOrder.setRefundPrice(highOrder.getPayRealPrice()); - highOrderService.updateOrder(highOrder); - } - } else { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(5); - } - highOrder.setCancelTime(new Date()); - highOrder.setOrderStatus(5); - highOrderService.updateOrder(highOrder); - } - } - } - } - } catch (Exception e) { - log.error("HighCouponSchedule --> handleMobileOrder() error!", e); - } - } - } - } - - /** - * @Author Sum1Dream - * @name handleThirdOrder.java - * @Description // 处理第三方订单 - * @Date 16:24 2022/7/8 - * @Param [] - * @return void - */ - @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 - public void handleThirdOrder() { - List orderList = highOrderService.getThirdOrder(); - // 判断是否存在订单 - if (orderList != null && orderList.size() > 0) { - for (HighOrder order : orderList) { - try { - HighOrder highOrder = highOrderService.getOrderById(order.getId()); - if (highOrder != null) { - // 肯德基订单 - if (highOrder.getHighChildOrderList().get(0).getGoodsType() == 4) { - JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(highOrder.getOrderNo()); - if (orderObject != null && orderObject.getBoolean("success")) { - JSONObject data = orderObject.getJSONObject("data"); - // 订单状态 0:待付款 5:排队中 15:TRAN_SUCCESS:交易成功 -5:已取消 - if (data.getInteger("status") == 15) { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(3); - } - - highOrder.setOrderStatus(3); - highOrder.setFinishTime(new Date()); - highOrderService.updateOrder(highOrder); - } - // 订单失败 - if (data.getInteger("status") == -5) { - if (highOrder.getOrderStatus() == 2) { - highOrderService.thirdOrderToRefund(order.getId()); - } else { - highOrderService.thirdCancelOrder(order.getId()); - } - } - } - } else if (highOrder.getHighChildOrderList().get(0).getGoodsType() == 9) { - // 星巴克订单 - // 根据订单号查询订单详情 - JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(highOrder.getOrderNo()); - if (orderObject != null && orderObject.getBoolean("success")) { - JSONObject data = orderObject.getJSONObject("data"); - // 订单状态 0:待付款 5:已支付 10:出单中 15:出单成功 20:配送中 25:配送完成 -5:已取消 -10:失败 - if (data.getInteger("status") == 15) { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(3); - } - highOrder.setOrderStatus(3); - highOrder.setFinishTime(new Date()); - highOrderService.updateOrder(highOrder); - } - // 订单失败 - if (data.getInteger("status") == -5) { - if (highOrder.getOrderStatus() == 2) { - highOrderService.thirdOrderToRefund(order.getId()); - } else { - highOrderService.thirdCancelOrder(order.getId()); - } - } - } - } else if (highOrder.getHighChildOrderList().get(0).getGoodsType() == 10) { - // 会员充值订单 - // 根据订单号查询订单详情 - JSONObject orderObject = QianZhuConfig.QueryV2(highOrder.getOrderNo()); - - if (orderObject != null && orderObject.getLong("Code") == 999) { - // 订单失败 // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 - if (orderObject.getJSONObject("Data").getInteger("OrderState") == 3) { - // 订单失败 - if (order.getOrderStatus() == 2) { - highOrderService.thirdOrderToRefund(order.getId()); - } else { - highOrderService.thirdCancelOrder(order.getId()); - } - } - // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 - if (orderObject.getJSONObject("Data").getInteger("OrderState") == 2) { - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - childOrder.setChildOrderStatus(3); - } - highOrder.setOrderStatus(3); - highOrder.setFinishTime(new Date()); - highOrderService.updateOrder(highOrder); - } - } - } - } - - - - } catch (Exception e) { - log.error("HighOrderSchedule --> handleThirdOrder() error!", e); - } - } - } - } /** * @Author 胡锐 * @Description 完成团油订单 超过支付时间24小时订单自动完成 * @Date 2021/4/4 22:45 **/ - @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 - public void finishGasOrder() { - List> mapList = highOrderService.getFinishGasOrder(); - if (mapList != null && mapList.size() > 0) { - for (Map map : mapList) { - HighOrder order = highOrderService.getOrderById(Long.parseLong(map.get("orderId").toString())); - if (order != null) { - order.setOrderStatus(3); - order.setFinishTime(new Date()); - highOrderService.updateOrderDetail(order); - } - } - } - } +// @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 +// public void finishGasOrder() { +// List> mapList = highOrderService.getFinishGasOrder(); +// if (mapList != null && mapList.size() > 0) { +// for (Map map : mapList) { +// HighOrder order = highOrderService.getOrderById(Long.parseLong(map.get("orderId").toString())); +// if (order != null) { +// order.setOrderStatus(3); +// order.setFinishTime(new Date()); +// highOrderService.updateOrderDetail(order); +// } +// } +// } +// } /** * @Author Sum1Dream * @name integralRebateOrder.java 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 3a567db6..6ff6cb5f 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java @@ -45,28 +45,6 @@ public class HighRechargeOrderSchedule { @Resource private OrderService orderService; - /** - * @return void - * @Author Sum1Dream - * @name cancelMobileOrder.java - * @Description // 取消话费订单 - * @Date 3:33 下午 2021/12/10 - * @Param [] - */ - @Scheduled(cron = "0 0/1 * * * ?") //每15分钟执行一次 - public void cancelMobileOrder() { - List orderList = outRechargeOrderService.getOutRechargeOrderList(); - if (orderList != null && orderList.size() > 0) { - for (OutRechargeOrder order : orderList) { - try { - outRechargeOrderService.cancelOrder(order.getId()); - } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", e); - } - } - } - } - /** * @return void * @Author Sum1Dream @@ -75,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)); @@ -104,7 +82,7 @@ public class HighRechargeOrderSchedule { continue; } System.out.println("话费定时任务 -> 退款任务" + order.getId()); - outRechargeOrderService.rechargeOrderToRefund(order.getId()); + outRechargeOrderService.refundOrder(order.getId() , childOrderList.get(0)); } } catch (Exception e) { @@ -115,78 +93,90 @@ public class HighRechargeOrderSchedule { System.out.println("话费定时任务 -> 结束任务"); } - @Scheduled(cron = "0 0/10 * * * ?") //每10分钟执行一次 - public void failRechargeOrder() throws Exception { + @Scheduled(cron = "0 0/30 * * * ?") //每30分钟执行一次 + public void failRechargeOrder() { List highOrders = orderService.phoneErrorOrder(); JSONObject object; for (HighOrder order: highOrders) { - object = new JSONObject(); + try { - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); + object = new JSONObject(); - if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); - if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { + OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); - OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); + if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { - outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); - outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); - outRechargeChildOrder.setUpdateTime(new Date()); - outRechargeChildOrder.setCreateTime(new Date()); + if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); - } else { - if (outRechargeOrder.getOutRechargeChildOrders().get(0).getStatus() != 101) { - // 龙阅 - if (outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform() == 2) { + OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); - object.put("out_trade_nums" , outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); + outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); + outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); + outRechargeChildOrder.setUpdateTime(new Date()); + outRechargeChildOrder.setCreateTime(new Date()); - JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); + outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); + } else { + if (childOrder.getStatus() != 101) { + // 龙阅 + if (childOrder.getRechargePlatform() == 2) { - 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部分成功 - if (!(objectData.getInteger("state") == 1 || objectData.getInteger("state") == 0 || objectData.getInteger("state") == 3)) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); - } - } + object.put("out_trade_nums" , childOrder.getOrderNo()); + + JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); - } - // 嗨购 - if (outRechargeOrder.getOutRechargeChildOrders().get(0).getRechargePlatform() == 4) { - object.put("orderid" , outRechargeOrder.getOutRechargeChildOrders().get(0).getOrderNo()); - - JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); - if (jsonObject.getJSONArray("data") == null) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); - } else { JSONArray objectJSONArray = jsonObject.getJSONArray("data"); - JSONObject objectData; + 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("status") == 1 || objectData.getInteger("status") == 0 || objectData.getInteger("status") == 4)) { - outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); + if (objectData.getInteger("state") == 2) { + 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取消,0充值中 ,1充值成功,2充值失败,3部分成功 + if (objectData.getInteger("status") == 2) { + outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder); + } else if (objectData.getInteger("status") == 1) { + outRechargeOrderService.completeOrder(outRechargeOrder , childOrder); + } } } } } } - } + } + } catch (Exception e) { + log.error("HighCouponSchedule --> expiredCoupon() error!", e); } + } } 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 423955e5..0eac3919 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -175,6 +175,16 @@ public interface OutRechargeOrderService { */ void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception; + /** + * @Author Sum1Dream + * @Name completeOrder + * @Description // 完成话费订单 + * @Date 14:58 2023/2/13 + * @Param [order, childOrder] + * @Return void + */ + void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder); + /** * @Author Sum1Dream * @name rechargeOrderNum.java 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 ab7496a7..040a9c39 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 @@ -814,7 +814,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Transactional( propagation= Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, - timeout = 10, + timeout = 25, rollbackFor = Exception.class) public void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); @@ -1037,6 +1037,17 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeOrderService.updateOrder(outRechargeOrder); } + @Override + public void completeOrder(OutRechargeOrder order, OutRechargeChildOrder childOrder) { + childOrder.setStatus(101); + order.setRechargeStatus(202); + order.setPayStatus(100); + order.setFinishTime(new Date()); + + outRechargeOrderService.updateOrder(order); + outRechargeChildOrderService.updateOrder(childOrder); + } + @Override public Integer rechargeOrderNum(Long userId) { OutRechargeOrderExample example = new OutRechargeOrderExample();