zou_ht 8 years ago
parent
commit
b689f0e87d

+ 2 - 2
src/main/java/com/goafanti/common/mapper/CustomerUserInfoMapper.xml

@@ -162,7 +162,7 @@
     values (#{id,jdbcType=VARCHAR}, #{cid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
       #{sex,jdbcType=CHAR}, #{mobile,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, 
       #{wechat,jdbcType=VARCHAR}, #{depatrment,jdbcType=VARCHAR}, #{customerPosition,jdbcType=VARCHAR}, 
-      #{remarks,jdbcType=VARCHAR}, #{telNum,jdbcType=VARCHAR}, 0
+      #{remarks,jdbcType=VARCHAR}, #{telNum,jdbcType=VARCHAR}, #{primaryFlg,jdbcType=VARCHAR}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.CustomerUserInfo">
@@ -426,7 +426,7 @@
   </select>
   
   <update id="updataPrimaryFlg" parameterType="java.lang.String" >
-    update customer set primary_flg=1 where 1=1 and cid = #{cid,jdbcType=VARCHAR}
+    update customer_user_info set primary_flg=1 where 1=1 and id = #{id,jdbcType=VARCHAR}
   </update>
  
 </mapper>

+ 5 - 6
src/main/java/com/goafanti/customer/bo/CustomerIn.java

@@ -9,7 +9,7 @@ public class CustomerIn {
 	/** 客户编号 **/
 	private String cuid;
 	/** 跟进时间 **/
-	private String followDate;
+	private String followDates;
 	
 	/** 客户名 **/
 	private String customerName;
@@ -213,13 +213,12 @@ public class CustomerIn {
 		this.beforeAdminName = beforeadminName;
 	}
 
-	public String getFollowDate() {
-		return followDate;
+	public String getFollowDates() {
+		return followDates;
 	}
 
-	public void setFollowDate(String followDate) {
-		this.followDate = followDate;
+	public void setFollowDates(String followDates) {
+		this.followDates = followDates;
 	}
 	
-	
 }

+ 31 - 13
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -3,6 +3,7 @@ package com.goafanti.customer.controller;
 import java.lang.reflect.InvocationTargetException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
@@ -23,6 +24,7 @@ import com.goafanti.customer.service.CustomerService;
 import com.goafanti.customer.service.CustomerUserService;
 import com.goafanti.customer.service.FollowUpService;
 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;
@@ -64,14 +66,14 @@ public class AdminCustomerApiController extends BaseController {
 		String followId=UUID.randomUUID().toString();//跟进记录ID
 		Customer c = new Customer();
 		cusIn.setFollowId(followId);
-		cusIn.setId(customerId);
-		
+		cusIn.setId(customerId);		
 		cui.setId(customerUsrId);
 		cui.setCid(customerId);//客户联系人表中的cid
 		
 		coi.setId(UUID.randomUUID().toString());//客户公司ID
 		coi.setCid(customerId);//客户公司表中的cid
-		
+		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
+		fur.setFollowDate(format.parse(cusIn.getFollowDates()));
 		fur.setId(followId);//跟进记录的ID
 		fur.setCid(customerId);//跟进记录表中的cid
 		fur.setCuid(customerUsrId);//跟进记录表中的联系人id		
@@ -179,15 +181,13 @@ public class AdminCustomerApiController extends BaseController {
 	 * @throws IllegalAccessException 
 	 */
 	@RequestMapping(value = "/addContacter", method = RequestMethod.POST)
-	public Result addContacter (CustomerIn cusIn) throws IllegalAccessException, InvocationTargetException {
+	public Result addContacter (CustomerUserInfo cui) throws IllegalAccessException, InvocationTargetException {
 		Result res =new Result();
-		CustomerUserInfo cui =new CustomerUserInfo();
-		BeanUtils.copyProperties(cui, cusIn);
 		cui.setId(UUID.randomUUID().toString());
 		if(cui.getPrimaryFlg()==0) {//0:主要联系人,1-非主要联系人
-			String primaryId = customerUserService.selectPrimaryFlgByCid(cusIn.getId());
+			String primaryId = customerUserService.selectPrimaryFlgByCid(cui.getCid());
 			if(StringUtils.isNoneBlank(primaryId)) {
-				customerUserService.updPrimaryFlg(cusIn.getId());//把主要联系人状态给去掉
+				customerUserService.updatePrimaryFlg(primaryId);//把主要联系人状态给去掉
 			}
 			customerUserService.addCustomerUserInfo(cui);//再添加联系人
 		}else {
@@ -242,12 +242,12 @@ public class AdminCustomerApiController extends BaseController {
 	 * 查询单个联系人信息
 	 * @return
 	 */
-	/*@RequestMapping(value = "/transferCsutomer", method = RequestMethod.POST)
-	public Result findContractById (String id)  {
+	@RequestMapping(value = "/findContactDetail", method = RequestMethod.POST)
+	public Result findContactDetail (String id)  {
 		Result res=new Result();
 		res.setData(customerUserService.findContractById(id));
 		return res;
-	}*/
+	}
 	
 	/**
 	 * 修改单个联系人信息
@@ -266,10 +266,10 @@ public class AdminCustomerApiController extends BaseController {
 	 * @throws ParseException 
 	 */
 	@RequestMapping(value = "/addFollow", method = RequestMethod.POST)
-	public Result addFollowUpRecord(FollowUpRecord fur, CustomerIn cusIn ,String followDate) throws ParseException{
+	public Result addFollowUpRecord(FollowUpRecord fur, CustomerIn cusIn) throws ParseException{
 		Result res = new Result();
 		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
-		if(StringUtils.isNotBlank(followDate)) fur.setFollowDate(format.parse(followDate));
+		if(StringUtils.isNotBlank(cusIn.getFollowDates())) fur.setFollowDate(format.parse(cusIn.getFollowDates()));
 		String followId = UUID.randomUUID().toString();
 		fur.setId(followId);
 		cusIn.setFollowId(followId);
@@ -314,4 +314,22 @@ public class AdminCustomerApiController extends BaseController {
 		return res;
 	}	
 	
+	/**
+	 * 删除联系人
+	 * @param customerId
+	 * @return
+	 */
+	@RequestMapping(value = "/delContract" , method = RequestMethod.GET)
+	public Result delContract(String id){
+		Result res= new Result();
+		CustomerUserInfo customerUserInfo = customerUserService.findContractById(id);
+		
+		if(customerUserInfo.getPrimaryFlg()==0) {
+			res.getError().add(new Error("该联系人为主要联系人,不能进行删除操作!"));
+		}else {
+			customerUserService.deleteContractById(id);
+		}
+		return res;
+	}	
+	
 }

+ 7 - 1
src/main/java/com/goafanti/customer/service/CustomerUserService.java

@@ -32,7 +32,7 @@ public interface CustomerUserService {
 	 * @param cui
 	 * @return
 	 */
-	int updPrimaryFlg (String cid);
+	int updatePrimaryFlg (String id);
 	
 	/**
 	 * 查询单个联系人信息
@@ -45,4 +45,10 @@ public interface CustomerUserService {
 	 * @return
 	 */
 	int updateContractById (CustomerUserInfo cui);
+	
+	/**
+	 * 删除联系人
+	 * @return
+	 */
+	int deleteContractById (String id);
 }

+ 7 - 2
src/main/java/com/goafanti/customer/service/impl/CustomerUserServiceImp.java

@@ -32,8 +32,8 @@ public class CustomerUserServiceImp extends BaseMybatisDao<CustomerUserInfoMappe
 	}
 
 	@Override
-	public int updPrimaryFlg(String cid) {
-		return customerUserInfoMapper.updataPrimaryFlg(cid);
+	public int updatePrimaryFlg(String id) {
+		return customerUserInfoMapper.updataPrimaryFlg(id);
 	}
 
 	@Override
@@ -46,6 +46,11 @@ public class CustomerUserServiceImp extends BaseMybatisDao<CustomerUserInfoMappe
 		return customerUserInfoMapper.updateByPrimaryKey(cui);
 	}
 
+	@Override
+	public int deleteContractById(String id) {
+		return customerUserInfoMapper.deleteByPrimaryKey(id);
+	}
+