From ddb54d37cda3fcb150d0475bfa3c82eeba384fac Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 20 Jul 2022 14:07:18 +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 | 79 +++++++++++-------- .../HighGasOilPriceTaskController.java | 8 +- .../cweb/controller/HighOrderController.java | 2 +- .../com/hai/config/ZkcPrinterTemplate.java | 8 +- .../com/hai/dao/HighGasOilPriceMapper.java | 27 ++++--- .../com/hai/dao/HighGasOilPriceMapperExt.java | 3 +- .../hai/dao/HighGasOilPriceSqlProvider.java | 14 ++++ .../java/com/hai/entity/HighGasOilPrice.java | 18 ++++- .../hai/entity/HighGasOilPriceExample.java | 60 ++++++++++++++ .../hai/enum_type/GasTaskPriceTypeEnum.java | 3 +- .../java/com/hai/model/GasPayPriceModel.java | 39 ++++++--- .../HighGasDiscountOilPriceServiceImpl.java | 47 ++++++----- .../HighGasOilPriceOfficialServiceImpl.java | 4 +- .../impl/HighGasOilPriceTaskServiceImpl.java | 20 ++++- 14 files changed, 243 insertions(+), 89 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 0414e5ab..3b12b1be 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java @@ -25,6 +25,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -37,9 +38,15 @@ public class HighGasOilPriceController { @Resource private HighGasOilPriceService gasOilPriceService; + @Resource + private HighTyAgentPriceService tyAgentPriceService; + @Resource private HighGasOilPriceOfficialService gasOilPriceOfficialService; + @Resource + private HighGasDiscountOilPriceService gasDiscountOilPriceService; + @Resource private HighMerchantStoreService merchantStoreService; @@ -51,23 +58,10 @@ public class HighGasOilPriceController { @ApiOperation(value = "编辑油品价格") public ResponseData editGasOilPrice(@RequestBody JSONObject body) { try { - if (body.getLong("storeId") == null - || body.getInteger("oilNo") == null - || body.getBigDecimal("priceGun") == null - || body.getBigDecimal("preferentialMargin") == null - ) { + if (body.getLong("storeId") == null || body.getInteger("oilNo") == null) { log.error("HighGasDiscountOilPriceController -> editGasOilPrice() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - - if (body.getBigDecimal("preferentialMargin").compareTo(body.getBigDecimal("priceGun")) == 0) { - log.error("HighGasDiscountOilPriceController -> editGasOilPrice() error!",""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "优惠幅度不能与油枪价相同"); - } - if (body.getBigDecimal("preferentialMargin").compareTo(body.getBigDecimal("priceGun")) == 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "优惠幅度不能大于枪价"); - } - // 查询门店详情 HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(body.getLong("storeId")); if (store == null) { @@ -87,25 +81,28 @@ public class HighGasOilPriceController { HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(body.getLong("storeId"), Integer.valueOf(body.getString("oilNo"))); if (price == null) { price = new HighGasOilPrice(); - } - price.setMerchantStoreId(body.getLong("storeId")); - price.setOilNo(Integer.parseInt(oilNo.getCodeValue())); - price.setOilNoName(oilNo.getCodeName()); - price.setPriceVip(body.getBigDecimal("priceGun").subtract(body.getBigDecimal("preferentialMargin"))); - price.setPreferentialMargin(body.getBigDecimal("preferentialMargin")); - price.setPriceGun(body.getBigDecimal("priceGun")); - - // 查询国标价格 - HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), body.getInteger("oilNo")); - if (priceOfficial != null) { + // 查询国标价格 + HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), body.getInteger("oilNo")); + if (priceOfficial == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法添加,系统未配置"+body.getInteger("oilNo")+"油号的国标价"); + } + price.setMerchantStoreId(body.getLong("storeId")); + price.setOilType(Integer.parseInt(oilNo.getExt1())); + price.setOilTypeName(oilNo.getExt2()); + price.setOilNo(Integer.parseInt(oilNo.getCodeValue())); + price.setOilNoName(oilNo.getCodeName()); + price.setPriceOfficial(priceOfficial.getPriceOfficial()); - } + price.setPriceGun(priceOfficial.getPriceOfficial()); + price.setPriceVip(priceOfficial.getPriceOfficial()); - price.setOilType(Integer.parseInt(oilNo.getExt1())); - price.setOilTypeName(oilNo.getExt2()); - gasOilPriceService.editGasOilPrice(price); + price.setGasStationDrop(new BigDecimal("0")); + price.setPreferentialMargin(new BigDecimal("0")); - return ResponseMsgUtil.success("操作成功"); + gasOilPriceService.editGasOilPrice(price); + return ResponseMsgUtil.success("操作成功"); + } + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已添加" + body.getInteger("oilNo") + "油号"); } catch (Exception e) { log.error("HighGasDiscountOilPriceController -> getGasDetailByStoreKey() error!",e); @@ -178,7 +175,27 @@ public class HighGasOilPriceController { public ResponseData getOilPriceListByStore(@RequestParam(name = "storeId", required = true) Long storeId) { try { - return ResponseMsgUtil.success(gasOilPriceService.getGasOilPriceByStore(storeId)); + List gasOilPriceList = gasOilPriceService.getGasOilPriceByStore(storeId); + for (HighGasOilPrice gasOilPrice : gasOilPriceList) { + BigDecimal discount = new BigDecimal("100"); + + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, gasOilPrice.getMerchantStoreId(), gasOilPrice.getOilNo().toString()); + if (tyAgentPrice != null) { + discount = tyAgentPrice.getPriceRate(); + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(gasOilPrice.getOilNo().toString()); + if (gasDiscountOilPrice != null) { + discount = gasDiscountOilPrice.getPriceRate(); + } + } + // 油枪价 - 优惠幅度 + BigDecimal price = gasOilPrice.getPriceGun().subtract(gasOilPrice.getPreferentialMargin()); + gasOilPrice.setPriceVip(price.multiply(discount.divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_UP)); + gasOilPrice.setExt1(discount.toString()); + } + return ResponseMsgUtil.success(gasOilPriceList); } catch (Exception e) { log.error("HighGasDiscountOilPriceController -> getOilPriceListByStore() error!",e); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java index 223d1f26..1dea4a56 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java @@ -80,7 +80,7 @@ public class HighGasOilPriceTaskController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置执行时间"); } - // 价格类型 1. 国标价 2. 油站价 3. 优惠幅度 + // 价格类型 1. 国标价 2. 油站价 3. 平台优惠 4. 油站直降 if (task.getPriceType().equals(GasTaskPriceTypeEnum.type1.getStatus())) { if (task.getRegionId() == null) { log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); @@ -96,9 +96,11 @@ public class HighGasOilPriceTaskController { task.setRegionName(region.getRegionName()); } - // 价格类型 1. 国标价 2. 油站价 3. 优惠幅度 + // 价格类型 1. 国标价 2. 油站价 3. 平台优惠 4. 油站直降 if (task.getPriceType().equals(GasTaskPriceTypeEnum.type2.getStatus()) - || task.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { + || task.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus()) + || task.getPriceType().equals(GasTaskPriceTypeEnum.type4.getStatus()) + ) { if (task.getMerStoreId() == null) { log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); 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 00b5ceb4..bd6cfec8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -321,7 +321,7 @@ public class HighOrderController { childOrder.setGasOilLiters(priceModel.getOilLiters()); childOrder.setGasDiscount(priceModel.getDiscount()); childOrder.setExt1(priceModel.getPricePlatform().toString()); - childOrder.setGasOilSubsidy(priceModel.getOilSubsidy()); + childOrder.setGasOilSubsidy(priceModel.getPreferentialMargin()); childOrder.setGasLitersPreferences(priceModel.getLitersPreferences()); childOrder.setGasPricePreferences(priceModel.getPricePreferences()); diff --git a/hai-service/src/main/java/com/hai/config/ZkcPrinterTemplate.java b/hai-service/src/main/java/com/hai/config/ZkcPrinterTemplate.java index e08f798f..02a2a653 100644 --- a/hai-service/src/main/java/com/hai/config/ZkcPrinterTemplate.java +++ b/hai-service/src/main/java/com/hai/config/ZkcPrinterTemplate.java @@ -142,10 +142,10 @@ public class ZkcPrinterTemplate { stream.write("来源:嗨森逛".getBytes("UTF-8")); stream.write(0x0A); - stream.write(("油枪:" + gunNo).getBytes("UTF-8")); + stream.write(("油枪:" + gunNo + "号").getBytes("UTF-8")); stream.write(0x0A); - stream.write(("油品:" + oilNo).getBytes("UTF-8")); + stream.write(("油品:" + oilNo + "#").getBytes("UTF-8")); stream.write(0x0A); stream.write(("升数:" + oilLiters + "升").getBytes("UTF-8")); @@ -216,10 +216,10 @@ public class ZkcPrinterTemplate { stream.write("来源:嗨森逛".getBytes("UTF-8")); stream.write(0x0A); - stream.write(("油枪:" + gunNo).getBytes("UTF-8")); + stream.write(("油枪:" + gunNo + "号").getBytes("UTF-8")); stream.write(0x0A); - stream.write(("油品:" + oilNo).getBytes("UTF-8")); + stream.write(("油品:" + oilNo + "#").getBytes("UTF-8")); stream.write(0x0A); stream.write(("升数:" + oilLiters + "升").getBytes("UTF-8")); diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapper.java index 482c4dd4..41b38ac2 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapper.java @@ -41,16 +41,18 @@ public interface HighGasOilPriceMapper extends HighGasOilPriceMapperExt { @Insert({ "insert into high_gas_oil_price (merchant_store_id, oil_no, ", "oil_no_name, preferential_margin, ", - "price_vip, price_gun, ", - "price_official, oil_type, ", - "oil_type_name, `status`, ", - "ext_1, ext_2, ext_3)", + "gas_station_drop, price_vip, ", + "price_gun, price_official, ", + "oil_type, oil_type_name, ", + "`status`, ext_1, ext_2, ", + "ext_3)", "values (#{merchantStoreId,jdbcType=BIGINT}, #{oilNo,jdbcType=INTEGER}, ", "#{oilNoName,jdbcType=VARCHAR}, #{preferentialMargin,jdbcType=DECIMAL}, ", - "#{priceVip,jdbcType=DECIMAL}, #{priceGun,jdbcType=DECIMAL}, ", - "#{priceOfficial,jdbcType=DECIMAL}, #{oilType,jdbcType=INTEGER}, ", - "#{oilTypeName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{gasStationDrop,jdbcType=DECIMAL}, #{priceVip,jdbcType=DECIMAL}, ", + "#{priceGun,jdbcType=DECIMAL}, #{priceOfficial,jdbcType=DECIMAL}, ", + "#{oilType,jdbcType=INTEGER}, #{oilTypeName,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", + "#{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGasOilPrice record); @@ -66,6 +68,7 @@ public interface HighGasOilPriceMapper extends HighGasOilPriceMapperExt { @Result(column="oil_no", property="oilNo", jdbcType=JdbcType.INTEGER), @Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR), @Result(column="preferential_margin", property="preferentialMargin", jdbcType=JdbcType.DECIMAL), + @Result(column="gas_station_drop", property="gasStationDrop", jdbcType=JdbcType.DECIMAL), @Result(column="price_vip", property="priceVip", jdbcType=JdbcType.DECIMAL), @Result(column="price_gun", property="priceGun", jdbcType=JdbcType.DECIMAL), @Result(column="price_official", property="priceOfficial", jdbcType=JdbcType.DECIMAL), @@ -80,9 +83,9 @@ public interface HighGasOilPriceMapper extends HighGasOilPriceMapperExt { @Select({ "select", - "id, merchant_store_id, oil_no, oil_no_name, preferential_margin, price_vip, ", - "price_gun, price_official, oil_type, oil_type_name, `status`, ext_1, ext_2, ", - "ext_3", + "id, merchant_store_id, oil_no, oil_no_name, preferential_margin, gas_station_drop, ", + "price_vip, price_gun, price_official, oil_type, oil_type_name, `status`, ext_1, ", + "ext_2, ext_3", "from high_gas_oil_price", "where id = #{id,jdbcType=BIGINT}" }) @@ -92,6 +95,7 @@ public interface HighGasOilPriceMapper extends HighGasOilPriceMapperExt { @Result(column="oil_no", property="oilNo", jdbcType=JdbcType.INTEGER), @Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR), @Result(column="preferential_margin", property="preferentialMargin", jdbcType=JdbcType.DECIMAL), + @Result(column="gas_station_drop", property="gasStationDrop", jdbcType=JdbcType.DECIMAL), @Result(column="price_vip", property="priceVip", jdbcType=JdbcType.DECIMAL), @Result(column="price_gun", property="priceGun", jdbcType=JdbcType.DECIMAL), @Result(column="price_official", property="priceOfficial", jdbcType=JdbcType.DECIMAL), @@ -119,6 +123,7 @@ public interface HighGasOilPriceMapper extends HighGasOilPriceMapperExt { "oil_no = #{oilNo,jdbcType=INTEGER},", "oil_no_name = #{oilNoName,jdbcType=VARCHAR},", "preferential_margin = #{preferentialMargin,jdbcType=DECIMAL},", + "gas_station_drop = #{gasStationDrop,jdbcType=DECIMAL},", "price_vip = #{priceVip,jdbcType=DECIMAL},", "price_gun = #{priceGun,jdbcType=DECIMAL},", "price_official = #{priceOfficial,jdbcType=DECIMAL},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java index c1aa28b9..58c40e8f 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java @@ -49,11 +49,12 @@ public interface HighGasOilPriceMapperExt { " and a.region_id = #{regionId} " + " and b.oil_no = #{oilNo} "}) @Results({ - @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="merchant_store_id", property="merchantStoreId", jdbcType=JdbcType.BIGINT), @Result(column="oil_no", property="oilNo", jdbcType=JdbcType.INTEGER), @Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR), @Result(column="preferential_margin", property="preferentialMargin", jdbcType=JdbcType.DECIMAL), + @Result(column="gas_station_drop", property="gasStationDrop", jdbcType=JdbcType.DECIMAL), @Result(column="price_vip", property="priceVip", jdbcType=JdbcType.DECIMAL), @Result(column="price_gun", property="priceGun", jdbcType=JdbcType.DECIMAL), @Result(column="price_official", property="priceOfficial", jdbcType=JdbcType.DECIMAL), diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceSqlProvider.java index 8287ae2e..714766f9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceSqlProvider.java @@ -44,6 +44,10 @@ public class HighGasOilPriceSqlProvider { sql.VALUES("preferential_margin", "#{preferentialMargin,jdbcType=DECIMAL}"); } + if (record.getGasStationDrop() != null) { + sql.VALUES("gas_station_drop", "#{gasStationDrop,jdbcType=DECIMAL}"); + } + if (record.getPriceVip() != null) { sql.VALUES("price_vip", "#{priceVip,jdbcType=DECIMAL}"); } @@ -94,6 +98,7 @@ public class HighGasOilPriceSqlProvider { sql.SELECT("oil_no"); sql.SELECT("oil_no_name"); sql.SELECT("preferential_margin"); + sql.SELECT("gas_station_drop"); sql.SELECT("price_vip"); sql.SELECT("price_gun"); sql.SELECT("price_official"); @@ -140,6 +145,10 @@ public class HighGasOilPriceSqlProvider { sql.SET("preferential_margin = #{record.preferentialMargin,jdbcType=DECIMAL}"); } + if (record.getGasStationDrop() != null) { + sql.SET("gas_station_drop = #{record.gasStationDrop,jdbcType=DECIMAL}"); + } + if (record.getPriceVip() != null) { sql.SET("price_vip = #{record.priceVip,jdbcType=DECIMAL}"); } @@ -189,6 +198,7 @@ public class HighGasOilPriceSqlProvider { sql.SET("oil_no = #{record.oilNo,jdbcType=INTEGER}"); sql.SET("oil_no_name = #{record.oilNoName,jdbcType=VARCHAR}"); sql.SET("preferential_margin = #{record.preferentialMargin,jdbcType=DECIMAL}"); + sql.SET("gas_station_drop = #{record.gasStationDrop,jdbcType=DECIMAL}"); sql.SET("price_vip = #{record.priceVip,jdbcType=DECIMAL}"); sql.SET("price_gun = #{record.priceGun,jdbcType=DECIMAL}"); sql.SET("price_official = #{record.priceOfficial,jdbcType=DECIMAL}"); @@ -224,6 +234,10 @@ public class HighGasOilPriceSqlProvider { sql.SET("preferential_margin = #{preferentialMargin,jdbcType=DECIMAL}"); } + if (record.getGasStationDrop() != null) { + sql.SET("gas_station_drop = #{gasStationDrop,jdbcType=DECIMAL}"); + } + if (record.getPriceVip() != null) { sql.SET("price_vip = #{priceVip,jdbcType=DECIMAL}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOilPrice.java b/hai-service/src/main/java/com/hai/entity/HighGasOilPrice.java index 94f7c58c..202d2494 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOilPrice.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOilPrice.java @@ -34,10 +34,15 @@ public class HighGasOilPrice implements Serializable { private String oilNoName; /** - * 优惠幅度 + * 平台优惠 */ private BigDecimal preferentialMargin; + /** + * 油站直降 + */ + private BigDecimal gasStationDrop; + /** * 优惠价 */ @@ -116,6 +121,14 @@ public class HighGasOilPrice implements Serializable { this.preferentialMargin = preferentialMargin; } + public BigDecimal getGasStationDrop() { + return gasStationDrop; + } + + public void setGasStationDrop(BigDecimal gasStationDrop) { + this.gasStationDrop = gasStationDrop; + } + public BigDecimal getPriceVip() { return priceVip; } @@ -205,6 +218,7 @@ public class HighGasOilPrice implements Serializable { && (this.getOilNo() == null ? other.getOilNo() == null : this.getOilNo().equals(other.getOilNo())) && (this.getOilNoName() == null ? other.getOilNoName() == null : this.getOilNoName().equals(other.getOilNoName())) && (this.getPreferentialMargin() == null ? other.getPreferentialMargin() == null : this.getPreferentialMargin().equals(other.getPreferentialMargin())) + && (this.getGasStationDrop() == null ? other.getGasStationDrop() == null : this.getGasStationDrop().equals(other.getGasStationDrop())) && (this.getPriceVip() == null ? other.getPriceVip() == null : this.getPriceVip().equals(other.getPriceVip())) && (this.getPriceGun() == null ? other.getPriceGun() == null : this.getPriceGun().equals(other.getPriceGun())) && (this.getPriceOfficial() == null ? other.getPriceOfficial() == null : this.getPriceOfficial().equals(other.getPriceOfficial())) @@ -225,6 +239,7 @@ public class HighGasOilPrice implements Serializable { result = prime * result + ((getOilNo() == null) ? 0 : getOilNo().hashCode()); result = prime * result + ((getOilNoName() == null) ? 0 : getOilNoName().hashCode()); result = prime * result + ((getPreferentialMargin() == null) ? 0 : getPreferentialMargin().hashCode()); + result = prime * result + ((getGasStationDrop() == null) ? 0 : getGasStationDrop().hashCode()); result = prime * result + ((getPriceVip() == null) ? 0 : getPriceVip().hashCode()); result = prime * result + ((getPriceGun() == null) ? 0 : getPriceGun().hashCode()); result = prime * result + ((getPriceOfficial() == null) ? 0 : getPriceOfficial().hashCode()); @@ -248,6 +263,7 @@ public class HighGasOilPrice implements Serializable { sb.append(", oilNo=").append(oilNo); sb.append(", oilNoName=").append(oilNoName); sb.append(", preferentialMargin=").append(preferentialMargin); + sb.append(", gasStationDrop=").append(gasStationDrop); sb.append(", priceVip=").append(priceVip); sb.append(", priceGun=").append(priceGun); sb.append(", priceOfficial=").append(priceOfficial); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceExample.java index 82cf93ae..313cda7f 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceExample.java @@ -435,6 +435,66 @@ public class HighGasOilPriceExample { return (Criteria) this; } + public Criteria andGasStationDropIsNull() { + addCriterion("gas_station_drop is null"); + return (Criteria) this; + } + + public Criteria andGasStationDropIsNotNull() { + addCriterion("gas_station_drop is not null"); + return (Criteria) this; + } + + public Criteria andGasStationDropEqualTo(BigDecimal value) { + addCriterion("gas_station_drop =", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropNotEqualTo(BigDecimal value) { + addCriterion("gas_station_drop <>", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropGreaterThan(BigDecimal value) { + addCriterion("gas_station_drop >", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("gas_station_drop >=", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropLessThan(BigDecimal value) { + addCriterion("gas_station_drop <", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropLessThanOrEqualTo(BigDecimal value) { + addCriterion("gas_station_drop <=", value, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropIn(List values) { + addCriterion("gas_station_drop in", values, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropNotIn(List values) { + addCriterion("gas_station_drop not in", values, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("gas_station_drop between", value1, value2, "gasStationDrop"); + return (Criteria) this; + } + + public Criteria andGasStationDropNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("gas_station_drop not between", value1, value2, "gasStationDrop"); + return (Criteria) this; + } + public Criteria andPriceVipIsNull() { addCriterion("price_vip is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/enum_type/GasTaskPriceTypeEnum.java b/hai-service/src/main/java/com/hai/enum_type/GasTaskPriceTypeEnum.java index 50a9e1da..ffd69631 100644 --- a/hai-service/src/main/java/com/hai/enum_type/GasTaskPriceTypeEnum.java +++ b/hai-service/src/main/java/com/hai/enum_type/GasTaskPriceTypeEnum.java @@ -7,7 +7,8 @@ package com.hai.enum_type; public enum GasTaskPriceTypeEnum { type1(1 , "国标价"), type2(2 , "油站价"), - type3(3 , "优惠幅度"), + type3(3 , "平台优惠"), + type4(4 , "油站直降"), ; private Integer status; diff --git a/hai-service/src/main/java/com/hai/model/GasPayPriceModel.java b/hai-service/src/main/java/com/hai/model/GasPayPriceModel.java index fe408fa2..3807cb91 100644 --- a/hai-service/src/main/java/com/hai/model/GasPayPriceModel.java +++ b/hai-service/src/main/java/com/hai/model/GasPayPriceModel.java @@ -33,6 +33,16 @@ public class GasPayPriceModel { */ private BigDecimal pricePlatform; + /** + * 油站直降 + */ + private BigDecimal gasStationDrop; + + /** + * 平台补贴 + */ + private BigDecimal preferentialMargin; + /** * 加油升数,计算方式:加油金额 / 国标价 */ @@ -43,11 +53,6 @@ public class GasPayPriceModel { */ private BigDecimal discount; - /** - * 加油补贴, 计算方式:国标价-团油VIP价 - */ - private BigDecimal oilSubsidy; - /** * 每升优惠 */ @@ -68,6 +73,22 @@ public class GasPayPriceModel { */ private BigDecimal payPrice; + public BigDecimal getPreferentialMargin() { + return preferentialMargin; + } + + public void setPreferentialMargin(BigDecimal preferentialMargin) { + this.preferentialMargin = preferentialMargin; + } + + public BigDecimal getGasStationDrop() { + return gasStationDrop; + } + + public void setGasStationDrop(BigDecimal gasStationDrop) { + this.gasStationDrop = gasStationDrop; + } + public BigDecimal getOilingPrice() { return oilingPrice; } @@ -124,14 +145,6 @@ public class GasPayPriceModel { this.discount = discount; } - public BigDecimal getOilSubsidy() { - return oilSubsidy; - } - - public void setOilSubsidy(BigDecimal oilSubsidy) { - this.oilSubsidy = oilSubsidy; - } - public BigDecimal getLitersPreferences() { return litersPreferences; } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java index 5de5044a..9ec33687 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java @@ -134,27 +134,26 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri } } discount = discount.divide(new BigDecimal("100")); - // 枪价 - BigDecimal priceGun; - // 优惠价 - BigDecimal priceVip; - // 优惠幅度 - BigDecimal preferentialMargin = new BigDecimal("0"); // 查询油站价格 HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(goodsId, Integer.parseInt(oilNo)); if (gasOilPrice == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); } - priceGun = gasOilPrice.getPriceGun(); - priceVip = gasOilPrice.getPriceVip(); - preferentialMargin = gasOilPrice.getPreferentialMargin(); - // 国标价 BigDecimal priceOfficial = gasOilPrice.getPriceOfficial(); + // 油站价 + BigDecimal priceGun = gasOilPrice.getPriceGun(); + // 油站直降 + BigDecimal gasStationDrop = gasOilPrice.getGasStationDrop(); + // 油站优惠价 + BigDecimal priceVip = gasOilPrice.getPriceVip(); + // 平台优惠 + BigDecimal preferentialMargin = gasOilPrice.getPreferentialMargin(); GasPayPriceModel payPriceModel = new GasPayPriceModel(); + // 1:平台自建 2:团油 3: 壳牌 if (store.getSourceType().equals(1)) { // 嗨森逛平台价 国标价 * 折扣 @@ -163,15 +162,21 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri // 加油金额 payPriceModel.setOilingPrice(oilingPrice); - // 加油站枪价 + // 油站枪价 payPriceModel.setPriceGun(priceGun); - // 加油站优惠价 + // 油站优惠价 payPriceModel.setPriceVip(priceVip); - // 加油站国标价 + // 油站国标价 payPriceModel.setPriceOfficial(priceOfficial); + // 油站直降 + payPriceModel.setGasStationDrop(gasStationDrop); + + // 平台补贴 + payPriceModel.setPreferentialMargin(gasOilPrice.getPreferentialMargin()); + // 平台价 payPriceModel.setPricePlatform(pricePlatform); @@ -182,19 +187,19 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount); // 加油补贴, 计算方式:加油站枪价 - 加油站VIP价 - payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); + // payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); // 折扣,1 -平台折扣 BigDecimal decimal1 = new BigDecimal("1").subtract(discount); - // 油枪价 - 优惠幅度 + // 油枪价 - 平台补贴 BigDecimal price = payPriceModel.getPriceGun().subtract(preferentialMargin); - // 优惠价格 (油枪价 - 优惠幅度) * 系统折扣 + // 优惠价格 (油枪价 - 平台补贴) * 系统折扣 payPriceModel.setPricePreferences(price.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); // 每升优惠 枪价 - 优惠价格 - payPriceModel.setLitersPreferences(priceGun.subtract(payPriceModel.getPricePreferences())); + payPriceModel.setLitersPreferences(payPriceModel.getPriceOfficial().subtract(payPriceModel.getPricePreferences())); // 本次优惠 加油升数 * 每升优惠 payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); @@ -233,6 +238,12 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri // 团油国标价 payPriceModel.setPriceOfficial(priceOfficial); + // 油站直降 + payPriceModel.setGasStationDrop(gasStationDrop); + + // 平台补贴 + payPriceModel.setPreferentialMargin(gasOilPrice.getPreferentialMargin()); + // 平台价 payPriceModel.setPricePlatform(pricePlatform); @@ -243,7 +254,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount); // 加油补贴, 计算方式:团油枪价 - 团油VIP价 - payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); + // payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); // 折扣,1 -平台折扣 BigDecimal decimal1 = new BigDecimal("1").subtract(discount); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceOfficialServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceOfficialServiceImpl.java index 6472416e..d53fcbfd 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceOfficialServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceOfficialServiceImpl.java @@ -142,8 +142,8 @@ public class HighGasOilPriceOfficialServiceImpl implements HighGasOilPriceOffici List list = highGasOilPriceService.getPriceListByRegionAndOilNo(priceOfficial.getRegionId(), priceOfficial.getOilNo()); for (HighGasOilPrice gasOilPrice : list) { gasOilPrice.setPriceOfficial(priceOfficial.getPriceOfficial()); - gasOilPrice.setPriceGun(priceOfficial.getPriceOfficial()); - gasOilPrice.setPriceVip(priceOfficial.getPriceOfficial().subtract(gasOilPrice.getPreferentialMargin())); + gasOilPrice.setPriceGun(priceOfficial.getPriceOfficial().subtract(gasOilPrice.getGasStationDrop())); + gasOilPrice.setPriceVip(gasOilPrice.getPriceGun().subtract(gasOilPrice.getPreferentialMargin())); highGasOilPriceService.editGasOilPrice(gasOilPrice); } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java index c249563b..83be2968 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java @@ -98,6 +98,7 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic } gasOilPriceOfficialService.editPrice(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo(), gasOilPriceTask.getPrice()); + // 更新自建站的国标价 gasOilPriceOfficialService.refreshGasPriceOfficial(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo()); } @@ -108,12 +109,12 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic if (price == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); } - price.setPriceGun(gasOilPriceTask.getPrice()); - price.setPriceVip(gasOilPriceTask.getPrice().subtract(price.getPreferentialMargin())); + price.setPriceGun(gasOilPriceTask.getPrice().subtract(price.getGasStationDrop())); + price.setPriceVip(price.getPriceGun().subtract(price.getPreferentialMargin())); gasOilPriceService.editGasOilPrice(price); } - // 优惠幅度 + // 平台优惠 if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { // 查询油品价格 HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); @@ -125,6 +126,19 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic gasOilPriceService.editGasOilPrice(price); } + // 油站直降 + if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type4.getStatus())) { + // 查询油品价格 + HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); + if (price == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); + } + price.setGasStationDrop(gasOilPriceTask.getPrice()); + price.setPriceGun(price.getPriceOfficial().subtract(price.getGasStationDrop())); + price.setPriceVip(price.getPriceGun().subtract(price.getPreferentialMargin())); + gasOilPriceService.editGasOilPrice(price); + } + } @Override