|
|
|
@ -4,10 +4,13 @@ import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
|
import com.hai.config.JinZhuJiaYouService; |
|
|
|
|
import com.hai.config.ShellGroupService; |
|
|
|
|
import com.hai.entity.HighGasOilGunNo; |
|
|
|
|
import com.hai.entity.HighGasOilPrice; |
|
|
|
|
import com.hai.entity.HighMerchantStore; |
|
|
|
|
import com.hai.entity.SecRegion; |
|
|
|
|
import com.hai.enum_type.JinZhuJiaYouOilNo; |
|
|
|
|
import com.hai.enum_type.MerchantStoreSourceType; |
|
|
|
|
import com.hai.model.HighMerchantModel; |
|
|
|
|
import com.hai.model.HighMerchantStoreModel; |
|
|
|
@ -25,6 +28,9 @@ public class HighGasServiceImpl implements HighGasService { |
|
|
|
|
@Resource |
|
|
|
|
private ShellGroupService shellGroupService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private JinZhuJiaYouService jinZhuJiaYouService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighMerchantService highMerchantService; |
|
|
|
|
|
|
|
|
@ -37,6 +43,9 @@ public class HighGasServiceImpl implements HighGasService { |
|
|
|
|
@Resource |
|
|
|
|
private HighGasOilGunNoService gasOilGunNoService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private CommonService commonService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void getJiaHaoYouAllStation() throws Exception { |
|
|
|
|
HighMerchantModel merchant = highMerchantService.getDetailByKey("HF0801103821"); |
|
|
|
@ -229,4 +238,177 @@ public class HighGasServiceImpl implements HighGasService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void getJinZhuAllStation() throws Exception { |
|
|
|
|
HighMerchantModel merchant = highMerchantService.getDetailByKey("HF0802153624"); |
|
|
|
|
|
|
|
|
|
JSONObject pageInfo = jinZhuJiaYouService.getStationListPage(0, 50).getJSONObject("data"); |
|
|
|
|
|
|
|
|
|
// 总页数
|
|
|
|
|
for (int pageNum = 0; pageNum < pageInfo.getInteger("totalPages"); pageNum++) { |
|
|
|
|
// 查询加油站列表
|
|
|
|
|
JSONObject respObject = jinZhuJiaYouService.getStationListPage(pageNum, 50).getJSONObject("data"); |
|
|
|
|
JSONArray stationArray = respObject.getJSONArray("content"); |
|
|
|
|
|
|
|
|
|
for (Object stationObject : stationArray) { |
|
|
|
|
JSONObject station = (JSONObject) stationObject; |
|
|
|
|
|
|
|
|
|
// 查询油站
|
|
|
|
|
HighMerchantStore store = highMerchantStoreService.getMerStoreDetailByKey(station.getString("code")); |
|
|
|
|
|
|
|
|
|
// 查询区域
|
|
|
|
|
SecRegion region = commonService.getRegionsById(station.getLong("provinceId")); |
|
|
|
|
|
|
|
|
|
if (store != null) { |
|
|
|
|
store.setPrestoreType(0); |
|
|
|
|
store.setMerchantId(merchant.getId()); |
|
|
|
|
store.setCompanyId(merchant.getCompanyId()); |
|
|
|
|
store.setStoreKey(station.getString("code")); |
|
|
|
|
store.setStoreName(station.getString("name")); |
|
|
|
|
store.setStoreLogo(CommonSysConst.getSysConfig().getGasDefaultOilStationImg()); |
|
|
|
|
store.setRegionId(station.getLong("provinceId")); |
|
|
|
|
store.setRegionName(region!=null?region.getRegionName():null); |
|
|
|
|
store.setAddress(station.getString("address")); |
|
|
|
|
store.setLongitude(station.getString("longitude")); |
|
|
|
|
store.setLatitude(station.getString("latitude")); |
|
|
|
|
store.setStatus(station.getString("status").equals("VALID")?1:2); |
|
|
|
|
store.setOperatorId(0L); |
|
|
|
|
store.setOperatorName("系统创建"); |
|
|
|
|
store.setUpdateTime(new Date()); |
|
|
|
|
highMerchantStoreService.updateMerchantStoreDetail(store); |
|
|
|
|
|
|
|
|
|
JSONArray oilPriceList = station.getJSONArray("oils"); |
|
|
|
|
for (Object oilPrice : oilPriceList) { |
|
|
|
|
JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); |
|
|
|
|
|
|
|
|
|
// 查询油号
|
|
|
|
|
JinZhuJiaYouOilNo oilNo = JinZhuJiaYouOilNo.getDataByCode(oilPriceObject.getString("oilNo")); |
|
|
|
|
if (oilNo != null) { |
|
|
|
|
// 查询门店油号
|
|
|
|
|
HighGasOilPrice highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilNo.getOilNo()); |
|
|
|
|
if (highGasOilPrice == null) { |
|
|
|
|
highGasOilPrice = new HighGasOilPrice(); |
|
|
|
|
highGasOilPrice.setMerchantStoreId(store.getId()); |
|
|
|
|
highGasOilPrice.setOilType(oilNo!=null?oilNo.getOilType():null); |
|
|
|
|
highGasOilPrice.setOilTypeName(oilNo!=null?oilNo.getOilTypeName():null); |
|
|
|
|
highGasOilPrice.setOilNo(oilNo!=null?oilNo.getOilNo():null); |
|
|
|
|
highGasOilPrice.setOilNoName(oilNo!=null?oilNo.getOilNoName():null); |
|
|
|
|
|
|
|
|
|
highGasOilPrice.setPreferentialMargin(new BigDecimal("0")); |
|
|
|
|
highGasOilPrice.setGasStationDrop(oilPriceObject.getBigDecimal("guidancePrice").subtract(oilPriceObject.getBigDecimal("listingPrice"))); |
|
|
|
|
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("merchantStrikePrice")); |
|
|
|
|
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("listingPrice")); |
|
|
|
|
highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("guidancePrice")); |
|
|
|
|
highGasOilPriceService.editGasOilPrice(highGasOilPrice); |
|
|
|
|
|
|
|
|
|
JSONArray oilGunNoList = oilPriceObject.getJSONArray("guns"); |
|
|
|
|
for (Object o : oilGunNoList) { |
|
|
|
|
HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), Integer.parseInt(o.toString())); |
|
|
|
|
if (gasOilGunNo == null) { |
|
|
|
|
gasOilGunNo = new HighGasOilGunNo(); |
|
|
|
|
gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); |
|
|
|
|
gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); |
|
|
|
|
gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); |
|
|
|
|
gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); |
|
|
|
|
gasOilGunNo.setOilType(highGasOilPrice.getOilType()); |
|
|
|
|
gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); |
|
|
|
|
gasOilGunNo.setGunNo(Integer.parseInt(o.toString())); |
|
|
|
|
gasOilGunNo.setStatus(1); |
|
|
|
|
gasOilGunNoService.editGunNo(gasOilGunNo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
highGasOilPrice.setGasStationDrop(oilPriceObject.getBigDecimal("guidancePrice").subtract(oilPriceObject.getBigDecimal("listingPrice"))); |
|
|
|
|
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("merchantStrikePrice")); |
|
|
|
|
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("listingPrice")); |
|
|
|
|
highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("guidancePrice")); |
|
|
|
|
highGasOilPriceService.editGasOilPrice(highGasOilPrice); |
|
|
|
|
|
|
|
|
|
JSONArray oilGunNoList = oilPriceObject.getJSONArray("guns"); |
|
|
|
|
for (Object o : oilGunNoList) { |
|
|
|
|
HighGasOilGunNo gasOilGunNo = gasOilGunNoService.getDetailByStoreAndGunNo(highGasOilPrice.getMerchantStoreId(), Integer.parseInt(o.toString())); |
|
|
|
|
if (gasOilGunNo == null) { |
|
|
|
|
gasOilGunNo = new HighGasOilGunNo(); |
|
|
|
|
gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); |
|
|
|
|
gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); |
|
|
|
|
gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); |
|
|
|
|
gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); |
|
|
|
|
gasOilGunNo.setOilType(highGasOilPrice.getOilType()); |
|
|
|
|
gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); |
|
|
|
|
gasOilGunNo.setGunNo(Integer.parseInt(o.toString())); |
|
|
|
|
gasOilGunNo.setStatus(1); |
|
|
|
|
gasOilGunNoService.editGunNo(gasOilGunNo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
store = new HighMerchantStore(); |
|
|
|
|
store.setPrestoreType(0); |
|
|
|
|
store.setType(1); |
|
|
|
|
store.setSourceType(MerchantStoreSourceType.type4.getNumber()); |
|
|
|
|
store.setMerchantId(merchant.getId()); |
|
|
|
|
store.setCompanyId(merchant.getCompanyId()); |
|
|
|
|
store.setStoreKey(station.getString("code")); |
|
|
|
|
store.setStoreName(station.getString("name")); |
|
|
|
|
store.setStoreLogo(CommonSysConst.getSysConfig().getGasDefaultOilStationImg()); |
|
|
|
|
store.setRegionId(station.getLong("provinceId")); |
|
|
|
|
store.setRegionName(station.getString("provinceName")); |
|
|
|
|
store.setAddress(station.getString("address")); |
|
|
|
|
store.setLongitude(station.getString("longitude")); |
|
|
|
|
store.setLatitude(station.getString("latitude")); |
|
|
|
|
store.setStatus(station.getString("status").equals("VALID")?1:2); |
|
|
|
|
store.setOperatorId(0L); |
|
|
|
|
store.setOperatorName("系统创建"); |
|
|
|
|
store.setCreateTime(new Date()); |
|
|
|
|
store.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
|
|
HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); |
|
|
|
|
BeanUtils.copyProperties(store, merchantStoreModel); |
|
|
|
|
highMerchantStoreService.insertMerchantStore(merchantStoreModel); |
|
|
|
|
|
|
|
|
|
JSONArray oilPriceList = station.getJSONArray("oils"); |
|
|
|
|
for (Object oilPrice : oilPriceList) { |
|
|
|
|
JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); |
|
|
|
|
|
|
|
|
|
// 查询油号
|
|
|
|
|
JinZhuJiaYouOilNo oilNo = JinZhuJiaYouOilNo.getDataByCode(oilPriceObject.getString("oilNo")); |
|
|
|
|
|
|
|
|
|
HighGasOilPrice highGasOilPrice = new HighGasOilPrice(); |
|
|
|
|
highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); |
|
|
|
|
highGasOilPrice.setOilType(oilNo!=null?oilNo.getOilType():null); |
|
|
|
|
highGasOilPrice.setOilTypeName(oilNo!=null?oilNo.getOilTypeName():null); |
|
|
|
|
highGasOilPrice.setOilNo(oilNo!=null?oilNo.getOilNo():null); |
|
|
|
|
highGasOilPrice.setOilNoName(oilNo!=null?oilNo.getOilNoName():null); |
|
|
|
|
|
|
|
|
|
highGasOilPrice.setPreferentialMargin(new BigDecimal("0")); |
|
|
|
|
highGasOilPrice.setGasStationDrop(oilPriceObject.getBigDecimal("guidancePrice").subtract(oilPriceObject.getBigDecimal("listingPrice"))); |
|
|
|
|
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("merchantStrikePrice")); |
|
|
|
|
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("listingPrice")); |
|
|
|
|
highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("guidancePrice")); |
|
|
|
|
|
|
|
|
|
highGasOilPriceService.editGasOilPrice(highGasOilPrice); |
|
|
|
|
|
|
|
|
|
JSONArray oilGunNoList = oilPriceObject.getJSONArray("guns"); |
|
|
|
|
for (Object o : oilGunNoList) { |
|
|
|
|
HighGasOilGunNo gasOilGunNo = new HighGasOilGunNo(); |
|
|
|
|
gasOilGunNo.setGasOilPriceId(highGasOilPrice.getId()); |
|
|
|
|
gasOilGunNo.setStoreId(highGasOilPrice.getMerchantStoreId()); |
|
|
|
|
gasOilGunNo.setOilNo(highGasOilPrice.getOilNo()); |
|
|
|
|
gasOilGunNo.setOilNoName(highGasOilPrice.getOilNoName()); |
|
|
|
|
gasOilGunNo.setOilType(highGasOilPrice.getOilType()); |
|
|
|
|
gasOilGunNo.setOilTypeName(highGasOilPrice.getOilTypeName()); |
|
|
|
|
gasOilGunNo.setGunNo(Integer.parseInt(o.toString())); |
|
|
|
|
gasOilGunNo.setStatus(1); |
|
|
|
|
gasOilGunNoService.editGunNo(gasOilGunNo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|