add data export
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
ALTER TABLE `async_task`
|
||||
ADD COLUMN `subject_type` VARCHAR(32) NULL COMMENT '任务处理对象类型' AFTER `type`,
|
||||
ADD COLUMN `subject_id` VARCHAR(36) NULL COMMENT '任务处理对象 ID' AFTER `subject_type`,
|
||||
ADD COLUMN `owner_user_id` VARCHAR(36) NULL COMMENT '任务创建人用户 ID' AFTER `subject_id`,
|
||||
ADD COLUMN `metadata` LONGTEXT NULL COMMENT '创建任务时的 JSON 元数据' AFTER `owner_user_id`,
|
||||
ADD COLUMN `result` LONGTEXT NULL COMMENT '任务完成后的 JSON 结果' AFTER `metadata`,
|
||||
ADD COLUMN `completed_at` BIGINT NULL COMMENT '完成时间' AFTER `died_at`,
|
||||
ADD COLUMN `expires_at` BIGINT NULL COMMENT '结果过期时间' AFTER `completed_at`,
|
||||
ADD KEY `idx_async_task_owner_created` (`owner_user_id`, `created_at`),
|
||||
ADD KEY `idx_async_task_expires_at` (`expires_at`);
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
UPDATE `gao_sales_order`
|
||||
SET `refund_status` = 'REFUNDED', `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `status` = 'CANCELLED'
|
||||
AND `paid_amount` = `refunded_amount`
|
||||
AND `refund_status` = 'PENDING'
|
||||
AND `deleted_at` IS NULL;
|
||||
@@ -0,0 +1,156 @@
|
||||
<?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.GaoDataExportMapper">
|
||||
<sql id="exportWhere">
|
||||
`${scopeColumn}` = #{scopeValue}
|
||||
<if test="hasDeletedAt">
|
||||
AND `deleted_at` IS NULL
|
||||
</if>
|
||||
<if test="requiredBizType != null">
|
||||
AND `biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="countRows" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM `${tableName}`
|
||||
WHERE <include refid="exportWhere"/>
|
||||
</select>
|
||||
|
||||
<select id="selectRows" resultType="map">
|
||||
SELECT *
|
||||
FROM `${tableName}`
|
||||
WHERE <include refid="exportWhere"/>
|
||||
ORDER BY `${timeColumn}` ASC, `id` ASC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectChildren" resultType="map">
|
||||
SELECT *
|
||||
FROM `${tableName}`
|
||||
WHERE `${foreignKey}` IN
|
||||
<foreach collection="parentIdList" item="parentId" open="(" separator="," close=")">
|
||||
#{parentId}
|
||||
</foreach>
|
||||
<if test="hasDeletedAt">
|
||||
AND `deleted_at` IS NULL
|
||||
</if>
|
||||
ORDER BY `${foreignKey}` ASC, `created_at` ASC
|
||||
</select>
|
||||
|
||||
<select id="countChildren" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM `${childTableName}` `c`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenByScope" resultType="map">
|
||||
SELECT `c`.*
|
||||
FROM `${childTableName}` `c`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
ORDER BY `c`.`created_at` ASC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
<select id="statAttachment" resultType="map">
|
||||
SELECT
|
||||
COUNT(`a`.`id`) AS `attachmentCount`,
|
||||
COALESCE(SUM(`a`.`size`), 0) AS `attachmentSize`
|
||||
FROM `attachment` `a`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `a`.`biz_id`
|
||||
WHERE
|
||||
`a`.`deleted_at` IS NULL
|
||||
AND (`a`.`destroy_at` IS NULL OR `a`.`destroy_at` > UNIX_TIMESTAMP() * 1000)
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
AND `a`.`biz_type` IN
|
||||
<foreach collection="attachmentBizTypeList" item="bizType" open="(" separator="," close=")">
|
||||
#{bizType}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="statChildAttachment" resultType="map">
|
||||
SELECT
|
||||
COUNT(`a`.`id`) AS `attachmentCount`,
|
||||
COALESCE(SUM(`a`.`size`), 0) AS `attachmentSize`
|
||||
FROM `attachment` `a`
|
||||
INNER JOIN `${childTableName}` `c` ON `c`.`id` = `a`.`biz_id`
|
||||
INNER JOIN `${tableName}` `r` ON `r`.`id` = `c`.`${childForeignKey}`
|
||||
WHERE
|
||||
`a`.`deleted_at` IS NULL
|
||||
AND (`a`.`destroy_at` IS NULL OR `a`.`destroy_at` > UNIX_TIMESTAMP() * 1000)
|
||||
<if test="hasDeletedAt">
|
||||
AND `r`.`deleted_at` IS NULL
|
||||
</if>
|
||||
<if test="childHasDeletedAt">
|
||||
AND `c`.`deleted_at` IS NULL
|
||||
</if>
|
||||
AND `r`.`${scopeColumn}` = #{scopeValue}
|
||||
<if test="requiredBizType != null">
|
||||
AND `r`.`biz_type` = #{requiredBizType}
|
||||
</if>
|
||||
<if test="beginAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` >= #{beginAt}
|
||||
</if>
|
||||
<if test="endAt != null and timeColumn != null">
|
||||
AND `r`.`${timeColumn}` <= #{endAt}
|
||||
</if>
|
||||
AND `a`.`biz_type` IN
|
||||
<foreach collection="attachmentBizTypeList" item="bizType" open="(" separator="," close=")">
|
||||
#{bizType}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -11,6 +11,10 @@
|
||||
AND o.`purchased_at` >= #{beginAt}
|
||||
AND o.`purchased_at` <= #{endAt}
|
||||
</sql>
|
||||
<sql id="operatingOrderFilter">
|
||||
<include refid="orderFilter"/>
|
||||
<if test="status == null">AND o.`status` <> 'CANCELLED'</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView">
|
||||
SELECT
|
||||
@@ -23,7 +27,7 @@
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
@@ -38,7 +42,7 @@
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
GROUP BY o.`order_type`
|
||||
ORDER BY o.`order_type` ASC
|
||||
</select>
|
||||
@@ -50,11 +54,11 @@
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`sale_amount` - o.`paid_amount`), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(GREATEST(o.`sale_amount` - o.`paid_amount`, 0)), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
GROUP BY o.`payment_status`
|
||||
ORDER BY o.`payment_status` ASC
|
||||
</select>
|
||||
@@ -72,8 +76,7 @@
|
||||
FROM `gao_sales_order` o
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = o.`customer_id` AND c.`deleted_at` IS NULL
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<if test="status == null">AND o.`status` <> 'CANCELLED'</if>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
GROUP BY o.`customer_id`, c.`code`, c.`name`
|
||||
ORDER BY `netPaidAmount` DESC, `orderCount` DESC, o.`customer_id` ASC
|
||||
LIMIT #{topN}
|
||||
@@ -167,12 +170,12 @@
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`sale_amount` - o.`paid_amount`), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(GREATEST(o.`sale_amount` - o.`paid_amount`, 0)), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
</select>
|
||||
|
||||
<select id="selectConsumptionDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView">
|
||||
@@ -208,7 +211,7 @@
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<include refid="operatingOrderFilter"/>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
@@ -120,11 +120,14 @@
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`sale_amount` - o.`paid_amount`), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(GREATEST(o.`sale_amount` - o.`paid_amount`, 0)), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o LEFT JOIN `gao_customer` c ON c.`id` = o.`customer_id`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
<if test="(statusList == null or statusList.size() == 0) and status == null">
|
||||
AND o.`status` <> 'CANCELLED'
|
||||
</if>
|
||||
</select>
|
||||
<sql id="customerProductWhere">
|
||||
i.`deleted_at` IS NULL
|
||||
|
||||
Reference in New Issue
Block a user