提交 2583a3cb 作者: zhenjie

小猪算账-配置修改、回调接口开发、调试

上级 d87eff3b
...@@ -17,6 +17,7 @@ import java.io.Serializable; ...@@ -17,6 +17,7 @@ import java.io.Serializable;
@AllArgsConstructor @AllArgsConstructor
public class XzWithdrawalVO implements Serializable { public class XzWithdrawalVO implements Serializable {
private static final long serialVersionUID = -8758847907824399671L; private static final long serialVersionUID = -8758847907824399671L;
private Integer userAccountId;
private String notifyUrl; private String notifyUrl;
private String taxFundId; private String taxFundId;
private String month; private String month;
......
package com.mmc.iuav.user.controller.xzsz;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.BaseController;
import com.mmc.iuav.user.model.vo.XzWithdrawalVO;
import com.mmc.iuav.user.service.xzsz.WithdrawalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author: zj
* @Date: 2023/8/23 15:58
*/
@Slf4j
@Api(tags = "提现相关")
@RequestMapping("/withdrawal/")
@RestController
public class WithdrawalController extends BaseController {
@Autowired
private WithdrawalService withdrawalService;
@ApiOperation(value = "提现申请")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("apply")
public ResultBody apply(@RequestBody XzWithdrawalVO xzWithdrawalVO) {
return withdrawalService.apply(xzWithdrawalVO);
}
// 提现查询
// 个人提现列表
// 全部用户提现列表
}
package com.mmc.iuav.user.dao.xzsz;
import org.apache.ibatis.annotations.Mapper;
/**
* @author: zj
* @Date: 2023/8/23 16:10
*/
@Mapper
public interface WithdrawalDao {
}
...@@ -9,9 +9,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -9,9 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface XzDao { public interface XzDao {
void addAuth(XzAuthDO authDO); int addAuth(XzAuthDO authDO);
XzAuthDO getXzAuthByUserAccountId(Integer userAccountId); XzAuthDO getXzAuthByUserAccountId(Integer userAccountId);
void updateAuthStatus(Integer userAccountId);
} }
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.enums.SettleTypeEnum;
import com.mmc.iuav.user.model.vo.XzWithdrawalVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/8/23 16:17
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class XzWithdrawalApplyDO implements Serializable {
private static final long serialVersionUID = 7891653696372539753L;
private Integer id;
private Integer userAccountId;
private String bankName;
private String bankRemo;
private String empNum;
private String empName;
private String empPhone;
private String licenseId;
private String licenseType;
private String month;
private String notifyUrl;
private String outerTradeNo;
private String payAccount;
private Double payAmount;
private String positionName;
private String remarks;
private String settleType;
private String taxFundId;
private String wechatAppId;
private String tradeStatus;
private String tradeTime;
private String frontLogNo;
private String tradeFailCode;
private String tradeResult;
private String submitStatus;
private String errorCode;
private String errorMessage;
private BigDecimal chargeAmount;
private Date createTime;
public XzWithdrawalApplyDO(XzWithdrawalVO xzWithdrawalVO) {
this.userAccountId = xzWithdrawalVO.getUserAccountId();
this.notifyUrl = xzWithdrawalVO.getNotifyUrl();
this.taxFundId = xzWithdrawalVO.getTaxFundId();
this.month = xzWithdrawalVO.getMonth();
this.outerTradeNo = xzWithdrawalVO.getOuterTradeNo();
this.empName = xzWithdrawalVO.getEmpName();
this.empPhone = xzWithdrawalVO.getEmpPhone();
this.empNum = xzWithdrawalVO.getEmpNum();
this.licenseId = xzWithdrawalVO.getLicenseId();
this.licenseType = xzWithdrawalVO.getLicenseType();
this.settleType = xzWithdrawalVO.getSettleType();
this.payAmount = xzWithdrawalVO.getPayAmount();
this.payAccount = xzWithdrawalVO.getSettleType().equals(SettleTypeEnum.BANK.getCode()) ?
xzWithdrawalVO.getPayAccount() : xzWithdrawalVO.getWechatAppId();
this.bankName = xzWithdrawalVO.getBankName();
this.positionName = xzWithdrawalVO.getPositionName();
this.remarks = xzWithdrawalVO.getRemarks();
this.bankRemo = xzWithdrawalVO.getBankRemo();
}
}
package com.mmc.iuav.user.enums;
/**
* @author: zj
* @Date: 2023/8/23 16:50
*/
public enum SettleTypeEnum {
ALIPAY("alipay", "支付宝"), WECHAT("wechatpay", "微信"), BANK("bankcard", "银行卡");
SettleTypeEnum(String code, String status) {
this.code = code;
this.status = status;
}
private String code;
private String status;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
...@@ -11,10 +11,8 @@ import com.mmc.iuav.user.dao.RealNameAuthDao; ...@@ -11,10 +11,8 @@ import com.mmc.iuav.user.dao.RealNameAuthDao;
import com.mmc.iuav.user.dao.UserServiceDao; import com.mmc.iuav.user.dao.UserServiceDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao; import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao; import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.CooperationTagDO; import com.mmc.iuav.user.dao.xzsz.XzDao;
import com.mmc.iuav.user.entity.RealNameAuthDO; import com.mmc.iuav.user.entity.*;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.UserRcdDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO; import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails; import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO; import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
...@@ -78,6 +76,9 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -78,6 +76,9 @@ public class UserAccountServiceImpl implements UserAccountService {
@Autowired @Autowired
private RealNameAuthDao realNameAuthDao; private RealNameAuthDao realNameAuthDao;
@Autowired
private XzDao xzDao;
@Override @Override
public UserAccountVO getUserAccountInfoByUnionId(String unionId) { public UserAccountVO getUserAccountInfoByUnionId(String unionId) {
...@@ -116,6 +117,10 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -116,6 +117,10 @@ public class UserAccountServiceImpl implements UserAccountService {
List<CooperationTagVO> cooperationTags = cooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList()); List<CooperationTagVO> cooperationTags = cooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
userAccountVO.setCooperationTagVOS(cooperationTags); userAccountVO.setCooperationTagVOS(cooperationTags);
} }
XzAuthDO xzAuthDO = xzDao.getXzAuthByUserAccountId(userAccountId);
if (xzAuthDO != null) {
userAccountVO.setXzAuthStatus(xzAuthDO.getXzAuthStatus());
}
return userAccountVO; return userAccountVO;
} }
......
package com.mmc.iuav.user.service.xzsz;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.XzWithdrawalVO;
/**
* @author: zj
* @Date: 2023/8/23 16:09
*/
public interface WithdrawalService {
ResultBody apply(XzWithdrawalVO xzWithdrawalVO);
}
package com.mmc.iuav.user.service.xzsz.impl;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.dao.xzsz.WithdrawalDao;
import com.mmc.iuav.user.model.vo.XzWithdrawalVO;
import com.mmc.iuav.user.service.xzsz.WithdrawalService;
import com.mmc.iuav.user.service.xzsz.XzService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author: zj
* @Date: 2023/8/23 16:09
*/
@Service
@Slf4j
public class WithdrawalServiceImpl implements WithdrawalService {
@Autowired
private WithdrawalDao withdrawalDao;
@Autowired
private XzService xzService;
@Override
public ResultBody apply(XzWithdrawalVO xzWithdrawalVO) {
// 确保已电签、自己钱包余额足够
// 确保主体金额足够再提现
return ResultBody.success();
}
}
package com.mmc.iuav.user.service.xzsz.impl; package com.mmc.iuav.user.service.xzsz.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.mmc.iuav.http.HttpsRequestUtil; import com.mmc.iuav.http.HttpsRequestUtil;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
...@@ -28,6 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -28,6 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -94,6 +100,8 @@ public class XzServiceImpl implements XzService { ...@@ -94,6 +100,8 @@ public class XzServiceImpl implements XzService {
com.alibaba.fastjson2.JSONObject jsonObject1 = com.alibaba.fastjson2.JSONObject.parseObject(contractScope); com.alibaba.fastjson2.JSONObject jsonObject1 = com.alibaba.fastjson2.JSONObject.parseObject(contractScope);
if (jsonObject1.get("data") != null) { if (jsonObject1.get("data") != null) {
// TODO 添加认证结果 // TODO 添加认证结果
String signedResult = this.getSignedResult(xzAuthVO);
return "合同签署完毕"; return "合同签署完毕";
} else { } else {
Map<String, Integer> userInfo = new HashMap<String, Integer>(); Map<String, Integer> userInfo = new HashMap<String, Integer>();
...@@ -122,10 +130,13 @@ public class XzServiceImpl implements XzService { ...@@ -122,10 +130,13 @@ public class XzServiceImpl implements XzService {
// 认证成功,修改认证状态 // 认证成功,修改认证状态
if (notify.get("code").toString().equals("0")) { if (notify.get("code").toString().equals("0")) {
XzAuthDO authDO = notify.get("data", XzAuthDO.class); XzAuthDO authDO = notify.get("data", XzAuthDO.class);
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("userAccountId", 1);
authDO.setCustomParams(com.alibaba.fastjson2.JSONObject.toJSONString(map));
Integer userAccountId = (Integer) com.alibaba.fastjson2.JSONObject.parseObject(authDO.getCustomParams()).get("userAccountId"); Integer userAccountId = (Integer) com.alibaba.fastjson2.JSONObject.parseObject(authDO.getCustomParams()).get("userAccountId");
if (userAccountId != null) { if (userAccountId != null) {
XzAuthDO xzAuthDO = xzDao.getXzAuthByUserAccountId(userAccountId); XzAuthDO xzAuthDO = xzDao.getXzAuthByUserAccountId(userAccountId);
if (xzAuthDO != null) { if (xzAuthDO == null) {
authDO.setUserAccountId(userAccountId); authDO.setUserAccountId(userAccountId);
authDO.setXzAuthStatus(1); authDO.setXzAuthStatus(1);
xzDao.addAuth(authDO); xzDao.addAuth(authDO);
...@@ -171,7 +182,7 @@ public class XzServiceImpl implements XzService { ...@@ -171,7 +182,7 @@ public class XzServiceImpl implements XzService {
PiggySingleWithdrawalApiV2Client v2Client = PiggySingleWithdrawalApiV2Client.getInstanse(userSystemConstant.getXzAppSecret(), userSystemConstant.getXzDomain()); PiggySingleWithdrawalApiV2Client v2Client = PiggySingleWithdrawalApiV2Client.getInstanse(userSystemConstant.getXzAppSecret(), userSystemConstant.getXzDomain());
JSONObject jsonObject = v2Client.singleSubmit(PiggySingleWithdrawV2Vo.builder() JSONObject jsonObject = v2Client.singleSubmit(PiggySingleWithdrawV2Vo.builder()
.appKey(userSystemConstant.getXzAppKey()) .appKey(userSystemConstant.getXzAppKey())
.bizAESContent(PiggyOpenBasicsAesUtil.produceAesData(userSystemConstant.getXzAppKey(), "0000000000000000", PiggySingleWithdrawV2Vo.SingleWithdrawV2Vo.builder() .bizAESContent(PiggyOpenBasicsAesUtil.produceAesData(userSystemConstant.getXzAppSecret(), "0000000000000000", PiggySingleWithdrawV2Vo.SingleWithdrawV2Vo.builder()
.notifyUrl(userSystemConstant.getWithdrawNotify()) .notifyUrl(userSystemConstant.getWithdrawNotify())
.taxFundId(userSystemConstant.getTaxFundId()) .taxFundId(userSystemConstant.getTaxFundId())
.month(xzWithdrawalVO.getMonth()) .month(xzWithdrawalVO.getMonth())
...@@ -188,7 +199,7 @@ public class XzServiceImpl implements XzService { ...@@ -188,7 +199,7 @@ public class XzServiceImpl implements XzService {
.bankRemo(xzWithdrawalVO.getBankRemo()) .bankRemo(xzWithdrawalVO.getBankRemo())
.build())) .build()))
.build()); .build());
System.out.println("单笔提现上报: " + jsonObject.toString()); log.info("singleSubmit res:{}", com.alibaba.fastjson2.JSONObject.toJSONString(jsonObject));
SingleSubmitResp singleSubmitResp = com.alibaba.fastjson2.JSONObject.parseObject(jsonObject.toString(), SingleSubmitResp.class); SingleSubmitResp singleSubmitResp = com.alibaba.fastjson2.JSONObject.parseObject(jsonObject.toString(), SingleSubmitResp.class);
return singleSubmitResp; return singleSubmitResp;
} }
...@@ -250,7 +261,42 @@ public class XzServiceImpl implements XzService { ...@@ -250,7 +261,42 @@ public class XzServiceImpl implements XzService {
public String xzWithdrawNotify(JSONObject notify) { public String xzWithdrawNotify(JSONObject notify) {
log.info("xzWithdrawNotify获取到的推送结果:{}", notify.toString()); log.info("xzWithdrawNotify获取到的推送结果:{}", notify.toString());
// TODO 会受到两次回调 // TODO 会受到两次回调
if (notify.get("isSuccess").toString().equals("T")) {
String s = decrypt(com.alibaba.fastjson2.JSONObject.parseObject(notify.get("data").toString()).get("bizAESContent").toString());
WithdrawalResp.Data data = com.alibaba.fastjson2.JSONObject.parseObject(s, WithdrawalResp.Data.class);
// TODO 判断是否已经处理,处理过就不用处理了
if (data.getNotifyType().equals("submitResult")) {
// 对上报的数据进行业务校验,例如:是否超限、是否有余额、是否有电签、参数是否准确等等前置校验。如果校验成功,订单进入待发队列等待发放
log.info("deal submitResult");
data.getOuterTradeNo();
} else if (data.getNotifyType().equals("tradeResult")) {
// 根据银行\微信\支付宝的反馈,推送订单的发放结果,发放成功\发放失败
log.info("deal tradeResult");
}
} else {
log.info("xzWithdrawNotify fail:{}", notify.toString());
}
return "success"; return "success";
} }
public String decrypt(String aesData) {
try {
byte[] raw = userSystemConstant.getXzAppSecret().getBytes("ASCII");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec iv = new IvParameterSpec("0000000000000000".getBytes());
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
Charset charset = Charset.forName("UTF-8");
String tempStr = URLDecoder.decode(aesData, charset);
byte[] encrypted1 = Base64.decode(tempStr);
byte[] original = cipher.doFinal(encrypted1);
String jsonParam = new String(original, "UTF-8");
return jsonParam;
} catch (Exception e) {
System.out.println("AES解密异常" + e);
}
return "";
}
} }
...@@ -39,6 +39,17 @@ public class WithdrawalResp { ...@@ -39,6 +39,17 @@ public class WithdrawalResp {
private String outerTradeNo; private String outerTradeNo;
private String notifyType; private String notifyType;
private String empName; private String empName;
private String empPhone;
private String licenseType;
private String licenseId;
private String settleType;
private String payAccount;
private String positionName;
private BigDecimal payAmount;
private String tradeStatus;
private String tradeTime;
private String frontLogNo;
private String tradeResult;
public Data() { public Data() {
} }
...@@ -155,16 +166,5 @@ public class WithdrawalResp { ...@@ -155,16 +166,5 @@ public class WithdrawalResp {
this.tradeResult = tradeResult; this.tradeResult = tradeResult;
} }
private String empPhone;
private String licenseType;
private String licenseId;
private String settleType;
private String payAccount;
private String positionName;
private BigDecimal payAmount;
private String tradeStatus;
private String tradeTime;
private String frontLogNo;
private String tradeResult;
} }
} }
...@@ -77,7 +77,7 @@ third-party: ...@@ -77,7 +77,7 @@ third-party:
position: 销售推广 position: 销售推广
taxFundId: xxxxxxxxxxxxxxxxxxxxxxx taxFundId: xxxxxxxxxxxxxxxxxxxxxxx
authNotify: https://test.iuav.shop/userapp/xz/xzAuthNotify authNotify: https://test.iuav.shop/userapp/xz/xzAuthNotify
withdrawNotify: http://test.iuav.shop/userapp/xz/xzWithdrawNotify withdrawNotify: https://test.iuav.shop/userapp/xz/xzWithdrawNotify
iuav: iuav:
pay: pay:
......
...@@ -46,7 +46,7 @@ third-party: ...@@ -46,7 +46,7 @@ third-party:
position: 销售推广 position: 销售推广
taxFundId: xxxxxxxxxxxxxxxxxxxxxxx taxFundId: xxxxxxxxxxxxxxxxxxxxxxx
authNotify: https://test.iuav.shop/userapp/xz/xzAuthNotify authNotify: https://test.iuav.shop/userapp/xz/xzAuthNotify
withdrawNotify: http://test.iuav.shop/userapp/xz/xzWithdrawNotify withdrawNotify: https://test.iuav.shop/userapp/xz/xzWithdrawNotify
iuav: iuav:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.iuav.user.dao.xzsz.WithdrawalDao">
</mapper>
\ No newline at end of file
...@@ -6,13 +6,9 @@ ...@@ -6,13 +6,9 @@
<insert id="addAuth" parameterType="com.mmc.iuav.user.entity.XzAuthDO" useGeneratedKeys="true" keyProperty="id"> <insert id="addAuth" parameterType="com.mmc.iuav.user.entity.XzAuthDO" useGeneratedKeys="true" keyProperty="id">
insert into xz_auth(user_account_id, `name`, id_card_no, mobile, bank_account, subsidiary_name, document_id, custom_params, contract_url, xz_auth_status, create_time) insert into xz_auth(user_account_id, `name`, id_card_no, mobile, bank_account, subsidiary_name, document_id, custom_params, contract_url, xz_auth_status, create_time)
values (#{userAccountId}, #{name}, #{idCardNo}, #{mobile}, #{bankAccount}, #{subsidiary_name}, #{document_id}, #{customParams}, #{contract_url}, NOW()) values (#{userAccountId}, #{name}, #{idCardNo}, #{mobile}, #{bankAccount}, #{subsidiary_name}, #{document_id}, #{customParams}, #{contract_url}, #{xzAuthStatus}, NOW())
</insert> </insert>
<update id="updateAuthStatus">
update user_account set xz_auth_status = 1 where id = #{userAccountId}
</update>
<select id="getXzAuthByUserAccountId" resultType="com.mmc.iuav.user.entity.XzAuthDO"> <select id="getXzAuthByUserAccountId" resultType="com.mmc.iuav.user.entity.XzAuthDO">
select id, user_account_id, `name`, id_card_no, mobile, bank_account, subsidiary_name, document_id, custom_params, contract_url, create_time select id, user_account_id, `name`, id_card_no, mobile, bank_account, subsidiary_name, document_id, custom_params, contract_url, create_time
from xz_auth where user_account_id = #{userAccountId} and is_deleted = 0 from xz_auth where user_account_id = #{userAccountId} and is_deleted = 0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论