|
@@ -0,0 +1,372 @@
|
|
|
+package org.jeecg.modules.mili.customer.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.druid.util.StringUtils;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.modules.mili.customer.entity.CustomerAudition;
|
|
|
+import org.jeecg.modules.mili.customer.entity.CustomerInfo;
|
|
|
+import org.jeecg.modules.mili.customer.entity.CustomerVisiting;
|
|
|
+import org.jeecg.modules.mili.customer.service.ICustomerFollowService;
|
|
|
+import org.jeecg.modules.mili.customer.service.ICustomerInfoService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @Description: 名单管理
|
|
|
+* @Author: jeecg-boot
|
|
|
+* @Date: 2022-06-27
|
|
|
+* @Version: V1.0
|
|
|
+*/
|
|
|
+@Api(tags="公池管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/customer/customerInfo")
|
|
|
+@Slf4j
|
|
|
+public class CustomerInfoController extends JeecgController<CustomerInfo, ICustomerInfoService> {
|
|
|
+ @Autowired
|
|
|
+ private ICustomerInfoService customerInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICustomerFollowService customerFollowService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param customerInfo
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "名单管理-分页列表查询")
|
|
|
+ @ApiOperation(value="名单管理-分页列表查询", notes="名单管理-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<IPage<CustomerInfo>> queryPageList(CustomerInfo customerInfo,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<CustomerInfo> queryWrapper = QueryGenerator.initQueryWrapper(customerInfo, req.getParameterMap());
|
|
|
+ //关键字查询
|
|
|
+ if(req.getParameterMap().get("keywords") !=null) {
|
|
|
+ String keywords = req.getParameterMap().get("keywords")[0];
|
|
|
+ queryWrapper.apply(" (name like '%"+keywords+"%' or " +
|
|
|
+ "nickname like '%"+keywords+"%' or " +
|
|
|
+ "contact_phone like'%"+keywords+"%' or " +
|
|
|
+ "mark like'%"+keywords+"%' or " +
|
|
|
+ "contact_name like'%"+keywords+"%' )");
|
|
|
+ }
|
|
|
+ // 判断日期段
|
|
|
+ if(req.getParameterMap().get("beginTime") !=null) {
|
|
|
+ String beginDate = req.getParameterMap().get("beginTime")[0];
|
|
|
+ String finishDate = req.getParameterMap().get("endTime")[0];
|
|
|
+ if (!StringUtils.isEmpty(beginDate) || StringUtils.isEmpty(finishDate)) {
|
|
|
+ DateTime beginOfDay = DateUtil.beginOfDay(DateUtil.parse(beginDate));
|
|
|
+ DateTime endOfDay = DateUtil.endOfDay(DateUtil.parse(finishDate));
|
|
|
+ queryWrapper.ge("create_time", beginOfDay).le("create_time", endOfDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //tabs查询
|
|
|
+ if(req.getParameterMap().get("tabs") !=null) {
|
|
|
+ String saleCode = req.getParameterMap().get("saleCode")[0];
|
|
|
+ queryWrapper.eq("sale_code",saleCode);
|
|
|
+ }
|
|
|
+ //groups查询
|
|
|
+ if(req.getParameterMap().get("groups") !=null) {
|
|
|
+ String group = req.getParameterMap().get("groups")[0];
|
|
|
+ if(group.equals("2")) {
|
|
|
+ queryWrapper.eq("follow_status",0);
|
|
|
+ }else if(group.equals("3")) {
|
|
|
+ //date_format(now(), '%Y-%m-%d') = date_format(next_follow_time, '%Y-%m-%d')
|
|
|
+ queryWrapper.apply("date_format(now(), '%Y-%m-%d') = date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+ }else if(group.equals("4")) {
|
|
|
+ // date_format(now(), '%Y-%m-%d') > date_format(next_follow_time, '%Y-%m-%d')
|
|
|
+ queryWrapper.apply("date_format(now(), '%Y-%m-%d') > date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //年龄查询 ageMin
|
|
|
+ if(req.getParameterMap().get("ageMin") !=null) {
|
|
|
+ String ageMin = req.getParameterMap().get("ageMin")[0];
|
|
|
+ String ageMax = req.getParameterMap().get("ageMax")[0];
|
|
|
+ queryWrapper.between("YEAR(now())-YEAR(birthday)",ageMin,ageMax);
|
|
|
+ }
|
|
|
+ //不显示失效
|
|
|
+ if(req.getParameterMap().get("noInvalid") !=null) {
|
|
|
+ queryWrapper.ne("follow_status",0);
|
|
|
+ }
|
|
|
+ Page<CustomerInfo> page = new Page<CustomerInfo>(pageNo, pageSize);
|
|
|
+ IPage<CustomerInfo> pageList = customerInfoService.page(page, queryWrapper);
|
|
|
+ // 不是特别优雅
|
|
|
+ for(int i=0 ; i< pageList.getRecords().size(); i++) {
|
|
|
+ String log = customerFollowService.getFollowLimit(pageList.getRecords().get(i).getId());
|
|
|
+ pageList.getRecords().get(i).setFollow_log(log);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param customerInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "名单管理-添加")
|
|
|
+ @ApiOperation(value="名单管理-添加", notes="名单管理-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<String> add(@RequestBody CustomerInfo customerInfo) {
|
|
|
+ customerInfoService.save(customerInfo);
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param customerInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "名单管理-编辑")
|
|
|
+ @ApiOperation(value="名单管理-编辑", notes="名单管理-编辑")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<String> edit(@RequestBody CustomerInfo customerInfo) {
|
|
|
+ customerInfoService.updateById(customerInfo);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "名单管理-通过id删除")
|
|
|
+ @ApiOperation(value="名单管理-通过id删除", notes="名单管理-通过id删除")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ customerInfoService.removeById(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "名单管理-批量删除")
|
|
|
+ @ApiOperation(value="名单管理-批量删除", notes="名单管理-批量删除")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ this.customerInfoService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "名单管理-通过id查询")
|
|
|
+ @ApiOperation(value="名单管理-通过id查询", notes="名单管理-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<CustomerInfo> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ CustomerInfo customerInfo = customerInfoService.getById(id);
|
|
|
+ if(customerInfo==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ return Result.OK(customerInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param customerInfo
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, CustomerInfo customerInfo) {
|
|
|
+ return super.exportXls(request, customerInfo, CustomerInfo.class, "名单管理");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ return super.importExcel(request, response, CustomerInfo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 顾问分配
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @AutoLog(value = "名单管理-顾问分配")
|
|
|
+ @ApiOperation(value="名单管理-顾问分配", notes="名单管理-顾问分配")
|
|
|
+ @RequestMapping(value = "/appoint")
|
|
|
+ public Result<String> appoint(@RequestBody String jsonParam) {
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonParam);
|
|
|
+ CustomerInfo customerInfo = JSON.parseObject(String.valueOf(jsonObject.get("customerInfo")),CustomerInfo.class);
|
|
|
+ JSONObject appointInfo = (JSONObject) jsonObject.get("appointInfo");
|
|
|
+ String saleName = String.valueOf(appointInfo.get("saleName"));
|
|
|
+ String schoolName = String.valueOf(appointInfo.get("schoolName"));
|
|
|
+ customerInfoService.appoint(customerInfo,saleName,schoolName);
|
|
|
+ return Result.OK("分配成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签约
|
|
|
+ *
|
|
|
+ * @param customerInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "潜客管理-签约")
|
|
|
+ @ApiOperation(value="潜客管理-签约", notes="潜客管理-签约")
|
|
|
+ @RequestMapping(value = "/sign", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<String> sign(@RequestBody CustomerInfo customerInfo ) {
|
|
|
+ customerInfoService.sign(customerInfo);
|
|
|
+ return Result.OK("报名成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 潜客管理-状态编辑
|
|
|
+ *
|
|
|
+ * @param customerInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "潜客管理-状态编辑")
|
|
|
+ @ApiOperation(value="潜客管理-状态编辑", notes="潜客管理-状态编辑")
|
|
|
+ @RequestMapping(value = "/statusEdit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<String> statusEdit(@RequestBody CustomerInfo customerInfo) {
|
|
|
+ customerInfoService.statusEdit(customerInfo);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 潜客管理-预约来访
|
|
|
+ *
|
|
|
+ * @param customerVisiting
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "潜客管理-预约来访")
|
|
|
+ @ApiOperation(value="潜客管理-预约来访", notes="潜客管理-预约来访")
|
|
|
+ @PostMapping(value = "/addVisit")
|
|
|
+ public Result<String> addVisit(@RequestBody CustomerVisiting customerVisiting) {
|
|
|
+ Result<String> customerPotential = customerInfoService.addVisit(customerVisiting);
|
|
|
+ return customerPotential;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 潜客管理-预约试听
|
|
|
+ *
|
|
|
+ * @param customerAudition
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "潜客管理-预约试听")
|
|
|
+ @ApiOperation(value="潜客管理-预约试听", notes="潜客管理-预约试听")
|
|
|
+ @PostMapping(value = "/addAudition")
|
|
|
+ public Result<String> addAudition(@RequestBody CustomerAudition customerAudition) {
|
|
|
+ Result<String> customerPotential = customerInfoService.addAudition(customerAudition);
|
|
|
+ return customerPotential;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 潜客管理分组数据
|
|
|
+ *
|
|
|
+ * @param json
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "潜客管理-分组数据")
|
|
|
+ @ApiOperation(value="潜客管理-分组数据", notes="潜客管理-分组数据")
|
|
|
+ @PostMapping(value = "/getGroupCounts")
|
|
|
+ public Result<JSONObject> getGroupCounts(@RequestBody JSONObject json) {
|
|
|
+ Result<JSONObject> result = new Result<JSONObject>();
|
|
|
+ List<CustomerInfo> newAppoints = new ArrayList<>();
|
|
|
+ List<CustomerInfo> todayAppoints = new ArrayList<>();
|
|
|
+ List<CustomerInfo> agoAppoints = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<CustomerInfo> qw_newAppoint = new QueryWrapper<>();
|
|
|
+ QueryWrapper<CustomerInfo> qw_todayAppoint = new QueryWrapper<>();
|
|
|
+ QueryWrapper<CustomerInfo> qw_agoAppoint = new QueryWrapper<>();
|
|
|
+ qw_newAppoint.eq("follow_status",0);
|
|
|
+ qw_todayAppoint.apply("date_format(now(), '%Y-%m-%d') = date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+ qw_agoAppoint.apply("date_format(now(), '%Y-%m-%d') > date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+ String tabs = json.getString("tabs");
|
|
|
+ if (tabs != null && tabs.equals("2")) {
|
|
|
+ String saleCode = json.getString("saleCode");
|
|
|
+ qw_newAppoint.eq("sale_code", saleCode);
|
|
|
+ qw_todayAppoint.eq("sale_code", saleCode);
|
|
|
+ qw_agoAppoint.eq("sale_code", saleCode);
|
|
|
+ }
|
|
|
+ newAppoints = customerInfoService.list(qw_newAppoint);
|
|
|
+ todayAppoints = customerInfoService.list(qw_todayAppoint);
|
|
|
+ agoAppoints = customerInfoService.list(qw_agoAppoint);
|
|
|
+ JSONObject obj=new JSONObject();
|
|
|
+ obj.put("newAppoint",newAppoints.size());
|
|
|
+ obj.put("todayAppoint",todayAppoints.size());
|
|
|
+ obj.put("agoAppoint",agoAppoints.size());
|
|
|
+ result.setResult(obj);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setCode(200);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 潜客管理获取分组
|
|
|
+// *
|
|
|
+// * @param json
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @AutoLog(value = "潜客管理-获取分组")
|
|
|
+// @ApiOperation(value="潜客管理-获取分组", notes="潜客管理-获取分组")
|
|
|
+// @PostMapping(value = "/getGroups")
|
|
|
+// public Result<IPage<CustomerInfo>> getGroups(@RequestBody JSONObject json) {
|
|
|
+// Result<List<CustomerInfo>> result = new Result<List<CustomerInfo>>();
|
|
|
+// CustomerInfo customerInfo = new CustomerInfo();
|
|
|
+// String group = json.getString("group");
|
|
|
+// List<CustomerInfo> customerInfos = new ArrayList<>();
|
|
|
+// QueryWrapper<CustomerInfo> queryWrapper = QueryGenerator.initQueryWrapper(customerInfo, null);
|
|
|
+// if(group.equals("2")) {
|
|
|
+// queryWrapper.eq("follow_status",0);
|
|
|
+// }else if(group.equals("3")) {
|
|
|
+// //date_format(now(), '%Y-%m-%d') = date_format(next_follow_time, '%Y-%m-%d')
|
|
|
+// queryWrapper.apply("date_format(now(), '%Y-%m-%d') = date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+// }else if(group.equals("4")) {
|
|
|
+// // date_format(now(), '%Y-%m-%d') > date_format(next_follow_time, '%Y-%m-%d')
|
|
|
+// queryWrapper.apply("date_format(now(), '%Y-%m-%d') > date_format(next_follow_time, '%Y-%m-%d')");
|
|
|
+// }
|
|
|
+// Page<CustomerInfo> page = new Page<CustomerInfo>(1, 99999);
|
|
|
+// IPage<CustomerInfo> pageList = customerInfoService.page(page, queryWrapper);
|
|
|
+// return Result.OK(pageList);
|
|
|
+// }
|
|
|
+
|
|
|
+}
|