提交 4597ac59 authored 作者: 胡宁宁's avatar 胡宁宁

司机接单逻辑调整

上级 9c243c1e
......@@ -37,7 +37,7 @@ public enum PerformanceResultEnum implements ResultEnum {
ORDER_WEIGHT_LACK(1201, "剩余吨数不足,请联系客服"),
ORDER_INVALID(1202, "无效的货单"),
ORDER_INVALID1(1203, "当前运单的货源已完成或取消,请查看其他货源"),
ORDER_DRIVER_LIMIT(1204, "该货单不支持车主抢单"),
ORDER_CHILD_NO_FOUND(1301, "运单不存在"),
ORDER_CHILD_STATUS_CHANGED(1302, "运单状态已变更,请重新刷新页面"),
......@@ -97,6 +97,10 @@ public enum PerformanceResultEnum implements ResultEnum {
INTEGRAL_RULE_NAME_EXIST(1703, "层级名称已存在"),
APP_POP_UP_ERROR(-1000, "app弹窗提示"),
/**司机提示语 **/
APP_POP_UP_DRIVER_RESIDUE_ERROR(-500, "app弹窗提示"),
/**车主提示语 **/
APP_POP_UP_OWNER_RESIDUE_ERROR(-499, "app弹窗提示"),
WALLET_CODE_IS_NULL(1704, "用户钱包不存在"),
ORDER_GOODS_SAVE_FAIL(1801, "保存货单失败,请稍后再试"),
......
......@@ -25,4 +25,7 @@ public class OrderChildSaveParam extends PositionParam {
@NotNull(message = "司机用户编号空")
private Long driverUserNo;
@ApiModelProperty(value = "支付方密码", example = "2356", dataType = "String")
private String pwd;
}
......@@ -13,13 +13,11 @@ import javax.validation.constraints.NotBlank;
@Builder
@Accessors(chain = true)
public class PayPlatformFeeParam {
@NotBlank(message = "支付人不能为空")
@ApiModelProperty(value = "支付来源", example = "2234", dataType = "int")
Integer from;
@NotBlank(message = "支付密码不能为空")
@ApiModelProperty(value = "支付方密码", example = "2356", dataType = "String")
String pwd;
@NotBlank(message = "金额不能为空")
@ApiModelProperty(value = "金额", example = "2356", dataType = "int")
Integer figure;
@NotBlank(message = "交易单号不能为空")
......
package com.clx.performance.param.pc.payment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@ApiModel(description = "钱包查询")
@Getter
@Setter
@ToString
@NoArgsConstructor
public class WalletParam {
/**
* 用户编号从10000001开始
*/
@ApiModelProperty(value = "主钱包账号", dataType = "int", example = "1")
private Integer userCode;
}
package com.clx.performance.param.pc.payment;
import com.fasterxml.jackson.annotation.JsonGetter;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
public class WalletResidueDTO {
//余额
@ApiModelProperty(value = "余额", dataType = "double", example = "11.10")
private Long residue;
//冻结的资金
@ApiModelProperty(value = "冻结的资金", dataType = "double", example = "11.10")
private Long frozen;
//保证金
@ApiModelProperty(value = "保证金", dataType = "double", example = "11.10")
private Double deposit;
//状态0锁定1正常2异常
@ApiModelProperty(value = "状态0锁定1正常2异常", dataType = "int", example = "1")
private Integer status;
//是否设置交易密码0没有1有
@ApiModelProperty(value = "是否设置交易密码0没有1有", dataType = "String", example = "1")
private String pwd;
public Long getResidue() {
return residue;
}
public void setResidue(Long residue) {
this.residue = residue;
}
public Long getFrozen() {
return frozen;
}
public void setFrozen(Long frozen) {
this.frozen = frozen;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
@JsonGetter(value="frozen")
public BigDecimal frozenFormat() {
return new BigDecimal(new Double(this.frozen)/100);
}
@JsonGetter(value="residue")
public Double residueFormat() {
return new Double(this.residue)/100;
}
@JsonGetter(value="deposit")
public Double depositFormat() {
return new Double(this.deposit)/100;
}
public Double getDeposit() {
return deposit;
}
public void setDeposit(Double deposit) {
this.deposit = deposit;
}
@Override
public String toString() {
return "WalletDTO [residue=" + residue + ", frozen=" + frozen
+ ", status=" + status + "]";
}
}
......@@ -227,5 +227,7 @@ public class OrderChildVO {
@ApiModelProperty(value = "车辆未开启中交兴路的提示信息")
private String notOpenZJXLMsg;
@ApiModelProperty("接单保证金 平台服务费费率 弹窗和文案显示 0 不显示 1 显示")
private Integer goodsOrderDetailShow = 0;
}
\ No newline at end of file
......@@ -155,4 +155,9 @@ public class OrderGoodsVO {
@ApiModelProperty("接单保证金(分/车)")
private BigDecimal deposit;
@ApiModelProperty("结算方式 1装车净重 2卸车净重")
private Integer settlementWay;
@ApiModelProperty("接单保证金 平台服务费费率 弹窗和文案显示 0 不显示 1 显示")
private Integer goodsOrderDetailShow = 0;
}
\ No newline at end of file
......@@ -34,6 +34,8 @@ import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.model.loan.OwnerRepayment;
import com.clx.performance.model.settle.SettlementDriverDetail;
import com.clx.performance.model.settle.SettlementOwnerDetail;
import com.clx.performance.param.pc.payment.PayPlatformFeeParam;
import com.clx.performance.service.PaymentService;
import com.clx.performance.service.loan.OwnerLoanRecordService;
import com.clx.performance.service.settle.NetworkDriverRunningWaterRecordService;
import com.clx.user.vo.feign.OwnerInfoFeignVO;
......@@ -42,6 +44,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -84,7 +87,7 @@ public class OrderChildLoanComponent {
private final NetworkDriverRunningWaterRecordService networkDriverRunningWaterRecordService;
private final PaymentService paymentService;
/**
* 接单校验判断
......@@ -338,6 +341,45 @@ public class OrderChildLoanComponent {
networkDriverRunningWaterRecordService.generateNetworkCaseOutRecord(settlementDriverDetail);
}
@Transactional(rollbackFor = Exception.class)
public void orderChildCancelAfter(String childNo){
//运单取消
OrderChild orderChild = orderChildDao.getByChildNo(childNo).orElseThrow(
PerformanceResultEnum.ORDER_CHILD_NO_FOUND);
BigDecimal platformServiceFee = orderChild.getPlatformServiceFee(); //平台服务费
List<OwnerLoanAccountRunningWaterRecord> runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByChildNoAndRunningWaterType(childNo, OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode());
if (CollectionUtil.isEmpty(runningWaterRecordList)) {
if( Objects.nonNull(platformServiceFee) && platformServiceFee.compareTo(BigDecimal.ZERO) != 0){
PayPlatformFeeParam payPlatformFeeParam = new PayPlatformFeeParam();
payPlatformFeeParam.setTradeNo(childNo);
payPlatformFeeParam.setFigure(platformServiceFee.intValue());
paymentService.paymentCancelPlatformFee(payPlatformFeeParam);
}
return;
}
Long ownerUserNo = runningWaterRecordList.get(0).getOwnerUserNo();
log.info("当前解冻货主:{},流水记录长度{},流水记录{}", ownerUserNo, runningWaterRecordList.size(), JSONUtil.parse(runningWaterRecordList));
for (OwnerLoanAccountRunningWaterRecord record : runningWaterRecordList) {
Long loanNo = record.getLoanNo();
Integer loanType = record.getLoanType();
String ownerUserName = record.getOwnerUserName();
BigDecimal balance = record.getAlterationBalance();
//解冻借款
thawOwnerLoanAccount(loanNo, loanType, ownerUserNo, ownerUserName, record.getMobile(), childNo, balance);
}
if( Objects.nonNull(platformServiceFee) && platformServiceFee.compareTo(BigDecimal.ZERO) != 0){
PayPlatformFeeParam payPlatformFeeParam = new PayPlatformFeeParam();
payPlatformFeeParam.setTradeNo(childNo);
payPlatformFeeParam.setFigure(platformServiceFee.intValue());
paymentService.paymentCancelPlatformFee(payPlatformFeeParam);
}
}
//归还借款单的剩余金额+解冻流水
public void thawOwnerLoanAccount(Long loanNo, Integer loanType, Long userNo, String userName, String mobile, String childNo, BigDecimal balance) {
log.info("归还借款单的剩余金额+解冻流水,loanNo:{},loanType:{},userNo:{},childNo:{}, balance:{}", loanNo, loanType, userNo, childNo, balance);
......
......@@ -66,6 +66,8 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getStatus, item.getStatus())
.set(OrderChild::getDeposit, item.getDeposit())
.set(OrderChild::getPlatformServiceFee, item.getPlatformServiceFee())
);
}
......@@ -83,6 +85,8 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getStatus, item.getStatus())
.set(OrderChild::getDeposit, item.getDeposit())
.set(OrderChild::getPlatformServiceFee, item.getPlatformServiceFee())
);
}
......@@ -103,6 +107,8 @@ public class OrderChildDaoImpl extends BaseDaoImpl<OrderChildMapper, OrderChild,
.set(OrderChild::getWeight, item.getWeight())
.set(OrderChild::getFreight, item.getFreight())
.set(OrderChild::getPoundStatus, item.getPoundStatus())
.set(OrderChild::getDeposit, item.getDeposit())
.set(OrderChild::getPlatformServiceFee, item.getPlatformServiceFee())
);
}
......
......@@ -2,12 +2,13 @@ package com.clx.performance.dao.impl.payment;
import com.clx.performance.dao.payment.OrderPaymentDao;
import com.clx.performance.mapper.payment.OrderPaymentMapper;
import com.clx.performance.model.IntegralStatistics;
import com.clx.performance.model.payment.OrderPayment;
import com.msl.common.base.Optional;
import com.msl.common.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author huningning
* Date 2024-06-18
......@@ -48,5 +49,11 @@ public class OrderPaymentDaoImpl extends BaseDaoImpl<OrderPaymentMapper, OrderPa
.map(super::getOne);
}
@Override
public List<OrderPayment> listByOrderNo(String orderNo, String paymentItem) {
return list(lQrWrapper()
.eq(OrderPayment::getOrderNo, orderNo)
.eq(OrderPayment::getPaymentItem, paymentItem)
);
}
}
......@@ -6,6 +6,8 @@ import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author huningning
* Date 2024-06-18
......@@ -24,4 +26,6 @@ public interface OrderPaymentDao extends BaseDao<OrderPaymentMapper, OrderPaymen
@Param("paymentItem")String paymentItem,
@Param("operation")Integer operation);
List<OrderPayment> listByOrderNo(@Param("orderNo")String orderNo, @Param("paymentItem")String paymentItem);
}
package com.clx.performance.dto.payment;
import com.fasterxml.jackson.annotation.JsonGetter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
/**
*
* @author 胡宁宁
* @date 2024年06
* @description
*/
@Data
@Builder
public class PaymentDTO {
/** 本次调整金额 **/
BigDecimal changeDeposit ;
/** 最新的保证金**/
BigDecimal platformServiceFeeNew;
}
......@@ -9,7 +9,7 @@ import java.math.BigDecimal;
/**
*
* @author 胡宁宁
* @date 2023年11月12日
* @date 2024年06
* @description
*/
public class WalletResidueCardDTO extends WalletResidueDTO{
......
......@@ -7,12 +7,11 @@ import java.math.BigDecimal;
/**
*
*
* @author 胡宁宁
* @date 2023年11月12日
* @date 2024年06
* @description
*/
public class WalletResidueDTO {
@ApiModelProperty(value = "余额", dataType = "double", example = "11.10")
......
......@@ -10,11 +10,14 @@ public enum HttpEnum {
PERFORMANCE_PAY_CLX_PAYMENT(10000, "履约服务向老马上来发起钱包转账",
"/payment-service/performance/payUserWalletTransfer"),
PERFORMANCE_PAY_CLX_DRIVER_FREEZE(10000, "履约服务向老马上来发起司机押金冻结",
PERFORMANCE_PAY_CLX_DRIVER_FREEZE(10001, "履约服务向老马上来发起司机押金冻结",
"/payment-service/performance/freezeUserMQ"),
PERFORMANCE_PAY_CLX_ADJUST_DRIVER_FREEZE(10000, "履约服务向老马上来发起司机押金冻结调整",
PERFORMANCE_PAY_CLX_ADJUST_DRIVER_FREEZE(10002, "履约服务向老马上来发起司机押金冻结调整",
"/payment-service/performance/completeFreezeBatchMQ"),
PERFORMANCE_PAY_CLX_WALLET(10003, "履约服务向老马上来发起司机余额查询",
"/payment-service/performance/getWalletAndCard"),
;
private final int code;
......
......@@ -211,24 +211,7 @@ public class EventListenerComponent {
String childNo = event.getChildNo();
log.info("需要解冻借款的的运单号:{}", childNo);
List<OwnerLoanAccountRunningWaterRecord> runningWaterRecordList = ownerLoanAccountRunningWaterRecordDao.getListByChildNoAndRunningWaterType(childNo, OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode());
if (CollectionUtil.isEmpty(runningWaterRecordList)) {
return;
}
Long ownerUserNo = runningWaterRecordList.get(0).getOwnerUserNo();
log.info("当前解冻货主:{},流水记录长度{},流水记录{}", ownerUserNo, runningWaterRecordList.size(), JSONUtil.parse(runningWaterRecordList));
for (OwnerLoanAccountRunningWaterRecord record : runningWaterRecordList) {
Long loanNo = record.getLoanNo();
Integer loanType = record.getLoanType();
String ownerUserName = record.getOwnerUserName();
BigDecimal balance = record.getAlterationBalance();
//解冻借款
orderChildLoanComponent.thawOwnerLoanAccount(loanNo, loanType, ownerUserNo, ownerUserName, record.getMobile(), childNo, balance);
}
orderChildLoanComponent.orderChildCancelAfter(childNo);
}
@EventListener(classes = {OwnerLoanThawEvent.class})
......
package com.clx.performance.extranal.order;
import com.clx.order.vo.pc.carrier.InvoicingCompanyVO;
import com.msl.common.base.Optional;
public interface InvoicingCompanyService {
InvoicingCompanyVO getInvoicingCompanyByGroupCode(String companyGroupCode);
Optional<InvoicingCompanyVO> getInvoicingCompany(int id);
}
package com.clx.performance.extranal.order.impl;
import com.clx.order.feign.InvoicingCompanyFeign;
import com.clx.order.vo.pc.carrier.InvoicingCompanyVO;
import com.clx.performance.extranal.order.InvoicingCompanyService;
import com.msl.common.base.Optional;
import com.msl.common.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
@AllArgsConstructor
public class InvoicingCompanyImpl implements InvoicingCompanyService {
private final InvoicingCompanyFeign invoicingCompanyFeign;
@Override
public Optional<InvoicingCompanyVO> getInvoicingCompany(int id) {
return Optional.ofNullable(invoicingCompanyFeign.getInvoicingCompany(id))
.filter(Result::succeed)
.map(Result::getData);
}
}
......@@ -3,6 +3,7 @@ package com.clx.performance.service;
import com.clx.performance.param.pc.payment.PayParam;
import com.clx.performance.param.pc.payment.PayPlatformFeeParam;
import com.clx.performance.param.pc.payment.WalletResidueDTO;
import com.msl.common.result.Result;
public interface PaymentService {
......@@ -23,4 +24,8 @@ public interface PaymentService {
void updateOrderPaymentSuccess(String orderNo,Integer operation, String paymentItem);
void updateOrderPaymentSerialNoSuccess(String orderNo,String serialNo,Integer operation, String paymentItem);
WalletResidueDTO getWalletAndCard(Integer userCode);
}
......@@ -5,12 +5,14 @@ import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.order.enums.InvoicingCompanyEnum;
import com.clx.order.enums.UpdateEnum;
import com.clx.order.enums.VehicleUsageEnum;
import com.clx.order.feign.OrderFeign;
import com.clx.order.param.feign.OrderCancelReasonParam;
import com.clx.order.param.feign.RollbackOrderWeightParam;
import com.clx.order.vo.feign.FeignOrderVO;
import com.clx.order.vo.pc.owner.OwnerQuotationDetailVO;
import com.clx.performance.component.GoodsOrderTruckRecordComponent;
import com.clx.performance.component.OrderCancelComponent;
import com.clx.performance.component.OrderGoodsStatusLazyComponent;
......@@ -21,6 +23,8 @@ import com.clx.performance.dao.OrderGoodsDriverTruckDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao;
import com.clx.performance.dto.OrderGoodsCancelDTO;
import com.clx.performance.enums.*;
import com.clx.performance.enums.settle.SettlementWayEnum;
import com.clx.performance.extranal.order.QuotationService;
import com.clx.performance.extranal.user.DriverService;
import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
......@@ -43,6 +47,7 @@ import com.clx.performance.vo.pc.OrderGoodsEditVO;
import com.clx.performance.vo.pc.OrderGoodsVO;
import com.clx.user.enums.driver.DriverInfoEnum;
import com.clx.user.feign.UserClxFeign;
import com.github.mustachejava.ObjectHandler;
import com.msl.common.base.Optional;
import com.msl.common.enums.ResultCodeEnum;
import com.msl.common.exception.ServiceSystemException;
......@@ -115,6 +120,8 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
private OrderChildPostService orderChildPostService;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private QuotationService quotationService;
private static Map<Integer, Consumer<OrderGoodsCancelDTO>> orderGoodsCancelMap = new HashMap<>();
......@@ -142,6 +149,21 @@ public class OrderGoodsServiceImpl implements OrderGoodsService, InitializingBea
orderGoodsVO.setLoadBeginTime(orderInfoFeign.getLoadBeginTime());
orderGoodsVO.setLoadEndTime(orderInfoFeign.getLoadEndTime());
orderGoodsVO.setResidueTransportWeight(BigDecimal.ZERO.compareTo(orderGoodsVO.getResidueTransportWeight()) > 0 ? BigDecimal.ZERO : orderGoodsVO.getResidueTransportWeight());
//获取订单配置的违约金方案
OwnerQuotationDetailVO quotationDetailVO = quotationService.getQuotationByOrderNo(orderNo).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
if(Objects.isNull(quotationDetailVO.getLiquidatedDamagesPlanId())){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND);
}
//货源详情页面 是否显示弹窗和显示平台服务费率
/** 订单结算方式为“卸车净重(减货损)”且平台运费报价为“未税”时 显示平台服务费率和弹窗提示司机平台服务费率**/
if (Objects.equals(orderGoodsVO.getSettlementWay(),
SettlementWayEnum.WayType.UNLOAD_LOSS.getCode())
&& Objects.equals(quotationDetailVO.getPlatformFreightQuotationTaxType(),
InvoicingCompanyEnum.TaxType.TAX_EXCLUDED.getCode())) {
orderGoodsVO.setGoodsOrderDetailShow(0);
}
return orderGoodsVO;
}
......
......@@ -2,6 +2,7 @@ package com.clx.performance.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.clx.performance.config.MslPaymentConfig;
import com.clx.performance.constant.ActionConstants;
import com.clx.performance.dao.ThirdPartRequestLogDao;
......@@ -13,6 +14,7 @@ import com.clx.performance.enums.*;
import com.clx.performance.enums.payment.PayOperationStatusEnum;
import com.clx.performance.enums.payment.PaymentActionEnum;
import com.clx.performance.enums.payment.PaymentStatusEnum;
import com.clx.performance.model.OrderGoodsTruckBind;
import com.clx.performance.model.ThirdPartRequestLog;
import com.clx.performance.model.payment.OrderPayment;
import com.clx.performance.param.pc.payment.*;
......@@ -26,8 +28,10 @@ import com.msl.common.result.Result;
import com.msl.common.utils.EncryptUtil;
import com.msl.common.utils.HttpUtil;
import com.msl.common.utils.LocalDateTimeUtils;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -40,6 +44,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.clx.performance.enums.HttpEnum.PERFORMANCE_PAY_CLX_PAYMENT;
......@@ -255,14 +260,25 @@ public class PaymentServiceImpl implements PaymentService {
@Override
public Result paymentCompletePlatformFee(PayPlatformFeeParam param) {
//查询冻结记录
OrderPayment orderPaymentOptional =
orderPaymentDao.selectByOrderNoAndItemIdAndOperation(param.getTradeNo(),
PayUnitTypeEnum.FREEZE_PLATFORM_FEE.getCode() + "",
PayOperationStatusEnum.FREEZE.getValue()).orNull();
if (null == orderPaymentOptional){
List<OrderPayment> orderPaymentList = checkOrderPaymentExit(param);
//如果没有冻结记录
List<OrderPayment> orderPaymentFreezeList = orderPaymentList.stream()
.filter(i -> i.getOperation().equals(PayOperationStatusEnum.FREEZE.getValue()))
.filter(i -> i.getStatus().equals(PaymentStatusEnum.SUCCESS.getValue()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(orderPaymentFreezeList)){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"数据不存在") ;
}
//冻结记录是否已经处理
List<OrderPayment> orderPaymentUnFreezeList = orderPaymentList.stream()
.filter(i -> i.getOperation().equals(PayOperationStatusEnum.UNFREEZE.getValue()))
.filter(i -> i.getStatus().equals(PaymentStatusEnum.SUCCESS.getValue()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(orderPaymentUnFreezeList)){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"冻结记录已处理") ;
}
OrderPayment orderPaymentOptional = orderPaymentFreezeList.get(0);
/** 创建记录 新的调整记录 **/
OrderPayment orderPayment = new OrderPayment()
.setAmount(param.getFigure())
......@@ -291,16 +307,37 @@ public class PaymentServiceImpl implements PaymentService {
return notify;
}
public List<OrderPayment> checkOrderPaymentExit(PayPlatformFeeParam param){
//查询冻结记录
List<OrderPayment> orderPaymentList= orderPaymentDao.listByOrderNo(param.getTradeNo(),
PayUnitTypeEnum.FREEZE_PLATFORM_FEE.getCode() + "");
if (CollectionUtils.isEmpty(orderPaymentList)){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"数据不存在") ;
}
return orderPaymentList;
}
@Override
public Result paymentCancelPlatformFee(PayPlatformFeeParam param) {
//查询冻结记录
OrderPayment orderPaymentOptional =
orderPaymentDao.selectByOrderNoAndItemIdAndOperation(param.getTradeNo(),
PayUnitTypeEnum.FREEZE_PLATFORM_FEE.getCode() + "",
PayOperationStatusEnum.FREEZE.getValue()).orNull();
if (null == orderPaymentOptional){
List<OrderPayment> orderPaymentList = checkOrderPaymentExit(param);
//如果没有冻结记录
List<OrderPayment> orderPaymentFreezeList = orderPaymentList.stream()
.filter(i -> i.getOperation().equals(PayOperationStatusEnum.FREEZE.getValue()))
.filter(i -> i.getStatus().equals(PaymentStatusEnum.SUCCESS.getValue()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(orderPaymentFreezeList)){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"数据不存在") ;
}
//冻结记录是否已经处理
List<OrderPayment> orderPaymentUnFreezeList = orderPaymentList.stream()
.filter(i -> i.getOperation().equals(PayOperationStatusEnum.UNFREEZE.getValue()))
.filter(i -> i.getStatus().equals(PaymentStatusEnum.SUCCESS.getValue()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(orderPaymentUnFreezeList)){
throw new ServiceSystemException(PerformanceResultEnum.DATA_NOT_FIND,"冻结记录已处理") ;
}
OrderPayment orderPaymentOptional = orderPaymentFreezeList.get(0);
/** 创建记录 新的调整记录 **/
OrderPayment orderPayment = new OrderPayment()
.setAmount(param.getFigure())
......@@ -367,6 +404,8 @@ public class PaymentServiceImpl implements PaymentService {
}
/**
* post请求
*/
......@@ -537,4 +576,25 @@ public class PaymentServiceImpl implements PaymentService {
return freezeBatchDTO;
}
/***
* 获取用户的钱包
* @param userCode
* @return
*/
@Override
public WalletResidueDTO getWalletAndCard(Integer userCode) {
WalletParam walletParam = new WalletParam();
walletParam.setUserCode(userCode);
Result<Object> notify = (Result<Object>) postRequest(mslPaymentConfig.getHost()
+ HttpEnum.PERFORMANCE_PAY_CLX_WALLET.getUrl(), JSON.toJSONString(walletParam));
log.info("获取司机钱包 {} 返回日志 {}",userCode, notify);
if (notify == null) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR);
}
if (notify.getCode() != 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, notify.getMsg());
}
return JSON.parseObject(notify.getData().toString(), WalletResidueDTO.class);
}
}
package com.clx.performance.service.impl.settle;
import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.settle.NetworkCaseOutRecordDao;
import com.clx.performance.dao.settle.OrderChildSyncTransportRecordDao;
import com.clx.performance.dto.PayStatusNotifyDTO;
import com.clx.performance.enums.NetworkDriverAccountEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.model.OrderChild;
import com.clx.performance.model.settle.OrderChildSyncTransportRecord;
import com.clx.performance.model.settle.SettlementDriverDetail;
import com.clx.performance.param.pc.payment.PayPlatformFeeParam;
import com.clx.performance.service.PaymentService;
import com.clx.performance.service.settle.NetworkDriverRunningWaterRecordService;
import com.clx.performance.service.settle.OrderChildSyncTransportRecordService;
import com.clx.performance.service.settle.SettlementDriverDetailService;
import com.clx.performance.service.settle.SettlementDriverService;
import com.clx.performance.struct.settle.SettlementDriverDetailStruct;
import com.msl.common.result.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
/**
* @author kavin
......@@ -36,6 +46,9 @@ public class OrderChildSyncTransportRecordServiceImpl implements OrderChildSyncT
private final SettlementDriverDetailService settlementDriverDetailService;
private final OrderChildDao orderChildDao;
private final PaymentService paymentService;
@Override
public void addOrderChildSyncTransportRecord(SettlementDriverDetail detail) {
OrderChildSyncTransportRecord record = struct.convertRecord(detail);
......@@ -44,6 +57,7 @@ public class OrderChildSyncTransportRecordServiceImpl implements OrderChildSyncT
orderChildSyncTransportRecordDao.saveEntity(record);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateStatus(PayStatusNotifyDTO payStatusNotifyDTO) {
String childNo = payStatusNotifyDTO.getChildNo();
......@@ -54,5 +68,21 @@ public class OrderChildSyncTransportRecordServiceImpl implements OrderChildSyncT
);
SettlementDriverDetail driverDetail = settlementDriverDetailService.selectOneByChildNo(childNo);
networkDriverRunningWaterRecordService.generateCaseOutSuccessRunningWaterRecord(driverDetail);
try{
//支付平台服务费
OrderChild orderChild = orderChildDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.ORDER_CHILD_NO_FOUND);
if (Objects.nonNull(orderChild.getPlatformServiceFee()) &&
!Objects.equals(orderChild.getPlatformServiceFee().intValue(), 0)) {
PayPlatformFeeParam payPlatformFeeParam = PayPlatformFeeParam.builder()
.figure(orderChild.getPlatformServiceFee().intValue())
.tradeNo(childNo)
.build();
Result result = paymentService.paymentCompletePlatformFee(payPlatformFeeParam);
log.info("运单完成 第三方回调 {} ,{} " ,childNo,result);
}
}catch (Exception e){
log.error("支付平台服务费异常 {}",e);
}
}
}
......@@ -19,6 +19,7 @@ import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.model.settle.*;
import com.clx.performance.param.pc.payment.PayParam;
import com.clx.performance.param.pc.payment.PayPlatformFeeParam;
import com.clx.performance.service.OrderChildLogService;
import com.clx.performance.service.PaymentService;
import com.clx.performance.service.impl.UniqueOrderNumService;
......@@ -316,7 +317,7 @@ public class SettlementMqHandlerServiceImpl implements SettlementMqHandlerServic
.remark(PayRemarkEnum.toString(PayRemarkEnum.FREIGHT_TO_OWNER.getValue()))
.build();
}
//支付司机运费
Result result = null;
String msg = null;
try{
......@@ -325,6 +326,20 @@ public class SettlementMqHandlerServiceImpl implements SettlementMqHandlerServic
settlementDriverNotify(detail.getChildNo(),0,e.getMessage());
msg = e.getMessage();
}
//支付平台服务费
try{
OrderChild orderChild = orderChildDao.getByChildNo(detail.getChildNo()).orElseThrow(PerformanceResultEnum.ORDER_CHILD_NO_FOUND);
if (Objects.nonNull(orderChild.getPlatformServiceFee()) &&
!Objects.equals(orderChild.getPlatformServiceFee().intValue(), 0)) {
PayPlatformFeeParam payPlatformFeeParam = PayPlatformFeeParam.builder()
.figure(orderChild.getPlatformServiceFee().intValue())
.tradeNo(detail.getChildNo())
.build();
result = paymentService.paymentCompletePlatformFee(payPlatformFeeParam);
}
}catch (Exception e){
log.error("支付平台服务费异常 {}",e);
}
if(Objects.nonNull(result)){
settlementDriverNotify(detail.getChildNo(),0,result.getMsg());
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论