提交代码

dev-discount
胡锐 3 years ago
parent ebf80a679e
commit f4cff23bb8
  1. 56
      hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceController.java

@ -7,19 +7,14 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighGasDiscountOilPrice; import com.hai.entity.*;
import com.hai.entity.HighGasOilPrice;
import com.hai.entity.HighMerchantStore;
import com.hai.entity.SecDictionary;
import com.hai.enum_type.MerchantStoreSourceType; import com.hai.enum_type.MerchantStoreSourceType;
import com.hai.model.HighMerchantStoreModel; import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.CommonService; import com.hai.service.*;
import com.hai.service.HighGasDiscountOilPriceService;
import com.hai.service.HighGasOilPriceService;
import com.hai.service.HighMerchantStoreService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -42,6 +37,9 @@ public class HighGasOilPriceController {
@Resource @Resource
private HighGasOilPriceService gasOilPriceService; private HighGasOilPriceService gasOilPriceService;
@Resource
private HighGasOilPriceOfficialService gasOilPriceOfficialService;
@Resource @Resource
private HighMerchantStoreService merchantStoreService; private HighMerchantStoreService merchantStoreService;
@ -54,7 +52,7 @@ public class HighGasOilPriceController {
public ResponseData editGasOilPrice(@RequestBody JSONObject body) { public ResponseData editGasOilPrice(@RequestBody JSONObject body) {
try { try {
if (body.getLong("storeId") == null if (body.getLong("storeId") == null
|| StringUtils.isBlank(body.getString("oilNo")) || body.getInteger("oilNo") == null
|| body.getBigDecimal("priceGun") == null || body.getBigDecimal("priceGun") == null
|| body.getBigDecimal("preferentialMargin") == null || body.getBigDecimal("preferentialMargin") == null
) { ) {
@ -88,7 +86,13 @@ public class HighGasOilPriceController {
price.setPriceVip(body.getBigDecimal("priceGun").subtract(body.getBigDecimal("preferentialMargin"))); price.setPriceVip(body.getBigDecimal("priceGun").subtract(body.getBigDecimal("preferentialMargin")));
price.setPreferentialMargin(body.getBigDecimal("preferentialMargin")); price.setPreferentialMargin(body.getBigDecimal("preferentialMargin"));
price.setPriceGun(body.getBigDecimal("priceGun")); price.setPriceGun(body.getBigDecimal("priceGun"));
price.setPriceOfficial(new BigDecimal("8"));
// 查询国标价格
HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), body.getInteger("oilNo"));
if (priceOfficial != null) {
price.setPriceOfficial(priceOfficial.getPriceOfficial());
}
price.setOilType(Integer.parseInt(oilNo.getExt1())); price.setOilType(Integer.parseInt(oilNo.getExt1()));
price.setOilTypeName(oilNo.getExt2()); price.setOilTypeName(oilNo.getExt2());
gasOilPriceService.editGasOilPrice(price); gasOilPriceService.editGasOilPrice(price);
@ -128,6 +132,38 @@ public class HighGasOilPriceController {
} }
} }
@RequestMapping(value="/getOilPriceDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询油品价格详情")
public ResponseData getOilPriceDetail(@RequestParam(name = "storeId", required = true) Long storeId,
@RequestParam(name = "oilNo", required = true) Integer oilNo) {
try {
// 查询门店详情
HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(storeId);
if (store == null) {
log.error("HighGasDiscountOilPriceController -> editGasOilPrice() error!","未找到门店");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店");
}
// 查询价格
HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(storeId, oilNo);
if (gasOilPrice == null) {
gasOilPrice = new HighGasOilPrice();
// 查询国标价格
HighGasOilPriceOfficial priceOfficial = gasOilPriceOfficialService.getPrice(store.getRegionId(), oilNo);
if (priceOfficial != null) {
gasOilPrice.setPriceOfficial(priceOfficial.getPriceOfficial());
}
}
return ResponseMsgUtil.success(gasOilPrice);
} catch (Exception e) {
log.error("HighGasDiscountOilPriceController -> getGasDetailByStoreKey() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getOilPriceListByStore",method = RequestMethod.GET) @RequestMapping(value="/getOilPriceListByStore",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询油品价格列表") @ApiOperation(value = "查询油品价格列表")

Loading…
Cancel
Save