提交代码

dev-discount
胡锐 2 years ago
parent 335979278a
commit e0cb9df0e0
  1. 10
      hai-cweb/src/main/java/com/cweb/controller/HighGasController.java
  2. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  3. 17
      hai-service/src/main/java/com/hai/config/JinZhuJiaYouService.java
  4. 76
      hai-service/src/main/java/com/hai/enum_type/JinZhuJiaYouOilNo.java
  5. 4
      hai-service/src/main/java/com/hai/service/HighGasService.java
  6. 182
      hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java

@ -278,7 +278,9 @@ public class HighGasController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
}
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(1) || store.getSourceType().equals(3)) {
if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) {
Map<String, Object> param = new HashMap<>();
param.put("provinceName", null);
param.put("provinceCode", null);
@ -379,7 +381,7 @@ public class HighGasController {
return ResponseMsgUtil.success(param);
} else if (store.getSourceType().equals(2)) {
} else if (store.getSourceType().equals(store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber()))) {
JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(storeKey);
if (jsonObject != null && jsonObject.getString("code").equals("200")) {
JSONObject result = jsonObject.getJSONObject("result");
@ -478,7 +480,9 @@ public class HighGasController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知来源的加油站");
}
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber()) ) {
Map<String, Object> param = new HashMap<>();
param.put("provinceName", null);
param.put("provinceCode", null);

File diff suppressed because one or more lines are too long

@ -1,6 +1,9 @@
package com.hai.config;
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.HttpsUtils;
import com.hai.enum_type.TripartiteReqLogReqType;
import com.hai.enum_type.TripartiteReqLogType;
@ -30,7 +33,7 @@ public class JinZhuJiaYouService {
/**
* 查询加油站列表
* @param pageNum 分页页数
* @param pageNum 分页页数 默认为0从0开始
* @param pageSize 每页数量最大100条
* @return
* @throws Exception
@ -101,7 +104,7 @@ public class JinZhuJiaYouService {
/**
* 接口请求
* @param param
* @param param 参数
* @return
* @throws Exception
*/
@ -118,9 +121,15 @@ public class JinZhuJiaYouService {
MapUtils.getString(param, "requestNo"),
TripartiteReqLogReqType.type1,
reqUrl,
repsObject.toString(),
JSONObject.toJSONString(heard),
repsObject.toString()
);
if (repsObject == null
|| !repsObject.getInteger("status").equals(200)
|| !repsObject.getString("type").equals("OK")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, repsObject == null?"请求失败":repsObject.getString("title"));
}
return repsObject;
}
@ -131,7 +140,7 @@ public class JinZhuJiaYouService {
* @throws Exception
*/
private static String generateSign(final Map<String, Object> data) throws IOException {
PrivateKey privateKey = PemUtil.loadPrivateKey(new FileInputStream("/home/project/jzKey.key"));
PrivateKey privateKey = PemUtil.loadPrivateKey(new FileInputStream("/home/project/hsg/jzKey.key"));
String signStr = null;
try {
Signature sign = Signature.getInstance("SHA256withRSA");

@ -0,0 +1,76 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* 金猪加油 油号枚举
*/
public enum JinZhuJiaYouOilNo {
NO_0("NO_0",0, "0#",1, "柴油"),
NO_92("NO_92",92, "92#",2, "汽油"),
NO_95("NO_95",95, "95#",2, "汽油"),
NO_98("NO_98",98, "98#",2, "汽油"),
;
private String oilNoCode;
private Integer oilNo;
private String oilNoName;
private Integer oilType;
private String oilTypeName;
JinZhuJiaYouOilNo(String oilNoCode,Integer oilNo,String oilNoName,Integer oilType,String oilTypeName) {
this.oilNoCode = oilNoCode;
this.oilNo = oilNo;
this.oilNoName = oilNoName;
this.oilType = oilType;
this.oilTypeName = oilTypeName;
}
public static JinZhuJiaYouOilNo getDataByCode(String code) {
for (JinZhuJiaYouOilNo ele : values()) {
if(Objects.equals(code,ele.getOilNoCode())) return ele;
}
return null;
}
public String getOilNoCode() {
return oilNoCode;
}
public void setOilNoCode(String oilNoCode) {
this.oilNoCode = oilNoCode;
}
public Integer getOilNo() {
return oilNo;
}
public void setOilNo(Integer oilNo) {
this.oilNo = oilNo;
}
public String getOilNoName() {
return oilNoName;
}
public void setOilNoName(String oilNoName) {
this.oilNoName = oilNoName;
}
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;
}
}

@ -10,4 +10,8 @@ public interface HighGasService {
*/
void getJiaHaoYouAllStation() throws Exception;
/**
* 获取渠道商金猪加油全量加油站
*/
void getJinZhuAllStation() throws Exception;
}

@ -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);
}
}
}
}
}
}
}

Loading…
Cancel
Save