提交 fd7e19f6 作者: zhenjie

Merge branch 'develop'

package com.mmc.iuav.user.model.fdd.vo; package com.mmc.iuav.user.model.fdd.vo;
import com.mmc.iuav.group.Insert;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -18,19 +19,19 @@ import java.io.Serializable; ...@@ -18,19 +19,19 @@ import java.io.Serializable;
@AllArgsConstructor @AllArgsConstructor
public class ContractVO implements Serializable { public class ContractVO implements Serializable {
private static final long serialVersionUID = 570570471824495498L; private static final long serialVersionUID = 570570471824495498L;
@ApiModelProperty(value = "合同地址") @ApiModelProperty(value = "合同地址", required = true)
@NotNull(message = "合同地址不能为空") @NotNull(message = "合同地址不能为空", groups = {Insert.class})
private String docUrl; private String docUrl;
@ApiModelProperty(value = "订单编号") @ApiModelProperty(value = "订单编号", required = true)
@NotNull(message = "订单编号不能为空") @NotNull(message = "订单编号不能为空", groups = {Insert.class})
private String orderNo; private String orderNo;
@ApiModelProperty(value = "合同标题") @ApiModelProperty(value = "合同标题", required = true)
@NotNull(message = "合同标题不能为空") @NotNull(message = "合同标题不能为空", groups = {Insert.class})
private String title; private String title;
@ApiModelProperty(value = "端口:0小程序 1后台") @ApiModelProperty(value = "端口:0小程序 1后台", required = true)
private Integer port; private Integer port;
@ApiModelProperty(value = "unionId", hidden = true) @ApiModelProperty(value = "unionId", hidden = true)
......
...@@ -29,7 +29,7 @@ public class PayUavWalletVO implements Serializable { ...@@ -29,7 +29,7 @@ public class PayUavWalletVO implements Serializable {
@ApiModelProperty(value = "佣金") @ApiModelProperty(value = "佣金")
private BigDecimal salaryAmount; private BigDecimal salaryAmount;
@ApiModelProperty(value = "订单状态 100:订单支付 1400:商城订单退款 1500:订单提成", required = true) @ApiModelProperty(value = "订单状态 100:订单支付 1400:商城订单退款 1500:订单提成 999:确认收货", required = true)
private Integer orderStatus; private Integer orderStatus;
@ApiModelProperty(value = "订单备注") @ApiModelProperty(value = "订单备注")
......
...@@ -28,7 +28,7 @@ public class FddConstant { ...@@ -28,7 +28,7 @@ public class FddConstant {
//小程序企业实名认证异步回调 //小程序企业实名认证异步回调
public static final String NOTIFY_E_CERT_RES = "fdd/auth/notifyECertRes"; public static final String NOTIFY_E_CERT_RES = "fdd/auth/notifyECertRes";
//签署合同异步回调 //签署合同异步回调
public static final String NOTIFY_STAMP = "/fdd/contract/notifyStamp"; public static final String NOTIFY_STAMP = "fdd/contract/notifyStamp";
public static final String APP_ID = "appId"; public static final String APP_ID = "appId";
......
package com.mmc.iuav.user.controller.fdd; package com.mmc.iuav.user.controller.fdd;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.BaseController; import com.mmc.iuav.user.controller.BaseController;
import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO; import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO;
...@@ -7,6 +8,7 @@ import com.mmc.iuav.user.model.fdd.vo.ContractVO; ...@@ -7,6 +8,7 @@ import com.mmc.iuav.user.model.fdd.vo.ContractVO;
import com.mmc.iuav.user.service.fdd.ContractService; import com.mmc.iuav.user.service.fdd.ContractService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -29,7 +31,7 @@ public class ContractController extends BaseController { ...@@ -29,7 +31,7 @@ public class ContractController extends BaseController {
@ApiOperation(value = "上传合同") @ApiOperation(value = "上传合同")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/uploadContract") @PostMapping("/uploadContract")
public ResultBody uploadContract(@RequestBody ContractVO param, HttpServletRequest request) { public ResultBody uploadContract(@Validated(value = {Insert.class}) @RequestBody ContractVO param, HttpServletRequest request) {
return contractService.uploadContract(param, this.getUserLoginInfoFromRedis(request)); return contractService.uploadContract(param, this.getUserLoginInfoFromRedis(request));
} }
......
...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -79,7 +80,7 @@ public class UserFddAuthController extends BaseController { ...@@ -79,7 +80,7 @@ public class UserFddAuthController extends BaseController {
@ApiOperation(value = "获取认证信息") @ApiOperation(value = "获取认证信息")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = UserFddDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = UserFddDTO.class)})
@GetMapping("getAppUserFddInfo") @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)); return userFddAuthService.getAppUserFddInfo(port, this.getUserLoginInfoFromRedis(request));
} }
......
...@@ -11,6 +11,7 @@ import com.mmc.iuav.user.model.vo.wallet.WalletFlowVO; ...@@ -11,6 +11,7 @@ import com.mmc.iuav.user.model.vo.wallet.WalletFlowVO;
import com.mmc.iuav.user.service.wallet.PayWalletService; import com.mmc.iuav.user.service.wallet.PayWalletService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -57,6 +58,14 @@ public class PayWalletController extends BaseController { ...@@ -57,6 +58,14 @@ public class PayWalletController extends BaseController {
return payWalletService.feignWalletFlow(walletFlowVO); 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") @ApiOperation(value = "feign-钱包流水记录不带token")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("feignWalletFlowNO") @PostMapping("feignWalletFlowNO")
...@@ -79,7 +88,7 @@ public class PayWalletController extends BaseController { ...@@ -79,7 +88,7 @@ public class PayWalletController extends BaseController {
return payWalletService.billingDetails(id, detailType); return payWalletService.billingDetails(id, detailType);
} }
@ApiOperation(value = "商城订单钱包流水加扣记录", hidden = true) @ApiOperation(value = "商城订单钱包流水加扣记录")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("feignPayUavWallet") @PostMapping("feignPayUavWallet")
public ResultBody payUavWallet(@RequestBody PayUavWalletVO payUavWalletVO) { public ResultBody payUavWallet(@RequestBody PayUavWalletVO payUavWalletVO) {
......
...@@ -2,6 +2,7 @@ package com.mmc.iuav.user.dao; ...@@ -2,6 +2,7 @@ package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.UserAccountDO; import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.UserRcdDO; 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.UserAccountQO;
import com.mmc.iuav.user.model.qo.UserRcdQO; import com.mmc.iuav.user.model.qo.UserRcdQO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -168,4 +169,5 @@ public interface UserServiceDao { ...@@ -168,4 +169,5 @@ public interface UserServiceDao {
UserAccountDO getUserAccountInfoByOpenId(String openid); UserAccountDO getUserAccountInfoByOpenId(String openid);
List<UserFddDO> listUserFddInfo(@Param(value = "unionId") String unionId, @Param(value = "openid") String openid);
} }
package com.mmc.iuav.user.mq; package com.mmc.iuav.user.mq;
import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO;
import com.mmc.iuav.user.model.vo.UserAccountVO; import com.mmc.iuav.user.model.vo.UserAccountVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/** /**
* @author: zj * @author: zj
...@@ -13,7 +10,15 @@ import org.springframework.stereotype.Component; ...@@ -13,7 +10,15 @@ import org.springframework.stereotype.Component;
public interface MqProducer { public interface MqProducer {
/** /**
* 用户信息变更 * 用户信息变更
*
* @param userAccountVO * @param userAccountVO
*/ */
public void sentUserInfoChangedMsg(UserAccountVO userAccountVO); public void sentUserInfoChangedMsg(UserAccountVO userAccountVO);
/**
* 合同签署完成
*
* @param contractInfoDTO
*/
public void sentFinishOrderSign(ContractInfoDTO contractInfoDTO);
} }
...@@ -24,4 +24,11 @@ public class RabbitmqConstant { ...@@ -24,4 +24,11 @@ public class RabbitmqConstant {
*/ */
public final static String USER_TOP_UP_SUCCESS_QUEUE = "USER_TOP_UP_SUCCESS_QUEUE"; public final static String USER_TOP_UP_SUCCESS_QUEUE = "USER_TOP_UP_SUCCESS_QUEUE";
public final static String USER_TOP_UP_SUCCESS_ROUTING_KEY = "USER_TOP_UP_SUCCESS_ROUTING_KEY"; public final static String USER_TOP_UP_SUCCESS_ROUTING_KEY = "USER_TOP_UP_SUCCESS_ROUTING_KEY";
/**
* 合同签署成功队列、routing_key
*/
public final static String ORDER_SIGN_EXCHANGE = "ORDER_SIGN_EXCHANGE";
public final static String ORDER_SIGN_FINISH_QUEUE = "ORDER_SIGN_FINISH_QUEUE";
public final static String ORDER_SIGN_SUCCESS_ROUTING_KEY = "ORDER_SIGN_SUCCESS_ROUTING_KEY";
} }
package com.mmc.iuav.user.mq.impl; package com.mmc.iuav.user.mq.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO;
import com.mmc.iuav.user.model.vo.UserAccountVO; import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.mq.MqProducer; import com.mmc.iuav.user.mq.MqProducer;
import com.mmc.iuav.user.mq.constant.RabbitmqConstant; import com.mmc.iuav.user.mq.constant.RabbitmqConstant;
...@@ -24,4 +25,10 @@ public class MqProducerImpl implements MqProducer { ...@@ -24,4 +25,10 @@ public class MqProducerImpl implements MqProducer {
log.info("sentUserInfoChangedMsg:{}", JSONObject.toJSONString(userAccountVO)); log.info("sentUserInfoChangedMsg:{}", JSONObject.toJSONString(userAccountVO));
rabbitTemplate.convertAndSend(RabbitmqConstant.USER_INFO_UPDATE_FANOUT_EXCHANGE, "", JSONObject.toJSONString(userAccountVO)); rabbitTemplate.convertAndSend(RabbitmqConstant.USER_INFO_UPDATE_FANOUT_EXCHANGE, "", JSONObject.toJSONString(userAccountVO));
} }
@Override
public void sentFinishOrderSign(ContractInfoDTO contractInfoDTO) {
log.info("sentUserInfoChangedMsg:{}", JSONObject.toJSONString(contractInfoDTO));
rabbitTemplate.convertAndSend(RabbitmqConstant.ORDER_SIGN_EXCHANGE, RabbitmqConstant.ORDER_SIGN_SUCCESS_ROUTING_KEY, JSONObject.toJSONString(contractInfoDTO));
}
} }
...@@ -5,6 +5,7 @@ import com.mmc.iuav.response.ResultBody; ...@@ -5,6 +5,7 @@ import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO; import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.fdd.dto.UserFddDTO; import com.mmc.iuav.user.model.fdd.dto.UserFddDTO;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -25,7 +26,7 @@ public interface UserFddAuthService { ...@@ -25,7 +26,7 @@ public interface UserFddAuthService {
String replaceUnableString(String uid); 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); ResultBody getFileByUuid(String uuid, String docType);
......
...@@ -15,6 +15,7 @@ import com.mmc.iuav.user.entity.fdd.UserFddDO; ...@@ -15,6 +15,7 @@ import com.mmc.iuav.user.entity.fdd.UserFddDO;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO; import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO; import com.mmc.iuav.user.model.fdd.dto.ContractInfoDTO;
import com.mmc.iuav.user.model.fdd.vo.ContractVO; import com.mmc.iuav.user.model.fdd.vo.ContractVO;
import com.mmc.iuav.user.mq.MqProducer;
import com.mmc.iuav.user.service.fdd.ContractService; import com.mmc.iuav.user.service.fdd.ContractService;
import com.mmc.iuav.user.service.fdd.SealManageService; import com.mmc.iuav.user.service.fdd.SealManageService;
import com.mmc.iuav.user.util.TDateUtil; import com.mmc.iuav.user.util.TDateUtil;
...@@ -40,6 +41,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -40,6 +41,8 @@ public class ContractServiceImpl implements ContractService {
ContractDao contractDao; ContractDao contractDao;
@Resource @Resource
SealManageService sealManageService; SealManageService sealManageService;
@Resource
private MqProducer mqProducer;
/** /**
* 上传合同 * 上传合同
...@@ -50,6 +53,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -50,6 +53,9 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public ResultBody uploadContract(ContractVO param, LoginSuccessDTO loginSuccessDTO) { public ResultBody uploadContract(ContractVO param, LoginSuccessDTO loginSuccessDTO) {
ResultBody resultBody = sealManageService.checkAuthStatus(param.getPort(), loginSuccessDTO); ResultBody resultBody = sealManageService.checkAuthStatus(param.getPort(), loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddDO = (UserFddDO) resultBody.getResult(); UserFddDO userFddDO = (UserFddDO) resultBody.getResult();
FddBaseClient baseClient = new FddBaseClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST); FddBaseClient baseClient = new FddBaseClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST);
// 查询这个订单号之前有没有上传过合同有的话就删除 // 查询这个订单号之前有没有上传过合同有的话就删除
...@@ -116,6 +122,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -116,6 +122,9 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public ResultBody stamp(String contractId, LoginSuccessDTO loginSuccessDTO, String pages, Integer port) { public ResultBody stamp(String contractId, LoginSuccessDTO loginSuccessDTO, String pages, Integer port) {
ResultBody resultBody = sealManageService.checkAuthStatus(port, loginSuccessDTO); ResultBody resultBody = sealManageService.checkAuthStatus(port, loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddDO = (UserFddDO) resultBody.getResult(); UserFddDO userFddDO = (UserFddDO) resultBody.getResult();
// 获取合同信息 // 获取合同信息
ContractInfoDO contractInfo = contractDao.contractInfoByOrderNo(null, contractId); ContractInfoDO contractInfo = contractDao.contractInfoByOrderNo(null, contractId);
...@@ -189,6 +198,10 @@ public class ContractServiceImpl implements ContractService { ...@@ -189,6 +198,10 @@ public class ContractServiceImpl implements ContractService {
updateSignStatus.setSignStatus(4); updateSignStatus.setSignStatus(4);
updateSignStatus.setBRemark(resultDesc); updateSignStatus.setBRemark(resultDesc);
updateSignStatus.setSingerTime(new Date()); updateSignStatus.setSingerTime(new Date());
// 同步订单状态
ContractInfoDTO contractInfoDTO = contractInfoDO.buildContractInfoDTO();
contractInfoDTO.setSignStatus(4);
mqProducer.sentFinishOrderSign(contractInfoDTO);
} else if (contractInfoDO.getSignStatus() == 2 && FddConstant.SIGN_FAIL.equals(resultCode) && contractInfoDO.getBTransactionId().equals(transactionId)) { } else if (contractInfoDO.getSignStatus() == 2 && FddConstant.SIGN_FAIL.equals(resultCode) && contractInfoDO.getBTransactionId().equals(transactionId)) {
// 乙方公司签章失败 // 乙方公司签章失败
updateSignStatus.setSignStatus(3); updateSignStatus.setSignStatus(3);
...@@ -200,7 +213,10 @@ public class ContractServiceImpl implements ContractService { ...@@ -200,7 +213,10 @@ public class ContractServiceImpl implements ContractService {
@Override @Override
public ResultBody file(String contractId, LoginSuccessDTO loginSuccessDTO, Integer port) { public ResultBody file(String contractId, LoginSuccessDTO loginSuccessDTO, Integer port) {
sealManageService.checkAuthStatus(port, loginSuccessDTO); ResultBody resultBody = sealManageService.checkAuthStatus(port, loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
// 判断该合同状态是否可以归档 // 判断该合同状态是否可以归档
ContractInfoDO contractInfoDO = contractDao.contractInfoByOrderNo(null, contractId); ContractInfoDO contractInfoDO = contractDao.contractInfoByOrderNo(null, contractId);
if (!contractInfoDO.getSignStatus().equals(4)) { if (!contractInfoDO.getSignStatus().equals(4)) {
......
...@@ -53,6 +53,9 @@ public class SealManageServiceImpl implements SealManageService { ...@@ -53,6 +53,9 @@ public class SealManageServiceImpl implements SealManageService {
@Override @Override
public ResultBody uploadSeal(SealVO sealVO, LoginSuccessDTO loginSuccessDTO) { public ResultBody uploadSeal(SealVO sealVO, LoginSuccessDTO loginSuccessDTO) {
ResultBody resultBody = this.checkAuthStatus(sealVO.getPort(), loginSuccessDTO); ResultBody resultBody = this.checkAuthStatus(sealVO.getPort(), loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddInfo = (UserFddDO) resultBody.getResult(); UserFddDO userFddInfo = (UserFddDO) resultBody.getResult();
sealVO.setUnionId(userFddInfo.getUnionId()); sealVO.setUnionId(userFddInfo.getUnionId());
FddBaseClient baseClient = new FddBaseClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST); FddBaseClient baseClient = new FddBaseClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST);
...@@ -119,6 +122,9 @@ public class SealManageServiceImpl implements SealManageService { ...@@ -119,6 +122,9 @@ public class SealManageServiceImpl implements SealManageService {
@Override @Override
public ResultBody removeSeal(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) { public ResultBody removeSeal(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) {
ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO); ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddInfo = (UserFddDO) resultBody.getResult(); UserFddDO userFddInfo = (UserFddDO) resultBody.getResult();
// 调用法大大删除印章接口 // 调用法大大删除印章接口
FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST); FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST);
...@@ -140,7 +146,24 @@ public class SealManageServiceImpl implements SealManageService { ...@@ -140,7 +146,24 @@ public class SealManageServiceImpl implements SealManageService {
String uid; String uid;
if (port.equals(0)) { if (port.equals(0)) {
UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId()); UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId());
uid = userFddAuthService.replaceUnableString(userInfo.getUnionId()); String unionId = userInfo.getUnionId();
uid = userFddAuthService.replaceUnableString(unionId);
UserFddDO userFddInfo = userFddAuthDao.getAppUserFddInfo(uid);
if (userFddInfo == null) {
uid = userFddAuthService.replaceUnableString(userInfo.getOpenId());
} else {
Integer accountType = userFddInfo.getAccountType();
Integer personVerifyStatus = userFddInfo.getPersonVerifyStatus();
Integer entVerifyStatus = userFddInfo.getEntVerifyStatus();
boolean isPersonVerified = !accountType.equals(1) && personVerifyStatus.equals(2);
boolean isEntVerified = !accountType.equals(2) && entVerifyStatus.equals(4);
if (isPersonVerified || isEntVerified) {
uid = userFddAuthService.replaceUnableString(userInfo.getOpenId());
}
}
} else { } else {
uid = loginSuccessDTO.getUserAccountId().toString(); uid = loginSuccessDTO.getUserAccountId().toString();
} }
...@@ -161,6 +184,9 @@ public class SealManageServiceImpl implements SealManageService { ...@@ -161,6 +184,9 @@ public class SealManageServiceImpl implements SealManageService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultBody defaultSeal(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) { public ResultBody defaultSeal(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) {
ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO); ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddInfo = (UserFddDO) resultBody.getResult(); UserFddDO userFddInfo = (UserFddDO) resultBody.getResult();
FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST); FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST);
DefaultSignatureParams params = new DefaultSignatureParams(); DefaultSignatureParams params = new DefaultSignatureParams();
...@@ -181,6 +207,9 @@ public class SealManageServiceImpl implements SealManageService { ...@@ -181,6 +207,9 @@ public class SealManageServiceImpl implements SealManageService {
@Override @Override
public ResultBody getSealInfo(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) { public ResultBody getSealInfo(String signatureId, Integer port, LoginSuccessDTO loginSuccessDTO) {
ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO); ResultBody resultBody = checkAuthStatus(port, loginSuccessDTO);
if (!resultBody.getCode().equals("200")) {
return resultBody;
}
UserFddDO userFddInfo = (UserFddDO) resultBody.getResult(); UserFddDO userFddInfo = (UserFddDO) resultBody.getResult();
FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST); FddExtraClient client = new FddExtraClient(FddConnectConstant.APP_ID, FddConnectConstant.APP_KEY, FddConnectConstant.VERSION, FddConnectConstant.HOST);
QuerySignatureParams params = new QuerySignatureParams(); QuerySignatureParams params = new QuerySignatureParams();
......
...@@ -15,6 +15,7 @@ import com.mmc.iuav.user.entity.UserAccountDO; ...@@ -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.FddVerifyInfoDO;
import com.mmc.iuav.user.entity.fdd.UserFddDO; import com.mmc.iuav.user.entity.fdd.UserFddDO;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO; 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.CompanyVerifyResp;
import com.mmc.iuav.user.model.fdd.resp.PersonVerifyResp; import com.mmc.iuav.user.model.fdd.resp.PersonVerifyResp;
import com.mmc.iuav.user.service.fdd.FddService; import com.mmc.iuav.user.service.fdd.FddService;
...@@ -23,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -23,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* author:zhenjie * author:zhenjie
...@@ -42,6 +45,9 @@ public class UserFddAuthServiceImpl implements UserFddAuthService { ...@@ -42,6 +45,9 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
@Autowired @Autowired
private UserFddAuthDao userFddAuthDao; private UserFddAuthDao userFddAuthDao;
@Autowired
private UserFddAuthService userFddAuthService;
@Override @Override
public String register(String uid, String accountType) { public String register(String uid, String accountType) {
return fddService.register(uid, accountType); return fddService.register(uid, accountType);
...@@ -49,8 +55,14 @@ public class UserFddAuthServiceImpl implements UserFddAuthService { ...@@ -49,8 +55,14 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
@Override @Override
public ResultBody getPersonVerifyUrl(Integer userAccountId) { public ResultBody getPersonVerifyUrl(Integer userAccountId) {
String unionId;
UserAccountDO userInfo = userServiceDao.getUserAccountById(userAccountId); UserAccountDO userInfo = userServiceDao.getUserAccountById(userAccountId);
String unionId = this.replaceUnableString(userInfo.getUnionId()); unionId = this.replaceUnableString(userInfo.getUnionId());
// 判断是否使用unionId注册过企业认证,如果注册过那就用openid注册
String companyCustomerId = this.checkRegisterFdd(unionId, 2);
if (companyCustomerId != null) {
unionId = this.replaceUnableString(userInfo.getOpenId());
}
//验证是否注册个人 //验证是否注册个人
String customerId = this.checkRegisterFdd(unionId, 1); String customerId = this.checkRegisterFdd(unionId, 1);
if (customerId == null) { if (customerId == null) {
...@@ -119,7 +131,14 @@ public class UserFddAuthServiceImpl implements UserFddAuthService { ...@@ -119,7 +131,14 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
if (port.equals(0)) { if (port.equals(0)) {
// 获取小程序用户信息拿到unionId // 获取小程序用户信息拿到unionId
UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId()); UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId());
uId = this.replaceUnableString(userInfo.getUnionId()); String unionId = this.replaceUnableString(userInfo.getUnionId());
// 判断是否用uid注册个人认证,如果用了那么就用openid进行企业认证
String customerId = this.checkRegisterFdd(unionId, 1);
if (customerId == null) {
uId = unionId;
} else {
uId = this.replaceUnableString(userInfo.getOpenId());
}
} else { } else {
uId = loginSuccessDTO.getUserAccountId().toString(); uId = loginSuccessDTO.getUserAccountId().toString();
} }
...@@ -197,6 +216,21 @@ public class UserFddAuthServiceImpl implements UserFddAuthService { ...@@ -197,6 +216,21 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
if (port.equals(0)) { if (port.equals(0)) {
UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId()); UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId());
uId = this.replaceUnableString(userInfo.getUnionId()); uId = this.replaceUnableString(userInfo.getUnionId());
UserFddDO userFddInfo = userFddAuthDao.getAppUserFddInfo(uId);
if (userFddInfo == null) {
uId = userFddAuthService.replaceUnableString(userInfo.getOpenId());
} else {
Integer accountType = userFddInfo.getAccountType();
Integer personVerifyStatus = userFddInfo.getPersonVerifyStatus();
Integer entVerifyStatus = userFddInfo.getEntVerifyStatus();
boolean isPersonVerified = accountType.equals(1) && !personVerifyStatus.equals(2);
boolean isEntVerified = accountType.equals(2) && !entVerifyStatus.equals(4);
if (isPersonVerified || isEntVerified) {
uId = userFddAuthService.replaceUnableString(userInfo.getOpenId());
}
}
} else { } else {
uId = loginSuccessDTO.getUserAccountId().toString(); uId = loginSuccessDTO.getUserAccountId().toString();
} }
...@@ -229,16 +263,19 @@ public class UserFddAuthServiceImpl implements UserFddAuthService { ...@@ -229,16 +263,19 @@ public class UserFddAuthServiceImpl implements UserFddAuthService {
@Override @Override
public ResultBody getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO) { public ResultBody<List<UserFddDTO>> getAppUserFddInfo(Integer port, LoginSuccessDTO loginSuccessDTO) {
String uId; String uId;
String openid;
if (port == 0) { if (port == 0) {
UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId()); UserAccountDO userInfo = userServiceDao.getUserAccountById(loginSuccessDTO.getUserAccountId());
uId = this.replaceUnableString(userInfo.getUnionId()); uId = this.replaceUnableString(userInfo.getUnionId());
openid = this.replaceUnableString(userInfo.getOpenId());
} else { } else {
uId = loginSuccessDTO.getUserAccountId().toString(); uId = loginSuccessDTO.getUserAccountId().toString();
openid = null;
} }
UserFddDO appUserFddDO = userFddAuthDao.getAppUserFddInfo(uId); List<UserFddDO> userFddDO = userServiceDao.listUserFddInfo(uId, openid);
return ResultBody.success(appUserFddDO == null ? null : appUserFddDO.buildUserFddDTO()); return ResultBody.success(userFddDO == null ? null : userFddDO.stream().map(UserFddDO::buildUserFddDTO).collect(Collectors.toList()));
} }
private CompanyVerifyResp reqCompanyVerifyUrl(String customerId) { private CompanyVerifyResp reqCompanyVerifyUrl(String customerId) {
......
...@@ -25,5 +25,6 @@ public interface PayWalletService { ...@@ -25,5 +25,6 @@ public interface PayWalletService {
ResultBody billingDetails(Integer id, String detailType); ResultBody billingDetails(Integer id, String detailType);
ResultBody payUavWallet(PayUavWalletVO payUavWalletVO); ResultBody payUavWallet(PayUavWalletVO payUavWalletVO);
ResultBody optimizeWalletFlow(WalletFlowVO walletFlowVO);
} }
package com.mmc.iuav.user.service.wallet.impl; package com.mmc.iuav.user.service.wallet.impl;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.general.CodeUtil; import com.mmc.iuav.general.CodeUtil;
import com.mmc.iuav.page.PageResult; import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
...@@ -198,10 +199,11 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -198,10 +199,11 @@ public class PayWalletServiceImpl implements PayWalletService {
publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId()); publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
publishUpdatePayWallet.setPid(publishWallet.getPid()); publishUpdatePayWallet.setPid(publishWallet.getPid());
publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount()) publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().add(publisherWalletFlowVO.getCashAmount())
.add(publisherWalletFlowVO.getTopYxjAmount()).add(publisherWalletFlowVO.getTopYxjAmount())); .add(publisherWalletFlowVO.getTopYxjAmount()).add(publisherWalletFlowVO.getTopYxjAmount())
.add(publisherWalletFlowVO.getUrgentYxjAmount()));
publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount()) publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().add(publisherWalletFlowVO.getSalaryAmount()
.subtract(flyerWalletFlowVO.getPercentagePenaltyOfOrder())); .add(publisherWalletFlowVO.getUrgentSalaryAmount()).add(publisherWalletFlowVO.getTopSalaryAmount()))
.add(flyerWalletFlowVO.getPercentagePenaltyOfOrder().abs()));
publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().subtract(publisherWalletFlowVO.getCashAmount()) publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().subtract(publisherWalletFlowVO.getCashAmount())
.subtract(publisherWalletFlowVO.getUrgentYxjAmount()).subtract(publisherWalletFlowVO.getTopYxjAmount())); .subtract(publisherWalletFlowVO.getUrgentYxjAmount()).subtract(publisherWalletFlowVO.getTopYxjAmount()));
...@@ -333,19 +335,10 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -333,19 +335,10 @@ public class PayWalletServiceImpl implements PayWalletService {
} }
private ResultBody publishCancelOrder(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet, Integer status) { private ResultBody publishCancelOrder(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet, Integer status) {
PayWalletDO publishUpdatePayWallet = new PayWalletDO(); PayWalletDO publishUpdatePayWallet = buildPublishUpdatePayWallet(publisherWalletFlowVO, publishWallet);
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()));
int i = payWalletDao.updatePayWallet(publishUpdatePayWallet); int i = payWalletDao.updatePayWallet(publishUpdatePayWallet);
if ((i > 0) && (publisherWalletFlowVO.getCashAmount().compareTo(BigDecimal.ZERO) > 0 || publisherWalletFlowVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0)) { 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); payWalletDao.insertPayLogDO(payLogDO);
return ResultBody.success(); return ResultBody.success();
} else { } else {
...@@ -358,6 +351,21 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -358,6 +351,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 publisherWalletFlowVO
* @param flag 0 未违约取消 1 违约取消 * @param flag 0 未违约取消 1 违约取消
...@@ -585,10 +593,13 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -585,10 +593,13 @@ public class PayWalletServiceImpl implements PayWalletService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public ResultBody payUavWallet(PayUavWalletVO payUavWalletVO) { public ResultBody payUavWallet(PayUavWalletVO payUavWalletVO) {
log.info("==================> 商城下单金额信息:{} <===============", JSONObject.toJSONString(payUavWalletVO));
// 获取用户钱包信息 // 获取用户钱包信息
PayWalletDO userWalletInfo = payWalletDao.getPayWalletByUser(payUavWalletVO.getUserAccountId()); PayWalletDO userWalletInfo = payWalletDao.getPayWalletByUser(payUavWalletVO.getUserAccountId());
String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + payUavWalletVO.getUserAccountId() + CodeUtil.getRandomNum(4); String payNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + payUavWalletVO.getUserAccountId() + CodeUtil.getRandomNum(4);
// 记录流水用户钱包流水记录 // 记录流水用户钱包流水记录
PayLogDO payLogDO = new PayLogDO(); PayLogDO payLogDO = new PayLogDO();
payLogDO.setUserAccountId(payUavWalletVO.getUserAccountId()); payLogDO.setUserAccountId(payUavWalletVO.getUserAccountId());
...@@ -599,49 +610,255 @@ public class PayWalletServiceImpl implements PayWalletService { ...@@ -599,49 +610,255 @@ public class PayWalletServiceImpl implements PayWalletService {
PayWalletDO payWalletDO = new PayWalletDO(); PayWalletDO payWalletDO = new PayWalletDO();
payWalletDO.setPid(userWalletInfo.getPid()); payWalletDO.setPid(userWalletInfo.getPid());
payWalletDO.setUserAccountId(payUavWalletVO.getUserAccountId()); payWalletDO.setUserAccountId(payUavWalletVO.getUserAccountId());
// 判断当前订单状态是什么类型 // 判断当前订单状态是什么类型
if (payUavWalletVO.getOrderStatus().equals(PayMethodEnums.PUBLISH_ORDER.getCode())) { Integer orderStatus = payUavWalletVO.getOrderStatus();
// 获取下单金额是否大于该用户钱包金额 if (orderStatus.equals(PayMethodEnums.PUBLISH_ORDER.getCode())) {
if (userWalletInfo.getCashAmt().compareTo(payUavWalletVO.getCashAmount()) < 0) { return handlePublishOrder(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
return ResultBody.error("可抵扣的云享金不足"); } else if (orderStatus.equals(PayMethodEnums.PAY_UAV_ORDER_REFUND.getCode())) {
} return handleOrderRefund(payUavWalletVO, userWalletInfo, payLogDO, payWalletDO);
if (userWalletInfo.getSalaryAmt().compareTo(payUavWalletVO.getSalaryAmount()) < 0) { } else if (orderStatus.equals(PayMethodEnums.ORDER_INCOME.getCode())) {
return ResultBody.error("可抵扣的佣金不足"); 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.getCashFreeze().add(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryFreeze().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.getCashFreeze().subtract(payUavWalletVO.getCashAmount()));
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryFreeze().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) { return ResultBody.error("无效的支付方式");
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount().negate()); }
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 { } else {
payLogDO.setCashAmtPaid(BigDecimal.ZERO); log.error("发布方取消订单,有飞手接单时,飞手用户钱包更新失败,飞手用户id是:{},接单方传入参数是:{},发单方违约金是:{}", flyerWalletFlowVO.getUserAccountId(), flyerWalletFlowVO, publisherWalletFlowVO.getPercentagePenaltyOfOrder());
return ResultBody.error("钱包操作错误");
} }
if (payUavWalletVO.getSalaryAmount().compareTo(BigDecimal.ZERO) > 0) { } else {
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount().negate()); 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 { } 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())); private ResultBody handleOrderPublish(PublisherWalletFlowVO publisherWalletFlowVO, PayWalletDO publishWallet) {
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount())); PayWalletDO publishUpdatePayWallet = new PayWalletDO();
} else if (payUavWalletVO.getOrderStatus().equals(PayMethodEnums.PAY_UAV_ORDER_REFUND.getCode())) { publishUpdatePayWallet.setUserAccountId(publisherWalletFlowVO.getUserAccountId());
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus()); publishUpdatePayWallet.setPid(publishWallet.getPid());
payLogDO.setCashAmtPaid(payUavWalletVO.getCashAmount()); publishUpdatePayWallet.setCashAmt(publishWallet.getCashAmt().subtract(publisherWalletFlowVO.getCashAmount().abs())
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount()); .subtract(publisherWalletFlowVO.getTopYxjAmount().abs()).subtract(publisherWalletFlowVO.getUrgentYxjAmount().abs()));
// 如果是1400 回滚解冻金额 publishUpdatePayWallet.setCashFreeze(publishWallet.getCashFreeze().add(publisherWalletFlowVO.getCashAmount().abs())
payWalletDO.setCashAmt(userWalletInfo.getCashAmt().add(payUavWalletVO.getCashAmount())); .add(publisherWalletFlowVO.getTopYxjAmount().abs()).add(publisherWalletFlowVO.getUrgentYxjAmount().abs()));
payWalletDO.setCashFreeze(userWalletInfo.getCashAmt().subtract(payUavWalletVO.getCashAmount())); publishUpdatePayWallet.setSalaryAmt(publishWallet.getSalaryAmt().subtract(publisherWalletFlowVO.getSalaryAmount().abs())
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount())); .subtract(publisherWalletFlowVO.getTopSalaryAmount().abs()).subtract(publisherWalletFlowVO.getUrgentSalaryAmount()).abs());
payWalletDO.setSalaryFreeze(userWalletInfo.getSalaryAmt().subtract(payUavWalletVO.getSalaryAmount())); 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 { } else {
payLogDO.setPayMethod(payUavWalletVO.getOrderStatus()); log.error("发布订单时,用户钱包更新失败,用户id是:{},传入参数是:{}", publisherWalletFlowVO.getUserAccountId(), publisherWalletFlowVO);
payLogDO.setCashAmtPaid(BigDecimal.ZERO); return ResultBody.error("钱包操作错误");
payLogDO.setSalaryAmtPaid(payUavWalletVO.getSalaryAmount());
// 订单收益
payWalletDO.setSalaryAmt(userWalletInfo.getSalaryAmt().add(payUavWalletVO.getSalaryAmount()));
} }
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 @@ ...@@ -462,5 +462,22 @@
where open_id = #{openid} where open_id = #{openid}
and disable = 0 and disable = 0
</select> </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> </mapper>
...@@ -18,4 +18,4 @@ patches: ...@@ -18,4 +18,4 @@ patches:
images: images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG - name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: ca052edd5a7e95f4d20df7935fad9c5b9ba2feee newTag: a9be43318a9913f15ec9657f2d026666e62514e0
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论