diff --git a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java index 979370b4..21feb168 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java @@ -374,10 +374,8 @@ public class CommonController { @RequestParam(name = "lat", required = true) String lat ) { try { - System.out.println("请求经度==================" + lng); - System.out.println("请求纬度==================" + lat); + JSONObject object = commonService.findByLatAndLng(lng , lat); - System.out.println("请求经纬度========" + object); return ResponseMsgUtil.success(object); } catch (Exception e) { 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 c2e385cb..2fb268be 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; 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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private OrderService orderService; @Autowired private WeChatQrcodeUtils weChatQrcodeUtils; @Resource private OrderRefundService orderRefundService; @Resource private HighOrderService highOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); // JSONObject object = new JSONObject(); // object.put("refuelPrice" , new BigDecimal(100)); // object.put("gasOilNo" , "92"); // object.put("gasGunNo" , "1"); // object.put("storeCode" , "54000"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { List highOrders = orderService.phoneErrorOrder(); for (HighOrder order: highOrders) { try { outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } return ResponseMsgUtil.success("操作成功"); } @RequestMapping(value = "/checkOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号话费查询是否可以退款") public ResponseData checkOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { outRechargeOrderService.rechargeOrderHandle(orderNo); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData orderRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Calendar createTimeS = Calendar.getInstance(); createTimeS.set(Calendar.DATE, 17); createTimeS.set(Calendar.HOUR_OF_DAY , 00); createTimeS.set(Calendar.MINUTE , 00); createTimeS.set(Calendar.SECOND , 00); Calendar createTimeE = Calendar.getInstance(); createTimeE.set(Calendar.DATE, 20); createTimeE.set(Calendar.HOUR_OF_DAY , 15); createTimeE.set(Calendar.MINUTE , 25); createTimeE.set(Calendar.SECOND , 00); Map param = new HashMap<>(); // param.put("createTimeS", createTimeS.getTimeInMillis()); // param.put("createTimeE", createTimeE.getTimeInMillis()); param.put("orderNo", orderNo); List orderRefundList = orderRefundService.getRefundOrderList(param); for (HighOrderRefund orderRefund : orderRefundList) { try { orderRefundService.refundPrice( orderRefund.getRefundOrderNo(), orderService.getOrderDetailByNo(orderRefund.getOrderNo()), OrderPayType.getDataByType(orderRefund.getPayType()), orderRefund.getRefundPrice(), orderRefund.getRefundIntegral() ); orderRefund.setExt1("true"); } catch (Exception e) { orderRefund.setExt1("false"); } finally { orderRefundService.update(orderRefund); } } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderMigration", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单迁移") public ResponseData phoneBillOrderMigration() { try { List list = outRechargeOrderService.selectList(); 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()); order.setDeductionCouponPrice(outRechargeOrder.getDiscountDeductionPrice()); if (outRechargeOrder.getDiscountDeductionPrice() == null) { outRechargeOrder.setDiscountDeductionPrice(new BigDecimal(0)); } if (outRechargeOrder.getIntegralDeductionPrice() == null) { outRechargeOrder.setIntegralDeductionPrice(new BigDecimal(0)); } order.setTotalDeductionPrice(outRechargeOrder.getDiscountDeductionPrice().add(outRechargeOrder.getIntegralDeductionPrice())); 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.excel.EasyExcel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; import com.bweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.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.model.ExportOrderMobileModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; 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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; 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; @Autowired private OutRechargeChildOrderService childOrderService; @Resource private HighOrderService highOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/refuelOnline/getStationStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取充值产品") public ResponseData getRechargeProduct() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/mobileRecharge/getMobileProduct" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询可用城市") public ResponseData getAllCities() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/apiMerchants/getAllCities" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克门店") public ResponseData starbucksStore() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("lat" , "29.56900"); mapPost.put("lon" , "106.55843"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("lat" , "29.56900"); map.put("lon" , "106.55843"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksStore" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克商品") public ResponseData starbucksProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/starbucks/starbucksProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcStoresList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData kfcStoresList() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcStoresList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店编码查询KFC产品") public ResponseData kfcProductByStoreCode(@RequestParam(name = "storeCode", required = true) String storeCode) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("storeCode" , storeCode); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("storeCode" , storeCode); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/kfc/kfcProductByStoreCode" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/memberProducts", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询会员产品") public ResponseData memberProducts() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/memberRecharge/memberProducts" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("notifyUrl" , "test"); // JSONObject object = new JSONObject(); // object.put("refuelPrice" , new BigDecimal(100)); // object.put("gasOilNo" , "92"); // object.put("gasGunNo" , "1"); // object.put("storeCode" , "54000"); mapPost.put("content" , object.toString()); System.out.println(mapPost); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("timetable" , mapPost.get("timetable").toString()); map.put("orderNo" , mapPost.get("orderNo")); map.put("productType" , object.getString("productType")); map.put("content" , object.toString()); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(3); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mobileDw", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单下载") public ResponseData mobileDw(@RequestParam(name = "createTimeS", required = true) String createTimeS, @RequestParam(name = "createTimeE", required = true) String createTimeE) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); List order = highOrderService.getOrderListNotChild(map); List list = new ArrayList<>(); ExportOrderMobileModel model; for (HighOrder highOrder : order) { model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); if (rechargeOrder != null) { OutRechargeChildOrder childOrder = mobileChildOrderHandle(highOrder,rechargeOrder); model.setRechargeOrderNo(rechargeOrder.getOrderNo()); if (childOrder != null) { model.setChildOrderNo(childOrder.getOrderNo()); if (childOrder.getRechargePlatform() != null) { model.setRechargePlatform(RechargePlatformType.getDataByType(childOrder.getRechargePlatform()).getName()); } model.setRemark(childOrder.getExt1()); } } model.setFinishTime(highOrder.getFinishTime()); model.setOrderStatus(OrderStatus.getDataByType(highOrder.getOrderStatus()).getName()); model.setMemPhone(highOrder.getMemPhone()); model.setCreateTime(highOrder.getCreateTime()); model.setTitle(highOrder.getTitle()); model.setPayablePrice(highOrder.getPayablePrice()); model.setRefundTime(highOrder.getRefundTime()); model.setPayPrice(highOrder.getPayPrice()); model.setOrderNo(highOrder.getOrderNo()); model.setMemCardNo(highOrder.getMemCardNo()); if (highOrder.getPayType() != null) { model.setPayType(OrderPayType.getDataByType(highOrder.getPayType()).getName()); } list.add(model); } String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { file.mkdirs(); } EasyExcel.write(fileUrl+pathName) .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); return ResponseMsgUtil.success(pathName); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/phoneBillOrderMigration", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费订单迁移") // public ResponseData phoneBillOrderMigration() { // try { // // List list = outRechargeOrderService.selectList(); // // 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()); // order.setDeductionCouponPrice(outRechargeOrder.getDiscountDeductionPrice()); // // if (outRechargeOrder.getDiscountDeductionPrice() == null) { // outRechargeOrder.setDiscountDeductionPrice(new BigDecimal(0)); // } // if (outRechargeOrder.getIntegralDeductionPrice() == null) { // outRechargeOrder.setIntegralDeductionPrice(new BigDecimal(0)); // } // order.setTotalDeductionPrice(outRechargeOrder.getDiscountDeductionPrice().add(outRechargeOrder.getIntegralDeductionPrice())); // 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; // } // } public OutRechargeChildOrder mobileChildOrderHandle(HighOrder highOrder , OutRechargeOrder outRechargeOrder) { // 组装查询子订单数据 Map childOrderMap101 = new HashMap<>(); childOrderMap101.put("parent_order_id", outRechargeOrder.getId()); childOrderMap101.put("status", "101,102"); // 查询充值订单 List childOrders = childOrderService.getListRechargeChildOrder(childOrderMap101); OutRechargeChildOrder childOrder; // 判读是否存在多个充值中的订单 if (childOrders.size() > 0) { childOrder = childOrders.get(0); if (childOrders.size() > 1) { childOrder.setExt1("当前订单存在多个充值订单"); } } else { childOrder = childOrderService.findByOrderId(outRechargeOrder.getId()); if (childOrder != null && highOrder != null && childOrder.getStatus() != null && highOrder.getOrderStatus() != null) { if (highOrder.getOrderStatus() == 2 && childOrder.getStatus() != 102) { childOrder.setExt1("主订单充值中,但是充值订单状态不为充值中"); } if (highOrder.getOrderStatus() == 3 && childOrder.getStatus() != 101) { childOrder.setExt1("主订单充值成功,但是充值订单状态不为充值成功"); } if (highOrder.getOrderStatus() == 4 && !(childOrder.getStatus() == 103 || childOrder.getStatus() == 104)) { childOrder.setExt1("主订单退款,但是充值订单状态不为退款"); } } } return childOrder; } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/resources/dev/config.properties b/hai-bweb/src/main/resources/dev/config.properties index da0992f7..25674f3d 100644 --- a/hai-bweb/src/main/resources/dev/config.properties +++ b/hai-bweb/src/main/resources/dev/config.properties @@ -1,5 +1,5 @@ -fileUrl=/home/project/hsg/filesystem -#fileUrl=/Volumes/work/code/filesystem/ +#fileUrl=/home/project/hsg/filesystem +fileUrl=/Volumes/work/code/filesystem/ cmsPath=/home/project/hsg/filesystem/cmsPath agentQrCode=/home/project/hsg/filesystem/agentQrCode agentQrCodeWxUrl=https://hsgcs.dctpay.com/wx/?action=ic&id= diff --git a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java index 0e380e56..f3953224 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -251,45 +251,6 @@ public class CommonController { } } - @RequestMapping(value = "/getScanCodePageHtmlSign", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "获取扫码页面签名") - public ResponseData getScanCodePageHtmlSign(@RequestBody JSONObject body) { - try { - if (body == null || StringUtils.isBlank(body.getString("url"))) { - log.error("getH5UserInfo error!", "参数校验失败" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - Map params = new HashMap<>(); - params.put("appid", SysConst.getSysConfig().getWxH5AppId()); - params.put("secret", SysConst.getSysConfig().getWxH5AppSecret()); - params.put("grant_type", "client_credential"); - - params.clear(); - params.put("access_token", weChatQrcodeUtils.getWxToken()); - params.put("type", "jsapi"); - JSONObject jsapiTicketObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", params); - if (jsapiTicketObject == null) { - log.error("getH5UserInfo error!", "获取微信jsapi_ticket失败" ); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信jsapi_ticket失败"); - } - - params = new HashMap<>(); - params.put("noncestr", WxUtils.makeNonStr()); - params.put("jsapi_ticket", jsapiTicketObject.getString("ticket")); - params.put("timestamp", System.currentTimeMillis() / 1000); - params.put("url", body.getString("url")); - - String signatureStr = WxUtils.generateSignature(params); - System.out.println(signatureStr); - params.put("signature", SHA1.gen(signatureStr)); - return ResponseMsgUtil.success(params); - - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } @RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET) @ResponseBody diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 4d31523a..e78f6070 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -41,38 +41,6 @@ public class OutRechargeOrderController { @Resource private OutRechargePriceService outRechargePriceService; - - @RequestMapping(value = "/addOrder", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "增加订单") - public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) { - try { - - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - - - - if (StringUtils.isBlank(object.getString("rechargeContent")) || - object.getLong("goodsId") == null - ) { - log.error("addOrder error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - object.put("mchId", request.getHeader("mchId")); - object.put("userId", userInfoModel.getHighUser().getId()); - - return ResponseMsgUtil.success(outRechargeOrderService.insertOrder(object)); - - } catch (Exception e) { - log.error("HighOrderController -> addOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据id查询订单详情") 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 4c1317bf..391d5090 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java @@ -195,7 +195,7 @@ public class OrderMobileRechargeController { dataList.add(model); } - String fileUrl = SysConst.getSysConfig().getFileUrl() + "temp orary/"; + String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java index 2b294cbb..5ba7131d 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java @@ -1,5 +1,6 @@ package com.hai.schedule; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.DateUtil; @@ -12,6 +13,7 @@ import com.hai.entity.OutRechargeOrder; import com.hai.order.service.OrderService; import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeOrderService; +import com.hai.service.impl.OutRechargeOrderServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; @@ -34,7 +36,7 @@ import java.util.Map; @Configuration public class HighRechargeOrderSchedule { - Logger log = LoggerFactory.getLogger(HighRechargeOrderSchedule.class); + private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); @Resource private OutRechargeOrderService outRechargeOrderService; @@ -53,64 +55,24 @@ public class HighRechargeOrderSchedule { * @Date 14:18 2022/5/31 * @Param [] */ - @Scheduled(cron = "0 0/7 * * * ?") //每7分钟执行一次 + @Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次 public void initRechargeOrder() { + log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); map.put("payStatus", String.valueOf(102)); - map.put("rechargeStatus", String.valueOf(205)); + map.put("rechargeStatus", String.valueOf(201)); List orderList = outRechargeOrderService.getListRechargeOrder(map); + log.info("处理话费订单条数:" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { - - // 定义小时数 - Date rechargeTime = order.getCreateTimed(); - Date currentTime = new Date(); - int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); - - // 查询当前订单是否超时 如果超过72小时则处理退款 - if (hours < 72) { - outRechargeOrderService.pollRequest(order); - } else { - // 话费订单处理 - outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); - } - + outRechargeOrderService.prepaidRechargeHandle(order); } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", e); + log.info("话费定时任务订单业务出现异常", e); } } } - System.out.println("话费定时任务 -> 结束任务"); } - @Scheduled(cron = "0 0/5 * * * ?") //每7分钟执行一次 - public void phoneErrorOrder() { - List highOrders = orderService.phoneErrorOrder(); - for (HighOrder order: highOrders) { - try { - // 定义话费充值业务订单模型 or 充值记录订单模型 - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); - OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); - // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 - Integer status = outRechargeOrderService.getRechargeOrderLegality(outRechargeOrder , childOrder); - - if (status == 2 || status == -1) { - childOrder.setStatus(103); - childOrder.setUpdateTime(new Date()); - rechargeChildOrderService.updateOrder(childOrder); - outRechargeOrder.setRechargeStatus(205); - outRechargeOrderService.updateOrder(outRechargeOrder); - } else if (status == 1) { - outRechargeOrderService.completeOrder(childOrder.getOrderNo()); - } - - } catch (Exception e) { - log.error("HighCouponSchedule --> expiredCoupon() error!", e); - } - - } - System.out.println("话费定时任务 -> 结束任务"); - } } diff --git a/hai-schedule/src/main/resources/prod/application.yml b/hai-schedule/src/main/resources/prod/application.yml index 4e86ae84..0d8036d4 100644 --- a/hai-schedule/src/main/resources/prod/application.yml +++ b/hai-schedule/src/main/resources/prod/application.yml @@ -79,6 +79,28 @@ mybatis: type-aliases-package: org.springboot.sample.entity +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 + pagehelper: helperDialect: mysql reasonable: true diff --git a/hai-service/src/main/java/com/hai/config/MessageConfig.java b/hai-service/src/main/java/com/hai/config/MessageConfig.java index af33df68..d124d367 100644 --- a/hai-service/src/main/java/com/hai/config/MessageConfig.java +++ b/hai-service/src/main/java/com/hai/config/MessageConfig.java @@ -199,8 +199,6 @@ public class MessageConfig { public static Map buildRequestBody(String msisdn, String smsTemplateId, Map paramValues, String accout, String passward) { if (null == msisdn || null == smsTemplateId || null == accout || null == passward) { - System.out.println( - "buildRequestBody(): mobiles, templateId or templateParas or account or password is null."); return null; } 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 71e40c93..274e623d 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -7,11 +7,15 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.WxUtils; +import com.hai.entity.OutRechargeChildOrder; +import com.hai.entity.OutRechargeOrder; +import com.hai.service.OutRechargeChildOrderService; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.*; /** @@ -26,6 +30,7 @@ public class RechargeConfig { private static Logger log = LoggerFactory.getLogger(RechargeConfig.class); + /** * @Author Sum1Dream * @name getProductsList.java @@ -62,13 +67,12 @@ public class RechargeConfig { paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); - log.info("============请求任务Start============="); + log.info("发起龙阅订单充值="); log.info("龙阅订单充值-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap); log.info("龙阅订单充值-响应参数: " + jsonObject.toJSONString()); - log.info("============请求任务End=============="); return jsonObject; } @@ -90,13 +94,12 @@ public class RechargeConfig { paramMap.put("out_trade_nums" , object.getString("out_trade_nums")); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); - log.info("============请求任务Start============="); + log.info("发起龙阅订单查询="); log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); log.info("龙阅订单查询-响应参数: " + jsonObject.toJSONString()); - log.info("============请求任务End=============="); return jsonObject; } @@ -123,42 +126,16 @@ public class RechargeConfig { String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5); map.put("sign" , signStr); - log.info("============请求任务Start============="); + log.info("发起尖椒充值"); log.info("尖椒订单充值-请求参数: " + JSON.toJSONString(map)); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "createOrder" , map); log.info("尖椒订单充值-响应参数: " + jsonObject.toJSONString()); - log.info("============请求任务End=============="); return jsonObject; } - /** - * @Author Sum1Dream - * @name checkOrderByJj.java - * @Description // 尖椒查询订单详情 - * @Date 09:57 2022/5/25 - * @Param [com.alibaba.fastjson.JSONObject] - * @return com.alibaba.fastjson.JSONObject - */ - public static JSONObject checkOrderByJj(JSONObject object) throws Exception { - - String timestamp = String.valueOf(System.currentTimeMillis()); - - Map map = new HashMap<>(); - map.put("out_order_id" , object.getString("out_order_id")); - map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey()); - map.put("timestamp" , timestamp.substring(0,timestamp.length()-3)); - map.put("notify_url" , CommonSysConst.getSysConfig().getLyNotifyUrl()); - - String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5); - - map.put("sign" , signStr); - - return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "queryOrder" , map); - - } /** * @Author Sum1Dream @@ -179,37 +156,16 @@ public class RechargeConfig { paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey()); paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5)); - log.info("============请求任务Start============="); + log.info("发起城宇话费下单="); log.info("城宇话费下单-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap); log.info("城宇话费下单-响应参数: " + jsonObject.toJSONString()); - log.info("============请求任务End=============="); return jsonObject; } - /** - * @Author Sum1Dream - * @name rechargeOrderByCy.java - * @Description // 城宇话费查询订单详情 - * @Date 10:22 2022/7/14 - * @Param [com.alibaba.fastjson.JSONObject] - * @return com.alibaba.fastjson.JSONObject - */ - public static JSONObject queryRechargeByCy(JSONObject object) throws Exception { - - Map paramMap = new HashMap<>(); - - paramMap.put("orderId" , object.getString("orderNo")); - 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)); - - return HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/queryRecharge", paramMap); - - } /** * @Author Sum1Dream @@ -230,14 +186,13 @@ public class RechargeConfig { paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl()); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); - log.info("============请求任务Start============="); + log.info("发起畅停话费查询订单="); 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; } @@ -256,29 +211,12 @@ public class RechargeConfig { paramMap.put("orderid" , object.getString("orderid")); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); - log.info("============请求任务Start============="); + log.info("发起畅停话费查询订单="); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>()); log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString()); - log.info("============请求任务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; } @@ -298,4 +236,5 @@ public class RechargeConfig { } + } diff --git a/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java b/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java new file mode 100644 index 00000000..1b2f224a --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java @@ -0,0 +1,86 @@ +package com.hai.order.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单退款模型 + * @className: ExportGasOrderModel + * @author: 袁野 + * @date: 2022/10/28 + **/ +@Data +public class ExportOrderMobileModel { + + @ColumnWidth(25) + @ExcelProperty("标题") + private String title; + + @ColumnWidth(15) + @ExcelProperty("客户电话") + private String memPhone; + + @ColumnWidth(25) + @ExcelProperty("交易单号") + private String orderNo; + + @ColumnWidth(25) + @ExcelProperty("充值订单号") + private String rechargeOrderNo; + + @ColumnWidth(25) + @ExcelProperty("充值子订单号") + private String childOrderNo; + + + @ColumnWidth(15) + @ExcelProperty("充值平台") + private String rechargePlatform; + + @ColumnWidth(13) + @ExcelProperty(value = "支付方式") + private String payType; + + @ColumnWidth(22) + @ExcelProperty(value = "卡号") + private String memCardNo; + + @ColumnWidth(13) + @ExcelProperty(value = "应付金额") + private BigDecimal payablePrice; + + @ColumnWidth(13) + @ExcelProperty(value = "实付金额") + private BigDecimal payPrice; + + @ColumnWidth(15) + @ExcelProperty("订单状态") + private String orderStatus; + + + + @ColumnWidth(15) + @ExcelProperty("创建时间") + private Date createTime; + + @ColumnWidth(15) + @ExcelProperty("支付时间") + private Date payTime; + + @ColumnWidth(15) + @ExcelProperty("完成时间") + private Date finishTime; + + @ColumnWidth(15) + @ExcelProperty("退款时间") + private Date refundTime; + + @ColumnWidth(15) + @ExcelProperty("备注") + private String remark; + +} diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index 240f3d6f..ed0b1083 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -489,10 +489,10 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); if (outRechargeOrder.getPayStatus() == null) { if (order.getProductType().equals(9)) { - outRechargeOrderService.editOutRechargeOrder(order); + outRechargeOrderService.editOutRechargeOrder(order , outRechargeOrder); } } - outRechargeOrderService.pollRequest(outRechargeOrder); + outRechargeOrderService.getPrepaidRechargeApi(outRechargeOrder); } } diff --git a/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java b/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java index d515399b..38912ac0 100644 --- a/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java +++ b/hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java @@ -9,10 +9,12 @@ import java.util.Objects; * @date: 2022/8/24 **/ public enum RechargePlatformType { + STATUS0(0, "未知"), STATUS1(1, "尖椒"), STATUS2(2, "龙阅"), STATUS3(3, "城宇"), STATUS4(4, "畅停"), + STATUS100(100, "手动"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 14b06d1b..04aa214e 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -133,6 +133,13 @@ public interface HighOrderService { **/ List getOrderList(Map map); + /** + * @Author 胡锐 + * @Description 查询订单列表 + * @Date 2021/3/26 23:06 + **/ + List getOrderListNotChild(Map map); + /** * 查询订单列表 * @param map diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index 2004c2ea..3f2d3162 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -24,10 +24,6 @@ public interface OutRechargeOrderService { **/ List getListRechargeOrder(Map map); - - List selectList(); - - /** * @Author Sum1Dream * @Description // 根据订单ID查询订单 @@ -46,14 +42,15 @@ public interface OutRechargeOrderService { **/ OutRechargeOrder findByOrderNo(String orderNo); - /*** todo 当前接口已经废弃 + /** * @Author Sum1Dream - * @Description // 新增订单 - * @Date 15:25 2021/6/11 - * @Param [outRechargeOrder] - * @return void + * @Description // 根据订单号查询订单 + * @Date 15:20 2021/6/11 + * @Param [orderNo] + * @return com.hai.entity.OutRechargeOrder **/ - OutRechargeOrder insertOrder(JSONObject object) throws Exception; + OutRechargeOrder findByOrderNoNotChild(String orderNo); + /*** * @Author Sum1Dream @@ -136,17 +133,29 @@ public interface OutRechargeOrderService { * @Param [orderId] * @Return void */ - void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception; + void refundOrder(Long orderId) throws Exception; + /** - * @Author Sum1Dream - * @name pollRequest.java - * @Description // 充值轮询 - * @Date 16:32 2022/5/25 - * @Param [com.hai.entity.OutRechargeOrder] - * @return void - */ - void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception; + * @Author Sum1Dream + * @Name getPrepaidRechargeApi + * @Description // 请求上游话费充值接口 + * @Date 14:25 2023/3/28 + * @Param [rechargeOrder] + * @Return void + */ + void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) throws Exception; + + /** + * @Author Sum1Dream + * @Name prepaidRechargeHandle + * @Description // 处理订单应用 + * @Date 18:44 2023/3/28 + * @Param [outRechargeOrder] + * @Return void + */ + void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder) throws Exception; + /** * @Author Sum1Dream @@ -178,17 +187,7 @@ public interface OutRechargeOrderService { * @Param [order, outRechargeOrder] * @Return void */ - void editOutRechargeOrder(HighOrder order); - - /** - * @Author Sum1Dream - * @Name refundLegality - * @Description // 话费订单处理 - * @Date 14:45 2023/2/15 - * @Param [outRechargeOrder, childOrder] - * @Return void - */ - void rechargeOrderHandle(String orderNo) throws Exception; + void editOutRechargeOrder(HighOrder order , OutRechargeOrder outRechargeOrder); /** * @Author Sum1Dream @@ -198,6 +197,6 @@ public interface OutRechargeOrderService { * @Param [object] * @Return void */ - Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; + Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) throws Exception; } 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 99e80c5c..eda3b737 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 @@ -829,6 +829,49 @@ public class HighOrderServiceImpl implements HighOrderService { return list; } + @Override + public List getOrderListNotChild(Map map) { + HighOrderExample example = new HighOrderExample(); + HighOrderExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "memId") != null) { + criteria.andMemIdEqualTo(MapUtils.getLong(map, "memId")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { + String[] statuses = MapUtils.getString(map, "status").split(","); + List list = new ArrayList<>(); + for (String status : statuses) { + list.add(Integer.parseInt(status)); + } + criteria.andOrderStatusIn(list); + } + + if (MapUtils.getString(map, "orderNo") != null) { + criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo")); + } + + if (MapUtils.getString(map, "phone") != null) { + criteria.andMemPhoneEqualTo(MapUtils.getString(map, "phone")); + } + + 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"))) { + criteria.andCreateTimeBetween( + DateUtil.format(MapUtils.getString(map, "createTimeS"), "yyyy-MM-dd HH:mm:ss"), + DateUtil.format(MapUtils.getString(map, "createTimeE"), "yyyy-MM-dd HH:mm:ss")); + } + +// example.setOrderByClause("create_time desc"); + + + return highOrderMapper.selectByExample(example); + } + + @Override public List getGoodsOrderModelList(Map map) throws Exception { 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 10cc548d..1f23f0b9 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 @@ -31,8 +31,14 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe if (MapUtils.getLong(map , "parent_order_id") != null) { criteria.andParentOrderIdEqualTo(MapUtils.getLong(map , "parent_order_id")); } - if (MapUtils.getInteger(map , "status") != null) { - criteria.andStatusEqualTo(MapUtils.getInteger(map , "status")); + if (MapUtils.getString(map , "status") != null) { + + String[] statusArray = MapUtils.getString(map, "status").split(","); + List list = new ArrayList<>(); + for (String status : statusArray) { + list.add(Integer.parseInt(status)); + } + criteria.andStatusIn(list); } example.setOrderByClause("create_time desc"); @@ -77,7 +83,7 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe OutRechargeChildOrderExample.Criteria criteria = example.createCriteria(); criteria.andParentOrderIdEqualTo(orderId); - + example.setOrderByClause("create_time desc"); List list = rechargeChildOrderMapper.selectByExample(example); if (list.size() > 0 ) { 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 75a33037..e408ff9a 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 @@ -20,6 +20,7 @@ import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildStatus; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; +import com.hai.order.utils.OrderUtil; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import org.apache.commons.collections4.MapUtils; @@ -53,9 +54,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private OrderService orderService; - @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; - @Resource private HighUserService highUserService; @@ -65,12 +63,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private OutRechargePriceService outRechargePriceService; - @Resource - private GoodsOrderServiceImpl goodsOrderService; - - @Resource - private BsIntegralRebateService bsIntegralRebateService; - @Resource private HighDiscountUserRelService highDiscountUserRelService; @@ -80,26 +72,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private OutRechargeChildOrderService outRechargeChildOrderService; - @Resource - private BsRequestRecordService bsRequestRecordService; - - @Resource - private BsConfigService bsConfigService; - - @Resource - private SecConfigService secConfigService; - - @Resource - private HighUserPayPasswordService highUserPayPasswordService; - - @Resource - private ApiMerchantsService apiMerchantsService; - - @Resource - private ApiAmountRecordService apiAmountRecordService; - - @Resource - private ApiOrderRecordService apiOrderRecordService; @Resource private BsRechargeCodeService rechargeCodeService; @@ -177,11 +149,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.selectByExample(example); } - @Override - public List selectList() { - return outRechargeOrderMapper.selectList(); - } - @Override public OutRechargeOrder findByOrderId(Long orderId) { return outRechargeOrderMapper.selectByPrimaryKey(orderId); @@ -207,203 +174,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrder; } - // todo 接口已经废弃 @Override - @Transactional( - isolation = Isolation.SERIALIZABLE, - propagation = Propagation.REQUIRES_NEW) - public OutRechargeOrder insertOrder(JSONObject object) throws Exception { - - OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); - - HighUser user = highUserService.findByUserId(object.getLong("userId")); + public OutRechargeOrder findByOrderNoNotChild(String orderNo) { - // 产品id - Long goodsId = object.getLong("goodsId"); - - // 充值内容 - String rechargeContent = object.getString("rechargeContent"); - - // 查询产品详情 - OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId, null); - - Map listMap = new HashMap<>(); - listMap.put("productType", "3"); - listMap.put("returnType", 1); - listMap.put("sourceId", goodsId); - - // 查询产品积分抵扣比例 - BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap); - - // 判断充值系统是否关闭 - if (!secConfigService.isConfig("RECHARGE", "1")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); - } - - HighDiscountUserRel highDiscountUserRel = null; - // 判断是否有优惠券 - if (object.getLong("memDiscountId") != null) { - outRechargeOrder.setMemDiscountId(object.getLong("memDiscountId")); - // 卡优惠券信息 - highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId")); - if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); - } - if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType()) - && !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券"); - } - } else { - outRechargeOrder.setPayRealPrice(outRechargePrice.getPayPrice()); - } - - // 优惠券抵扣 - if (highDiscountUserRel != null) { - - outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); - BigDecimal payPrice = new BigDecimal(0); - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { - // 如果商品支付总额 小于 满减价格 - if (outRechargePrice.getRechargePrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) < 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到" + highDiscountUserRel.getHighDiscount().getDiscountCondition() + "元,无法使用此优惠券"); - } - // 计算支付金额 = 商品充值总额 - 满减额度 - payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - - } - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { - // 计算支付金额 = 商品充值总额 - 满减额度 - payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - - } - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { - BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); - // 订单总额 * 折扣 - payPrice = outRechargePrice.getRechargePrice().multiply(discountPrice); - outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getRechargePrice().subtract(payPrice)); - outRechargeOrder.setPayRealPrice(payPrice); - } - - // 如果总额小于0 - if (payPrice.compareTo(new BigDecimal("0")) < 0) { - outRechargeOrder.setPayRealPrice(new BigDecimal("0")); - } else { - outRechargeOrder.setPayRealPrice(payPrice); - } - } - - // 判断积分数量是否大于0 - if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) { - - // 判断用户积分是否够 - if (object.getLong("integralNum") > user.getGold()) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足"); - } - - // 积分抵扣金额 - BigDecimal integralDeductionPrice = object.getBigDecimal("integralNum").divide(new BigDecimal(100).setScale(2, RoundingMode.HALF_UP)); - // 最高可抵扣金额 - BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); - // 判读积分是否大于限制额度 - if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) < 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单最大抵扣积分金额:" + maxIntegralDeductionPrice); - } - - // 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额 - if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) { - // 查询用户支付密码 - HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(object.getLong("userId")); - if (userPayPassword == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); - } - if (StringUtils.isBlank(object.getString("password"))) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); - } - // 校验支付密码 - if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); - } - } - - outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice); - outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice())); - - } - - outRechargeOrder.setUserId(user.getId()); - outRechargeOrder.setIntegralNum(object.getBigDecimal("integralNum")); - outRechargeOrder.setRechargeContent(rechargeContent); - outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId()); - outRechargeOrder.setUserName(user.getName()); - outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); - outRechargeOrder.setUserPhone(user.getPhone()); - outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); - outRechargeOrder.setCreateTimed(new Date()); - outRechargeOrder.setGoodsId(goodsId); - outRechargeOrder.setWhetherRebate(false); - outRechargeOrder.setMerchId(object.getString("mchId")); - outRechargeOrder.setRechargePrice(outRechargePrice.getRechargePrice()); - if (object.getLong("memDiscountId") != null) { - outRechargeOrder.setPayPrice(outRechargePrice.getRechargePrice()); - } else { - outRechargeOrder.setPayPrice(outRechargePrice.getPayPrice()); - } - outRechargeOrder.setType(1); - outRechargeOrder.setOrderPrice(outRechargePrice.getRechargePrice()); - outRechargeOrder.setOperatorName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType())); - outRechargeOrder.setOperatorType(outRechargePrice.getOperatorType()); - - - // 判断积分支付是否扣完金额 - if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { - // 201:充值中 202:充值成功 203:充值失败 204:未充值 - outRechargeOrder.setRechargeStatus(204); - // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - outRechargeOrder.setPayStatus(102); - outRechargeOrder.setPayTime(new Date()); - outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); - } else { - // 201:充值中 202:充值成功 203:充值失败 204:未充值 - outRechargeOrder.setRechargeStatus(204); - // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - outRechargeOrder.setPayStatus(101); - } - - // 使用优惠券 - if (outRechargeOrder.getMemDiscountId() != null) { - HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); - discountUserRel.setUseTime(new Date()); // 使用时间 - discountUserRel.setStatus(2); //状态 0:已过期 1:未使用 2:已使用 - highDiscountUserRelService.updateDiscountUserRel(discountUserRel); - - HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(discountUserRel.getDiscountAgentCodeId()); - code.setStatus(3); - highDiscountAgentCodeService.updateCode(code); - } - - - - outRechargeOrderMapper.insert(outRechargeOrder); + OutRechargeOrderExample example = new OutRechargeOrderExample(); + example.createCriteria().andOrderNoEqualTo(orderNo); - if (outRechargeOrder.getIntegralNum() != null) { - String remark = "话费订单" + outRechargeOrder.getOrderNo() + "下单,使用积分:" + object.getInteger("integralNum"); - highUserService.goldHandle(outRechargeOrder.getUserId(), outRechargeOrder.getIntegralNum().intValue(), 2, 2, outRechargeOrder.getId() , remark); - } + List list = outRechargeOrderMapper.selectByExample(example); - if (outRechargeOrder.getPayStatus() == 102) { - pollRequest(outRechargeOrder); + if (list.size() == 0) { + return null; } - return outRechargeOrder; - + return list.get(0); } @Override @@ -574,9 +357,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { isolation = Isolation.READ_COMMITTED, timeout = 25, rollbackFor = Exception.class) - public void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception { + public void refundOrder(Long orderId) throws Exception { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); + log.info("发起话费订单退款" + outRechargeOrder.getOrderNo() + ""); + // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 if (outRechargeOrder.getPayStatus() != 102) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); @@ -584,7 +369,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { // 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 if (outRechargeOrder.getRechargeStatus() == 202) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款"); } // 订单处理 @@ -599,192 +384,104 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { outRechargeOrder.setRefundTime(new Date()); outRechargeOrderService.updateOrder(outRechargeOrder); - // 充值订单记录修改状态 - childOrder.setStatus(103); - outRechargeChildOrderService.updateOrder(childOrder); } - @Override - public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { + public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) throws Exception { - // 查询充值产品 - OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); + JSONObject object = new JSONObject(); + object.put("rechargePrice" , outRechargeOrder.getRechargePrice()); + object.put("rechargeMobile" , outRechargeOrder.getRechargeContent()); + object.put("productId" , outRechargeOrder.getGoodsId()); + object.put("parentOrderId" , outRechargeOrder.getId()); + + // 判断参数是否为空 + if ( + object.getBigDecimal("rechargePrice") == null || + object.getString("rechargeMobile") == null || + object.getInteger("productId") == null || + object.getLong("parentOrderId") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 定义子订单对象 + OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); - // 查询是否存在充值中的订单 - // 定义子订单请求map - Map childOrderMap102 = new HashMap<>(); + // 补充下单参数 + object = prepaidRechargeOrderHandle(object); - // 组装查询子订单数据 - childOrderMap102.put("parent_order_id", outRechargeOrder.getId()); - childOrderMap102.put("status", 102); - // 查询子订单 - List childOrderList102 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap102); + // 补充子订单参数 + childOrder.setParentOrderId(object.getLong("parentOrderId")); + childOrder.setRechargePlatform(object.getInteger("rechargePlatform")); + childOrder.setStatus(102); + childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo()); + childOrder.setUpdateTime(new Date()); + childOrder.setCreateTime(new Date()); - if (childOrderList102.size() > 0) { - return; + // 尖椒充值 + if (object.getInteger("rechargePlatform") == 1) { + object.put("out_order_id", childOrder.getOrderNo()); + object.put("amount", object.getBigDecimal("rechargePrice")); + object.put("mobile", object.getString("rechargeMobile")); + object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); + JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); + childOrder.setExt1(returnObject.toJSONString()); } - // 查询充值子订单列表 - // 定义子订单请求map - Map childOrderMap = new HashMap<>(); - - // 组装查询子订单数据 - childOrderMap.put("parent_order_id", outRechargeOrder.getId()); - // 查询子订单 - List childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); - - // 定义新的子订单对象 - OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); + // 龙阅 + if (object.getInteger("rechargePlatform") == 2) { - // 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停 - int platformType = 0; - - // 判断子订单是否存在充值中订单 - if (childOrderList.size() > 0) { - // 修改之前的自订单充值记录 - childOrder = childOrderList.get(0); - - // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法 - Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); - if (status == 0 || status == 3 || status == 99) { - return; - } else if (status == 1) { - completeOrder(childOrder.getOrderNo()); + if (object.getString("code") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // 修改充值记录状态 - childOrder.setStatus(103); - childOrder.setUpdateTime(new Date()); - outRechargeChildOrderService.updateOrder(childOrder); + object.put("out_trade_num", childOrder.getOrderNo()); + object.put("product_id", object.getString("code")); + object.put("mobile", object.getString("rechargeMobile")); + object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); + JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); + childOrder.setExt1(returnObject.toJSONString()); } - // 获取充值平台 - platformType = getRechargePlatformType(); + // 畅停充值 + if (object.getInteger("rechargePlatform") == 4) { - // 定义下单请求数据对象 - JSONObject object = new JSONObject(); - - // 定义新充值订单号 - String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); - - // 查询平台 - String string = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1); - String[] rechargePlatform = string.split("-"); - - // 判断平台只定义一个那么类型就是唯一 - if (string.length() == 1) { - platformType = Integer.parseInt(string); - } else { - // 如果平台充值记录暂无 则充值第一个 - if (platformType == 0) { - platformType = Integer.parseInt(rechargePlatform[0]); - } else { - // 获取上一条充值平台的下一个平台内容 - platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); + if (object.getString("code") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + object.put("orderid", childOrder.getOrderNo()); + object.put("product_id", object.getString("code")); + object.put("phone", object.getString("rechargeMobile")); + object.put("price", object.getBigDecimal("rechargePrice")); + JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object); + childOrder.setExt1(returnObject.toJSONString()); } - - // 定义查询充值产品编码 - Map map = new HashMap<>(); - map.put("type" , 1); - - for (String s : rechargePlatform) { - // 尖椒充值 - if (s.equals("1") && platformType == 1) { - object.put("out_order_id", orderNo); - object.put("amount", outRechargePrice.getRechargePrice()); - object.put("mobile", outRechargeOrder.getRechargeContent()); - object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); - JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); - object.put("return_content", returnObject); - if (returnObject.getLong("code") == 200) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } - childOrder.setRechargePlatform(1); - break; - } - // 龙阅充值 - if (s.equals("2") && platformType == 2) { - - map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , platformType); - BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); - object.put("out_trade_num", orderNo); - object.put("product_id", rechargeCode.getGoodsId()); - object.put("mobile", outRechargeOrder.getRechargeContent()); - object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); - JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); - object.put("return_content", returnObject); - if (returnObject.getLong("errno") == 0) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } - childOrder.setRechargePlatform(2); - break; - } - // 城宇充值 - if (s.equals("3") && platformType == 3) { - - map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , platformType); - BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); - object.put("agentOrderId", orderNo); - object.put("productId", rechargeCode.getGoodsId()); - object.put("mobile", outRechargeOrder.getRechargeContent()); - JSONObject returnObject = RechargeConfig.rechargeOrderByCy(object); - object.put("return_content", returnObject); - if (returnObject.getBoolean("success")) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } - childOrder.setRechargePlatform(3); - break; - } - // 畅停充值 - if (s.equals("4") && platformType == 4) { - - map.put("sourceId" , outRechargePrice.getId()); - map.put("rechargePlatform" , platformType); - 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); - } - childOrder.setRechargePlatform(4); - break; - } - } - - childOrder.setOrderNo(orderNo); - childOrder.setCreateTime(new Date()); - childOrder.setParentOrderId(outRechargeOrder.getId()); - childOrder.setUpdateTime(new Date()); outRechargeChildOrderService.insertOrder(childOrder); + } - // 判断是否充值提交成功 - if (childOrder.getStatus() == 102) { - outRechargeOrder.setRechargeStatus(201); - outRechargeOrder.setPayStatus(102); - } - - if (childOrder.getStatus() == 103) { - outRechargeOrder.setRechargeStatus(205); - outRechargeOrder.setPayStatus(102); + @Override + public void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder) throws Exception { + + // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 + int orderStatus = orderWhetherRecharge(outRechargeOrder); + + if (orderStatus == 1) { + getPrepaidRechargeApi(outRechargeOrder); + } + if (orderStatus == 2) { + refundOrder(outRechargeOrder.getId()); + } + if (orderStatus == 4) { + HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); + highOrder.setExceptionStatus(true); + highOrder.setExceptionContent("话费订单存在多条重复记录"); + highOrderService.updateOrder(highOrder); + } + if (orderStatus == 5) { + completeOrder(outRechargeOrder.getOrderNo()); } - outRechargeOrderService.updateOrder(outRechargeOrder); } @Override @@ -831,8 +528,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Override - public void editOutRechargeOrder(HighOrder orderData) { - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderData.getOrderNo()); + public void editOutRechargeOrder(HighOrder orderData , OutRechargeOrder outRechargeOrder) { // 201:充值中 202:充值成功 203:充值失败 204:未充值 outRechargeOrder.setRechargeStatus(201); @@ -855,43 +551,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } @Override - public void rechargeOrderHandle(String orderNo) throws Exception { - - // 定义话费充值业务订单模型 or 充值记录订单模型 - OutRechargeOrder outRechargeOrder = findByOrderNo(orderNo); - OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); - - // 状态需要支付状态为已充值 并且 充值状态不为 充值成功 - if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { - - // 判断充值记录是否存在 - if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) { - - // - OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder(); - outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); - outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId()); - outRechargeChildOrder.setUpdateTime(new Date()); - outRechargeChildOrder.setCreateTime(new Date()); - outRechargeChildOrderService.insertOrder(outRechargeChildOrder); - // 话费退款 - refundOrder(outRechargeOrder.getId() , outRechargeChildOrder); - } else { - // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 - Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder); - if (status == 2 || status == -1) { - refundOrder(outRechargeOrder.getId() , childOrder); - } else if (status == 1) { - completeOrder(childOrder.getOrderNo()); - } - } - - } - } - + public Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) throws Exception { - @Override - public Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception { JSONObject object = new JSONObject(); // 龙阅 if (childOrder.getRechargePlatform() == 2) { @@ -953,12 +614,175 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return 99; } + // 获取当前最新的充值平台 private Integer getRechargePlatformType() { OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc(); if (outRechargeChildOrder != null) { return outRechargeChildOrder.getRechargePlatform(); } - return 0; + return null; + } + + /** + * @Author Sum1Dream + * @Name prepaidRechargeOrderHandle + * @Description // 充值订单下单数据操作 + * @Date 18:54 2023/3/28 + * @Param [object] + * @Return com.alibaba.fastjson.JSONObject + */ + private JSONObject prepaidRechargeOrderHandle(JSONObject object) { + + if (object.getLong("productId") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品编码为空"); + } + + // 查询充值产品 + OutRechargePrice outRechargePrice = outRechargePriceService.findByGoodsId(object.getLong("productId")); + + if (outRechargePrice == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知产品编码"); + } + + // 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停 + Integer platformType = getRechargePlatformType(); + + // 截取可平台字符串 + String rechargePlatformString = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1); + String[] rechargePlatform = rechargePlatformString.split("-"); + + if (rechargePlatform.length == 1) { + platformType = Integer.parseInt(rechargePlatformString); + } + if (rechargePlatform.length > 1) { + // 如果平台充值记录暂无 则充值第一个 + if (platformType == null) { + platformType = Integer.parseInt(rechargePlatform[0]); + } else { + // 获取上一条充值平台的下一个平台内容 + platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]); + } + } + + Map rechargeCodeMap = new HashMap<>(); + + rechargeCodeMap.put("sourceId" , outRechargePrice.getId()); + rechargeCodeMap.put("rechargePlatform" , platformType); + BsRechargeCode rechargeCode = rechargeCodeService.findByMap(rechargeCodeMap); + + object.put("code" , rechargeCode.getGoodsId()); + object.put("rechargePlatform" , platformType); + + return object; + + } + + /** + * @Author Sum1Dream + * @Name orderWhetherRecharge + * @Description // 订单是否可以充值 + * @Date 16:11 2023/3/28 + * @Param [childOrder] + * @Return java.lang.Integer 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 + */ + private Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder) throws Exception { + + // 查询子订单 + List childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId()); + + + // 充值订单充值时间 + Date rechargeTime = rechargeOrder.getCreateTimed(); + Date currentTime = new Date(); + int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); + + // 判断订单是否存在充值完成订单 + Map childMap = new HashMap<>(); + childMap.put("parent_order_id", rechargeOrder.getId()); + childMap.put("status", 101); + List childOrders101 = outRechargeChildOrderService.getListRechargeChildOrder(childMap); + + // 判断充值成功是否存在多个 存在返回异常 + if (childOrders101.size() > 1) { + return 4; + } + // 判断是否存在充值成功的订单 + if (childOrders101.size() == 1) { + return 5; + } + + // 查询充值中的订单 + childMap.put("status", 102); + List childOrders102 = outRechargeChildOrderService.getListRechargeChildOrder(childMap); + + + // 充值中的订单存在多个 返回异常 + if (childOrders102.size() > 1) { + return 4; + } + // 只存在一个充值中的订单需要查询当前充值中的订单状态 + if (childOrders102.size() == 1) { + + // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 + Integer status = getRechargeOrderLegality(childOrders102.get(0)); + if (status == 2 || status == -1) { + // 修改充值订单状态 + rechargeChildOrderHandle(childOrders102.get(0) , 103); + // 如果订单记录超过5条退款 反之继续充值 + if (childOrderList.size() > 4) { + return 2; + } else { + // 如果订单记录超过71小时 反之继续充值 + return hours > 71 ? 2 : 1; + } + } + // 充值订单为充值成功 + if (status == 1) { + // 修改充值订单状态 + rechargeChildOrderHandle(childOrders102.get(0) , 101); + return 5; + } + + } + + // 没有充值中的订单 查询所有订单中最新的一条订单状态 + if (childOrders102.size() == 0) { + // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 + Integer status = getRechargeOrderLegality(childOrderList.get(0)); + if (status == 2 || status == -1) { + // 修改充值订单状态 + rechargeChildOrderHandle(childOrderList.get(0) , 103); + // 如果订单记录超过5条退款 反之继续充值 + if (childOrderList.size() > 4) { + return 2; + } else { + // 如果订单记录超过71小时 反之继续充值 + return hours > 71 ? 2 : 1; + } + + } + if (status == 1) { + // 修改充值订单状态 + rechargeChildOrderHandle(childOrderList.get(0) , 101); + return 5; + } + + } + return 3; + } + + /** + * @Author Sum1Dream + * @Name rechargeChildOrderHandle + * @Description // 处理子订单 + * @Date 18:50 2023/3/28 + * @Param [rechargeChildOrder] + * @Return void + */ + private void rechargeChildOrderHandle(OutRechargeChildOrder rechargeChildOrder , Integer status) { + rechargeChildOrder.setUpdateTime(new Date()); + rechargeChildOrder.setStatus(status); + outRechargeChildOrderService.updateOrder(rechargeChildOrder); } } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java deleted file mode 100644 index 084dd710..00000000 --- a/hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.hai.service.pay.impl; - -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.common.pay.util.XmlUtil; -import com.hai.common.pay.util.sdk.WXPayConstants; -import com.hai.common.utils.WxUtils; -import com.hai.config.CommonSysConst; -import com.hai.dao.HighGasOrderPushMapper; -import com.hai.entity.*; -import com.hai.enum_type.OrderPushType; -import com.hai.model.ResultProfitSharing; -import com.hai.service.*; -import com.hai.service.pay.PayService; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContexts; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import javax.net.ssl.SSLContext; -import java.io.FileInputStream; -import java.math.BigDecimal; -import java.security.KeyStore; -import java.util.*; - -/** - * @Auther: 胡锐 - * @Description: - * @Date: 2021/3/27 00:35 - */ -@Service("rechargeOrderService") -public class RechargeOrderServiceImpl implements PayService { - - private static Logger log = LoggerFactory.getLogger(RechargeOrderServiceImpl.class); - - @Resource - private OutRechargeOrderService outRechargeOrderService; - - @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; - - - - // todo 当前接口已经废弃 - @Override - public void paySuccess(Map map, String payType) throws Exception { - - if (payType.equals("Alipay")) { - // 支付宝支付 todo 暂未开发 - return; - } - if (payType.equals("WechatPay")) { - // 查询订单信息 - OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no")); - // 推送订单记录 - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type2.getType()); - highGasOrderPush.setOrderNo(order.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setRequestContent(order.getOrderNo()); - highGasOrderPush.setReturnContent(String.valueOf(map)); - highGasOrderPushMapper.insert(highGasOrderPush); - if (order.getPayStatus() == 101) { - order.setPaySerialNo(map.get("transaction_id")); // 支付流水号 - order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额 - order.setPayTime(new Date()); // 支付时间 - // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - order.setPayStatus(102); - order.setRechargeStatus(204); - order.setPayType(2); - outRechargeOrderService.updateOrder(order); -// if (order.getRechargeType() == 1) { -// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType()); -// if (object.getInteger("code") != 200) { -// order.setRechargeStatus(1); -// order.setAbnormalMsg(object.getString("message")); -// } -// } - outRechargeOrderService.pollRequest(order); - - } - } - } - -} diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java index 84a30ef7..b4015acf 100644 --- a/v1/src/main/java/com/v1/controller/WxMsgController.java +++ b/v1/src/main/java/com/v1/controller/WxMsgController.java @@ -181,32 +181,43 @@ public class WxMsgController { // 4:支付码牌扫码 if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){ // 支付码码牌上的二维码 - if (Objects.equals(object.getString("codeTyp"), "PAYMENT_CODE")) { + if (Objects.equals(object.getString("codeType"), "PAYMENT_CODE")) { linkContent = - "支付分享,享受更高优惠[礼物]\n\n" - + "\n\n"; + + "'>立即领取优惠券\n\n"; } // 支付成功生成的二维码 - if (Objects.equals(object.getString("codeTyp"), "PAYMENT_SUCCESS")) { + if (Objects.equals(object.getString("codeType"), "PAYMENT_SUCCESS")) { linkContent = "支付分享,享受更高优惠[礼物]\n\n" + "分享好友\n\n"; + } + // 扫码分享二维码进入 + if (Objects.equals(object.getString("codeType"), "SHARE")) { + linkContent = + "支付分享,享受更高优惠[礼物]\n\n" + + "分享好友\n\n"; } } + // 5:扫码贵州中石化优惠券二维码 if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){ mapQrCode.put("type", object.getString("encryptType")); @@ -248,6 +259,7 @@ public class WxMsgController { linkContent = "点击查看更多优惠\n\n"; } + System.out.println("===================" + linkContent); // 判断是否是新用户 // if (user == null) { diff --git a/v1/src/main/java/com/v1/controller/orderController.java b/v1/src/main/java/com/v1/controller/orderController.java index dddf518b..038c6f09 100644 --- a/v1/src/main/java/com/v1/controller/orderController.java +++ b/v1/src/main/java/com/v1/controller/orderController.java @@ -5,11 +5,14 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.WxOrderConfig; import com.hai.entity.ApiMerchants; import com.hai.entity.ApiOrder; import com.hai.entity.ApiProductConfig; +import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.openApi.service.ApiOrderService; +import com.hai.order.model.RefundPriceModel; import com.hai.order.type.OrderProductType; import com.hai.service.*; import com.v1.config.ToolConfig; @@ -26,6 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.sound.midi.Soundbank; import java.util.HashMap; import java.util.Map; @@ -259,4 +263,68 @@ public class orderController { } } + @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "对外订单退款接口") + public ResponseData externalOrderRefund(@RequestBody JSONObject object , HttpServletRequest request) { + try { + + System.out.println(object); + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if ( + StringUtils.isBlank(object.getString("apiKey")) || + StringUtils.isBlank(object.getString("paySerialNo")) || + StringUtils.isBlank(object.getString("wxMchId")) || + StringUtils.isBlank(object.getString("refundPrice")) || + StringUtils.isBlank(object.getString("payRealPrice")) || + StringUtils.isBlank(object.getString("sign")) || + StringUtils.isBlank(object.getString("merchId")) + ) { + log.error("createOrder error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "帐户错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + Map map = new HashMap<>(); + map.put("paySerialNo" , object.getString("paySerialNo")); + map.put("wxMchId" , object.getString("wxMchId")); + map.put("payRealPrice" , object.getString("payRealPrice")); + map.put("refundPrice" , object.getString("refundPrice")); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + + if (!secConfigService.isSignVerify(map, object.getString("sign"))) { + log.error("createOrder error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + return ResponseMsgUtil.success(WxOrderConfig.orderToRefund(object.getString("paySerialNo"),object.getBigDecimal("payRealPrice"), object.getString("wxMchId"), object.getBigDecimal("refundPrice"))); + + } catch (Exception e) { + log.error("HighOpenApiController --> createOrder() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + }