Browse Source

新增客户最后跟进列表新增筛选项

anderx 2 years ago
parent
commit
a6af5e40f7

+ 47 - 38
src/main/java/com/goafanti/common/mapper/UserMidMapper.xml

@@ -27,12 +27,13 @@
     <result column="follow_explain" jdbcType="VARCHAR" property="followExplain" />
     <result column="follow_aname" jdbcType="VARCHAR" property="followAname" />
     <result column="follow_aid" jdbcType="VARCHAR" property="followAid" />
+    <result column="aname" jdbcType="VARCHAR" property="aname" />
   </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, chargeback, `member`, last_sales_type,
     last_follow_type, follow_number, task_names, sign_number, sign_amount, last_signing_time,
-    first_signing_time, follow_dep, follow_explain, follow_aname, follow_aid
+    first_signing_time, follow_dep, follow_explain, follow_aname, follow_aid, aname
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -44,32 +45,29 @@
     delete from user_mid
     where id = #{id,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" parameterType="com.goafanti.common.model.UserMid">
-    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, chargeback,
-      `member`, last_sales_type, last_follow_type,
-      follow_number, task_names, sign_number,
-      sign_amount, last_signing_time, first_signing_time,
-      follow_dep, follow_explain, follow_aname,
-      follow_aid)
-    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}, #{chargeback,jdbcType=INTEGER},
-      #{member,jdbcType=INTEGER}, #{lastSalesType,jdbcType=INTEGER}, #{lastFollowType,jdbcType=INTEGER},
-      #{followNumber,jdbcType=INTEGER}, #{taskNames,jdbcType=VARCHAR}, #{signNumber,jdbcType=INTEGER},
-      #{signAmount,jdbcType=DECIMAL}, #{lastSigningTime,jdbcType=DATE}, #{firstSigningTime,jdbcType=DATE},
-      #{followDep,jdbcType=VARCHAR}, #{followExplain,jdbcType=VARCHAR}, #{followAname,jdbcType=VARCHAR},
-      #{followAid,jdbcType=VARCHAR})
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserMid" useGeneratedKeys="true">
+    insert into user_mid (`uid`, aid, last_follow_time,
+      last_sign_time, create_time, big_customer,
+      update_aid, update_name, date_update_time,
+      channel_type, chargeback, `member`,
+      last_sales_type, last_follow_type, follow_number,
+      task_names, sign_number, sign_amount,
+      last_signing_time, first_signing_time, follow_dep,
+      follow_explain, follow_aname, follow_aid,
+      aname)
+    values (#{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}, #{chargeback,jdbcType=INTEGER}, #{member,jdbcType=INTEGER},
+      #{lastSalesType,jdbcType=INTEGER}, #{lastFollowType,jdbcType=INTEGER}, #{followNumber,jdbcType=INTEGER},
+      #{taskNames,jdbcType=VARCHAR}, #{signNumber,jdbcType=INTEGER}, #{signAmount,jdbcType=DECIMAL},
+      #{lastSigningTime,jdbcType=DATE}, #{firstSigningTime,jdbcType=DATE}, #{followDep,jdbcType=VARCHAR},
+      #{followExplain,jdbcType=VARCHAR}, #{followAname,jdbcType=VARCHAR}, #{followAid,jdbcType=VARCHAR},
+      #{aname,jdbcType=VARCHAR})
   </insert>
-  <insert id="insertSelective" parameterType="com.goafanti.common.model.UserMid">
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserMid" useGeneratedKeys="true">
     insert into user_mid
     <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        id,
-      </if>
       <if test="uid != null">
         `uid`,
       </if>
@@ -142,11 +140,11 @@
       <if test="followAid != null">
         follow_aid,
       </if>
+      <if test="aname != null">
+        aname,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=INTEGER},
-      </if>
       <if test="uid != null">
         #{uid,jdbcType=VARCHAR},
       </if>
@@ -219,6 +217,9 @@
       <if test="followAid != null">
         #{followAid,jdbcType=VARCHAR},
       </if>
+      <if test="aname != null">
+        #{aname,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserMid">
@@ -296,6 +297,9 @@
       <if test="followAid != null">
         follow_aid = #{followAid,jdbcType=VARCHAR},
       </if>
+      <if test="aname != null">
+        aname = #{aname,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -324,10 +328,12 @@
       follow_dep = #{followDep,jdbcType=VARCHAR},
       follow_explain = #{followExplain,jdbcType=VARCHAR},
       follow_aname = #{followAname,jdbcType=VARCHAR},
-      follow_aid = #{followAid,jdbcType=VARCHAR}
+      follow_aid = #{followAid,jdbcType=VARCHAR},
+      aname = #{aname,jdbcType=VARCHAR}
     where id = #{id,jdbcType=INTEGER}
   </update>
 
+
   <update id="updateByUid" parameterType="com.goafanti.common.model.UserMid">
     update user_mid
     <set>
@@ -400,6 +406,9 @@
       <if test="followAid != null">
         follow_aid = #{followAid,jdbcType=VARCHAR},
       </if>
+      <if test="aname != null">
+        aname = #{aname,jdbcType=VARCHAR},
+      </if>
     </set>
     where `uid` = #{uid,jdbcType=VARCHAR}
   </update>
@@ -441,7 +450,7 @@
 
   <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
+                                                                    left join t_order_task b on a.order_no =b.order_no
     where a.buyer_id = #{uid}
     group by  a.buyer_id
   </select>
@@ -450,7 +459,7 @@
            sum(a.total_amount)signAmount,count(*)signNumber
     from t_order_new a
     where a.delete_sign in (0,2) and a.process_status >4
-    and a.buyer_id= #{uid}
+      and a.buyer_id= #{uid}
     group by a.buyer_id
   </select>
 
@@ -465,9 +474,9 @@
     from user a left join user_mid b on a.id=b.uid  left join admin c on a.aid=c.id
     left join department d on c.department_id =d.id
     where a.share_type =2
-      <if test="userName != null">
-        and a.nickname like concat('%',#{userName},'%')
-      </if>
+    <if test="userName != null">
+      and a.nickname like concat('%',#{userName},'%')
+    </if>
     <if test="aid != null">
       and c.id =#{aid}
     </if>
@@ -634,12 +643,12 @@
 
   <select id="selectsignStatisticsOrderList" resultType="com.goafanti.order.bo.TOrderNewBo">
     select a.order_no as orderNo,a.create_time as createTime, date_format(a.sign_time,'%Y-%m-%d' ) as signDate,a.delete_sign deleteSign,
-           a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
-           a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
-           dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
-           a.sales_type salesType, a.channel_id channelId ,a.other
+    a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
+    a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
+    dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
+    a.sales_type salesType, a.channel_id channelId ,a.other
     from t_order_new a  left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
-                        left join department dep on a.order_dep=dep.id
+    left join department dep on a.order_dep=dep.id
     where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
     <if test="amountType != null">
       <if test="amountType == 1">

+ 14 - 1
src/main/java/com/goafanti/common/model/UserMid.java

@@ -60,7 +60,7 @@ public class UserMid implements Serializable {
     private Date dateUpdateTime;
 
     /**
-     * 渠道类别 1=政府部门,2=民主党派3=园区,4=民间组织,5=其他战略合作单位
+     * 渠道类别 1=其他,2=民主党派3=园区,4=民间组织,5=战略合作单位
      */
     private Integer channelType;
 
@@ -134,6 +134,11 @@ public class UserMid implements Serializable {
      */
     private String followAid;
 
+    /**
+     * 管理员名称
+     */
+    private String aname;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -335,4 +340,12 @@ public class UserMid implements Serializable {
     public void setFollowAid(String followAid) {
         this.followAid = followAid;
     }
+
+    public String getAname() {
+        return aname;
+    }
+
+    public void setAname(String aname) {
+        this.aname = aname;
+    }
 }

+ 5 - 3
src/main/java/com/goafanti/common/utils/DateUtils.java

@@ -520,9 +520,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 	 */
 	public static Integer sumDays(String dates) {
 		Date date = StringToDate(dates, AFTConstants.YYYYMMDDHHMMSS);
-		Date now=getEarlyToday();
-
-		int days=(int)(now.getTime()-date.getTime())/(1000*3600*24);
+		Date now=new Date();
+//		long sum=now.getTime()-date.getTime();
+//		long one =60*60*24*1000;
+//		int days= Math.toIntExact(sum / one);
+		int days=(int)((now.getTime()-date.getTime())/(1000*3600*24));
 		return days;
 	}
 }

+ 6 - 1
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -367,6 +367,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		if(in.getNewChannel()!=null)user.setNewChannel(in.getNewChannel());
 		user.setChannel(0);
 		passwordUtil.encryptPassword(user);
+		String aname = adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getName();
 		if (in.getType() == UserType.PERSONAL.getCode()) {
 			if (userMapper.checkUser("", "", in.getContactMobile(), in.getType(), null, null).size() > 0)
 				throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_EXIST, in.getName(), ""));
@@ -389,6 +390,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			UserMid um=new UserMid();
 			um.setAid(user.getAid());
 			um.setUid(uid);
+			um.setAname(aname);
 			um.setChannelType(in.getChannelType());
 			userMidMapper.insertSelective(um);
 			// 创建企业认证信息
@@ -424,7 +426,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		// 新增企业联系人
 		OrganizationContactBook cob = new OrganizationContactBook();
 		cob.setAid(TokenManager.getAdminId());
-		cob.setAname(adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getName());
+		cob.setAname(aname);
 		cob.setId(UUID.randomUUID().toString());
 		cob.setPosition(in.getPosition());
 		cob.setUid(uid);
@@ -577,6 +579,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		int i=userMidMapper.updateByUid(um);
 		if (i==0) {
 			um.setAid(aid);
+			um.setAname(a.getName());
 			userMidMapper.insertSelective(um);
 		}
 		StringBuffer str=new StringBuffer(a.getName()).append("修改了主营产品");
@@ -880,6 +883,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		um.setLastFollowTime(date);
 		int x=userMidMapper.updateByUid(um);
 		if (x==0){
+			Admin admin = adminMapper.selectByPrimaryKey(aid);
+			um.setAname(admin.getName());
 			userMidMapper.insertSelective(um);
 		}
 	}

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

@@ -615,6 +615,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			int x=userMidMapper.updateByUid(um);
 			if (x==0) {
 				um.setAid(t.getSalesmanId());
+				Admin salesman = adminMapper.selectByPrimaryKey(t.getSalesmanId());
+				um.setAname(salesman.getName());
 				userMidMapper.insertSelective(um);
 			}
 		}