package com.gic.haoban.manage.web.controller.potential;

import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.manage.api.dto.contact.ContactOrderDetailDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactOrderSearchQDTO;
import com.gic.haoban.manage.api.service.contact.ContactOrderApiService;
import com.gic.haoban.manage.web.qo.contact.ContactOrderPageQO;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 潜客雷达-数据
 */
@RestController
@RequestMapping()
public class PotentialDataController {

    @Autowired
    private ContactOrderApiService contactOrderApiService;
    /**
     * 分页查询转化记录
     * @param contactOrderPageQO
     * @return
     */
    @RequestMapping(path = "/contact/page-order")
    public RestResponse<Page<ContactOrderDetailDTO>> pageOrder(@RequestBody ContactOrderPageQO contactOrderPageQO) {
        String enterpriseId = contactOrderPageQO.getEnterpriseId();
        String clerkId = contactOrderPageQO.getClerkId();
        String storeId = contactOrderPageQO.getStoreId();
        ContactOrderSearchQDTO searchQDTO = new ContactOrderSearchQDTO();
        searchQDTO.setStoreIdList(Lists.newArrayList(storeId));
        searchQDTO.setClerkId(clerkId);
        searchQDTO.setBeginTime(contactOrderPageQO.getBeginTime());
        searchQDTO.setEndTime(contactOrderPageQO.getEndTime());
        BasePageInfo basePageInfo = contactOrderPageQO.getBasePageInfo();
        ServiceResponse<Page<ContactOrderDetailDTO>> serviceResponse = contactOrderApiService.pageContactOrder(enterpriseId,searchQDTO,basePageInfo);
        if (!serviceResponse.isSuccess()) {
            return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
        }
        return RestResponse.successResult(serviceResponse.getResult());
    }

}
