diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index def20259..47ccbee5 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -113,6 +113,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/highGas/*") .excludePathPatterns("/wechat/*") .excludePathPatterns("/tuanyou/*") + .excludePathPatterns("/highGas/*") .excludePathPatterns("/common/*") .excludePathPatterns("/order/qzOrderToPay") .excludePathPatterns("/czOrder/orderRefundNotify") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index 592d40d9..0c62423d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -88,7 +88,6 @@ public class HighGasController { iterator.remove(); } } - PageInfo> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance)); for (Map map : mapPageInfo.getList()) { if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) { diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 60306ed5..efbe1773 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -169,7 +169,7 @@ public class HighOrderController { } if (childOrder.getGoodsType() == 3) { - if (childOrder.getGoodsPrice() == null || childOrder.getGasPriceGun() == null || childOrder.getGasPriceVip() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) { + if (childOrder.getGasPriceGun() == null || childOrder.getGasPriceVip() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) { log.error("HighOrderController --> addOrder() error!", "参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } @@ -180,9 +180,29 @@ public class HighOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); } highOrder.setPayType(2); // 第三方平台 + + // 获取当前加油价格 + JSONObject jsonObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), childOrder.getGasOilNo()); + if (jsonObject == null || !jsonObject.getString("code").equals("200")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格"); + } + if(jsonObject.getJSONArray("result").size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格"); + } + JSONObject priceDetail = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.getJSONArray("result").get(0)), JSONObject.class); + childOrder.setGoodsName(store.getStoreName()); childOrder.setGoodsImg(store.getStoreLogo()); + + // 平台的价格 + childOrder.setExt1(childOrder.getGasPriceVip().toString()); childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); + + // 团油的价格 + childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); + childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); + childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); + childOrder.setGoodsSpecName("默认"); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index ccf3efef..c4a24c5d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -93,6 +93,7 @@ public class HighTestController { // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { + highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java index 812d0739..c6defe97 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java @@ -1,17 +1,24 @@ package com.cweb.controller.pay; import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonSysConst; import com.hai.config.WxOrderConfig; import com.hai.dao.HighGasOrderRefundMapper; +import com.hai.entity.HighChildOrder; import com.hai.entity.HighGasOrderRefund; import com.hai.entity.HighOrder; import com.hai.model.OrderRefundModel; +import com.hai.model.ResponseData; import com.hai.service.HighOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -94,4 +101,35 @@ public class TuanYouController { log.error("WechatPayController --> wechatNotify() error!", e); } } + + @RequestMapping(value = "/abnormalOrderRefund", method = RequestMethod.POST) + @ApiOperation(value = "异常订单退款") + @ResponseBody + public ResponseData abnormalOrderRefund(@RequestBody JSONObject body) { + try { + if (StringUtils.isNotBlank(body.getString("orderNo"))) { + // 查询订单 + HighOrder order = highOrderService.getOrderByOrderNo(body.getString("orderNo")); + // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 + if (order != null && order.getOrderStatus() == 2) { + OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice()); + if(orderRefundModel.getResult_code().equals("SUCCESS")) { + for (HighChildOrder childOrder : order.getHighChildOrderList()) { + childOrder.setChildOrdeStatus(4); + } + order.setOrderStatus(4); + order.setRefundTime(new Date()); + order.setRefundPrice(order.getPayRealPrice()); + highOrderService.updateOrder(order); + return ResponseMsgUtil.success("退款成功"); + } + } + } + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java index 26511f9a..ea47fff2 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java @@ -78,6 +78,7 @@ public class HighGasSchedule { // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { + highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName"));