parent
0f29439608
commit
c7fd02d5f4
@ -0,0 +1,112 @@ |
||||
package com.hai.openApi.model; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
|
||||
public class ApiGasOliPriceModel { |
||||
|
||||
/** |
||||
* 油号 |
||||
*/ |
||||
private String oilNo; |
||||
|
||||
/** |
||||
* 油品名称 |
||||
*/ |
||||
private String oilNoName; |
||||
|
||||
|
||||
/** |
||||
* 成本价 |
||||
*/ |
||||
private BigDecimal priceCost; |
||||
|
||||
/** |
||||
* 枪价 |
||||
*/ |
||||
private BigDecimal priceGun; |
||||
|
||||
/** |
||||
* 官方指导价 |
||||
*/ |
||||
private BigDecimal priceOfficial; |
||||
|
||||
/** |
||||
* 油品类型 1:汽油:2:柴油;3:天然气 |
||||
*/ |
||||
private Integer oilType; |
||||
|
||||
/** |
||||
* 燃油类型名 1:汽油:2:柴油;3:天然气 |
||||
*/ |
||||
private String oilTypeName; |
||||
|
||||
/** |
||||
* 油枪号数组 |
||||
*/ |
||||
private String[] gasOliNo; |
||||
|
||||
public String getOilNo() { |
||||
return oilNo; |
||||
} |
||||
|
||||
public void setOilNo(String oilNo) { |
||||
this.oilNo = oilNo; |
||||
} |
||||
|
||||
public String getOilNoName() { |
||||
return oilNoName; |
||||
} |
||||
|
||||
public void setOilNoName(String oilNoName) { |
||||
this.oilNoName = oilNoName; |
||||
} |
||||
|
||||
public BigDecimal getPriceCost() { |
||||
return priceCost; |
||||
} |
||||
|
||||
public void setPriceCost(BigDecimal priceCost) { |
||||
this.priceCost = priceCost; |
||||
} |
||||
|
||||
public BigDecimal getPriceGun() { |
||||
return priceGun; |
||||
} |
||||
|
||||
public void setPriceGun(BigDecimal priceGun) { |
||||
this.priceGun = priceGun; |
||||
} |
||||
|
||||
public BigDecimal getPriceOfficial() { |
||||
return priceOfficial; |
||||
} |
||||
|
||||
public void setPriceOfficial(BigDecimal priceOfficial) { |
||||
this.priceOfficial = priceOfficial; |
||||
} |
||||
|
||||
public Integer getOilType() { |
||||
return oilType; |
||||
} |
||||
|
||||
public void setOilType(Integer oilType) { |
||||
this.oilType = oilType; |
||||
} |
||||
|
||||
public String getOilTypeName() { |
||||
return oilTypeName; |
||||
} |
||||
|
||||
public void setOilTypeName(String oilTypeName) { |
||||
this.oilTypeName = oilTypeName; |
||||
} |
||||
|
||||
public String[] getGasOliNo() { |
||||
return gasOliNo; |
||||
} |
||||
|
||||
public void setGasOliNo(String[] gasOliNo) { |
||||
this.gasOliNo = gasOliNo; |
||||
} |
||||
} |
@ -0,0 +1,96 @@ |
||||
package com.hai.openApi.model; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class ApiMchStoreModel { |
||||
|
||||
// 区域名称
|
||||
private String regionName; |
||||
|
||||
// 门店logo
|
||||
private String storeLogo; |
||||
|
||||
// 门店编码
|
||||
private String storeCode; |
||||
|
||||
// 门店名称
|
||||
private String storeName; |
||||
|
||||
// 门店地址
|
||||
private String address; |
||||
|
||||
// 经度
|
||||
private String longitude; |
||||
|
||||
// 纬度
|
||||
/** |
||||
* 商户地址纬度 |
||||
*/ |
||||
private String latitude; |
||||
|
||||
private List<ApiGasOliPriceModel> apiGasOliPriceModels; |
||||
|
||||
public String getRegionName() { |
||||
return regionName; |
||||
} |
||||
|
||||
public void setRegionName(String regionName) { |
||||
this.regionName = regionName; |
||||
} |
||||
|
||||
public String getStoreLogo() { |
||||
return storeLogo; |
||||
} |
||||
|
||||
public void setStoreLogo(String storeLogo) { |
||||
this.storeLogo = storeLogo; |
||||
} |
||||
|
||||
public String getStoreCode() { |
||||
return storeCode; |
||||
} |
||||
|
||||
public void setStoreCode(String storeCode) { |
||||
this.storeCode = storeCode; |
||||
} |
||||
|
||||
public String getStoreName() { |
||||
return storeName; |
||||
} |
||||
|
||||
public void setStoreName(String storeName) { |
||||
this.storeName = storeName; |
||||
} |
||||
|
||||
public String getAddress() { |
||||
return address; |
||||
} |
||||
|
||||
public void setAddress(String address) { |
||||
this.address = address; |
||||
} |
||||
|
||||
public String getLongitude() { |
||||
return longitude; |
||||
} |
||||
|
||||
public void setLongitude(String longitude) { |
||||
this.longitude = longitude; |
||||
} |
||||
|
||||
public String getLatitude() { |
||||
return latitude; |
||||
} |
||||
|
||||
public void setLatitude(String latitude) { |
||||
this.latitude = latitude; |
||||
} |
||||
|
||||
public List<ApiGasOliPriceModel> getApiGasOliPriceModels() { |
||||
return apiGasOliPriceModels; |
||||
} |
||||
|
||||
public void setApiGasOliPriceModels(List<ApiGasOliPriceModel> apiGasOliPriceModels) { |
||||
this.apiGasOliPriceModels = apiGasOliPriceModels; |
||||
} |
||||
} |
@ -0,0 +1,137 @@ |
||||
package com.v1.controller; |
||||
|
||||
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.ResponseMsgUtil; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.openApi.model.ApiMchStoreModel; |
||||
import com.hai.openApi.service.ApiMchProductService; |
||||
import com.hai.order.type.OrderProductType; |
||||
import com.hai.service.ApiIpAddressService; |
||||
import com.hai.service.ApiMerchantsService; |
||||
import com.hai.service.HighMerchantStoreService; |
||||
import com.hai.service.SecConfigService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/refuelOnline") |
||||
@Api(value = "在线加油接口") |
||||
public class RefuelOnlineController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(RefuelOnlineController.class); |
||||
|
||||
@Resource |
||||
private ApiIpAddressService apiIpAddressService; |
||||
|
||||
@Resource |
||||
private ApiMerchantsService apiMerchantsService; |
||||
|
||||
@Resource |
||||
private SecConfigService secConfigService; |
||||
|
||||
@Resource |
||||
private ApiMchProductService apiMchProductService; |
||||
|
||||
@Resource |
||||
private HighMerchantStoreService highMerchantStoreService; |
||||
|
||||
@RequestMapping(value = "/getStationStores", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取油站门店") |
||||
public ResponseData getStationStores(@RequestBody JSONObject object , HttpServletRequest request ) { |
||||
try { |
||||
|
||||
String ip = ""; |
||||
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
||||
if (request.getHeader("x-forwarded-for") == null) { |
||||
ip = request.getRemoteAddr(); |
||||
} else { |
||||
ip = request.getHeader("x-forwarded-for"); |
||||
} |
||||
|
||||
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
||||
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(object.getString("apiKey")) || |
||||
StringUtils.isBlank(object.getString("merchId")) || |
||||
StringUtils.isBlank(object.getString("sign")) |
||||
) { |
||||
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
||||
} |
||||
|
||||
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
||||
|
||||
if (apiMerchants == null) { |
||||
log.error("getRechargeProduct error!", "帐户号错误!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
||||
} |
||||
|
||||
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE6.getApiCode(), object.getString("merchId"))) { |
||||
log.error("getAllCities error!", "当前帐户无权限查询!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
||||
} |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("apiKey" , object.getString("apiKey")); |
||||
map.put("merchId" , object.getString("merchId")); |
||||
|
||||
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
||||
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||
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<ApiMchProduct> apiMchProducts = apiMchProductService.getListMchProduct(mapProduct); |
||||
|
||||
Map<String, Object> mapMerchant; |
||||
List<HighMerchantStore> merchantStores = new ArrayList<>(); |
||||
|
||||
for (ApiMchProduct mchProduct : apiMchProducts) { |
||||
mapMerchant = new HashMap<>(); |
||||
mapMerchant.put("merchantId" , mchProduct.getMerchantId()); |
||||
merchantStores.addAll(highMerchantStoreService.getMerchantStoreList(mapMerchant)); |
||||
} |
||||
|
||||
List<ApiMchStoreModel> apiMchStoreModels = new ArrayList<>(); |
||||
|
||||
for (HighMerchantStore merchantStore : merchantStores) { |
||||
ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); |
||||
apiMchStoreModel.setAddress(merchantStore.getAddress()); |
||||
// apiMchStoreModel.setStore_logo();
|
||||
} |
||||
|
||||
return ResponseMsgUtil.success(merchantStores); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue