Search in sources :

Example 6 with CustomerService

use of com.itrus.portal.db.CustomerService in project portal by ixinportal.

the class OnlineServiceController method createService.

/**
 * 创建(修改)天威默认客服
 *
 * @param phoneName1
 * @param phone1
 * @param downloadUrl1
 * @param messageContent1
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/createService", produces = "text/html")
public // 客服电话名称
String createService(// 客服电话名称
@RequestParam(value = "phoneName1", required = false) String phoneName1, // 客服电话号码
@RequestParam(value = "phone1", required = false) String phone1, // 企业QQ账号
@RequestParam(value = "downloadUrl1", required = false) String downloadUrl1, // 企业QQ链接
@RequestParam(value = "messageContent1", required = false) String messageContent1, Model uiModel) {
    // 查询默认客服的数据
    EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
    EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
    qqEx.andEnterpriseQqStateEqualTo(0L);
    EnterpriseQq enterpriseqq = onlineService.selectQq(enterpriseE);
    // 查询默认客服的数据
    CustomerServiceExample customerE = new CustomerServiceExample();
    CustomerServiceExample.Criteria serviceE = customerE.createCriteria();
    serviceE.andServiceStateEqualTo(0);
    CustomerService customerService = onlineService.selectService(customerE);
    if (enterpriseqq != null) {
        enterpriseqq.setEnterpriseQq(downloadUrl1);
        enterpriseqq.setEnterpriseQqLinks(messageContent1);
        enterpriseqq.setEnterpriseQqState(0L);
        enterpriseqq.setModifyTime(new Date());
        onlineService.updateenterprise(enterpriseqq);
        /*Project project = projectService.selectByPrimaryKey(enterpriseqq.getProjectId());
			LogUtil.adminlog(sqlSession, "修改天威默认客服", project.getName() + "修改的文件是:" + enterpriseqq.getEnterpriseQq());*/
        // 修改默认qq
        EnterpriseQqExample enterpriseEX = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqE = enterpriseEX.createCriteria();
        qqE.andQqStateEqualTo(0L);
        List<EnterpriseQq> enterpriseq = onlineService.selectQqList(enterpriseEX);
        if (enterpriseq.size() != 0) {
            for (EnterpriseQq e : enterpriseq) {
                e.setEnterpriseQq(downloadUrl1);
                e.setEnterpriseQqLinks(messageContent1);
                e.setModifyTime(new Date());
                onlineService.updateenterprise(e);
            }
        }
    } else {
        EnterpriseQq enterprise = new EnterpriseQq();
        enterprise.setEnterpriseQq(downloadUrl1);
        enterprise.setEnterpriseQqLinks(messageContent1);
        enterprise.setEnterpriseQqState(0L);
        enterprise.setCreateTime(new Date());
        onlineService.insertenterprise(enterprise);
        LogUtil.adminlog(sqlSession, "修改天威默认客服", "修改的文件是:" + messageContent1);
    }
    if (customerService != null) {
        customerService.setServicePhone(phone1);
        customerService.setPhoneName(phoneName1);
        customerService.setServiceState(0);
        customerService.setModifyTime(new Date());
        onlineService.updatecustomer(customerService);
        // 修改默认客服电话
        EnterpriseQqExample enterpriseEX = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqE = enterpriseEX.createCriteria();
        qqE.andCustermServiceStateEqualTo(0L);
        List<EnterpriseQq> enterpriseq = onlineService.selectQqList(enterpriseEX);
        if (enterpriseq.size() != 0) {
            for (EnterpriseQq e : enterpriseq) {
                CustomerServiceExample customerEX = new CustomerServiceExample();
                CustomerServiceExample.Criteria serviceEX = customerEX.createCriteria();
                int cid = Integer.parseInt(e.getId().toString());
                serviceEX.andEnterpriseIdEqualTo(cid);
                CustomerService customers = onlineService.selectService(customerEX);
                if (customers != null) {
                    customers.setServicePhone(phone1);
                    customers.setPhoneName(phoneName1);
                    customers.setCreateTime(new Date());
                    onlineService.updatecustomer(customers);
                }
            }
        }
    } else {
        CustomerService customer = new CustomerService();
        customer.setServicePhone(phone1);
        customer.setPhoneName(phoneName1);
        customer.setServiceState(0);
        customer.setCreateTime(new Date());
        onlineService.insertcustomer(customer);
        LogUtil.adminlog(sqlSession, "修改天威默认客服", "修改的文件是:" + phoneName1);
    }
    return "redirect:/onlineserviceconfig";
}
Also used : EnterpriseQq(com.itrus.portal.db.EnterpriseQq) CustomerService(com.itrus.portal.db.CustomerService) CustomerServiceExample(com.itrus.portal.db.CustomerServiceExample) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with CustomerService

use of com.itrus.portal.db.CustomerService in project portal by ixinportal.

the class OnlineServiceController method update.

/**
 * 修改处理
 *
 * @param id
 * @param customerJson
 * @param keys
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/update/{id}", produces = "text/html")
public String update(@PathVariable("id") Long id, @RequestParam(value = "jsonObj", required = false) String customerJson, @RequestParam(value = "keys", required = false) String keys, @RequestParam(value = "delKeys", required = false) String delKeys, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "entQq", required = false) String entQq, @RequestParam(value = "entQqLinks", required = false) String entQqLinks, @RequestParam(value = "isDefaultQq", required = false) String isDefaultQq, @RequestParam(value = "isDefaultPhone", required = false) String isDefaultPhone, Model uiModel) {
    // List<CustomerService> customer = (List<CustomerService>)
    // JSON.parseObject(customerJson, CustomerService.class);//Weibo类在下边定义
    String[] keyArr = keys.split(",");
    if (StringUtils.isNotEmpty(delKeys)) {
        String[] delKeyArr = delKeys.split(",");
        for (String d : delKeyArr) {
            if (!d.contains("new")) {
                List<CustomerService> customerServices = onlineService.selectlistcustomer(Long.parseLong(d));
                if (customerServices != null) {
                    customerServices.get(0);
                    onlineService.delete(Long.parseLong(d));
                }
            }
        }
    }
    EnterpriseQq enterprise = onlineService.selectEnterprise(id);
    if (StringUtils.isNotEmpty(isDefaultQq) && isDefaultQq.equals("1")) {
        EnterpriseQq enterpriseQqDefault = onlineService.selectByDefaultEnterpriseQq();
        enterprise.setEnterpriseQq(enterpriseQqDefault.getEnterpriseQq());
        enterprise.setEnterpriseQqLinks(enterpriseQqDefault.getEnterpriseQqLinks());
        enterprise.setQqState(0L);
    } else {
        enterprise.setEnterpriseQq(entQq);
        enterprise.setEnterpriseQqLinks(entQqLinks);
        enterprise.setQqState(1L);
    }
    enterprise.setEnterpriseQqState(1L);
    enterprise.setProjectId(projectId);
    enterprise.setModifier(getAdmin().getId());
    enterprise.setModifyTime(new Date());
    onlineService.updateenterprise(enterprise);
    // Map<Long, List<CustomerService>> listmain = new HashMap<Long,
    // List<CustomerService>>();
    CustomerServiceExample customerE = new CustomerServiceExample();
    CustomerServiceExample.Criteria serviceE = customerE.createCriteria();
    int cid = Integer.parseInt(enterprise.getId().toString());
    serviceE.andEnterpriseIdEqualTo(cid);
    List<CustomerService> listcustomer = onlineService.selectServiceList(customerE);
    if (StringUtils.isNotEmpty(isDefaultPhone) && isDefaultPhone.equals("1")) {
        for (CustomerService c : listcustomer) {
            onlineService.delete(c.getId());
        }
        CustomerService customerService = new CustomerService();
        CustomerService customerServiceDefault = onlineService.selectByDefaultCustomerService();
        customerService.setServicePhone(customerServiceDefault.getServicePhone());
        customerService.setPhoneName(customerServiceDefault.getPhoneName());
        customerService.setExplanatoryTime(customerServiceDefault.getExplanatoryTime());
        customerService.setServiceState(1);
        customerService.setCreator(getAdmin().getId());
        customerService.setCreateTime(new Date());
        customerService.setEnterpriseId(enterprise.getId());
        enterprise.setCustermServiceState(0L);
        onlineService.updateenterprise(enterprise);
        onlineService.insert(customerService);
    } else {
        enterprise.setCustermServiceState(1L);
        onlineService.updateenterprise(enterprise);
        JSONObject jsonObj = JSONObject.parseObject(customerJson);
        for (String s : keyArr) {
            JSONObject jsonc = jsonObj.getJSONObject(s);
            int i = 0;
            for (CustomerService c : listcustomer) {
                if (c.getId().toString().equals(s)) {
                    i++;
                    // 修改 c
                    c.setPhoneName(jsonc.getString("phoneName"));
                    c.setServicePhone(jsonc.getString("servicePhone"));
                    c.setExplanatoryTime(jsonc.getString("explanatoryTime"));
                    c.setModifyTime(new Date());
                    c.setModifier(getAdmin().getId());
                    c.setServiceState(1);
                    onlineService.updatecustomer(c);
                }
            }
            if (i == 0 && s.contains("new")) {
                // 增加
                CustomerService custom = new CustomerService();
                custom.setPhoneName(jsonc.getString("phoneName"));
                custom.setServicePhone(jsonc.getString("servicePhone"));
                custom.setExplanatoryTime(jsonc.getString("explanatoryTime"));
                custom.setCreateTime(new Date());
                custom.setServiceState(1);
                custom.setEnterpriseId(enterprise.getId());
                onlineService.insertcustomer(custom);
            }
            if (i == 0 && !s.contains("new")) {
                // 删除 c
                Long sid = Long.parseLong(s.toString());
                onlineService.delete(sid);
            }
        }
    }
    return "redirect:/onlineserviceconfig";
}
Also used : CustomerService(com.itrus.portal.db.CustomerService) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) CustomerServiceExample(com.itrus.portal.db.CustomerServiceExample) JSONObject(com.alibaba.fastjson.JSONObject) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with CustomerService

use of com.itrus.portal.db.CustomerService in project portal by ixinportal.

the class OnlineServiceController method create.

/**
 * 创建客服配置
 *
 * @param phoneconfig
 * @param projectId
 * @param enterpriseQq
 * @param enterpriseQqLinks
 * @param isDefaultQq
 * @param isDefaultPhone
 * @param uiModel
 * @return
 * @throws Exception
 */
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@RequestParam(value = "phoneconfig", required = false) String phoneconfig, @RequestParam(value = "projectId", required = false) Long projectId, @RequestParam(value = "entQq", required = false) String entQq, @RequestParam(value = "entQqLinks", required = false) String entQqLinks, @RequestParam(value = "isDefaultQq", required = false) String isDefaultQq, @RequestParam(value = "isDefaultPhone", required = false) String isDefaultPhone, Model uiModel) throws Exception {
    EnterpriseQq enterpriseQq = new EnterpriseQq();
    CustomerService customerService = new CustomerService();
    // 判断是否默认客服qq
    if (StringUtils.isNotEmpty(isDefaultQq) && isDefaultQq.equals("1")) {
        EnterpriseQq enterpriseQqDefault = onlineService.selectByDefaultEnterpriseQq();
        enterpriseQq.setEnterpriseQq(enterpriseQqDefault.getEnterpriseQq());
        enterpriseQq.setEnterpriseQqLinks(enterpriseQqDefault.getEnterpriseQqLinks());
        enterpriseQq.setQqState(0L);
    } else {
        enterpriseQq.setEnterpriseQq(entQq);
        enterpriseQq.setEnterpriseQqLinks(entQqLinks);
        enterpriseQq.setQqState(1L);
    }
    enterpriseQq.setEnterpriseQqState(1L);
    enterpriseQq.setProjectId(projectId);
    enterpriseQq.setCreator(getAdmin().getId());
    enterpriseQq.setCreateTime(new Date());
    onlineService.insert(enterpriseQq);
    // 判断是否默认客服电话
    if (StringUtils.isNotEmpty(isDefaultPhone) && isDefaultPhone.equals("1")) {
        CustomerService customerServiceDefault = onlineService.selectByDefaultCustomerService();
        customerService.setServicePhone(customerServiceDefault.getServicePhone());
        customerService.setPhoneName(customerServiceDefault.getPhoneName());
        customerService.setExplanatoryTime(customerServiceDefault.getExplanatoryTime());
        customerService.setServiceState(1);
        customerService.setCreator(getAdmin().getId());
        customerService.setCreateTime(new Date());
        customerService.setEnterpriseId(enterpriseQq.getId());
        enterpriseQq.setCustermServiceState(0L);
        onlineService.updateenterprise(enterpriseQq);
        onlineService.insert(customerService);
    } else {
        enterpriseQq.setCustermServiceState(1L);
        onlineService.updateenterprise(enterpriseQq);
        JSONArray jsonArr = JSONArray.parseArray(phoneconfig);
        for (int i = 0; i < jsonArr.size(); i++) {
            customerService = new CustomerService();
            JSONObject jsonObject = (JSONObject) jsonArr.get(i);
            customerService.setServicePhone(jsonObject.getString("phone"));
            customerService.setPhoneName(jsonObject.getString("phoneName"));
            customerService.setExplanatoryTime(jsonObject.getString("explain"));
            customerService.setServiceState(1);
            customerService.setCreator(getAdmin().getId());
            customerService.setCreateTime(new Date());
            customerService.setEnterpriseId(enterpriseQq.getId());
            onlineService.insert(customerService);
        }
    }
    return "redirect:/onlineserviceconfig";
}
Also used : EnterpriseQq(com.itrus.portal.db.EnterpriseQq) CustomerService(com.itrus.portal.db.CustomerService) JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with CustomerService

use of com.itrus.portal.db.CustomerService in project portal by ixinportal.

the class OnlineServiceImpl method selectByDefaultCustomerService.

/**
 * 得到默认企业qq
 * @return
 */
public CustomerService selectByDefaultCustomerService() {
    CustomerServiceExample customerServiceExample = new CustomerServiceExample();
    CustomerServiceExample.Criteria sec = customerServiceExample.createCriteria();
    sec.andServiceStateEqualTo(0);
    List<CustomerService> customerServices = selectCustomerServiceList(customerServiceExample);
    if (customerServices.isEmpty()) {
        return null;
    }
    return customerServices.get(0);
}
Also used : CustomerService(com.itrus.portal.db.CustomerService) CustomerServiceExample(com.itrus.portal.db.CustomerServiceExample)

Aggregations

CustomerService (com.itrus.portal.db.CustomerService)9 CustomerServiceExample (com.itrus.portal.db.CustomerServiceExample)8 EnterpriseQq (com.itrus.portal.db.EnterpriseQq)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 JSONObject (com.alibaba.fastjson.JSONObject)4 EnterpriseQqExample (com.itrus.portal.db.EnterpriseQqExample)4 Project (com.itrus.portal.db.Project)4 ProjectExample (com.itrus.portal.db.ProjectExample)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Map (java.util.Map)2 JSONArray (com.alibaba.fastjson.JSONArray)1 Calendar (java.util.Calendar)1 List (java.util.List)1 HttpSession (javax.servlet.http.HttpSession)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1