Administrator
2024-01-31 ab37d7d33e2484ee97a602f348ab475101389149
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wallet/WalletCtrl.java
@@ -3,14 +3,21 @@
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.pojoSe.SeConsume;
import com.dy.pipIrrGlobal.pojoSe.SeRefund;
import com.dy.pipIrrGlobal.pojoSe.SeWallet;
import com.dy.pipIrrGlobal.pojoSe.SeWalletRecharge;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
import com.dy.pipIrrGlobal.voSe.VoWallet;
import com.dy.pipIrrGlobal.voSe.VoWalletRecharge;
import com.dy.pipIrrGlobal.voSe.VoWalletRefund;
import com.dy.pipIrrSell.result.SellResultCode;
import com.dy.pipIrrSell.wallet.enums.LastOperateENUM;
import com.dy.pipIrrSell.wallet.enums.RefundStatusENUM;
import com.dy.pipIrrSell.wallet.qo.QoWalletRecharge;
import com.dy.pipIrrSell.wallet.qo.QueryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -28,8 +35,7 @@
import org.springframework.web.bind.annotation.*;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.Optional;
import java.util.*;
/**
 * @author ZhuBaoMin
@@ -326,4 +332,119 @@
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
    /**
     * 根据农户姓名获取电子钱包账户记录
     * @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_wallets")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoWallet>>> getWallets(QueryVo vo){
        try {
            QueryResultVo<List<VoWallet>> res = walletSv.getWallets(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_recharges")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoWalletRecharge>>> getWalletRecharges(QoWalletRecharge vo){
        try {
            QueryResultVo<List<VoWalletRecharge>> res = walletSv.getWalletRecharges(vo);
            if(res.itemTotal == 0) {
                return BaseResponseUtils.buildFail(SellResultCode.No_WALLER_RECHARGES.getMessage());
            }
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("获取电子钱包充值记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    @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_consume")
    @SsoAop()
    public BaseResponse<Map> getWalletConsumes(QueryVo vo){
        Long clientId = Optional.ofNullable(vo.getClientId()).orElse(0L);
        if(clientId == 0) {
            return BaseResponseUtils.buildFail(SellResultCode.WALLET_CLIENT_ID_CANNOT_BE_NULL.getMessage());
        }
        try {
            Map res = Optional.ofNullable(walletSv.getWalletConsumes(vo)).orElse(new HashMap());
            if(res.size() <= 0) {
                return BaseResponseUtils.buildFail(SellResultCode.No_WALLER_RECHARGES.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_refunds")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoWalletRefund>>> getWalletRefunds(QueryVo vo){
        try {
            QueryResultVo<List<VoWalletRefund>> res = walletSv.getWalletRefunds(vo);
            if(res.itemTotal == 0) {
                return BaseResponseUtils.buildFail(SellResultCode.No_REFUNDS.getMessage());
            }
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("获取电子钱包退款记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}