From 48c4d19c3655a13cf12cf1ed81eeb79eefd9d3bd Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Fri, 13 Sep 2024 16:40:23 +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 --- .../controller/BsDiscountUserController.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cweb/src/main/java/com/cweb/controller/BsDiscountUserController.java b/cweb/src/main/java/com/cweb/controller/BsDiscountUserController.java index 63ce02c..25cbf73 100644 --- a/cweb/src/main/java/com/cweb/controller/BsDiscountUserController.java +++ b/cweb/src/main/java/com/cweb/controller/BsDiscountUserController.java @@ -8,14 +8,17 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsAgentPrice; import com.hfkj.entity.BsDiscountUser; import com.hfkj.model.DiscountUserModel; import com.hfkj.model.GasListModel; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; +import com.hfkj.service.agent.BsAgentPriceService; import com.hfkj.service.discount.BsDiscountService; import com.hfkj.service.discount.BsDiscountUserService; import com.hfkj.service.gas.BsGasService; +import com.hfkj.sysenum.agent.AgentPriceTypeEnum; import com.hfkj.sysenum.discount.DiscountUserStatusEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -47,11 +50,14 @@ public class BsDiscountUserController { private UserCenter userCenter; @Resource private BsGasService gasService; + @Resource + private BsAgentPriceService agentPriceService; @RequestMapping(value="/usableMerList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "可用加油站列表") public ResponseData usableMerList(@RequestParam(name = "discountNo", required = true) String discountNo, + @RequestParam(name = "agentMerId", required = false) Long agentMerId, @RequestParam(name = "gasName", required = false) String gasName, @RequestParam(name = "distanceLimit", required = false) Integer distanceLimit, @RequestParam(name = "oilNo", required = true) String oilNo, @@ -62,7 +68,25 @@ public class BsDiscountUserController { try { PageHelper.startPage(pageNum,pageSize); - return ResponseMsgUtil.success(new PageInfo<>(gasService.getGasListByDiscount(discountNo,longitude, latitude, oilNo, gasName, distanceLimit, true))); + PageInfo pageInfo = new PageInfo<>(gasService.getGasListByDiscount(discountNo,longitude, latitude, oilNo, gasName, distanceLimit, true)); + for (GasListModel gas : pageInfo.getList()) { + BigDecimal discount = new BigDecimal("100"); + if (agentMerId != null) { + // 查询代理价格 + BsAgentPrice agentPrice = agentPriceService.getDetail(agentMerId, gas.getOilNo()); + if (agentPrice != null) { + discount = agentPrice.getPriceRate(); + } + } else { + // 查询平台价格 + BsAgentPrice agentPrice = agentPriceService.getDetail(AgentPriceTypeEnum.type1, gas.getMerNo(), gas.getOilNo()); + if (agentPrice != null) { + discount = agentPrice.getPriceRate(); + } + } + gas.setPriceVip(gas.getPriceVip().multiply(discount.divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + return ResponseMsgUtil.success(pageInfo); } catch (Exception e) { return ResponseMsgUtil.exception(e);