| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.tourguide.modules.order.entity.TourOrder; |
| | | import com.tourguide.modules.order.dto.GuideTodayStatsResponse; |
| | | import com.tourguide.modules.order.dto.VisitorOrderStatRow; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | public interface TourOrderMapper extends BaseMapper<TourOrder> { |
| | |
| | | @Select("SELECT DISTINCT scenic_name FROM tour_order WHERE deleted = 0 AND scenic_name IS NOT NULL AND scenic_name <> '' ORDER BY scenic_name") |
| | | List<String> selectScenicOptions(); |
| | | |
| | | @Select({ |
| | | "<script>", |
| | | "SELECT visitor_id AS visitorId, COUNT(*) AS orderCount, ", |
| | | "COALESCE(SUM(CASE WHEN status NOT IN ('PENDING_PAYMENT', 'CANCELLED', 'REFUNDED') ", |
| | | "THEN COALESCE(payment_amount, amount) ELSE 0 END), 0) AS totalConsumption ", |
| | | "FROM tour_order WHERE deleted = 0 AND visitor_id IN ", |
| | | "<foreach collection='visitorIds' item='visitorId' open='(' separator=',' close=')'>#{visitorId}</foreach>", |
| | | "GROUP BY visitor_id", |
| | | "</script>" |
| | | }) |
| | | List<VisitorOrderStatRow> selectVisitorOrderStats(@Param("visitorIds") Collection<Long> visitorIds); |
| | | |
| | | @Select("SELECT COALESCE(SUM(guide_earning_amount), 0) FROM tour_order " + |
| | | "WHERE deleted = 0 AND guide_id = #{guideId} AND status = 'COMPLETED' " + |
| | | "AND guide_earning_amount IS NOT NULL " + |