'提交代码'

dev-discount
= 3 years ago
parent ec607f9a74
commit 3a6731b204
  1. 19
      hai-cweb/src/main/java/com/cweb/controller/HighGasController.java
  2. 34
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 2
      hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java

@ -24,6 +24,7 @@ import com.hai.service.HighGasOilPriceService;
import com.hai.service.HighOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -87,7 +88,21 @@ public class HighGasController {
iterator.remove();
}
}
return ResponseMsgUtil.success(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()) {
if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) {
// 查询是否配置了优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.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_official")).multiply(priceRate).setScale(1, BigDecimal.ROUND_DOWN));
}
}
}
return ResponseMsgUtil.success(mapPageInfo);
}
return ResponseMsgUtil.success(new PageInfo<>());
} catch (Exception e) {
@ -117,7 +132,7 @@ public class HighGasController {
for (Object oilPriceObject : originalOilPriceList) {
JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class);
// 查询是否配置了优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNoName(price.getString("oilNoName"));
HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNo(price.getString("oilNo"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));

@ -169,7 +169,7 @@ public class HighOrderController {
}
if (childOrder.getGoodsType() == 3) {
if (childOrder.getGoodsPrice() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) {
if (childOrder.getGoodsPrice() == null || childOrder.getGasPriceGun() == null || childOrder.getGasPriceVip() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) {
log.error("HighOrderController --> addOrder() error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
@ -180,33 +180,8 @@ public class HighOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息");
}
highOrder.setPayType(2); // 第三方平台
// 获取当前加油价格
JSONObject jsonObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), childOrder.getGasOilNo());
if (jsonObject == null || !jsonObject.getString("code").equals("200")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格");
}
if(jsonObject.getJSONArray("result").size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格");
}
/* // 处理油品价格
for (Object oilPriceObject : originalOilPriceList) {
JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class);
// 查询是否配置了优惠比例
HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNoName(price.getString("oilNoName"));
if (gasDiscountOilPrice != null) {
// 优惠比例 / 100 = 最终优惠比例
BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN));
// 油品国标价 * 最终优惠比例
price.put("priceVip", price.getBigDecimal("priceOfficial").multiply(priceRate).setScale(1, BigDecimal.ROUND_DOWN));
}
newOilPriceList.add(price);
}*/
JSONObject priceDetail = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.getJSONArray("result").get(0)), JSONObject.class);
childOrder.setGoodsName(store.getStoreName());
childOrder.setGoodsImg(store.getStoreLogo());
childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun"));
childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip"));
childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP));
childOrder.setGoodsSpecName("默认");
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
@ -431,4 +406,11 @@ public class HighOrderController {
return ResponseMsgUtil.exception(e);
}
}
/*
public static void main(String[] args) {
BigDecimal bigDecimal1 = new BigDecimal("1200").divide(new BigDecimal("5.58"), 10, BigDecimal.ROUND_DOWN);
System.out.println(bigDecimal1);
BigDecimal bigDecimal2 = bigDecimal1.multiply(new BigDecimal("5.40")).setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println(bigDecimal2);
}*/
}

@ -14,8 +14,10 @@ public interface HighGasOilPriceMapperExt {
@Select("<script>" +
" SELECT" +
" a.oil_no_name," +
" a.oil_no," +
" a.price_gun," +
" a.price_vip," +
" a.price_official," +
" b.* " +
" FROM" +
" high_gas_oil_price a," +

Loading…
Cancel
Save