Commit ece75428 by 罗承锋

添加销售统计

parent 6ba8d588
......@@ -192,4 +192,34 @@ public interface OrderMapper extends BaseMapper<Order> {
* @return
*/
List<Map<String,Object>> kdOrderConversionXF(@Param("startTime") String startTime,@Param("endTime") String endTime);
/**
* 获取成员销售统计
* @return
*/
List<Map<String, Object>> getUserSalesStatistic(Map<String, Object> map);
/**
* 获取楼长的销售统计
* @return
*/
List<Map<String, Object>> getLzSalesStatistic(Map<String, Object> map);
/**
* 获取学校的销售统计
* @return
*/
List<Map<String, Object>> getSchoolSaleStatistic(Map<String, Object> map);
/**
* 获取产品转换率
* @return
*/
List<Map<String, Object>> getProductTransferStatistic(Map<String, Object> map);
/**
* 获取产品销售排名
* @return
*/
List<Map<String, Object>> getProductSalesStatistic(Map<String, Object> map);
}
......@@ -324,4 +324,148 @@
ORDER BY sub_id
</select>
<select id="getUserSalesStatistic" parameterType="map" resultType="java.util.HashMap">
SELECT
hehuoren_name as name,
count( hehuoren_id ) as num
FROM
hhr_order
WHERE
order_status = "已完成"
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
GROUP BY
hehuoren_id
ORDER BY
count( hehuoren_id ) DESC
LIMIT 0, 10
</select>
<select id="getLzSalesStatistic" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
supervisor_name as name,
count( supervisor_name ) as num
FROM
hhr_order
WHERE
order_status = "已完成"
AND supervisor_name IS NOT NULL
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
GROUP BY
supervisor_name
ORDER BY
count( supervisor_name ) DESC
LIMIT 0, 10
</select>
<select id="getSchoolSaleStatistic" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
hehuoren_school as name,
count( hehuoren_school ) as num
FROM
hhr_order
WHERE
order_status = "已完成"
AND hehuoren_school IS NOT NULL
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
GROUP BY
hehuoren_school
ORDER BY
count( hehuoren_school ) DESC
LIMIT 0, 10
</select>
<select id="getProductTransferStatistic" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
hp.package_name as name,
round( complate.num / ( all_order.num + 1000 ) * 100, 2) as num
FROM
(
SELECT
package_id,
count( package_id ) AS num
FROM
hhr_order
WHERE
order_status = "已完成"
AND user_type = "0"
AND package_id IS NOT NULL
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
GROUP BY
package_id
) complate
RIGHT JOIN
(
SELECT
package_id,
count( package_id ) AS num
FROM
hhr_order
WHERE
user_type = "0"
AND package_id IS NOT NULL
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
GROUP BY package_id
) all_order
ON
complate.package_id = all_order.package_id
LEFT JOIN hhr_package hp ON all_order.package_id = hp.id
ORDER BY
( complate.num / ( all_order.num + 1000 ) ) DESC
LIMIT 0, 10
</select>
<select id="getProductSalesStatistic" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
hp.package_name as name,
count( ho.id ) as num
FROM
hhr_package hp
LEFT JOIN
(
select
id, package_id
from
hhr_order
<where>
<if test="area != null and area != ''">
AND hehuoren_area = #{area}
</if>
<if test="school != null and school != ''">
AND hehuoren_school = #{school}
</if>
</where>
)ho ON hp.id = ho.package_id
AND ho.id IS NOT NULL
GROUP BY
hp.id
ORDER BY
count( ho.id ) DESC
limit 0, 5
</select>
</mapper>
\ No newline at end of file
......@@ -10,10 +10,7 @@ import com.winsun.auth.core.shiro.ShiroUser;
import com.winsun.bean.HhrSupervisorSchool;
import com.winsun.bean.HhrUser;
import com.winsun.bean.UserSchool;
import com.winsun.mapper.HhrSupervisorSchoolMapper;
import com.winsun.mapper.HhrUserMapper;
import com.winsun.mapper.SysUserMapper;
import com.winsun.mapper.UserSchoolMapper;
import com.winsun.mapper.*;
import com.winsun.service.AccessStatisticService;
import com.winsun.service.IHhrUserService;
import lombok.extern.slf4j.Slf4j;
......@@ -46,18 +43,22 @@ public class AnalysisController extends BaseController {
private IHhrUserService hhrUserService;
private OrderMapper orderMapper;
@Autowired
public AnalysisController(SysUserMapper sysUserMapper, HhrUserMapper hhrUserMapper,
HhrSupervisorSchoolMapper hhrSupervisorSchoolMapper,
UserSchoolMapper userSchoolMapper,
AccessStatisticService accessStatisticService,
IHhrUserService hhrUserService) {
IHhrUserService hhrUserService,
OrderMapper orderMapper) {
this.sysUserMapper = sysUserMapper;
this.hhrUserMapper = hhrUserMapper;
this.hhrSupervisorSchoolMapper = hhrSupervisorSchoolMapper;
this.userSchoolMapper = userSchoolMapper;
this.accessStatisticService = accessStatisticService;
this.hhrUserService = hhrUserService;
this.orderMapper = orderMapper;
}
/**
......@@ -171,4 +172,104 @@ public class AnalysisController extends BaseController {
return ResponseData.success(uvStatisticsEchartData);
}
/**
* TODO 获取成员销量排名表
* @return
*/
@Permission(menuname="获取成员销量排名表", value="getUserSalesStatistic", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getUserSalesStatistic(String area, String school) {
Map<String, Object> map = new HashMap<>();
map.put("area", area);
map.put("school", school);
List<Map<String, Object>> userSalesStatistic = orderMapper.getUserSalesStatistic(map);
Map<String, Object> stringObjectMap = this.transferEchartData(userSalesStatistic);
return ResponseData.success(stringObjectMap);
}
/**
* TODO 获取楼长的销售统计
* @return
*/
@Permission(menuname="获取楼长的销售统计", value="getLzSalesStatistic", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getLzSalesStatistic(String area, String school) {
Map<String, Object> map = new HashMap<>();
map.put("area", area);
map.put("school", school);
List<Map<String, Object>> getLzSalesStatistic = orderMapper.getLzSalesStatistic(map);
Map<String, Object> stringObjectMap = this.transferEchartData(getLzSalesStatistic);
return ResponseData.success(stringObjectMap);
}
/**
* TODO 获取学校销量统计
* @return
*/
@Permission(menuname="获取学校销量统计", value="getSchoolSaleStatistic", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getSchoolSaleStatistic(String area, String school) {
Map<String, Object> map = new HashMap<>();
map.put("area", area);
map.put("school", school);
List<Map<String, Object>> getSchoolSaleStatistic = orderMapper.getSchoolSaleStatistic(map);
Map<String, Object> stringObjectMap = this.transferEchartData(getSchoolSaleStatistic);
return ResponseData.success(stringObjectMap);
}
/**
* TODO 获取产品转换率
* @return
*/
@Permission(menuname="获取产品转换率", value="getProductTransferStatistic", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getProductTransferStatistic(String area, String school) {
Map<String, Object> map = new HashMap<>();
map.put("area", area);
map.put("school", school);
List<Map<String, Object>> getProductTransferStatistic = orderMapper.getProductTransferStatistic(map);
Map<String, Object> stringObjectMap = this.transferEchartData(getProductTransferStatistic);
return ResponseData.success(stringObjectMap);
}
/**
* TODO 获取产品销售统计
* @return
*/
@Permission(menuname="获取产品销售统计", value="getProductSalesStatistic", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getProductSalesStatistic(String area, String school) {
Map<String, Object> map = new HashMap<>();
map.put("area", area);
map.put("school", school);
List<Map<String, Object>> getProductSalesStatistic = orderMapper.getProductSalesStatistic(map);
Map<String, Object> stringObjectMap = this.transferEchartData(getProductSalesStatistic);
return ResponseData.success(stringObjectMap);
}
/**
* TODO 获取区域不达标的数据
* @return
*/
@Permission(menuname="获取区域不达标的数据", value="getAreaSalesNotStandard", method = RequestMethod.POST)
public ResponseData<Map<String, Object>> getAreaSalesNotStandard(String area, String school) {
return null;
}
public Map<String, Object> transferEchartData(List<Map<String, Object>> maps) {
Map<String, Object> resultMap = new HashMap<>();
List<String> name = new ArrayList<>();
List<Float> num = new ArrayList<>();
maps.forEach(map -> {
if (map.get("name") != null) {
name.add(map.get("name").toString());
}
if (map.get("num") != null) {
num.add(Float.parseFloat(map.get("num").toString()));
}
});
resultMap.put("name", name);
resultMap.put("num", num);
return resultMap;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment