This commit is contained in:
moxiangrong
2024-02-28 19:10:55 +08:00
parent bed9e338ad
commit 53c6e29f1b
6 changed files with 52 additions and 3 deletions

View File

@ -7,5 +7,9 @@ public interface ErrorCodeConstants {
ErrorCode MERCHANT_DETAILS_NOT_EXISTS = new ErrorCode(1008009000, "支付服务商配置不存在");
ErrorCode PAY_TYPE_NOT_EXISTS = new ErrorCode(800000000, "支付类型不存在");
ErrorCode PAY_TYPE_IS_EXISTS = new ErrorCode(800000001, "支付类型重复");
ErrorCode PAY_ID_IS_EXISTS = new ErrorCode(800000002, "支付id重复");
}

View File

@ -1,5 +1,7 @@
package co.yixiang.yshop.module.pay.service.merchantdetails;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -32,6 +34,12 @@ public class MerchantDetailsServiceImpl implements MerchantDetailsService {
@Override
public String createMerchantDetails(MerchantDetailsCreateReqVO createReqVO) {
if (ObjectUtil.isNotNull(getMerchantByType(createReqVO.getPayType()))) {
throw exception(PAY_TYPE_IS_EXISTS);
}
if (ObjectUtil.isNotNull(getMerchantDetails(createReqVO.getDetailsId()))) {
throw exception(PAY_ID_IS_EXISTS);
}
// 插入
MerchantDetailsDO merchantDetails = MerchantDetailsConvert.INSTANCE.convert(createReqVO);
merchantDetailsMapper.insert(merchantDetails);
@ -41,6 +49,12 @@ public class MerchantDetailsServiceImpl implements MerchantDetailsService {
@Override
public void updateMerchantDetails(MerchantDetailsUpdateReqVO updateReqVO) {
LambdaQueryWrapper<MerchantDetailsDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MerchantDetailsDO::getPayType, updateReqVO.getPayType())
.ne(MerchantDetailsDO::getDetailsId, updateReqVO.getDetailsId());
if (merchantDetailsMapper.exists(queryWrapper)) {
throw exception(PAY_TYPE_IS_EXISTS);
}
// 校验存在
validateMerchantDetailsExists(updateReqVO.getDetailsId());
// 更新