add store
This commit is contained in:
@@ -6,10 +6,16 @@
|
||||
*
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`id` IN
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
@@ -19,7 +25,8 @@
|
||||
COUNT(1) AS `newCustomerCount`
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`created_at` >= #{beginCreatedAt}
|
||||
`store_id` = #{storeId}
|
||||
AND `created_at` >= #{beginCreatedAt}
|
||||
AND `created_at` <= #{endCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d')
|
||||
@@ -31,7 +38,8 @@
|
||||
COUNT(1)
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`created_at` < #{beginCreatedAt}
|
||||
`store_id` = #{storeId}
|
||||
AND `created_at` < #{beginCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
@@ -41,7 +49,8 @@
|
||||
COUNT(1) AS `count`
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`deleted_at` IS NULL
|
||||
`store_id` = #{storeId}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY IFNULL(CAST(`gender` AS CHAR), 'UNKNOWN')
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
*
|
||||
FROM `gao_event`
|
||||
WHERE
|
||||
`status` = '${@com.imyeyu.api.modules.gao.entity.GaoEvent$Status@ACTIVE.name()}'
|
||||
`store_id` = #{storeId}
|
||||
AND `status` = '${@com.imyeyu.api.modules.gao.entity.GaoEvent$Status@ACTIVE.name()}'
|
||||
AND (`begin_at` IS NULL OR `begin_at` <= #{now})
|
||||
AND (`end_at` IS NULL OR #{now} <= `end_at`)
|
||||
AND `deleted_at` IS NULL
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
`gao_event_record`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="storeId != null">
|
||||
AND `store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
AND `customer_id` = #{customerId}
|
||||
</if>
|
||||
@@ -18,19 +21,48 @@
|
||||
AND `registered_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND `registered_at` >= #{endAt}
|
||||
AND `registered_at` <= #{endAt}
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="countByStoreIdAndRegisteredDateValue" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_event_record`
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `registered_date_value` = #{registeredDateValue}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<update id="updateBusinessDayNoByStoreIdAndRegisteredDateValue">
|
||||
UPDATE `gao_event_record`
|
||||
SET
|
||||
`business_day_no` = #{businessDayNo},
|
||||
`updated_at` = ROUND(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)
|
||||
WHERE
|
||||
`store_id` = #{storeId}
|
||||
AND `registered_date_value` = #{registeredDateValue}
|
||||
AND `deleted_at` IS NULL
|
||||
</update>
|
||||
|
||||
<sql id="rangeFrom">
|
||||
FROM `gao_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
</sql>
|
||||
<sql id="rangeWhere">
|
||||
r.`registered_at` >= #{beginAt}
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
TRUE
|
||||
<if test="beginAt != null">
|
||||
AND r.`registered_at` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null">
|
||||
AND r.`registered_at` <= #{endAt}
|
||||
</if>
|
||||
AND r.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">
|
||||
AND r.`store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
AND r.`customer_id` = #{customerId}
|
||||
</if>
|
||||
@@ -69,6 +101,9 @@
|
||||
<sql id="rankWhere">
|
||||
r.`deleted_at` IS NULL
|
||||
AND c.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">
|
||||
AND r.`store_id` = #{storeId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND r.`customer_id` = #{customerId}
|
||||
</if>
|
||||
@@ -97,7 +132,7 @@
|
||||
WITH `daily_stat` AS (
|
||||
SELECT
|
||||
r.`customer_id` AS `customerId`,
|
||||
DATE(FROM_UNIXTIME(r.`registered_at` / 1000)) AS `eventDate`,
|
||||
r.`business_day_no` AS `businessDayNo`,
|
||||
COUNT(1) AS `dailyCount`,
|
||||
MAX(r.`registered_at`) AS `latestRegisteredAt`
|
||||
FROM `gao_event_record` r
|
||||
@@ -106,7 +141,7 @@
|
||||
<include refid="rankWhere"/>
|
||||
GROUP BY
|
||||
r.`customer_id`,
|
||||
DATE(FROM_UNIXTIME(r.`registered_at` / 1000))
|
||||
r.`business_day_no`
|
||||
),
|
||||
`rank_stat` AS (
|
||||
SELECT
|
||||
@@ -120,14 +155,14 @@
|
||||
`continuous_ordered` AS (
|
||||
SELECT
|
||||
`customerId`,
|
||||
`eventDate`,
|
||||
ROW_NUMBER() OVER (PARTITION BY `customerId` ORDER BY `eventDate` DESC) AS `dayIndex`
|
||||
`businessDayNo`,
|
||||
ROW_NUMBER() OVER (PARTITION BY `customerId` ORDER BY `businessDayNo` DESC) AS `dayIndex`
|
||||
FROM `daily_stat`
|
||||
),
|
||||
`latest_date` AS (
|
||||
SELECT
|
||||
`customerId`,
|
||||
MAX(`eventDate`) AS `latestEventDate`
|
||||
MAX(`businessDayNo`) AS `latestBusinessDayNo`
|
||||
FROM `daily_stat`
|
||||
GROUP BY `customerId`
|
||||
),
|
||||
@@ -137,7 +172,7 @@
|
||||
COUNT(1) AS `recentContinuousEventDays`
|
||||
FROM `continuous_ordered` o
|
||||
LEFT JOIN `latest_date` l ON o.`customerId` = l.`customerId`
|
||||
WHERE DATE_ADD(o.`eventDate`, INTERVAL o.`dayIndex` DAY) = DATE_ADD(l.`latestEventDate`, INTERVAL 1 DAY)
|
||||
WHERE o.`businessDayNo` + o.`dayIndex` = l.`latestBusinessDayNo` + 1
|
||||
GROUP BY o.`customerId`
|
||||
),
|
||||
`ranked` AS (
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoStoreMapper">
|
||||
<select id="selectByUserId" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
||||
SELECT
|
||||
s.*
|
||||
FROM `gao_user` u
|
||||
INNER JOIN `gao_store` s ON u.`store_id` = s.`id`
|
||||
WHERE
|
||||
u.`user_id` = #{userId}
|
||||
AND u.`enabled` = TRUE
|
||||
AND u.`deleted_at` IS NULL
|
||||
AND s.`status` = 'ACTIVE'
|
||||
AND s.`deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
FROM `role`
|
||||
WHERE
|
||||
1 = 1
|
||||
TRUE
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="item" separator="," open="(" close=")">
|
||||
@@ -14,29 +14,10 @@
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND 1 = 0
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByModuleCodeAndCodeList" resultType="com.imyeyu.api.modules.user.entity.Role">
|
||||
SELECT
|
||||
*
|
||||
FROM `role`
|
||||
WHERE
|
||||
1 = 1
|
||||
AND `module_code` = #{moduleCode}
|
||||
<if test="codeList != null and !codeList.isEmpty()">
|
||||
AND `code` IN
|
||||
<foreach collection="codeList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="codeList == null or codeList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectByModuleCode" resultType="com.imyeyu.api.modules.user.entity.Role">
|
||||
SELECT
|
||||
*
|
||||
@@ -44,6 +25,6 @@
|
||||
WHERE
|
||||
`module_code` = #{moduleCode}
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at` ASC
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -12,6 +12,23 @@
|
||||
(#{item.id}, #{item.userId}, #{item.roleId}, #{item.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectByUserIdList" resultType="com.imyeyu.api.modules.user.entity.UserRole">
|
||||
SELECT
|
||||
*
|
||||
FROM `user_role`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="userIdList != null and !userIdList.isEmpty()">
|
||||
AND `user_id` IN
|
||||
<foreach collection="userIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIdList == null or userIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<update id="deleteByRoleIdList">
|
||||
UPDATE `user_role`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP()
|
||||
|
||||
Reference in New Issue
Block a user