Просмотр исходного кода

销售来源列表与导出按金额统计开发

anderx лет назад: 3
Родитель
Сommit
9b7118e06f

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

@@ -3,6 +3,7 @@ package com.goafanti.common.dao;
 import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.order.bo.*;
+import com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -56,6 +57,8 @@ public interface TOrderNewMapper {
 
     List<OutOrderSalesSource> orderSalesSource(InputOrderSalesSource in);
 
+    List<OutOrderSalesSourceAmount> orderSalesSourceAmount(InputOrderSalesSource in);
+
     TOrderNew  checkOrderProcessStatus(Integer tid);
 
     List<TOrderNew> selectgetAll();

+ 35 - 6
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -1839,6 +1839,40 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     from t_order_new  where delete_sign in (0,2) and  buyer_id = #{uid}
     order by create_time desc
   </select>
+  <select id="orderSalesSourceAmount" resultType="com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount">
+    select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,
+        y.dhxkf/y.total_amount dhxkfl, y.dhzdzy,y.dhzdzy/y.total_amount dhzdzyl,y.wl,y.wl/y.total_amount wll,
+    y.qd,y.qd/y.total_amount qdl,y.zjs,y.zjs/y.total_amount zjsl,y.qt,y.qt/y.total_amount qtl,
+    y.gxfg,y.gxfg/y.total_amount gxfgl,y.qtfg,y.qtfg/y.total_amount qtfgl
+    from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
+    sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
+    sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
+      from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
+      case a.sales_type when 0 then a.total_amount else 0 end dhxkf,
+      case a.sales_type when 1 then a.total_amount else 0 end dhzdzy,
+      case a.sales_type when 2 then a.total_amount else 0 end wl,
+      case a.sales_type when 3 then a.total_amount else 0 end qd,
+      case a.sales_type when 4 then a.total_amount else 0 end zjs,
+      case a.sales_type when 5 then a.total_amount else 0 end qt,
+      case a.sales_type when 6 then a.total_amount else 0 end gxfg,
+      case a.sales_type when 7 then a.total_amount else 0 end qtfg
+    from t_order_new a left join department b on a.order_dep =b.id
+    where a.delete_sign in (0,2) and a.process_status  &gt; 0  and a.approval in (0,1,2)
+    <if test=" startDate !=null and endDate != null">
+      and a.create_time between #{startDate} and #{endDate}
+    </if>
+    <if test=" deps !=null">
+      and a.order_dep in
+      <foreach close=")" collection="listDep" item="depId" open="(" separator=",">
+        #{depId}
+      </foreach>
+    </if>
+    <if test=" province !=null">
+      and b.province = #{province}
+    </if>
+    )x group by x.province)y left join district_glossory dg on y.province=dg.id
+      order by y.total_amount desc
+  </select>
   <select id="orderSalesSource" resultType="com.goafanti.order.bo.OutOrderSalesSource">
     select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,y.dhxkf/y.counts dhxkfl,
     y.dhzdzy,y.dhzdzy/y.counts dhzdzyl,y.wl,y.wl/y.counts wll,
@@ -1871,12 +1905,7 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
       and b.province = #{province}
     </if>
     )x group by x.province)y left join district_glossory dg on y.province=dg.id
-    <if test=" sort ==0">
-      order by y.total_amount desc
-    </if>
-    <if test=" sort ==1">
-      order by y.counts desc
-    </if>
+    order by y.counts desc
   </select>
 
   <select id="selectstatisticsOrderListPage" resultType="com.goafanti.order.bo.TOrderNewBo">

+ 7 - 1
src/main/java/com/goafanti/common/utils/excel/NewExcelUtil.java

@@ -461,6 +461,8 @@ public class NewExcelUtil<T> {
 		return cell;
 	}
 
+
+
 	/**
 	 * 设置单元格信息
 	 *
@@ -473,7 +475,11 @@ public class NewExcelUtil<T> {
 			if (attr.percentage()==1){
 				if (value!=null){
 					BigDecimal v=new BigDecimal(value.toString());
-					value=v.multiply(new BigDecimal(100)).stripTrailingZeros().toPlainString()+"%";
+					v=v.multiply(new BigDecimal(100));
+					if (attr.scale()>0){
+					v=v.setScale(attr.scale(),BigDecimal.ROUND_HALF_EVEN);
+					}
+					value=v.stripTrailingZeros().toPlainString()+"%";
 				}else {
 					value="0%";
 				}

+ 8 - 8
src/main/java/com/goafanti/order/bo/outStatistics/OutOrderSalesSourceAmount.java

@@ -14,35 +14,35 @@ public class OutOrderSalesSourceAmount {
     private Integer counts;
     @Excel(name = "电话新开发",width = 10)
     private BigDecimal dhxkf;
-    @Excel(name = "电话新开发占比",percentage = 1,width = 10)
+    @Excel(name = "电话新开发占比",percentage = 1,width = 10,scale = 2)
     private String dhxkfl;
     @Excel(name = "电话自带资源",width = 10)
     private BigDecimal dhzdzy;
-    @Excel(name = "电话自带资源占比",percentage = 1,width = 10)
+    @Excel(name = "电话自带资源占比",percentage = 1,width = 10,scale = 2)
     private String dhzdzyl;
     @Excel(name = "网络",width = 10)
     private BigDecimal wl;
-    @Excel(name = "网络占比",percentage = 1,width = 10)
+    @Excel(name = "网络占比",percentage = 1,width = 10,scale = 2)
     private String wll;
     @Excel(name = "渠道",width = 10)
     private BigDecimal qd;
-    @Excel(name = "渠道占比",percentage = 1,width = 10)
+    @Excel(name = "渠道占比",percentage = 1,width = 10,scale = 2)
     private String qdl;
     @Excel(name = "转介绍",width = 10)
     private BigDecimal zjs;
-    @Excel(name = "转介绍占比",percentage = 1,width = 10)
+    @Excel(name = "转介绍占比",percentage = 1,width = 10,scale = 2)
     private String zjsl;
     @Excel(name = "其他",width = 10)
     private BigDecimal qt;
-    @Excel(name = "其他占比",percentage = 1,width = 10)
+    @Excel(name = "其他占比",percentage = 1,width = 10,scale = 2)
     private String qtl;
     @Excel(name = "高新复购",width = 10)
     private BigDecimal gxfg;
-    @Excel(name = "高新复购占比",percentage = 1,width = 10)
+    @Excel(name = "高新复购占比",percentage = 1,width = 10,scale = 2)
     private String gxfgl;
     @Excel(name = "其他复购",width = 10)
     private BigDecimal qtfg;
-    @Excel(name = "其他复购占比",percentage = 1,width = 10)
+    @Excel(name = "其他复购占比",percentage = 1,width = 10,scale = 2)
     private String qtfgl;
 
     public Integer getProvince() {

+ 10 - 1
src/main/java/com/goafanti/order/service/impl/OrderStatisticsServiceImpl.java

@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSON;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.order.bo.*;
+import com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount;
 import com.goafanti.order.service.OrderStatisticsService;
 import groovy.util.logging.Log4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 @Service
@@ -25,7 +27,14 @@ public class OrderStatisticsServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 			List<String> ls= JSON.parseArray(in.getDeps(),String.class);
 			in.setListDep(ls);
 		}
-		return tOrderNewMapper.orderSalesSource(in);
+		if (in.getSort()==0){
+			List<OutOrderSalesSource> outOrderSalesSources = tOrderNewMapper.orderSalesSource(in);
+			return outOrderSalesSources;
+		}else if (in.getSort()==1){
+			List<OutOrderSalesSourceAmount> outOrderSalesSources = tOrderNewMapper.orderSalesSourceAmount(in);
+			return outOrderSalesSources;
+		}
+		return null;
 	}
 
 }