From 2f5f826af002b4555bb71f554785ef6faf3b5a0f Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 26 七月 2024 10:23:04 +0800
Subject: [PATCH] 1、完善代码。
---
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java | 85 ++++++++++++++++++++----------------------
1 files changed, 41 insertions(+), 44 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java
index e53ea94..727175d 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java
@@ -1,17 +1,16 @@
package com.dy.pipIrrWechat.virtualCard;
-import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard;
import com.dy.pipIrrGlobal.voSe.VoVcRecharge;
import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
-import com.dy.pipIrrWechat.util.PayHelper;
-import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM;
import com.dy.pipIrrWechat.result.WechatResultCode;
+import com.dy.pipIrrWechat.util.PayHelper;
import com.dy.pipIrrWechat.virtualCard.dto.DtoRegist;
import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge;
+import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@@ -43,53 +42,25 @@
private final PayHelper payHelper;
/**
- * 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗�
- * @return
- */
- @GetMapping(path = "/get")
- @SsoAop()
- public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){
- try {
- List<VoVirtualCard> res = virtualCardSv.getVCs(clientId);
- return BaseResponseUtils.buildSuccess(res);
- } catch (Exception e) {
- log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
- }
- }
-
- /**
- * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞�
- * @param vcId
- * @return
- */
- @GetMapping(path = "/getVcById")
- @SsoAop()
- public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){
- try {
- return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId));
- } catch (Exception e) {
- log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
- }
- }
-
- /**
- * 铏氭嫙鍗¤处鍙锋敞鍐�
+ * 娉ㄥ唽铏氭嫙鍗�
* @param po
* @param bindingResult
* @return
*/
@PostMapping(path = "add_vc")
- @SsoAop()
- public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult){
+ public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult) {
if(bindingResult != null && bindingResult.hasErrors()){
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
Long clientId = po.getClientId();
// 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode
- String areaCode = String.valueOf(virtualCardSv.getAreaCodeById(clientId));
+ Long areaCodeL = virtualCardSv.getAreaCodeById(clientId);
+ if(areaCodeL == null) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.AREA_CODE_MISTAKE.getMessage());
+ }
+ String areaCode = String.valueOf(areaCodeL);
+
/**
* 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪铏氭嫙鍗¤〃涓拡瀵硅櫄鎷熷崱缂栧彿锛坴cNum锛夎繘琛屾ā绯婃煡璇�
* 濡傛灉5浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛�
@@ -101,7 +72,7 @@
Integer number = Integer.parseInt(vcNum.substring(12));
number = number + 1;
if(number > 65535) {
- return BaseResponseUtils.buildFail(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage());
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage());
}
vcNum = vcNum.substring(0, 12) + String.format("%05d", number);
} else {
@@ -118,9 +89,38 @@
seVirtualCard.setCreateTime(new Date());
Long rec = virtualCardSv.insertVirtualCard(seVirtualCard);
if(rec == null) {
- return BaseResponseUtils.buildFail(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true) ;
+ }
+
+ /**
+ * 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗�
+ * @return
+ */
+ @GetMapping(path = "/get")
+ public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){
+ try {
+ return BaseResponseUtils.buildSuccess(virtualCardSv.getVCs(clientId));
+ } catch (Exception e) {
+ log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ }
+
+ /**
+ * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞�
+ * @param vcId
+ * @return
+ */
+ @GetMapping(path = "/getVcById")
+ public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){
+ try {
+ return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId));
+ } catch (Exception e) {
+ log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
}
/**
@@ -140,7 +140,6 @@
//})
//@PostMapping(path = "add_refund", consumes = MediaType.APPLICATION_JSON_VALUE)
//@Transactional(rollbackFor = Exception.class)
- //@SsoAop()
//public BaseResponse<Boolean> addRefund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){
// if(bindingResult != null && bindingResult.hasErrors()){
// return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
@@ -198,7 +197,6 @@
//})
//@PostMapping(path = "audit_refund", consumes = MediaType.APPLICATION_JSON_VALUE)
//@Transactional(rollbackFor = Exception.class)
- //@SsoAop()
//public BaseResponse<Boolean> auditRefund(@RequestBody @Valid DtoAudit po, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException {
// if(bindingResult != null && bindingResult.hasErrors()){
// return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
@@ -256,7 +254,6 @@
* @return
*/
@GetMapping(path = "/getVcRechargeRecords")
- @SsoAop()
public BaseResponse<QueryResultVo<List<VoVcRecharge>>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){
try {
QueryResultVo<List<VoVcRecharge>> res = virtualCardSv.getVcRechargeRecords(dtoVcRecharge);
--
Gitblit v1.8.0