diff --git a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java index c0f52b98..955e8f7f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/Goods/GoodsDetailController.java @@ -1,6 +1,7 @@ package com.bweb.controller.Goods; +import com.alibaba.fastjson.JSONArray; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -12,10 +13,12 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.GoodsDetail; +import com.hai.entity.GoodsLogistics; import com.hai.entity.HighApprove; import com.hai.entity.HighGoodsType; import com.hai.enum_type.ApproveType; import com.hai.goods.service.GoodsDetailService; +import com.hai.goods.service.GoodsLogisticsService; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.HighApproveService; @@ -54,6 +57,9 @@ public class GoodsDetailController { @Autowired private UserCenter userCenter; + @Resource + private GoodsLogisticsService logisticsService; + @RequestMapping(value = "/getListGoodsDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询商品列表") @@ -162,6 +168,8 @@ public class GoodsDetailController { goodsDetail.setStatus(goods.getStatus()); goodsDetail.setCreateTime(goods.getCreateTime()); + goodsDetail.setOpName(goods.getOpName()); + goodsDetail.setOpId(goods.getOpId()); goodsDetail.setUpdateTime(new Date()); goodsDetail.setGoodsTypeName(goodsType.getTitle()); goodsDetail.setCompanyId(userInfoModel.getBsCompany().getId()); @@ -280,8 +288,6 @@ public class GoodsDetailController { goodsDetail.setStatus(goodsDetail.getStatus() == 1 ? 2:3); goodsDetail.setUpdateTime(new Date()); - goodsDetail.setOpId(userInfoModel.getSecUser().getId()); - goodsDetail.setOpName(userInfoModel.getSecUser().getLoginName()); goodsDetailService.updateGoodsDetail(goodsDetail); return ResponseMsgUtil.success("操作成功!"); @@ -291,5 +297,22 @@ public class GoodsDetailController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据快递单号查询物流信息") + public ResponseData getLogisticsMsg(@RequestParam(name = "orderId", required = false) Long orderId) { + try { + + GoodsLogistics logistics = (GoodsLogistics) logisticsService.getLogisticsMsg(orderId); + JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); + return ResponseMsgUtil.success(object); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.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 adfc7192..9c8925c0 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.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.data.redis.core.RedisTemplate; 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 BsOrderRebateService bsOrderRebateService; @Resource private CommonService commonService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Autowired private RedisTemplate redisTemplate; @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" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); mapPost.put("merchId" , "20220896102"); Map map = new HashMap<>(); map.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); map.put("merchId" , "20220896102"); 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/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 = "/getRegional", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询区域信息") public ResponseData getRegional() { try { return ResponseMsgUtil.success(commonService.getRegional("code" , "name" , "childs")); } 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"); 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 = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, "工会卡充值退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); return ResponseMsgUtil.success("退款成功"); } 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 = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); 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); } } 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); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test() { try { JSONObject object = new JSONObject(); object.put("productType" , 101); object.put("phone" , "17726395120"); object.put("orderNo" , "ZF1130202305041640363988083900"); object.put("orderId" , 792 ); object.put("title" , "惠付门店"); object.put("createTime" , new Date()); object.put("price" , 1); bsOrderRebateService.insertOrderRebate(object); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.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.data.redis.core.RedisTemplate; 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 BsOrderRebateService bsOrderRebateService; @Resource private CommonService commonService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); mapPost.put("merchId" , "20220896102"); Map map = new HashMap<>(); map.put("apiKey" , "4B1DF80A2D64376D2807ACA6CFEDE8AA"); map.put("merchId" , "20220896102"); 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/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 = "/getRegional", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询区域信息") public ResponseData getRegional() { try { return ResponseMsgUtil.success(commonService.getRegional("code" , "name" , "childs")); } 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"); 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 = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, "工会卡充值退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); return ResponseMsgUtil.success("退款成功"); } 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 = false) String createTimeS, @RequestParam(name = "createTimeE", required = false) String createTimeE, @RequestParam(name = "refundTimeS", required = false) String refundTimeS, @RequestParam(name = "refundTimeE", required = false) String refundTimeE ) { try { Map map = new HashMap<>(); map.put("productType" , 9); map.put("createTimeS" , createTimeS); map.put("createTimeE" , createTimeE); map.put("refundTimeS" , refundTimeS); map.put("refundTimeE" , refundTimeE); 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); } } 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); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test() { try { JSONObject object = new JSONObject(); object.put("productType" , 101); object.put("phone" , "17726395120"); object.put("orderNo" , "ZF1130202305041640363988083900"); object.put("orderId" , 792 ); object.put("title" , "惠付门店"); object.put("createTime" , new Date()); object.put("price" , 1); bsOrderRebateService.insertOrderRebate(object); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file 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 a1fe6f31..41485c9d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -263,7 +263,7 @@ public class CommonController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位"); } - JSONObject object = commonService.findByLatAndLng(lng, lat).getJSONObject("result").getJSONObject("addressComponent"); + JSONObject object = jsonObjectR.getJSONObject("result").getJSONObject("addressComponent"); ApiCity apiCity = commonService.findCityByName(object.getString("city")); @@ -296,6 +296,46 @@ public class CommonController { } } + @RequestMapping(value = "/baiduApiMapSearch", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取定位信息") + public ResponseData baiduApiMapSearch( + @RequestParam(name = "lng", required = true) String lng, + @RequestParam(name = "lat", required = true) String lat, + @RequestParam(name = "query", required = false) String query) { + try { + + + if (query == null) { + JSONObject map = commonService.findByLatAndLng(lng, lat); + if (!map.getString("status").equals("0")) { + log.error("findByLatAndLng error!", "定位错误,请重新定位"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位"); + } + query = map.getJSONObject("result").getString("formatted_address"); + } + + Map map = new HashMap<>(); + + map.put("query" , query); + map.put("location", lat+","+lng); + + JSONObject jsonObjectR = commonService.baiduApiMapSearch(map); + + if (!jsonObjectR.getString("status").equals("0")) { + log.error("findByLatAndLng error!", "定位错误,请重新定位"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位"); + } + + + return ResponseMsgUtil.success(jsonObjectR.getJSONArray("results")); + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取定位信息") @@ -442,4 +482,26 @@ public class CommonController { } } + @RequestMapping(value = "/gaoDeApiMapSearch", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取定位信息") + public ResponseData gaoDeApiMapSearch( + @RequestParam(name = "query", required = false) String query) { + try { + + Map map = new HashMap<>(); + + map.put("keywords" , query); + map.put("extensions" , "all"); + + JSONObject jsonObject = commonService.gaoDeApiMapSearch(map); + + return ResponseMsgUtil.success(jsonObject.getJSONArray("tips")); + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java index 417c6be0..3f8eb9df 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/Goods/GoodsController.java @@ -210,10 +210,10 @@ public class GoodsController { @RequestMapping(value = "/getLogisticsMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据快递单号查询物流信息") - public ResponseData getLogisticsMsg(@RequestParam(name = "num", required = true) String num) { + public ResponseData getLogisticsMsg(@RequestParam(name = "orderId", required = false) Long orderId) { try { - return ResponseMsgUtil.success(logisticsService.getLogisticsMsg(num)); + return ResponseMsgUtil.success(logisticsService.getLogisticsMsg(orderId)); } catch (Exception e) { log.error("HighOrderController --> getUserOrderList() error!", e); @@ -222,7 +222,5 @@ public class GoodsController { } - - } diff --git a/hai-order/src/main/java/com/web/controller/OrderController.java b/hai-order/src/main/java/com/web/controller/OrderController.java index 86510ba1..3a168099 100644 --- a/hai-order/src/main/java/com/web/controller/OrderController.java +++ b/hai-order/src/main/java/com/web/controller/OrderController.java @@ -11,12 +11,14 @@ import com.hai.common.utils.BaiduUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.goods.service.DeliveryAddressService; +import com.hai.goods.service.GoodsLogisticsService; import com.hai.goods.service.GoodsOrderExtService; import com.hai.model.GoodsOrderModel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderModel; +import com.hai.order.model.GoodsChildOrderExtModel; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildGoodsType; @@ -37,7 +39,9 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -59,6 +63,9 @@ public class OrderController { @Resource private DeliveryAddressService deliveryAddressService; + @Resource + private GoodsLogisticsService goodsLogisticsService; + @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") @@ -177,6 +184,21 @@ public class OrderController { HighOrder highOrder = orderService.getOrderDetailByNo(orderNo); if (highOrder.getProductType() == 12) { + + + // todo 临时代码 + + for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { + + GoodsLogistics logistics = goodsLogisticsService.findGoodsLogistics(childOrder.getId()); + if (logistics != null) { + childOrder.setExt6(logistics.getLogisticsStatusDesc()); + childOrder.setExt4(logistics.getNumber()); + } + + } + + GoodsOrder order = goodsOrderExtService.findGoodsOrder(highOrder.getOrderNo()); GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(order.getDeliveryAddressId()); @@ -184,6 +206,8 @@ public class OrderController { BeanUtils.copyProperties(highOrder , goodsOrderModel); goodsOrderModel.setGoodsOrder(order); goodsOrderModel.setGoodsDeliveryAddress(deliveryAddress); + + return ResponseMsgUtil.success(goodsOrderModel); } diff --git a/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java b/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java index e83fe3ed..602c522c 100644 --- a/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java +++ b/hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java @@ -11,16 +11,20 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.PageUtil; +import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonConfig; import com.hai.entity.*; import com.hai.enum_type.UserObjectTypeEnum; import com.hai.goods.model.GoodsModel; +import com.hai.goods.service.DeliveryAddressService; import com.hai.goods.service.GoodsLogisticsService; import com.hai.goods.service.GoodsOrderExtService; import com.hai.goods.service.GoodsSkuService; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.order.model.ExportOrderMobileModel; +import com.hai.order.model.GoodsChildOrderExtModel; import com.hai.order.model.GoodsOrderExtModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; @@ -66,6 +70,12 @@ public class GoodsOrderController { @Resource private GoodsLogisticsService goodsLogisticsService; + @Resource + private DeliveryAddressService deliveryAddressService; + + @Resource + private RedisUtil redisUtil; + @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单列表") @@ -195,4 +205,94 @@ public class GoodsOrderController { return ResponseMsgUtil.exception(e); } } + + + @RequestMapping(value = "/getOrderChildList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询子订单列表") + public ResponseData getOrderChildList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "childOrderNo", required = false) String childOrderNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + Map map = new HashMap<>(); + + map.put("createTimeS", createTimeS); + map.put("createTimeE", createTimeE); + map.put("orderNo", orderNo); + map.put("secUserId", userInfoModel.getSecUser().getId()); + map.put("childOrderNo", childOrderNo); + map.put("memPhone", memPhone); + map.put("status", status); + + + List list = orderService.getChildOrderList(map); + + List goodsChildOrderExtModels = new ArrayList<>(); + + GoodsChildOrderExtModel model; + + for (HighChildOrder order : list) { + model = new GoodsChildOrderExtModel(); + BeanUtils.copyProperties(order, model); + GoodsLogistics logistics = goodsLogisticsService.findGoodsLogistics(order.getId()); + if (logistics != null) { + model.setLogisticsStatus(logistics.getLogisticsStatusDesc()); + model.setLogisticsNo(logistics.getNumber()); + } + GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(order.getOrderNo()); + GoodsDeliveryAddress deliveryAddress = deliveryAddressService.findDeliveryAddressById(goodsOrder.getDeliveryAddressId()); + model.setDeliveryAddressMsg(goodsOrder.getDeliveryAddress() + "-" + deliveryAddress.getConsignee() + " " + deliveryAddress.getPhone()); + goodsChildOrderExtModels.add(model); + } + + return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsChildOrderExtModels.size(), pageSize, new PageInfo<>(goodsChildOrderExtModels))); + + } catch (Exception e) { + log.error("OrderCouponController --> getOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/editLogisticsNo", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "录入运单号") + public ResponseData editLogisticsNo(@RequestParam(name = "orderId", required = false) Long orderId, + @RequestParam(name = "logisticsNo", required = false) String logisticsNo + ) { + try { + + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + + JSONObject jsonObjects = CommonConfig.getLogisticsMsg(logisticsNo); + + jsonObjects.getJSONObject("data").put("orderId" , orderId); + + GoodsLogistics logistics = goodsLogisticsService.editLogistics(jsonObjects.getJSONObject("data")); + + redisUtil.set("logisticsMsg" + orderId , logistics ,21600); + + return ResponseMsgUtil.success("录入成功"); + + } catch (Exception e) { + log.error("OrderCouponController --> getOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + } 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 75f2b376..f1a51dce 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 @@ -7,6 +7,7 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; +import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighOrder; import com.hai.entity.OutRechargeChildOrder; @@ -21,6 +22,7 @@ import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderStatus; import com.hai.order.type.RechargePlatformType; +import com.hai.service.HighOrderService; import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeOrderService; import com.hai.service.impl.OutRechargeOrderServiceImpl; @@ -29,6 +31,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -38,10 +42,8 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.TimeUnit; @Controller @RequestMapping(value = "mobileRecharge") @@ -57,12 +59,19 @@ public class OrderMobileRechargeController { private OutRechargeOrderService outRechargeOrderService; @Resource - private OutRechargeChildOrderService outRechargeChildOrderService; + private OrderService orderService; + + @Resource + private HighOrderService highOrderService; + @Autowired + private RedisTemplate redisTemplate; @Resource - private OrderService orderService; + private RedisUtil redisUtil; + @Resource + private OutRechargeChildOrderService outRechargeChildOrderService; @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) @ResponseBody @@ -71,6 +80,7 @@ public class OrderMobileRechargeController { @RequestParam(name = "memPhone", required = false) String memPhone, @RequestParam(name = "memCardNo", required = false) String memCardNo, @RequestParam(name = "title", required = false) String title, + @RequestParam(name = "exceptionStatus", required = false) Boolean exceptionStatus, @RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "orderStatus", required = false) Integer orderStatus, @RequestParam(name = "companyId", required = false) Long companyId, @@ -80,8 +90,8 @@ public class OrderMobileRechargeController { @RequestParam(name = "payTimeE", required = false) Long payTimeE, @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, @RequestParam(name = "finishTimeE", required = false) Long finishTimeE, - @RequestParam(name = "refundTimeS", required = false) String refundTimeS, - @RequestParam(name = "refundTimeE", required = false) String refundTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { @@ -99,6 +109,8 @@ public class OrderMobileRechargeController { } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); } + + map.put("exceptionStatus", exceptionStatus); map.put("createTimeS", createTimeS); map.put("createTimeE", createTimeE); map.put("payTimeS", payTimeS); @@ -129,10 +141,12 @@ public class OrderMobileRechargeController { @ApiOperation(value = "导出话费订单列表") public ResponseData exportMobilePartyOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "serialNumber", required = false) String serialNumber, @RequestParam(name = "memCardNo", required = false) String memCardNo, @RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "orderStatus", required = false) Integer orderStatus, @RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "exceptionStatus", required = false) Boolean exceptionStatus, @RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "title", required = false) String title, @RequestParam(name = "createTimeE", required = false) Long createTimeE, @@ -142,6 +156,7 @@ public class OrderMobileRechargeController { @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, @RequestParam(name = "refundTimeE", required = false) Long refundTimeE, @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, + @RequestParam(name = "finishTimeE", required = false) Long finishTimeE) { try { @@ -159,6 +174,7 @@ public class OrderMobileRechargeController { } map.put("createTimeS", createTimeS); map.put("createTimeE", createTimeE); + map.put("exceptionStatus", exceptionStatus); map.put("payTimeS", payTimeS); map.put("payTimeE", payTimeE); map.put("finishTimeS", finishTimeS); @@ -178,8 +194,20 @@ public class OrderMobileRechargeController { List list = new ArrayList<>(); + // 配置初始化处理条数 + int i = 0; + int percent; + ExportOrderMobileModel model; for (HighOrder highOrder : order) { + + i++; + + // 生成百分比 + percent = i*100/order.size(); + + redisUtil.set(serialNumber , percent , 3600); + model = new ExportOrderMobileModel(); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNoNotChild(highOrder.getOrderNo()); @@ -226,6 +254,8 @@ public class OrderMobileRechargeController { .head(ExportOrderMobileModel.class) .sheet("话费交易订单") .doWrite(list); + + redisUtil.set(serialNumber + "download" , pathName , 600); return ResponseMsgUtil.success(pathName); } catch (Exception e) { @@ -240,7 +270,7 @@ public class OrderMobileRechargeController { public ResponseData getMobileOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Map map = new HashMap<>(); - map.put("tradeOrder", orderService.getOrderDetailByNo(orderNo)); + map.put("tradeOrder", orderService.getOrderDetail(orderNo)); map.put("mobileOrder", outRechargeOrderService.findByOrderNo(orderNo)); return ResponseMsgUtil.success(map); @@ -250,4 +280,82 @@ public class OrderMobileRechargeController { } } + @RequestMapping(value="/refundOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "订单退款") + public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { + + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); + + String key = "recharge_" + outRechargeOrder.getId(); + try { + + // 分布式锁占坑 + Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, outRechargeOrder.getOrderNo()); + + if(Boolean.TRUE.equals(lock)) { + // 加锁成功,处理业务 + // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单存在多个充值订单 5:订单充值完成 6:充值订单号未查询到任何充值记录 + int orderStatus = outRechargeOrderService.orderWhetherRecharge(outRechargeOrder); + if (orderStatus == 2) { + outRechargeOrderService.refundOrder(outRechargeOrder.getId()); + } + if (orderStatus == 6) { + outRechargeOrderService.refundOrder(outRechargeOrder.getId()); + } + } else { + // 加锁失败,重试 + Thread.sleep(100); + refundOrder(orderNo); + } + + + + HighOrder order = highOrderService.getOrderByOrderNo(orderNo); + order.setExceptionStatus(false); + highOrderService.updateOrder(order); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("OrderExtController -> getGasOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } finally { + // 删除key,释放锁 + redisTemplate.delete(key); + } + } + + @RequestMapping(value="/orderNormal",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "订单修改正常") + public ResponseData orderNormal(@RequestParam(name = "orderNo", required = true) String orderNo) { + + + try { + + OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); + + List rechargeChildOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId()); + + for (OutRechargeChildOrder rechargeChildOrder : rechargeChildOrderList) { + if (rechargeChildOrder.getStatus() == 104) { + rechargeChildOrder.setStatus(102); + } + outRechargeChildOrderService.updateOrder(rechargeChildOrder); + } + + HighOrder order = highOrderService.getOrderByOrderNo(orderNo); + order.setExceptionStatus(false); + highOrderService.updateOrder(order); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("OrderExtController -> getGasOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderMobileRechargeConsumer.java b/hai-order/src/main/java/com/web/rocketmq/consumer/OrderMobileRechargeConsumer.java deleted file mode 100644 index 4a9a8f27..00000000 --- a/hai-order/src/main/java/com/web/rocketmq/consumer/OrderMobileRechargeConsumer.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.web.rocketmq.consumer; - -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.config.CommonSysConst; -import com.hai.config.RechargeConfig; -import com.hai.entity.OutRechargeChildOrder; -import com.hai.entity.OutRechargeOrder; -import com.hai.service.OutRechargeChildOrderService; -import com.hai.service.OutRechargeOrderService; -import lombok.extern.slf4j.Slf4j; -import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; -import org.apache.rocketmq.spring.core.RocketMQListener; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Date; - -@Component -@Slf4j -@RocketMQMessageListener(consumerGroup = "order-mobile-recharge-group", topic = "order-topic",selectorExpression = "mobile-recharge") -public class OrderMobileRechargeConsumer implements RocketMQListener { - - @Resource - private OutRechargeOrderService outRechargeOrderService; - - @Resource - private OutRechargeChildOrderService outRechargeChildOrderService; - - @Override - public void onMessage(OutRechargeChildOrder childOrder) { - - JSONObject object = new JSONObject(); - - OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - - object.put("rechargePrice" , outRechargeOrder.getRechargePrice()); - object.put("rechargeMobile" , outRechargeOrder.getRechargeContent()); - object.put("productId" , outRechargeOrder.getGoodsId()); - object.put("parentOrderId" , outRechargeOrder.getId()); - - // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 - Integer status = outRechargeOrderService.getRechargeOrderLegality(childOrder); - - if (status == 2 || status == -1) { - // 补充下单参数 - object = outRechargeOrderService.prepaidRechargeOrderHandle(object); - - // 尖椒充值 - 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()); - } - - // 龙阅 - if (object.getInteger("rechargePlatform") == 2) { - - if (object.getString("code") == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - 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()); - } - - // 畅停充值 - if (object.getInteger("rechargePlatform") == 4) { - - 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()); - } - - - System.out.println("消费内容:" + childOrder); - - childOrder.setUpdateTime(new Date()); - outRechargeChildOrderService.updateOrder(childOrder); - } - - } -} 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 2e309e0c..82a8f998 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java @@ -50,7 +50,7 @@ public class HighRechargeOrderSchedule { * @Date 14:18 2022/5/31 * @Param [] */ - @Scheduled(cron = "0 0/60 * * * ?") //每120分钟执行一次 + @Scheduled(cron = "0 0/60 * * * ?") //每60分钟执行一次 public void initRechargeOrder() { log.info("处理话费订单定时任务开始"); Map map = new HashMap<>(); 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 716b50c4..b63b44d3 100644 --- a/hai-service/src/main/java/com/hai/config/RechargeConfig.java +++ b/hai-service/src/main/java/com/hai/config/RechargeConfig.java @@ -100,7 +100,7 @@ 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("发起龙阅订单查询="); + log.info("发起龙阅订单查询"); log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap)); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); diff --git a/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java b/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java index 50bf4303..00382ce2 100644 --- a/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java +++ b/hai-service/src/main/java/com/hai/goods/service/GoodsLogisticsService.java @@ -55,6 +55,16 @@ public interface GoodsLogisticsService { */ GoodsLogistics findGoodsLogisticsById(Long id); + /** + * @Author Sum1Dream + * @Name findGoodsLogisticsById + * @Description // 根据id查询物流信息 + * @Date 16:19 2023/4/11 + * @Param [id] + * @Return com.hai.entity.GoodsLogistics + */ + GoodsLogistics findGoodsLogistics(Long orderId); + /** * @Author Sum1Dream * @Name findGoodsLogisticsByNum @@ -84,4 +94,16 @@ public interface GoodsLogisticsService { * @Return com.alibaba.fastjson.JSONObject */ Object getLogisticsMsg(String num); + + /** + * @Author Sum1Dream + * @Name getLogisticsMsg + * @Description // 查询物流信息 + * @Date 16:19 2023/4/20 + * @Param [num] + * @Return com.alibaba.fastjson.JSONObject + */ + Object getLogisticsMsg(Long orderId); + + } diff --git a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java index 2c8286e3..c2bea46d 100644 --- a/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/goods/service/impl/GoodsLogisticsServiceImpl.java @@ -1,6 +1,9 @@ package com.hai.goods.service.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.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonConfig; @@ -50,6 +53,22 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { return goodsLogisticsMapper.selectByPrimaryKey(id); } + @Override + public GoodsLogistics findGoodsLogistics(Long orderId) { + GoodsLogisticsExample example = new GoodsLogisticsExample(); + GoodsLogisticsExample.Criteria criteria = example.createCriteria(); + + criteria.andOrderIdEqualTo(orderId).andStatusEqualTo(1); + + List logistics = goodsLogisticsMapper.selectByExample(example); + + if (logistics.size() > 0) { + return logistics.get(0); + } + + return null; + } + @Override public GoodsLogistics findGoodsLogisticsByNum(String num) { GoodsLogisticsExample example = new GoodsLogisticsExample(); @@ -78,6 +97,7 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { } logistics.setTaskNo(jsonObject.getString("orderNo")); + logistics.setTheLastTime(info.getDate("theLastTime")); logistics.setTheLastMessage(info.getString("theLastMessage")); logistics.setTakeTime(info.getString("takeTime")); @@ -87,11 +107,12 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { logistics.setLogisticsStatusDesc(info.getString("logisticsStatusDesc")); logistics.setLogisticsTraceDetails(info.getString("logisticsTraceDetailList")); logistics.setStatus(1); - - if ( logistics.getId() == null) { + if ( logistics.getId() == null || !Objects.equals(logistics.getOrderId(), jsonObject.getLong("orderId"))) { + logistics.setOrderId(jsonObject.getLong("orderId")); logistics.setCreateTime(new Date()); insertGoodsLogistics(logistics); } else { + logistics.setOrderId(jsonObject.getLong("orderId")); updateGoodsLogistics(logistics); } @@ -133,4 +154,35 @@ public class GoodsLogisticsServiceImpl implements GoodsLogisticsService { return data; } } + + @Override + public Object getLogisticsMsg(Long orderId) { + Object data = redisUtil.get("logisticsMsg" + orderId); + if (data == null) { + + GoodsLogistics goodsLogistics = findGoodsLogistics(orderId); + + if (goodsLogistics == null || goodsLogistics.getNumber() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未发货!"); + } + + JSONObject jsonObjects = CommonConfig.getLogisticsMsg(goodsLogistics.getNumber()); + redisUtil.set("logisticsMsgOl" + orderId , jsonObjects ,21600); + if (jsonObjects.getInteger("code") == 200 && jsonObjects.getBoolean("success")) { + + jsonObjects.getJSONObject("data").put("orderId" , orderId); + + GoodsLogistics logistics = editLogistics((JSONObject) jsonObjects.get("data")); + + redisUtil.set("logisticsMsg" + orderId , logistics ,21600); + + return logistics; + } + + return jsonObjects; + + } else { + return data; + } + } } diff --git a/hai-service/src/main/java/com/hai/mobile/service/MobileHandleService.java b/hai-service/src/main/java/com/hai/mobile/service/MobileHandleService.java new file mode 100644 index 00000000..f17d57ed --- /dev/null +++ b/hai-service/src/main/java/com/hai/mobile/service/MobileHandleService.java @@ -0,0 +1,14 @@ +package com.hai.mobile.service; + +/** + * @serviceName MobileHandleService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 话费业务处理 + * @createTime 11:09 2023/5/17 + **/ +public interface MobileHandleService { + + + +} diff --git a/hai-service/src/main/java/com/hai/mobile/service/impl/MobileHandleServiceImpl.java b/hai-service/src/main/java/com/hai/mobile/service/impl/MobileHandleServiceImpl.java new file mode 100644 index 00000000..1c4d734f --- /dev/null +++ b/hai-service/src/main/java/com/hai/mobile/service/impl/MobileHandleServiceImpl.java @@ -0,0 +1,6 @@ +package com.hai.mobile.service.impl; + +import com.hai.mobile.service.MobileHandleService; + +public class MobileHandleServiceImpl implements MobileHandleService { +} diff --git a/hai-service/src/main/java/com/hai/order/model/GoodsChildOrderExtModel.java b/hai-service/src/main/java/com/hai/order/model/GoodsChildOrderExtModel.java new file mode 100644 index 00000000..49a2a360 --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/model/GoodsChildOrderExtModel.java @@ -0,0 +1,37 @@ +package com.hai.order.model; + +import com.hai.entity.HighChildOrder; + +public class GoodsChildOrderExtModel extends HighChildOrder { + + /** + * 1:待发货 2:已发货 3:配送中 4:已送达 5:已取消 6:退货中 7:已退货 8:待支付 0:删除'; + */ + private String logisticsStatus; + private String logisticsNo; + private String deliveryAddressMsg; + + public String getDeliveryAddressMsg() { + return deliveryAddressMsg; + } + + public void setDeliveryAddressMsg(String deliveryAddressMsg) { + this.deliveryAddressMsg = deliveryAddressMsg; + } + + public String getLogisticsNo() { + return logisticsNo; + } + + public void setLogisticsNo(String logisticsNo) { + this.logisticsNo = logisticsNo; + } + + public String getLogisticsStatus() { + return logisticsStatus; + } + + public void setLogisticsStatus(String logisticsStatus) { + this.logisticsStatus = logisticsStatus; + } +} diff --git a/hai-service/src/main/java/com/hai/order/service/OrderService.java b/hai-service/src/main/java/com/hai/order/service/OrderService.java index ed9ef88d..12f6df6d 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderService.java @@ -69,6 +69,17 @@ public interface OrderService { */ HighOrder getOrderDetailByNo(String orderNo); + + /** + * @Author Sum1Dream + * @Name getOrderDetail + * @Description // 查询线上 + * @Date 18:29 2023/5/18 + * @Param [orderNo] + * @Return com.hai.entity.HighOrder + */ + HighOrder getOrderDetail(String orderNo); + /** * 根据子订单号查询子订单信息 * @param childOrderNo @@ -103,4 +114,14 @@ public interface OrderService { */ List phoneErrorOrder(); + + /** + * @Author Sum1Dream + * @Name getChildOrderList + * @Description // 查询子订单数量 + * @Date 15:54 2023/5/16 + * @Param [param] + * @Return java.util.List + */ + List getChildOrderList(Map param); } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 7847cd56..736fd74f 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -883,6 +883,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setPraiseStatus(0); childOrder.setCreateTime(new Date()); + // 生成充值订单 outRechargeOrder.setUserId(order.getMemId()); outRechargeOrder.setRechargeContent(rechargeContent); outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId()); @@ -929,6 +930,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setGoodsType(OrderChildGoodsType.TYPE11.getNumber()); childOrder.setGoodsId(createOrderChild.getGoodsId()); childOrder.setGoodsName(goods.getName()); + childOrder.setSecUserId(goods.getOpId()); childOrder.setSkuId(createOrderChild.getSkuId()); childOrder.setGoodsSpecName(goodsSku.getName()); childOrder.setGoodsPrice(goodsSku.getOriginalPrice()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 6be554d5..c5e6e3ab 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -623,14 +623,6 @@ public class OrderServiceImpl implements OrderService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!"); } - // 订单是否异常,订单没异常则需要校验产品业务是否支持退款 - if (order.getExceptionStatus().equals(true) - // 产品业务是否支付退款 - && order.getProductType().equals(OrderProductType.PRODUCT_TYPE9.getNumber()) - ) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!"); - } - // 退款订单号 String refundOrderNo = OrderUtil.generateRefundOrderNo(); @@ -764,6 +756,18 @@ public class OrderServiceImpl implements OrderService { return order; } + @Override + public HighOrder getOrderDetail(String orderNo) { + HighOrderExample orderExample = new HighOrderExample(); + orderExample.createCriteria().andOrderNoEqualTo(orderNo); + List orderList = orderMapper.selectByExample(orderExample); + if (orderList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号"); + } + + return orderList.get(0); + } + @Override public HighChildOrder getChildOrderByNo(String childOrderNo) { HighChildOrderExample childOrderExample = new HighChildOrderExample(); @@ -784,6 +788,10 @@ public class OrderServiceImpl implements OrderService { criteria.andMemIdEqualTo(MapUtils.getLong(param, "userId")); } + if (MapUtils.getBoolean(param, "exceptionStatus") != null) { + criteria.andExceptionStatusEqualTo(MapUtils.getBoolean(param, "exceptionStatus")); + } + if (MapUtils.getLong(param, "companyId") != null) { criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId")); } @@ -824,23 +832,26 @@ public class OrderServiceImpl implements OrderService { } if (MapUtils.getLong(param, "payTimeS") != null) { - criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeS"))); + criteria.andPayTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeS"))); } if (MapUtils.getLong(param, "payTimeE") != null) { - criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "payTimeE"))); + criteria.andPayTimeLessThan(new Date(MapUtils.getLong(param, "payTimeE"))); } if (MapUtils.getLong(param, "finishTimeS") != null) { - criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "finishTimeS"))); + criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "finishTimeS"))); } if (MapUtils.getLong(param, "finishTimeE") != null) { - criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "finishTimeE"))); + criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(param, "finishTimeE"))); } - if (StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeS")) && StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeE"))) { - criteria.andRefundTimeBetween( - DateUtil.format(MapUtils.getString(param, "refundTimeS"), "yyyy-MM-dd HH:mm:ss"), - DateUtil.format(MapUtils.getString(param, "refundTimeE"), "yyyy-MM-dd HH:mm:ss")); + + if (MapUtils.getLong(param, "refundTimeS") != null) { + criteria.andRefundTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeS"))); } + if (MapUtils.getLong(param, "refundTimeE") != null) { + criteria.andRefundTimeLessThan(new Date(MapUtils.getLong(param, "refundTimeE"))); + } + example.setOrderByClause("create_time desc"); return orderMapper.selectByExample(example); @@ -861,4 +872,39 @@ public class OrderServiceImpl implements OrderService { public List phoneErrorOrder() { return orderMapper.phoneErrorOrder(); } + + @Override + public List getChildOrderList(Map param) { + + HighChildOrderExample example = new HighChildOrderExample(); + HighChildOrderExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(param, "orderNo") != null) { + criteria.andOrderNoEqualTo(MapUtils.getString(param, "orderNo")); + } + + if (MapUtils.getString(param, "childOrderNo") != null) { + criteria.andChildOrderNoEqualTo(MapUtils.getString(param, "childOrderNo")); + } + + if (MapUtils.getString(param, "memPhone") != null) { + criteria.andMemPhoneEqualTo(MapUtils.getString(param, "memPhone")); + } + if (MapUtils.getInteger(param, "status") != null) { + criteria.andChildOrderStatusEqualTo(MapUtils.getInteger(param, "status")); + } + if (MapUtils.getLong(param, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS"))); + } + if (MapUtils.getLong(param, "createTimeE") != null) { + criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "createTimeE"))); + } + if (MapUtils.getLong(param, "secUserId") != null) { + criteria.andSecUserIdEqualTo(MapUtils.getLong(param, "secUserId")); + } + example.setOrderByClause("create_time desc"); + + + return childOrderMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/CommonService.java b/hai-service/src/main/java/com/hai/service/CommonService.java index abd092d7..b1afbbc1 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -253,6 +253,10 @@ public interface CommonService { */ JSONObject findByLatAndLng( String lng , String lat) throws Exception; + JSONObject baiduApiMapSearch(Map map); + + JSONObject gaoDeApiMapSearch(Map map); + /** * @Author Sum1Dream * @name configPayType.java 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 6148530f..1a834c3c 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -205,7 +205,7 @@ public interface OutRechargeOrderService { * @Description // 订单是否可以充值 * @Date 16:11 2023/3/28 * @Param [childOrder] - * @Return java.lang.Integer 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 + * @Return java.lang.Integer 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 6:充值订单号未查询到任何充值记录 */ Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder); diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index 824c6f89..29774971 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -562,6 +562,33 @@ public class CommonServiceImpl implements CommonService { } + @Override + public JSONObject baiduApiMapSearch(Map map) { + //申请百度开放平台KEY(ak) + map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR"); + // 输出Json数据 + map.put("output", "json"); + // 圆形区域检索半径,单位为米。(增加区域内数据召回权重,如需严格限制召回数据在区域内,请搭配使用radius_limit参数),当半径过大,超过中心点所在城市边界时,会变为城市范围检索,检索范围为中心点所在城市 + map.put("radius", "500"); + // 检索结果详细程度。取值为1 或空,则返回基本信息;取值为2,返回检索POI详细信息 + map.put("scope", "1"); + // 是否召回国标行政区划编码,true(召回)、false(不召回) + map.put("extensions_adcode", "true"); + // GPS 经纬度类型 + map.put("coordtype", "wgs84ll"); + + return HttpsUtils.doGet("https://api.map.baidu.com/place/v2/search" , map); + } + + + @Override + public JSONObject gaoDeApiMapSearch(Map map) { + + map.put("key" , "b7f6a6c5cd9801a82a0dc827f271a75d"); + + return HttpsUtils.doGet("https://restapi.amap.com/v3/assistant/inputtips" , map); + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void configPayType(JSONObject object) { diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java index 6ddff44c..a010ea19 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java @@ -59,6 +59,9 @@ public class HighGoldRecServiceImpl implements HighGoldRecService { if (MapUtils.getLong(map, "resId") != null) { criteria.andResIdEqualTo(MapUtils.getLong(map, "resId")); } + if (MapUtils.getString(map, "resOrderNo") != null) { + criteria.andResOrderNoEqualTo(MapUtils.getString(map, "resOrderNo")); + } if (MapUtils.getLong(map , "createTimeS") != null) { criteria.andCreateTimeBetween(new Date(MapUtils.getLong(map , "createTimeS")) , new Date(MapUtils.getLong(map , "createTimeE"))); 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 bc31ef77..2667ea36 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 @@ -399,42 +399,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } - @Override - public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) { - - 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(); - - // 补充下单参数 - object = prepaidRechargeOrderHandle(object); - - // 补充子订单参数 - 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()); - outRechargeChildOrderService.insertOrder(childOrder); - rocketMQTemplate.syncSend(OrderTopic.MOBILE_TOPIC_PROFIT_RECHARGE.getTopic(), childOrder); - } @Override public void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder){ @@ -448,7 +413,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if(Boolean.TRUE.equals(lock)) { // 加锁成功,处理业务 - // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 + // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单存在多个充值订单 5:订单充值完成 6:充值订单号未查询到任何充值记录 int orderStatus = orderWhetherRecharge(outRechargeOrder); log.info("处理话费" + outRechargeOrder.getOrderNo() + "订单状态:" + orderStatus); if (orderStatus == 1) { @@ -460,7 +425,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (orderStatus == 4) { HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); highOrder.setExceptionStatus(true); - highOrder.setExceptionContent("话费订单存在多条重复记录"); + highOrder.setExceptionContent("订单存在多个充值订单"); + highOrderService.updateOrder(highOrder); + } + if (orderStatus == 6) { + HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo()); + highOrder.setExceptionStatus(true); + highOrder.setExceptionContent("充值订单号未查询到任何充值记录"); highOrderService.updateOrder(highOrder); } if (orderStatus == 5) { @@ -483,6 +454,181 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } +// @Override +// public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) { +// +// 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(); +// +// // 补充下单参数 +// object = prepaidRechargeOrderHandle(object); +// +// // 补充子订单参数 +// 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()); +// +// outRechargeChildOrderService.insertOrder(childOrder); +// +// // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 +// Integer status = outRechargeOrderService.getRechargeOrderLegality(childOrder); +// +// if (status == 2 || status == -1) { +// // 补充下单参数 +// object = outRechargeOrderService.prepaidRechargeOrderHandle(object); +// +// // 尖椒充值 +// 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()); +// } +// +// // 龙阅 +// if (object.getInteger("rechargePlatform") == 2) { +// +// if (object.getString("code") == null) { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); +// } +// +// 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()); +// } +// +// // 畅停充值 +// if (object.getInteger("rechargePlatform") == 4) { +// +// 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()); +// } +// +// +// System.out.println("消费内容:" + childOrder); +// +// childOrder.setUpdateTime(new Date()); +// outRechargeChildOrderService.updateOrder(childOrder); +// } +// } + + @Override + public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) { + + 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(); + + // 补充下单参数 + object = prepaidRechargeOrderHandle(object); + + // 补充子订单参数 + 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()); + outRechargeChildOrderService.insertOrder(childOrder); + // 尖椒充值 + 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.setRechargePlatform(1); + childOrder.setExt1("尖椒" + returnObject.toJSONString()); + childOrder.setExt2(object.toJSONString()); + } + + // 龙阅 + if (object.getInteger("rechargePlatform") == 2) { + + if (object.getString("code") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + 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.setRechargePlatform(2); + childOrder.setExt1("龙阅充值" + returnObject.toJSONString()); + childOrder.setExt2("龙阅请求参数" + object.toJSONString()); + childOrder.setExt3("龙阅充值" + returnObject.toJSONString()); + + } + + // 畅停充值 + if (object.getInteger("rechargePlatform") == 4) { + + 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.setRechargePlatform(4); + childOrder.setExt1("畅停充值" + returnObject.toJSONString()); + childOrder.setExt2("畅停请求参数" + object.toJSONString()); + childOrder.setExt3("畅停充值" + returnObject.toJSONString()); + } + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.updateOrder(childOrder); + } + @Override public void completeOrder(Long orderId) { @@ -503,6 +649,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (highOrder != null) { highOrder.setOrderStatus(OrderStatusEnum.type3.getType()); highOrder.setFinishTime(new Date()); + highOrder.setExceptionStatus(false); + highOrder.setExceptionContent(null); for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { highChildOrder.setChildOrderStatus(OrderChildStatus.STATUS3.getNumber()); highChildOrder.setFinishTime(new Date()); @@ -553,28 +701,28 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { public Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) { try { + JSONObject object = new JSONObject(); + + Integer status = 99; + // 龙阅 if (childOrder.getRechargePlatform() == 2) { object.put("out_trade_nums" , childOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByLy(object); + childOrder.setExt3("龙阅查询"+ jsonObject); JSONArray objectJSONArray = jsonObject.getJSONArray("data"); + JSONObject objectData = new JSONObject(); for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; } - if (objectData.size() == 0) { - if (jsonObject.getInteger("errno") == 0) { - return 2; - } else { - return 99; - } - } else { + if (objectData.size() > 0) { // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 - return objectData.getInteger("state"); + status = objectData.getInteger("state"); } } @@ -583,37 +731,46 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { object.put("orderid" , childOrder.getOrderNo()); JSONObject jsonObject = RechargeConfig.checkOrderByHg(object); - if (jsonObject.getJSONArray("data") == null) { - if (jsonObject.getInteger("code") == 20001) { - return 2; - } - return 99; - } else { + childOrder.setExt3("畅停查询"+ jsonObject); + if (jsonObject.getJSONArray("data") != null) { JSONArray objectJSONArray = jsonObject.getJSONArray("data"); + JSONObject objectData; for (Object objects : objectJSONArray) { objectData = (JSONObject) objects; // 0充值中,1成功,2失败,3已取消,4部分充值,5缓存订单 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 - if (objectData.getInteger("status") == 0 || objectData.getInteger("status") == 5) { - return 0; + status = 0; } else if (objectData.getInteger("status") == 1) { - return 1; + status = 1; } else if (objectData.getInteger("status") == 2) { - return 2; + status = 2; } else if (objectData.getInteger("status") == 3) { - return -1; + status = -1; } else if (objectData.getInteger("status") == 4) { - return 3; + status = 3; } } } } - return 99; + + if (status == 1) { + childOrder.setStatus(101); + } + if (status == 2 || status == -1) { + childOrder.setStatus(103); + } + if (status == 99 ) { + childOrder.setStatus(104); + } + + childOrder.setUpdateTime(new Date()); + outRechargeChildOrderService.updateOrder(childOrder); + return status; }catch (Exception e) { - return null; + return 99; } @@ -692,7 +849,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { List childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId()); if (childOrderList.size() == 0) { - return 4; + return 6; } // 充值订单充值时间 @@ -732,14 +889,17 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (status == 2 || status == -1) { // 修改充值订单状态 rechargeChildOrderHandle(childOrders102.get(0) , 103); - // 如果订单记录超过5条退款 反之继续充值 - if (childOrderList.size() > 4) { + // 如果订单记录超过2条退款 反之继续充值 + if (childOrderList.size() > 1) { return 2; } else { // 如果订单记录超过71小时 反之继续充值 return hours > 71 ? 2 : 1; } } + if (status == 99) { + return 6; + } // 充值订单为充值成功 if (status == 1) { // 修改充值订单状态 @@ -757,8 +917,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { if (status == 2 || status == -1) { // 修改充值订单状态 rechargeChildOrderHandle(childOrderList.get(0) , 103); - // 如果订单记录超过5条退款 反之继续充值 - if (childOrderList.size() > 4) { + // 如果订单记录超过2条退款 反之继续充值 + if (childOrderList.size() > 1) { return 2; } else { // 如果订单记录超过71小时 反之继续充值 @@ -766,17 +926,15 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { } } + if (status == 99) { + return 6; + } if (status == 1) { // 修改充值订单状态 rechargeChildOrderHandle(childOrderList.get(0) , 101); return 5; } - } else { - // 如果订单记录超过71小时 反之继续充值 - return hours > 71 ? 2 : 1; } - - } return 3; } diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java index ef928d4d..7dbc36b7 100644 --- a/v1/src/main/java/com/v1/controller/WxMsgController.java +++ b/v1/src/main/java/com/v1/controller/WxMsgController.java @@ -216,7 +216,7 @@ public class WxMsgController { linkContent = "支付分享,享受更高优惠[礼物]\n\n" + "分享好友\n\n"; } @@ -339,7 +339,7 @@ public class WxMsgController { linkContent = "支付分享,享受更高优惠[礼物]\n\n" + "分享好友\n\n"; } diff --git a/v1/src/main/java/com/v1/controller/business/OrderRebateController.java b/v1/src/main/java/com/v1/controller/business/OrderRebateController.java index 5daf1d81..638cb717 100644 --- a/v1/src/main/java/com/v1/controller/business/OrderRebateController.java +++ b/v1/src/main/java/com/v1/controller/business/OrderRebateController.java @@ -172,6 +172,7 @@ public class OrderRebateController { Map mapGold = new HashMap<>(); mapGold.put("goldType", 1); mapGold.put("resId", object.getLong("orderId")); + mapGold.put("resOrderNo", object.getString("orderNo")); List goldRecs = highGoldRecService.getGoldRec(mapGold); @@ -296,10 +297,6 @@ public class OrderRebateController { } - - - - return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e);