Browse Source

科德系统渠道模块开发

anderx 3 years ago
parent
commit
214259cb04

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

@@ -53,4 +53,6 @@ public interface TOrderNewMapper {
     List<outProvinceStatisticsList> provinceStatisticsList(InputStatistics in);
 
     List<Map<String, Object>> selectOrderByuid(String uid);
+
+    List<OutOrderSalesSource> orderSalesSource(InputOrderSalesSource in);
 }

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

@@ -877,8 +877,9 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	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
-  	<if test="specially == 2">
+  	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
+    <if test="specially == 2">
   	,f.name as initiateName ,e.reason ,date_format(e.create_time,'%Y-%m-%d' ) as backDate,e.id as backId
   	</if>
   	<if test="specially == 4">
@@ -1604,4 +1605,38 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
       select order_no orderNo,contract_no contractNo
       from t_order_new  where delete_sign in (0,2) and  buyer_id = #{uid}
     </select>
+  <select id="orderSalesSource" resultType="com.goafanti.order.bo.OutOrderSalesSource">
+    select y.province,dg.name ,y.total_amount,y.counts,y.dh,y.dh/y.counts dhl,y.wl,y.wl/y.counts wll,
+    y.qd,y.qd/y.counts qdl,y.zjs,y.zjs/y.counts zjsl,y.qt,y.qt/y.counts qtl,
+    y.gxfg,y.gxfg/y.counts gxfgl,y.qtfg,y.qtfg/y.counts qtfgl
+    from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
+    sum(x.dh)dh,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 a.order_no ,a.order_dep ,b.province ,1 counts,a.total_amount,a.sales_type ,
+    case a.sales_type when 0 then 1 when 1 then 1 else 0 end dh,
+    case a.sales_type when 2 then 1 else 0 end wl,
+    case a.sales_type when 3 then 1 else 0 end qd,
+    case a.sales_type when 4 then 1 else 0 end zjs,
+    case a.sales_type when 5 then 1 else 0 end qt,
+    case a.sales_type when 6 then 1 else 0 end gxfg,
+    case a.sales_type when 7 then 1 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; 4
+    <if test=" startDate !=null and endDate != null">
+      and a.create_time between #{startDate} and #{endDate}
+    </if>
+    <if test=" depId !=null">
+      and a.order_dep= #{depId}
+    </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
+    <if test=" sort ==0">
+    order by y.total_amount
+    </if>
+    <if test=" sort ==1">
+    order by y.counts
+    </if>
+  </select>
 </mapper>

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

@@ -2209,7 +2209,7 @@ inner join(
 			and a.new_channel = #{newChannel}
 		</if>
 		<if test=" name !=null ">
-		and a.nickname = #{name}
+		and a.nickname like concat ('%',#{name},'%')
 		</if>
 		<if test=" aid !=null ">
 		and a.aid= #{aid}
@@ -2247,7 +2247,7 @@ inner join(
 			and a.new_channel = #{newChannel}
 		</if>
 		<if test=" name !=null ">
-			and a.nickname = #{name}
+			and a.nickname like concat ('%',#{name},'%')
 		</if>
 		<if test=" aid !=null ">
 			and a.aid= #{aid}

+ 7 - 0
src/main/java/com/goafanti/customer/bo/OutChannelListBo.java

@@ -4,6 +4,7 @@ public class OutChannelListBo {
 
     private String id;
     private String name;
+    private String aName;
     /** 省 **/
     private String province;
 
@@ -108,5 +109,11 @@ public class OutChannelListBo {
         this.lastFollowTime = lastFollowTime;
     }
 
+    public String getaName() {
+        return aName;
+    }
 
+    public void setaName(String aName) {
+        this.aName = aName;
+    }
 }

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

@@ -138,13 +138,14 @@ public class AdminCustomerApiController extends BaseApiController{
 	}
 
 	/**
-	 *  渠道客户列表
+	 *  私有渠道客户列表
 	 *
 	 **/
 	@RequestMapping(value = "/channelUserList" , method = RequestMethod.GET)
 	public Result channelUserList(InputChannelListBo in ){
 		Result res = new Result();
 		in.setNewChannel(1);
+		in.setShareType(0);
 		if (StringUtils.isBlank(in.getAid())){
 			in.setAid(TokenManager.getAdminId());
 		}
@@ -153,7 +154,7 @@ public class AdminCustomerApiController extends BaseApiController{
 	}
 
 	/**
-	 *  渠道客户列表
+	 *  公共渠道客户列表
 	 *
 	 **/
 	@RequestMapping(value = "/publicChannelUserList" , method = RequestMethod.GET)
@@ -166,6 +167,22 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 
+	/**
+	 *  渠道客户查询
+	 *
+	 **/
+	@RequestMapping(value = "/selectChannelUserList" , method = RequestMethod.GET)
+	public Result selectChannelUserList(InputChannelListBo in ){
+		Result res = new Result();
+		in.setNewChannel(1);
+		if (in.getName()==null||in.getName().length()<2){
+			res.getError().add(buildError("搜索名字必须大于2个字符"));
+			return res;
+		}
+		res.setData(customerService.selectChannelUserList(in));
+		return res;
+	}
+
 
 
 	/** 跟进管理列表

+ 2 - 0
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -541,4 +541,6 @@ public interface CustomerService {
     int updateUserDate(String uid,Integer province, Integer city, Integer area, String businessScope, String intendedProject);
 
 	Pagination<OutChannelListBo> channelUserList(InputChannelListBo in);
+
+    List<?> selectChannelUserList(InputChannelListBo in);
 }

+ 25 - 17
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -2387,23 +2387,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	@Override
 	public Pagination<OutChannelListBo> channelUserList(InputChannelListBo in) {
 		Map<String, Object> params = new HashMap<>();
-		if (StringUtils.isNotBlank(in.getName()))params.put("name",in.getName());
-		if (StringUtils.isNotBlank(in.getStartDate()))params.put("startDate",in.getStartDate());
-		if (StringUtils.isNotBlank(in.getEndDate()))params.put("endDate",in.getEndDate()+" 23:59:59");
-		if (null!=in.getProvince())params.put("province",in.getProvince());
-		if (null!=in.getArea())params.put("area",in.getArea());
-		if (null!=in.getCity())params.put("city",in.getCity());
-		if (null!=in.getType())params.put("type",in.getType());
-		if (null==in.getShareType()){
-			params.put("shareType",0);
-		}else{
-			params.put("shareType",in.getShareType());
-		}
-		if (null == in.getNewChannel()){
-			params.put("newChannel",1);
-		}else {
-			params.put("newChannel",in.getNewChannel());
-		}
+		addParams(in, params);
 		Pagination<OutChannelListBo> p = (Pagination<OutChannelListBo>) findPage(
 				"channelUserList", "channelUserCout", params, in.getPageNo(),
 				in.getPageSize());
@@ -2418,6 +2402,30 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	/**
+	 * 组装参数
+	 * @param in
+	 * @param params
+	 */
+	private void addParams(InputChannelListBo in, Map<String, Object> params) {
+		if (StringUtils.isNotBlank(in.getName())) params.put("name", in.getName());
+		if (StringUtils.isNotBlank(in.getStartDate())) params.put("startDate", in.getStartDate());
+		if (StringUtils.isNotBlank(in.getEndDate())) params.put("endDate", in.getEndDate()+" 23:59:59");
+		if (null!= in.getProvince()) params.put("province", in.getProvince());
+		if (null!= in.getArea()) params.put("area", in.getArea());
+		if (null!= in.getCity()) params.put("city", in.getCity());
+		if (null!= in.getType()) params.put("type", in.getType());
+		if (null!= in.getShareType()) params.put("shareType", in.getShareType());
+		if (null != in.getNewChannel())params.put("newChannel", in.getNewChannel());
+	}
+
+	@Override
+	public List<OutChannelListBo> selectChannelUserList(InputChannelListBo in) {
+		Map<String, Object> params = new HashMap<>();
+		addParams(in, params);
+		return (List<OutChannelListBo>) findList("channelUserList",params,1,9999);
+	}
+
+	/**
 	 * 根据您 初始时间、最后跟进时间当前时间计算剩余天数
 	 * @param out
 	 * @return

+ 53 - 0
src/main/java/com/goafanti/order/bo/InputOrderSalesSource.java

@@ -0,0 +1,53 @@
+package com.goafanti.order.bo;
+
+public class InputOrderSalesSource {
+
+    private String startDate;
+    private String endDate;
+    private String depId;
+    private Integer province;
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    public String getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(String startDate) {
+        this.startDate = startDate;
+    }
+
+    public String getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(String endDate) {
+        this.endDate = endDate;
+    }
+
+    public String getDepId() {
+        return depId;
+    }
+
+    public void setDepId(String depId) {
+        this.depId = depId;
+    }
+
+    public Integer getProvince() {
+        return province;
+    }
+
+    public void setProvince(Integer province) {
+        this.province = province;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+}

+ 168 - 0
src/main/java/com/goafanti/order/bo/OutOrderSalesSource.java

@@ -0,0 +1,168 @@
+package com.goafanti.order.bo;
+
+import java.math.BigDecimal;
+
+public class OutOrderSalesSource {
+    private Integer province;
+    private String name;
+    private BigDecimal total_amount;
+    private Integer counts;
+    private Integer dh;
+    private String dhl;
+    private Integer wl;
+    private String wll;
+    private Integer qd;
+    private String qdl;
+    private Integer zjs;
+    private String zjsl;
+    private Integer qt;
+    private String qtl;
+    private Integer gxfg;
+    private String gxfgl;
+    private Integer qtfg;
+    private String qtfgl;
+
+    public Integer getProvince() {
+        return province;
+    }
+
+    public void setProvince(Integer province) {
+        this.province = province;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public BigDecimal getTotal_amount() {
+        return total_amount;
+    }
+
+    public void setTotal_amount(BigDecimal total_amount) {
+        this.total_amount = total_amount;
+    }
+
+    public Integer getCounts() {
+        return counts;
+    }
+
+    public void setCounts(Integer counts) {
+        this.counts = counts;
+    }
+
+    public Integer getDh() {
+        return dh;
+    }
+
+    public void setDh(Integer dh) {
+        this.dh = dh;
+    }
+
+    public String getDhl() {
+        return dhl;
+    }
+
+    public void setDhl(String dhl) {
+        this.dhl = dhl;
+    }
+
+    public Integer getWl() {
+        return wl;
+    }
+
+    public void setWl(Integer wl) {
+        this.wl = wl;
+    }
+
+    public String getWll() {
+        return wll;
+    }
+
+    public void setWll(String wll) {
+        this.wll = wll;
+    }
+
+    public Integer getQd() {
+        return qd;
+    }
+
+    public void setQd(Integer qd) {
+        this.qd = qd;
+    }
+
+    public String getQdl() {
+        return qdl;
+    }
+
+    public void setQdl(String qdl) {
+        this.qdl = qdl;
+    }
+
+    public Integer getZjs() {
+        return zjs;
+    }
+
+    public void setZjs(Integer zjs) {
+        this.zjs = zjs;
+    }
+
+    public String getZjsl() {
+        return zjsl;
+    }
+
+    public void setZjsl(String zjsl) {
+        this.zjsl = zjsl;
+    }
+
+    public Integer getQt() {
+        return qt;
+    }
+
+    public void setQt(Integer qt) {
+        this.qt = qt;
+    }
+
+    public String getQtl() {
+        return qtl;
+    }
+
+    public void setQtl(String qtl) {
+        this.qtl = qtl;
+    }
+
+    public Integer getGxfg() {
+        return gxfg;
+    }
+
+    public void setGxfg(Integer gxfg) {
+        this.gxfg = gxfg;
+    }
+
+    public String getGxfgl() {
+        return gxfgl;
+    }
+
+    public void setGxfgl(String gxfgl) {
+        this.gxfgl = gxfgl;
+    }
+
+    public Integer getQtfg() {
+        return qtfg;
+    }
+
+    public void setQtfg(Integer qtfg) {
+        this.qtfg = qtfg;
+    }
+
+    public String getQtfgl() {
+        return qtfgl;
+    }
+
+    public void setQtfgl(String qtfgl) {
+        this.qtfgl = qtfgl;
+    }
+}

+ 32 - 18
src/main/java/com/goafanti/order/controller/ProjectStatisticsApiController.java

@@ -6,6 +6,8 @@ import java.io.IOException;
 
 import javax.servlet.http.HttpServletResponse;
 
+import com.goafanti.order.bo.InputOrderSalesSource;
+import com.goafanti.order.service.OrderStatisticsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -19,13 +21,15 @@ import com.goafanti.order.service.ProjectStatisticsService;
 
 @RestController
 @RequestMapping(value = "/api/admin/statistis")
-public class ProjectStatisticsApiController extends CertifyApiController {
-	
+public class StatisticsApiController extends CertifyApiController {
+
 	@Autowired
 	private ProjectStatisticsService	projectStatisticsService;
-	
-	
-	
+	@Autowired
+	private OrderStatisticsService orderStatisticsService;
+
+
+
 	/**
 	 * 	项目汇总列表
 	 */
@@ -35,12 +39,12 @@ public class ProjectStatisticsApiController extends CertifyApiController {
 		res.setData(projectStatisticsService.selectTaskList( ps));
 		return res;
 	}
-	
-	
-	
+
+
+
 	/**
 	 * 项目汇总列表导出xls
-	 * @throws IOException 
+	 * @throws IOException
 	 */
 	@RequestMapping(value = "/exporTaskList", method = RequestMethod.GET)
 	public Result exporTaskList(HttpServletResponse response,InputProjectStatistics ib) throws IOException{
@@ -52,12 +56,12 @@ public class ProjectStatisticsApiController extends CertifyApiController {
 			e.printStackTrace();
 			return res;
 		}
-     res.data(1); 
+     res.data(1);
 	return res;
-		
+
 	}
-	
-	
+
+
 	/**
 	 * 	项目省份统计列表
 	 */
@@ -67,11 +71,11 @@ public class ProjectStatisticsApiController extends CertifyApiController {
 		res.setData(projectStatisticsService.selectProvincialStatistics( is));
 		return res;
 	}
-	
-	
+
+
 	/**
 	 * 	项目省份统计列表导出xls
-	 * @throws IOException 
+	 * @throws IOException
 	 */
 	@RequestMapping(value = "/exporProvincialList", method = RequestMethod.GET)
 	public Result exporProvincialList(InputProvincialStatistics ib){
@@ -79,6 +83,16 @@ public class ProjectStatisticsApiController extends CertifyApiController {
 		return projectStatisticsService.exporProvincialList( ib);
 		}
 
-	
-	
+	/**
+	 * 	订单销售来源统计
+	 */
+	@RequestMapping(value="/orderSalesSource" ,method = RequestMethod.GET)
+	public Result orderSalesSource(InputOrderSalesSource in){
+		Result res=new Result();
+		res.setData(orderStatisticsService.orderSalesSource( in));
+		return res;
+	}
+
+
+
 }

+ 13 - 0
src/main/java/com/goafanti/order/service/OrderStatisticsService.java

@@ -0,0 +1,13 @@
+package com.goafanti.order.service;
+
+
+import com.goafanti.order.bo.InputOrderSalesSource;
+import com.goafanti.order.bo.OutOrderSalesSource;
+
+import java.util.List;
+
+public interface OrderStatisticsService {
+
+
+	List<OutOrderSalesSource> orderSalesSource(InputOrderSalesSource in);
+}

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

@@ -157,7 +157,12 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		t.setUpdateTime(date);
 		t.setBuyerId(uid);
 		t.setSalesType(salesType);
-		if (channelId!=null)t.setChannelId(channelId);
+		if (salesType==salesTypes.qd.getCode()&&channelId!=null){
+			t.setChannelId(channelId);
+			User u =userMapper.selectByPrimaryKey(channelId);
+			t.setOther(u.getNickname());
+		}
+
 		if (other!=null )t.setOther(other);
 		User u=userMapper.selectByPrimaryKey(uid);
 		if(u.getShareType()!=null&&u.getShareType()==2){

+ 46 - 0
src/main/java/com/goafanti/order/service/impl/OrderStatisticsServiceImpl.java

@@ -0,0 +1,46 @@
+package com.goafanti.order.service.impl;
+
+import com.goafanti.common.bo.Error;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.dao.TOrderNewMapper;
+import com.goafanti.common.dao.TOrderTaskMapper;
+import com.goafanti.common.error.BusinessException;
+import com.goafanti.common.utils.ExportExcelUtil;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.order.bo.*;
+import com.goafanti.order.enums.NewProjectStatus;
+import com.goafanti.order.service.OrderStatisticsService;
+import com.goafanti.order.service.ProjectStatisticsService;
+import groovy.util.logging.Log4j;
+import org.apache.commons.collections4.map.HashedMap;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+@Log4j
+public class OrderStatisticsServiceImpl extends BaseMybatisDao<TOrderNewMapper> implements OrderStatisticsService {
+	@Autowired
+	private TOrderNewMapper tOrderNewMapper;
+
+	@Override
+	public List<OutOrderSalesSource> orderSalesSource(InputOrderSalesSource in) {
+		if (in.getSort()==null)in.setSort(0);
+		return tOrderNewMapper.orderSalesSource(in);
+	}
+}