Explorar o código

客户中间表关联接口修改

anderx %!s(int64=4) %!d(string=hai) anos
pai
achega
b27a937795

+ 21 - 18
.idea/workspace.xml

@@ -10,10 +10,15 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="03bdfc55-71bf-4741-8c4c-e1a0c2a3c3ba" name="Default Changelist" comment="导出修改">
+    <list default="true" id="03bdfc55-71bf-4741-8c4c-e1a0c2a3c3ba" name="Default Changelist" comment="客户信息主营产品修改日志排序修改">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserDataLogMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserDataLogMapper.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/utils/excel/NewExcelUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/utils/excel/NewExcelUtil.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/dao/UserLockReleaseMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/dao/UserLockReleaseMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/dao/UserMidMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/dao/UserMidMapper.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserMidMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/common/mapper/UserMidMapper.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java" afterDir="false" />
     </list>
     <list id="571ad643-3e7d-4437-aedf-999fc56d0449" name="updateBusinessScope" comment="" />
     <option name="SHOW_DIALOG" value="false" />
@@ -91,17 +96,6 @@
     </key>
   </component>
   <component name="RunManager">
-    <configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
-      <option name="arquillianRunConfiguration">
-        <value>
-          <option name="containerStateName" value="" />
-        </value>
-      </option>
-      <option name="TEST_OBJECT" value="class" />
-      <method v="2">
-        <option name="Make" enabled="true" />
-      </method>
-    </configuration>
     <configuration name="Tomcat 8.5.59" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat 8.5.59" ALTERNATIVE_JRE_ENABLED="false" nameIsGenerated="true">
       <option name="OPEN_IN_BROWSER" value="false" />
       <option name="COMMON_VM_ARGUMENTS" value="-Dprofiles.activation=&quot;local&quot; -Djdbc.worker.id=&quot;1001&quot;" />
@@ -237,7 +231,8 @@
       <workItem from="1630888067668" duration="852000" />
       <workItem from="1630893291690" duration="11740000" />
       <workItem from="1630976664603" duration="14614000" />
-      <workItem from="1631062478856" duration="19712000" />
+      <workItem from="1631062478856" duration="20529000" />
+      <workItem from="1631149669077" duration="4198000" />
     </task>
     <task id="LOCAL-00001" summary="修改客户跟进列表">
       <created>1630486551669</created>
@@ -449,7 +444,14 @@
       <option name="project" value="LOCAL" />
       <updated>1631090866513</updated>
     </task>
-    <option name="localTasksCounter" value="31" />
+    <task id="LOCAL-00031" summary="客户信息主营产品修改日志排序修改">
+      <created>1631099545002</created>
+      <option name="number" value="00031" />
+      <option name="presentableId" value="LOCAL-00031" />
+      <option name="project" value="LOCAL" />
+      <updated>1631099545002</updated>
+    </task>
+    <option name="localTasksCounter" value="32" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -494,7 +496,8 @@
     <MESSAGE value="config整理" />
     <MESSAGE value="处理相同的修改" />
     <MESSAGE value="导出修改" />
-    <option name="LAST_COMMIT_MESSAGE" value="导出修改" />
+    <MESSAGE value="客户信息主营产品修改日志排序修改" />
+    <option name="LAST_COMMIT_MESSAGE" value="客户信息主营产品修改日志排序修改" />
     <option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
   </component>
   <component name="XDebuggerManager">
@@ -502,7 +505,7 @@
       <breakpoints>
         <line-breakpoint enabled="true" type="java-line">
           <url>file://$PROJECT_DIR$/src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java</url>
-          <line>1076</line>
+          <line>1073</line>
           <option name="timeStamp" value="4" />
         </line-breakpoint>
       </breakpoints>

+ 1 - 8
src/main/java/com/goafanti/common/dao/UserLockReleaseMapper.java

@@ -82,7 +82,6 @@ public interface UserLockReleaseMapper {
 
 	/**
 	 * 重新锁定
-	 * @param oldAid
 	 * @param aid
 	 * @param uid
 	 * @return
@@ -110,19 +109,13 @@ public interface UserLockReleaseMapper {
 	List<LockingReleaseBo> checkTask(@Param("buyerId")String buyerId, @Param("commodityId")String commodityId);
 
 
-	void updateBatchReleaseProject(@Param("uids")List<String> uids, @Param("receiveId")String receiveId, @Param("aid")String aid);
-
-	void updateBatchlockProject(@Param("uid")List<String> uids, @Param("receiveId")String receiveId, @Param("aid")String aid);
-
 	int updatePrivateBusinessTransfer(@Param("inputId")String inputId, @Param("uid")String uid, @Param("pid")String pid,@Param("aid")String aid);
 
 	List<LockingReleaseBo> checkUserProject(@Param("uid")String uid, @Param("pid")String pid, @Param("aid")String aid);
 
 	List<userDaysBo> selectUserDays(@Param("aid")String aid, @Param("x")Integer x, @Param("y")Integer y);
 
-	int updateUserMid(@Param("uid")String uid, @Param("aid")String aid, @Param("followTime")Date followTime, @Param("lockTime")Date lockTime);
-	
-	int insertUserMid(@Param("uid")String uid, @Param("aid")String aid, @Param("followTime")Date followTime, @Param("lockTime")Date lockTime);
+
 
 	int insertList(List<UserLockRelease> ulrList);
 

+ 5 - 0
src/main/java/com/goafanti/common/dao/UserMidMapper.java

@@ -1,6 +1,9 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.UserMid;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface UserMidMapper {
     int deleteByPrimaryKey(Integer id);
@@ -16,4 +19,6 @@ public interface UserMidMapper {
     int updateByPrimaryKey(UserMid record);
 
     int updateByUid(UserMid um);
+
+    void updateListByUid(@Param("aid") String aid,@Param("updateFollow") Integer updateFollow, @Param("list")List<String> list);
 }

+ 0 - 11
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -500,17 +500,6 @@
 	and datediff(now(),if(t0.lock_time &lt; t1.last_follow_time,t1.last_follow_time,t1.t0.lock_time)) &gt; #{days} 
   </select>
   
-  
-   <insert id="insertUserMid">
-  insert into user_mid (uid,aid,last_sign_time,last_follow_time,create_time)
-  values (#{uid},#{aid},#{lockTime},#{followTime},now())
-  </insert>
-  <update id="updateUserMid" >
-  update user_mid 
-  set last_sign_time=#{lockTime},last_follow_time=#{followTime}
-  where uid=#{uid} and aid=#{aid}
-  </update> 
-  
   <insert id="insertList" >
       insert into user_lock_release (id, type, uid, 
       aid, business_project_id, status, 

+ 35 - 0
src/main/java/com/goafanti/common/mapper/UserMidMapper.xml

@@ -174,4 +174,39 @@
     </set>
     where `uid` = #{uid,jdbcType=VARCHAR}
   </update>
+
+
+  <update id="updateListByUid" parameterType="com.goafanti.common.model.UserMid">
+    update user_mid
+    <set>
+      <if test="aid != null">
+        aid = #{aid,jdbcType=VARCHAR},
+      </if>
+      <if test="updateFollow ==1">
+        last_follow_time = null,
+      </if>
+      <if test="lastSignTime != null">
+        last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bigCustomer != null">
+        big_customer = #{bigCustomer,jdbcType=INTEGER},
+      </if>
+      <if test="updateAid != null">
+        update_aid = #{updateAid,jdbcType=VARCHAR},
+      </if>
+      <if test="updateName != null">
+        update_name = #{updateName,jdbcType=VARCHAR},
+      </if>
+      <if test="dateUpdateTime != null">
+        date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where `uid` in
+    <foreach item="item" collection="list" separator="," open="(" close=")" index="">
+      #{item}
+    </foreach>
+  </update>
 </mapper>

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

@@ -809,7 +809,7 @@ public class AdminCustomerApiController extends BaseApiController{
 			return res;
 		}
 		if(data==null)data=0;
-		if(data==1&&customerService.checkData(uid,aid)){
+		if(data==1&&customerService.checkData(uid,oldAid)){
 			res.getError().add(buildError("","资料归属不正确,无法转交客户资料。"));
 			return res;
 		}

+ 42 - 21
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -653,8 +653,6 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		int followCount = userBusinessMapper.selectFollowCountByUAid(fbb.getUid(), null) + 1;
 		userFollow.setFollowCount(followCount);
 		userFollowMapper.insert(userFollow);
-		// 判断是跟进还是签单
-		int x = 0;
 		// 检查客户锁定情况
 		if (fbb.getUserBusinessList()!=null&&fbb.getUserBusinessList().size() > 0) {
 			boolean isUserOwner = false;
@@ -780,7 +778,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 
 			}
 		}
-		followProject(fbb.getUid(), x);
+		followProject(fbb.getUid());
 		return 1;
 	}
 
@@ -788,19 +786,17 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	 * 跟进更新用户中间表
 	 * 
 	 */
-	private void followProject(String uid, int x) {
+	private void followProject(String uid) {
 		Date date = new Date();
 		String aid = TokenManager.getAdminId();
-		if (x == 0) {
-			if (userLockReleaseMapper.updateUserMid(uid, aid, date, null) < 1) {
-				userLockReleaseMapper.insertUserMid(uid, aid, date, null);
-			}
-		} else {
-			if (userLockReleaseMapper.updateUserMid(uid, aid, date, date) < 1) {
-				userLockReleaseMapper.insertUserMid(uid, aid, date, date);
-			}
+		UserMid um=new UserMid();
+		um.setUid(uid);
+		um.setAid(aid);
+		um.setLastFollowTime(date);
+		int x=userMidMapper.updateByUid(um);
+		if (x==0){
+			userMidMapper.insertSelective(um);
 		}
-
 	}
 
 	@SuppressWarnings("unused")
@@ -1151,6 +1147,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			addUserTransferLog(uid, TokenManager.getAdminId(), null,1, null, now, uList);
 			if (flag <= 0)
 				throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_RECEIVE, ""));
+			updateUserMid(aid,uid,0,null);
 			//转交
 		} else if (AFTConstants.USER_TRANSFER_TO_OTHER.equals(operatorType)
 				|| AFTConstants.SIGN_USER_TRANSFER_TO_OTHER == operatorType) {
@@ -1171,7 +1168,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 					if (flag <= 0)
 						throw new BusinessException(new Error(ErrorConstants.CUSTOMER_TRANSFER_FAIL, ""));
 				}
-
+				updateUserMid(aid,uid,0,null);
 			} else {
 				for (String us : uList) {
 					if (userMapper.getAidAndUser(us, TokenManager.getAdminId()) <= 0)
@@ -1180,8 +1177,10 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 				if (AFTConstants.USER_TRANSFER_TO_OTHER == operatorType) {
 					flag = updateUsersLock(uList, oldAid, UserLockReleaseStatus.LOCKED.getCode(),
 							UserLockReleaseStatus.RELEASE.getCode()); // 原用户释放客户
-					if (flag > 0)
+					if (flag > 0){
 						flag = addUserLock(uid, aid, now, uList); // 指定用户锁定客户
+
+					}
 					if (flag <= 0)
 						throw new BusinessException(new Error(ErrorConstants.CUSTOMER_TRANSFER_FAIL, ""));
 				}
@@ -1191,6 +1190,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 
 			addUserTransferLog(uid, aid,oldAid, type, null, now, uList);
 		}
+
+
 		if (isUs) {
 			if (AFTConstants.USER_RECEIVE == operatorType) {
 				userMapper.updateList(aid, null, 3, null, 2, uList,null);
@@ -1204,6 +1205,25 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	/**
+	 * 处理中间表
+	 * @param aid
+	 * @param uid
+	 * @param type 0单个 1批量
+	 */
+	private void updateUserMid(String aid, String uid,Integer type,List<String> list){
+		if (type==0){
+			UserMid um=new UserMid();
+			um.setAid(aid);
+			um.setUid(uid);
+			um.setLastFollowTime(null);
+			userMidMapper.updateByUid(um);
+		}else{
+			if (!list.isEmpty())userMidMapper.updateListByUid(aid,1,list);
+		}
+
+	}
+
+	/**
 	 * 
 	 * @param uid      客户id
 	 * @param aid      接受者id
@@ -2293,12 +2313,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 
 	@Override
 	public boolean checkData(String uid, String aid) {
-		User u=userMapper.selectByPrimaryKey(uid);
-		if (u.getInformationMaintainer().equals(aid)){
-			return true;
+		List<String> list=Arrays.asList(uid.split(","));
+		for (String s : list) {
+			User u=userMapper.selectByPrimaryKey(s);
+			if (u.getInformationMaintainer().equals(aid)){
+				return true;
+			}
 		}
-		return false;
+	return false;
 	}
-
-
 }

+ 2 - 5
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -411,12 +411,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			if(t.getTotalAmount().compareTo(new BigDecimal("10"))>=0) {
 				UserMid um=new UserMid();
 				um.setUid(t.getBuyerId());
+				um.setAid(t2.getSalesmanId());
 				um.setBigCustomer(1);
-				int i=userMidMapper.updateByUid(um);
-				if (i==0) {
-					um.setAid(t2.getSalesmanId());
-					userMidMapper.insertSelective(um);
-				}
+				userMidMapper.updateByUid(um);
 			}
 			pushGeneralSendNoticeAndEmail(aids, type,t2.getOrderNo(), TokenManager.getAdminId(),t.getApproval());
 		}