|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.utils.RedisUtil; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.entity.*; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
@ -60,12 +61,17 @@ public class RefuelOnlineController { |
|
|
|
|
@Resource |
|
|
|
|
private ApiCommonConfig apiCommonConfig; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getStationStore", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取油站门店") |
|
|
|
|
public ResponseData getStationStore(@RequestBody JSONObject object , HttpServletRequest request ) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ip = ""; |
|
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
|
@ -82,10 +88,10 @@ public class RefuelOnlineController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
|
// if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
|
|
|
|
|
// log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
|
|
|
|
|
|
|
|
@ -108,55 +114,64 @@ public class RefuelOnlineController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, Object> mapProduct = new HashMap<>(); |
|
|
|
|
mapProduct.put("mchId" , object.getString("merchId")); |
|
|
|
|
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE6.getNumber()); |
|
|
|
|
List<ApiMchStoreModel> apiMchStoreModels; |
|
|
|
|
|
|
|
|
|
List<ApiMchProduct> apiMchProducts = apiMchProductService.getListMchProduct(mapProduct); |
|
|
|
|
apiMchStoreModels = (List<ApiMchStoreModel>) redisUtil.get("stationStoreApi"); |
|
|
|
|
|
|
|
|
|
Map<String, Object> mapMerchant = new HashMap<>();; |
|
|
|
|
Map<Long, BigDecimal> discountMap = new HashMap<>(); |
|
|
|
|
List<HighMerchantStore> merchantStores = new ArrayList<>(); |
|
|
|
|
if (apiMchStoreModels == null) { |
|
|
|
|
apiMchStoreModels = new ArrayList<>(); |
|
|
|
|
Map<String, Object> mapProduct = new HashMap<>(); |
|
|
|
|
mapProduct.put("mchId" , object.getString("merchId")); |
|
|
|
|
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE6.getNumber()); |
|
|
|
|
|
|
|
|
|
for (ApiMchProduct mchProduct : apiMchProducts) { |
|
|
|
|
mapMerchant.put("merchantId" , mchProduct.getMerchantId()); |
|
|
|
|
discountMap.put(mchProduct.getMerchantId() , mchProduct.getDiscount()); |
|
|
|
|
merchantStores.addAll(highMerchantStoreService.getMerchantStoreList(mapMerchant)); |
|
|
|
|
} |
|
|
|
|
List<ApiMchProduct> apiMchProducts = apiMchProductService.getListMchProduct(mapProduct); |
|
|
|
|
|
|
|
|
|
Map<String, Object> mapMerchant = new HashMap<>();; |
|
|
|
|
Map<Long, BigDecimal> discountMap = new HashMap<>(); |
|
|
|
|
List<HighMerchantStore> merchantStores = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (ApiMchProduct mchProduct : apiMchProducts) { |
|
|
|
|
mapMerchant.put("merchantId" , mchProduct.getMerchantId()); |
|
|
|
|
discountMap.put(mchProduct.getMerchantId() , mchProduct.getDiscount()); |
|
|
|
|
merchantStores.addAll(highMerchantStoreService.getMerchantStoreList(mapMerchant)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<ApiMchStoreModel> apiMchStoreModels = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (HighMerchantStore merchantStore : merchantStores) { |
|
|
|
|
ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); |
|
|
|
|
apiMchStoreModel.setAddress(merchantStore.getAddress()); |
|
|
|
|
apiMchStoreModel.setStoreCode(merchantStore.getId().toString()); |
|
|
|
|
apiMchStoreModel.setLatitude(merchantStore.getLatitude()); |
|
|
|
|
apiMchStoreModel.setLongitude(merchantStore.getLongitude()); |
|
|
|
|
apiMchStoreModel.setStoreName(merchantStore.getStoreName()); |
|
|
|
|
apiMchStoreModel.setRegionName(merchantStore.getRegionName()); |
|
|
|
|
|
|
|
|
|
List<HighGasOilPrice> gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId()); |
|
|
|
|
for (HighMerchantStore merchantStore : merchantStores) { |
|
|
|
|
ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); |
|
|
|
|
apiMchStoreModel.setAddress(merchantStore.getAddress()); |
|
|
|
|
apiMchStoreModel.setStoreCode(merchantStore.getId().toString()); |
|
|
|
|
apiMchStoreModel.setLatitude(merchantStore.getLatitude()); |
|
|
|
|
apiMchStoreModel.setLongitude(merchantStore.getLongitude()); |
|
|
|
|
apiMchStoreModel.setStoreName(merchantStore.getStoreName()); |
|
|
|
|
apiMchStoreModel.setRegionName(merchantStore.getRegionName()); |
|
|
|
|
|
|
|
|
|
List<HighGasOilPrice> gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId()); |
|
|
|
|
|
|
|
|
|
List<ApiGasOliPriceModel> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (HighGasOilPrice gasOilPrice : gasOilPrices) { |
|
|
|
|
ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel(); |
|
|
|
|
gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(discountMap.get(merchantStore.getMerchantId()), gasOilPrice.getPriceGun())); |
|
|
|
|
gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun()); |
|
|
|
|
gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial()); |
|
|
|
|
gasOliPriceModel.setOilNo(gasOilPrice.getOilNo()); |
|
|
|
|
gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName()); |
|
|
|
|
gasOliPriceModel.setOilType(gasOilPrice.getOilType()); |
|
|
|
|
gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName()); |
|
|
|
|
gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId())); |
|
|
|
|
list.add(gasOliPriceModel); |
|
|
|
|
List<ApiGasOliPriceModel> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (HighGasOilPrice gasOilPrice : gasOilPrices) { |
|
|
|
|
ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel(); |
|
|
|
|
gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(discountMap.get(merchantStore.getMerchantId()), gasOilPrice.getPriceGun())); |
|
|
|
|
gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun()); |
|
|
|
|
gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial()); |
|
|
|
|
gasOliPriceModel.setOilNo(gasOilPrice.getOilNo()); |
|
|
|
|
gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName()); |
|
|
|
|
gasOliPriceModel.setOilType(gasOilPrice.getOilType()); |
|
|
|
|
gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName()); |
|
|
|
|
gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId())); |
|
|
|
|
list.add(gasOliPriceModel); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
apiMchStoreModel.setApiGasOliPriceModels(list); |
|
|
|
|
apiMchStoreModels.add(apiMchStoreModel); |
|
|
|
|
} |
|
|
|
|
apiMchStoreModel.setApiGasOliPriceModels(list); |
|
|
|
|
apiMchStoreModels.add(apiMchStoreModel); |
|
|
|
|
redisUtil.set("stationStoreApi", apiMchStoreModels); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(apiMchStoreModels); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|