Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a742333647
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.ghy.web.controller.worker;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.ghy.common.adapay.AdapayConfig;
|
||||||
|
import com.ghy.common.adapay.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.worker.domain.WorkerBank;
|
||||||
|
import com.ghy.worker.request.WorkerBindBankCardRequest;
|
||||||
|
import com.ghy.worker.service.WorkerBankService;
|
||||||
|
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 javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clunt
|
||||||
|
* 师傅银行卡绑定
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/worker/bank")
|
||||||
|
public class WorkerBankController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkerBankService workerBankService;
|
||||||
|
@Resource
|
||||||
|
private AdapayService adapayService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人账户绑定银行卡接口
|
||||||
|
*/
|
||||||
|
@PostMapping("bind")
|
||||||
|
@ResponseBody
|
||||||
|
private AjaxResult bindBankCard(@RequestBody WorkerBindBankCardRequest request) throws BaseAdaPayException {
|
||||||
|
Set<Merchant> merchants = AdapayConfig.getMerchants();
|
||||||
|
for (Merchant merchant : merchants) {
|
||||||
|
String memberId = AdapayUtils.getWorkerMemberId(request.getWorkerId(), merchant.getDeptId());
|
||||||
|
|
||||||
|
// 需要先检查一次memberId是否已存在,如果已存在则只需要绑卡即可
|
||||||
|
Map<String, Object> member = adapayService.queryMember(merchant.getDeptId(), memberId);
|
||||||
|
if (AdapayStatusEnum.succeeded.code.equals(member.get("status")) && memberId.equals(member.get("member_id"))) {
|
||||||
|
log.info("用户[memberId={}]已存在 跳过实名直接绑卡", memberId);
|
||||||
|
} else {
|
||||||
|
// 先在Adapay创建实名用户
|
||||||
|
Map<String, Object> result1 = adapayService.createMember(merchant.getDeptId(), memberId, request.getPhone(),
|
||||||
|
request.getName(), request.getCertId());
|
||||||
|
if (!AdapayStatusEnum.succeeded.code.equals(result1.get("status"))) {
|
||||||
|
log.error("实名认证失败[{}]", JSON.toJSONString(result1));
|
||||||
|
return AjaxResult.error("个人信息不正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始创建结算账户
|
||||||
|
Map<String, Object> 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"))) {
|
||||||
|
log.info("用户[memberId={}]结算账户已存在 跳过", memberId);
|
||||||
|
} else {
|
||||||
|
log.error("创建结算账户失败[{}]", JSON.toJSONString(result2));
|
||||||
|
return AjaxResult.error("个人信息与银行卡不匹配");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkerBank workerBank = new WorkerBank();
|
||||||
|
workerBank.setWorkerId(request.getWorkerId());
|
||||||
|
workerBank.setName(request.getName());
|
||||||
|
workerBank.setCertId(request.getCertId());
|
||||||
|
workerBank.setBankNum(request.getBankNum());
|
||||||
|
workerBank.setPhone(request.getPhone());
|
||||||
|
workerBank.setDeptId(merchant.getDeptId());
|
||||||
|
workerBank.setAdapayMemberId(memberId);
|
||||||
|
workerBank.setSettleAccount(1);
|
||||||
|
workerBankService.insertWorkerBank(workerBank);
|
||||||
|
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,13 @@ package com.ghy.worker.domain;
|
||||||
|
|
||||||
import com.ghy.common.annotation.Excel;
|
import com.ghy.common.annotation.Excel;
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clunt
|
||||||
|
* 师傅银行卡实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
public class WorkerBank extends BaseEntity {
|
public class WorkerBank extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "师傅银行卡id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "师傅银行卡id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.ghy.worker.mapper;
|
||||||
|
|
||||||
|
import com.ghy.worker.domain.WorkerBank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clunt
|
||||||
|
* 师傅银行卡mapper层
|
||||||
|
*/
|
||||||
|
public interface WorkerBankMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param workerBank 银行卡实体
|
||||||
|
* @return 消费者
|
||||||
|
*/
|
||||||
|
int insertWorkerBank(WorkerBank workerBank);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ghy.worker.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WorkerBindBankCardRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 师傅ID
|
||||||
|
*/
|
||||||
|
private Long workerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户真实姓名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证号
|
||||||
|
*/
|
||||||
|
private String certId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡号
|
||||||
|
*/
|
||||||
|
private String bankNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡绑定手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.ghy.worker.service;
|
||||||
|
|
||||||
|
import com.ghy.worker.domain.WorkerBank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clunt
|
||||||
|
* 师傅银行卡service层
|
||||||
|
*/
|
||||||
|
public interface WorkerBankService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param workerBank 银行卡实体
|
||||||
|
* @return 消费者
|
||||||
|
*/
|
||||||
|
int insertWorkerBank(WorkerBank workerBank);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.ghy.worker.service.impl;
|
||||||
|
|
||||||
|
import com.ghy.worker.domain.WorkerBank;
|
||||||
|
import com.ghy.worker.mapper.WorkerBankMapper;
|
||||||
|
import com.ghy.worker.service.WorkerBankService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class WorkerBankServiceImpl implements WorkerBankService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkerBankMapper workerBankMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertWorkerBank(WorkerBank workerBank) {
|
||||||
|
return workerBankMapper.insertWorkerBank(workerBank);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?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.ghy.worker.mapper.WorkerBankMapper">
|
||||||
|
|
||||||
|
<resultMap id="WorkerTeamResult" type="com.ghy.worker.domain.WorkerBank">
|
||||||
|
<result property="workerBankId" column="worker_bank_id"/>
|
||||||
|
<result property="workerId" column="worker_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="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="insertWorkerBank" parameterType="com.ghy.worker.domain.WorkerBank" useGeneratedKeys="true"
|
||||||
|
keyProperty="workerBankId">
|
||||||
|
INSERT INTO worker_bank(
|
||||||
|
<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>
|
||||||
|
<if test="bankName != null and bankName != ''">bank_name,</if>
|
||||||
|
<if test="bankNum != null and bankNum != ''">bank_num,</if>
|
||||||
|
<if test="phone != null and phone != ''">phone,</if>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
|
<if test="adapayMemberId != null and adapayMemberId != ''">adapay_member_id,</if>
|
||||||
|
<if test="settleAccount != null">settle_account,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
create_time
|
||||||
|
)VALUES(
|
||||||
|
<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>
|
||||||
|
<if test="bankName != null and bankName != ''">#{bankName},</if>
|
||||||
|
<if test="bankNum != null and bankNum != ''">#{bankNum},</if>
|
||||||
|
<if test="phone != null and phone != ''">#{phone},</if>
|
||||||
|
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||||
|
<if test="adapayMemberId != null and adapayMemberId != ''">#{adapayMemberId},</if>
|
||||||
|
<if test="settleAccount != null">#{settleAccount},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- <sql id="selectWorkerBank">-->
|
||||||
|
<!-- SELECT *-->
|
||||||
|
<!-- FROM worker_bank-->
|
||||||
|
<!-- </sql>-->
|
||||||
|
|
||||||
|
<!-- <select id="getWorkerTeamList" resultMap="WorkerTeamResult">-->
|
||||||
|
<!-- <include refid="selectWorkerTeam"/>-->
|
||||||
|
<!-- <where>-->
|
||||||
|
<!-- <if test="leaderId != null and leaderId != ''">-->
|
||||||
|
<!-- AND leader_id = #{leaderId}-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- </where>-->
|
||||||
|
<!-- </select>-->
|
||||||
|
|
||||||
|
<!-- <delete id="deleteWorkerTeamByIds" parameterType="Long">-->
|
||||||
|
<!-- DELETE FROM worker_team WHERE worker_team_id IN-->
|
||||||
|
<!-- <foreach collection="array" item="workerTeamId" open="(" separator="," close=")">-->
|
||||||
|
<!-- #{workerTeamId}-->
|
||||||
|
<!-- </foreach>-->
|
||||||
|
<!-- </delete>-->
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue