Merge branch 'gas' into pre

dev-discount
胡锐 2 years ago
commit 5cf5ccb760
  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. 57
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  4. 160
      hai-service/src/main/java/com/hai/config/JinZhuJiaYouService.java
  5. 3
      hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java
  6. 76
      hai-service/src/main/java/com/hai/enum_type/JinZhuJiaYouOilNo.java
  7. 1
      hai-service/src/main/java/com/hai/enum_type/TripartiteReqLogType.java
  8. 4
      hai-service/src/main/java/com/hai/service/HighGasService.java
  9. 6
      hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java
  10. 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, "未找到加油站"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
} }
// 来源类型 1:平台自建 2:团油 // 来源类型 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<>(); Map<String, Object> param = new HashMap<>();
param.put("provinceName", null); param.put("provinceName", null);
param.put("provinceCode", null); param.put("provinceCode", null);
@ -379,7 +381,7 @@ public class HighGasController {
return ResponseMsgUtil.success(param); 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); JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(storeKey);
if (jsonObject != null && jsonObject.getString("code").equals("200")) { if (jsonObject != null && jsonObject.getString("code").equals("200")) {
JSONObject result = jsonObject.getJSONObject("result"); JSONObject result = jsonObject.getJSONObject("result");
@ -478,7 +480,9 @@ public class HighGasController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知来源的加油站"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知来源的加油站");
} }
// 来源类型 1:平台自建 2:团油 // 来源类型 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<>(); Map<String, Object> param = new HashMap<>();
param.put("provinceName", null); param.put("provinceName", null);
param.put("provinceCode", null); param.put("provinceCode", null);

File diff suppressed because one or more lines are too long

@ -191,6 +191,21 @@ public class OrderController {
} }
} }
} }
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
BigDecimal account = new BigDecimal("0");
// 查询账号余额
HighMerchantAccount merAccount = merchantAccountService.getStoreAccountDetail(store.getMerchantId());
if (merAccount != null) {
account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId()));
}
// 客户加油金额 大于 商户账号余额
if(order.getTotalPrice().compareTo(account) == 1) {
log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服");
}
}
} }
} }
@ -531,6 +546,20 @@ public class OrderController {
} }
} }
} }
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
BigDecimal account = new BigDecimal("0");
// 查询账号余额
HighMerchantAccount merAccount = merchantAccountService.getStoreAccountDetail(store.getMerchantId());
if (merAccount != null) {
account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId()));
}
// 客户加油金额 大于 商户账号余额
if(order.getTotalPrice().compareTo(account) == 1) {
log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服");
}
}
} }
} }
@ -643,6 +672,20 @@ public class OrderController {
} }
} }
} }
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
BigDecimal account = new BigDecimal("0");
// 查询账号余额
HighMerchantAccount merAccount = merchantAccountService.getStoreAccountDetail(store.getMerchantId());
if (merAccount != null) {
account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId()));
}
// 客户加油金额 大于 商户账号余额
if(order.getTotalPrice().compareTo(account) == 1) {
log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服");
}
}
} }
} }
@ -735,6 +778,20 @@ public class OrderController {
} }
} }
} }
// 来源类型 1:平台自建 2:团油
if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) {
BigDecimal account = new BigDecimal("0");
// 查询账号余额
HighMerchantAccount merAccount = merchantAccountService.getStoreAccountDetail(store.getMerchantId());
if (merAccount != null) {
account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId()));
}
// 客户加油金额 大于 商户账号余额
if(order.getTotalPrice().compareTo(account) == 1) {
log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服");
}
}
} }
} }

@ -0,0 +1,160 @@
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;
import com.hai.service.BsTripartiteReqLogService;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.security.*;
import java.util.HashMap;
import java.util.Map;
/**
* 金猪加油服务
*/
@Component
public class JinZhuJiaYouService {
private final static String reqUrl = "http://api.jianshiyun.com/api/gateway";
@Resource
private BsTripartiteReqLogService reqLogService;
/**
* 查询加油站列表
* @param pageNum 分页页数 默认为0从0开始
* @param pageSize 每页数量最大100条
* @return
* @throws Exception
*/
public JSONObject getStationListPage(Integer pageNum, Integer pageSize) throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("requestNo", System.currentTimeMillis()+"");
param.put("page", pageNum);
param.put("size", pageSize);
return request("STATION_TREE_PAGE", param);
}
/**
* 查询加油站列表
* @param stationCode 油站编号
* @return
* @throws Exception
*/
public JSONObject getStationDetail(String stationCode) throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("requestNo", System.currentTimeMillis()+"");
param.put("code", stationCode);
return request("STATION_VIEW", param);
}
/**
* 创建加油订单
* @param merchantOrderNo 订单号
* @param orderAmount 加油金额
* @param stationCode 油站code
* @param oilNo 油号
* @param gunNo 枪号
* @param userMobile 用户手机号
* @return
* @throws Exception
*/
public JSONObject createOrder(String merchantOrderNo,
BigDecimal orderAmount,
String stationCode,
String oilNo,
String gunNo,
String userMobile) throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("requestNo", System.currentTimeMillis()+"");
param.put("merchantOrderNo", merchantOrderNo);
param.put("orderAmount", orderAmount);
param.put("stationCode", stationCode);
param.put("oilNo", oilNo);
param.put("gunNo", gunNo);
param.put("userMobile", userMobile);
return request("ORDER_CREATE", param);
}
/**
* 查询加油站列表
* @param merchantOrderNo 订单号
* @param paymentAmount
* @return
* @throws Exception
*/
public JSONObject payOrder(String merchantOrderNo, BigDecimal paymentAmount) throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("requestNo", System.currentTimeMillis()+"");
param.put("merchantOrderNo", merchantOrderNo);
param.put("paymentAmount", paymentAmount);
return request("ORDER_PAYMENT", param);
}
/**
* 接口请求
* @param param 参数
* @return
* @throws Exception
*/
private JSONObject request(String service, Map<String,Object> param) throws Exception {
// 请求头部
Map<String, Object> heard = new HashMap<>();
heard.put("Request-App-Id", "app_xiaohan_test_01");
heard.put("Request-Service-Name", "STATION_TREE_PAGE");
heard.put("Request-Signature", generateSign(param));
JSONObject repsObject = HttpsUtils.doPost(reqUrl, param, heard);
reqLogService.insert(
TripartiteReqLogType.type8,
MapUtils.getString(param, "requestNo"),
TripartiteReqLogReqType.type1,
reqUrl,
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;
}
/**
* 生成签名
* @param data
* @return
* @throws Exception
*/
private static String generateSign(final Map<String, Object> data) throws IOException {
PrivateKey privateKey = PemUtil.loadPrivateKey(new FileInputStream("/home/project/hsg/jzKey.key"));
String signStr = null;
try {
Signature sign = Signature.getInstance("SHA256withRSA");
sign.initSign(privateKey);
sign.update(JSONObject.toJSONString(data).getBytes("utf-8"));
signStr = java.util.Base64.getEncoder().encodeToString(sign.sign());
} catch (SignatureException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
return signStr;
}
}

@ -41,7 +41,8 @@ public interface HighGasOilPriceMapperExt {
@Select({" SELECT a.store_key storeKey,ROUND((st_distance_sphere(point(a.longitude, a.latitude) , point(${longitude},${latitude}))/1000),2) as distance" + @Select({" SELECT a.store_key storeKey,ROUND((st_distance_sphere(point(a.longitude, a.latitude) , point(${longitude},${latitude}))/1000),2) as distance" +
" FROM high_merchant_store a,high_gas_oil_price b where a.type = 1 and a.`status` = 1 and a.id = b.merchant_store_id and b.`status` = 1 GROUP BY a.id" + " FROM high_merchant_store a,high_gas_oil_price b where a.type = 1 and a.`status` = 1 and a.id = b.merchant_store_id and b.`status` = 1 " +
" and a.longitude is not null and a.latitude is not null GROUP BY a.id" +
" ORDER BY distance asc LIMIT 1 "}) " ORDER BY distance asc LIMIT 1 "})
Map<String,Object> recentGasStation(@Param("longitude") String longitude,@Param("latitude") String latitude); Map<String,Object> recentGasStation(@Param("longitude") String longitude,@Param("latitude") String latitude);

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

@ -11,6 +11,7 @@ public enum TripartiteReqLogType {
type5(5, "千猪肯德基"), type5(5, "千猪肯德基"),
type6(6, "千猪星巴克"), type6(6, "千猪星巴克"),
type7(7, "千猪话费"), type7(7, "千猪话费"),
type8(8, "金猪加油"),
; ;
private Integer type; private Integer type;

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

@ -156,9 +156,11 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri
// 1:平台自建 2:团油 3: 壳牌 // 1:平台自建 2:团油 3: 壳牌
if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber()) if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { || store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())
|| store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())
) {
// 嗨森逛平台价 国标价 * 折扣 // 嗨森逛平台价 油枪价 * 折扣
BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP);
// 加油金额 // 加油金额

@ -4,10 +4,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.JinZhuJiaYouService;
import com.hai.config.ShellGroupService; import com.hai.config.ShellGroupService;
import com.hai.entity.HighGasOilGunNo; import com.hai.entity.HighGasOilGunNo;
import com.hai.entity.HighGasOilPrice; import com.hai.entity.HighGasOilPrice;
import com.hai.entity.HighMerchantStore; 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.enum_type.MerchantStoreSourceType;
import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantModel;
import com.hai.model.HighMerchantStoreModel; import com.hai.model.HighMerchantStoreModel;
@ -25,6 +28,9 @@ public class HighGasServiceImpl implements HighGasService {
@Resource @Resource
private ShellGroupService shellGroupService; private ShellGroupService shellGroupService;
@Resource
private JinZhuJiaYouService jinZhuJiaYouService;
@Resource @Resource
private HighMerchantService highMerchantService; private HighMerchantService highMerchantService;
@ -37,6 +43,9 @@ public class HighGasServiceImpl implements HighGasService {
@Resource @Resource
private HighGasOilGunNoService gasOilGunNoService; private HighGasOilGunNoService gasOilGunNoService;
@Resource
private CommonService commonService;
@Override @Override
public void getJiaHaoYouAllStation() throws Exception { public void getJiaHaoYouAllStation() throws Exception {
HighMerchantModel merchant = highMerchantService.getDetailByKey("HF0801103821"); 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