From ce1985a0fc44cb2a8ca5f70cb2361556712804d0 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 25 六月 2025 15:28:35 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java | 338 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 315 insertions(+), 23 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java index 33a1ec5..ea8f0f8 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java @@ -3,21 +3,25 @@ import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; -import com.dy.pipIrrGlobal.voSe.VoTermActiveCard; -import com.dy.pipIrrGlobal.voSe.VoTermRecharge; -import com.dy.pipIrrTerminal.card.dto.ActiveCard; -import com.dy.pipIrrTerminal.card.dto.DtoRecharge; -import com.dy.pipIrrTerminal.card.dto.DtoReissue; +import com.dy.common.webUtil.QueryResultVo; +import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.voSe.*; +import com.dy.pipIrrTerminal.card.dto.*; +import com.dy.pipIrrTerminal.card.qo.QoCards; +import com.dy.pipIrrTerminal.card.qo.QoLostCards; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; -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.RestController; +import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -37,64 +41,352 @@ /** * 寮�鍗★紙鍚厖鍊硷級 + * * @param po * @param bindingResult * @return */ @PostMapping(path = "termActiveCard", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() - public BaseResponse<VoTermActiveCard> termActiveCard(@RequestBody @Valid ActiveCard po, BindingResult bindingResult) { + public BaseResponse<VoTermActiveCard> termActiveCard(@RequestBody @Valid ActiveCard po, + BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { - return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Map map_result = cardSv.activeOrReissueTermCard(po); - if(map_result.get("success").equals(false)) { + if (map_result.get("success").equals(false)) { return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } - return BaseResponseUtils.buildSuccess(map_result.get("content")) ; + return BaseResponseUtils.buildSuccess(map_result.get("content")); } /** * 鍏呭�� + * * @param po * @param bindingResult * @return */ @PostMapping(path = "termRecharge", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() - public BaseResponse<VoTermRecharge> termRecharge(@RequestBody @Valid DtoRecharge po, BindingResult bindingResult) { + public BaseResponse<VoTermCommon> termRecharge(@RequestBody @Valid DtoRecharge po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { - return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } - Map map_result = cardSv.addRecharge(po); - if(map_result.get("success").equals(false)) { + Map map_result = cardSv.addRecharge(po, null); + if (map_result.get("success").equals(false)) { return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } - return BaseResponseUtils.buildSuccess(map_result.get("content")) ; + return BaseResponseUtils.buildSuccess(map_result.get("content")); + + } + + /** + * 鎸傚け + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "termReportLoss", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> termReportLoss(@RequestBody @Valid DtoLoss po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = cardSv.reportLoss(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); + + } + + /** + * 瑙i攣 + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "termUnlock", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> termUnlock(@RequestBody @Valid DtoUnlock po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = cardSv.unlock(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); } /** * 琛ュ崱 + * * @param po * @param bindingResult * @return */ @PostMapping(path = "termReissue", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() - public BaseResponse<VoTermRecharge> termReissue(@RequestBody @Valid DtoReissue po, BindingResult bindingResult) { + public BaseResponse<VoTermCommon> termReissue(@RequestBody @Valid DtoReissue po, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { - return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Map map_result = cardSv.reissue(po); - if(map_result.get("success").equals(false)) { + if (map_result.get("success").equals(false)) { return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); } - return BaseResponseUtils.buildSuccess(map_result.get("content")) ; + return BaseResponseUtils.buildSuccess(map_result.get("content")); } -} + + /** + * 閿�鍗� + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "termCancel", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<VoTermCommon> termCancel(@RequestBody @Valid DtoCancel po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = cardSv.cancel(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); + + } + + /** + * 琛ユ墸 + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "termRepay", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<VoRepaySupplement> termRepay(@RequestBody @Valid DtoRepaySupplement po, + BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + if (po.getRepayMorny() == null || po.getRepayMorny() <= 0) { + return BaseResponseUtils.buildErrorMsg("琛ユ墸閲戦涓嶈兘涓虹┖涓旈渶澶т簬0"); + } + + if (po.getRepayMorny() > po.getBalance()) { + return BaseResponseUtils.buildErrorMsg("琛ユ墸閲戦涓嶈兘澶т簬琛ユ墸鍓嶄綑棰�"); + } + + Map map_result = cardSv.repay(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); + } + + /** + * 杩旇繕 + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "supplement", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<VoRepaySupplement> supplement(@RequestBody @Valid DtoRepaySupplement po, + BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + if (po.getSupplementMoney() == null || po.getSupplementMoney() <= 0) { + return BaseResponseUtils.buildErrorMsg("杩旇繕閲戦涓嶈兘涓虹┖涓旈渶澶т簬0"); + } + + Map map_result = cardSv.supplement(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); + } + + /** + * 鎿嶄綔鎵ц鍥炶皟 + * + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "termCallBack", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> termCallBack(@RequestBody @Valid DtoCallBack po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = cardSv.callBack(po); + if (map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess(map_result.get("content")); + } + + /** + * 璇诲彇鍗′俊鎭� + * + * @param cardAddr + * @return + */ + @GetMapping(path = "readCard") + @SsoAop() + public BaseResponse<VoTermCard> readCard(@RequestParam String cardAddr) { + try { + VoTermCard voTermCard = cardSv.readCard(cardAddr); + if (voTermCard == null) { + return BaseResponseUtils.buildNonExist(); + } + return BaseResponseUtils.buildSuccess(voTermCard); + } catch (Exception e) { + log.error("鏌ヨ鍐滄埛寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇姘村崱鍒楄〃锛岀粓绔簲鐢ㄧ▼搴忎娇鐢� + * + * @param vo + * @return + */ + @Operation(summary = "鑾峰緱涓�椤垫按鍗¤褰�", description = "杩斿洖涓�椤垫按鍗℃暟鎹�") + @ApiResponses(value = { + @ApiResponse(responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "杩斿洖涓�椤垫按鍗℃暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", content = { + @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = VoCards.class)) }) + }) + @GetMapping(path = "getcards") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoCards>>> getcards(QoCards vo) { + try { + QueryResultVo<List<VoCards>> res = cardSv.getCards(vo); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ姘村崱寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鑾峰彇宸叉寕澶辩殑姘村崱鍒楄〃锛岀粓绔簲鐢ㄧ▼搴忎娇鐢� + * + * @param vo + * @return + */ + @Operation(summary = "鑾峰緱涓�椤靛凡鎸傚け姘村崱璁板綍", description = "杩斿洖涓�椤靛凡鎸傚け姘村崱鏁版嵁") + @ApiResponses(value = { + @ApiResponse(responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "杩斿洖涓�椤靛凡鎸傚け姘村崱鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", content = { + @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = VoCards.class)) }) + }) + @GetMapping(path = "getlostcards") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoCards>>> getLostCards(QoLostCards vo) { + try { + QueryResultVo<List<VoCards>> res = cardSv.getLostCards(vo); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ宸叉寕澶辨按鍗″紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鏍规嵁姘村崱缂栧彿鑾峰彇鍗′俊鎭� + * + * @param cardNum 姘村崱缂栧彿 + * @return + */ + @Operation(summary = "鏍规嵁姘村崱缂栧彿鑾峰彇鍗′俊鎭�", description = "鏍规嵁姘村崱缂栧彿鑾峰彇瀵瑰簲鐨勫崱淇℃伅") + @ApiResponses(value = { + @ApiResponse(responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "杩斿洖鍗′俊鎭紙BaseResponse.content:VoCardByClientNum锛�", content = { + @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = VoCardByClientNum.class)) }) + }) + @GetMapping(path = "getcardbycardnum") + @SsoAop() + public BaseResponse<VoCardByClientNum> getCardByCardNum(@RequestParam String cardNum) { + try { + VoCardByClientNum res = cardSv.getCardByCardNum(cardNum); + if (res == null) { + return BaseResponseUtils.buildFail("鏈壘鍒板搴旂殑鍗′俊鎭�"); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏍规嵁姘村崱缂栧彿鏌ヨ鍗′俊鎭紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } + + /** + * 鍒涘缓绠$悊鍗� + * + * @param dto 鍒涘缓绠$悊鍗″弬鏁� + * @param bindingResult 鍙傛暟楠岃瘉缁撴灉 + * @return 鍒涘缓缁撴灉 + */ + @Operation(summary = "鍒涘缓绠$悊鍗�", description = "鍒涘缓鍏呭�兼満鐢ㄧ鐞嗗崱") + @ApiResponses(value = { + @ApiResponse(responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "鍒涘缓鎴愬姛锛岃繑鍥炶鍗曞彿", content = { + @Content(mediaType = MediaType.APPLICATION_JSON_VALUE) }) + }) + @PostMapping(path = "createManagementCard", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<String> createManagementCard(@RequestBody @Valid CreateManagementCardDto dto, + BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils + .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + // 楠岃瘉鍗$墖绫诲瀷鏄惁鍦ㄥ厑璁歌寖鍥村唴 + if (dto.getCardType() < 2 || dto.getCardType() > 10) { + return BaseResponseUtils.buildErrorMsg("鍗$墖绫诲瀷蹇呴』鍦�2-10涔嬮棿"); + } + + // 妫�鏌ュ崱鐗囧湴鍧�鏄惁宸插瓨鍦� + if (cardSv.isCardAddrExists(dto.getCardAddr())) { + return BaseResponseUtils.buildErrorMsg("璇ュ崱鐗囧湴鍧�宸插瓨鍦紝璇蜂娇鐢ㄥ叾浠栧湴鍧�"); + } + + Map<String, Object> result = cardSv.createManagementCard(dto); + if ((Boolean) result.get("success")) { + return BaseResponseUtils.buildSuccess((String) result.get("content")); + } else { + return BaseResponseUtils.buildErrorMsg(result.get("msg").toString()); + } + } +} \ No newline at end of file -- Gitblit v1.8.0