| | |
| | | import com.core.common.R; |
| | | import com.core.domain.KeyValueVo; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.crm.common.entity.PhoneCodeTypeParam; |
| | | import com.zy.crm.common.model.SettleDto; |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.*; |
| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private PriOnline2FollService priOnline2FollService; |
| | | |
| | | @Autowired |
| | | private SmsCodeService smsCodeService; |
| | | |
| | | String PZH = " ———————————————————————————————————————————————————————————————————————————————— "; |
| | | |
| | | @RequestMapping(value = "/priOnline2/{id}/auth") |
| | |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam(required = false) String allSwitch, |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam Map<String, Object> param) { |
| | | @RequestParam Map<String, Object> paramSou) { |
| | | EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>(); |
| | | wrapper.setSqlSelect("id,title,create_time as createTime,assistant_plan_id as assistantPlanId,host_plan_id as hostPlanId,assistant_host_sign as assistantHostSign,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); |
| | | // wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); |
| | | excludeTrash(param); |
| | | excludeTrash(paramSou); |
| | | Map<String, Object> param = convertallSwitch(paramSou); |
| | | |
| | | if (!Cools.isEmpty(allSwitch)){ |
| | | List<PriOnline2> priOnline2List = priOnline2Service.listByAll(getUserId()); |
| | | Page<PriOnline2> page1 = new Page<PriOnline2>(curr, limit).setRecords(priOnline2List); |
| | | page1.setTotal(priOnline2Service.listByAllTotal(getUserId())); |
| | | return R.ok(page1); |
| | | } |
| | | |
| | | convert(param, wrapper); |
| | | allLike(PriOnline2.class, param.keySet(), wrapper, condition); |
| | | wrapper.or().eq("member_id", getUserId()); |
| | |
| | | return R.ok(priOnline2Service.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private Map<String, Object> convertallSwitch(Map<String, Object> map) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | if (entry.getKey().equals("allSwitch")) { |
| | | map.remove("allSwitch"); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | boolean signUserId = false; |
| | | boolean signDeptId = false; |
| | |
| | | User userUp = userService.selectById(plan.getUserId()); |
| | | priOnline2.setAssistantHostSign(plan.getAssistantHostSign()); |
| | | priOnline2.setAssistantPlanId(plan.getAssistantPlanId()); |
| | | priOnline2.setHostPlanId(plan.getHostPlanId()); |
| | | priOnline2.setHostPlanId(plan.getId()); |
| | | if (plan.getAssistantHostSign()==1){ |
| | | priOnline2.setHostPlanId(plan.getHostPlanId()); |
| | | } |
| | | |
| | | |
| | | //业务员 |
| | |
| | | priOnline2.setMemberId(getUserId()); |
| | | |
| | | Cstmr cstmr = cstmrService.selectById(plan.getCstmrId()); |
| | | priOnline2.setTemplateName(cstmr.getName()); //甲方单位名称 |
| | | priOnline2.setTemplateName(cstmr.getName()); //客户信息名称 |
| | | |
| | | priOnline2.setSettle(0); |
| | | |
| | |
| | | planService.updateById(plan); |
| | | |
| | | priOnline2Service.insert(priOnline2); |
| | | |
| | | // 自动添加跟进人 |
| | | for (User user:users){ |
| | | List<PriOnline2Foll> priOnline2Folls = priOnline2FollService.selectList(new EntityWrapper<PriOnline2Foll>().eq("pri_online2_id", priOnline2.getId()).eq("user_id", user.getId())); |
| | | if (Cools.isEmpty(priOnline2Folls) || priOnline2Folls.size()==0){ |
| | | PriOnline2Foll priOnline2Foll = new PriOnline2Foll(); |
| | | priOnline2Foll.setPriOnline2Id(priOnline2.getId()); |
| | | priOnline2Foll.setUserId(user.getId()); |
| | | if (!priOnline2FollService.insert(priOnline2Foll)) { |
| | | throw new CoolException("保存失败,请重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (plan.getAssistantHostSign()==1){ |
| | |
| | | |
| | | if (user.getId().equals(priOnline2.getUserId())) { |
| | | if (priOnline2.getAssistantHostSign()==0){ |
| | | User manager = new User(); |
| | | try { |
| | | manager = userService.getDeptManager(getHostId(), getUser().getDeptId()); // 获取部门领导 |
| | | } catch (Exception e) { |
| | | manager = getUser(); |
| | | } |
| | | try { |
| | | priQuoteAdd(priOnline2.getId(), plannerId); |
| | | } catch (Exception e) { |
| | | return R.error("自动生成报价单失败"); |
| | | } |
| | | if (!smsCodeService.sendSmsCodeText(manager.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E)) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | }else { |
| | | try { |
| | |
| | | return R.error("更新主表失败"); |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | User phoneUser = userService.selectById(nextUserId); |
| | | if (!smsCodeService.sendSmsCodeText(phoneUser.getMobile(), PhoneCodeTypeParam.ALIYUN_M1ABAC630E)) { |
| | | return R.ok("审批成功但短信发送失败!"); |
| | | } |
| | | } |
| | | |
| | | return R.ok("审批成功"); |
| | |
| | | @ManagerAuth |
| | | public R priOnline2priQuoteAdd(@RequestParam Long planId) { |
| | | List<KeyValueVo> vos = new ArrayList<>(); |
| | | vos.add(new KeyValueVo("报价模板1", 1L)); |
| | | vos.add(new KeyValueVo("报价模板2", 2L)); |
| | | vos.add(new KeyValueVo("货架模板", 1L)); |
| | | vos.add(new KeyValueVo("集成模板", 2L)); |
| | | return R.ok().add(vos); |
| | | } |
| | | |