26 lines
1.0 KiB
Java
26 lines
1.0 KiB
Java
package com.rj.mapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.rj.entity.LbUserCoupon;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
|
import java.time.LocalDate;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@Mapper
|
|
public interface LbUserCouponMapper extends BaseMapper<LbUserCoupon> {
|
|
|
|
@Select("SELECT user_id, ANY_VALUE(user_phone) AS user_phone, ANY_VALUE(user_nickname) AS user_nickname, " +
|
|
"ANY_VALUE(parent_phone) AS parent_phone, ANY_VALUE(parent_nickname) AS parent_nickname, " +
|
|
"YEAR(coupon_date) AS year, MONTH(coupon_date) AS month, " +
|
|
"SUM(coupon_amount) AS total_amount " +
|
|
"FROM lb_user_coupon " +
|
|
"WHERE tenant_id = #{tenantId} " +
|
|
"AND coupon_date >= #{startDate} " +
|
|
"AND coupon_date <= #{endDate} " +
|
|
"GROUP BY user_id, YEAR(coupon_date), MONTH(coupon_date)")
|
|
List<Map<String, Object>> selectMonthlyAggregation(String tenantId, LocalDate startDate, LocalDate endDate);
|
|
}
|