修改结算银行卡 Adapay部分

This commit is contained in:
HH 2023-03-12 18:00:23 +08:00
parent 205c50459d
commit 2ddf5a6bf6
4 changed files with 53 additions and 20 deletions

View File

@ -1,14 +1,15 @@
package com.ghy.web.controller.worker;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ghy.common.adapay.AdapayConfig;
import com.ghy.payment.service.AdapayService;
import com.ghy.common.adapay.model.AdapayStatusEnum;
import com.ghy.common.adapay.model.Merchant;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.utils.AdapayUtils;
import com.ghy.common.utils.ExceptionUtil;
import com.ghy.payment.service.AdapayService;
import com.ghy.worker.domain.Worker;
import com.ghy.worker.domain.WorkerBank;
import com.ghy.worker.domain.WorkerCertification;
@ -17,12 +18,8 @@ import com.ghy.worker.service.IWorkerCertificationService;
import com.ghy.worker.service.WorkerBankService;
import com.ghy.worker.service.WorkerService;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
@ -70,11 +67,12 @@ public class WorkerBankController extends BaseController {
}
// 开始创建结算账户
Map<String, Object> result2 = adapayService.createSettleAccount(merchant.getDeptId(), memberId, request.getBankNum(), request.getName(),
JSONObject result2 = adapayService.createSettleAccount(merchant.getDeptId(), memberId, request.getBankNum(), request.getName(),
"2", request.getCertId(), request.getPhone(), null, null, null);
if (!AdapayStatusEnum.succeeded.code.equals(result2.get("status"))) {
if ("account_exists".equals(result2.get("error_code"))) {
logger.info("用户[memberId={}]结算账户已存在 跳过", memberId);
} else {
logger.error("创建结算账户失败[{}]", JSON.toJSONString(result2));
return AjaxResult.error("个人信息与银行卡不匹配或不支持信用卡绑定");
@ -82,6 +80,7 @@ public class WorkerBankController extends BaseController {
}
WorkerBank workerBank = new WorkerBank();
workerBank.setSettleAccountId(result2.getString("id"));
workerBank.setWorkerId(request.getWorkerId());
workerBank.setName(request.getName());
workerBank.setCertId(request.getCertId());
@ -95,7 +94,7 @@ public class WorkerBankController extends BaseController {
}
// 判断师傅是否已经审核过审核过就更新师傅状态为可用
WorkerCertification workerCertification = workerCertificationService.selectByWorkerId(request.getWorkerId());
if (workerCertification != null &&workerCertification.getStatus() == 1){
if (workerCertification != null && workerCertification.getStatus() == 1) {
// 更新师傅为可用
Worker worker = new Worker();
worker.setWorkerId(request.getWorkerId());
@ -105,12 +104,22 @@ public class WorkerBankController extends BaseController {
return AjaxResult.success("绑定银行卡成功");
}
@PutMapping("update")
@ResponseBody
private AjaxResult updateBankCard(@RequestBody WorkerBindBankCardRequest request) throws BaseAdaPayException {
Set<Merchant> merchants = AdapayConfig.getMerchants();
for (Merchant merchant : merchants) {
}
return AjaxResult.success("绑定银行卡成功");
}
@PostMapping("/getByWorkerId")
@ResponseBody
public AjaxResult getByWorkerId(@RequestBody WorkerBindBankCardRequest request){
public AjaxResult getByWorkerId(@RequestBody WorkerBindBankCardRequest request) {
try {
return AjaxResult.success(workerBankService.getByWorkerId(request.getWorkerId()));
}catch (Exception e){
} catch (Exception e) {
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
}

View File

@ -202,6 +202,26 @@ public class AdapayService {
return (JSONObject) SettleAccount.create(settleCountParams, deptId.toString());
}
/**
* 删除结算账户对象 https://docs.adapay.tech/api/trade.html#id50
* 删除结算账户对象是对已创建完成的结算账户对象进行删除操作
* 删除结算账户成功后支付时不再支持分账功能您可再调用创建结算账户对象创建新的结算账户
* 删除结算账户对象需要 Adapay 系统生成的结算账户对象 id 进行删除
*
* @param deptId [必填]商户ID
* @param memberId [必填]商户下的用户id只能为英文数字或者下划线的一种或多种组合保证在app_id下唯一
* @param settleAccountId [必填]结算账户ID
* @return { "status": "succeeded", "id":"0006440476699456", "prod_mode": "true" }
*/
public JSONObject deleteSettleAccount(@NotNull Long deptId, @NotNull String memberId, @NotNull String settleAccountId) throws BaseAdaPayException {
String appId = AdapayConfig.getAppId(deptId);
JSONObject settleCountParams = new JSONObject();
settleCountParams.put("app_id", appId);
settleCountParams.put("settle_account_id", settleAccountId);
settleCountParams.put("member_id", memberId);
return (JSONObject) SettleAccount.delete(settleCountParams);
}
/**
* 创建实名用户 https://docs.adapay.tech/api/trade.html#member-realname
*

View File

@ -11,6 +11,9 @@ import lombok.Data;
@Data
public class WorkerBank extends BaseEntity {
@Excel(name = "结算账户ID", cellType = Excel.ColumnType.STRING)
private String settleAccountId;
@Excel(name = "师傅银行卡id", cellType = Excel.ColumnType.NUMERIC)
private Long workerBankId;

View File

@ -3,16 +3,17 @@
<mapper namespace="com.ghy.worker.mapper.WorkerBankMapper">
<resultMap id="WorkerBankResult" type="com.ghy.worker.domain.WorkerBank">
<result property="workerBankId" column="worker_bank_id"/>
<result property="workerBankId" column="worker_bank_id"/>
<result property="settleAccountId" column="settle_account_id"/>
<result property="workerId" column="worker_id"/>
<result property="name" column="name"/>
<result property="certId" column="cert_id"/>
<result property="name" column="name"/>
<result property="certId" column="cert_id"/>
<result property="bankName" column="bank_name"/>
<result property="bankNum" column="bank_num"/>
<result property="phone" column="phone"/>
<result property="deptId" column="dept_id"/>
<result property="adapayMemberId" column="adapay_member_id"/>
<result property="settleAccount" column="settle_account"/>
<result property="bankNum" column="bank_num"/>
<result property="phone" column="phone"/>
<result property="deptId" column="dept_id"/>
<result property="adapayMemberId" column="adapay_member_id"/>
<result property="settleAccount" column="settle_account"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
@ -22,7 +23,7 @@
<insert id="insertWorkerBank" parameterType="com.ghy.worker.domain.WorkerBank" useGeneratedKeys="true"
keyProperty="workerBankId">
INSERT INTO worker_bank(
INSERT INTO worker_bank( settle_account_id,
<if test="workerId != null and workerId != 0">worker_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="certId != null and certId != ''">cert_id,</if>
@ -35,7 +36,7 @@
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)VALUES(
)VALUES( #{settleAccountId},
<if test="workerId != null and workerId != 0">#{workerId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="certId != null and certId != ''">#{certId},</if>