Merge branch 'pre' into dev

dev-discount
胡锐 3 years ago
commit a6282477a6
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 114
      hai-cweb/src/main/java/com/cweb/controller/HighGasController.java
  3. 2
      hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java
  4. 1
      hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java
  5. 89
      hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java

File diff suppressed because one or more lines are too long

@ -112,6 +112,45 @@ public class HighGasController {
PageInfo<Map<String, Object>> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance));
for (Map<String, Object> map : mapPageInfo.getList()) {
if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) {
if (MapUtils.getInteger(map, "source_type").equals(1)) {
// 查询是否配置了【油站的】优惠比例
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no"));
if (tyAgentPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = tyAgentPrice.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 {
// 查询是否配置了【油品】优惠比例
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) {
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));
// 油枪价 - 优惠幅度
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) {
@ -142,6 +181,7 @@ public class HighGasController {
}
}
}
}
return ResponseMsgUtil.success(mapPageInfo);
}
@ -271,6 +311,43 @@ public class HighGasController {
oilPriceMap.put("priceVip", oilPrice.getPriceVip());
oilPriceMap.put("priceGun", oilPrice.getPriceGun());
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);
}
param.put("oilPriceList", oilPriceMapList);
@ -418,6 +495,43 @@ public class HighGasController {
oilPriceMap.put("priceVip", oilPrice.getPriceVip());
oilPriceMap.put("priceGun", oilPrice.getPriceGun());
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);
}
param.put("oilPriceList", oilPriceMapList);

@ -151,7 +151,7 @@ public class HighGasSchedule {
}
}
@Scheduled(cron = "0 1 7 * * ?") //每日7点1分执行一次
@Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次
public void refreshPriceOfficial() throws Exception {
gasOilPriceOfficialService.refreshPriceOfficial();

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

@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@ -134,12 +135,74 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
}
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);
if (oilPriceObject == null) {
@ -154,24 +217,10 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
priceGun = priceDetail.getBigDecimal("priceGun");
// 团油优惠价
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);
GasPayPriceModel payPriceModel = new GasPayPriceModel();
// 加油金额
payPriceModel.setOilingPrice(oilingPrice);
@ -191,7 +240,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN));
// 平台折扣,我们平台或者代理商设置的折扣
payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("0") : discount);
payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount);
// 加油补贴, 计算方式:团油枪价 - 团油VIP价
payPriceModel.setOilSubsidy(priceGun.subtract(priceVip));
@ -213,7 +262,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
// 支付价格
payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences()));
}
return payPriceModel;
}
}

Loading…
Cancel
Save