From a0f80085171523797f0a29c9b555aca3fccd6426 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Fri, 10 Feb 2023 17:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A42=E3=80=820=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/HighTestController.java | 2 +- .../OutRechargePriceController.java | 10 +- .../OrderMobileRechargeController.java | 8 +- .../MobileRechargeNotifyController.java | 333 ++++++++++++++++++ .../consumer/OrderRefundSuccessConsumer.java | 10 +- .../schedule/HighRechargeOrderSchedule.java | 81 ++++- .../java/com/hai/common/utils/HttpsUtils.java | 3 +- .../java/com/hai/common/utils/WxUtils.java | 35 ++ .../java/com/hai/config/CommonSysConfig.java | 5 + .../config/HuiLianTongUnionCardConfig.java | 11 +- .../java/com/hai/config/RechargeConfig.java | 99 +++++- .../com/hai/config/ThirdProductConfig.java | 27 +- .../java/com/hai/config/UnionPayConfig.java | 2 +- .../java/com/hai/dao/HighOrderMapperExt.java | 56 ++- .../java/com/hai/entity/BsRechargeCode.java | 4 +- .../hai/order/model/OrderThirdPartyModel.java | 8 + .../hai/order/service/OrderRefundService.java | 1 + .../com/hai/order/service/OrderService.java | 10 + .../service/impl/OrderRefundServiceImpl.java | 7 +- .../order/service/impl/OrderServiceImpl.java | 8 +- .../service/impl/HighOrderServiceImpl.java | 7 +- .../OutRechargeChildOrderServiceImpl.java | 2 + .../impl/OutRechargeOrderServiceImpl.java | 26 +- .../resources/dev/commonConfig.properties | 12 +- .../resources/prod/commonConfig.properties | 10 +- 25 files changed, 706 insertions(+), 71 deletions(-) create mode 100644 hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index f2f74497..ab47f1c7 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.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.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.QianZhuConfig; import com.hai.config.WxOrderConfig; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; 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; @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 = "/下单", 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 = "/phoneBillOrderMigration", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单迁移") public ResponseData phoneBillOrderMigration() { try { List list = outRechargeOrderService.getListRechargeOrder(new HashMap<>()); for (OutRechargeOrder outRechargeOrder : list) { HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); if (highOrder == null) { HighOrder order = new HighOrder(); // 拼接订单 order.setOrderStatus(orderStatus(outRechargeOrder.getPayStatus())); order.setOrderNo(outRechargeOrder.getOrderNo()); order.setTitle(orderTitle(outRechargeOrder)); order.setSearchTitle(outRechargeOrder.getOrderNo() + orderTitle(outRechargeOrder)); order.setPayType(outRechargeOrder.getPayType()); order.setProductType(9); if (outRechargeOrder.getLaborUnionCard() != null) { order.setMemCardType(1); } order.setPayTime(outRechargeOrder.getPayTime()); order.setFinishTime(outRechargeOrder.getFinishTime()); order.setCreateTime(outRechargeOrder.getCreateTimed()); order.setCancelTime(outRechargeOrder.getCancelTime()); order.setRefundTime(outRechargeOrder.getRefundTime()); order.setPayRealPrice(outRechargeOrder.getPayRealPrice()); order.setPayablePrice(outRechargeOrder.getPayRealPrice()); order.setPayPrice(outRechargeOrder.getPayPrice()); order.setTotalPrice(outRechargeOrder.getOrderPrice()); outRechargeOrder.setDiscountDeductionPrice(outRechargeOrder.getDiscountDeductionPrice()==null?new BigDecimal("0"):outRechargeOrder.getDiscountDeductionPrice()); if (outRechargeOrder.getPayStatus() == 102 || outRechargeOrder.getPayStatus() == 100) { if (outRechargeOrder.getMemDiscountId() != null) { order.setTotalDeductionPrice(order.getDeductionCouponPrice()); } else { order.setTotalDeductionPrice(outRechargeOrder.getOrderPrice().subtract(outRechargeOrder.getPayRealPrice())); order.setDeductionProductPrice(outRechargeOrder.getOrderPrice().subtract(outRechargeOrder.getPayRealPrice())); } } else { order.setTotalDeductionPrice(new BigDecimal(0)); order.setDeductionProductPrice(new BigDecimal(0)); } order.setDeductionCouponPrice(outRechargeOrder.getDiscountDeductionPrice()); order.setPaySerialNo(outRechargeOrder.getPaySerialNo()); order.setMemId(outRechargeOrder.getUserId()); order.setMemName(outRechargeOrder.getUserName()); order.setMemPhone(outRechargeOrder.getUserPhone()); order.setMemCardNo(outRechargeOrder.getLaborUnionCard()); order.setCompanyId(outRechargeOrder.getCompanyId()); order.setPayGold(outRechargeOrder.getIntegralNum().intValue()); order.setMemDiscountId(outRechargeOrder.getMemDiscountId()); order.setMemDiscountName(outRechargeOrder.getMemDiscountName()); highOrderService.phoneBillOrderMigration(order); } } return ResponseMsgUtil.success("迁移完成"); } 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 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("out_trade_nums", "CZ2023020912403791506"); 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 { // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 if (!(objectData.getInteger("state") == 1 || objectData.getInteger("state") == 0 || objectData.getInteger("state") == 3)) { return ResponseMsgUtil.success("退款成功"); } } return ResponseMsgUtil.success(objectData); } 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 objectData = RechargeConfig.checkOrderByHg(object); //(0充值中1成功2失败3已取消4部分充值5缓存订单) 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 diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java index 99aee160..6f31f835 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java @@ -260,21 +260,21 @@ public class OutRechargePriceController { map.put("sourceId" , outRechargePrice.getId()); List rechargeCodes = bsRechargeCodeService.getListRechargeCode(map); - if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") ) && rechargeCodes.size() == 0) { + if ((outRechargePrice.getRechargePlatform().contains("-2-") || outRechargePrice.getRechargePlatform().contains("-3-") || outRechargePrice.getRechargePlatform().contains("-4-") ) && rechargeCodes.size() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); } for (BsRechargeCode rechargeCode : rechargeCodes) { - if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3) ){ + if ((rechargeCode.getRechargePlatform() == 2 || rechargeCode.getRechargePlatform() == 3 || rechargeCode.getRechargePlatform() == 4) ){ if (rechargeCode.getGoodsId() == null) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); } if (rechargeCode.getGoodsId().length() == 0) { log.error("OutRechargePriceController -> editPriceStatus() error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇平台需要输入商品编码!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,嗨购平台需要输入商品编码!"); } } diff --git a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java index 5a2f6222..f58f4f1b 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 @@ -148,7 +148,7 @@ public class OrderMobileRechargeController { map.put("orderNo", orderNo); map.put("memPhone", memPhone); map.put("memCardNo", memCardNo); - map.put("productType", productType); + map.put("productType", 9); map.put("status", status); map.put("payType", payType); @@ -168,10 +168,14 @@ public class OrderMobileRechargeController { model.setDeductionProductPrice(thirdPartyModel.getDeductionProductPrice()); model.setPayablePrice(thirdPartyModel.getPayablePrice()); model.setPayPrice(thirdPartyModel.getPayPrice()); - model.setPayType(OrderPayType.getDataByType(thirdPartyModel.getPayType()).getName()); + if (thirdPartyModel.getPayType() != null) { + model.setPayType(OrderPayType.getDataByType(thirdPartyModel.getPayType()).getName()); + } model.setOrderStatus(OrderStatusEnum.getNameByType(thirdPartyModel.getOrderStatus())); model.setCreateTime(thirdPartyModel.getCreateTime()); model.setPayTime(thirdPartyModel.getPayTime()); + model.setRefundTime(thirdPartyModel.getRefundTime()); + model.setMemCardNo(thirdPartyModel.getMemCardNo()); dataList.add(model); } diff --git a/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java b/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java new file mode 100644 index 00000000..f328ce78 --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java @@ -0,0 +1,333 @@ +package com.web.controller.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hai.config.WxMsgConfig; +import com.hai.entity.*; +import com.hai.enum_type.OrderStatusEnum; +import com.hai.enum_type.RechargePayType; +import com.hai.order.service.OrderService; +import com.hai.order.type.OrderChildStatus; +import com.hai.service.*; +import com.hai.service.impl.OutRechargeOrderServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +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 javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Controller +@RequestMapping(value = "/mobileRechargeNotify") +@Api(value = "通知") +public class MobileRechargeNotifyController { + + private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); + + @Resource + private OutRechargeOrderService outRechargeOrderService; + + @Resource + private OutRechargeChildOrderService outRechargeChildOrderService; + + @Resource + private HighUserService highUserService; + + @Resource + private ApiOrderRecordService apiOrderRecordService; + + @Resource + private HighOrderService highOrderService; + + @Resource + private OrderService orderService; + + @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) + @ApiOperation(value = "尖椒充值回调") + @ResponseBody + public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { + try { + + JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); + + log.info("============回调任务Start============="); + log.info("尖椒订单充值-回调参数: " + dataObject); + log.info("============回调任务End============="); + + // 1 尖椒 2 龙阅 + dataObject.put("orderNo" , dataObject.getString("out_order_id")); + + // 查询充值记录订单 + OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id")); + + // 查询充值订单 + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); + + // 判断是否充值成功 并发送微信小程序服务通知 + if (dataObject.getInteger("status") == 3) { + if (rechargeOrder.getRechargeStatus() ==201) { + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedSuccess( + rechargeOrder.getRechargeContent() + "充值成功", + String.valueOf(rechargeOrder.getPayRealPrice()), + rechargeOrder.getOrderNo(), + rechargeOrder.getFinishTime(), + RechargePayType.getNameByType(rechargeOrder.getPayType()), + highUser.getOpenId()); + }).start(); + } + + childOrder.setStatus(101); + rechargeOrder.setRechargeStatus(202); + rechargeOrder.setPayStatus(100); + + outRechargeOrderService.updateOrder(rechargeOrder); + outRechargeChildOrderService.updateOrder(childOrder); + orderFinish(rechargeOrder); + + // api商户订单 + if (rechargeOrder.getPayType() == 6) { + apiOrderRecord(rechargeOrder); + } + + } else { + // 充值失败操作 + callbackResult(childOrder , rechargeOrder); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + + @RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST) + @ApiOperation(value = "龙阅充值回调") + @ResponseBody + public void rechargeCallbackByLy( + @RequestParam(name = "out_trade_num", required = true) String out_trade_num, + @RequestParam(name = "userid", required = true) Long userid, + @RequestParam(name = "state", required = true) Long state, + @RequestBody String reqBodyStr , + HttpServletRequest request, HttpServletResponse response) { + try { + + log.info("============回调任务Start============="); + log.info("龙阅订单充值-回调参数: " + reqBodyStr); + log.info("============回调任务End============="); + + OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); + + // 判断是否充值成功 并发送微信小程序服务通知 + if (state == 1) { + if (rechargeOrder.getRechargeStatus() ==201) { + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedSuccess( + rechargeOrder.getRechargeContent() + "充值成功", + String.valueOf(rechargeOrder.getPayRealPrice()), + rechargeOrder.getOrderNo(), + rechargeOrder.getFinishTime(), + RechargePayType.getNameByType(rechargeOrder.getPayType()), + highUser.getOpenId()); + }).start(); + } + childOrder.setStatus(101); + rechargeOrder.setRechargeStatus(202); + rechargeOrder.setPayStatus(100); + rechargeOrder.setFinishTime(new Date()); + + outRechargeOrderService.updateOrder(rechargeOrder); + outRechargeChildOrderService.updateOrder(childOrder); + orderFinish(rechargeOrder); + if (rechargeOrder.getPayType() == 6) { + apiOrderRecord(rechargeOrder); + } + } else { + callbackResult(childOrder , rechargeOrder); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + @RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST) + @ApiOperation(value = "嗨购充值回调") + @ResponseBody + public void rechargeCallbackByHg( + @RequestParam(name = "mchid", required = false) String mchid, + @RequestParam(name = "out_order_id", required = false) String out_order_id, + @RequestParam(name = "orderid", required = true) String orderid, + @RequestParam(name = "return_time", required = false) String return_time, + @RequestParam(name = "return_price", required = false) String return_price, + @RequestParam(name = "recharge_price", required = false) String recharge_price, + @RequestParam(name = "price", required = false) String price, + @RequestParam(name = "status", required = true) String status, + @RequestParam(name = "phone", required = false) String phone, + @RequestParam(name = "secret_key", required = false) String secret_key, + HttpServletResponse response) { + try { + + + + JSONObject dataObject = new JSONObject(); + + dataObject.put("mchid" , mchid); + dataObject.put("out_order_id" , out_order_id); + dataObject.put("orderid" , orderid); + dataObject.put("return_time" , return_time); + dataObject.put("return_price" , mchid); + dataObject.put("recharge_price" , recharge_price); + dataObject.put("price" , price); + dataObject.put("status" , status); + dataObject.put("phone" , phone); + dataObject.put("secret_key" , secret_key); + + log.info("============回调任务Start============="); + log.info("嗨购订单充值-回调参数: " + dataObject); + log.info("============回调任务End============="); + + // 1 尖椒 2 龙阅 + + // 查询充值记录订单 + OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(orderid); + + // 查询充值订单 + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); + + // 判断是否充值成功 并发送微信小程序服务通知 + if (Objects.equals(status, "1")) { + if (rechargeOrder.getRechargeStatus() ==201) { + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedSuccess( + rechargeOrder.getRechargeContent() + "充值成功", + String.valueOf(rechargeOrder.getPayRealPrice()), + rechargeOrder.getOrderNo(), + rechargeOrder.getFinishTime(), + RechargePayType.getNameByType(rechargeOrder.getPayType()), + highUser.getOpenId()); + }).start(); + } + + childOrder.setStatus(101); + rechargeOrder.setRechargeStatus(202); + rechargeOrder.setPayStatus(100); + + outRechargeOrderService.updateOrder(rechargeOrder); + outRechargeChildOrderService.updateOrder(childOrder); + orderFinish(rechargeOrder); + + // api商户订单 + if (rechargeOrder.getPayType() == 6) { + apiOrderRecord(rechargeOrder); + } + + } else { + // 充值失败操作 + callbackResult(childOrder , rechargeOrder); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("SUCCESS"); + + + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + + // 充值回调结果处理 + private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception { + + // 101:充值成功 102: 充值中 103:充值失败 104 未充值 + // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { + + Date rechargeTime = rechargeOrder.getCreateTimed(); + Date currentTime = new Date(); +// 当前时间减去充值时间 + int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); + +// // 判断快充 并且 充值时间小于6 +// if (rechargeOrder.getRechargeType() == 1 && hours < 6) { +// outRechargeOrderService.pollRequest(rechargeOrder); +// return; +// } + // 判断慢充 并且 充值时间小于72 + if (hours < 72) { + outRechargeOrderService.pollRequest(rechargeOrder); + return; + } + + outRechargeOrderService.refundOrder(rechargeOrder.getId() , childOrder); + + // 发送充值失败 微信小程序服务通知 + new Thread(() -> { + HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); + WxMsgConfig.rechargedFail( + rechargeOrder.getRechargeContent() + "充值失败", + String.valueOf(rechargeOrder.getPayRealPrice()), + highUser.getOpenId()); + }).start(); + + } + + } + + // 订单完成操作 + private void orderFinish(OutRechargeOrder rechargeOrder) { + HighOrder highOrder = highOrderService.getOrderByOrderNo(rechargeOrder.getOrderNo()); + if (highOrder != null) { + highOrder.setOrderStatus(OrderStatusEnum.type3.getType()); + highOrder.setFinishTime(new Date()); + for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { + highChildOrder.setChildOrderStatus(OrderChildStatus.STATUS3.getNumber()); + highChildOrder.setFinishTime(new Date()); + } + orderService.updateOrderData(highOrder); + } + + } + + private void apiOrderRecord(OutRechargeOrder rechargeOrder) { + Map orderMap = new HashMap<>(); + orderMap.put("orderId" , rechargeOrder.getId()); + + // 查询是否用重复订单 + ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); + + apiOrderRecord.setStatus(100); + apiOrderRecord.setRequestTime(new Date()); + apiOrderRecordService.updateOrderRecord(apiOrderRecord); + + } + +} diff --git a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java b/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java index ac8d6eeb..148825c0 100644 --- a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java +++ b/hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java @@ -6,7 +6,9 @@ import com.hai.order.service.OrderRefundHandleService; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildGoodsType; +import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderStatus; +import com.hai.service.BsMsgService; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.core.RocketMQListener; @@ -28,8 +30,12 @@ public class OrderRefundSuccessConsumer implements RocketMQListener 结束任务"); } - @Scheduled(cron = "0 0/1 * * * ?") //每分钟执行一次 - public void failRechargeOrder() { + @Scheduled(cron = "0 0/10 * * * ?") //每10分钟执行一次 + public void failRechargeOrder() throws Exception { + List highOrders = orderService.phoneErrorOrder(); - Map map = new HashMap<>(); + JSONObject object; - map.put("payStatus" , 102); - map.put("rechargeStatus" , 203); + for (HighOrder order: highOrders) { - List orderList = outRechargeOrderService.getListRechargeOrder(map); - if (orderList != null && orderList.size() > 0) { - for (OutRechargeOrder order : orderList) { - try { + object = new JSONObject(); - OutRechargeChildOrder childOrder = rechargeChildOrderService.findByOrderId(order.getId()); + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); - outRechargeOrderService.refundOrder(order.getId() , childOrder); + if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { - outRechargeOrderService.rechargeOrderToRefund(order.getId()); - } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", e); + 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 objectData = RechargeConfig.checkOrderByHg(object); + + //(0充值中1成功2失败3已取消4部分充值5缓存订单) + if (!(objectData.getInteger("status") == 1 || objectData.getInteger("status") == 0 || objectData.getInteger("status") == 4)) { + outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeOrder.getOutRechargeChildOrders().get(0)); + } + } + } } + + } + } } diff --git a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java index f781d35e..8d2d9708 100644 --- a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java @@ -51,7 +51,7 @@ public class HttpsUtils { private static PoolingHttpClientConnectionManager connMgr; private static RequestConfig requestConfig; - private static final int MAX_TIMEOUT = 10000; + private static final int MAX_TIMEOUT = 20000; static { // 设置连接池 @@ -543,6 +543,7 @@ public class HttpsUtils { return null; } + public static JSONObject doPostForm(String apiUrl, String body, Map header) { CloseableHttpClient httpClient = null; if (apiUrl.startsWith("https")) { diff --git a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java index 95a02611..52be2091 100644 --- a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java @@ -10,6 +10,7 @@ import com.thoughtworks.xstream.io.xml.XppDriver; import net.sf.cglib.beans.BeanMap; import org.apache.commons.lang3.StringUtils; +import org.springframework.util.DigestUtils; import javax.crypto.Mac; @@ -466,6 +467,40 @@ public class WxUtils { } } + /** + * 生成嗨购签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 + * + * @param data 待签名数据 + * @param key API密钥 + * @param signType 签名方式 + * @return 签名 + */ + public static String generateSignatureHg(final Map data, String key, WXPayConstants.SignType signType) throws Exception { + + + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); +// Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN)) { + continue; + } + if (data.get(k) != null) // 参数值为空,则不参与签名 + sb.append(k).append(data.get(k)); + } + sb.append("secretKey").append(key); + if (WXPayConstants.SignType.MD5.equals(signType)) { + return MD5(sb.toString() , false); + } + else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) { + return HMACSHA256(sb.toString(), key); + } + else { + throw new Exception(String.format("Invalid sign_type: %s", signType)); + } + } + /** * 生成签名. * diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index f6923650..d772ca1f 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -103,6 +103,11 @@ public class CommonSysConfig { private String JjUrl; private String JjAppSecret; + private String HgApiKey; + private String HgNotifyUrl; + private String HgMemberId; + private String HgPostUrl; + private String CyApiKey; private String CyAppSecret; private String CyPostUrl; diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index 3e62ec28..63e535b8 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -214,7 +214,16 @@ public class HuiLianTongUnionCardConfig { dataMap.put("orderNo", refundOrderNo); dataMap.put("origOrderNo", origOrderNo); dataMap.put("checkPassword", "N"); - return request("qtk/refund", dataMap); + + + log.info("============请求任务Start============="); + log.info("汇联通充值-请求参数: " + JSON.toJSONString(dataMap)); + + JSONObject returnObject = request("qtk/refund", dataMap); + + log.info("汇联通充值-响应参数: " + returnObject.toJSONString()); + log.info("============请求任务End=============="); + return returnObject; } 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 e1f0602e..34be3a2f 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -7,13 +7,12 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.WxUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * @ClassName TelConfig @@ -90,7 +89,16 @@ public class RechargeConfig { paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); paramMap.put("out_trade_nums" , object.getString("out_trade_nums")); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); - return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); + + log.info("============请求任务Start============="); + log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap)); + + JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); + + log.info("龙阅订单查询-响应参数: " + jsonObject.toJSONString()); + log.info("============请求任务End=============="); + + return jsonObject; } /** @@ -205,30 +213,89 @@ public class RechargeConfig { /** * @Author Sum1Dream - * @Name searchProductByHg - * @Description // 嗨购话费产品查询 + * @Name checkOrderByHg + * @Description // 查询嗨购订单下单 + * @Date 14:50 2023/2/8 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + public static JSONObject rechargeOrderByHg(JSONObject object) throws Exception { + Map paramMap = new HashMap<>(); + + 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("product_id" , object.getString("product_id")); + paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl()); + paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); + + log.info("============请求任务Start============="); + log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + + System.out.println("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>()); + + log.info("嗨购话费查询订单-响应参数: " + repsObject.toJSONString()); + log.info("============请求任务End=============="); + return repsObject; + } + + /** + * @Author Sum1Dream + * @Name searchOrder + * @Description // 嗨购话费查询订单详情 * @Date 11:39 2023/2/7 * @Param [object] * @Return com.alibaba.fastjson.JSONObject */ - public static JSONObject searchProductByHg(JSONObject object) throws Exception { + public static JSONObject checkOrderByHg(JSONObject object) throws Exception { Map paramMap = new HashMap<>(); - paramMap.put("agentOrderId" , object.getString("agentOrderId")); - paramMap.put("productId" , object.getInteger("productId")); - paramMap.put("mobile" , object.getString("mobile")); - paramMap.put("timestamp" , DateUtil.date2String(new Date() , DateUtil.Y_M_D_HMS)); - paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey()); - paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5)); + paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId()); + paramMap.put("orderid" , object.getString("orderid")); + paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); log.info("============请求任务Start============="); - log.info("城宇话费下单-请求参数: " + JSON.toJSONString(paramMap)); + log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); - JSONObject jsonObject = HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap); + JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>()); - log.info("城宇话费下单-响应参数: " + jsonObject.toJSONString()); + log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); + log.info("============请求任务End=============="); + return jsonObject; + } + + public static JSONObject searchProduct() throws Exception { + Map paramMap = new HashMap<>(); + + paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId()); + paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); + + log.info("============请求任务Start============="); + log.info("嗨购话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); + + JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "/external/api/searchProduct", paramSort(paramMap) , new HashMap<>()); + + log.info("嗨购话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("============请求任务End=============="); return jsonObject; } + + private static String paramSort(final Map param) { + Set keySet = param.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(param.get(k)); + } else { + sb.append("&").append(k).append("=").append(param.get(k)); + } + } + return sb.toString(); + } + + } diff --git a/hai-service/src/main/java/com/hai/config/ThirdProductConfig.java b/hai-service/src/main/java/com/hai/config/ThirdProductConfig.java index 9b288e2d..f7267a09 100644 --- a/hai-service/src/main/java/com/hai/config/ThirdProductConfig.java +++ b/hai-service/src/main/java/com/hai/config/ThirdProductConfig.java @@ -4,13 +4,11 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.entity.BsProductConfig; -import com.hai.entity.BsProductDiscount; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighOrder; +import com.hai.entity.*; import com.hai.order.model.CreateOrderChildModel; import com.hai.service.ApiProductService; import com.hai.service.BsConfigService; +import com.hai.service.HighCouponService; import com.hai.service.HighOrderService; import org.springframework.stereotype.Component; @@ -37,6 +35,9 @@ public class ThirdProductConfig { @Resource private HighOrderService highOrderService; + @Resource + private HighCouponService highCouponService; + // 产品折扣比例 public BigDecimal getProductConfigNum(Integer productType , Long companyId) { @@ -58,6 +59,7 @@ public class ThirdProductConfig { Map listMap = new HashMap<>(); listMap.put("productType", productType); listMap.put("companyId", companyId); + listMap.put("productId", productId); List productConfigs = apiProductService.getProductConfig(listMap); @@ -85,7 +87,22 @@ public class ThirdProductConfig { listMap.put("sourceId", highOrder.getHighChildOrderList().get(0).getGoodsId()); } - } else { + } else if (productType == 5) { + if (orderNo != null) { + HighOrder highOrder = highOrderService.getOrderByOrderNo(orderNo); + + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + if (!childOrder.getGiveawayType()) { + HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); + BsProductConfig productConfigCoupon = getProductConfig(productType, companyId , Long.valueOf(coupon.getCouponSource())); + listMap.put("sourceId", productConfigCoupon.getId()); + } + } + + } else { + listMap.put("sourceId", productConfig.getId()); + } + }else { listMap.put("sourceId", productConfig.getId()); } diff --git a/hai-service/src/main/java/com/hai/config/UnionPayConfig.java b/hai-service/src/main/java/com/hai/config/UnionPayConfig.java index 3d91ea0e..18230299 100644 --- a/hai-service/src/main/java/com/hai/config/UnionPayConfig.java +++ b/hai-service/src/main/java/com/hai/config/UnionPayConfig.java @@ -158,7 +158,7 @@ public class UnionPayConfig { * @param param * @return */ - private static String paramSort(final Map param) { + public static String paramSort(final Map param) { Set keySet = param.keySet(); String[] keyArray = keySet.toArray(new String[keySet.size()]); Arrays.sort(keyArray); 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 e9791bc3..b5e31f1c 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1140,7 +1140,6 @@ public interface HighOrderMapperExt { }) List getSelfOilStationOrderList(@Param("goodsId") String goodsId); - // todo 根据上线时间 选择时间 @Select("select ho.* from high_order ho left join bs_order_rebate bor on ho.id = bor.order_id where bor.id is null and order_status = 3 and pay_type != 3 and pay_real_price > 0 and whether_rebate = false and ho.create_time > '2023-02-01 00:00:00' group by create_time desc;") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @@ -1223,4 +1222,59 @@ 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;") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), + @Result(column="search_title", property="searchTitle", jdbcType=JdbcType.VARCHAR), + @Result(column="product_type", property="productType", jdbcType=JdbcType.INTEGER), + @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), + @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR), + @Result(column="promote_code", property="promoteCode", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_discount_id", property="memDiscountId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_discount_name", property="memDiscountName", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR), + @Result(column="mem_phone", property="memPhone", jdbcType=JdbcType.VARCHAR), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), + @Result(column="mem_card_id", property="memCardId", jdbcType=JdbcType.BIGINT), + @Result(column="mem_card_type", property="memCardType", jdbcType=JdbcType.INTEGER), + @Result(column="mem_card_no", property="memCardNo", jdbcType=JdbcType.VARCHAR), + @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), + @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER), + @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="surplus_refund_integral", property="surplusRefundIntegral", jdbcType=JdbcType.INTEGER), + @Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="cancel_remarks", property="cancelRemarks", jdbcType=JdbcType.VARCHAR), + @Result(column="refund_time", property="refundTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="account_merchant_num", property="accountMerchantNum", jdbcType=JdbcType.VARCHAR), + @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), + @Result(column="profit_sharing_record_id", property="profitSharingRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="whether_check", property="whetherCheck", jdbcType=JdbcType.BIT), + @Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT), + @Result(column="exception_status", property="exceptionStatus", jdbcType=JdbcType.BIT), + @Result(column="exception_content", property="exceptionContent", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_4", property="ext4", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_5", property="ext5", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_6", property="ext6", jdbcType=JdbcType.VARCHAR) + }) + List phoneErrorOrder(); } diff --git a/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java b/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java index c9ed5049..de18ee76 100644 --- a/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java +++ b/hai-service/src/main/java/com/hai/entity/BsRechargeCode.java @@ -29,7 +29,7 @@ public class BsRechargeCode implements Serializable { private String sourceId; /** - * 充值平台:充值平台 1:尖椒 2:龙阅 3:城宇 + * 充值平台:充值平台 1:尖椒 2:龙阅 3:城宇 4.嗨购 */ private Integer rechargePlatform; @@ -254,4 +254,4 @@ public class BsRechargeCode implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java index 05561532..ccc00961 100644 --- a/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java +++ b/hai-service/src/main/java/com/hai/order/model/OrderThirdPartyModel.java @@ -56,6 +56,10 @@ public class OrderThirdPartyModel { @ExcelProperty(value = "支付方式") private String payType; + @ColumnWidth(22) + @ExcelProperty(value = "卡号") + private String memCardNo; + @ColumnWidth(13) @ExcelProperty(value = "订单状态") private String orderStatus; @@ -68,4 +72,8 @@ public class OrderThirdPartyModel { @ExcelProperty(value = "支付时间") private Date payTime; + @ColumnWidth(20) + @ExcelProperty(value = "退款时间") + private Date refundTime; + } diff --git a/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java b/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java index f92c389e..277c8305 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java @@ -1,5 +1,6 @@ package com.hai.order.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.entity.HighOrderRefund; diff --git a/hai-service/src/main/java/com/hai/order/service/OrderService.java b/hai-service/src/main/java/com/hai/order/service/OrderService.java index 439d9e7b..ed9ef88d 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderService.java @@ -93,4 +93,14 @@ public interface OrderService { */ void orderCheck(String orderNo); + /** + * @Author Sum1Dream + * @Name phoneErrorOrder + * @Description // 查询话费错误订单 + * @Date 10:13 2023/2/10 + * @Param [] + * @Return java.util.List + */ + List phoneErrorOrder(); + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java index 8b40310b..eb341817 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java @@ -28,10 +28,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @className: OrderRefundServiceImpl @@ -176,7 +173,7 @@ public class OrderRefundServiceImpl implements OrderRefundService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR,refund.getString("respMessage")); } JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(refund.getString("data")); - if (consumptionResult.getBoolean("success") != true) { + if (!(consumptionResult.getBoolean("success") || Objects.equals(consumptionResult.getString("message"), "原交易已撤销,不可再次操作"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败!"+consumptionResult.getString("message")); } refundPriceModel.setRefundSuccess(true); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 3c495939..97a54902 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -524,7 +524,7 @@ public class OrderServiceImpl implements OrderService { @Transactional( propagation= Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, - timeout = 10, + timeout = 25, rollbackFor = Exception.class) @CacheUpdate(name = "order:", key = "#order.orderNo", value = "#order") public HighOrder refundOrder(HighOrder order, String remarks, OrderRefundOpUserType opUserType, Long opUserId, String opUserName) throws Exception { @@ -580,6 +580,8 @@ public class OrderServiceImpl implements OrderService { rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_REFUND_SUCCESS.getTopic(), orderRefund); } + + return updateOrderData(order); } @@ -759,4 +761,8 @@ public class OrderServiceImpl implements OrderService { } } + @Override + public List phoneErrorOrder() { + return orderMapper.phoneErrorOrder(); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index e2d71550..99e80c5c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -807,12 +807,9 @@ public class HighOrderServiceImpl implements HighOrderService { if (MapUtils.getString(map, "phone") != null) { criteria.andMemPhoneEqualTo(MapUtils.getString(map, "phone")); } - if (MapUtils.getString(map, "merchId") != null) { - // criteria.andMerchIdEqualTo(MapUtils.getString(map, "merchId")); - } - if (MapUtils.getLong(map, "identificationCode") != null) { - // criteria.andIdentificationCodeEqualTo(MapUtils.getLong(map, "identificationCode")); + if (MapUtils.getInteger(map, "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map, "productType")); } if (StringUtils.isNotBlank(MapUtils.getString(map, "createTimeS")) && StringUtils.isNotBlank(MapUtils.getString(map, "createTimeE"))) { diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java index afbcc53c..f2414d2f 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java @@ -46,6 +46,8 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe OutRechargeChildOrderExample example = new OutRechargeChildOrderExample(); example.createCriteria().andParentOrderIdEqualTo(orderId); + example.setOrderByClause("create_time desc"); + return rechargeChildOrderMapper.selectByExample(example); } 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 ece7a931..ab7496a7 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 @@ -889,7 +889,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 定义新的子订单对象 OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - // 1:尖椒 2:龙阅 3:畅停 + // 1:尖椒 2:龙阅 3:畅停 4.嗨购 int type = 0; // 定义新增子订单充值平台 int rechargePlatformType = 0; @@ -948,7 +948,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); object.put("return_content", returnObject); - if (returnObject != null && returnObject.getLong("code") == 200) { + if (returnObject.getLong("code") == 200) { childOrder.setStatus(102); } else { childOrder.setStatus(103); @@ -987,7 +987,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { object.put("mobile", outRechargeOrder.getRechargeContent()); JSONObject returnObject = RechargeConfig.rechargeOrderByCy(object); object.put("return_content", returnObject); - if (returnObject != null && returnObject.getBoolean("success")) { + if (returnObject.getBoolean("success")) { childOrder.setStatus(102); } else { childOrder.setStatus(103); @@ -995,6 +995,26 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { rechargePlatformType = 3; break; } + // 嗨购充值 + if (s.equals("4") && type == 4) { + + map.put("sourceId" , outRechargePrice.getId()); + map.put("rechargePlatform" , type); + BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); + object.put("orderid", orderNo); + object.put("product_id", rechargeCode.getGoodsId()); + object.put("phone", outRechargeOrder.getRechargeContent()); + object.put("price", outRechargeOrder.getRechargePrice()); + JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object); + object.put("return_content", returnObject); + if (returnObject.getLong("code") != null && returnObject.getLong("code") == 200) { + childOrder.setStatus(102); + } else { + childOrder.setStatus(103); + } + rechargePlatformType = 4; + break; + } } childOrder.setOrderNo(orderNo); diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 4d9b36ce..93e7444b 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -82,20 +82,22 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelMemberId=d13091df65d64aafbf0f35d2093157b7 # Jj -JjNotifyUrl = https://hsgcs.dctpay.com/order/telChargeCallback/rechargeCallbackByJj +JjNotifyUrl = https://hsgcs.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByJj JjAppKey = eaomqcbpdz7yjfih JjUrl = https://hfcs.dmjvip.com/index.php/third/mobile/ JjAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8 #LY -LyNotifyUrl = https://hsgcs.dctpay.com/order/telChargeCallback/rechargeCallbackByLy -#LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU -#LyMemberId=18665 -#LyPostUrl=https://cz.31994.cn/yrapi.php/ +LyNotifyUrl = https://hsgcs.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByLy LyApiKey=UzMxo9SIL1tmFvWTwys7pQRGJqO3EChK LyMemberId=11236 LyPostUrl=http://cz.zt10010.com/yrapi.php/ +HgNotifyUrl = https://hsgcs.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByHg +HgApiKey=3fd74e7c16b04681a0f481c5bc0a96d3 +HgMemberId=1622808562621276161 +HgPostUrl=http://113.250.49.100:8088/recharge/ + #CY CyApiKey=cyMYLABWa2H2u CyAppSecret =cysslWXHnMHDMEvDEtwSWaJMGwl4dkcPLT diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index ede94b33..e7ef7de5 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -77,13 +77,13 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelMemberId=d13091df65d64aafbf0f35d2093157b7 // Mobile -JjNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByJj +JjNotifyUrl = https://hsg.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByJj JjAppKey = p429mlj3cvn5hb07 JjUrl = https://jj.dmjvip.com/index.php/third/mobile/ JjAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij #LY -LyNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByLy +LyNotifyUrl = https://hsg.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByLy #LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU ##LyMemberId=18665 ##LyPostUrl=https://cz.31994.cn/yrapi.php/ @@ -92,6 +92,12 @@ LyMemberId=11236 LyPostUrl=http://cz.zt10010.com/yrapi.php/ +HgNotifyUrl = https://hsg.dctpay.com/order/mobileRechargeNotify/rechargeCallbackByHg +HgApiKey=3fd74e7c16b04681a0f481c5bc0a96d3 +HgMemberId=1622808562621276161 +HgPostUrl=http://113.250.49.100:8088/recharge/ + + #CY CyApiKey=cyMYLABWa2H2u CyAppSecret =cysslWXHnMHDMEvDEtwSWaJMGwl4dkcPLT