首页 数据统计

This commit is contained in:
2024-09-10 15:54:40 +08:00
parent 6c480acd20
commit ced7d4bc7d
6 changed files with 243 additions and 93 deletions

View File

@@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @author GYJ
@@ -41,6 +41,33 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
@Param("startTime") String startTime,
@Param("endTime") String endTime);
@Select("<script>" +
"SELECT" +
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') THEN flow.amount ELSE 0 END),0) AS 'inAmount'," +
" COALESCE(SUM(CASE WHEN flow.biz_code = 'inMoneyOut' THEN flow.amount ELSE 0 END),0) AS 'outAmount'," +
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN flow.amount ELSE 0 END),0) AS 'useAmount'," +
" COALESCE(COUNT(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN 1 ELSE NULL END),0) AS 'useNum'" +
"FROM" +
" tb_shop_user_flow flow" +
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id and vip.shop_id= #{shopId} " +
"WHERE" +
" flow.create_time BETWEEN #{startTime} AND #{endTime} " +
"</script>")
Map<String, Object> tradeIndexFlow(@Param("shopId") Integer shopId,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
@Select("<script>" +
"SELECT COALESCE(count(1),0) from( " +
" SELECT flow.create_time " +
" FROM tb_shop_user_flow flow " +
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id AND vip.shop_id = #{shopId} " +
"WHERE biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') " +
"GROUP BY " +
" shop_user_id) as flows where flows.create_time BETWEEN #{startTime} AND #{endTime}" +
"</script>")
Integer tradeIndexNewFlow(@Param("shopId") Integer shopId, @Param("startTime") String startTime, @Param("endTime") String endTime);
@Select(value = "select * from tb_shop_user_flow where shop_user_id=#{userId} order by id desc limit #{page},#{size}")
List<TbShopUserFlow> selectByUserId(@Param("userId") Integer userId,@Param("page") Integer page,@Param("size") Integer size);