From f4cff23bb8bd2df32ccdbfc3fd8f9c3ad88f34f5 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 17 May 2022 15:09:37 +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/HighGasOilPriceController.java | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java index fb000583..e3407d4d 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java @@ -7,19 +7,14 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.HighGasDiscountOilPrice; -import com.hai.entity.HighGasOilPrice; -import com.hai.entity.HighMerchantStore; -import com.hai.entity.SecDictionary; +import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; -import com.hai.service.CommonService; -import com.hai.service.HighGasDiscountOilPriceService; -import com.hai.service.HighGasOilPriceService; -import com.hai.service.HighMerchantStoreService; +import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +37,9 @@ public class HighGasOilPriceController { @Resource private HighGasOilPriceService gasOilPriceService; + @Resource + private HighGasOilPriceOfficialService gasOilPriceOfficialService; + @Resource private HighMerchantStoreService merchantStoreService; @@ -54,7 +52,7 @@ public class HighGasOilPriceController { public ResponseData editGasOilPrice(@RequestBody JSONObject body) { try { if (body.getLong("storeId") == null - || StringUtils.isBlank(body.getString("oilNo")) + || body.getInteger("oilNo") == null || body.getBigDecimal("priceGun") == null || body.getBigDecimal("preferentialMargin") == null ) { @@ -88,7 +86,13 @@ public class HighGasOilPriceController { price.setPriceVip(body.getBigDecimal("priceGun").subtract(body.getBigDecimal("preferentialMargin"))); price.setPreferentialMargin(body.getBigDecimal("preferentialMargin")); price.setPriceGun(body.getBigDecimal("priceGun")); - price.setPriceOfficial(new BigDecimal("8")); + + // 查询国标价格 + HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), body.getInteger("oilNo")); + if (priceOfficial != null) { + price.setPriceOfficial(priceOfficial.getPriceOfficial()); + } + price.setOilType(Integer.parseInt(oilNo.getExt1())); price.setOilTypeName(oilNo.getExt2()); gasOilPriceService.editGasOilPrice(price); @@ -128,6 +132,38 @@ public class HighGasOilPriceController { } } + @RequestMapping(value="/getOilPriceDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油品价格详情") + public ResponseData getOilPriceDetail(@RequestParam(name = "storeId", required = true) Long storeId, + @RequestParam(name = "oilNo", required = true) Integer oilNo) { + try { + // 查询门店详情 + HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(storeId); + if (store == null) { + log.error("HighGasDiscountOilPriceController -> editGasOilPrice() error!","未找到门店"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店"); + } + + // 查询价格 + HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(storeId, oilNo); + if (gasOilPrice == null) { + gasOilPrice = new HighGasOilPrice(); + // 查询国标价格 + HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), oilNo); + if (priceOfficial != null) { + gasOilPrice.setPriceOfficial(priceOfficial.getPriceOfficial()); + } + } + + return ResponseMsgUtil.success(gasOilPrice); + + } catch (Exception e) { + log.error("HighGasDiscountOilPriceController -> getGasDetailByStoreKey() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getOilPriceListByStore",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油品价格列表")