修改结算银行卡 Adapay部分
This commit is contained in:
parent
205c50459d
commit
2ddf5a6bf6
|
|
@ -1,14 +1,15 @@
|
||||||
package com.ghy.web.controller.worker;
|
package com.ghy.web.controller.worker;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ghy.common.adapay.AdapayConfig;
|
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.AdapayStatusEnum;
|
||||||
import com.ghy.common.adapay.model.Merchant;
|
import com.ghy.common.adapay.model.Merchant;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.utils.AdapayUtils;
|
import com.ghy.common.utils.AdapayUtils;
|
||||||
import com.ghy.common.utils.ExceptionUtil;
|
import com.ghy.common.utils.ExceptionUtil;
|
||||||
|
import com.ghy.payment.service.AdapayService;
|
||||||
import com.ghy.worker.domain.Worker;
|
import com.ghy.worker.domain.Worker;
|
||||||
import com.ghy.worker.domain.WorkerBank;
|
import com.ghy.worker.domain.WorkerBank;
|
||||||
import com.ghy.worker.domain.WorkerCertification;
|
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.WorkerBankService;
|
||||||
import com.ghy.worker.service.WorkerService;
|
import com.ghy.worker.service.WorkerService;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Map;
|
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);
|
"2", request.getCertId(), request.getPhone(), null, null, null);
|
||||||
if (!AdapayStatusEnum.succeeded.code.equals(result2.get("status"))) {
|
if (!AdapayStatusEnum.succeeded.code.equals(result2.get("status"))) {
|
||||||
if ("account_exists".equals(result2.get("error_code"))) {
|
if ("account_exists".equals(result2.get("error_code"))) {
|
||||||
logger.info("用户[memberId={}]结算账户已存在 跳过", memberId);
|
logger.info("用户[memberId={}]结算账户已存在 跳过", memberId);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.error("创建结算账户失败[{}]", JSON.toJSONString(result2));
|
logger.error("创建结算账户失败[{}]", JSON.toJSONString(result2));
|
||||||
return AjaxResult.error("个人信息与银行卡不匹配或不支持信用卡绑定");
|
return AjaxResult.error("个人信息与银行卡不匹配或不支持信用卡绑定");
|
||||||
|
|
@ -82,6 +80,7 @@ public class WorkerBankController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkerBank workerBank = new WorkerBank();
|
WorkerBank workerBank = new WorkerBank();
|
||||||
|
workerBank.setSettleAccountId(result2.getString("id"));
|
||||||
workerBank.setWorkerId(request.getWorkerId());
|
workerBank.setWorkerId(request.getWorkerId());
|
||||||
workerBank.setName(request.getName());
|
workerBank.setName(request.getName());
|
||||||
workerBank.setCertId(request.getCertId());
|
workerBank.setCertId(request.getCertId());
|
||||||
|
|
@ -95,7 +94,7 @@ public class WorkerBankController extends BaseController {
|
||||||
}
|
}
|
||||||
// 判断师傅是否已经审核过,审核过,就更新师傅状态为可用
|
// 判断师傅是否已经审核过,审核过,就更新师傅状态为可用
|
||||||
WorkerCertification workerCertification = workerCertificationService.selectByWorkerId(request.getWorkerId());
|
WorkerCertification workerCertification = workerCertificationService.selectByWorkerId(request.getWorkerId());
|
||||||
if (workerCertification != null &&workerCertification.getStatus() == 1){
|
if (workerCertification != null && workerCertification.getStatus() == 1) {
|
||||||
// 更新师傅为可用
|
// 更新师傅为可用
|
||||||
Worker worker = new Worker();
|
Worker worker = new Worker();
|
||||||
worker.setWorkerId(request.getWorkerId());
|
worker.setWorkerId(request.getWorkerId());
|
||||||
|
|
@ -105,12 +104,22 @@ public class WorkerBankController extends BaseController {
|
||||||
return AjaxResult.success("绑定银行卡成功");
|
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")
|
@PostMapping("/getByWorkerId")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult getByWorkerId(@RequestBody WorkerBindBankCardRequest request){
|
public AjaxResult getByWorkerId(@RequestBody WorkerBindBankCardRequest request) {
|
||||||
try {
|
try {
|
||||||
return AjaxResult.success(workerBankService.getByWorkerId(request.getWorkerId()));
|
return AjaxResult.success(workerBankService.getByWorkerId(request.getWorkerId()));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,26 @@ public class AdapayService {
|
||||||
return (JSONObject) SettleAccount.create(settleCountParams, deptId.toString());
|
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
|
* 创建实名用户 https://docs.adapay.tech/api/trade.html#member-realname
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class WorkerBank extends BaseEntity {
|
public class WorkerBank extends BaseEntity {
|
||||||
|
|
||||||
|
@Excel(name = "结算账户ID", cellType = Excel.ColumnType.STRING)
|
||||||
|
private String settleAccountId;
|
||||||
|
|
||||||
@Excel(name = "师傅银行卡id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "师傅银行卡id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long workerBankId;
|
private Long workerBankId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<resultMap id="WorkerBankResult" type="com.ghy.worker.domain.WorkerBank">
|
<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="workerId" column="worker_id"/>
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
<result property="certId" column="cert_id"/>
|
<result property="certId" column="cert_id"/>
|
||||||
|
|
@ -22,7 +23,7 @@
|
||||||
|
|
||||||
<insert id="insertWorkerBank" parameterType="com.ghy.worker.domain.WorkerBank" useGeneratedKeys="true"
|
<insert id="insertWorkerBank" parameterType="com.ghy.worker.domain.WorkerBank" useGeneratedKeys="true"
|
||||||
keyProperty="workerBankId">
|
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="workerId != null and workerId != 0">worker_id,</if>
|
||||||
<if test="name != null and name != ''">name,</if>
|
<if test="name != null and name != ''">name,</if>
|
||||||
<if test="certId != null and certId != ''">cert_id,</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="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
create_time
|
create_time
|
||||||
)VALUES(
|
)VALUES( #{settleAccountId},
|
||||||
<if test="workerId != null and workerId != 0">#{workerId},</if>
|
<if test="workerId != null and workerId != 0">#{workerId},</if>
|
||||||
<if test="name != null and name != ''">#{name},</if>
|
<if test="name != null and name != ''">#{name},</if>
|
||||||
<if test="certId != null and certId != ''">#{certId},</if>
|
<if test="certId != null and certId != ''">#{certId},</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue