add GaoPackage
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
ALTER TABLE `gao_event`
|
||||
ADD COLUMN `biz_type` VARCHAR(32) NOT NULL DEFAULT 'GENERAL' COMMENT '业务类型,GENERAL 普通登记,PACKAGE_PURCHASE 购买产品套餐' AFTER `id`;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_package_config` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`store_id` VARCHAR(36) NOT NULL COMMENT '所属门店 ID',
|
||||
`name` VARCHAR(128) NOT NULL COMMENT '套餐名称',
|
||||
`description` VARCHAR(255) NULL COMMENT '套餐说明',
|
||||
`standard_amount` BIGINT NOT NULL DEFAULT 0 COMMENT '标准总价,单位分',
|
||||
`status` VARCHAR(32) NOT NULL COMMENT 'DRAFT 草稿,ACTIVE 启用,INACTIVE 停用',
|
||||
`begin_at` BIGINT NULL COMMENT '有效期开始时间戳,毫秒',
|
||||
`end_at` BIGINT NULL COMMENT '有效期结束时间戳,毫秒',
|
||||
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`updated_by` VARCHAR(36) NOT NULL COMMENT '最后修改用户 ID',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_package_config_store_status` (`store_id`, `status`, `deleted_at`, `begin_at`, `end_at`, `sort`)
|
||||
) COMMENT='GAO 套餐配置';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_package_config_item` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`package_config_id` VARCHAR(36) NOT NULL COMMENT '套餐配置 ID',
|
||||
`product_name` VARCHAR(128) NOT NULL COMMENT '产品名称',
|
||||
`unit` VARCHAR(32) NOT NULL COMMENT '产品单位',
|
||||
`default_quantity` DECIMAL(18,3) NOT NULL COMMENT '默认数量',
|
||||
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`remark` VARCHAR(255) NULL COMMENT '备注',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_package_config_item_config` (`package_config_id`, `deleted_at`, `sort`, `created_at`)
|
||||
) COMMENT='GAO 套餐配置产品明细';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_customer_package` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`store_id` VARCHAR(36) NOT NULL COMMENT '门店 ID',
|
||||
`customer_id` VARCHAR(36) NOT NULL COMMENT '客户 ID',
|
||||
`package_config_id` VARCHAR(36) NOT NULL COMMENT '来源套餐配置 ID',
|
||||
`purchase_event_record_id` VARCHAR(36) NOT NULL COMMENT '购买事件登记 ID',
|
||||
`request_no` VARCHAR(128) NOT NULL COMMENT '购买幂等请求号',
|
||||
`package_name_snapshot` VARCHAR(128) NOT NULL COMMENT '套餐名称快照',
|
||||
`standard_amount_snapshot` BIGINT NOT NULL COMMENT '标准价快照,单位分',
|
||||
`sale_amount` BIGINT NOT NULL COMMENT '实际成交价,单位分',
|
||||
`pending_paid_amount` BIGINT NOT NULL DEFAULT 0 COMMENT '待核销收款合计,单位分',
|
||||
`paid_amount` BIGINT NOT NULL DEFAULT 0 COMMENT '累计有效收款,单位分',
|
||||
`refunded_amount` BIGINT NOT NULL DEFAULT 0 COMMENT '累计有效退款,单位分',
|
||||
`status` VARCHAR(32) NOT NULL COMMENT '套餐状态',
|
||||
`payment_status` VARCHAR(32) NOT NULL COMMENT '付款状态',
|
||||
`refund_status` VARCHAR(32) NOT NULL COMMENT '退款状态',
|
||||
`purchased_at` BIGINT NOT NULL COMMENT '购买时间',
|
||||
`operator_user_id` VARCHAR(36) NOT NULL COMMENT '购买登记人',
|
||||
`cancelled_at` BIGINT NULL COMMENT '取消时间',
|
||||
`cancel_operator_user_id` VARCHAR(36) NULL COMMENT '取消操作人',
|
||||
`cancel_reason` TEXT NULL COMMENT '取消原因',
|
||||
`remark` TEXT NULL COMMENT '备注',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_gao_customer_package_purchase_event` (`purchase_event_record_id`),
|
||||
UNIQUE KEY `uk_gao_customer_package_request` (`store_id`, `request_no`),
|
||||
KEY `idx_gao_customer_package_customer` (`store_id`, `customer_id`, `status`, `deleted_at`, `purchased_at`),
|
||||
KEY `idx_gao_customer_package_payment` (`store_id`, `payment_status`, `refund_status`, `deleted_at`, `purchased_at`)
|
||||
) COMMENT='GAO 客户套餐';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_customer_package_item` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`customer_package_id` VARCHAR(36) NOT NULL COMMENT '客户套餐 ID',
|
||||
`product_name_snapshot` VARCHAR(128) NOT NULL COMMENT '产品名称快照',
|
||||
`unit_snapshot` VARCHAR(32) NOT NULL COMMENT '产品单位快照',
|
||||
`total_quantity` DECIMAL(18,3) NOT NULL COMMENT '总权益数量',
|
||||
`reserved_quantity` DECIMAL(18,3) NOT NULL DEFAULT 0 COMMENT '待核销占用数量',
|
||||
`delivered_quantity` DECIMAL(18,3) NOT NULL DEFAULT 0 COMMENT '已核销净发放数量',
|
||||
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||
`remark` VARCHAR(255) NULL COMMENT '备注',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_customer_package_item_package` (`customer_package_id`, `deleted_at`, `sort`, `created_at`)
|
||||
) COMMENT='GAO 客户套餐产品权益快照';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_package_delivery` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`customer_package_id` VARCHAR(36) NOT NULL COMMENT '客户套餐 ID',
|
||||
`store_id` VARCHAR(36) NOT NULL COMMENT '门店 ID',
|
||||
`customer_id` VARCHAR(36) NOT NULL COMMENT '客户 ID',
|
||||
`operation_type` VARCHAR(32) NOT NULL COMMENT 'DELIVER 正常发放,REVOKE 整单冲正',
|
||||
`status` VARCHAR(32) NOT NULL COMMENT '发放状态',
|
||||
`request_no` VARCHAR(128) NOT NULL COMMENT '客户端幂等请求号',
|
||||
`operator_user_id` VARCHAR(36) NOT NULL COMMENT '提交人',
|
||||
`delivered_at` BIGINT NOT NULL COMMENT '实际发放时间',
|
||||
`verifier_user_id` VARCHAR(36) NULL COMMENT '核销或拒绝操作人',
|
||||
`verified_at` BIGINT NULL COMMENT '核销或拒绝时间',
|
||||
`source_delivery_id` VARCHAR(36) NULL COMMENT '冲正单指向原发放单',
|
||||
`reason` TEXT NULL COMMENT '拒绝、撤销或冲正原因',
|
||||
`remark` TEXT NULL COMMENT '备注',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_gao_package_delivery_request` (`store_id`, `request_no`),
|
||||
UNIQUE KEY `uk_gao_package_delivery_revoke_source` (`source_delivery_id`),
|
||||
KEY `idx_gao_package_delivery_package_time` (`customer_package_id`, `delivered_at`, `id`),
|
||||
KEY `idx_gao_package_delivery_customer_time` (`store_id`, `customer_id`, `delivered_at`, `id`),
|
||||
KEY `idx_gao_package_delivery_status` (`store_id`, `status`, `delivered_at`, `id`)
|
||||
) COMMENT='GAO 套餐发放操作';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_package_delivery_item` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`delivery_id` VARCHAR(36) NOT NULL COMMENT '发放单 ID',
|
||||
`customer_package_item_id` VARCHAR(36) NOT NULL COMMENT '客户套餐产品 ID',
|
||||
`quantity` DECIMAL(18,3) NOT NULL COMMENT '本次数量',
|
||||
`reserved_before` DECIMAL(18,3) NOT NULL COMMENT '操作前占用数量快照',
|
||||
`reserved_after` DECIMAL(18,3) NOT NULL COMMENT '操作后占用数量快照',
|
||||
`delivered_before` DECIMAL(18,3) NOT NULL COMMENT '操作前已发数量快照',
|
||||
`delivered_after` DECIMAL(18,3) NOT NULL COMMENT '操作后已发数量快照',
|
||||
`product_name_snapshot` VARCHAR(128) NOT NULL COMMENT '产品名称快照',
|
||||
`unit_snapshot` VARCHAR(32) NOT NULL COMMENT '产品单位快照',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_gao_package_delivery_item` (`delivery_id`, `customer_package_item_id`),
|
||||
KEY `idx_gao_package_delivery_item_package_item` (`customer_package_item_id`, `created_at`, `id`)
|
||||
) COMMENT='GAO 套餐发放产品明细';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `gao_fund_record` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`store_id` VARCHAR(36) NOT NULL COMMENT '门店 ID',
|
||||
`customer_id` VARCHAR(36) NULL COMMENT '客户 ID',
|
||||
`biz_type` VARCHAR(32) NOT NULL COMMENT '业务类型',
|
||||
`biz_id` VARCHAR(36) NOT NULL COMMENT '业务对象 ID',
|
||||
`operation_type` VARCHAR(32) NOT NULL COMMENT '资金操作类型',
|
||||
`status` VARCHAR(32) NOT NULL COMMENT '资金操作状态',
|
||||
`amount` BIGINT NOT NULL COMMENT '金额,单位分',
|
||||
`source_record_id` VARCHAR(36) NULL COMMENT '冲正时关联原资金记录',
|
||||
`request_no` VARCHAR(128) NOT NULL COMMENT '幂等请求号',
|
||||
`operator_user_id` VARCHAR(36) NOT NULL COMMENT '提交操作用户 ID',
|
||||
`verifier_user_id` VARCHAR(36) NULL COMMENT '收款核销用户 ID',
|
||||
`verified_at` BIGINT NULL COMMENT '收款核销时间',
|
||||
`occurred_at` BIGINT NOT NULL COMMENT '线下操作发生时间',
|
||||
`reason` TEXT NULL COMMENT '原因',
|
||||
`remark` TEXT NULL COMMENT '备注',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_gao_fund_record_request` (`store_id`, `request_no`),
|
||||
UNIQUE KEY `uk_gao_fund_record_revoke_source` (`source_record_id`),
|
||||
KEY `idx_gao_fund_record_biz_time` (`store_id`, `biz_type`, `biz_id`, `occurred_at`, `id`),
|
||||
KEY `idx_gao_fund_record_customer_time` (`store_id`, `customer_id`, `occurred_at`, `id`),
|
||||
KEY `idx_gao_fund_record_status` (`store_id`, `status`, `operation_type`, `occurred_at`, `id`)
|
||||
) COMMENT='GAO 通用资金操作流水';
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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.GaoCustomerPackageItemMapper">
|
||||
<select id="selectByCustomerPackageId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectByCustomerPackageIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="customerPackageIdList != null and !customerPackageIdList.isEmpty()">
|
||||
AND `customer_package_id` IN <foreach collection="customerPackageIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `customer_package_id`, `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<update id="updateReservedQuantity">
|
||||
UPDATE `gao_customer_package_item`
|
||||
SET `reserved_quantity` = `reserved_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `reserved_quantity` + #{delta} >= 0
|
||||
</update>
|
||||
<update id="updateDeliveredQuantity">
|
||||
UPDATE `gao_customer_package_item`
|
||||
SET `delivered_quantity` = `delivered_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `delivered_quantity` + #{delta} >= 0
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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.GaoCustomerPackageMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectByRequestNoAnyStore" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectByPurchaseEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `purchase_event_record_id` = #{purchaseEventRecordId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
p.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND p.`store_id` = #{storeId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND p.`customer_id` = #{customerId}</if>
|
||||
<if test="status != null">AND p.`status` = #{status}</if>
|
||||
<if test="paymentStatus != null">AND p.`payment_status` = #{paymentStatus}</if>
|
||||
<if test="refundStatus != null">AND p.`refund_status` = #{refundStatus}</if>
|
||||
<if test="beginAt != null">AND p.`purchased_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND p.`purchased_at` <= #{endAt}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (p.`package_name_snapshot` LIKE CONCAT('%', #{keyword}, '%') OR c.`name` LIKE CONCAT('%', #{keyword}, '%') OR c.`code` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_customer_package` p
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = p.`customer_id`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT p.* FROM `gao_customer_package` p
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = p.`customer_id`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY p.`purchased_at` DESC, p.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updatePendingPaidAmountDelta">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `pending_paid_amount` = `pending_paid_amount` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `pending_paid_amount` + #{delta} >= 0
|
||||
</update>
|
||||
<update id="updatePaidAmountDelta">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `paid_amount` = `paid_amount` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `paid_amount` + #{delta} >= 0
|
||||
</update>
|
||||
<update id="updateStatusIf">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `status` = #{toStatus}, `cancelled_at` = #{cancelledAt}, `cancel_operator_user_id` = #{cancelOperatorUserId}, `cancel_reason` = #{cancelReason}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -136,6 +136,9 @@
|
||||
AND (
|
||||
c.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR c.`name` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR c.`name_pinyin_full` LIKE CONCAT(#{keyword}, '%')
|
||||
OR c.`name_pinyin_initial` LIKE CONCAT(#{keyword}, '%')
|
||||
OR c.`name_pinyin_mixed` LIKE CONCAT(#{keyword}, '%')
|
||||
OR r.`remark` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR r.`operator_user_id` LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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.GaoFundRecordMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectRevokeBySourceRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `source_record_id` = #{sourceRecordId} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="countPendingReceiveByBizId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_fund_record`
|
||||
WHERE `biz_id` = #{bizId} AND `operation_type` = 'RECEIVE' AND `status` = 'PENDING' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByBizId" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `biz_id` = #{bizId} AND `deleted_at` IS NULL
|
||||
ORDER BY `occurred_at` DESC, `created_at` DESC
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
f.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND f.`store_id` = #{storeId}</if>
|
||||
<if test="customerPackageId != null and customerPackageId != ''">AND f.`biz_id` = #{customerPackageId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND f.`customer_id` = #{customerId}</if>
|
||||
<if test="operationType != null">AND f.`operation_type` = #{operationType}</if>
|
||||
<if test="status != null">AND f.`status` = #{status}</if>
|
||||
<if test="beginAt != null">AND f.`occurred_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND f.`occurred_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_fund_record` f WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT f.* FROM `gao_fund_record` f WHERE <include refid="queryWhere"/>
|
||||
ORDER BY f.`occurred_at` DESC, f.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updateStatusIf">
|
||||
UPDATE `gao_fund_record`
|
||||
SET `status` = #{toStatus}, `verifier_user_id` = #{verifierUserId}, `verified_at` = #{verifiedAt}, `reason` = #{reason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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.GaoPackageConfigItemMapper">
|
||||
<select id="selectByPackageConfigId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem">
|
||||
SELECT * FROM `gao_package_config_item`
|
||||
WHERE `package_config_id` = #{packageConfigId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectByPackageConfigIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfigItem">
|
||||
SELECT * FROM `gao_package_config_item`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="packageConfigIdList != null and !packageConfigIdList.isEmpty()">
|
||||
AND `package_config_id` IN <foreach collection="packageConfigIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `package_config_id`, `sort`, `created_at`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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.GaoPackageConfigMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfig">
|
||||
SELECT * FROM `gao_package_config`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN <foreach collection="idList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
<select id="selectValidList" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfig">
|
||||
SELECT * FROM `gao_package_config`
|
||||
WHERE `store_id` = #{storeId}
|
||||
AND `status` = 'ACTIVE'
|
||||
AND (`begin_at` IS NULL OR `begin_at` <= #{now})
|
||||
AND (`end_at` IS NULL OR #{now} <= `end_at`)
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_config`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (`name` LIKE CONCAT('%', #{keyword}, '%') OR `description` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfig">
|
||||
SELECT * FROM `gao_package_config`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (`name` LIKE CONCAT('%', #{keyword}, '%') OR `description` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
ORDER BY `sort`, `created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="selectByStoreIdAndName" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageConfig">
|
||||
SELECT * FROM `gao_package_config`
|
||||
WHERE `store_id` = #{storeId} AND `name` = #{name} AND `deleted_at` IS NULL
|
||||
<if test="excludeId != null">AND `id` != #{excludeId}</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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.GaoPackageDeliveryItemMapper">
|
||||
<select id="selectByDeliveryId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDeliveryItem">
|
||||
SELECT * FROM `gao_package_delivery_item`
|
||||
WHERE `delivery_id` = #{deliveryId} AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at`, `id`
|
||||
</select>
|
||||
<select id="selectByDeliveryIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDeliveryItem">
|
||||
SELECT * FROM `gao_package_delivery_item`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="deliveryIdList != null and !deliveryIdList.isEmpty()">
|
||||
AND `delivery_id` IN <foreach collection="deliveryIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `delivery_id`, `created_at`, `id`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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.GaoPackageDeliveryMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectRevokeBySourceDeliveryId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `source_delivery_id` = #{sourceDeliveryId} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="countPendingByCustomerPackageId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `status` = 'PENDING' AND `operation_type` = 'DELIVER' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="countVerifiedByCustomerPackageId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `status` = 'VERIFIED' AND `operation_type` = 'DELIVER' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByCustomerPackageId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `deleted_at` IS NULL
|
||||
ORDER BY `delivered_at` DESC, `created_at` DESC
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
d.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND d.`store_id` = #{storeId}</if>
|
||||
<if test="customerPackageId != null and customerPackageId != ''">AND d.`customer_package_id` = #{customerPackageId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND d.`customer_id` = #{customerId}</if>
|
||||
<if test="status != null">AND d.`status` = #{status}</if>
|
||||
<if test="operationType != null">AND d.`operation_type` = #{operationType}</if>
|
||||
<if test="beginAt != null">AND d.`delivered_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND d.`delivered_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery` d WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT d.* FROM `gao_package_delivery` d WHERE <include refid="queryWhere"/>
|
||||
ORDER BY d.`delivered_at` DESC, d.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updateStatusIf">
|
||||
UPDATE `gao_package_delivery`
|
||||
SET `status` = #{toStatus}, `verifier_user_id` = #{verifierUserId}, `verified_at` = #{verifiedAt}, `reason` = #{reason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user