|  |  | 
 |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
 |  |  | import com.dy.common.webUtil.QueryResultVo; | 
 |  |  | import com.dy.common.webUtil.ResultCodeMsg; | 
 |  |  | import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; | 
 |  |  | import com.dy.pipIrrGlobal.pojoSe.SeActiveCard; | 
 |  |  | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; | 
 |  |  | import com.dy.pipIrrGlobal.voBa.VoAreaCode; | 
 |  |  | import com.dy.pipIrrGlobal.util.Constant; | 
 |  |  | import com.dy.pipIrrGlobal.voSe.VoActiveCard; | 
 |  |  | import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; | 
 |  |  | import com.dy.pipIrrSell.clientCard.CardStateENUM; | 
 |  |  | import com.dy.pipIrrSell.clientCard.ClientCardSv; | 
 |  |  | import com.dy.pipIrrSell.clientCard.LastOperateENUM; | 
 |  |  | import com.dy.pipIrrSell.recharge.DtoRecharge; | 
 |  |  | import com.dy.pipIrrSell.recharge.RechargeCtrl; | 
 |  |  | import com.dy.pipIrrSell.recharge.RechargeSv; | 
 |  |  | import com.dy.pipIrrSell.result.SellResultCode; | 
 |  |  | import io.swagger.v3.oas.annotations.Operation; | 
 |  |  | import io.swagger.v3.oas.annotations.Parameter; | 
 |  |  | import io.swagger.v3.oas.annotations.media.Content; | 
 |  |  | import io.swagger.v3.oas.annotations.media.Schema; | 
 |  |  | import io.swagger.v3.oas.annotations.responses.ApiResponse; | 
 |  |  | 
 |  |  |     private final ActiveCardSv activeCardSv; | 
 |  |  |     private final ClientCardSv clientCardSv; | 
 |  |  |     private final RechargeCtrl rechargeCtrl; | 
 |  |  |     private final RechargeSv rechargeSv; | 
 |  |  |     private final BaSettingsMapper baSettingsMapper; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     //@Value("${projectCode.ym}") | 
 |  |  |     //private Integer projectCode; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取开卡记录 | 
 |  |  |      * @param vo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Operation(summary = "获得一页开卡记录", description = "返回一页开卡数据") | 
 |  |  |     @ApiResponses(value = { | 
 |  |  |             @ApiResponse( | 
 |  |  | 
 |  |  |                             schema = @Schema(implementation = VoActiveCard.class))} | 
 |  |  |             ) | 
 |  |  |     }) | 
 |  |  |     @GetMapping(path = "/getActiveCards", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @SsoAop("-1") | 
 |  |  |     public BaseResponse<QueryResultVo<List<VoActiveCard>>> getActiveCards(@RequestBody @Parameter(description = "查询form表单json数据", required = true) QueryVo vo){ | 
 |  |  |     @GetMapping(path = "/getActiveCards") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<QueryResultVo<List<VoActiveCard>>> getActiveCards(QueryVo vo){ | 
 |  |  |         try { | 
 |  |  |             QueryResultVo<List<VoActiveCard>> res = activeCardSv.getActiveCards(vo); | 
 |  |  |             return BaseResponseUtils.buildSuccess(res); | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 开卡操作 | 
 |  |  |      * @param po | 
 |  |  |      * @param bindingResult | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Operation(summary = "开卡", description = "新开农户卡") | 
 |  |  |     @ApiResponses(value = { | 
 |  |  |             @ApiResponse( | 
 |  |  | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "add_active", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> add_active(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid DtoActiveCard po, @Parameter(hidden = true) BindingResult bindingResult){ | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> add_active(@RequestBody @Valid DtoActiveCard po, BindingResult bindingResult){ | 
 |  |  |         if(bindingResult != null && bindingResult.hasErrors()){ | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |          * townId       镇级区划代码 | 
 |  |  |          * villageId    村级区划代码 | 
 |  |  |          */ | 
 |  |  |         VoAreaCode voAreaCode = activeCardSv.getAreaCodeByNum(po.getClientNum()); | 
 |  |  |         if(voAreaCode == null) { | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.AREA_CODE_MISTAKE.getMessage()); | 
 |  |  |         } | 
 |  |  |         String provinceId = voAreaCode.getProvinceId(); | 
 |  |  |         String cityId = voAreaCode.getCityId(); | 
 |  |  |         String countryId = voAreaCode.getCountryId(); | 
 |  |  |         String townId = voAreaCode.getTownId(); | 
 |  |  |         String villageId = voAreaCode.getVillageId(); | 
 |  |  |         String areaCode = provinceId + cityId + countryId + townId + villageId; | 
 |  |  |         //VoAreaCode voAreaCode = activeCardSv.getAreaCodeByNum(po.getClientNum()); | 
 |  |  |         //if(voAreaCode == null) { | 
 |  |  |         //    return BaseResponseUtils.buildFail(SellResultCode.AREA_CODE_MISTAKE.getMessage()); | 
 |  |  |         //} | 
 |  |  |         //String provinceId = voAreaCode.getProvinceId(); | 
 |  |  |         //String cityId = voAreaCode.getCityId(); | 
 |  |  |         //String countryId = voAreaCode.getCountryId(); | 
 |  |  |         //String townId = voAreaCode.getTownId(); | 
 |  |  |         //String villageId = voAreaCode.getVillageId(); | 
 |  |  |         //String areaCode = provinceId + cityId + countryId + townId + villageId; | 
 |  |  |  | 
 |  |  |         String areaCode = String.valueOf(activeCardSv.getAreaCodeByNum(po.getClientNum())); | 
 |  |  |  | 
 |  |  |         /** | 
 |  |  |          * 根据行政区划串(areaCode)在水卡表中针对水卡编号(cardNum)进行模糊查询 | 
 |  |  | 
 |  |  |          */ | 
 |  |  |         String cardAddr = po.getCardAddr(); | 
 |  |  |         String clientNum = po.getClientNum(); | 
 |  |  |         //Long clientId = po.getClientId(); | 
 |  |  |  | 
 |  |  |         Integer cardCost = po.getCardCost(); | 
 |  |  |         Float amount = po.getAmount(); | 
 |  |  |         Long paymentId = po.getPaymentId(); | 
 |  |  | 
 |  |  |         Date createTime = new Date(); | 
 |  |  |  | 
 |  |  |         /** | 
 |  |  |          * 根据农户编号获取农户ID | 
 |  |  |          */ | 
 |  |  |         Long clientId = activeCardSv.getClientIdByNum(clientNum); | 
 |  |  |  | 
 |  |  |         /** | 
 |  |  |          * 添加农户卡记录 | 
 |  |  |          */ | 
 |  |  |         SeClientCard seClientCard = new SeClientCard(); | 
 |  |  |         seClientCard.setCardaddr(cardAddr); | 
 |  |  |         seClientCard.setCardnum(cardNum); | 
 |  |  |         seClientCard.setClientnum(clientNum); | 
 |  |  |         seClientCard.setMoney(0.0); | 
 |  |  |         //seClientCard.setClientnum(clientNum); | 
 |  |  |         seClientCard.setClientid(clientId); | 
 |  |  |         seClientCard.setMoney(0f); | 
 |  |  |         seClientCard.setState(CardStateENUM.NORMAL.getCode()); | 
 |  |  |         seClientCard.setCreatedt(createTime); | 
 |  |  |         seClientCard.setLastoper(LastOperateENUM.ACTIVE.getCode()); | 
 |  |  | 
 |  |  |          * 添加开卡记录 | 
 |  |  |          */ | 
 |  |  |         SeActiveCard activeCard = new SeActiveCard(); | 
 |  |  |         activeCard.setCardnum(cardNum); | 
 |  |  |         activeCard.setClientnum(clientNum); | 
 |  |  |         //activeCard.setCardnum(cardNum); | 
 |  |  |         //activeCard.setClientnum(clientNum); | 
 |  |  |  | 
 |  |  |         activeCard.setCardid(cardId); | 
 |  |  |         activeCard.setClientid(clientId); | 
 |  |  |         activeCard.setCardcost(cardCost); | 
 |  |  |         activeCard.setPaymentid(paymentId); | 
 |  |  |         activeCard.setOperatetype(OperateTypeENUM.ACTIVE.getCode()); | 
 |  |  | 
 |  |  |         /** | 
 |  |  |          * 如果操作人员开卡时输入了充值金额,则开卡后调用充值功能 | 
 |  |  |          */ | 
 |  |  |         po.setCardNum(cardNum); | 
 |  |  |         po.setCardNum(Long.parseLong(cardNum)); | 
 |  |  |         if(amount != null && amount > 0) { | 
 |  |  |             po.setClientId(clientId); | 
 |  |  |             DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); | 
 |  |  |             dtoRecharge.setMoney(0f); | 
 |  |  |             dtoRecharge.setGift(0f); | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return BaseResponseUtils.buildSuccess(cardNum) ; | 
 |  |  |         Map map = new HashMap(); | 
 |  |  |         if(amount != null && amount > 0) { | 
 |  |  |             Long rechargeId = rechargeSv.selectIdByCardId(cardId); | 
 |  |  |             map.put("orderNumber",rechargeId+"");//返回充值ID | 
 |  |  |         }else { | 
 |  |  |             map.put("orderNumber",rec+"");//返回开卡ID | 
 |  |  |         } | 
 |  |  |         String projectNo = baSettingsMapper.getItemValue("projectNo"); | 
 |  |  |         Integer projectNo1 = Integer.valueOf(projectNo); | 
 |  |  |         String projectNo3 = String.format("%02x", projectNo1); | 
 |  |  |         map.put("projectNo", projectNo3); | 
 |  |  |         map.put("cardNum", cardNum); | 
 |  |  |         return BaseResponseUtils.buildSuccess(map) ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Operation(summary = "补卡", description = "补卡") | 
 |  |  | 
 |  |  |     }) | 
 |  |  |     @PostMapping(path = "add_reissue", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @SsoAop("-1")//@SsoAop(power = "-1") | 
 |  |  |     public BaseResponse<Boolean> add_reissue(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid DtoActiveCard po, @Parameter(hidden = true) BindingResult bindingResult){ | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> add_reissue(@RequestBody @Valid DtoActiveCard po, BindingResult bindingResult){ | 
 |  |  |         if(bindingResult != null && bindingResult.hasErrors()){ | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         /** | 
 |  |  |          * cardId           水卡编号(非传入参数,由cardNum反查,更新水卡表用) | 
 |  |  |          * cardNum          水卡编号 | 
 |  |  |          * clientNum        农户编号(非传入参数,由cardNum反查,添加补卡使用) | 
 |  |  |          //* clientNum        农户编号(非传入参数,由cardNum反查,添加补卡使用) | 
 |  |  |          * clientId         农户ID(非传入参数,由cardNum反查,添加补卡使用) | 
 |  |  |          * cardCost         卡片费用 | 
 |  |  |          * reissueAmount    补卡金额,补卡时使用 | 
 |  |  |          * paymentId        支付方式编号 | 
 |  |  | 
 |  |  |          * activeTime       补卡时间 | 
 |  |  |          */ | 
 |  |  |         Long cardId = 0L; | 
 |  |  |         String cardNum = po.getCardNum(); | 
 |  |  |         String clientNum = ""; | 
 |  |  |         Long cardNum = po.getCardNum(); | 
 |  |  |         //String clientNum = ""; | 
 |  |  |         Long clientId = 0L; | 
 |  |  |         Integer cardCost = po.getCardCost(); | 
 |  |  |         Double reissueAmount = po.getReissueAmount(); | 
 |  |  |         Float reissueAmount = po.getReissueAmount(); | 
 |  |  |         Long paymentId = po.getPaymentId(); | 
 |  |  |         String remarks = po.getRemarks(); | 
 |  |  |         Long operator = po.getOperator(); | 
 |  |  | 
 |  |  |             return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_ERROR.getMessage()); | 
 |  |  |         } | 
 |  |  |         cardId = Long.parseLong(map.get("cardId").toString()); | 
 |  |  |         clientNum = map.get("clientNum").toString(); | 
 |  |  |         //clientNum = map.get("clientNum").toString(); | 
 |  |  |         clientId = Long.parseLong(map.get("clientId").toString()); | 
 |  |  |  | 
 |  |  |         /** | 
 |  |  |          * 修改农户卡信息: | 
 |  |  | 
 |  |  |          * 添加补卡记录 | 
 |  |  |          */ | 
 |  |  |         SeActiveCard activeCard = new SeActiveCard(); | 
 |  |  |         activeCard.setCardnum(cardNum); | 
 |  |  |         activeCard.setClientnum(clientNum); | 
 |  |  |         //activeCard.setCardnum(cardNum); | 
 |  |  |         //activeCard.setClientnum(clientNum); | 
 |  |  |         activeCard.setCardid(cardId); | 
 |  |  |         activeCard.setClientid(clientId); | 
 |  |  |         activeCard.setCardcost(cardCost); | 
 |  |  |         activeCard.setPaymentid(paymentId); | 
 |  |  |         activeCard.setReissueamount(reissueAmount); | 
 |  |  |         activeCard.setOperatetype(OperateTypeENUM.REPLACE.getCode()); | 
 |  |  |         activeCard.setOperatetype(OperateTypeENUM.REISSUE.getCode()); | 
 |  |  |         activeCard.setRemarks(remarks); | 
 |  |  |         activeCard.setOperator(operator); | 
 |  |  |         activeCard.setOperatedt(replaceTime); |