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 aba846eb..27984cd4 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -20,6 +20,7 @@ import com.hai.config.TuanYouConfig; import com.hai.entity.*; import com.hai.enum_type.DiscountUseScope; import com.hai.enum_type.GasClassGroupTaskStatus; +import com.hai.enum_type.MerAccountMarketingType; import com.hai.enum_type.OrderChildGoodsTypeEnum; import com.hai.model.GasPayPriceModel; import com.hai.model.HighMerchantStoreModel; @@ -322,7 +323,7 @@ public class HighOrderController { } // 营销减免的金额 - BigDecimal marketingPrice = merchantAccountMarketingService.getPrice(store.getMerchantId(), 1, Integer.valueOf(childOrder.getGasOilNo())); + BigDecimal marketingPrice = merchantAccountMarketingService.getPrice(store.getMerchantId(), MerAccountMarketingType.type3.getType(), Integer.valueOf(childOrder.getGasOilNo())); // 计算价格 GasPayPriceModel priceModel = gasDiscountOilPriceService.oilPriceDiscountCompute(childOrder.getGoodsPrice(), childOrder.getGoodsId(), childOrder.getGasOilNo(), highOrder.getIsTyAgent()); @@ -366,11 +367,17 @@ public class HighOrderController { childOrder.setGoodsImg(store.getStoreLogo()); } - childOrder.setGasPriceCost(priceModel.getPriceGun().subtract(marketingPrice)); - childOrder.setGasPriceCostTotal(childOrder.getGasPriceCost().multiply(childOrder.getGasOilLiters()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); childOrder.setGoodsName(store.getStoreName()); childOrder.setGoodsSpecName("默认"); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); + + // 成本价 油站价 减 营销策略价 + childOrder.setGasPriceCost(priceModel.getPriceGun().subtract(marketingPrice)); + if (marketingPrice.compareTo(new BigDecimal("0")) <= 0) { + childOrder.setGasPriceCostTotal(childOrder.getTotalPrice()); + } else { + childOrder.setGasPriceCostTotal(childOrder.getGasPriceCost().multiply(childOrder.getGasOilLiters()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); + } } if (childOrder.getGoodsType() == 7) { diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantAccountMarketingService.java b/hai-service/src/main/java/com/hai/service/HighMerchantAccountMarketingService.java index f4b6c708..5145d13a 100644 --- a/hai-service/src/main/java/com/hai/service/HighMerchantAccountMarketingService.java +++ b/hai-service/src/main/java/com/hai/service/HighMerchantAccountMarketingService.java @@ -15,6 +15,12 @@ public interface HighMerchantAccountMarketingService { */ void insert(HighMerchantAccountMarketing merchantAccountMarketing); + /** + * 修改 + * @param merchantAccountMarketing + */ + void update(HighMerchantAccountMarketing merchantAccountMarketing); + /** * 查询详情 * @param merId diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountMarketingServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountMarketingServiceImpl.java index 81d77eca..90fc1e52 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountMarketingServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountMarketingServiceImpl.java @@ -28,6 +28,12 @@ public class HighMerchantAccountMarketingServiceImpl implements HighMerchantAcco marketingMapper.insert(merchantAccountMarketing); } + @Override + public void update(HighMerchantAccountMarketing merchantAccountMarketing) { + merchantAccountMarketing.setUpdateTime(new Date()); + marketingMapper.updateByPrimaryKeySelective(merchantAccountMarketing); + } + @Override public HighMerchantAccountMarketing getDetailByMerAndType(Long merId, Integer type) { HighMerchantAccountMarketingExample example = new HighMerchantAccountMarketingExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java index 3b38af5f..8f94b9ba 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java @@ -103,13 +103,20 @@ public class HighMerchantAccountServiceImpl implements HighMerchantAccountServic } if (MapUtils.getInteger(marketingParam, "marketingType").equals(MerAccountMarketingType.type3.getType())) { - HighMerchantAccountMarketing accountMarketing = new HighMerchantAccountMarketing(); - accountMarketing.setType(MerAccountMarketingType.type3.getType()); - accountMarketing.setMerId(merId); - accountMarketing.setMerAccountId(account.getId()); - JSONArray oilNoData = (JSONArray) marketingParam.get("marketingOilNoData"); - accountMarketing.setOilNoReliefPrice(oilNoData.toJSONString()); - marketingService.insert(accountMarketing); + HighMerchantAccountMarketing accountMarketing = marketingService.getDetailByMerAndType(merId, MerAccountMarketingType.type3.getType()); + if (accountMarketing == null) { + accountMarketing = new HighMerchantAccountMarketing(); + accountMarketing.setType(MerAccountMarketingType.type3.getType()); + accountMarketing.setMerId(merId); + accountMarketing.setMerAccountId(account.getId()); + JSONArray oilNoData = (JSONArray) marketingParam.get("marketingOilNoData"); + accountMarketing.setOilNoReliefPrice(oilNoData.toJSONString()); + marketingService.insert(accountMarketing); + } else { + JSONArray oilNoData = (JSONArray) marketingParam.get("marketingOilNoData"); + accountMarketing.setOilNoReliefPrice(oilNoData.toJSONString()); + marketingService.update(accountMarketing); + } } }