|  |  |  | 
|---|
|  |  |  | 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.Plan; | 
|---|
|  |  |  | 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.PlanService; | 
|---|
|  |  |  | import com.zy.crm.manager.service.PriOnlineService; | 
|---|
|  |  |  | import com.zy.crm.manager.service.PriSalesService; | 
|---|
|  |  |  | import org.apache.poi.xssf.usermodel.XSSFSheet; | 
|---|
|  |  |  | 
|---|
|  |  |  | private PriOnlineService priOnlineService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ItemService itemService; | 
|---|
|  |  |  | private PlanService planService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priSales/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/priSales/delete/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | @ManagerAuth(memo = "删除产品费用明细") | 
|---|
|  |  |  | public R delete(Long[] ids){ | 
|---|
|  |  |  | if (Cools.isEmpty(ids)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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$()); | 
|---|
|  |  |  | result.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(result); | 
|---|