pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
@@ -8,17 +8,16 @@
import com.dy.pipIrrGlobal.pojoBa.BaClient;
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.VoActiveCard;
import com.dy.pipIrrGlobal.voSe.VoActiveCardNew;
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.QoActiveCard;
import com.dy.pipIrrSell.cardOperate.qo.QoRecharge;
import com.dy.pipIrrSell.cardOperate.qo.QoTransaction;
import com.dy.pipIrrSell.cardOperate.qo.QoTransactionStatistics;
import com.dy.pipIrrSell.cardOperate.qo.*;
import com.dy.pipIrrSell.clientCard.CardStateENUM;
import com.dy.pipIrrSell.clientCard.ClientCardSv;
import com.dy.pipIrrSell.clientCard.LastOperateENUM;
@@ -37,6 +36,7 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -224,6 +224,12 @@
        String remarks = po.getRemarks();
        Long operator = po.getOperator();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("正常")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
         */
@@ -342,6 +348,12 @@
        Long operator = po.getOperator();
        Date cancelTime = new Date();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("正常")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
         */
@@ -432,6 +444,12 @@
        Long operator = po.getOperator();
        Date lossTime = new Date();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("正常")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
         */
@@ -520,6 +538,12 @@
        Long operator = po.getOperator();
        Date reversalTime = new Date();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("正常")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
         */
@@ -607,6 +631,12 @@
        Long operator = po.getOperator();
        Date refundTime = new Date();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("正常")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
         */
@@ -639,7 +669,8 @@
        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);
@@ -692,6 +723,12 @@
        String remarks = po.getRemarks();
        Long operator = po.getOperator();
        Date unlockTime = new Date();
        // 验证水卡状态是否支持当前操作
        String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(Long.parseLong(cardNum))).orElse("");
        if(stateName.length() == 0 || !stateName.equals("已挂失")) {
            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
        }
        /**
         * 依据水卡编号获取水卡表主键及农户编号
@@ -835,7 +872,7 @@
    })
    @GetMapping(path = "/getActiveCards")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoActiveCardNew>>> get(QoActiveCard vo){
    public BaseResponse<QueryResultVo<List<VoActiveCardNew>>> getActiveCards(QoActiveCard vo){
        try {
            QueryResultVo<List<VoActiveCardNew>> res = cardOperateSv.getActiveCards(vo);
            if(res.itemTotal == 0) {
@@ -848,4 +885,81 @@
        }
    }
    /**
     * 根据指定条件获取补卡记录
     * @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()) ;
        }
    }
    /**
     * 根据指定条件获取收据列表
     * @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()) ;
        }
    }
}