|
|
@@ -9,6 +9,7 @@ import java.util.UUID;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -27,16 +28,17 @@ import com.goafanti.admin.service.AdminService;
|
|
|
import com.goafanti.common.bo.Error;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
-import com.goafanti.common.controller.BaseController;
|
|
|
+import com.goafanti.common.controller.BaseApiController;
|
|
|
import com.goafanti.common.model.Customer;
|
|
|
import com.goafanti.common.model.CustomerOrganizationInfo;
|
|
|
import com.goafanti.common.model.CustomerUserInfo;
|
|
|
import com.goafanti.common.model.FollowUpRecord;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/api/admin/customer")
|
|
|
-public class AdminCustomerApiController extends BaseController {
|
|
|
+public class AdminCustomerApiController extends BaseApiController {
|
|
|
|
|
|
@Resource
|
|
|
private CustomerService customerService;
|
|
|
@@ -72,7 +74,7 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
|
|
|
coi.setId(UUID.randomUUID().toString());//客户公司ID
|
|
|
coi.setCid(customerId);//客户公司表中的cid
|
|
|
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
|
|
|
fur.setFollowDate(format.parse(cusIn.getFollowDates()));
|
|
|
fur.setId(followId);//跟进记录的ID
|
|
|
fur.setCid(customerId);//跟进记录表中的cid
|
|
|
@@ -80,8 +82,8 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
/*if(StringUtils.isNotBlank(cusIn.getAid())) fur.setAid(cusIn.getAid());*//*暂时注释*/
|
|
|
|
|
|
BeanUtils.copyProperties(c, cusIn);
|
|
|
- c.setShareType(Integer.parseInt(cusIn.getShareTyp()));
|
|
|
- c.setCustomerType(Integer.parseInt(cusIn.getCustomerTyp()));
|
|
|
+ c.setShareType(Integer.parseInt(cusIn.getShareType()));
|
|
|
+ c.setCustomerType(Integer.parseInt(cusIn.getCustomerType()));
|
|
|
c.setId(customerId);
|
|
|
|
|
|
customerService.addCustomer(c);
|
|
|
@@ -90,7 +92,7 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
//插入 customerOrganizationInfo
|
|
|
customerOrganizationService.addCustomerOrganizationInfo(coi);
|
|
|
//插入跟进表
|
|
|
- followUpService.addFollowUp(fur,cusIn);
|
|
|
+ followUpService.addFollowUp(fur);
|
|
|
//添加日志
|
|
|
customerService.saveCustomerLogo(cusIn, AFTConstants.CUSTOMER_CREATE,customerId);
|
|
|
return res;
|
|
|
@@ -104,10 +106,10 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
@RequestMapping(value = "/deleteCustomer", method = RequestMethod.POST)
|
|
|
- public Result deleteCustomer(String id,CustomerIn cusIn) throws ParseException {
|
|
|
+ public Result deleteCustomer(CustomerIn cusIn) throws ParseException {
|
|
|
Result res=new Result();
|
|
|
- customerService.deleteCustomer(id);
|
|
|
- customerService.saveCustomerLogo(cusIn, AFTConstants.CUSTOMER_DELETE,id);
|
|
|
+ customerService.deleteCustomer(cusIn.getId());
|
|
|
+ customerService.saveCustomerLogo(cusIn, AFTConstants.CUSTOMER_DELETE,cusIn.getId());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -154,8 +156,8 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/findCustomerUserDetails", method = RequestMethod.POST)
|
|
|
- public Result findCustomerUserDetails(String id) {
|
|
|
+ @RequestMapping(value = "/findCustomerDetails", method = RequestMethod.POST)
|
|
|
+ public Result findCustomerDetails(String id) {
|
|
|
Result res=new Result();
|
|
|
res.setData(customerService.findCustomerDetails(id));
|
|
|
return res;
|
|
|
@@ -166,10 +168,10 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/findCustomerUserNameList", method = RequestMethod.POST)
|
|
|
- public Result findCustomerUserNameList (String cid) {
|
|
|
+ @RequestMapping(value = "/findCustomerUserList", method = RequestMethod.POST)
|
|
|
+ public Result findCustomerUserList (String cid) {
|
|
|
Result res =new Result();
|
|
|
- res.setData(customerUserService.findCustomerUserNameList(cid));
|
|
|
+ res.setData(customerUserService.selectCustomerUserList(cid));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -203,13 +205,13 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
* @throws InvocationTargetException
|
|
|
* @throws IllegalAccessException
|
|
|
*/
|
|
|
- @RequestMapping(value = "/updCustomer", method = RequestMethod.POST)
|
|
|
- public Result updCustomer (CustomerIn cusIn,CustomerOrganizationInfo coi) throws IllegalAccessException, InvocationTargetException {
|
|
|
+ @RequestMapping(value = "/updateCustomer", method = RequestMethod.POST)
|
|
|
+ public Result updateCustomer (CustomerIn cusIn,CustomerOrganizationInfo coi,HttpServletResponse rsp) throws IllegalAccessException, InvocationTargetException {
|
|
|
Result res=new Result();
|
|
|
Customer c =new Customer();
|
|
|
BeanUtils.copyProperties(c, cusIn);
|
|
|
- c.setShareType(Integer.parseInt(cusIn.getShareTyp()));
|
|
|
- c.setCustomerType(Integer.parseInt(cusIn.getCustomerTyp()));
|
|
|
+ c.setShareType(Integer.parseInt(cusIn.getShareType()));
|
|
|
+ c.setCustomerType(Integer.parseInt(cusIn.getCustomerType()));
|
|
|
coi.setCid(cusIn.getId());
|
|
|
//更新主表
|
|
|
customerService.updateCustomer(c);
|
|
|
@@ -230,7 +232,9 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
public Result transferCustomer (CustomerIn cusIn) throws IllegalAccessException, InvocationTargetException {
|
|
|
Result res=new Result();
|
|
|
Customer c =new Customer();
|
|
|
- BeanUtils.copyProperties(c, cusIn);
|
|
|
+ c.setId(cusIn.getId());
|
|
|
+ c.setAid(cusIn.getAid());
|
|
|
+ c.setCreateTime(new Date());
|
|
|
//更新主表
|
|
|
customerService.updateCustomer(c);
|
|
|
//插入日志表
|
|
|
@@ -242,22 +246,29 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
* 查询单个联系人信息
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/findContactDetail", method = RequestMethod.POST)
|
|
|
- public Result findContactDetail (String id) {
|
|
|
+ @RequestMapping(value = "/findContactDetail", method = RequestMethod.GET)
|
|
|
+ public Result findContactDetail (String contactId) {
|
|
|
Result res=new Result();
|
|
|
- res.setData(customerUserService.findContractById(id));
|
|
|
+ res.setData(customerUserService.findContactDetail(contactId));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改单个联系人信息
|
|
|
+ * 修改联系人信息
|
|
|
* @return
|
|
|
*/
|
|
|
- /*@RequestMapping(value = "/transferCsutomer", method = RequestMethod.POST)
|
|
|
- public Result updContractById (String id) {
|
|
|
+ @RequestMapping(value = "/updateContacter", method = RequestMethod.POST)
|
|
|
+ public Result updateContacter (CustomerUserInfo cui) {
|
|
|
Result res=new Result();
|
|
|
+ if(cui.getPrimaryFlg() == 0){
|
|
|
+ String primaryId = customerUserService.selectPrimaryFlgByCid(cui.getCid());
|
|
|
+ if(StringUtils.isNoneBlank(primaryId)) {
|
|
|
+ customerUserService.updatePrimaryFlg(primaryId);//把主要联系人状态给去掉
|
|
|
+ }
|
|
|
+ }
|
|
|
+ customerUserService.updateContractById(cui);
|
|
|
return res;
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 添加跟进记录
|
|
|
@@ -272,8 +283,10 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
if(StringUtils.isNotBlank(cusIn.getFollowDates())) fur.setFollowDate(format.parse(cusIn.getFollowDates()));
|
|
|
String followId = UUID.randomUUID().toString();
|
|
|
fur.setId(followId);
|
|
|
+ fur.setCid(cusIn.getId());
|
|
|
+ fur.setEffective(0);
|
|
|
cusIn.setFollowId(followId);
|
|
|
- followUpService.addFollowUp(fur, cusIn);
|
|
|
+ followUpService.addFollowUp(fur);
|
|
|
Customer cus = new Customer();
|
|
|
try {
|
|
|
BeanUtils.copyProperties(cus, cusIn);
|
|
|
@@ -283,8 +296,7 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
cus.setCustomerStatus(Integer.parseInt(cusIn.getCustomerStatus()));
|
|
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
customerService.updateCustomer(cus);
|
|
|
return res;
|
|
|
}
|
|
|
@@ -319,17 +331,121 @@ public class AdminCustomerApiController extends BaseController {
|
|
|
* @param customerId
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/delContract" , method = RequestMethod.GET)
|
|
|
- public Result delContract(String id){
|
|
|
+ @RequestMapping(value = "/deleteContacter" , method = RequestMethod.GET)
|
|
|
+ public Result deleteContacter(String contactId){
|
|
|
Result res= new Result();
|
|
|
- CustomerUserInfo customerUserInfo = customerUserService.findContractById(id);
|
|
|
-
|
|
|
+ CustomerUserInfo customerUserInfo = customerUserService.findContractById(contactId);
|
|
|
if(customerUserInfo.getPrimaryFlg()==0) {
|
|
|
res.getError().add(new Error("该联系人为主要联系人,不能进行删除操作!"));
|
|
|
}else {
|
|
|
- customerUserService.deleteContractById(id);
|
|
|
+ customerUserService.deleteContractById(contactId);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 营销员填写跟进记录上传文件
|
|
|
+ * @param req
|
|
|
+ * @param sign
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/attachmentUpload" , method = RequestMethod.POST)
|
|
|
+ public Result attachmentUpload(HttpServletRequest req, String sign){
|
|
|
+ Result res= new Result();
|
|
|
+ res.setData(handleFile(res, "/customer_sys_file/", true, req, sign));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除跟进记录
|
|
|
+ * @param followId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteFollowUpRecord", method = RequestMethod.GET)
|
|
|
+ public Result deleteFollowUpRecord(String followId){
|
|
|
+ Result res= new Result();
|
|
|
+ followUpService.deleteFollowUpRecord(followId);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看公共客户
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/listPublicCustomer", method = RequestMethod.POST)
|
|
|
+ public Result listPublicCustomer(HttpServletRequest request,CustomerIn cin,Integer pageSize, Integer pageNumber){
|
|
|
+ Result res = new Result();
|
|
|
+ Pagination<CustomerOut> boList = customerService.getPublicCustomer(cin, pageSize, pageNumber);
|
|
|
+ res.setData(boList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 领取
|
|
|
+ * @param cusIn
|
|
|
+ * @return
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/receivePublicCustomer", method = RequestMethod.GET)
|
|
|
+ public Result receivePublicCustomer(CustomerIn cusIn) throws IllegalAccessException, InvocationTargetException{
|
|
|
+ Result res=new Result();
|
|
|
+ Customer c =new Customer();
|
|
|
+ c.setId(cusIn.getId());
|
|
|
+ c.setAid(TokenManager.getAdminId());
|
|
|
+ //更新主表
|
|
|
+ customerService.updateCustomer(c);
|
|
|
+ //插入日志表
|
|
|
+ customerService.saveCustomerLogo(cusIn, AFTConstants.CUSTOMER_RECEIVE,cusIn.getId());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看公共客户
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/listTeamCustomer", method = RequestMethod.POST)
|
|
|
+ public Result listTeamCustomer(HttpServletRequest request,CustomerIn cin,Integer pageSize, Integer pageNumber){
|
|
|
+ Result res = new Result();
|
|
|
+ Pagination<CustomerOut> boList = customerService.getPublicCustomer(cin, pageSize, pageNumber);
|
|
|
+ res.setData(boList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转为公共客户
|
|
|
+ * @return
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/transferToPublic" , method = RequestMethod.POST)
|
|
|
+ public Result transferToPublic(CustomerIn cusIn) throws IllegalAccessException, InvocationTargetException{
|
|
|
+ Result res=new Result();
|
|
|
+ Customer c = new Customer();
|
|
|
+ c.setId(cusIn.getId());
|
|
|
+ c.setAid("");
|
|
|
+ c.setShareType(1);
|
|
|
+ c.setCreateTime(new Date());
|
|
|
+ //更新主表
|
|
|
+ customerService.updateCustomer(c);
|
|
|
+ //插入日志表
|
|
|
+ customerService.saveCustomerLogo(cusIn, AFTConstants.CUSTOMER_TO_PUBLIC,cusIn.getId());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看公司客户
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/listCompanyCustomer", method = RequestMethod.POST)
|
|
|
+ public Result listCompanyCustomer(HttpServletRequest request,CustomerIn cin,Integer pageSize, Integer pageNumber){
|
|
|
+ Result res = new Result();
|
|
|
+ Pagination<CustomerOut> boList = customerService.getCompanyCustomer(cin, pageSize, pageNumber);
|
|
|
+ res.setData(boList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
}
|