package com.hzs.member.detail.provider;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.domain.R;
import com.hzs.common.domain.member.detail.CuMemberServiceLog;
import com.hzs.common.domain.member.detail.CuMemberServiceLogExt;
import com.hzs.member.detail.ICuMemberServiceLogServiceApi;
import com.hzs.member.detail.service.ICuMemberServiceLogService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Description:
 * @Author: sui q
 * @Time: 2023/3/13 19:04
 * @Classname: CuMemberServiceLogProvider
 * @PackageName: com.hzs.member.detail.provider
 */
@DubboService
public class CuMemberServiceLogProvider implements ICuMemberServiceLogServiceApi {

    private ICuMemberServiceLogService cuMemberServiceLogService;

    @Autowired
    public void setCuMemberServiceLogService(ICuMemberServiceLogService cuMemberServiceLogService) {
        this.cuMemberServiceLogService = cuMemberServiceLogService;
    }

    @Override
    public List<CuMemberServiceLog> queryMaxCuMemberServiceLog(Long pkMember, List<Integer> editTypeList) {
        return cuMemberServiceLogService.queryMaxCuMemberServiceLog(pkMember, editTypeList);
    }

    /**
     * 查询最大审核次数
     *
     * @param pkMember
     * @param editType
     * @return
     */
    @Override
    public Integer selectByMaxApproveNumber(Long pkMember, Integer editType, Integer approveStatus) {
        return cuMemberServiceLogService.selectByMaxApproveNumber(pkMember, editType, approveStatus);
    }

    /**
     * 新增
     *
     * @param memberLog
     * @return
     */
    @Override
    public R<Boolean> insert(CuMemberServiceLog memberLog) {
        return R.ok(cuMemberServiceLogService.save(memberLog));
    }

    /**
     * 根据业务单号查询
     *
     * @return
     */
    @Override
    public R<CuMemberServiceLog> selectByBusinessNo(String businessNo) {
        return cuMemberServiceLogService.selectByBusinessNo(businessNo);
    }

    /**
     * 根据业务单号修改信息
     *
     * @param memberLog
     * @return
     */
    @Override
    public R<Boolean> updateByBusinessNo(CuMemberServiceLog memberLog) {
        return cuMemberServiceLogService.updateByBusinessNo(memberLog);
    }

    /**
     * @description: 根据业务单号查询业务日志
     * @author: zhang jing
     * @date: 2023/7/29 11:16
     * @param: [businessNo]
     * @return: com.hzs.common.core.domain.R<java.util.List < com.hzs.common.domain.member.detail.CuMemberServiceLog>>
     **/
    @Override
    public R<List<CuMemberServiceLog>> selectCuMemberServiceLog(String businessNo) {
        return cuMemberServiceLogService.selectCuMemberServiceLog(businessNo);
    }

    @Override
    public R<CuMemberServiceLogExt> queryPolicy(Long pkMember) {
        return R.ok(cuMemberServiceLogService.queryPolicy(pkMember));
    }

    /**
     * @param pkMember         会员主键 pkMember
     * @param approvalBusiness 类型 EApprovalBusiness
     * @param approveStatus    提交签呈状态 EApproveStatus
     * @return
     */
    @Override
    public R<Integer> queryCount(Long pkMember, Integer approvalBusiness, Integer approveStatus) {
        QueryWrapper<CuMemberServiceLog> query = new QueryWrapper<>();
        query.eq("APPROVE_STATUS", approveStatus);
        query.eq("EDIT_TYPE", approvalBusiness);
        query.eq("PK_MEMBER", pkMember);
        return R.ok(cuMemberServiceLogService.count(query));
    }

    @Override
    public R<CuMemberServiceLog> selectTopData(Long pkMember, int editType, int approveStatus) {
        return R.ok(cuMemberServiceLogService.selectTopData(pkMember, editType, approveStatus));
    }

}
