Browse Source

各接口操作数据同步到客户统计表

anderx 3 years ago
parent
commit
a5402970ef

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

@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface UserMidMapper {
+
+
     int deleteByPrimaryKey(Integer id);
 
     int insert(UserMid record);
@@ -21,4 +23,6 @@ public interface UserMidMapper {
     int updateByUid(UserMid um);
 
     void updateListByUid(@Param("aid") String aid,@Param("updateFollow") Integer updateFollow, @Param("list")List<String> list);
+
+    String getUserTaskNames(String uid) ;
 }

+ 102 - 4
src/main/java/com/goafanti/common/mapper/UserMidMapper.xml

@@ -13,10 +13,17 @@
     <result column="update_name" jdbcType="VARCHAR" property="updateName" />
     <result column="date_update_time" jdbcType="TIMESTAMP" property="dateUpdateTime" />
     <result column="channel_type" jdbcType="INTEGER" property="channelType" />
+    <result column="chargeback" jdbcType="INTEGER" property="chargeback" />
+    <result column="member" jdbcType="INTEGER" property="member" />
+    <result column="last_sales_type" jdbcType="INTEGER" property="lastSalesType" />
+    <result column="last_follow_type" jdbcType="INTEGER" property="lastFollowType" />
+    <result column="follow_number" jdbcType="INTEGER" property="followNumber" />
+    <result column="task_names" jdbcType="VARCHAR" property="taskNames" />
   </resultMap>
   <sql id="Base_Column_List">
     id, `uid`, aid, last_follow_time, last_sign_time, create_time, big_customer, update_aid,
-    update_name, date_update_time, channel_type
+    update_name, date_update_time, channel_type, chargeback, `member`, last_sales_type,
+    last_follow_type, follow_number, task_names
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -24,6 +31,7 @@
     from user_mid
     where id = #{id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from user_mid
     where id = #{id,jdbcType=INTEGER}
@@ -32,11 +40,15 @@
     insert into user_mid (id, `uid`, aid,
       last_follow_time, last_sign_time, create_time,
       big_customer, update_aid, update_name,
-      date_update_time, channel_type)
+      date_update_time, channel_type, chargeback,
+      `member`, last_sales_type, last_follow_type,
+      follow_number, task_names)
     values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
       #{lastFollowTime,jdbcType=TIMESTAMP}, #{lastSignTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
       #{bigCustomer,jdbcType=INTEGER}, #{updateAid,jdbcType=VARCHAR}, #{updateName,jdbcType=VARCHAR},
-      #{dateUpdateTime,jdbcType=TIMESTAMP}, #{channelType,jdbcType=INTEGER})
+      #{dateUpdateTime,jdbcType=TIMESTAMP}, #{channelType,jdbcType=INTEGER}, #{chargeback,jdbcType=INTEGER},
+      #{member,jdbcType=INTEGER}, #{lastSalesType,jdbcType=INTEGER}, #{lastFollowType,jdbcType=INTEGER},
+      #{followNumber,jdbcType=INTEGER}, #{taskNames,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.UserMid">
     insert into user_mid
@@ -74,6 +86,24 @@
       <if test="channelType != null">
         channel_type,
       </if>
+      <if test="chargeback != null">
+        chargeback,
+      </if>
+      <if test="member != null">
+        `member`,
+      </if>
+      <if test="lastSalesType != null">
+        last_sales_type,
+      </if>
+      <if test="lastFollowType != null">
+        last_follow_type,
+      </if>
+      <if test="followNumber != null">
+        follow_number,
+      </if>
+      <if test="taskNames != null">
+        task_names,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -109,6 +139,24 @@
       <if test="channelType != null">
         #{channelType,jdbcType=INTEGER},
       </if>
+      <if test="chargeback != null">
+        #{chargeback,jdbcType=INTEGER},
+      </if>
+      <if test="member != null">
+        #{member,jdbcType=INTEGER},
+      </if>
+      <if test="lastSalesType != null">
+        #{lastSalesType,jdbcType=INTEGER},
+      </if>
+      <if test="lastFollowType != null">
+        #{lastFollowType,jdbcType=INTEGER},
+      </if>
+      <if test="followNumber != null">
+        #{followNumber,jdbcType=INTEGER},
+      </if>
+      <if test="taskNames != null">
+        #{taskNames,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserMid">
@@ -144,6 +192,24 @@
       <if test="channelType != null">
         channel_type = #{channelType,jdbcType=INTEGER},
       </if>
+      <if test="chargeback != null">
+        chargeback = #{chargeback,jdbcType=INTEGER},
+      </if>
+      <if test="member != null">
+        `member` = #{member,jdbcType=INTEGER},
+      </if>
+      <if test="lastSalesType != null">
+        last_sales_type = #{lastSalesType,jdbcType=INTEGER},
+      </if>
+      <if test="lastFollowType != null">
+        last_follow_type = #{lastFollowType,jdbcType=INTEGER},
+      </if>
+      <if test="followNumber != null">
+        follow_number = #{followNumber,jdbcType=INTEGER},
+      </if>
+      <if test="taskNames != null">
+        task_names = #{taskNames,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -158,9 +224,16 @@
       update_aid = #{updateAid,jdbcType=VARCHAR},
       update_name = #{updateName,jdbcType=VARCHAR},
       date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
-      channel_type = #{channelType,jdbcType=INTEGER}
+      channel_type = #{channelType,jdbcType=INTEGER},
+      chargeback = #{chargeback,jdbcType=INTEGER},
+      `member` = #{member,jdbcType=INTEGER},
+      last_sales_type = #{lastSalesType,jdbcType=INTEGER},
+      last_follow_type = #{lastFollowType,jdbcType=INTEGER},
+      follow_number = #{followNumber,jdbcType=INTEGER},
+      task_names = #{taskNames,jdbcType=VARCHAR}
     where id = #{id,jdbcType=INTEGER}
   </update>
+
   <update id="updateByUid" parameterType="com.goafanti.common.model.UserMid">
     update user_mid
     <set>
@@ -191,6 +264,24 @@
       <if test="channelType != null">
         channel_type = #{channelType,jdbcType=INTEGER},
       </if>
+      <if test="chargeback != null">
+        chargeback = #{chargeback,jdbcType=INTEGER},
+      </if>
+      <if test="member != null">
+        `member` = #{member,jdbcType=INTEGER},
+      </if>
+      <if test="lastSalesType != null">
+        last_sales_type = #{lastSalesType,jdbcType=INTEGER},
+      </if>
+      <if test="lastFollowType != null">
+        last_follow_type = #{lastFollowType,jdbcType=INTEGER},
+      </if>
+      <if test="followNumber != null">
+        follow_number = #{followNumber,jdbcType=INTEGER},
+      </if>
+      <if test="taskNames != null">
+        task_names = #{taskNames,jdbcType=VARCHAR},
+      </if>
     </set>
     where `uid` = #{uid,jdbcType=VARCHAR}
   </update>
@@ -229,4 +320,11 @@
       #{item}
     </foreach>
   </update>
+
+  <select id="getUserTaskNames" resultType="java.lang.String">
+    select group_concat(distinct b.commodity_name)task_names from t_order_new a
+    left join t_order_task b on a.order_no =b.order_no
+    where a.buyer_id = #{uid}
+    group by  a.buyer_id
+  </select>
 </mapper>

+ 78 - 0
src/main/java/com/goafanti/common/model/UserMid.java

@@ -63,6 +63,36 @@ public class UserMid implements Serializable {
      */
     private Integer channelType;
 
+    /**
+     * 退单标识
+     */
+    private Integer chargeback;
+
+    /**
+     * 会员标识
+     */
+    private Integer member;
+
+    /**
+     * 最后销售类型
+     */
+    private Integer lastSalesType;
+
+    /**
+     * 最后跟进方式
+     */
+    private Integer lastFollowType;
+
+    /**
+     * 跟进次数
+     */
+    private Integer followNumber;
+
+    /**
+     * 已签项目
+     */
+    private String taskNames;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -152,4 +182,52 @@ public class UserMid implements Serializable {
     public void setChannelType(Integer channelType) {
         this.channelType = channelType;
     }
+
+    public Integer getChargeback() {
+        return chargeback;
+    }
+
+    public void setChargeback(Integer chargeback) {
+        this.chargeback = chargeback;
+    }
+
+    public Integer getMember() {
+        return member;
+    }
+
+    public void setMember(Integer member) {
+        this.member = member;
+    }
+
+    public Integer getLastSalesType() {
+        return lastSalesType;
+    }
+
+    public void setLastSalesType(Integer lastSalesType) {
+        this.lastSalesType = lastSalesType;
+    }
+
+    public Integer getLastFollowType() {
+        return lastFollowType;
+    }
+
+    public void setLastFollowType(Integer lastFollowType) {
+        this.lastFollowType = lastFollowType;
+    }
+
+    public Integer getFollowNumber() {
+        return followNumber;
+    }
+
+    public void setFollowNumber(Integer followNumber) {
+        this.followNumber = followNumber;
+    }
+
+    public String getTaskNames() {
+        return taskNames;
+    }
+
+    public void setTaskNames(String taskNames) {
+        this.taskNames = taskNames;
+    }
 }

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

@@ -493,7 +493,7 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 
-	/** 添加拜访记录
+	/** 添加拜访记录、客户跟进
 	 * @throws ParseException
 	 * @throws Exception **/
 	@RequestMapping(value = "/addFollow", method = RequestMethod.POST)

+ 7 - 0
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -692,6 +692,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		userFollow.setUid(fbb.getUid());
 		int followCount = userBusinessMapper.selectFollowCountByUAid(fbb.getUid(), null) + 1;
 		userFollow.setFollowCount(followCount);
+		//处理中间表
+		UserMid um =new UserMid();
+		um.setUid(userFollow.getUid());
+		um.setLastFollowTime(userFollow.getCreateTime());
+		um.setLastSalesType(followCount);
+		um.setLastFollowType(userFollow.getContactType());
+		userMidMapper.updateByUid(um);
 		userFollowMapper.insert(userFollow);
 		// 检查客户锁定情况
 		if (fbb.getUserBusinessList()!=null&&fbb.getUserBusinessList().size() > 0) {

+ 1 - 1
src/main/java/com/goafanti/order/controller/OrderChangeApiController.java

@@ -361,7 +361,7 @@ public class OrderChangeApiController extends CertifyApiController {
 		return res;
 	}
 	/**
-	 * 完成变更
+	 * 完成变更、完成变更
 	 */
 	@RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
 	public Result completeOrderChange(NewOrderChangeBo nb) {

+ 18 - 6
src/main/java/com/goafanti/order/service/impl/OrderChangeServiceImpl.java

@@ -109,6 +109,8 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 	private PushOrderService pushOrderService;
 	@Autowired
 	private TOrderMidMapper tOrderMidMapper;
+	@Autowired
+	private UserMidMapper userMidMapper;
 
 	Logger							logger	= LoggerFactory.getLogger(OrderChangeServiceImpl.class);
 
@@ -678,17 +680,17 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		if (nob.getType()==OrderChangeType.XMJJEBG.getCode()) {
 			o.setTotalAmount(nob.getTotalAmount());
 			//处理项目及催款
-			pushTaskAndDun(nob.getId(),nob.getOrderNo());
+			pushTaskAndDun(nob.getId(),o);
 		}else if (nob.getType()==OrderChangeType.JXMBG.getCode()) {
-			pushTaskAndDun(nob.getId(),nob.getOrderNo());
+			pushTaskAndDun(nob.getId(),o);
 		}else if (nob.getType()==OrderChangeType.JJEBG.getCode()) {
 			o.setTotalAmount(nob.getTotalAmount());
-			pushTaskAndDun(nob.getId(),nob.getOrderNo());
+			pushTaskAndDun(nob.getId(),o);
 		}else if (nob.getType()==OrderChangeType.CB.getCode()){
 			o.setTotalAmount(nob.getTotalAmount());
-			pushTaskAndDun(nob.getId(),nob.getOrderNo());
+			pushTaskAndDun(nob.getId(),o);
 		}else if (nob.getType()==OrderChangeType.ZS.getCode()) {
-			pushTaskAndDun(nob.getId(),nob.getOrderNo());
+			pushTaskAndDun(nob.getId(),o);
 		}else if(nob.getType()==OrderChangeType.TDTK.getCode()) {
 			//先将业务锁关闭
 			List<String> list=tOrderTaskMapper.getLockId(nb.getOrderNo(),o.getSalesmanId(),o.getBuyerId());
@@ -713,11 +715,16 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 			o.setProcessStatus(ProcessStatus.YPZXSGLY.getCode());
 		}
 		o.setDeleteSign(0);
+		//处理客户中间表退单标识
+		UserMid um=new UserMid();
+		um.setUid(o.getBuyerId());
+		um.setChargeback(1);
+		userMidMapper.updateByUid(um);
 		tOrderNewMapper.updateByPrimaryKeySelective(o);
 		return o;
 	}
 
-	private void pushTaskAndDun(Integer id,String orderNo) {
+	private void pushTaskAndDun(Integer id,TOrderNew o) {
 		List<TChangeTaskOut> listct=tChangeTaskMapper.selectByCid(id,null);
 		for (TChangeTaskOut cd : listct) {
 			TOrderTask ot=new TOrderTask();
@@ -744,6 +751,11 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 				tOrderTaskMapper.deleteByPrimaryKey(cd.getTid());
 			}
 		}
+		//处理客户已派项目
+		UserMid um=new UserMid();
+		String taskNames=userMidMapper.getUserTaskNames(o.getBuyerId());
+		um.setUid(o.getBuyerId());
+		um.setTaskNames(taskNames);
 		List<TChangeDunOut> listcd=tChangeDunMapper.selectByCid(id);
 		for (TChangeDunOut cd : listcd) {
 			NewOrderDun nd=new NewOrderDun();

+ 21 - 13
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -339,7 +339,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		if (StringUtils.isBlank(t.getOrderDep())) {
 			t.setOrderDep(adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getDepartmentId());
 		}
-		if (isSubmit==1) {//订单提交
+			//订单提交
+		if (isSubmit==1) {
 			if(t2.getProcessStatus()<ProcessStatus.YPYXGLY.getCode()) {
 				t.setOrderStatus(OrderNewState.QDDS.getCode());
 				t.setProcessStatus(ProcessStatus.YPYXGLY.getCode());
@@ -370,20 +371,10 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			AdminListBo a = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
 			aids.addAll(adminMapper.listNameByDepAndName(a.getDepartmentId(), "营销管理员"));
 			type=NoticeStatus.ORDER_START.getCode();
-			//如果订单金额超过10W标记为大客户
-			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);
-				}
-			}
+
 			TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(t2.getOrderNo());
 			pushGeneralSendNoticeAndEmail(aids, type,order, TokenManager.getAdminId(),t.getApproval());
+
 		}
 		if (t2.getApproval()==ApprovalNewState.BH.getCode()||
 				t2.getOrderStatus()==OrderNewState.QDSHJJ.getCode()||
@@ -429,11 +420,28 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		}
 		//判断订单是否为会员订单
 		int i =tOrderMidMapper.judgeProjectType(t.getOrderNo());
+		UserMid um=new UserMid();
+		um.setUid(t.getBuyerId());
+		um.setLastSalesType(t.getSalesType());
 		if (i>0){
 			tm.setProjectType(1);
+			um.setMember(1);
 		}else{
 			tm.setProjectType(0);
 		}
+		//如果订单金额超过10W标记为大客户
+		if(t.getTotalAmount().compareTo(new BigDecimal("10"))>=0) {
+			um.setUid(t.getBuyerId());
+			um.setAid(t.getSalesmanId());
+			um.setBigCustomer(1);
+
+		}
+		int x=userMidMapper.updateByUid(um);
+		if (x==0) {
+			um.setAid(t.getSalesmanId());
+			userMidMapper.insertSelective(um);
+		}
+		userMidMapper.updateByUid(um);
 		tm.setDepName(tOrderMidMapper.selectDepNameByDepid(t.getOrderDep()));
 		if (tm.getId()!=null) {
 			tOrderMidMapper.updateByPrimaryKeySelective(tm);

+ 7 - 0
src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java

@@ -109,6 +109,8 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	@Autowired
 	private MemberLogMapper memberLogMapper;
 	@Autowired
+	private UserMidMapper userMidMapper;
+	@Autowired
 	private AsyncUtils	asyncUtils;
 	@Value(value = "${upload.path}")
 	private String 					uploadPath 			= null;
@@ -139,6 +141,11 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 			orderNewService.pushOrderDun(t.getOrderNo());
 			//未锁定客户就锁定客户
 			pushUser(t, tn, date);
+			//处理客户已派项目
+			UserMid um=new UserMid();
+			String taskNames=userMidMapper.getUserTaskNames(tn.getBuyerId());
+			um.setUid(tn.getBuyerId());
+			um.setTaskNames(taskNames);
 		}else if(type==1) {
 			t.setManagerId(taskReceiverId);
 			t.setConsultantId(null);