From 0230c8b9866083341749d51393046053ab978a7e Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期五, 05 七月 2024 16:25:53 +0800 Subject: [PATCH] 2024-07-05 朱宝民 1.多数据源配置,2.注销、挂失、冲正、解锁优化返回值 --- pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java | 572 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 426 insertions(+), 146 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 e17004d..25c4d9c 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,18 +1,24 @@ 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; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoBa.BaClient; import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; -import com.dy.pipIrrGlobal.util.Constant; +import com.dy.pipIrrGlobal.util.AmountToChinese; +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.converter.RechargeDtoMapper; import com.dy.pipIrrSell.cardOperate.dto.*; import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; -import com.dy.pipIrrSell.cardOperate.qo.QoRecharge; +import com.dy.pipIrrSell.cardOperate.qo.*; import com.dy.pipIrrSell.clientCard.CardStateENUM; import com.dy.pipIrrSell.clientCard.ClientCardSv; import com.dy.pipIrrSell.clientCard.LastOperateENUM; @@ -31,7 +37,7 @@ import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import java.time.format.DateTimeFormatter; +import java.math.BigDecimal; import java.util.*; /** @@ -56,15 +62,6 @@ * @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 = "active", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() @@ -74,7 +71,15 @@ } // 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode - String areaCode = String.valueOf(cardOperateSv.getAreaCodeByNum(po.getClientNum())); + String areaCode = cardOperateSv.getAreaCodeByNum(po.getClientNum()); + if(areaCode.trim().length() == 0) { + 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); + } /** * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪姘村崱琛ㄤ腑閽堝姘村崱缂栧彿锛坈ardNum锛夎繘琛屾ā绯婃煡璇� @@ -86,19 +91,19 @@ if(cardNum != null && cardNum.trim().length() > 0) { Integer number = Integer.parseInt(cardNum.substring(12)); number = number + 1; - if(number > 9999) { - return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); + if(number > 65535) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); } - cardNum = cardNum.substring(0, 12) + String.format("%04d", number); + cardNum = cardNum.substring(0, 12) + String.format("%05d", number); } else { - cardNum = areaCode + "0001"; + cardNum = areaCode + "00001"; } /** * cardAddr 姘村崱鍦板潃锛堜粎浠呭啓鍏ワ紝鏃犱笟鍔★級 * clientNum 鍐滄埛缂栧彿 * cardCost 鍗$墖璐圭敤 - * amount 鍏呭�奸噾棰� + * amount 鍏呭�奸噾棰濓紝鍏呭�兼帴鍙d负杈撳叆鍙傛暟锛岃ˉ鍗℃帴鍙d负鍘熷崱閫�杩橀噾棰� * reissueAmount 琛ュ崱閲戦锛岃ˉ鍗℃椂浣跨敤 * paymentId 鏀粯鏂瑰紡缂栧彿 * remarks 澶囨敞 @@ -108,6 +113,7 @@ String cardAddr = po.getCardAddr(); String clientNum = po.getClientNum(); Integer cardCost = po.getCardCost(); + Long originalCardId = po.getOriginalCardId(); Float amount = po.getAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); @@ -118,30 +124,36 @@ * 鏍规嵁鍐滄埛缂栧彿鑾峰彇鍐滄埛ID */ Long clientId = cardOperateSv.getClientIdByNum(clientNum); + if(clientId == null) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.CLIENT_NUM_ERROR.getMessage()); + } /** - * 娣诲姞鍐滄埛鍗¤褰� + * 娣诲姞鍐滄埛鍗¤褰曪紝閫�杩橀噾棰濅綔涓哄綋鍓嶄綑棰� */ SeClientCard seClientCard = new SeClientCard(); seClientCard.setCardaddr(cardAddr); seClientCard.setCardnum(cardNum); seClientCard.setClientid(clientId); - seClientCard.setMoney(0f); + seClientCard.setMoney(amount); seClientCard.setState(CardStateENUM.NORMAL.getCode()); + if(originalCardId != null) { + seClientCard.setOriginalCardId(originalCardId); + } seClientCard.setCreatedt(activeTime); seClientCard.setLastoper(LastOperateENUM.ACTIVE.getCode()); - Long cardId = Optional.ofNullable(clientCardSv.add(seClientCard)).orElse(0L) ; if(cardId == 0) { - return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); } /** - * 娣诲姞寮�鍗¤褰� + * 娣诲姞寮�鍗¤褰曪紝閫�杩橀噾棰濅綔涓哄厖鍊奸噾棰� */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); + seCardOperate.setMoney(amount); seCardOperate.setCardCost(cardCost); seCardOperate.setPaymentId(paymentId); seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode()); @@ -150,14 +162,15 @@ seCardOperate.setOperateDt(activeTime); Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); if(rec == 0) { - return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); } /** * 濡傛灉鎿嶄綔浜哄憳寮�鍗℃椂杈撳叆浜嗗厖鍊奸噾棰濓紝鍒欏紑鍗″悗璋冪敤鍏呭�煎姛鑳� + * 琛ュ崱闄ゅ锛岃ˉ鍗$殑閫�杩橀噾棰濇槸浠庢寕澶卞崱涓浆绉昏繃鏉ョ殑锛屾病鏈夊疄闄呴噾閽变氦鏄� */ - po.setCardNum(cardNum); - if(amount != null && amount > 0) { + po.setCardNum(Long.parseLong(cardNum)); + if(amount != null && amount > 0 && originalCardId == null) { po.setClientId(clientId); DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); dtoRecharge.setMoney(0f); @@ -165,12 +178,17 @@ dtoRecharge.setPrice(0f); BaseResponse<Boolean> job = cardOperateSv.addRecharge(dtoRecharge); if(!job.getCode().equals("0001")) { - return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); + return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); } } + if(po.getProtocol().trim().equals("p206V1_0_1")) { + cardNum = cardNum.substring(6,12) + cardNum.substring(13); + } + Map map = new HashMap(); - map.put("projectCode", Constant.projectCode_ym); + map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map.put("orderNumber", cardId); map.put("cardNum", cardNum); return BaseResponseUtils.buildSuccess(map) ; } @@ -181,15 +199,6 @@ * @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() @@ -202,8 +211,10 @@ * cardAddr 鏂扮殑姘村崱鍦板潃锛堜粎浠呭啓鍏ワ紝鏃犱笟鍔★級 * clientNum 鍐滄埛缂栧彿锛屽紑鏂板崱浣跨敤锛岄�氳繃鑰佸崱鍙疯幏鍙� * cardNum 姘村崱缂栧彿锛屼紶鍏ョ殑鏄�佸崱鍙凤紝杩斿洖鐨勬槸鏂板崱鍙� + * cardId 鍘熸按鍗★紙鎸傚け姘村崱锛塈D锛岃浆绉讳綑棰濆悗闇�瑕佹洿鏂板崱浣欓涓�0 * moeny 浣欓锛屾寕澶辨椂浣跨敤 * cardCost 鍗$墖璐圭敤 + * reissueAmount 閫�杩橀噾棰� * paymentId 鏀粯鏂瑰紡缂栧彿 * remarks 澶囨敞 * operator 鎿嶄綔浜虹紪鍙� @@ -211,59 +222,84 @@ String cardAddr = po.getCardAddr(); String clientNum = ""; - String cardNum = po.getCardNum(); - Float money = po.getMoney(); - Integer cardCost = po.getCardCost(); + Long cardNum = po.getCardNum(); + Long cardId = 0L; + Integer cardCost = Optional.ofNullable(po.getCardCost()).orElse(0); + Float reissueAmount = po.getReissueAmount(); Long paymentId = po.getPaymentId(); String remarks = po.getRemarks(); Long operator = po.getOperator(); + String protocol = null; + + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + protocol = "p206V1_0_1"; + } + cardNum = Long.valueOf(cardNumS); + + // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶变笖鏈ˉ鍗$殑鍙互琛ュ崱 + if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } + + // 濡傛灉浼犲叆浜嗛��杩橀噾棰濓紝闇�瑕佸垽鏂�佸崱锛堣鎸傚け鐨勬按鍗★級鎸傚け鏃舵槸鍚﹀凡缁忛��娆撅紝鏃犺閫�娆惧灏戦兘鎻愮ず鐢ㄦ埛鎸傚け鏃跺凡閫�娆� + if(reissueAmount != null) { + Double tradeAmount = cardOperateSv.getTradeAmountByCardNo(cardNum); + if(tradeAmount != null) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_FEE_CANNOT_BE_REFUNDED.getMessage()); + } + } /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); /** - * 娣诲姞鎸傚け璁板綍 + * 濡傛灉鏄ˉ鍗¤皟鐢ㄧ殑寮�鍗′笖杞Щ浜嗛��杩橀噾棰濓紝闇�淇敼鎸傚け鍗′綑棰濅负0 */ - DtoLoss dtoLoss = new DtoLoss(); - dtoLoss.setCardNum(cardNum); - dtoLoss.setMoney(money); - dtoLoss.setRefund(0f); - dtoLoss.setRemarks(remarks); - dtoLoss.setOperator(operator); - BaseResponse<java.lang.Boolean> baseResponse_addLoss = this.add_loss(dtoLoss, null); - - if(!baseResponse_addLoss.getCode().equals("0001")) { - return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); + if(reissueAmount != null) { + SeClientCard seClientCard = new SeClientCard(); + seClientCard.setId(cardId); + seClientCard.setMoney(0f); + cardOperateSv.updateClientCard(seClientCard); } /** - * 娣诲姞寮�鍗¤褰� + * 娣诲姞寮�鍗¤褰曪紝閫�杩橀噾棰濆啿鍒版柊鍗′腑 */ DtoActiveCard dtoActiveCard = new DtoActiveCard(); + dtoActiveCard.setProtocol(protocol); dtoActiveCard.setCardAddr(cardAddr); dtoActiveCard.setClientNum(clientNum); + dtoActiveCard.setOriginalCardId(cardId); + //dtoActiveCard.setOriginalCardId(cardNum); dtoActiveCard.setCardCost(cardCost); - dtoActiveCard.setAmount(0f); + dtoActiveCard.setAmount(reissueAmount); dtoActiveCard.setPaymentId(paymentId); dtoActiveCard.setRemarks(remarks); dtoActiveCard.setOperator(operator); BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, 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 = 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); return BaseResponseUtils.buildSuccess(map_response) ; } @@ -274,15 +310,6 @@ * @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() @@ -299,20 +326,10 @@ * @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()); } @@ -329,19 +346,32 @@ */ Long cardId = 0L; Long clientId = 0L; - String cardNum = po.getCardNum(); + Long cardNum = po.getCardNum(); Float refund = po.getRefund(); Byte refundType = po.getRefundType(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date cancelTime = new Date(); + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + } + cardNum = Long.valueOf(cardNumS); + + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); + if(stateName.length() == 0 || !stateName.equals("姝e父")) { + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } + /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); @@ -359,16 +389,18 @@ 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()); } /** * 娣诲姞娉ㄩ攢璁板綍 + * 鏀粯鏂瑰紡涓虹幇閲� */ SeCardOperate seCardOperate = new SeCardOperate(); seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setTradeAmount(-refund); + seCardOperate.setPaymentId(1L); seCardOperate.setOperateType(OperateTypeENUM.CANCEL.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); @@ -376,10 +408,22 @@ 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) ; + //return BaseResponseUtils.buildSuccess(true) ; + + cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.substring(0,2).equals("10")) { + cardNumS = cardNumS.substring(6, 12) + cardNumS.substring(13); + } + cardNum = Long.valueOf(cardNumS); + + 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) ; } /** @@ -388,15 +432,6 @@ * @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() @@ -408,7 +443,7 @@ /** * cardId 姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� * clientId 鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� - * cardNum 姘村崱缂栧彿 + * cardNum 瑕佹寕澶辩殑姘村崱缂栧彿 * money 浣欓 * refund 閫�娆鹃噾棰� * remarks 澶囨敞 @@ -417,27 +452,42 @@ */ Long cardId = 0L; Long clientId = 0L; - String cardNum = po.getCardNum(); - Float money = po.getMoney(); - Float refund = po.getRefund(); + Long cardNum = po.getCardNum(); + 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(); + + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + } + cardNum = Long.valueOf(cardNumS); + + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); + if(stateName.length() == 0 || !stateName.equals("姝e父")) { + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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); @@ -447,27 +497,40 @@ 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); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); seCardOperate.setTradeAmount(-refund); + seCardOperate.setPaymentId(1L); seCardOperate.setOperateType(OperateTypeENUM.LOSS.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); 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) ; + //return BaseResponseUtils.buildSuccess(true) ; + cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.substring(0,2).equals("10")) { + cardNumS = cardNumS.substring(6, 12) + cardNumS.substring(13); + } + cardNum = Long.valueOf(cardNumS); + + 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) ; } /** @@ -476,15 +539,6 @@ * @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() @@ -505,19 +559,32 @@ */ Long cardId = 0L; Long clientId = 0L; - String cardNum = po.getCardNum(); + Long cardNum = po.getCardNum(); Float cardBalance = po.getCardBalance(); Float systemBalance = po.getSystemBalance(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date reversalTime = new Date(); + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + } + cardNum = Long.valueOf(cardNumS); + + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); + if(stateName.length() == 0 || !stateName.equals("姝e父")) { + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } + /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); @@ -534,7 +601,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()); } /** @@ -551,10 +618,22 @@ 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) ; + //return BaseResponseUtils.buildSuccess(true) ; + cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.substring(0,2).equals("10")) { + cardNumS = cardNumS.substring(6, 12) + cardNumS.substring(13); + } + cardNum = Long.valueOf(cardNumS); + + 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) ; + } /** @@ -563,15 +642,6 @@ * @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() @@ -592,19 +662,32 @@ */ Long cardId = 0L; Long clientId = 0L; - String cardNum = po.getCardNum(); + Long cardNum = po.getCardNum(); Float money = po.getMoney(); Float refund = po.getRefund(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date refundTime = new Date(); + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + } + cardNum = Long.valueOf(cardNumS); + + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); + if(stateName.length() == 0 || !stateName.equals("姝e父")) { + return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } + /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); @@ -621,7 +704,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()); } /** @@ -631,14 +714,15 @@ seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); - seCardOperate.setNoTradeAmount(refund); + //seCardOperate.setNoTradeAmount(refund); + seCardOperate.setRefundAmount(refund); seCardOperate.setOperateType(OperateTypeENUM.REFUND.getCode()); seCardOperate.setRemarks(remarks); seCardOperate.setOperator(operator); 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) ; @@ -650,28 +734,18 @@ * @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()); } /** - * cardId 姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardAddr鍙嶆煡锛屼慨鏀瑰啘鎴峰崱浣跨敤锛� + * cardId 姘村崱涓婚敭锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛屼慨鏀瑰啘鎴峰崱浣跨敤锛� * clientId 鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� - * cardNum 姘村崱鍦板潃 + * cardNum 姘村崱缂栧彿 * money 浣欓 * remarks 澶囨敞 * operator 鎿嶄綔浜虹紪鍙� @@ -679,18 +753,30 @@ */ Long cardId = 0L; Long clientId = 0L; - String cardNum = po.getCardNum(); + Long cardNum = po.getCardNum(); Float money = po.getMoney(); String remarks = po.getRemarks(); Long operator = po.getOperator(); Date unlockTime = new Date(); + + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + String cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + } + cardNum = Long.valueOf(cardNumS); + + // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互瑙i攣 + if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); + } /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); @@ -708,7 +794,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()); } /** @@ -724,12 +810,29 @@ 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) ; + //return BaseResponseUtils.buildSuccess(true) ; + cardNumS = String.valueOf(cardNum).trim(); + if(cardNumS.substring(0,2).equals("10")) { + cardNumS = cardNumS.substring(6, 12) + cardNumS.substring(13); + } + cardNum = Long.valueOf(cardNumS); + + 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) ; + } + /** + * 鑾峰彇鍏呭�艰褰� + * @param vo + * @return + */ @Operation(summary = "鑾峰彇鍏呭�艰褰�", description = "杩斿洖鍏呭�艰褰�") @ApiResponses(value = { @ApiResponse( @@ -742,6 +845,15 @@ @GetMapping(path = "/getRecharges") @SsoAop() public BaseResponse<QueryResultVo<List<VoRecharge>>> get(QoRecharge vo){ + // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙� + if(vo != null && vo.getCardNum() != null) { + String cardNumS = String.valueOf(vo.getCardNum()).trim(); + if(cardNumS.length() == 10) { + cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); + vo.setCardNum(Long.parseLong(cardNumS)); + } + } + try { QueryResultVo<List<VoRecharge>> res = cardOperateSv.getRecharges(vo); return BaseResponseUtils.buildSuccess(res); @@ -750,4 +862,172 @@ 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 = BaClient.class))} + ) + }) + @GetMapping(path = "getTransactions") + @SsoAop() + public BaseResponse<Map> getOperates(QoTransaction vo){ + try { + Map res = cardOperateSv.getTransactions(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 = "杩斿洖涓�椤靛紑鍗℃暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoActiveCard.class))} + ) + }) + @GetMapping(path = "/getActiveCards") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoActiveCard>>> getActiveCards(QoActiveCard vo){ + try { + QueryResultVo<List<VoActiveCard>> res = cardOperateSv.getActiveCards(vo); + if(res.itemTotal == 0) { + return BaseResponseUtils.buildFail(SellResultCode.No_ActiveCards.getMessage()); + } + 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 = "杩斿洖涓�椤佃ˉ鍗℃暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoActiveCard.class))} + ) + }) + @GetMapping(path = "/getReissueCards") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoReissueCard>>> getReissueCards(QoReissueCard vo){ + try { + QueryResultVo<List<VoReissueCard>> res = cardOperateSv.getReissueCards(vo); + if(res.itemTotal == 0) { + return BaseResponseUtils.buildFail(SellResultCode.No_ReissueCards.getMessage()); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇琛ュ崱璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇閫氱敤鎿嶄綔璁板綍 + * 娉ㄩ攢銆佹寕澶便�佸啿姝c�佽В閿侀�氱敤 + * 娉ㄩ攢-3锛屾寕澶�-6锛屽啿姝�-7锛岃В閿�-8 + * @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 = VoActiveCard.class))} + ) + }) + @GetMapping(path = "/getOptions") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoOperate>>> getCommonOperations(QoCommonOperate vo){ + // 楠岃瘉鎿嶄綔绫诲瀷鏄惁姝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()); + } + + try { + QueryResultVo<List<VoOperate>> res = cardOperateSv.getCommonOperations(vo); + if(res.itemTotal == 0) { + return BaseResponseUtils.buildFail(SellResultCode.No_CANCELS.getMessage()); + } + 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 = "杩斿洖涓�椤佃ˉ鍗℃暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoActiveCard.class))} + ) + }) + @GetMapping(path = "/get_receipts") + @SsoAop() + public BaseResponse<Map> getReceipts(QoReceipt vo){ + try { + Map res = Optional.ofNullable(cardOperateSv.getReceipts(vo)).orElse(new HashMap()); + if(res.size() == 0) { + return BaseResponseUtils.buildFail(SellResultCode.No_RECEIPTS.getMessage()); + } + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇鐢靛瓙閽卞寘璐︽埛璁板綍", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 閲戦杞ぇ鍐� + * @param amount + * @return + */ + + @GetMapping(path = "/amount_to_chinese") + public BaseResponse<Boolean> amountToChinese(BigDecimal amount) { + try { + AmountToChinese amountToChinese = new AmountToChinese(); + String chinese = amountToChinese.toChinese(amount); + return BaseResponseUtils.buildSuccess(chinese) ; + } catch (Exception e) { + return BaseResponseUtils.buildException(e.getMessage()) ; + } + + } } -- Gitblit v1.8.0