package com.hzs.member.address.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.EApprovalBusiness;
import com.hzs.common.domain.member.address.CuMemberGift;
import com.hzs.common.domain.member.address.CuMemberGiftRecord;
import com.hzs.member.account.vo.ApprovalDetailVO;
import com.hzs.member.address.mapper.CuMemberGiftMapper;
import com.hzs.member.address.service.ICuMemberGiftRecordService;
import com.hzs.member.address.service.ICuMemberGiftService;
import com.hzs.member.address.vo.CuMemberGiftVO;
import com.hzs.member.param.CuMemberGiftParam;
import com.hzs.system.sys.IApprovalServiceApi;
import com.hzs.system.sys.dto.ApprovalQueryDTO;
import com.hzs.system.sys.dto.ApprovalQueryDetailDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 会员礼包收货地址 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2022-08-22
 */
@Service
public class CuMemberGiftServiceImpl extends ServiceImpl<CuMemberGiftMapper, CuMemberGift> implements ICuMemberGiftService {

    @DubboReference
    IApprovalServiceApi approvalServiceApi;
    ICuMemberGiftRecordService cuMemberGiftRecordService;
    /**
     * @description: 查询会员礼包收货地址列表
     * @author: zhang jing
     * @date: 2022/10/20 14:25
     * @param: [memberGiftParam]
     * @return: java.util.List<com.hzs.member.param.CuMemberGiftParam>
     **/
    @Override
    public List<CuMemberGiftParam> selectCuMemberGiftList(CuMemberGiftParam memberGiftParam) {
        return baseMapper.selectCuMemberGiftList(memberGiftParam);
    }

    /**
     * @description: 查询会员礼包收货地址修改审批详情
     * @author: zhang jing
     * @date: 2022/10/22 14:07
     * @param: [pkId]
     * @return: java.util.List<com.hzs.member.address.vo.CuMemberGiftVO>
     **/
    @Override
    public CuMemberGiftVO  approvalDetail(Long pkId) {
/*        CuMemberGiftVO memberGiftVO=new CuMemberGiftVO();
        QueryWrapper<CuMemberGiftRecord> queryWrapper=new QueryWrapper();
        queryWrapper.eq("PK_CU_MEMBER_GIFT",pkId);
        CuMemberGiftRecord memberGiftRecord=cuMemberGiftRecordService.getOne(queryWrapper);
        //调用审批流
//        R<ApprovalQueryDTO> approvalQueryResult = approvalServiceApi.approvalDetail(EApprovalBusiness.CU_MEMBER_GIFT,null,null);
        R<ApprovalQueryDTO> approvalQueryResult=null;
        List<ApprovalDetailVO> approvalDetailVOS = new ArrayList<>();
        if (approvalQueryResult.isSuccess()) {
            //转换审批详情
            List<ApprovalQueryDetailDTO> approvalQueryDetailDTOS = approvalQueryResult.getData().getDetailList();
            approvalQueryDetailDTOS.forEach(item -> approvalDetailVOS.add(BeanUtil.copyProperties(item, ApprovalDetailVO.class)));
        }
        memberGiftVO.setDetailList(approvalDetailVOS);
        return memberGiftVO;*/
        return null;
    }
}
