package com.sifang.modules.customer.controller;

import com.sifang.modules.customer.Service.YueXiuProjectOperatingService;
import com.sifang.modules.customer.dao.CustomerEntryDao;
import com.sifang.modules.customer.entity.CustomerEntry;
import com.sifang.modules.sunshine.SystemSetting.utils.Result;
import com.sifang.modules.sys.web.BaseExceptionController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "${adminPath}/incomingManagement")
public class YueXiuProjectOperatingController extends BaseExceptionController {

   @Autowired
   private YueXiuProjectOperatingService yueXiuProjectOperatingService;

    @Autowired
    CustomerEntryDao customerDao;
    /**
     * 进件重新推送
     */
    @ResponseBody
    @RequestMapping(value = "againPushIncoming")
    public Result againPushIncoming(String entryId,String type){
        CustomerEntry entry = customerDao.get(entryId);
        yueXiuProjectOperatingService.againPushIncoming(entry,type);
        return Result.ok();
    }

    /**
     * 取消第一次进件
     */
    @ResponseBody
    @RequestMapping(value = "cancelProjectApply")
    public Result cancelProjectApply(String entryId,String cancelReason){
        yueXiuProjectOperatingService.cancelProjectApply(entryId,cancelReason);
        return Result.ok();
    }

    /**
     * 重新进件
     */
    @ResponseBody
    @RequestMapping(value = "againIncoming")
    public Result againIncoming(String entryId){
        yueXiuProjectOperatingService.againIncoming(entryId);
        return Result.ok();
    }

    /**
     * 退回进件
     */
    @ResponseBody
    @RequestMapping(value = "returnIncomingApplication")
    public Result returnIncomingApplication(String entryId,String prjCancelReason){
        CustomerEntry entry = customerDao.get(entryId);
        yueXiuProjectOperatingService.returnIncomingApplication(entry,prjCancelReason);
        return Result.ok();
    }

    /**
     * 进件状态 退回完工
     */
    @ResponseBody
    @RequestMapping(value = "returnIncomingToCompletion")
    public Result returnIncomingToCompletion(String entryId,String prjCancelReason){
        yueXiuProjectOperatingService.returnIncomingToCompletion(entryId,prjCancelReason);
        return Result.ok();
    }
}
