中扬CRM客户关系管理系统
LSH
2023-09-11 8b434a01ef9e2e48d1300be7792caa91f653b08e
src/main/java/com/zy/crm/manager/controller/PriSalesController.java
@@ -12,12 +12,8 @@
import com.core.common.R;
import com.core.domain.KeyValueVo;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.entity.Item;
import com.zy.crm.manager.entity.PriOnline;
import com.zy.crm.manager.entity.PriSales;
import com.zy.crm.manager.service.ItemService;
import com.zy.crm.manager.service.PriOnlineService;
import com.zy.crm.manager.service.PriSalesService;
import com.zy.crm.manager.entity.*;
import com.zy.crm.manager.service.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,10 +33,13 @@
    private PriSalesService priSalesService;
    @Autowired
    private PriOnlineService priOnlineService;
    private PriOnline2Service priOnline2Service;
    @Autowired
    private ItemService itemService;
    private PlanService planService;
    @Autowired
    private PriQuoteBudgetService priQuoteBudgetService;
    @RequestMapping(value = "/priSales/{id}/auth")
    @ManagerAuth
@@ -97,17 +96,18 @@
    }
    @RequestMapping(value = "/priSales/add/auth")
    @ManagerAuth
    @ManagerAuth(memo = "添加产品费用明细")
    public R add(@RequestBody Map<String,Object> map) {
        PriOnline priOnline = priOnlineService.selectById(Long.parseLong(map.get("priOnlineId").toString()));
        PriOnline2 priOnline2 = priOnline2Service.selectById(Long.parseLong(map.get("priOnlineId").toString()));
        PriSales priSales = new PriSales();
        priSales.setCreateTime(new Date());
        priSales.setTitle(map.get("title").toString());
        priSales.setTemplateName(priOnline.getTemplateName());
        priSales.setTemplateName(priOnline2.getTemplateName());
        priSales.setSheetData(map.get("sheetData").toString());
        priSales.setItemId(priOnline.getItemId());
        priSales.setOrderNum(priOnline.getOrderNum());
        priSales.setPriOnline2Id(Long.parseLong(map.get("priOnlineId").toString()));
        priSales.setItemId(priOnline2.getItemId());
        priSales.setOrderNum(priOnline2.getOrderNum());
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        priSales.setInOrderNum(format.format(new Date()));
@@ -120,19 +120,19 @@
        priSales.setDeptId(getDeptId());
        //业务员
        Item item = itemService.selectById(priSales.getItemId());
        priSales.setMemberId(item.getMember());
        Plan plan = planService.selectById(priSales.getItemId());
        priSales.setMemberId(plan.getUserId());
        //设置项目流程
        item.setStep(3);
        itemService.updateById(item);
        plan.setStep(3);
        planService.updateById(plan);
        priSalesService.insert(priSales);
        return R.ok();
    }
    @RequestMapping(value = "/priSales/addOther/auth")
    @ManagerAuth
    @ManagerAuth(memo = "另存产品费用明细")
    public R addOther(@RequestBody Map<String,Object> map) {
        PriSales online = priSalesService.selectById(Long.parseLong(map.get("id").toString()));
@@ -155,15 +155,15 @@
        priSales.setUpdateTime(new Date());
        //业务员
        Item item = itemService.selectById(priSales.getItemId());
        priSales.setMemberId(item.getMember());
        Plan plan = planService.selectById(priSales.getItemId());
        priSales.setMemberId(plan.getUserId());
        priSalesService.insert(priSales);
        return R.ok();
    }
    @RequestMapping(value = "/priSales/update/auth")
    @ManagerAuth
    @ManagerAuth(memo = "更新产品费用明细")
    public R update(@RequestBody Map<String,Object> map){
        PriSales priSales = priSalesService.selectById(Long.parseLong(map.get("id").toString()));
        priSales.setTitle(map.get("title").toString());
@@ -177,7 +177,7 @@
    }
    @RequestMapping(value = "/priSales/updateForm/auth")
    @ManagerAuth
    @ManagerAuth(memo = "更新产品费用明细模板名和标题")
    public R updateForm(Long id,String templateName,String title){
        PriSales priSales = priSalesService.selectById(id);
        priSales.setTemplateName(templateName);
@@ -191,10 +191,16 @@
    }
    @RequestMapping(value = "/priSales/delete/auth")
    @ManagerAuth
    @ManagerAuth(memo = "删除产品费用明细")
    public R delete(Long[] ids){
        if (Cools.isEmpty(ids)){
            return R.error();
        }
        for (Long id : ids){
            int  priQuoteBudget= priQuoteBudgetService.selectCount(new EntityWrapper<PriQuoteBudget>().eq("pri_sales_id", id));
            if (priQuoteBudget!=0){
                return R.error("存在关联的报价预算单,禁止删除!!!");
            }
        }
        priSalesService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
@@ -222,7 +228,7 @@
        for (PriSales priSales : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", priSales.getId());
            map.put("value", priSales.getInOrderNum() + "/" + priSales.getItemId$() + "/" + priSales.getMemberId$());
            map.put("value", priSales.getInOrderNum() + "/" + priSales.getPlanId$() + "/" + priSales.getMemberId$()+"/" + priSales.getTemplateName());
            result.add(map);
        }
        return R.ok(result);