liurunyu
2024-10-12 708dce320caedf9973ff0282098fb70dafd6702e
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/clientCard/ClientCardCtrl.java
@@ -7,6 +7,10 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.voSe.VoCardInfo;
import com.dy.pipIrrGlobal.voSe.VoCards;
import com.dy.pipIrrGlobal.voSe.VoCards2;
import com.dy.pipIrrSell.clientCard.qo.QoCards;
import com.dy.pipIrrSell.clientCard.qo.QoCards2;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -16,12 +20,10 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * @author ZhuBaoMin
@@ -38,6 +40,11 @@
public class ClientCardCtrl {
    private final ClientCardSv clientCardSv;
    /**
     * 获取指定用户名下全部水卡(物理卡+虚拟卡)
     * @param clientId
     * @return
     */
    @Operation(summary = "获得全部水卡", description = "返回全部水卡数据")
    @ApiResponses(value = {
            @ApiResponse(
@@ -58,4 +65,131 @@
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 根据水卡编号获取操作记录及余额
     * @param cardNum 水卡编号
     * @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 = "/getoperaterecords")
    @SsoAop()
    public BaseResponse<List<Map<String, Object>>> getOperateRecordsAndMoney(@RequestParam("cardNum") Long cardNum){
        try {
            Map map = clientCardSv.getOperateRecordsAndMoney(cardNum);
            return BaseResponseUtils.buildSuccess(map);
        } catch (Exception e) {
            log.error("查询操作记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 根据水卡编号获取卡片状态
     * @param cardNum
     * @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 = "/cardstate")
    @SsoAop()
    public BaseResponse<String> getCardStateByCardNum(@RequestParam("cardNum") Long cardNum){
        try {
            String stateName = clientCardSv.getCardStateByCardNum(cardNum);
            return BaseResponseUtils.buildSuccess(stateName);
        } 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 = BaClient.class))}
            )
    })
    @GetMapping(path = "getcards")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoCards>>> getcards(QoCards vo){
        try {
            QueryResultVo<List<VoCards>> res = clientCardSv.getCards(vo);
            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 = BaClient.class))}
            )
    })
    @GetMapping(path = "getUnreplaced")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoCards>>> getUnreplaced(QoCards vo){
        try {
            QueryResultVo<List<VoCards>> res = clientCardSv.getUnreplaced(vo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询农户异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 根据农户姓名、电话查询正常状态的水卡列表
     * @param vo
     * @return
     */
    @GetMapping(path = "getCardsByClientNameAndPhone")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoCards2>>> getCardsByClientNameAndPhone(QoCards2 vo){
        try {
            QueryResultVo<List<VoCards2>> res = clientCardSv.getCardsByClientNameAndPhone(vo);
            return BaseResponseUtils.buildSuccess(res);
            //if(res.itemTotal != null && res.itemTotal > 0) {
            //    return BaseResponseUtils.buildSuccess(res);
            //}else {
            //    return BaseResponseUtils.buildFail(SellResultCode.THE_CARD_NOT_EXIST.getMessage());
            //}
        } catch (Exception e) {
            log.error("查询水卡异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}