Browse Source

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

anderx 3 years ago
parent
commit
243fb4470e

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

@@ -1819,6 +1819,7 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     <if test="amountStatus == 4">
       and a.total_amount  &gt; 40
     </if>
+
     order by a.create_time desc
     <if test="page_sql!=null">
       ${page_sql}
@@ -1874,6 +1875,7 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     <if test="amountStatus == 4">
       and a.total_amount  &gt; 40
     </if>
+
   </select>
 
 </mapper>

+ 112 - 28
src/main/java/com/goafanti/common/mapper/UserMidMapper.xml

@@ -540,43 +540,43 @@
   </select>
 
   <select id="selectsignStatisticsList" resultType="com.goafanti.order.bo.OutSignStatistics">
-    select x.id, name, counts, totalAmount, newSignNumber, repeatSignNumber, channelSignNumber,
-    (newSignNumber/counts)newRatio,(repeatSignNumber/counts)repeatRatio,(newSignNumber/counts)channelRatio
-    from( select a.id,a.name ,sum(x.counts)counts ,sum(x.totalAmount)totalAmount,sum(x.newSignNumber)newSignNumber,
-    sum(x.repeatSignNumber)repeatSignNumber,sum(x.channelSignNumber)channelSignNumber
+    select a.id, a.name,y.aid, userCount, orderCount, totalAmount, newSignNumber, repeatSignNumber, channelSignNumber,
+    (newSignNumber/orderCount)newRatio,(repeatSignNumber/orderCount)repeatRatio,(newSignNumber/orderCount)channelRatio
     from  admin a
     left join user_role ur on ur.uid =a.id left join `role` r on r.id=ur.rid
-    left join ( select b.aid,count(*)counts,sum(a.total_amount) totalAmount ,
+    left join ( select x.aid,count(id) userCount, sum(x.orderCount)orderCount,sum(x.totalAmount)totalAmount,
+    sum(x.newSignNumber)newSignNumber,sum(x.repeatSignNumber)repeatSignNumber,
+    sum(x.channelSignNumber)channelSignNumber
+    from ( select b.aid,b.id,count(*)orderCount ,sum(a.total_amount) totalAmount ,
     sum(if(a.sales_type &lt; 3 || (a.sales_type &gt; 3 &amp;&amp; a.sales_type &lt; 6),1,0 ))newSignNumber,
-    sum(if(a.sales_type=3,1,0 ))repeatSignNumber,sum(if(a.sales_type &gt; 5,1,0 ))channelSignNumber
+    sum(if(a.sales_type=3,1,0 ))channelSignNumber,sum(if(a.sales_type &gt; 5,1,0 ))repeatSignNumber
     from t_order_new a left join user b on b.id=a.buyer_id
-    where a.process_status &lt;4 and b.share_type =2
-  <if test="amountType != null">
-    <if test="amountType == 1">
-      and  a.total_amount &lt; 10
-    </if>
-    <if test="amountType == 2">
-      and  a.total_amount BETWEEN 10 and 20
-    </if>
-    <if test="amountType == 3">
-      and  a.total_amount BETWEEN 20 and 30
+    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">
+        and  a.total_amount &lt; 10
+      </if>
+      <if test="amountType == 2">
+        and  a.total_amount BETWEEN 10 and 20
+      </if>
+      <if test="amountType == 3">
+        and  a.total_amount BETWEEN 20 and 30
+      </if>
+      <if test="amountType == 4">
+        and  a.total_amount &gt; 30
+      </if>
     </if>
-    <if test="amountType == 4">
-      and  a.total_amount &gt; 30
+    <if test="signTimeStart != null and signTimeEnd!=null">
+      and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
     </if>
-  </if>
-  <if test="signTimeStart != null and signTimeEnd!=null">
-    and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
-  </if>
-    group by b.aid)x on x.aid=a.id
+    group by b.aid,b.id)x group by x.aid)y on y.aid=a.id
     where r.role_type in (96,996)
-  <if test="aid != null">
-    and a.id= #{aid}
-  </if>
+    <if test="aid != null">
+      and a.id= #{aid}
+    </if>
     <if test="depId != null">
-    and a.department_id = #{depId}
+      and a.department_id = #{depId}
     </if>
-    group by a.id,a.name)x
     <if test="page_sql!=null">
       ${page_sql}
     </if>
@@ -594,4 +594,88 @@
     </if>
     group by a.id,a.name)x
   </select>
+
+  <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
+    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
+    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">
+        and  a.total_amount &lt; 10
+      </if>
+      <if test="amountType == 2">
+        and  a.total_amount BETWEEN 10 and 20
+      </if>
+      <if test="amountType == 3">
+        and  a.total_amount BETWEEN 20 and 30
+      </if>
+      <if test="amountType == 4">
+        and  a.total_amount &gt; 30
+      </if>
+    </if>
+    <if test="signTimeStart != null and signTimeEnd!=null">
+      and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
+    </if>
+    <if test="aid !=null">
+      and  b.aid= #{aid}
+    </if>
+    <if test="orderType !=null">
+      <if test="orderType ==1">
+        and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
+      </if>
+      <if test="orderType ==2">
+        and a.sales_type &gt; 5
+      </if>
+      <if test="orderType ==3">
+        and a.sales_type=3
+      </if>
+    </if>
+    order by a.create_time desc
+    <if test="page_sql!=null">
+      ${page_sql}
+    </if>
+  </select>
+
+  <select id="selectsignStatisticsOrderCount" resultType="integer">
+    select count(*)
+    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
+    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">
+        and  a.total_amount &lt; 10
+      </if>
+      <if test="amountType == 2">
+        and  a.total_amount BETWEEN 10 and 20
+      </if>
+      <if test="amountType == 3">
+        and  a.total_amount BETWEEN 20 and 30
+      </if>
+      <if test="amountType == 4">
+        and  a.total_amount &gt; 30
+      </if>
+    </if>
+    <if test="signTimeStart != null and signTimeEnd!=null">
+      and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
+    </if>
+    <if test="aid !=null">
+      and  b.aid= #{aid}
+    </if>
+    <if test="orderType !=null">
+      <if test="orderType ==1">
+        and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
+      </if>
+      <if test="orderType ==2">
+        and a.sales_type &gt; 5
+      </if>
+      <if test="orderType ==3">
+        and a.sales_type=3
+      </if>
+    </if>
+  </select>
 </mapper>

+ 9 - 0
src/main/java/com/goafanti/order/bo/InputSignStatistics.java

@@ -8,9 +8,18 @@ public class InputSignStatistics {
     private String signTimeStart;
     private String signTimeEnd;
 
+    private Integer orderType;
     private Integer pageSize;
     private Integer pageNo;
 
+    public Integer getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(Integer orderType) {
+        this.orderType = orderType;
+    }
+
     public String getDepId() {
         return depId;
     }

+ 20 - 10
src/main/java/com/goafanti/order/bo/OutSignStatistics.java

@@ -6,7 +6,8 @@ public class OutSignStatistics {
 
     private String id;
     private String name;
-    private Integer counts;
+    private Integer userCount;
+    private Integer orderCount;
     private BigDecimal totalAmount;
     private Integer newSignNumber;
     private Integer repeatSignNumber;
@@ -15,6 +16,24 @@ public class OutSignStatistics {
     private BigDecimal repeatRatio;
     private BigDecimal channelRatio;
 
+    public Integer getUserCount() {
+        if (userCount == null) return 0;
+        return userCount;
+    }
+
+    public void setUserCount(Integer userCount) {
+        this.userCount = userCount;
+    }
+
+    public Integer getOrderCount() {
+        if (orderCount == null) return 0;
+        return orderCount;
+    }
+
+    public void setOrderCount(Integer orderCount) {
+        this.orderCount = orderCount;
+    }
+
     public BigDecimal getNewRatio() {
         return newRatio;
     }
@@ -55,15 +74,6 @@ public class OutSignStatistics {
         this.name = name;
     }
 
-    public Integer getCounts() {
-        if (counts == null) return 0;
-        return counts;
-    }
-
-    public void setCounts(Integer counts) {
-        this.counts = counts;
-    }
-
     public BigDecimal getTotalAmount() {
         if (totalAmount == null) return new BigDecimal(0);
         return totalAmount;

+ 12 - 0
src/main/java/com/goafanti/order/controller/StatisticsApiController.java

@@ -135,5 +135,17 @@ public class StatisticsApiController extends CertifyApiController {
 		return res;
 	}
 
+	/**
+	 * 销售来源订单列表
+	 * @param in
+	 * @return
+	 */
+	@RequestMapping(value="/signStatistics/orderList", method = RequestMethod.GET)
+	public Result orderNewList(InputSignStatistics in ){
+		Result res=new Result();
+		res.data(userStaticticsService.signStatisticsOrderList(in));
+		return res;
+	}
+
 
 }

+ 3 - 4
src/main/java/com/goafanti/order/service/UserStaticticsService.java

@@ -1,10 +1,7 @@
 package com.goafanti.order.service;
 
 import com.goafanti.core.mybatis.page.Pagination;
-import com.goafanti.order.bo.InputSignStatistics;
-import com.goafanti.order.bo.InputSignSummary;
-import com.goafanti.order.bo.OutSignStatistics;
-import com.goafanti.order.bo.OutSignSummary;
+import com.goafanti.order.bo.*;
 
 import java.util.List;
 
@@ -15,4 +12,6 @@ public interface UserStaticticsService {
     List<OutSignSummary> signSummaryList(InputSignSummary in);
 
     Pagination<OutSignStatistics> signStatistics(InputSignStatistics in);
+
+    Pagination<TOrderNewBo> signStatisticsOrderList(InputSignStatistics in);
 }

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

@@ -635,6 +635,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		if (in.getDepId()!=null)params.put("depId",in.getDepId());
 
 
+
 		Pagination<TOrderNewBo> p = (Pagination<TOrderNewBo>)findPage("selectstatisticsOrderListPage",
 				"selectstatisticsOrderListCount", params, in.getPageNo(), in.getPageSize());
 		return p;

+ 12 - 0
src/main/java/com/goafanti/order/service/impl/UserStatisticsServiceImpl.java

@@ -60,11 +60,23 @@ public class UserStatisticsServiceImpl extends BaseMybatisDao<UserMidMapper> imp
 		return (Pagination<OutSignStatistics>) findPage("selectsignStatisticsList","selectsignStatisticsCount",map,in.getPageNo(),in.getPageSize());
 	}
 
+
+
 	private void addsignStatisticsParam(InputSignStatistics in, Map<String, Object> map) {
 		if (in.getDepId()!=null)map.put("depId",in.getDepId());
 		if (in.getAid()!=null)map.put("aid",in.getAid());
 		if (in.getAmountType()!=null)map.put("amountType",in.getAmountType());
 		if (in.getSignTimeStart()!=null)map.put("signTimeStart",in.getSignTimeStart());
 		if (in.getSignTimeEnd()!=null)map.put("signTimeEnd",in.getSignTimeEnd()+" 23:59:59");
+		if (in.getOrderType()!=null)map.put("orderType",in.getOrderType());
 	}
+
+	@Override
+	public Pagination<TOrderNewBo> signStatisticsOrderList(InputSignStatistics in) {
+		Map<String, Object> map = new HashMap<>();
+		addsignStatisticsParam(in, map);
+		return (Pagination<TOrderNewBo>) findPage("selectsignStatisticsOrderList","selectsignStatisticsOrderCount",map,in.getPageNo(),in.getPageSize());
+	}
+
 }
+