提交 981cc78a authored 作者: huyufan's avatar huyufan

同步运单风控

上级 5067099e
...@@ -99,7 +99,7 @@ public enum PerformanceResultEnum implements ResultEnum { ...@@ -99,7 +99,7 @@ public enum PerformanceResultEnum implements ResultEnum {
ORDER_GOODS_SAVE_FAIL(1801, "保存货单失败,请稍后再试"), ORDER_GOODS_SAVE_FAIL(1801, "保存货单失败,请稍后再试"),
ORDER_CHILD_SYNC_ERROR(1901, "承运同步网络货运异常"),
; ;
private final int code; private final int code;
private final String msg; private final String msg;
......
...@@ -36,8 +36,8 @@ public class ThirdOrderChildBrokerParam { ...@@ -36,8 +36,8 @@ public class ThirdOrderChildBrokerParam {
@ApiModelProperty(value = "溢价金额", dataType = "Integer", required = true) @ApiModelProperty(value = "溢价金额", dataType = "Integer", required = true)
@NotNull(message = "溢价金额不能为空") @NotNull(message = "溢价金额不能为空")
private Integer orderChildBrokerBeyondFreight = 0; private Integer orderChildBrokerBeyondFreight = 0;
@ApiModelProperty(value = "净重", dataType="BigDecimal", required = true) @ApiModelProperty(value = "司机实际净重", dataType="BigDecimal", required = true)
@NotNull(message = "净重不能为空") @NotNull(message = "司机实际净重不能为空")
private BigDecimal net; private BigDecimal net;
@ApiModelProperty(value = "装车净重", dataType="BigDecimal") @ApiModelProperty(value = "装车净重", dataType="BigDecimal")
@NotNull(message = "装车净重不能为空") @NotNull(message = "装车净重不能为空")
...@@ -125,8 +125,8 @@ public class ThirdOrderChildBrokerParam { ...@@ -125,8 +125,8 @@ public class ThirdOrderChildBrokerParam {
private String receiveCompany; private String receiveCompany;
@ApiModelProperty(value = "发货单位", dataType="String") @ApiModelProperty(value = "发货单位", dataType="String")
private String sendCompany; private String sendCompany;
@ApiModelProperty(value = "收货净重", dataType="BigDecimal", required = true) @ApiModelProperty(value = "卸车净重", dataType="BigDecimal", required = true)
@NotNull(message = "收货净重不能为空") @NotNull(message = "卸车净重不能为空")
private BigDecimal receiveNet; private BigDecimal receiveNet;
@ApiModelProperty(value = "货物名称", dataType="String", required = true) @ApiModelProperty(value = "货物名称", dataType="String", required = true)
......
...@@ -17,125 +17,6 @@ public class ThirdComponent { ...@@ -17,125 +17,6 @@ public class ThirdComponent {
public static final String TRANSPORT_USER = "13403503399"; public static final String TRANSPORT_USER = "13403503399";
public static final String TRANSPORT_KEY = "9Y1N5AUP8N2TI359"; public static final String TRANSPORT_KEY = "9Y1N5AUP8N2TI359";
// @Autowired
// private HttpLogService httpLogService;
// /**
// * post请求
// *
// * @param host
// * @param httpEnum
// * @param param
// * @param httpLog
// * @param isEncrypt
// */
// @Transactional(propagation = Propagation.NOT_SUPPORTED)
// public Result<?> postRequest(String host, HttpEnum httpEnum, String param, HttpLog httpLog, boolean isEncrypt) {
// if (Objects.nonNull(httpLog)) {
// httpLog.setTryCount(httpLog.getTryCount() + 1);
// httpLogService.updateHttpLogTryCount(httpLog);
// } else {
// httpLog = new HttpLog()
// .setMsgId(UUID.randomUUID().toString())
// .setType(httpEnum.getCode())
// .setRemark(httpEnum.getMark())
// .setUrl(httpEnum.getUrl())
// .setParam(param)
// .setStatus(HttpStatusEnum.HAVING.getCode())
// .setTryCount(1);
// httpLogService.saveHttpLog(httpLog);
// }
// return isEncrypt ? encryptPost(host + httpLog.getUrl(), httpLog.getParam(), httpLog.getId()) : asyncPost(host + httpLog.getUrl(), httpLog.getParam(), httpLog.getId());
// }
//
// @Transactional(propagation = Propagation.NOT_SUPPORTED)
// public Result<?> postRequestBroker(String host, HttpEnum httpEnum, String param, HttpLog httpLog, Map<String, Object> headers) {
// if (Objects.nonNull(httpLog)) {
// httpLog.setTryCount(httpLog.getTryCount() + 1);
// httpLogService.updateHttpLogTryCount(httpLog);
// } else {
// httpLog = new HttpLog()
// .setMsgId(UUID.randomUUID().toString())
// .setType(httpEnum.getCode())
// .setRemark(httpEnum.getMark())
// .setUrl(httpEnum.getUrl())
// .setParam(param)
// .setStatus(HttpStatusEnum.HAVING.getCode())
// .setTryCount(1)
// .setHeader(JSON.toJSONString(headers));
// httpLogService.saveHttpLog(httpLog);
// }
// return asyncPostBroker(host + httpLog.getUrl(), httpLog.getParam(), httpLog.getId(), headers);
// }
//
// /**
// * get请求
// *
// * @param host
// * @param httpEnum
// * @param headers
// * @param param
// * @return
// */
// @Transactional(propagation = Propagation.NOT_SUPPORTED)
// public Result<?> getRequest(String host, HttpEnum httpEnum, Map<String, Object> headers, HttpLog httpLog, Object... param) {
// if (Objects.nonNull(httpLog)) {
// httpLog.setTryCount(httpLog.getTryCount() + 1);
// httpLogService.updateHttpLogTryCount(httpLog);
// } else {
// httpLog = new HttpLog()
// .setMsgId(UUID.randomUUID().toString())
// .setType(httpEnum.getCode())
// .setRemark(httpEnum.getMark())
// .setUrl(String.format(httpEnum.getUrl(), param))
// .setHeader(JSON.toJSONString(headers))
// .setParam("")
// .setStatus(HttpStatusEnum.HAVING.getCode())
// .setTryCount(1);
// httpLogService.saveHttpLog(httpLog);
// }
// return asyncGet(host + httpLog.getUrl(), headers, httpLog.getId());
// }
//
// private Result<?> asyncGet(String url, Map<String, Object> headers, Integer httpLogId) {
// try {
// return Optional.ofBlank(HttpClientUtil.httpGetRequest(url, headers))
// .map(res -> JSON.parseObject(res, Result.class))
// .peek(result -> httpLogService.updateHttpLogStatus(httpLogId, result))
// .filter(Result::succeed)
// .orElse(new Result<>(ResultCodeEnum.FAIL));
// } catch (Exception e) {
// log.error("http请求错误---->httpLogId:{},url:{}", httpLogId, url, e);
// }
// return new Result<>(ResultCodeEnum.FAIL);
// }
//
// private Result<?> asyncPost(String url, String param, Integer httpLogId) {
// try {
// return Optional.ofBlank(HttpClientUtil.httpPostRequest(url, param))
// .map(res -> JSON.parseObject(res, Result.class))
// .peek(result -> httpLogService.updateHttpLogStatus(httpLogId, result))
// .filter(Result::succeed)
// .orElse(new Result<>(ResultCodeEnum.FAIL));
// } catch (Exception e) {
// log.error("http请求错误---->httpLogId:{},url:{},param:{}", httpLogId, url, param, e);
// }
// return new Result<>(ResultCodeEnum.FAIL);
// }
//
// private Result<?> asyncPostBroker(String url, String param, Integer httpLogId, Map<String, Object> headers) {
// try {
// String s = HttpClientUtil.httpPostRequestBroker(url, param, headers);
// return Optional.ofBlank(s)
// .map(res -> JSON.parseObject(res, Result.class))
// .peek(result -> httpLogService.updateHttpLogStatus(httpLogId, result))
// .filter(Result::succeed)
// .orElse(new Result<>(ResultCodeEnum.FAIL));
// } catch (Exception e) {
// log.error("http请求错误---->httpLogId:{},url:{},param:{}", httpLogId, url, param, e);
// }
// return new Result<>(ResultCodeEnum.FAIL);
// }
public static String encrypt(String param) throws Exception { public static String encrypt(String param) throws Exception {
...@@ -152,24 +33,5 @@ public class ThirdComponent { ...@@ -152,24 +33,5 @@ public class ThirdComponent {
} }
} }
public static Result<?> encryptPost(String url, String param, Integer httpLogId) {
try {
return HttpUtil.post(url, null,
EncryptUtil.buildDTO(TRANSPORT_USER, param, TRANSPORT_KEY, System.currentTimeMillis()))
.map(r -> JSON.parseObject(r, new TypeReference<HttpDTO>() {
}))
.peek(dto -> log.info("http请求返回------dto->{}", dto))
.mapTry(dto -> EncryptUtil.decrypt(dto.getData(), TRANSPORT_KEY))
.map(t -> {
return JSONUtil.toBean(t, Result.class);
}
).get();
// .peek(result -> httpLogService.updateHttpLogStatus(httpLogId, result))
} catch (GeneralSecurityException e) {
log.error("解密失败", e);
throw new RuntimeException();
}
}
} }
package com.clx.performance.dto;
import lombok.Data;
@Data
public class OrderChildSyncDTO {
private Integer code;
private OrderChildSyncResultDTO data;
}
package com.clx.performance.dto;
import lombok.Data;
import java.util.List;
@Data
public class OrderChildSyncResultDTO {
@Data
class Res {
private String msg;
private String type;
}
private List<Res> riskList;
//0: 通过风控 1:未通过风控
private Integer status;
}
...@@ -78,16 +78,7 @@ public class TransportSyncServiceImpl implements TransportSyncService { ...@@ -78,16 +78,7 @@ public class TransportSyncServiceImpl implements TransportSyncService {
UserIdCardVO truckOwnerUserIdCardVO = syncOrderChildVO.getTruckOwnerUserIdCardVO(); UserIdCardVO truckOwnerUserIdCardVO = syncOrderChildVO.getTruckOwnerUserIdCardVO();
DriverLicenceFeignVO driverLicenceFeignVO = syncOrderChildVO.getDriverLicenceFeignVO(); DriverLicenceFeignVO driverLicenceFeignVO = syncOrderChildVO.getDriverLicenceFeignVO();
DriverLicenceFeignVO truckOwnerLicenceFeignVO = syncOrderChildVO.getTruckOwnerLicenceFeignVO(); DriverLicenceFeignVO truckOwnerLicenceFeignVO = syncOrderChildVO.getTruckOwnerLicenceFeignVO();
log.info("=============================================================");
log.info("orderChild:{}", JSONUtil.parse(orderChild));
log.info("orderGoods:{}", JSONUtil.parse(orderGoods));
log.info("orderInfoFeign:{}", JSONUtil.parse(orderInfoFeign));
log.info("settlementOwnerDetail:{}", JSONUtil.parse(settlementOwnerDetail));
log.info("route:{}", JSONUtil.parse(route));
log.info("syncOrderChildVO:{}", JSONUtil.parse(syncOrderChildVO));
log.info("receiveAddress:{}", JSONUtil.parse(receiveAddress));
log.info("sendAddress:{}", JSONUtil.parse(sendAddress));
log.info("=============================================================");
//设置司机银行卡 //设置司机银行卡
generateDriverBankCard(driverBankCard, driverUserIdCardVO, param); generateDriverBankCard(driverBankCard, driverUserIdCardVO, param);
//设置车主银行卡 //设置车主银行卡
...@@ -110,9 +101,9 @@ public class TransportSyncServiceImpl implements TransportSyncService { ...@@ -110,9 +101,9 @@ public class TransportSyncServiceImpl implements TransportSyncService {
param.setChildNo(orderChild.getChildNo()); param.setChildNo(orderChild.getChildNo());
param.setTruckNo(orderChild.getTruckNo()); param.setTruckNo(orderChild.getTruckNo());
param.setFreightPrice(Integer.valueOf(orderChild.getFreightPrice().toString())); param.setFreightPrice(Integer.valueOf(orderChild.getFreightPrice().toString()));
param.setFreight(Integer.valueOf(orderChild.getFreight().toString())); param.setFreight(settlementOwnerDetail.getFreight().intValue());
param.setLoadNet(orderChild.getLoadNet()); param.setLoadNet(orderChild.getLoadNet());
param.setNet(orderChild.getUnloadNet()); param.setNet(settlementDriverDetail.getWeight());
param.setSendAddress(orderGoods.getSendAddressShorter()); param.setSendAddress(orderGoods.getSendAddressShorter());
param.setSendProvince(sendAddress.getProvince()); param.setSendProvince(sendAddress.getProvince());
param.setSendCity(sendAddress.getCity()); param.setSendCity(sendAddress.getCity());
...@@ -199,7 +190,6 @@ public class TransportSyncServiceImpl implements TransportSyncService { ...@@ -199,7 +190,6 @@ public class TransportSyncServiceImpl implements TransportSyncService {
//车辆信息 //车辆信息
public void generateTruckInfo(OrderChild orderChild, ThirdOrderChildBrokerParam param) { public void generateTruckInfo(OrderChild orderChild, ThirdOrderChildBrokerParam param) {
TruckInfoFeignVo truckInfoFeignVo = truckFeign.getTruckInfo(orderChild.getTruckId()).getData(); TruckInfoFeignVo truckInfoFeignVo = truckFeign.getTruckInfo(orderChild.getTruckId()).getData();
log.info("++++++++++++++++++++++++++++++++++++++++++++++++++truckInfoFeignVo++++++++++++++++" + JSONUtil.parse(truckInfoFeignVo));
OrderChildTruckInfoDTO truckInfoDTO = new OrderChildTruckInfoDTO(); OrderChildTruckInfoDTO truckInfoDTO = new OrderChildTruckInfoDTO();
DriverInfoFeignVo ownerInfo = driverFeign.getDriverInfo(orderChild.getTruckOwnUserNo()).getData(); DriverInfoFeignVo ownerInfo = driverFeign.getDriverInfo(orderChild.getTruckOwnUserNo()).getData();
truckInfoDTO.setMobile(ownerInfo.getMobile()); truckInfoDTO.setMobile(ownerInfo.getMobile());
...@@ -318,7 +308,6 @@ public class TransportSyncServiceImpl implements TransportSyncService { ...@@ -318,7 +308,6 @@ public class TransportSyncServiceImpl implements TransportSyncService {
public void generateRouteList(GdRouteDTO gdRouteDTO, ThirdOrderChildBrokerParam param) { public void generateRouteList(GdRouteDTO gdRouteDTO, ThirdOrderChildBrokerParam param) {
List<OrderChildTruckTraceDTO> list = new LinkedList<>(); List<OrderChildTruckTraceDTO> list = new LinkedList<>();
log.info("轨迹我"+ JSONUtil.parse(gdRouteDTO));
for (int i = 0; i < gdRouteDTO.getPosList().size(); i++) { for (int i = 0; i < gdRouteDTO.getPosList().size(); i++) {
if (i == 6) { if (i == 6) {
OrderChildTruckTraceDTO dto = new OrderChildTruckTraceDTO(); OrderChildTruckTraceDTO dto = new OrderChildTruckTraceDTO();
......
package com.clx.performance.service.impl.settle; package com.clx.performance.service.impl.settle;
import cn.hutool.json.JSONUtil;
import com.clx.performance.component.ThirdComponent;
import com.clx.performance.dao.OrderChildDao; import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.settle.SettlementDriverDetailDao; import com.clx.performance.dao.settle.SettlementDriverDetailDao;
import com.clx.performance.dao.settle.SettlementOwnerDetailDao; import com.clx.performance.dao.settle.SettlementOwnerDetailDao;
import com.clx.performance.dto.OrderChildSyncDTO;
import com.clx.performance.enums.PerformanceResultEnum; import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.enums.settle.SettlementOwnerEnum; import com.clx.performance.enums.settle.SettlementOwnerEnum;
import com.clx.performance.feign.TransportFeignService; import com.clx.performance.feign.TransportFeignService;
...@@ -17,6 +20,7 @@ import com.clx.performance.service.settle.SettlementMqService; ...@@ -17,6 +20,7 @@ import com.clx.performance.service.settle.SettlementMqService;
import com.clx.performance.service.settle.SettlementService; import com.clx.performance.service.settle.SettlementService;
import com.clx.performance.vo.feign.transport.ThirdOrderChildBrokerResultVO; import com.clx.performance.vo.feign.transport.ThirdOrderChildBrokerResultVO;
import com.msl.common.dto.HttpDTO; import com.msl.common.dto.HttpDTO;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result; import com.msl.common.result.Result;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -72,7 +76,21 @@ public class SettlementServiceImpl implements SettlementService { ...@@ -72,7 +76,21 @@ public class SettlementServiceImpl implements SettlementService {
//是否通过风控,调用网络货运 //是否通过风控,调用网络货运
ThirdOrderChildBrokerParam param = transportSyncService.generateOrderChildSync(orderChild, orderGoods, settlementOwnerDetail, settlementDriverDetail); ThirdOrderChildBrokerParam param = transportSyncService.generateOrderChildSync(orderChild, orderGoods, settlementOwnerDetail, settlementDriverDetail);
Result<HttpDTO> httpDTOResult = transportFeignService.orderChildSync(param); Result<HttpDTO> httpDTOResult = transportFeignService.orderChildSync(param);
System.out.println(httpDTOResult); String decrypt = ThirdComponent.decrypt(httpDTOResult.getData().getData());
OrderChildSyncDTO bean = JSONUtil.toBean(decrypt, OrderChildSyncDTO.class);
if (bean.getCode() == 0) {
Integer status = bean.getData().getStatus();
if (status == 0) {
//通过风控
invoiceType = SettlementOwnerEnum.InvoiceType.ONLINE.getCode();
} else {
invoiceType = SettlementOwnerEnum.InvoiceType.ORDINARY.getCode();
}
} else {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_SYNC_ERROR);
}
if (SettlementOwnerEnum.InvoiceType.ONLINE.getCode().equals(invoiceType) && settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) { if (SettlementOwnerEnum.InvoiceType.ONLINE.getCode().equals(invoiceType) && settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) {
settlementDriverDetail.setPrepayFreightFlag(1); settlementDriverDetail.setPrepayFreightFlag(1);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论