| | |
| | | import com.dy.pipIrrSell.clientCard.LastOperateENUM; |
| | | import com.dy.pipIrrSell.recharge.DtoRecharge; |
| | | import com.dy.pipIrrSell.recharge.RechargeCtrl; |
| | | 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; |
| | |
| | | public class ActiveCardCtrl { |
| | | private final ActiveCardSv activeCardSv; |
| | | private final ClientCardSv clientCardSv; |
| | | |
| | | private final RechargeCtrl rechargeCtrl; |
| | | |
| | | @Operation(summary = "获得一页开卡记录", description = "返回一页开卡数据") |
| | |
| | | */ |
| | | VoAreaCode voAreaCode = activeCardSv.getAreaCodeByNum(po.getClientNum()); |
| | | if(voAreaCode == null) { |
| | | return BaseResponseUtils.buildFail("该农户行政区划异常,请联系系统管理员"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.AREA_CODE_MISTAKE.getMessage()); |
| | | } |
| | | String provinceId = voAreaCode.getProvinceId(); |
| | | String cityId = voAreaCode.getCityId(); |
| | |
| | | Integer number = Integer.parseInt(cardNum.substring(12)); |
| | | number = number + 1; |
| | | if(number > 9999) { |
| | | return BaseResponseUtils.buildFail("水卡编号已满,请联系系统管理员"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | cardNum = cardNum.substring(0, 12) + String.format("%04d", number); |
| | | } else { |
| | |
| | | |
| | | |
| | | /** |
| | | * cardId 水卡编号(插入记录后生成) |
| | | * cardAddr 水卡地址(仅仅写入,无业务) |
| | | * clientNum 农户编号 |
| | | * cardCost 卡片费用 |
| | |
| | | * operator 操作人编号 |
| | | * activeTime 开卡时间 |
| | | */ |
| | | //Long cardId = 0L; |
| | | String cardAddr = po.getCardAddr(); |
| | | //Long clientId = po.getClientId(); |
| | | String clientNum = po.getClientNum(); |
| | | Integer cardCost = po.getCardCost(); |
| | | Float amount = po.getAmount(); |
| | |
| | | */ |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setCardaddr(cardAddr); |
| | | //seClientCard.setClientid(clientId); |
| | | seClientCard.setCardnum(cardNum); |
| | | seClientCard.setClientnum(clientNum); |
| | | seClientCard.setMoney(0.0); |
| | |
| | | |
| | | Long cardId = Optional.ofNullable(clientCardSv.add(seClientCard)).orElse(0L) ; |
| | | if(cardId == 0) { |
| | | return BaseResponseUtils.buildFail("开卡失败-农户卡写入异常"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | SeActiveCard activeCard = new SeActiveCard(); |
| | | activeCard.setCardnum(cardNum); |
| | | activeCard.setClientnum(clientNum); |
| | | //activeCard.setCardid(cardId); |
| | | //activeCard.setClientid(clientId); |
| | | activeCard.setCardcost(cardCost); |
| | | activeCard.setPaymentid(paymentId); |
| | | activeCard.setOperatetype(OperateTypeENUM.ACTIVE.getCode()); |
| | |
| | | activeCard.setOperatedt(createTime); |
| | | Long rec = Optional.ofNullable(activeCardSv.add(activeCard)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail("开卡失败-开卡记录写入异常"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | dtoRecharge.setPrice(0f); |
| | | BaseResponse<Boolean> job = rechargeCtrl.addRecharge(dtoRecharge); |
| | | if(!job.getCode().equals("0001")) { |
| | | return BaseResponseUtils.buildFail("开卡成功,但充值失败"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | Long cardId = 0L; |
| | | String cardNum = po.getCardNum(); |
| | | //String clientNum = po.getClientNum(); |
| | | String clientNum = ""; |
| | | Integer cardCost = po.getCardCost(); |
| | | Double reissueAmount = po.getReissueAmount(); |
| | |
| | | */ |
| | | Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); |
| | | if(map == null || map.size() <= 0) { |
| | | return BaseResponseUtils.buildFail("卡号错误,该卡不存在"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_ERROR.getMessage()); |
| | | } |
| | | cardId = Long.parseLong(map.get("cardId").toString()); |
| | | clientNum = map.get("clientNum").toString(); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.REPLACE.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail("补卡失败-农户卡修改异常"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | SeActiveCard activeCard = new SeActiveCard(); |
| | | activeCard.setCardnum(cardNum); |
| | | activeCard.setClientnum(clientNum); |
| | | //activeCard.setCardid(cardId); |
| | | //activeCard.setClientid(clientId); |
| | | activeCard.setCardcost(cardCost); |
| | | activeCard.setPaymentid(paymentId); |
| | | activeCard.setReissueamount(reissueAmount); |
| | |
| | | activeCard.setOperatedt(replaceTime); |
| | | Long rec = Optional.ofNullable(activeCardSv.add(activeCard)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail("补卡失败-补卡记录写入异常"); |
| | | return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |