From 30c070004a07330f14e08b1739f703f05b33ed03 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 19 Jul 2024 15:41:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/BsDeviceController.java | 44 ++++++++++++++++++- .../bweb/controller/BsGasOrderController.java | 34 ++++++++++++-- .../hfkj/service/gas/BsGasOrderService.java | 6 +++ .../gas/impl/BsGasOrderServiceImpl.java | 19 +++++++- .../service/order/OrderPaySuccessService.java | 6 ++- .../service/order/OrderRefundBusiness.java | 20 +++++---- .../sysenum/DeviceReceiptOutContentEnum.java | 7 +++ 7 files changed, 120 insertions(+), 16 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/BsDeviceController.java b/bweb/src/main/java/com/bweb/controller/BsDeviceController.java index 7cce3c2..bb6a9bd 100644 --- a/bweb/src/main/java/com/bweb/controller/BsDeviceController.java +++ b/bweb/src/main/java/com/bweb/controller/BsDeviceController.java @@ -16,6 +16,7 @@ import com.hfkj.service.BsDeviceService; import com.hfkj.service.merchant.BsMerchantService; import com.hfkj.sysenum.DeviceReceiptOutContentEnum; import com.hfkj.sysenum.DeviceTypeEnum; +import com.hfkj.sysenum.MerchantSourceTypeEnum; import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -95,6 +96,21 @@ public class BsDeviceController { } } } + + DeviceReceiptOutContentEnum receiptOutContent = null; + Map param = new HashMap<>(); + param.put("type", DeviceTypeEnum.type1.getType()); + param.put("merNo", body.getMerNo()); + // 查询设备 + List deviceList = deviceService.getDeviceList(param); + if (!deviceList.isEmpty()) { + // 查询设备的设置 + receiptOutContent = DeviceReceiptOutContentEnum.getDataByType(deviceList.get(0).getReceiptOutContent()); + } + if (receiptOutContent == null) { + receiptOutContent = DeviceReceiptOutContentEnum.content2; + } + device.setMerId(merchant.getId()); device.setMerNo(merchant.getMerNo()); device.setMerName(merchant.getMerName()); @@ -104,7 +120,7 @@ public class BsDeviceController { device.setDeviceKey(body.getDeviceKey()); device.setDeviceImei(body.getDeviceImei()); device.setDeviceIccid(body.getDeviceIccid()); - device.setReceiptOutContent(body.getReceiptOutContent()==null?DeviceReceiptOutContentEnum.content2.getType():body.getReceiptOutContent()); + device.setReceiptOutContent(receiptOutContent.getType()); device.setReceiptTop(body.getReceiptTop()); device.setReceiptSource(body.getReceiptSource()); device.setReceiptBottom(body.getReceiptBottom()); @@ -206,6 +222,32 @@ public class BsDeviceController { } + @RequestMapping(value="/getSettingReceipt",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询小票打印内容") + public ResponseData getSettingReceipt(@RequestParam(name = "merNo", required = true) String merNo) { + try { + DeviceReceiptOutContentEnum receiptOutContent = null; + Map param = new HashMap<>(); + param.put("type", DeviceTypeEnum.type1.getType()); + param.put("merNo", merNo); + // 查询设备 + List deviceList = deviceService.getDeviceList(param); + if (!deviceList.isEmpty()) { + // 查询设备的设置 + receiptOutContent = DeviceReceiptOutContentEnum.getDataByType(deviceList.get(0).getReceiptOutContent()); + } + if (receiptOutContent == null) { + receiptOutContent = DeviceReceiptOutContentEnum.content2; + } + return ResponseMsgUtil.success(receiptOutContent.getType()); + + } catch (Exception e) { + log.error("HighDeviceController -> settingReceipt() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/settingReceipt",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "设置小票打印内容") diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java b/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java index e3672b7..545e1e1 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java @@ -1,6 +1,7 @@ package com.bweb.controller; import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -19,6 +20,7 @@ import com.hfkj.model.order.ExportGasOrderModel; import com.hfkj.service.BsDeviceService; import com.hfkj.service.gas.BsGasOrderService; import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.OrderPaySuccessService; import com.hfkj.sysenum.MerchantSourceTypeEnum; import com.hfkj.sysenum.SecUserObjectTypeEnum; import com.hfkj.sysenum.gas.OrderOilStatus; @@ -29,10 +31,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.File; @@ -381,6 +380,33 @@ public class BsGasOrderController { } + @RequestMapping(value="/repairOrder",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "补单") + public ResponseData repairOrder(@RequestBody JSONObject body) { + try { + if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询加油订单 + BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(body.getString("orderNo")); + if (gasOrder == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的加油的订单"); + } + if (!gasOrder.getAbnormal().equals(true)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油订单未处于异常状态,无需补单!"); + } + // 补推 + gasOrderService.repairOrder(gasOrder.getOrderNo()); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/queryOilOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询加油订单详情") diff --git a/service/src/main/java/com/hfkj/service/gas/BsGasOrderService.java b/service/src/main/java/com/hfkj/service/gas/BsGasOrderService.java index e2d5891..242934b 100644 --- a/service/src/main/java/com/hfkj/service/gas/BsGasOrderService.java +++ b/service/src/main/java/com/hfkj/service/gas/BsGasOrderService.java @@ -39,6 +39,12 @@ public interface BsGasOrderService { */ BsGasOrder getDetailByOrderNo(String orderNo); + /** + * 补单 + * @param orderNo + */ + BsGasOrder repairOrder(String orderNo) throws Exception; + /** * 查询详情 * @param paySerialNo diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java index 632a320..778aff0 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java @@ -1,10 +1,15 @@ package com.hfkj.service.gas.impl; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.DateUtil; import com.hfkj.dao.BsGasOrderMapper; import com.hfkj.entity.BsGasOrder; import com.hfkj.entity.BsGasOrderExample; import com.hfkj.service.gas.BsGasOrderService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.OrderPaySuccessService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -27,7 +32,10 @@ public class BsGasOrderServiceImpl implements BsGasOrderService { @Resource private BsGasOrderMapper gasOrderMapper; - + @Resource + private BsOrderService orderService; + @Resource + private OrderPaySuccessService paySuccessService; @Override public void addGasOrder(BsGasOrder gasOrder) { gasOrder.setCreateTime(new Date()); @@ -61,6 +69,15 @@ public class BsGasOrderServiceImpl implements BsGasOrderService { return null; } + @Override + public BsGasOrder repairOrder(String orderNo) throws Exception { + BsGasOrder result = paySuccessService.oilHandle(orderService.getDetail(orderNo)); + if (result.getAbnormal().equals(true)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补单失败!原因:" + result.getAbnormalContent()); + } + return result; + } + @Override public BsGasOrder getDetailByPaySerialNo(String paySerialNo) { BsGasOrderExample example = new BsGasOrderExample(); diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index fc87da7..c1ebdde 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -69,7 +69,7 @@ public class OrderPaySuccessService { * 加油业务 * @param order */ - public void oilHandle(OrderModel order) throws Exception { + public BsGasOrder oilHandle(OrderModel order) throws Exception { // 查询加油订单 BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(order.getOrderNo()); if (gasOrder != null) { @@ -114,6 +114,8 @@ public class OrderPaySuccessService { JSONObject pushResult = NewLinkRequestService.refuelingOrderPush(param); if (pushResult != null && pushResult.getString("code").equals("200")) { gasOrder.setChannelOrderNo(pushResult.getJSONObject("result").getString("orderNo")); + gasOrder.setAbnormal(false); + gasOrder.setAbnormalContent(null); } else { gasOrder.setAbnormal(true); gasOrder.setAbnormalContent(pushResult.getString("message")); @@ -142,6 +144,8 @@ public class OrderPaySuccessService { // 子订单完成 orderService.childOrderComplete(gasOrder.getOrderChildNo()); } + + return gasOrder; } } diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java index 9627ebe..a6983ce 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java @@ -47,16 +47,18 @@ public class OrderRefundBusiness { gasOrderService.updateGasOrder(gasOrder); try { - if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) { - // 退回商户额度 - merchantAccountService.refund(gasOrder.getMerNo(), gasOrder.getGasRefuelPrice(), refund); + if (gasOrder.getAbnormal().equals(false)) { + if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) { + // 退回商户额度 + merchantAccountService.refund(gasOrder.getMerNo(), gasOrder.getGasRefuelPrice(), refund); - } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { - JSONObject object = NewLinkRequestService.refuelingOrderRefund(gasOrder.getUserPhone(), gasOrder.getOrderNo(), refund.getRefundRemark()); - if (object == null || !object.getString("code").equals("200")) { - gasOrder.setAbnormal(true); - gasOrder.setAbnormalContent("渠道退款失败!"); - gasOrderService.updateGasOrder(gasOrder); + } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { + JSONObject object = NewLinkRequestService.refuelingOrderRefund(gasOrder.getUserPhone(), gasOrder.getOrderNo(), refund.getRefundRemark()); + if (object == null || !object.getString("code").equals("200")) { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent("渠道退款失败!原因:" + object.getString("message")); + gasOrderService.updateGasOrder(gasOrder); + } } } } catch (Exception e) {} diff --git a/service/src/main/java/com/hfkj/sysenum/DeviceReceiptOutContentEnum.java b/service/src/main/java/com/hfkj/sysenum/DeviceReceiptOutContentEnum.java index 1a405dd..51272e7 100644 --- a/service/src/main/java/com/hfkj/sysenum/DeviceReceiptOutContentEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/DeviceReceiptOutContentEnum.java @@ -29,6 +29,13 @@ public enum DeviceReceiptOutContentEnum { this.name = name; } + public static DeviceReceiptOutContentEnum getDataByType(Integer type) { + for (DeviceReceiptOutContentEnum ele : values()) { + if(Objects.equals(type,ele.getType())) return ele; + } + return null; + } + public static String getNameByType(Integer type) { for (DeviceReceiptOutContentEnum ele : values()) { if(Objects.equals(type,ele.getType())) return ele.getName();