提交代码

dev-discount
胡锐 3 years ago
parent d3c4bb2680
commit 45acdc2ad9
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 154
      hai-cweb/src/main/java/com/cweb/controller/HighGasController.java
  3. 1
      hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java
  4. 147
      hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java

File diff suppressed because one or more lines are too long

@ -112,32 +112,72 @@ public class HighGasController {
PageInfo<Map<String, Object>> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance)); PageInfo<Map<String, Object>> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance));
for (Map<String, Object> map : mapPageInfo.getList()) { for (Map<String, Object> map : mapPageInfo.getList()) {
if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) { if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) {
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); if (MapUtils.getInteger(map, "source_type").equals(1)) {
if (tyAgentPrice != null) { // 查询是否配置了【油站的】优惠比例
// 优惠比例 / 100 = 最终优惠比例 HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no"));
BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); if (tyAgentPrice != null) {
// 油品国标价 * 最终优惠比例
map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例 // 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例 // 油枪价 - 优惠幅度
map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin")));
// (油枪价 - 优惠幅度) * 系统折扣
map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin")));
// (油枪价 - 优惠幅度) * 系统折扣
map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
} }
}
// 查询是否配置了【代理商】优惠比例 // 查询是否配置了【代理商】优惠比例
if (isTyAgent != null && isTyAgent == true) { if (isTyAgent != null && isTyAgent == true) {
HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no"));
if (agentPrice != null) { if (agentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin")));
// (油枪价 - 优惠幅度) * 系统折扣
map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
} else if (MapUtils.getInteger(map, "source_type").equals(2)) {
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no"));
if (tyAgentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例 // 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例 // 油品国标价 * 最终优惠比例
map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
// 查询是否配置了【代理商】优惠比例
if (isTyAgent != null && isTyAgent == true) {
HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no"));
if (agentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
} }
} }
} }
@ -271,6 +311,43 @@ public class HighGasController {
oilPriceMap.put("priceVip", oilPrice.getPriceVip()); oilPriceMap.put("priceVip", oilPrice.getPriceVip());
oilPriceMap.put("priceGun", oilPrice.getPriceGun()); oilPriceMap.put("priceGun", oilPrice.getPriceGun());
oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial()); oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial());
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), oilPrice.getOilNo().toString());
if (tyAgentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(oilPrice.getOilNo().toString());
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
// 查询是否配置了【代理商】优惠比例
if (isTyAgent != null && isTyAgent == true) {
HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), oilPrice.getOilNo().toString());
if (agentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
oilPriceMapList.add(oilPriceMap); oilPriceMapList.add(oilPriceMap);
} }
param.put("oilPriceList", oilPriceMapList); param.put("oilPriceList", oilPriceMapList);
@ -418,6 +495,43 @@ public class HighGasController {
oilPriceMap.put("priceVip", oilPrice.getPriceVip()); oilPriceMap.put("priceVip", oilPrice.getPriceVip());
oilPriceMap.put("priceGun", oilPrice.getPriceGun()); oilPriceMap.put("priceGun", oilPrice.getPriceGun());
oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial()); oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial());
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), oilPrice.getOilNo().toString());
if (tyAgentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
} else {
// 查询是否配置了【油品】优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(oilPrice.getOilNo().toString());
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
// 查询是否配置了【代理商】优惠比例
if (isTyAgent != null && isTyAgent == true) {
HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), oilPrice.getOilNo().toString());
if (agentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油枪价 - 优惠幅度
BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin());
// (油枪价 - 优惠幅度) * 系统折扣
oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
oilPriceMapList.add(oilPriceMap); oilPriceMapList.add(oilPriceMap);
} }
param.put("oilPriceList", oilPriceMapList); param.put("oilPriceList", oilPriceMapList);

@ -22,6 +22,7 @@ public interface HighGasOilPriceMapperExt {
" a.price_gun," + " a.price_gun," +
" a.price_vip," + " a.price_vip," +
" a.price_official," + " a.price_official," +
" a.preferential_margin," +
" b.* " + " b.* " +
" FROM" + " FROM" +
" high_gas_oil_price a," + " high_gas_oil_price a," +

@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -134,12 +135,74 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
} }
discount = discount.divide(new BigDecimal("100")); discount = discount.divide(new BigDecimal("100"));
// 枪价 // 枪价
BigDecimal priceGun = null; BigDecimal priceGun;
// 优惠价 // 优惠价
BigDecimal priceVip = null; BigDecimal priceVip;
// 优惠幅度
BigDecimal preferentialMargin = new BigDecimal("0");
// 来源类型 1:平台自建 2:团油 // 查询油站价格
if (store.getSourceType().equals(2)) { 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();
GasPayPriceModel payPriceModel = new GasPayPriceModel();
if (store.getSourceType().equals(1)) {
// 嗨森逛平台价 国标价 * 折扣
BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
// 加油金额
payPriceModel.setOilingPrice(oilingPrice);
// 加油站枪价
payPriceModel.setPriceGun(priceGun);
// 加油站优惠价
payPriceModel.setPriceVip(priceVip);
// 加油站国标价
payPriceModel.setPriceOfficial(priceOfficial);
// 平台价
payPriceModel.setPricePlatform(pricePlatform);
// 加油升数,计算方式:加油金额 / 枪价
payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN));
// 平台折扣,我们平台或者代理商设置的折扣
payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount);
// 加油补贴, 计算方式:加油站枪价 - 加油站VIP价
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.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN));
// 支付价格 加油金额 - 本次优惠
payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences()));
} else if (store.getSourceType().equals(2)) {
// 查询油站油品价格 // 查询油站油品价格
JSONObject oilPriceObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), oilNo); JSONObject oilPriceObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), oilNo);
if (oilPriceObject == null) { if (oilPriceObject == null) {
@ -154,66 +217,52 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
priceGun = priceDetail.getBigDecimal("priceGun"); priceGun = priceDetail.getBigDecimal("priceGun");
// 团油优惠价 // 团油优惠价
priceVip = priceDetail.getBigDecimal("priceVip"); priceVip = priceDetail.getBigDecimal("priceVip");
}
HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(goodsId, Integer.parseInt(oilNo));
if (gasOilPrice == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格");
}
if (priceGun == null) {
priceGun = gasOilPrice.getPriceGun();
}
if (priceVip == null) {
priceVip = gasOilPrice.getPriceVip();
}
// 团油国标价 // 嗨森逛平台价 国标价 * 折扣
BigDecimal priceOfficial = gasOilPrice.getPriceOfficial(); BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
// 嗨森逛平台价 国标价 * 折扣
BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
GasPayPriceModel payPriceModel = new GasPayPriceModel(); // 加油金额
// 加油金额 payPriceModel.setOilingPrice(oilingPrice);
payPriceModel.setOilingPrice(oilingPrice);
// 团油枪价 // 团油枪价
payPriceModel.setPriceGun(priceGun); payPriceModel.setPriceGun(priceGun);
// 团油优惠价
payPriceModel.setPriceVip(priceVip);
// 团油国标 // 团油优惠价
payPriceModel.setPriceOfficial(priceOfficial); payPriceModel.setPriceVip(priceVip);
// 平台 // 团油国标
payPriceModel.setPricePlatform(pricePlatform); payPriceModel.setPriceOfficial(priceOfficial);
// 加油升数,计算方式:加油金额 / 枪 // 平台
payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); payPriceModel.setPricePlatform(pricePlatform);
// 平台折扣,我们平台或者代理商设置的折扣 // 加油升数,计算方式:加油金额 / 枪价
payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("0") : discount); payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN));
// 加油补贴, 计算方式:团油枪价 - 团油VIP价 // 平台折扣,我们平台或者代理商设置的折扣
payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount);
// 折扣,1 -平台折扣 // 加油补贴, 计算方式:团油枪价 - 团油VIP价
BigDecimal decimal1 = new BigDecimal("1").subtract(discount); payPriceModel.setOilSubsidy(priceGun.subtract(priceVip));
// 价格差价 团油枪价 - 团油VIP价 // 折扣,1 -平台折扣
BigDecimal oilPriceDifferences = priceGun.subtract(priceVip); BigDecimal decimal1 = new BigDecimal("1").subtract(discount);
// 每升优惠 团油枪价 *(1-平台折扣)+(国标价-团油VIP价 ) // 价格差价 团油枪价 - 团油VIP价
payPriceModel.setLitersPreferences(priceGun.multiply(decimal1).setScale(2, BigDecimal.ROUND_HALF_UP).add(oilPriceDifferences)); BigDecimal oilPriceDifferences = priceGun.subtract(priceVip);
// 优惠价格 团油枪价 * 平台折扣 -(国标价-团油VIP价 ) // 每升优惠 团油枪价 *(1-平台折扣)+(国标价-团油VIP价 )
payPriceModel.setPricePreferences(pricePlatform.subtract(oilPriceDifferences)); payPriceModel.setLitersPreferences(priceGun.multiply(decimal1).setScale(2, BigDecimal.ROUND_HALF_UP).add(oilPriceDifferences));
// 本次优惠 // 优惠价格 团油枪价 * 平台折扣 -(国标价-团油VIP价 )
payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); payPriceModel.setPricePreferences(pricePlatform.subtract(oilPriceDifferences));
// 支付价格 // 本次优惠
payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN));
// 支付价格
payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences()));
}
return payPriceModel; return payPriceModel;
} }
} }

Loading…
Cancel
Save