支付的 code review

This commit is contained in:
YunaiV 2021-11-05 08:10:07 +08:00
parent 26798a8816
commit 6265e4a736
8 changed files with 26 additions and 25 deletions

View File

@ -12,6 +12,7 @@ import javax.validation.constraints.NotNull;
@Data @Data
public class PayMerchantBaseVO { public class PayMerchantBaseVO {
// TODO @aquanno 应该不允许修改啊哈哈我的原型没画对
@ApiModelProperty(value = "商户号") @ApiModelProperty(value = "商户号")
private String no; private String no;

View File

@ -9,7 +9,6 @@ import cn.iocoder.yudao.adminserver.modules.pay.convert.merchant.PayMerchantConv
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper; import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper;
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService; import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -20,7 +19,7 @@ import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*; import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.MERCHANT_NOT_EXISTS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/** /**
* 支付商户信息 Service 实现类 * 支付商户信息 Service 实现类
@ -39,6 +38,7 @@ public class PayMerchantServiceImpl implements PayMerchantService {
// 插入 // 插入
PayMerchantDO merchant = PayMerchantConvert.INSTANCE.convert(createReqVO); PayMerchantDO merchant = PayMerchantConvert.INSTANCE.convert(createReqVO);
// 根据 年月日时分秒毫秒 生成时间戳 // 根据 年月日时分秒毫秒 生成时间戳
// TODO @aquan生成 no 可以单独一个小方法
String merchantNo = "M" + DateUtil.format(LocalDateTime.now(),"yyyyMMddHHmmssSSS"); String merchantNo = "M" + DateUtil.format(LocalDateTime.now(),"yyyyMMddHHmmssSSS");
merchant.setNo(merchantNo); merchant.setNo(merchantNo);
merchantMapper.insert(merchant); merchantMapper.insert(merchant);

View File

@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.*;
/** /**
* {@link PayMerchantServiceImpl} 的单元测试类 * {@link PayMerchantServiceImpl} 的单元测试类
* *
* @author 芋艿 * @author 芋艿 // TODO @aquan修改成自己的
*/ */
@Import(PayMerchantServiceImpl.class) @Import(PayMerchantServiceImpl.class)
public class PayMerchantServiceTest extends BaseDbUnitTest { public class PayMerchantServiceTest extends BaseDbUnitTest {
@ -51,6 +51,7 @@ public class PayMerchantServiceTest extends BaseDbUnitTest {
assertNotNull(merchantId); assertNotNull(merchantId);
// 校验记录的属性是否正确 // 校验记录的属性是否正确
PayMerchantDO merchant = merchantMapper.selectById(merchantId); PayMerchantDO merchant = merchantMapper.selectById(merchantId);
// TODO @aquan需要判断 no 非空
assertPojoEquals(reqVO, merchant,"no"); assertPojoEquals(reqVO, merchant,"no");
} }

View File

@ -33,7 +33,7 @@ public class PayMerchantDO extends BaseDO {
* 例如说M233666999 * 例如说M233666999
* 只有新增时插入不允许修改 * 只有新增时插入不允许修改
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT) // TODO @aquanService 逻辑里设置所以不用这个注解哈
private String no; private String no;
/** /**
* 商户全称 * 商户全称

View File

@ -21,10 +21,10 @@ public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest {
private PayChannelCoreMapper payChannelCoreMapper; private PayChannelCoreMapper payChannelCoreMapper;
/** /**
* 插入初始配置 * 插入 {@link PayChannelEnum#WX_PUB} 初始配置
*/ */
@Test @Test
public void testInsert() throws FileNotFoundException { public void testInsertWxPub() throws FileNotFoundException {
PayChannelDO payChannelDO = new PayChannelDO(); PayChannelDO payChannelDO = new PayChannelDO();
payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode()); payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode());
payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
@ -45,11 +45,12 @@ public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest {
payChannelCoreMapper.insert(payChannelDO); payChannelCoreMapper.insert(payChannelDO);
} }
// TODO @ouyangZfb 改成 AlipayQr
/** /**
* 插入支付宝 初始配置 * 插入 {@link PayChannelEnum#ALIPAY_QR} 初始配置
*/ */
@Test @Test
public void testInsertZfb() throws FileNotFoundException { public void testInsertZfb() {
PayChannelDO payChannelDO = new PayChannelDO(); PayChannelDO payChannelDO = new PayChannelDO();
payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode()); payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode());
payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus());

View File

@ -6,7 +6,7 @@ import lombok.ToString;
import java.util.Map; import java.util.Map;
// TODO @jason注释要写下哈字段不要使用 // 注释非标准
@Data @Data
@ToString @ToString
@Builder @Builder

View File

@ -42,7 +42,6 @@ public class PayOrderNotifyRespDTO {
*/ */
private String data; private String data;
/** /**
* TODO @jason 结合其他的渠道定义成枚举, * TODO @jason 结合其他的渠道定义成枚举,
* alipay * alipay

View File

@ -72,15 +72,16 @@ public class PayOrderController {
return "success"; return "success";
} }
@RequestMapping("/notify/test") @GetMapping(value = "/return/alipay-qr/{channelId}")
@ApiOperation("通知的测试接口") @ApiOperation("支付宝 wap 页面回跳")
public String notifyTest() { public String returnAliPayQrPayOrder(@PathVariable("channelId") Long channelId){
// System.out.println(data); //TODO @jason 校验 是否支付宝调用 支付宝publickey 可以根据 appId 跳转不同的页面
return "success"; System.out.println("支付成功");
return "支付成功";
} }
@PostMapping(value = "/notify/alipay-wap/{channelId}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @PostMapping(value = "/notify/alipay-wap/{channelId}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ApiOperation("支付宝wap页面回调") @ApiOperation("支付宝 wap 页面回调")
public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId, public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId,
@RequestParam Map<String, String> params, @RequestParam Map<String, String> params,
@RequestBody String originData) throws Exception { @RequestBody String originData) throws Exception {
@ -89,25 +90,23 @@ public class PayOrderController {
return "success"; return "success";
} }
/** /**
* https://opendocs.alipay.com/open/203/105285#%E5%89%8D%E5%8F%B0%E5%9B%9E%E8%B7%B3%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E * https://opendocs.alipay.com/open/203/105285#%E5%89%8D%E5%8F%B0%E5%9B%9E%E8%B7%B3%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E
* @param channelId 渠道id * @param channelId 渠道id
* @return 返回跳转页面 * @return 返回跳转页面
*/ */
@GetMapping(value = "/return/alipay-wap/{channelId}") @GetMapping(value = "/return/alipay-wap/{channelId}")
@ApiOperation("支付宝wap页面回跳") @ApiOperation("支付宝 wap 页面回跳")
public String returnAliPayWapPayOrder(@PathVariable("channelId") Long channelId){ public String returnAliPayWapPayOrder(@PathVariable("channelId") Long channelId){
//TODO 校验 是否支付宝调用 可以根据 appId 跳转不同的页面 //TODO 校验 是否支付宝调用 可以根据 appId 跳转不同的页面
return "支付成功"; return "支付成功";
} }
@RequestMapping("/notify/test")
@GetMapping(value = "/return/alipay-qr/{channelId}") @ApiOperation("通知的测试接口")
@ApiOperation("支付宝wap页面回跳") public String notifyTest() {
public String returnAliPayQrPayOrder(@PathVariable("channelId") Long channelId){ // System.out.println(data);
//TODO @jason 校验 是否支付宝调用 支付宝publickey 可以根据 appId 跳转不同的页面 return "success";
System.out.println("支付成功");
return "支付成功";
} }
} }