Browse Source

客户转交修改开发

anderx 3 years ago
parent
commit
bef09b2568

+ 4 - 0
src/main/java/com/goafanti/common/dao/TOrderNewMapper.java

@@ -73,4 +73,8 @@ public interface TOrderNewMapper {
 
     void updateExamineById(@Param("id") String id,@Param("type")Integer type);
 
+
+
+
+    List<TOrderNewBo> selectByuidandAid(@Param("uid")String uid,@Param("aid") String aid);
 }

+ 7 - 0
src/main/java/com/goafanti/common/enums/OrderLogProcess.java

@@ -29,6 +29,13 @@ public enum OrderLogProcess {
 	XMWBBH(16,"项目外包驳回"),
 	DDLZZJ(17,"订单离职转交"),
 	YXJLTT(18,"营销经理审核"),
+	HYCWTG(19,"会员财务通过"),
+	HYTPTG(20,"会员特批通过"),
+	HYCWBH(21,"会员财务驳回"),
+	HYTPBH(22,"会员特批驳回"),
+	HYXMWC(23,"会员项目完成"),
+	DDZJ(24,"订单转交"),
+
 	NOT(99,"未知"),
 	;
 

+ 5 - 0
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -2056,6 +2056,11 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
         where c.role_type in ('9998') and a.status ='0' ) zxsgly on 1=1
     where a.order_no = #{orderNo}
   </select>
+  <select id="selectByuidandAid" resultType="com.goafanti.order.bo.TOrderNewBo">
+    select order_no orderNo
+    from t_order_new
+    where buyer_id=#{uid} and salesman_id=#{aid}
+  </select>
 
 
 

+ 3 - 6
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -902,7 +902,7 @@ public class AdminCustomerApiController extends BaseApiController{
 	 * @param aid
 	 * @param operatorType 3私有 4签单
 	 * @param oldAid
-	 * @param data 资料同步转移 0否 1是
+	 * @param data 资料同步转移 0无 1资料转交 2订单转交 3全部转交
 	 * @return
 	 */
 	@RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
@@ -922,11 +922,8 @@ public class AdminCustomerApiController extends BaseApiController{
 			return res;
 		}
 		if(data==null)data=0;
-		if(data==1&&customerService.checkData(uid,oldAid)){
-			res.getError().add(buildError("","资料归属不正确,无法转交客户资料。"));
-			return res;
-		}
-		customerService.updateByOperatorType(uid,aid,oldAid,operatorType,data);
+		res.setData(customerService.updateByOperatorType(uid, aid, oldAid, operatorType, data));
+
 		return res;
 	}
 

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

@@ -235,7 +235,7 @@ public interface CustomerService {
 	 * @param operatorType
 	 * @return
 	 */
-	int updateByOperatorType(String uid,String aid,String oldAid,Integer operatorType,Integer data);
+	List<String> updateByOperatorType(String uid,String aid,String oldAid,Integer operatorType,Integer data);
 
 	/**
 	 * 客户统计

+ 61 - 13
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -17,8 +17,10 @@ import javax.annotation.Resource;
 
 import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.common.dao.*;
+import com.goafanti.common.enums.*;
 import com.goafanti.common.model.*;
 import com.goafanti.customer.bo.*;
+import com.goafanti.order.bo.TOrderNewBo;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.ibatis.builder.BuilderException;
@@ -32,13 +34,6 @@ import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.userDaysBo;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
-import com.goafanti.common.enums.ChannelStatus;
-import com.goafanti.common.enums.CustomerStatusFiled;
-import com.goafanti.common.enums.DeleteStatus;
-import com.goafanti.common.enums.IdentityProcess;
-import com.goafanti.common.enums.UserLevel;
-import com.goafanti.common.enums.UserLockReleaseStatus;
-import com.goafanti.common.enums.UserType;
 import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.utils.BeanUtilsExt;
 import com.goafanti.common.utils.DateUtils;
@@ -107,6 +102,15 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	private UserMidMapper userMidMapper;
 	@Resource
 	private UserDataLogMapper	userDataLogMapper;
+	@Resource
+	private TOrderNewMapper	tOrderNewMapper;
+	@Resource
+	private TOrderMidMapper	tOrderMidMapper;
+	@Resource
+	private TOrderLogMapper	tOrderLogMapper;
+
+
+
 	@Value(value = "${upload.path}")
 	private String uploadPath = null;
 
@@ -1203,9 +1207,11 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public int updateByOperatorType(String uid,String aid, String oldAid, Integer operatorType,Integer data) {
+	@Transactional
+	public List<String> updateByOperatorType(String uid,String aid, String oldAid, Integer operatorType,Integer data) {
 		User user = new User();
 		Date now = new Date();
+		List<String> errors=new ArrayList<>();
 		if(aid==null)aid=TokenManager.getAdminId();
 		if(data==null)data=0;
 		// 是否多个客户
@@ -1236,9 +1242,11 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 				|| AFTConstants.CHANNEL_USER_TRANSFER_TO_OTHER .equals(operatorType)) {
 			if (!isUs) {
 				user.setAid(aid);
-				if (data==1){
-					user.setInformationMaintainer(aid);
-					organizationContactBookMapper.updateAdmin(uid,aid);
+				if (data==1||data==3){
+					informationMaintainerHandOver(uid, aid, oldAid, user, errors);
+				}
+				if (data==2||data==3){
+					updateOrderHandOver(uid,aid,oldAid);
 				}
 				user.setSource(3);// 客户来源设置为转交
 				//私有和渠道有客户锁操作
@@ -1256,8 +1264,15 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 				updateUserMid(aid,uid,0,null);
 			} else {
 				for (String us : uList) {
-					if (userMapper.getAidAndUser(us, TokenManager.getAdminId()) <= 0)
+					if (userMapper.getAidAndUser(us, TokenManager.getAdminId()) <= 0){
 						throw new BusinessException(new Error("请勿非法操作!", "请勿非法操作!"));
+					}
+					if (data==1||data==3){
+						informationMaintainerHandOver(us, aid, oldAid, user, errors);
+					}
+					if (data==2||data==3){
+						updateOrderHandOver(uid,aid,oldAid);
+					}
 				}
 				if (AFTConstants.USER_TRANSFER_TO_OTHER == operatorType) {
 					flag = updateUsersLock(uList, oldAid, UserLockReleaseStatus.LOCKED.getCode(),
@@ -1286,7 +1301,40 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		} else {
 			userMapper.updateByPrimaryKeySelective(user);
 		}
-		return 1;
+		return errors;
+	}
+
+	private void updateOrderHandOver(String uid, String aid, String oldAid) {
+		List<TOrderNewBo> list = tOrderNewMapper.selectByuidandAid(uid, aid);
+		for (TOrderNewBo bo : list) {
+			bo.setSalesmanId(aid);
+			bo.setOldSalesmanId(oldAid);
+			tOrderNewMapper.updateByPrimaryKeySelective(bo);
+			TOrderMid mid=new TOrderMid();
+			mid.setOrderNo(bo.getOrderNo());
+			Admin admin = adminMapper.selectByPrimaryKey(aid);
+			Admin oldadmin = adminMapper.selectByPrimaryKey(oldAid);
+			mid.setSalesmanName(admin.getName());
+			tOrderMidMapper.updateByOrderNo(mid);
+			TOrderLog log=new TOrderLog();
+			log.setProcess(OrderLogProcess.DDZJ.getCode());
+			log.setAid(oldAid);
+			log.setOrderNo(bo.getOrderNo());
+			log.setCreateTime(new Date());
+			log.setRemarks("订单转交:"+oldadmin.getName()+"=>"+admin.getName());
+			tOrderLogMapper.insert(log);
+		}
+	}
+
+
+	private void informationMaintainerHandOver(String uid, String aid, String oldAid, User user, List<String> errors) {
+		User useUser = userMapper.selectByPrimaryKey(user.getId());
+		if (useUser.getInformationMaintainer().equals(oldAid)){
+			user.setInformationMaintainer(aid);
+			organizationContactBookMapper.updateAdmin(uid, aid);
+		}else {
+			errors.add("客户["+useUser.getNickname()+"]归属不正确,资料转交失败。");
+		}
 	}
 
 	@Override