修改C端数据维度,订单时间最多查询半年

This commit is contained in:
yuyang 2022-04-22 14:52:47 +08:00
parent 92bf282038
commit 34418b0749
4 changed files with 21 additions and 36 deletions

View File

@ -181,7 +181,7 @@ public interface XhpcStatisticsServiceMapper {
* @param type 1 平台 2 运营商 3流量方
* @return
*/
List<Map<String,Object>> getSumSourceList(@Param("startTime")String startTime, @Param("endTime")String endTime,@Param("sourceIds")List<String> sourceIds, @Param("userId")Long userId, @Param("type")Integer type,@Param("chargingStationIdList")List<String> chargingStationIdList,@Param("tenantId")String tenantId,@Param("tenantId")Long sysUserId,@Param("tenantId")Integer number);
List<Map<String,Object>> getSumSourceList(@Param("startTime")String startTime, @Param("endTime")String endTime,@Param("sourceIds")List<String> sourceIds, @Param("userId")Long userId, @Param("type")Integer type,@Param("chargingStationIdList")List<String> chargingStationIdList,@Param("tenantId")String tenantId,@Param("tenantId")Long sysUserId,@Param("number")Integer number);
/**
* 获取登陆用户信息

View File

@ -149,5 +149,5 @@ public interface XhpcUserMapper {
public int getOrderTimeNumber(@Param("userId")String userId,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("tenantId")String tenantId);
List<Map<String,Object>> getUserDimension(@Param("number")Integer number,@Param("userId")String userId,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("tenantId")String tenantId,@Param("activity")Integer activity,@Param("frequency")Integer frequency,@Param("amount") BigDecimal amount,@Param("phone")String phone);
List<Map<String,Object>> getUserDimension(@Param("userId")String userId,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("tenantId")String tenantId,@Param("activity")Integer activity,@Param("frequency")Integer frequency,@Param("amount") BigDecimal amount,@Param("phone")String phone);
}

View File

@ -231,9 +231,9 @@ public class XhpcUserServiceImpl extends BaseService implements IXhpcUserService
String tenantId = loginUser.getTenantId();
//时间范围内的所有订单总数
int orderTimeNumber = xhpcUserMapper.getOrderTimeNumber(null, startTime, endTime, tenantId);
// int orderTimeNumber = xhpcUserMapper.getOrderTimeNumber(null, startTime, endTime, tenantId);
startPage();
List<Map<String, Object>> userDimension = xhpcUserMapper.getUserDimension(orderTimeNumber, null, startTime, endTime, tenantId,activity,frequency,amount,phone);
List<Map<String, Object>> userDimension = xhpcUserMapper.getUserDimension(null, startTime, endTime, tenantId,activity,frequency,amount,phone);
return userDimension;
}

View File

@ -326,36 +326,22 @@
<select id="getUserDimension" resultType="map">
SELECT
us.number number,
us.totalPrice totalPrice,
us.activity activity,
us.appUserId appUserId,
us.phone phone
from xhpc_app_user AS xaus
JOIN (
SELECT
count(xho.history_order_id) number,
IFNULL(SUM(xho.total_price),0) totalPrice,
IFNULL(TRUNCATE((count(xho.history_order_id)/#{number})*100,0),0) activity,
xau.app_user_id appUserId,
xau.phone phone
from xhpc_app_user as xau
LEFT JOIN xhpc_history_order xho on xau.app_user_id = xho.user_id and xho.source = 0 and xho.tenant_id =#{tenantId}
where xau.del_flag =0
<if test="startTime !=null and startTime !=''">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and xho.end_time &lt;= #{endTime}
</if>
<if test="phone !=null and phone !=''">
and xau.phone like concat('%', #{phone}, '%')
</if>
GROUP BY xau.app_user_id
order by totalPrice desc) us on xaus.app_user_id = us.appUserId
where xaus.del_flag = 0
<if test="activity !=null">
and us.activity &gt;= #{activity}
count(xho.history_order_id) number,
IFNULL(SUM(xho.total_price),0) totalPrice,
xaus.app_user_id appUserId,
xaus.phone phone
from xhpc_app_user AS xaus
LEFT JOIN xhpc_history_order xho on xaus.app_user_id = xho.user_id and xho.source = 0 and xho.tenant_id =#{tenantId}
WHERE
xaus.del_flag = 0 and YEAR(xho.end_time)=YEAR(NOW())
<if test="startTime !=null and startTime !=''">
and xho.end_time &gt;=#{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and xho.end_time &lt;= #{endTime}
</if>
<if test="phone !=null and phone !=''">
and xau.phone like concat('%', #{phone}, '%')
</if>
<if test="frequency !=null">
and us.number &gt;= #{frequency}
@ -370,8 +356,7 @@
and xaus.user_id = #{userId}
</if>
GROUP BY xaus.app_user_id
order by totalPrice desc,number desc,activity desc
order by totalPrice desc,number desc
</select>