package com.zhiqiyun.open.router.apis;

import com.dliyun.oap.framework.annotation.ServiceMethod;
import com.dliyun.oap.framework.annotation.ServiceMethodBean;
import com.dliyun.oap.framework.response.OapResponse;
import com.zhiqiyun.open.core.models.statistics.ComplaintInfo;
import com.zhiqiyun.open.core.service.ComplaintInfoService;
import com.zhiqiyun.open.core.service.SequenceService;
import com.zhiqiyun.open.router.request.statistics.SaveComplaintInfoRequest;
import com.zhiqiyun.open.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@ServiceMethodBean
public class ComplaintApi {

	@Autowired
	private ComplaintInfoService complaintInfoService;

	@Autowired
	private SequenceService sequenceService;

	@ServiceMethod(method = "save.complaint.info", title = "保存客诉信息")
	public OapResponse saveComplaintInfo(SaveComplaintInfoRequest request) {

		Long id = this.sequenceService.nextId();

		ComplaintInfo entity = new ComplaintInfo();
		entity.setAuthId(request.getAuthId());
		entity.setMerchantId(request.getMerchantId());
		entity.setOrgId(request.getOrgId());
//		entity.setSupplierId();
		entity.setProductId(request.getProductId());
		entity.setBigType(request.getBigType());
		entity.setType(request.getType());
		entity.setLevel(request.getLevel());
		entity.setUid(request.getUid());
		entity.setPlaceIncident(request.getPlaceIncident());
		entity.setBeComplained(request.getBeComplained());
		entity.setBeComplainedIndustry(request.getBeComplainedIndustry());
		entity.setLocation(request.getLocation());
		entity.setSourceChannel(request.getSourceChannel());
		entity.setAcceptanceName(request.getAcceptanceName());
		entity.setAcceptanceNo(request.getAcceptanceNo());
		entity.setAcceptanceDepartment(request.getAcceptanceDepartment());
		entity.setAcceptanceTime(request.getAcceptanceTime());
		entity.setIsHandle(request.getIsHandle());
		entity.setContext(request.getContext());
		entity.setUrlImg(request.getUrlImg());
		entity.setUrlImg(request.getUrlImg());
		entity.setContact(request.getContact());
		entity.setContactPhone(request.getContactPhone());
		entity.setVideo(request.getVideo());
		entity.setRestoreContent(request.getRestoreContent());
		entity.setRestoreUid(request.getRestoreUid());
		entity.setRestoreName(request.getRestoreName());
		entity.setRestorePhone(request.getRestorePhone());
		entity.setRestorePic(request.getRestorePic());
		entity.setRestoreDate(request.getRestoreDate());
		entity.setComplaintDate(DateUtil.current());
//		entity.setCreator(request.getCreator());
		entity.setCreateDate(DateUtil.current());
		entity.setIsDeleted(0);

		entity.setId(id);

		this.complaintInfoService.save(entity);

		return OapResponse.success();
	}
}
