From 3dae16069f7f6572750f028a48ca291f449bbb44 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期五, 12 七月 2024 14:37:40 +0800 Subject: [PATCH] 2024-07-12 朱宝民 开卡传入协议,补卡返回协议 --- pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java | 300 ++++++++++++++++++++++++++--------------------------------- 1 files changed, 133 insertions(+), 167 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java index bb54a18..502c1e9 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java @@ -1,5 +1,7 @@ package com.dy.pipIrrSell.cardOperate; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; @@ -9,9 +11,10 @@ import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.util.AmountToChinese; -import com.dy.pipIrrGlobal.util.Constant; -import com.dy.pipIrrGlobal.voSe.*; -import com.dy.pipIrrSell.cardOperate.converter.RechargeDtoMapper; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; +import com.dy.pipIrrGlobal.voSe.VoOperate; +import com.dy.pipIrrGlobal.voSe.VoRecharge; +import com.dy.pipIrrGlobal.voSe.VoReissueCard; import com.dy.pipIrrSell.cardOperate.dto.*; import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; import com.dy.pipIrrSell.cardOperate.qo.*; @@ -34,7 +37,6 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; -import java.time.format.DateTimeFormatter; import java.util.*; /** @@ -62,26 +64,24 @@ @PostMapping(path = "active", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> add_active(@RequestBody @Valid DtoActiveCard po, BindingResult bindingResult){ + public BaseResponse<Boolean> add_active(@RequestBody @Valid ActiveCard po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } + + Long clientId = po.getClientId(); // 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode - String areaCode = cardOperateSv.getAreaCodeByNum(po.getClientNum()); - if(areaCode.trim().length() == 0) { + Long areaCodeL = cardOperateSv.getAreaCodeById(clientId); + if(areaCodeL == null) { return BaseResponseUtils.buildErrorMsg(SellResultCode.AREA_CODE_MISTAKE.getMessage()); } - - // p206V1_0_1鍗忚锛屽皢鍓�6浣嶈鏀垮尯鍒掓敼涓�100000 - if(po.getProtocol().trim().equals("p206V1_0_1")) { - areaCode = "100000" + areaCode.substring(6); - } + String areaCode = String.valueOf(areaCodeL); /** * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪姘村崱琛ㄤ腑閽堝姘村崱缂栧彿锛坈ardNum锛夎繘琛屾ā绯婃煡璇� - * 濡傛灉4浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� - * 濡傛灉4浣嶉『搴忓彿鏈揪鍒版渶澶у�硷紝鍒欏姞1 + * 濡傛灉椤哄簭鍙峰凡缁忚揪鍒版渶澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� + * 濡傛灉椤哄簭鍙锋湭杈惧埌鏈�澶у�硷紝鍒欏姞1 * cardNum涓烘柊鐨勫崱鍙� */ String cardNum = Optional.ofNullable(cardOperateSv.getCardNumOfMax(areaCode)).orElse(""); @@ -98,8 +98,8 @@ /** * cardAddr 姘村崱鍦板潃锛堜粎浠呭啓鍏ワ紝鏃犱笟鍔★級 - * clientNum 鍐滄埛缂栧彿 * cardCost 鍗$墖璐圭敤 + * originalCardId 鍘熸按鍗D * amount 鍏呭�奸噾棰濓紝鍏呭�兼帴鍙d负杈撳叆鍙傛暟锛岃ˉ鍗℃帴鍙d负鍘熷崱閫�杩橀噾棰� * reissueAmount 琛ュ崱閲戦锛岃ˉ鍗℃椂浣跨敤 * paymentId 鏀粯鏂瑰紡缂栧彿 @@ -107,8 +107,8 @@ * operator 鎿嶄綔浜虹紪鍙� * activeTime 寮�鍗℃椂闂� */ + String protocol = po.getProtocol(); String cardAddr = po.getCardAddr(); - String clientNum = po.getClientNum(); Integer cardCost = po.getCardCost(); Long originalCardId = po.getOriginalCardId(); Float amount = po.getAmount(); @@ -118,23 +118,18 @@ Date activeTime = new Date(); /** - * 鏍规嵁鍐滄埛缂栧彿鑾峰彇鍐滄埛ID - */ - Long clientId = cardOperateSv.getClientIdByNum(clientNum); - if(clientId == null) { - return BaseResponseUtils.buildErrorMsg(SellResultCode.CLIENT_NUM_ERROR.getMessage()); - } - - /** * 娣诲姞鍐滄埛鍗¤褰曪紝閫�杩橀噾棰濅綔涓哄綋鍓嶄綑棰� */ SeClientCard seClientCard = new SeClientCard(); + seClientCard.setProtocol(protocol); seClientCard.setCardaddr(cardAddr); seClientCard.setCardnum(cardNum); seClientCard.setClientid(clientId); seClientCard.setMoney(amount); seClientCard.setState(CardStateENUM.NORMAL.getCode()); - seClientCard.setOriginalCardId(originalCardId); + if(originalCardId != null) { + seClientCard.setOriginalCardId(originalCardId); + } seClientCard.setCreatedt(activeTime); seClientCard.setLastoper(LastOperateENUM.ACTIVE.getCode()); Long cardId = Optional.ofNullable(clientCardSv.add(seClientCard)).orElse(0L) ; @@ -148,7 +143,7 @@ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); - seCardOperate.setMoney(amount); + seCardOperate.setMoney(0f); seCardOperate.setCardCost(cardCost); seCardOperate.setPaymentId(paymentId); seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode()); @@ -164,10 +159,13 @@ * 濡傛灉鎿嶄綔浜哄憳寮�鍗℃椂杈撳叆浜嗗厖鍊奸噾棰濓紝鍒欏紑鍗″悗璋冪敤鍏呭�煎姛鑳� * 琛ュ崱闄ゅ锛岃ˉ鍗$殑閫�杩橀噾棰濇槸浠庢寕澶卞崱涓浆绉昏繃鏉ョ殑锛屾病鏈夊疄闄呴噾閽变氦鏄� */ - po.setCardNum(Long.parseLong(cardNum)); if(amount != null && amount > 0 && originalCardId == null) { - po.setClientId(clientId); - DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); + DtoRecharge dtoRecharge = new DtoRecharge(); + dtoRecharge.setCardNum(Long.parseLong(cardNum)); + dtoRecharge.setAmount(amount); + dtoRecharge.setPaymentId(paymentId); + dtoRecharge.setRemarks(remarks); + dtoRecharge.setOperator(operator); dtoRecharge.setMoney(0f); dtoRecharge.setGift(0f); dtoRecharge.setPrice(0f); @@ -177,13 +175,9 @@ } } - if(po.getProtocol().trim().equals("p206V1_0_1")) { - cardNum = cardNum.substring(6,12) + cardNum.substring(13); - } - Map map = new HashMap(); map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); - map.put("orderNumber", cardId); + map.put("orderNumber", rec); map.put("cardNum", cardNum); return BaseResponseUtils.buildSuccess(map) ; } @@ -194,21 +188,12 @@ * @param bindingResult * @return */ - @Operation(summary = "琛ュ崱", description = "琛ュ崱") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "reissue", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_reissue(@RequestBody @Valid DtoReissue po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** @@ -218,24 +203,35 @@ * cardId 鍘熸按鍗★紙鎸傚け姘村崱锛塈D锛岃浆绉讳綑棰濆悗闇�瑕佹洿鏂板崱浣欓涓�0 * moeny 浣欓锛屾寕澶辨椂浣跨敤 * cardCost 鍗$墖璐圭敤 + * reissueAmount 閫�杩橀噾棰� * paymentId 鏀粯鏂瑰紡缂栧彿 * remarks 澶囨敞 * operator 鎿嶄綔浜虹紪鍙� */ + String protocol; String cardAddr = po.getCardAddr(); String clientNum = ""; + Long clientId = 0L; Long cardNum = po.getCardNum(); Long cardId = 0L; - Integer cardCost = po.getCardCost(); + Integer cardCost = Optional.ofNullable(po.getCardCost()).orElse(0); Float reissueAmount = po.getReissueAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); - // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互琛ュ崱 + // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶变笖鏈ˉ鍗$殑鍙互琛ュ崱 if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { - return BaseResponseUtils.buildFail(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } + + // 濡傛灉浼犲叆浜嗛��杩橀噾棰濓紝闇�瑕佸垽鏂�佸崱锛堣鎸傚け鐨勬按鍗★級鎸傚け鏃舵槸鍚﹀凡缁忛��娆撅紝鏃犺閫�娆惧灏戦兘鎻愮ず鐢ㄦ埛鎸傚け鏃跺凡閫�娆� + if(reissueAmount != null && reissueAmount > 0) { + Double tradeAmount = cardOperateSv.getTradeAmountByCardNo(cardNum); + if(tradeAmount != null) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_FEE_CANNOT_BE_REFUNDED.getMessage()); + } } /** @@ -243,43 +239,52 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } clientNum = map.get("clientNum").toString(); cardId = Long.parseLong(map.get("cardId").toString()); + clientId = Long.parseLong(map.get("clientId").toString()); + protocol = map.get("protocol").toString(); /** * 濡傛灉鏄ˉ鍗¤皟鐢ㄧ殑寮�鍗′笖杞Щ浜嗛��杩橀噾棰濓紝闇�淇敼鎸傚け鍗′綑棰濅负0 */ - SeClientCard seClientCard = new SeClientCard(); - seClientCard.setId(cardId); - seClientCard.setMoney(0f); - cardOperateSv.updateClientCard(seClientCard); + if(reissueAmount != null) { + SeClientCard seClientCard = new SeClientCard(); + seClientCard.setId(cardId); + seClientCard.setMoney(0f); + cardOperateSv.updateClientCard(seClientCard); + } /** * 娣诲姞寮�鍗¤褰曪紝閫�杩橀噾棰濆啿鍒版柊鍗′腑 */ - DtoActiveCard dtoActiveCard = new DtoActiveCard(); - dtoActiveCard.setCardAddr(cardAddr); - dtoActiveCard.setClientNum(clientNum); - dtoActiveCard.setOriginalCardId(cardNum); - dtoActiveCard.setCardCost(cardCost); - dtoActiveCard.setAmount(reissueAmount); - dtoActiveCard.setPaymentId(paymentId); - dtoActiveCard.setRemarks(remarks); - dtoActiveCard.setOperator(operator); - BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, null); + ActiveCard activeCard = new ActiveCard(); + activeCard.setProtocol(protocol); + activeCard.setCardAddr(cardAddr); + activeCard.setClientId(clientId); + activeCard.setOriginalCardId(cardId); + activeCard.setCardCost(cardCost); + activeCard.setAmount(reissueAmount); + activeCard.setPaymentId(paymentId); + activeCard.setRemarks(remarks); + activeCard.setOperator(operator); + BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(activeCard, null); if(!baseResponse_addActive.getCode().equals("0001")) { - return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); } - String theContent = String.valueOf(baseResponse_addActive.getContent()); - cardNum = Long.parseLong(theContent.substring(theContent.indexOf("=") + 1, theContent.indexOf(","))); + JSONObject job_content = (JSONObject) JSON.toJSON( baseResponse_addActive.getContent()); + cardNum = job_content.getLong("cardNum"); + String orderNumber = job_content.getString("orderNumber"); + String projectNo = job_content.getString("projectNo"); Map map_response = new HashMap(); - map_response.put("projectCode", Constant.projectCode_ym); + map_response.put("projectNo", projectNo); + map_response.put("orderNumber", orderNumber); map_response.put("cardNum", cardNum); + map_response.put("protocol", protocol); return BaseResponseUtils.buildSuccess(map_response) ; } @@ -289,21 +294,12 @@ * @param bindingResult * @return */ - @Operation(summary = "鍏呭��", description = "鍏呭��") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "recharge", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_recharge(@RequestBody @Valid DtoRecharge po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } return cardOperateSv.addRecharge(po); } @@ -314,22 +310,12 @@ * @param bindingResult * @return */ - @Operation(summary = "娣诲姞娉ㄩ攢璁板綍", description = "娣诲姞娉ㄩ攢璁板綍") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "cancel", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_cancel(@RequestBody @Valid DtoCancel po, BindingResult bindingResult){ - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** @@ -354,7 +340,7 @@ // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); if(stateName.length() == 0 || !stateName.equals("姝e父")) { - return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); } /** @@ -362,7 +348,7 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); @@ -380,7 +366,7 @@ seClientCard.setLastoper(LastOperateENUM.CANCEL.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { - return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CANCEL_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** @@ -399,10 +385,14 @@ Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CANCELL_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CANCEL_FAIL_WRITE_CANCELL_ERROR.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + Map map_response = new HashMap(); + map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map_response.put("orderNumber", rec); + map_response.put("cardNum", cardNum); + return BaseResponseUtils.buildSuccess(map_response) ; } /** @@ -411,27 +401,18 @@ * @param bindingResult * @return */ - @Operation(summary = "娣诲姞鎸傚け璁板綍", description = "娣诲姞鎸傚け璁板綍") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "loss", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_loss(@RequestBody @Valid DtoLoss po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** * cardId 姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� * clientId 鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� - * cardNum 姘村崱缂栧彿 + * cardNum 瑕佹寕澶辩殑姘村崱缂栧彿 * money 浣欓 * refund 閫�娆鹃噾棰� * remarks 澶囨敞 @@ -441,8 +422,8 @@ Long cardId = 0L; Long clientId = 0L; Long cardNum = po.getCardNum(); - Float money = po.getMoney(); - Float refund = po.getRefund(); + Float money = Optional.ofNullable(po.getMoney()).orElse(0f); + Float refund = Optional.ofNullable(po.getRefund()).orElse(0f); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date lossTime = new Date(); @@ -450,7 +431,7 @@ // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); if(stateName.length() == 0 || !stateName.equals("姝e父")) { - return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); } /** @@ -458,15 +439,17 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); /** * 淇敼鍐滄埛鍗′俊鎭細 - * 鎸傚け鏃堕棿 - * 鏈�鍚庢搷浣滅被鍨�-4 + * 浣欓 + * 鎸傚け鏃堕棿 + * 鐘舵�� + * 鏈�鍚庢搷浣滅被鍨�-6 */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setId(cardId); @@ -476,11 +459,12 @@ seClientCard.setLastoper(LastOperateENUM.LOSS.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { - return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** * 娣诲姞鎸傚け璁板綍 + * 濡傛灉閫�娆鹃噾棰濅笉涓虹┖锛屽垯浼犲叆璐熷�� */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); @@ -494,10 +478,14 @@ seCardOperate.setOperateDt(lossTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + Map map_response = new HashMap(); + map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map_response.put("orderNumber", rec); + map_response.put("cardNum", cardNum); + return BaseResponseUtils.buildSuccess(map_response) ; } /** @@ -506,21 +494,12 @@ * @param bindingResult * @return */ - @Operation(summary = "娣诲姞鍐叉璁板綍", description = "娣诲姞鍐叉璁板綍") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "reversal", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_reversal(@RequestBody @Valid DtoReversal po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** @@ -545,7 +524,7 @@ // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); if(stateName.length() == 0 || !stateName.equals("姝e父")) { - return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); } /** @@ -553,7 +532,7 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); @@ -570,7 +549,7 @@ seClientCard.setLastoper(LastOperateENUM.REVERSAL.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { - return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** @@ -587,10 +566,15 @@ seCardOperate.setOperateDt(reversalTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.REVERSAL_FAIL_WRITE_REVERSAL_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.REVERSAL_FAIL_WRITE_REVERSAL_ERROR.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + Map map_response = new HashMap(); + map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map_response.put("orderNumber", rec); + map_response.put("cardNum", cardNum); + return BaseResponseUtils.buildSuccess(map_response) ; + } /** @@ -599,21 +583,12 @@ * @param bindingResult * @return */ - @Operation(summary = "琛ユ墸", description = "琛ユ墸") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "refund", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_refund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** @@ -638,7 +613,7 @@ // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); if(stateName.length() == 0 || !stateName.equals("姝e父")) { - return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); } /** @@ -646,7 +621,7 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); @@ -663,7 +638,7 @@ seClientCard.setLastoper(LastOperateENUM.REFUND.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { - return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** @@ -673,7 +648,6 @@ seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); - //seCardOperate.setNoTradeAmount(refund); seCardOperate.setRefundAmount(refund); seCardOperate.setOperateType(OperateTypeENUM.REFUND.getCode()); seCardOperate.setRemarks(remarks); @@ -681,7 +655,7 @@ seCardOperate.setOperateDt(refundTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.REFUND_FAIL_WRITE_REFUND_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.REFUND_FAIL_WRITE_REFUND_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; @@ -693,22 +667,12 @@ * @param bindingResult * @return */ - @Operation(summary = "娣诲姞瑙i攣璁板綍", description = "娣诲姞瑙i攣璁板綍") - @ApiResponses(value = { - @ApiResponse( - responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, - description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", - content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = Boolean.class))} - ) - }) @PostMapping(path = "unlock", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> add_unlock(@RequestBody @Valid DtoUnlock po, BindingResult bindingResult){ - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } /** @@ -730,7 +694,7 @@ // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互瑙i攣 if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { - return BaseResponseUtils.buildFail(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); } /** @@ -738,7 +702,7 @@ */ Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); if(map == null || map.size() <= 0) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); } cardId = Long.parseLong(map.get("cardId").toString()); clientId = Long.parseLong(map.get("clientId").toString()); @@ -756,7 +720,7 @@ seClientCard.setLastoper(LastOperateENUM.UNLOCK.getCode()); Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); if(rec_updateClientCard == 0) { - return BaseResponseUtils.buildFail(SellResultCode.UNLOCK_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.UNLOCK_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** @@ -772,10 +736,15 @@ seCardOperate.setOperateDt(unlockTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.UNLOCK_FAIL_WRITE_UNLOCK_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.UNLOCK_FAIL_WRITE_UNLOCK_ERROR.getMessage()); } - return BaseResponseUtils.buildSuccess(true) ; + Map map_response = new HashMap(); + map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map_response.put("orderNumber", rec); + map_response.put("cardNum", cardNum); + return BaseResponseUtils.buildSuccess(map_response) ; + } /** @@ -797,9 +766,6 @@ public BaseResponse<QueryResultVo<List<VoRecharge>>> get(QoRecharge vo){ try { QueryResultVo<List<VoRecharge>> res = cardOperateSv.getRecharges(vo); - //if(res.itemTotal == 0) { - // return BaseResponseUtils.buildFail(SellResultCode.No_RECHARGES.getMessage()); - //} return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鑾峰彇鍏呭�艰褰曞紓甯�", e); @@ -853,7 +819,7 @@ try { QueryResultVo<List<VoActiveCard>> res = cardOperateSv.getActiveCards(vo); if(res.itemTotal == 0) { - return BaseResponseUtils.buildFail(SellResultCode.No_ActiveCards.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ActiveCards.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { @@ -882,7 +848,7 @@ try { QueryResultVo<List<VoReissueCard>> res = cardOperateSv.getReissueCards(vo); if(res.itemTotal == 0) { - return BaseResponseUtils.buildFail(SellResultCode.No_ReissueCards.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ReissueCards.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { @@ -913,13 +879,13 @@ // 楠岃瘉鎿嶄綔绫诲瀷鏄惁姝g‘ Integer operateType = Optional.ofNullable(vo.getOperateType()).orElse(0); if(operateType != 3 && operateType != 6 && operateType != 7 && operateType != 8) { - return BaseResponseUtils.buildFail(SellResultCode.PARAMS_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.PARAMS_ERROR.getMessage()); } try { QueryResultVo<List<VoOperate>> res = cardOperateSv.getCommonOperations(vo); if(res.itemTotal == 0) { - return BaseResponseUtils.buildFail(SellResultCode.No_CANCELS.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.No_CANCELS.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { @@ -948,7 +914,7 @@ try { Map res = Optional.ofNullable(cardOperateSv.getReceipts(vo)).orElse(new HashMap()); if(res.size() == 0) { - return BaseResponseUtils.buildFail(SellResultCode.No_RECEIPTS.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.No_RECEIPTS.getMessage()); } return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { -- Gitblit v1.8.0