1
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.ruoyi.jarvis.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 礼金信息对象 gift_coupon
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GiftCoupon extends BaseEntity {
|
||||
|
||||
/** 礼金Key(主键) */
|
||||
@Excel(name = "礼金Key")
|
||||
private String giftCouponKey;
|
||||
|
||||
/** 商品SKU ID */
|
||||
@Excel(name = "商品SKU")
|
||||
private String skuId;
|
||||
|
||||
/** 商品名称 */
|
||||
@Excel(name = "商品名称")
|
||||
private String skuName;
|
||||
|
||||
/** 礼金类型(g=自营,pop=POP) */
|
||||
@Excel(name = "类型", readConverterExp = "g=自营,pop=POP")
|
||||
private String owner;
|
||||
|
||||
/** 礼金金额(元) */
|
||||
@Excel(name = "礼金金额")
|
||||
private Double amount;
|
||||
|
||||
/** 礼金数量 */
|
||||
@Excel(name = "礼金数量")
|
||||
private Integer quantity;
|
||||
|
||||
/** 已使用数量 */
|
||||
@Excel(name = "已使用数量")
|
||||
private Integer usedQuantity;
|
||||
|
||||
/** 总分摊金额 */
|
||||
@Excel(name = "总分摊金额")
|
||||
private Double totalOcsAmount;
|
||||
|
||||
/** 使用次数(订单数量) */
|
||||
@Excel(name = "使用次数")
|
||||
private Integer useCount;
|
||||
|
||||
/** 创建时间(首次创建时间) */
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 过期时间 */
|
||||
@Excel(name = "过期时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireTime;
|
||||
|
||||
/** 是否过期(0否 1是) */
|
||||
@Excel(name = "是否过期", readConverterExp = "0=否,1=是")
|
||||
private Integer isExpired;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.jarvis.mapper;
|
||||
|
||||
import com.ruoyi.jarvis.domain.GiftCoupon;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 礼金信息 Mapper 接口
|
||||
*/
|
||||
public interface GiftCouponMapper {
|
||||
|
||||
/**
|
||||
* 查询礼金列表(从订单表中汇总)
|
||||
*/
|
||||
List<GiftCoupon> selectGiftCouponList(GiftCoupon giftCoupon);
|
||||
|
||||
/**
|
||||
* 根据礼金Key查询详情
|
||||
*/
|
||||
GiftCoupon selectGiftCouponByKey(String giftCouponKey);
|
||||
|
||||
/**
|
||||
* 查询礼金统计信息
|
||||
*/
|
||||
GiftCoupon selectGiftCouponStatistics(GiftCoupon giftCoupon);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.jarvis.service;
|
||||
|
||||
import com.ruoyi.jarvis.domain.GiftCoupon;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 礼金信息 Service 接口
|
||||
*/
|
||||
public interface IGiftCouponService {
|
||||
|
||||
/**
|
||||
* 查询礼金列表
|
||||
*/
|
||||
List<GiftCoupon> selectGiftCouponList(GiftCoupon giftCoupon);
|
||||
|
||||
/**
|
||||
* 根据礼金Key查询详情
|
||||
*/
|
||||
GiftCoupon selectGiftCouponByKey(String giftCouponKey);
|
||||
|
||||
/**
|
||||
* 查询礼金统计信息
|
||||
*/
|
||||
GiftCoupon selectGiftCouponStatistics(GiftCoupon giftCoupon);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.jarvis.service.impl;
|
||||
|
||||
import com.ruoyi.jarvis.domain.GiftCoupon;
|
||||
import com.ruoyi.jarvis.mapper.GiftCouponMapper;
|
||||
import com.ruoyi.jarvis.service.IGiftCouponService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 礼金信息 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class GiftCouponServiceImpl implements IGiftCouponService {
|
||||
|
||||
@Autowired
|
||||
private GiftCouponMapper giftCouponMapper;
|
||||
|
||||
@Override
|
||||
public List<GiftCoupon> selectGiftCouponList(GiftCoupon giftCoupon) {
|
||||
return giftCouponMapper.selectGiftCouponList(giftCoupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiftCoupon selectGiftCouponByKey(String giftCouponKey) {
|
||||
return giftCouponMapper.selectGiftCouponByKey(giftCouponKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiftCoupon selectGiftCouponStatistics(GiftCoupon giftCoupon) {
|
||||
return giftCouponMapper.selectGiftCouponStatistics(giftCoupon);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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.ruoyi.jarvis.mapper.GiftCouponMapper">
|
||||
|
||||
<resultMap id="GiftCouponResult" type="GiftCoupon">
|
||||
<result property="giftCouponKey" column="gift_coupon_key"/>
|
||||
<result property="skuId" column="sku_id"/>
|
||||
<result property="skuName" column="sku_name"/>
|
||||
<result property="owner" column="owner"/>
|
||||
<result property="amount" column="amount"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="usedQuantity" column="used_quantity"/>
|
||||
<result property="totalOcsAmount" column="total_ocs_amount"/>
|
||||
<result property="useCount" column="use_count"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="expireTime" column="expire_time"/>
|
||||
<result property="isExpired" column="is_expired"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGiftCouponBase">
|
||||
SELECT
|
||||
gift_coupon_key,
|
||||
MAX(sku_id) as sku_id,
|
||||
MAX(sku_name) as sku_name,
|
||||
MAX(owner) as owner,
|
||||
COUNT(DISTINCT order_id) as use_count,
|
||||
SUM(gift_coupon_ocs_amount) as total_ocs_amount,
|
||||
MIN(order_time) as create_time,
|
||||
MAX(expire_time) as expire_time,
|
||||
CASE
|
||||
WHEN MAX(expire_time) IS NOT NULL AND MAX(expire_time) < NOW() THEN 1
|
||||
ELSE 0
|
||||
END as is_expired
|
||||
FROM (
|
||||
SELECT
|
||||
or_rows.gift_coupon_key,
|
||||
or_rows.sku_id,
|
||||
or_rows.sku_name,
|
||||
CASE
|
||||
WHEN or_rows.pop_id IS NULL OR or_rows.pop_id = '' THEN 'g'
|
||||
ELSE 'pop'
|
||||
END as owner,
|
||||
or_rows.order_id,
|
||||
or_rows.gift_coupon_ocs_amount,
|
||||
or_rows.order_time,
|
||||
NULL as expire_time
|
||||
FROM order_rows or_rows
|
||||
WHERE or_rows.gift_coupon_key IS NOT NULL AND or_rows.gift_coupon_key != ''
|
||||
<if test="giftCouponKey != null and giftCouponKey != ''">
|
||||
AND or_rows.gift_coupon_key like concat('%', #{giftCouponKey}, '%')
|
||||
</if>
|
||||
<if test="skuId != null and skuId != ''">
|
||||
AND or_rows.sku_id like concat('%', #{skuId}, '%')
|
||||
</if>
|
||||
<if test="skuName != null and skuName != ''">
|
||||
AND or_rows.sku_name like concat('%', #{skuName}, '%')
|
||||
</if>
|
||||
<if test="owner != null and owner != ''">
|
||||
AND CASE
|
||||
WHEN or_rows.pop_id IS NULL OR or_rows.pop_id = '' THEN 'g'
|
||||
ELSE 'pop'
|
||||
END = #{owner}
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
AND or_rows.order_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
AND or_rows.order_time <= #{params.endTime}
|
||||
</if>
|
||||
) gc
|
||||
GROUP BY gift_coupon_key
|
||||
<if test="isExpired != null">
|
||||
HAVING CASE
|
||||
WHEN MAX(expire_time) IS NOT NULL AND MAX(expire_time) < NOW() THEN 1
|
||||
ELSE 0
|
||||
END = #{isExpired}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectGiftCouponList" parameterType="GiftCoupon" resultMap="GiftCouponResult">
|
||||
<include refid="selectGiftCouponBase"/>
|
||||
ORDER BY create_time DESC, gift_coupon_key DESC
|
||||
</select>
|
||||
|
||||
<select id="selectGiftCouponByKey" parameterType="String" resultMap="GiftCouponResult">
|
||||
SELECT
|
||||
gift_coupon_key,
|
||||
MAX(sku_id) as sku_id,
|
||||
MAX(sku_name) as sku_name,
|
||||
MAX(owner) as owner,
|
||||
COUNT(DISTINCT order_id) as use_count,
|
||||
SUM(gift_coupon_ocs_amount) as total_ocs_amount,
|
||||
MIN(order_time) as create_time,
|
||||
MAX(expire_time) as expire_time,
|
||||
CASE
|
||||
WHEN MAX(expire_time) IS NOT NULL AND MAX(expire_time) < NOW() THEN 1
|
||||
ELSE 0
|
||||
END as is_expired
|
||||
FROM (
|
||||
SELECT
|
||||
or_rows.gift_coupon_key,
|
||||
or_rows.sku_id,
|
||||
or_rows.sku_name,
|
||||
CASE
|
||||
WHEN or_rows.pop_id IS NULL OR or_rows.pop_id = '' THEN 'g'
|
||||
ELSE 'pop'
|
||||
END as owner,
|
||||
or_rows.order_id,
|
||||
or_rows.gift_coupon_ocs_amount,
|
||||
or_rows.order_time,
|
||||
NULL as expire_time
|
||||
FROM order_rows or_rows
|
||||
WHERE or_rows.gift_coupon_key IS NOT NULL AND or_rows.gift_coupon_key != ''
|
||||
AND or_rows.gift_coupon_key = #{giftCouponKey}
|
||||
) gc
|
||||
GROUP BY gift_coupon_key
|
||||
</select>
|
||||
|
||||
<select id="selectGiftCouponStatistics" parameterType="GiftCoupon" resultMap="GiftCouponResult">
|
||||
SELECT
|
||||
COUNT(*) as use_count,
|
||||
COALESCE(SUM(total_ocs_amount), 0) as total_ocs_amount
|
||||
FROM (
|
||||
<include refid="selectGiftCouponBase"/>
|
||||
) stats
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user