提交 efe56615 作者: xiaowang

法大大认证信息、钱包优化

上级 6eb9c8c6
......@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
......@@ -79,7 +80,7 @@ public class UserFddAuthController extends BaseController {
@ApiOperation(value = "获取认证信息")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = UserFddDTO.class)})
@GetMapping("getAppUserFddInfo")
public ResultBody<UserFddDTO> getAppUserFddInfo(@ApiParam(value = "端口:0小程序 1后台") @RequestParam Integer port, HttpServletRequest request) {
public ResultBody<List<UserFddDTO>> getAppUserFddInfo(@ApiParam(value = "端口:0小程序 1后台") @RequestParam Integer port, HttpServletRequest request) {
return userFddAuthService.getAppUserFddInfo(port, this.getUserLoginInfoFromRedis(request));
}
......
......@@ -11,6 +11,7 @@ import com.mmc.iuav.user.model.vo.wallet.WalletFlowVO;
import com.mmc.iuav.user.service.wallet.PayWalletService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -57,6 +58,14 @@ public class PayWalletController extends BaseController {
return payWalletService.feignWalletFlow(walletFlowVO);
}
@ApiOperation(value = "feign-钱包流水记录(优化版)")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("optimizeWalletFlow")
@ApiIgnore
public ResultBody optimizeWalletFlow(@RequestBody WalletFlowVO walletFlowVO) {
return payWalletService.optimizeWalletFlow(walletFlowVO);
}
@ApiOperation(value = "feign-钱包流水记录不带token")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("feignWalletFlowNO")
......
......@@ -2,6 +2,7 @@ package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.UserRcdDO;
import com.mmc.iuav.user.entity.fdd.UserFddDO;
import com.mmc.iuav.user.model.qo.UserAccountQO;
import com.mmc.iuav.user.model.qo.UserRcdQO;
import org.apache.ibatis.annotations.Mapper;
......@@ -168,4 +169,5 @@ public interface UserServiceDao {
UserAccountDO getUserAccountInfoByOpenId(String openid);
List<UserFddDO> listUserFddInfo(@Param(value = "unionId") String unionId, @Param(value = "openid") String openid);
}
......@@ -5,6 +5,7 @@ import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.fdd.dto.UserFddDTO;
import java.util.List;
import java.util.Map;
/**
......@@ -25,7 +26,7 @@ public interface UserFddAuthService {
String replaceUnableString(String uid);
ResultBody<UserFddDTO> getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO);
ResultBody<List<UserFddDTO>> getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO);
ResultBody getFileByUuid(String uuid, String docType);
......
......@@ -15,6 +15,7 @@ import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.fdd.FddVerifyInfoDO;
import com.mmc.iuav.user.entity.fdd.UserFddDO;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.fdd.dto.UserFddDTO;
import com.mmc.iuav.user.model.fdd.resp.CompanyVerifyResp;
import com.mmc.iuav.user.model.fdd.resp.PersonVerifyResp;
import com.mmc.iuav.user.service.fdd.FddService;
......@@ -23,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* author:zhenjie
......@@ -242,16 +245,19 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
@Override
public ResultBody getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO) {
public ResultBody<List<UserFddDTO>> getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO) {
String uId;
String openid;
if (port == 0) {
UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId());
uId = this.replaceUnableString(userInfo.getUnionId());
openid = this.replaceUnableString(userInfo.getOpenId());
} else {
uId = loginSuccessDTO.getUserAccountId().toString();
openid = null;
}
UserFddDO appUserFddDO = userFddAuthDao.getAppUserFddInfo(uId);
return ResultBody.success(appUserFddDO == null ? null : appUserFddDO.buildUserFddDTO());
List<UserFddDO> userFddDO = userServiceDao.listUserFddInfo(uId, openid);
return ResultBody.success(userFddDO == null ? null : userFddDO.stream().map(UserFddDO::buildUserFddDTO).collect(Collectors.toList()));
}
private CompanyVerifyResp reqCompanyVerifyUrl(String customerId) {
......
......@@ -25,5 +25,6 @@ public interface PayWalletService {
ResultBody billingDetails(Integer id, String detailType);
ResultBody payUavWallet(PayUavWalletVO payUavWalletVO);
ResultBody optimizeWalletFlow(WalletFlowVO walletFlowVO);
}
......@@ -333,19 +333,10 @@ public class PayWalletServiceImpl implements PayWalletService {
}
private ResultBody publishCancelOrder(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet, Integer status) {
PayWalletDO publishUpdatePayWallet = new PayWalletDO();
publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
publishUpdatePayWallet.setPid(publishWallet.getPid());
publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount()));
publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().add(publisherWalletFlowVO.getTopYxjAmount())
.add(publisherWalletFlowVO.getUrgentYxjAmount()).subtract(publisherWalletFlowVO.getCashAmount()));
publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount()));
publishUpdatePayWallet.setSalaryFreeze(publishWallet.getSalaryFreeze().add(publisherWalletFlowVO.getTopSalaryAmount())
.add(publisherWalletFlowVO.getUrgentSalaryAmount()).subtract(publisherWalletFlowVO.getSalaryAmount()));
PayWalletDO publishUpdatePayWallet = buildPublishUpdatePayWallet(publisherWalletFlowVO, publishWallet);
int i = payWalletDao.updatePayWallet(publishUpdatePayWallet);
if ((i > 0) && (publisherWalletFlowVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0 || publisherWalletFlowVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0)) {
PayLogDO payLogDO = buildPayLogDO(publisherWalletFlowVO, null);
// 插入流水记录表
PayLogDO payLogDO = buildPayLog(publisherWalletFlowVO, null);
payWalletDao.insertPayLogDO(payLogDO);
return ResultBody.success();
} else {
......@@ -358,6 +349,21 @@ public class PayWalletServiceImpl implements PayWalletService {
}
}
private PayWalletDO buildPublishUpdatePayWallet(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet) {
PayWalletDO publishUpdatePayWallet = new PayWalletDO();
publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
publishUpdatePayWallet.setPid(publishWallet.getPid());
publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount()));
publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().add(publisherWalletFlowVO.getTopYxjAmount())
.add(publisherWalletFlowVO.getUrgentYxjAmount()).subtract(publisherWalletFlowVO.getCashAmount()));
publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount()));
publishUpdatePayWallet.setSalaryFreeze(publishWallet.getSalaryFreeze().add(publisherWalletFlowVO.getTopSalaryAmount())
.add(publisherWalletFlowVO.getUrgentSalaryAmount()).subtract(publisherWalletFlowVO.getSalaryAmount()));
return publishUpdatePayWallet;
}
/**
* @param publisherWalletFlowVO
* @param flag 0 未违约取消 1 违约取消
......@@ -585,10 +591,12 @@ public class PayWalletServiceImpl implements PayWalletService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody payUavWallet(PayUavWalletVO payUavWalletVO) {
// 获取用户钱包信息
PayWalletDO userWalletInfo = payWalletDao.getPayWalletByUser(payUavWalletVO.getUserAccountId());
String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + payUavWalletVO.getUserAccountId() + CodeUtil.getRandomNum(4);
// 记录流水用户钱包流水记录
PayLogDO payLogDO = new PayLogDO();
payLogDO.setUserAccountId(payUavWalletVO.getUserAccountId());
......@@ -599,53 +607,255 @@ public class PayWalletServiceImpl implements PayWalletService {
PayWalletDO payWalletDO = new PayWalletDO();
payWalletDO.setPid(userWalletInfo.getPid());
payWalletDO.setUserAccountId(payUavWalletVO.getUserAccountId());
// 判断当前订单状态是什么类型
if (payUavWalletVO.getOrderStatus().equals(PayMethodEnums.PUBLISH_ORDER.getCode())) {
// 获取下单金额是否大于该用户钱包金额
if (userWalletInfo.getCashAmt().compareTo(payUavWalletVO.getCashAmount()) < 0) {
return ResultBody.error("可抵扣的云享金不足");
}
if (userWalletInfo.getSalaryAmt().compareTo(payUavWalletVO.getSalaryAmount()) < 0) {
return ResultBody.error("可抵扣的佣金不足");
Integer orderStatus = payUavWalletVO.getOrderStatus();
if (orderStatus.equals(PayMethodEnums.PUBLISH_ORDER.getCode())) {
return handlePublishOrder(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
} else if (orderStatus.equals(PayMethodEnums.PAY_UAV_ORDER_REFUND.getCode())) {
return handleOrderRefund(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
} else if (orderStatus.equals(PayMethodEnums.ORDER_INCOME.getCode())) {
return handleOrderIncome(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
} else {
return handleConfirmReceipt(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
}
}
@Transactional(rollbackFor = Exception.class)
public ResultBody handlePublishOrder(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) {
// 获取下单金额是否大于该用户钱包金额
if (userWalletInfo.getCashAmt().compareTo(payUavWalletVO.getCashAmount()) < 0) {
return ResultBody.error("可抵扣的云享金不足");
}
if (userWalletInfo.getSalaryAmt().compareTo(payUavWalletVO.getSalaryAmount()) < 0) {
return ResultBody.error("可抵扣的佣金不足");
}
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
if (payUavWalletVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0) {
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount().negate());
} else {
payLogDO.setCashAmtPaid(BigDecimal.ZERO);
}
if (payUavWalletVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0) {
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount().negate());
} else {
payLogDO.setSalaryAmtPaid(BigDecimal.ZERO);
}
// 如果是100 扣减余额冻结金额
payWalletDO.setCashAmt(userWalletInfo.getCashAmt().subtract(payUavWalletVO.getCashAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashAmt().add(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
payWalletDao.insertPayLogDO(payLogDO);
payWalletDao.updatePayWallet(payWalletDO);
return ResultBody.success();
}
@Transactional(rollbackFor = Exception.class)
public ResultBody handleOrderRefund(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) {
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount());
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
// 如果是1400 回滚解冻金额
payWalletDO.setCashAmt(userWalletInfo.getCashAmt().add(payUavWalletVO.getCashAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashAmt().subtract(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDao.insertPayLogDO(payLogDO);
payWalletDao.updatePayWallet(payWalletDO);
return ResultBody.success();
}
@Transactional(rollbackFor = Exception.class)
public ResultBody handleOrderIncome(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) {
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
payLogDO.setCashAmtPaid(BigDecimal.ZERO);
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
// 订单收益
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
payWalletDao.insertPayLogDO(payLogDO);
payWalletDao.updatePayWallet(payWalletDO);
return ResultBody.success();
}
@Transactional(rollbackFor = Exception.class)
public ResultBody handleConfirmReceipt(PayUavWalletVO payUavWalletVO, PayWalletDO userWalletInfo, PayLogDO payLogDO, PayWalletDO payWalletDO) {
// 确认收货,解冻用户钱包信息
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryFreeze().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashFreeze().subtract(payUavWalletVO.getCashAmount()));
payWalletDao.insertPayLogDO(payLogDO);
payWalletDao.updatePayWallet(payWalletDO);
return ResultBody.success();
}
@Override
// TODO 还未优化完
public ResultBody optimizeWalletFlow(WalletFlowVO walletFlowVO) {
// 获取发布者和接单者的信息
PublisherWalletFlowVO publisherWalletFlowVO = walletFlowVO.getPublisherWalletFlowVO();
FlyerWalletFlowVO flyerWalletFlowVO = walletFlowVO.getFlyerWalletFlowVO();
// 发布者和接单者的钱包信息
PayWalletDO publishWallet = (publisherWalletFlowVO != null) ? payWalletDao.getPayWalletByUser(publisherWalletFlowVO.getUserAccountId()) : new PayWalletDO();
PayWalletDO flyerWallet = (flyerWalletFlowVO != null) ? payWalletDao.getPayWalletByUser(flyerWalletFlowVO.getUserAccountId()) : new PayWalletDO();
// 判断状态进行资金的扣减等于100时 发布订单
if (publisherWalletFlowVO != null) {
Integer modeOfPayment = publisherWalletFlowVO.getModeOfPayment();
if (modeOfPayment.equals(PayMethodEnums.PUBLISH_ORDER.getCode())) {
return handleOrderPublish(publisherWalletFlowVO, publishWallet);
} else if (modeOfPayment.equals(PayMethodEnums.CANCEL_ORDER_TAKING.getCode())) {
// 等于200时 发布方取消订单,无飞手接单
return publishCancelOrder(publisherWalletFlowVO, publishWallet, 200);
} else if (modeOfPayment.equals(PayMethodEnums.RECEIVED_ORDER_CANCEL.getCode())) {
// 等于300时 发布方取消订单,有飞手接单
return handleReceivedOrderCancel(publisherWalletFlowVO, publishWallet, flyerWalletFlowVO, flyerWallet);
}
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
if (payUavWalletVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0) {
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount().negate());
}
return ResultBody.error("无效的支付方式");
}
private ResultBody handleReceivedOrderCancel(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet, FlyerWalletFlowVO flyerWalletFlowVO, PayWalletDO flyerWallet) {
// 等于300时 发布方取消订单,有飞手接单
PayWalletDO publishUpdatePayWallet = new PayWalletDO();
publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
publishUpdatePayWallet.setPid(publishWallet.getPid());
publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount()));
publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().subtract(publisherWalletFlowVO.getCashAmount())
.subtract(publisherWalletFlowVO.getYxjCashPledge().abs()).subtract(publisherWalletFlowVO.getTopYxjAmount().abs())
.subtract(publisherWalletFlowVO.getUrgentYxjAmount().abs()));
publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount()));
publishUpdatePayWallet.setSalaryFreeze(publishWallet.getSalaryFreeze().subtract(publisherWalletFlowVO.getSalaryCashPledge().abs())
.subtract(publisherWalletFlowVO.getSalaryAmount()).subtract(publisherWalletFlowVO.getUrgentSalaryAmount().abs())
.subtract(publisherWalletFlowVO.getTopSalaryAmount().abs()));
// 更新发布者钱包数据
int publishUpdateCount = payWalletDao.updatePayWallet(publishUpdatePayWallet);
if (publishUpdateCount <= 0) {
log.error("发布方取消订单,有飞手接单时,发单方用户钱包更新失败,更新参数是:{},发单方用户id是:{},传入参数是:{}", publishUpdatePayWallet, publisherWalletFlowVO.getUserAccountId(), publisherWalletFlowVO);
return ResultBody.error("钱包操作错误");
}
if (publisherWalletFlowVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0 || publisherWalletFlowVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0) {
// 插入发布者流水记录表
sendBackPublishPayLog(publisherWalletFlowVO, 1);
}
// 处理飞手钱包数据
return handleRenegeOperate(publisherWalletFlowVO, null, flyerWalletFlowVO, flyerWallet, 1);
}
/**
* @param publisherWalletFlowVO
* @param publishWallet
* @param flyerWalletFlowVO
* @param flyerWallet
* @param renege 1:发布方违约 2:飞手方违约
* @return
*/
private ResultBody handleRenegeOperate(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet, FlyerWalletFlowVO flyerWalletFlowVO, PayWalletDO flyerWallet, Integer renege) {
PayWalletDO updatePayWallet = new PayWalletDO();
if (renege == 1) {
updatePayWallet.setUserAccountId(flyerWalletFlowVO.getUserAccountId());
updatePayWallet.setPid(flyerWallet.getPid());
updatePayWallet.setCashAmt(flyerWallet.getCashAmt().add(flyerWalletFlowVO.getCashAmount()));
updatePayWallet.setCashFreeze(flyerWallet.getCashFreeze().subtract(flyerWalletFlowVO.getCashAmount()));
updatePayWallet.setSalaryAmt(flyerWallet.getSalaryAmt().add(flyerWalletFlowVO.getSalaryAmount()).subtract(publisherWalletFlowVO.getPercentagePenaltyOfOrder()));
updatePayWallet.setSalaryFreeze(flyerWallet.getSalaryFreeze().subtract(flyerWalletFlowVO.getSalaryAmount()));
int flyerUpdateCount = payWalletDao.updatePayWallet(updatePayWallet);
if (flyerUpdateCount > 0) {
// 记录订单保证金退回记录
if (flyerWalletFlowVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0 || flyerWalletFlowVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0) {
sendBackPledge(flyerWalletFlowVO);
}
// 获得违约金流水记录
paymentOfLiquidatedDamage(publisherWalletFlowVO, flyerWalletFlowVO, 0);
return ResultBody.success();
} else {
payLogDO.setCashAmtPaid(BigDecimal.ZERO);
log.error("发布方取消订单,有飞手接单时,飞手用户钱包更新失败,飞手用户id是:{},接单方传入参数是:{},发单方违约金是:{}", flyerWalletFlowVO.getUserAccountId(), flyerWalletFlowVO, publisherWalletFlowVO.getPercentagePenaltyOfOrder());
return ResultBody.error("钱包操作错误");
}
if (payUavWalletVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0) {
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount().negate());
} else {
updatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
updatePayWallet.setPid(publishWallet.getPid());
updatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount())
.add(publisherWalletFlowVO.getTopYxjAmount()).add(publisherWalletFlowVO.getTopYxjAmount()));
updatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount())
.subtract(flyerWalletFlowVO.getPercentagePenaltyOfOrder()));
updatePayWallet.setCashFreeze(publishWallet.getCashFreeze().subtract(publisherWalletFlowVO.getCashAmount())
.subtract(publisherWalletFlowVO.getUrgentYxjAmount()).subtract(publisherWalletFlowVO.getTopYxjAmount()));
updatePayWallet.setSalaryFreeze(publishWallet.getSalaryFreeze().subtract(publisherWalletFlowVO.getSalaryAmount())
.subtract(publisherWalletFlowVO.getUrgentSalaryAmount()).subtract(publisherWalletFlowVO.getTopSalaryAmount()));
int publishUpdateCount = payWalletDao.updatePayWallet(updatePayWallet);
if (publishUpdateCount > 0) {
// 记录飞手违约金流水
paymentOfLiquidatedDamage(publisherWalletFlowVO, flyerWalletFlowVO, 1);
if (publisherWalletFlowVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0
|| publisherWalletFlowVO.getUrgentYxjAmount().compareTo(BigDecimal.ZERO) > 0
|| publisherWalletFlowVO.getTopYxjAmount().compareTo(BigDecimal.ZERO) > 0
|| publisherWalletFlowVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0
|| publisherWalletFlowVO.getUrgentSalaryAmount().compareTo(BigDecimal.ZERO) > 0
|| publisherWalletFlowVO.getTopSalaryAmount().compareTo(BigDecimal.ZERO) > 0) {
// 记录退回订单金额
sendBackPublishPayLog(publisherWalletFlowVO, 0);
}
return ResultBody.success();
} else {
payLogDO.setSalaryAmtPaid(BigDecimal.ZERO);
log.error("飞手有责取消订单,发布者用户钱包更新失败,发布者用户id是:{},发布方传入参数是:{},接单方方违约金是:{}", publisherWalletFlowVO.getUserAccountId(), publisherWalletFlowVO, flyerWalletFlowVO.getPercentagePenaltyOfOrder());
return ResultBody.error("钱包操作错误");
}
// 如果是100 扣减余额冻结金额
payWalletDO.setCashAmt(userWalletInfo.getCashAmt().subtract(payUavWalletVO.getCashAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashAmt().add(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
} else if (payUavWalletVO.getOrderStatus().equals(PayMethodEnums.PAY_UAV_ORDER_REFUND.getCode())) {
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount());
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
// 如果是1400 回滚解冻金额
payWalletDO.setCashAmt(userWalletInfo.getCashAmt().add(payUavWalletVO.getCashAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashAmt().subtract(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount()));
} else if (payUavWalletVO.getOrderStatus().equals(PayMethodEnums.ORDER_INCOME.getCode())) {
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus());
payLogDO.setCashAmtPaid(BigDecimal.ZERO);
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
// 订单收益
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
}
}
private ResultBody handleOrderPublish(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet) {
PayWalletDO publishUpdatePayWallet = new PayWalletDO();
publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
publishUpdatePayWallet.setPid(publishWallet.getPid());
publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().subtract(publisherWalletFlowVO.getCashAmount().abs())
.subtract(publisherWalletFlowVO.getTopYxjAmount().abs()).subtract(publisherWalletFlowVO.getUrgentYxjAmount().abs()));
publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().add(publisherWalletFlowVO.getCashAmount().abs())
.add(publisherWalletFlowVO.getTopYxjAmount().abs()).add(publisherWalletFlowVO.getUrgentYxjAmount().abs()));
publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().subtract(publisherWalletFlowVO.getSalaryAmount().abs())
.subtract(publisherWalletFlowVO.getTopSalaryAmount().abs()).subtract(publisherWalletFlowVO.getUrgentSalaryAmount()).abs());
publishUpdatePayWallet.setSalaryFreeze(publishWallet.getSalaryFreeze().add(publisherWalletFlowVO.getSalaryAmount().abs())
.add(publisherWalletFlowVO.getTopSalaryAmount().abs()).add(publisherWalletFlowVO.getUrgentSalaryAmount().abs()));
int update = payWalletDao.updatePayWallet(publishUpdatePayWallet);
if (update > 0) {
PayLogDO payLogDO = buildPayLog(publisherWalletFlowVO, null);
payLogDO.setCashAmtPaid(publisherWalletFlowVO.getCashAmount().add(publisherWalletFlowVO.getTopYxjAmount()).add(publisherWalletFlowVO.getUrgentYxjAmount()));
payLogDO.setSalaryAmtPaid(publisherWalletFlowVO.getSalaryAmount().add(publisherWalletFlowVO.getTopSalaryAmount()).add(publisherWalletFlowVO.getUrgentSalaryAmount()));
// 插入流水记录表
payWalletDao.insertPayLogDO(payLogDO);
return ResultBody.success();
} else {
// 确认收货,解冻用户钱包信息
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryFreeze().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDO.setCashFreeze(userWalletInfo.getCashFreeze().subtract(payUavWalletVO.getCashAmount()));
log.error("发布订单时,用户钱包更新失败,用户id是:{},传入参数是:{}", publisherWalletFlowVO.getUserAccountId(), publisherWalletFlowVO);
return ResultBody.error("钱包操作错误");
}
payWalletDao.insertPayLogDO(payLogDO);
payWalletDao.updatePayWallet(payWalletDO);
return ResultBody.success();
}
public PayLogDO buildPayLog(PublisherWalletFlowVO publisherWalletFlowVO, FlyerWalletFlowVO flyerWalletFlowVO) {
if (publisherWalletFlowVO != null) {
return createPayLog(publisherWalletFlowVO.getUserAccountId(), publisherWalletFlowVO.getModeOfPayment(),
publisherWalletFlowVO.getCashAmount(), publisherWalletFlowVO.getSalaryAmount(),
publisherWalletFlowVO.getTimeOfPayment(), publisherWalletFlowVO.getOperateUserAccountId());
}
if (flyerWalletFlowVO != null) {
return createPayLog(flyerWalletFlowVO.getUserAccountId(), flyerWalletFlowVO.getModeOfPayment(),
flyerWalletFlowVO.getCashAmount(), flyerWalletFlowVO.getSalaryAmount(),
flyerWalletFlowVO.getTimeOfPayment(), flyerWalletFlowVO.getOperateUserAccountId());
}
return null;
}
private PayLogDO createPayLog(Integer userAccountId, Integer modeOfPayment, BigDecimal cashAmount, BigDecimal salaryAmount, Date timeOfPayment, Integer operateUserAccountId) {
PayLogDO payLogDO = new PayLogDO();
String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + userAccountId + CodeUtil.getRandomNum(4);
payLogDO.setPayMethod(modeOfPayment);
payLogDO.setPayNo(payNo);
payLogDO.setUserAccountId(userAccountId);
payLogDO.setCashAmtPaid(cashAmount);
payLogDO.setSalaryAmtPaid(salaryAmount);
payLogDO.setPayTime(timeOfPayment);
payLogDO.setOperateUser(operateUserAccountId);
return payLogDO;
}
}
......@@ -462,5 +462,22 @@
where open_id = #{openid}
and disable = 0
</select>
<select id="listUserFddInfo" resultType="com.mmc.iuav.user.entity.fdd.UserFddDO">
select id,
customer_id,
union_id,
person_verify_status,
ent_verify_status,
account_type,
create_time,
update_time
from user_fdd
<where>
union_id = #{unionId}
<if test="openid != null">
or union_id = #{openid}
</if>
</where>
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论