feat(customer):新增服务人员/机构新增/修改银行账户的相关功能

This commit is contained in:
JIAN 2024-08-30 00:23:21 +08:00
parent d62a73d0ed
commit b005d1771d
6 changed files with 278 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package com.jzo2o.customer.controller.agency;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author JIAN
*/
@RestController("agencyBankAccountController")
@RequestMapping("/agency/bank-account")
@Api(tags = "机构端 - 银行账号相关接口")
public class BankAccountController {
@Resource
private IBankAccountService bankAccountService;
/**
* 新增/修改银行账号
*/
@PostMapping
public void upsertBankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
bankAccountService.upsertBankAccount(bankAccountUpsertReqDTO);
}
/**
* 获取当前用户的银行账户
*/
@GetMapping("/currentUserBankAccount")
public BankAccountResDTO getCurrentUserBankAccount() {
return bankAccountService.getCurrentUserBankAccount();
}
}

View File

@ -0,0 +1,36 @@
package com.jzo2o.customer.controller.worker;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author JIAN
*/
@RestController("workerBankAccountController")
@RequestMapping("/worker/bank-account")
@Api(tags = "服务端 - 银行账号相关接口")
public class BankAccountController {
@Resource
private IBankAccountService bankAccountService;
/**
* 新增/修改银行账号
*/
@PostMapping
public void upsertBankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
bankAccountService.upsertBankAccount(bankAccountUpsertReqDTO);
}
/**
* 获取当前用户的银行账户
*/
@GetMapping("/currentUserBankAccount")
public BankAccountResDTO getCurrentUserBankAccount() {
return bankAccountService.getCurrentUserBankAccount();
}
}

View File

@ -0,0 +1,15 @@
package com.jzo2o.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jzo2o.customer.model.domain.BankAccount;
/**
* <p>
* 服务人员/机构银行账号 Mapper 接口
* </p>
*
* @author JIAN
* @since 2024-08-29
*/
public interface BankAccountMapper extends BaseMapper<BankAccount> {
}

View File

@ -0,0 +1,101 @@
package com.jzo2o.customer.model.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 服务人员/机构银行账号
* </p>
*
* @author JIAN
* @since 2024-08-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("bank_account")
public class BankAccount implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 服务人员/机构id
*/
@TableId(value = "id", type = IdType.NONE)
private Long id;
/**
* 类型2服务人员3服务机构
*/
@TableField("type")
private Integer type;
/**
* 户名
*/
@TableField("name")
private String name;
/**
* 省份
*/
@TableField("province")
private String province;
/**
* 市级
*/
@TableField("city")
private String city;
/**
* /
*/
@TableField("district")
private String district;
/**
* 银行名称
*/
@TableField("bank_name")
private String bankName;
/**
* 银行网点
*/
@TableField("branch")
private String branch;
/**
* 银行卡号
*/
@TableField("account")
private String account;
/**
* 开户证明
*/
@TableField("account_certification")
private String accountCertification;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,26 @@
package com.jzo2o.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
/**
* <p>
* 服务人员/机构银行账号 服务类
* </p>
*
* @author JIAN
* @since 2024-08-29
*/
public interface IBankAccountService extends IService<BankAccount> {
/**
* 新增/更新银行账户
*/
void upsertBankAccount(BankAccountUpsertReqDTO bankAccountUpsertReqDTO);
/**
* 获取当前用户的银行账户
*/
BankAccountResDTO getCurrentUserBankAccount();
}

View File

@ -0,0 +1,64 @@
package com.jzo2o.customer.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jzo2o.common.expcetions.ForbiddenOperationException;
import com.jzo2o.common.utils.BeanUtils;
import com.jzo2o.common.utils.ObjectUtils;
import com.jzo2o.customer.mapper.BankAccountMapper;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.domain.ServeProvider;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import com.jzo2o.customer.service.IServeProviderService;
import com.jzo2o.mvc.utils.UserContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* <p>
* 服务人员/机构银行账号 服务实现类
* </p>
* @author JIAN
* @since 2024-08-29
*/
@Service
public class BankAccountServiceImpl extends ServiceImpl<BankAccountMapper, BankAccount> implements IBankAccountService {
@Resource
IServeProviderService serveProviderService;
@Override
@Transactional
public void upsertBankAccount(BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
Long userId = UserContext.currentUserId();
ServeProvider serveProvider = serveProviderService.getById(userId);
if (ObjectUtils.isEmpty(serveProvider)) {
throw new ForbiddenOperationException("当前用户不存在");
}
BankAccount bankAccount = BeanUtils.toBean(bankAccountUpsertReqDTO, BankAccount.class);
bankAccount.setId(userId);
bankAccount.setType(serveProvider.getType());
if (ObjectUtils.isEmpty(baseMapper.selectById(userId))) {
baseMapper.insert(bankAccount);
} else {
baseMapper.updateById(bankAccount);
}
}
@Override
public BankAccountResDTO getCurrentUserBankAccount() {
Long userId = UserContext.currentUserId();
if (ObjectUtils.isEmpty(userId)) {
throw new ForbiddenOperationException("当前用户不存在");
}
BankAccount bankAccount = baseMapper.selectById(userId);
return ObjectUtils.isEmpty(bankAccount)
? new BankAccountResDTO()
: BeanUtils.toBean(bankAccount, BankAccountResDTO.class);
}
}