From a8f31c8b9c1e9bb7644e27b8baa476e1593790c0 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期四, 11 七月 2024 14:50:39 +0800 Subject: [PATCH] 2024-07-11 朱宝民 优化开卡接口、补卡接口,灌溉单元农户关联接口,轮灌组农户关联接口 --- pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java | 457 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 257 insertions(+), 200 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 d1be98a..cc04af9 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; @@ -8,12 +10,11 @@ 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.VoActiveCardNew; +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.*; @@ -35,7 +36,7 @@ import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import java.time.format.DateTimeFormatter; +import java.math.BigDecimal; import java.util.*; /** @@ -60,49 +61,46 @@ * @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() - 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()); } + Long clientId = po.getClientId(); + // 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode - String areaCode = String.valueOf(cardOperateSv.getAreaCodeByNum(po.getClientNum())); + Long areaCodeL = cardOperateSv.getAreaCodeById(clientId); + if(areaCodeL == null) { + return BaseResponseUtils.buildErrorMsg(SellResultCode.AREA_CODE_MISTAKE.getMessage()); + } + String areaCode = String.valueOf(areaCodeL); /** * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪姘村崱琛ㄤ腑閽堝姘村崱缂栧彿锛坈ardNum锛夎繘琛屾ā绯婃煡璇� - * 濡傛灉4浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� - * 濡傛灉4浣嶉『搴忓彿鏈揪鍒版渶澶у�硷紝鍒欏姞1 + * 濡傛灉椤哄簭鍙峰凡缁忚揪鍒版渶澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� + * 濡傛灉椤哄簭鍙锋湭杈惧埌鏈�澶у�硷紝鍒欏姞1 * cardNum涓烘柊鐨勫崱鍙� */ String cardNum = Optional.ofNullable(cardOperateSv.getCardNumOfMax(areaCode)).orElse(""); 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 鍏呭�奸噾棰� + * originalCardId 鍘熸按鍗D + * amount 鍏呭�奸噾棰濓紝鍏呭�兼帴鍙d负杈撳叆鍙傛暟锛岃ˉ鍗℃帴鍙d负鍘熷崱閫�杩橀噾棰� * reissueAmount 琛ュ崱閲戦锛岃ˉ鍗℃椂浣跨敤 * paymentId 鏀粯鏂瑰紡缂栧彿 * remarks 澶囨敞 @@ -110,8 +108,8 @@ * activeTime 寮�鍗℃椂闂� */ 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(); @@ -119,33 +117,31 @@ Date activeTime = new Date(); /** - * 鏍规嵁鍐滄埛缂栧彿鑾峰彇鍐滄埛ID - */ - Long clientId = cardOperateSv.getClientIdByNum(clientNum); - - /** - * 娣诲姞鍐滄埛鍗¤褰� + * 娣诲姞鍐滄埛鍗¤褰曪紝閫�杩橀噾棰濅綔涓哄綋鍓嶄綑棰� */ 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(0f); seCardOperate.setCardCost(cardCost); seCardOperate.setPaymentId(paymentId); seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode()); @@ -154,27 +150,32 @@ 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.setClientId(clientId); - DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); + if(amount != null && amount > 0 && originalCardId == null) { + 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); 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()); } } Map map = new HashMap(); - map.put("projectCode", Constant.projectCode_ym); + map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); + map.put("orderNumber", rec); map.put("cardNum", cardNum); return BaseResponseUtils.buildSuccess(map) ; } @@ -185,15 +186,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() @@ -206,8 +198,10 @@ * cardAddr 鏂扮殑姘村崱鍦板潃锛堜粎浠呭啓鍏ワ紝鏃犱笟鍔★級 * clientNum 鍐滄埛缂栧彿锛屽紑鏂板崱浣跨敤锛岄�氳繃鑰佸崱鍙疯幏鍙� * cardNum 姘村崱缂栧彿锛屼紶鍏ョ殑鏄�佸崱鍙凤紝杩斿洖鐨勬槸鏂板崱鍙� + * cardId 鍘熸按鍗★紙鎸傚け姘村崱锛塈D锛岃浆绉讳綑棰濆悗闇�瑕佹洿鏂板崱浣欓涓�0 * moeny 浣欓锛屾寕澶辨椂浣跨敤 * cardCost 鍗$墖璐圭敤 + * reissueAmount 閫�杩橀噾棰� * paymentId 鏀粯鏂瑰紡缂栧彿 * remarks 澶囨敞 * operator 鎿嶄綔浜虹紪鍙� @@ -215,59 +209,75 @@ String cardAddr = po.getCardAddr(); String clientNum = ""; - String cardNum = po.getCardNum(); - Float money = po.getMoney(); - Integer cardCost = po.getCardCost(); + Long clientId = 0L; + 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(); + + // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶变笖鏈ˉ鍗$殑鍙互琛ュ崱 + if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { + 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()); + } + } /** * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿 */ 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()); /** - * 娣诲姞鎸傚け璁板綍 + * 濡傛灉鏄ˉ鍗¤皟鐢ㄧ殑寮�鍗′笖杞Щ浜嗛��杩橀噾棰濓紝闇�淇敼鎸傚け鍗′綑棰濅负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.setCardAddr(cardAddr); - dtoActiveCard.setClientNum(clientNum); - dtoActiveCard.setCardCost(cardCost); - dtoActiveCard.setAmount(0f); - dtoActiveCard.setPaymentId(paymentId); - dtoActiveCard.setRemarks(remarks); - dtoActiveCard.setOperator(operator); - BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, null); + ActiveCard activeCard = new ActiveCard(); + 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 = 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) ; } @@ -278,15 +288,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() @@ -303,20 +304,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()); } @@ -333,19 +324,25 @@ */ 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(); + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + 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()); @@ -363,7 +360,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()); } /** @@ -382,10 +379,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) ; } /** @@ -394,15 +395,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() @@ -414,7 +406,7 @@ /** * cardId 姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� * clientId 鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛� - * cardNum 姘村崱缂栧彿 + * cardNum 瑕佹寕澶辩殑姘村崱缂栧彿 * money 浣欓 * refund 閫�娆鹃噾棰� * remarks 澶囨敞 @@ -423,27 +415,35 @@ */ 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(); + + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + 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); @@ -453,27 +453,33 @@ 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) ; + 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) ; } /** @@ -482,15 +488,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() @@ -511,19 +508,25 @@ */ 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(); + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + 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()); @@ -540,7 +543,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()); } /** @@ -557,10 +560,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) ; + } /** @@ -569,15 +577,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() @@ -598,19 +597,25 @@ */ 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(); + // 楠岃瘉姘村崱鐘舵�佹槸鍚︽敮鎸佸綋鍓嶆搷浣� + 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()); @@ -627,7 +632,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()); } /** @@ -637,14 +642,14 @@ seCardOperate.setCardId(cardId); seCardOperate.setClientId(clientId); seCardOperate.setMoney(money); - 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) ; @@ -656,28 +661,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 鎿嶄綔浜虹紪鍙� @@ -685,18 +680,23 @@ */ 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(); + + // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互瑙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()); @@ -714,7 +714,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()); } /** @@ -730,10 +730,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) ; + } /** @@ -762,7 +767,6 @@ } } - /** * 鏍规嵁鎸囧畾鏉′欢鑾峰彇浜ゆ槗鏄庣粏 * @param vo @@ -789,34 +793,6 @@ } } - - /** - * 鑾峰彇浜ゆ槗姹囨�昏褰� - * @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 = "getStatistics") - @SsoAop() - public BaseResponse<Map> getStatistics(QoTransactionStatistics vo){ - try { - Map res = cardOperateSv.getTransactionStatistics(vo); - return BaseResponseUtils.buildSuccess(res); - } catch (Exception e) { - log.error("鏌ヨ浜ゆ槗姹囨�昏褰曞紓甯�", e); - return BaseResponseUtils.buildException(e.getMessage()) ; - } - } - - /** * 鏍规嵁鎸囧畾鏉′欢鑾峰彇寮�鍗¤褰� * @param vo @@ -833,9 +809,9 @@ }) @GetMapping(path = "/getActiveCards") @SsoAop() - public BaseResponse<QueryResultVo<List<VoActiveCardNew>>> getActiveCards(QoActiveCard vo){ + public BaseResponse<QueryResultVo<List<VoActiveCard>>> getActiveCards(QoActiveCard vo){ try { - QueryResultVo<List<VoActiveCardNew>> res = cardOperateSv.getActiveCards(vo); + QueryResultVo<List<VoActiveCard>> res = cardOperateSv.getActiveCards(vo); if(res.itemTotal == 0) { return BaseResponseUtils.buildFail(SellResultCode.No_ActiveCards.getMessage()); } @@ -845,8 +821,6 @@ return BaseResponseUtils.buildException(e.getMessage()) ; } } - - /** * 鏍规嵁鎸囧畾鏉′欢鑾峰彇琛ュ崱璁板綍 @@ -877,4 +851,87 @@ } } + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇閫氱敤鎿嶄綔璁板綍 + * 娉ㄩ攢銆佹寕澶便�佸啿姝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