活动优惠模块
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
server:
|
||||
port: 8205
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
type-enums-package: com.atguigu.ssyx.enums
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://82.157.68.223:3306/shequ-activity?characterEncoding=utf-8&useSSL=false
|
||||
username: shequ-activity
|
||||
password: shequ-activity
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
@@ -0,0 +1,11 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-activity
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: localhost:8848
|
||||
username: nacos
|
||||
password: nacos
|
@@ -0,0 +1,94 @@
|
||||
<?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.atguigu.ssyx.activity.mapper.ActivityInfoMapper">
|
||||
|
||||
<resultMap id="ActivityRuleMap" type="com.atguigu.ssyx.model.activity.ActivityRule" autoMapping="true"></resultMap>
|
||||
<resultMap id="CouponInfoMap" type="com.atguigu.ssyx.model.activity.CouponInfo" autoMapping="true"></resultMap>
|
||||
<resultMap id="ActivitySkuMap" type="com.atguigu.ssyx.model.activity.ActivitySku" autoMapping="true"></resultMap>
|
||||
|
||||
<!-- //根据所有skuId列表获取参与活动-->
|
||||
<select id="selectCartActivity" resultMap="ActivitySkuMap">
|
||||
select
|
||||
info.id as activityId,
|
||||
sku.sku_id as skuId
|
||||
from activity_info info
|
||||
inner join activity_sku sku on info.id = sku.activity_id
|
||||
<where>
|
||||
and sku.sku_id in
|
||||
<foreach collection="skuIdList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</where>
|
||||
and now() between info.start_time and info.end_time
|
||||
</select>
|
||||
|
||||
<!--//2 根据skuId+分类id+userId查询优惠卷信息-->
|
||||
<select id="selectCouponInfoList" resultMap="CouponInfoMap">
|
||||
select info.id,
|
||||
info.coupon_type,
|
||||
info.coupon_name,
|
||||
info.amount,
|
||||
info.condition_amount,
|
||||
info.start_time,
|
||||
info.end_time,
|
||||
info.range_type,
|
||||
info.range_desc,
|
||||
info.publish_count,
|
||||
info.per_limit,
|
||||
info.use_count,
|
||||
info.receive_count,
|
||||
info.expire_time,
|
||||
info.publish_status,
|
||||
info.create_time,
|
||||
info.update_time,
|
||||
info.is_deleted,
|
||||
cuse.coupon_status
|
||||
from coupon_info info
|
||||
left join coupon_range crange on info.id = crange.coupon_id
|
||||
left join coupon_use cuse on info.id = cuse.coupon_id
|
||||
and cuse.user_id = #{userId}
|
||||
where (
|
||||
info.range_type = 1
|
||||
or (info.range_type = 2 and crange.range_id = #{skuId})
|
||||
or (info.range_type = 3 and crange.range_id = #{categoryId})
|
||||
)
|
||||
and now() between info.start_time and info.end_time
|
||||
order by info.amount desc
|
||||
</select>
|
||||
|
||||
<!--//根据skuId进行查询,查询sku对应活动里面规则列表-->
|
||||
<select id="findActivityRule" resultMap="ActivityRuleMap">
|
||||
select info.activity_type as activityType,
|
||||
rule.id,
|
||||
rule.activity_id,
|
||||
rule.condition_amount,
|
||||
rule.condition_num,
|
||||
rule.benefit_amount,
|
||||
rule.benefit_discount
|
||||
from activity_info info
|
||||
inner join activity_sku sku on info.id = sku.activity_id
|
||||
inner join activity_rule rule on info.id = rule.activity_id
|
||||
where sku.sku_id = #{skuId}
|
||||
and now() between info.start_time and info.end_time
|
||||
order by rule.condition_amount desc
|
||||
</select>
|
||||
|
||||
<!--// 如果之前参加过,活动正在进行中,排除商品-->
|
||||
<select id="selectSkuIdListExist" resultType="Long">
|
||||
select sku.sku_id
|
||||
from activity_info info
|
||||
inner join activity_sku sku on info.id = sku.activity_id
|
||||
<where>
|
||||
<if test="skuIdList != null">
|
||||
and sku.sku_id in
|
||||
<foreach collection="skuIdList" item="item"
|
||||
index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
and now() between info.start_time and info.end_time
|
||||
</select>
|
||||
<select id="selectActivityRuleList" resultType="com.atguigu.ssyx.model.activity.ActivityRule"></select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user