提交 0e0672de authored 作者: luojie's avatar luojie

修复优惠券分类sql

上级 52f23090
...@@ -58,10 +58,9 @@ public class TbCfCouponController { ...@@ -58,10 +58,9 @@ public class TbCfCouponController {
public Result<CouponItem> queryCouponByUserId(@ApiParam("用户Id")@PathVariable("userId") String userId) { public Result<CouponItem> queryCouponByUserId(@ApiParam("用户Id")@PathVariable("userId") String userId) {
return tbCfIssueCouponService.queryCouponByUserId(userId); return tbCfIssueCouponService.queryCouponByUserId(userId);
} }
/* @ApiOperation("更改优惠券状态") /* @ApiOperation("更改优惠券状态")
@GetMapping("/changCouponStatus/{userId}/{couponId}") @GetMapping("/changCouponStatus/{userId}/{couponId}")
public Result changCouponStatus(@ApiParam("用户Id")@PathVariable("userId") String userId,@ApiParam("优惠券Id")@PathVariable("couponId") String couponId){ public Result changCouponStatus(@ApiParam("用户Id")@PathVariable("userId") String userId,@ApiParam("优惠券Id")@PathVariable("couponId") String couponId){
return tbCfIssueCouponService.changeCouponStatus(userId,couponId); return tbCfIssueCouponService.changeCouponStatus(userId,couponId);
}*/ }*/
} }
...@@ -741,6 +741,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -741,6 +741,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
List<TbCfCouponEntity> usableCouponList = new ArrayList<>(); List<TbCfCouponEntity> usableCouponList = new ArrayList<>();
//不可用优惠券 //不可用优惠券
List<TbCfCouponEntity> unusableCouponList = new ArrayList<>(); List<TbCfCouponEntity> unusableCouponList = new ArrayList<>();
BigDecimal itemsPrice = tbCfOrder.getItemsPrice(); BigDecimal itemsPrice = tbCfOrder.getItemsPrice();
for (TbCfCouponEntity tbCfCoupon : tbCfCouponList) { for (TbCfCouponEntity tbCfCoupon : tbCfCouponList) {
if (itemsPrice.compareTo(tbCfCoupon.getWithAmount()) >= 0) { if (itemsPrice.compareTo(tbCfCoupon.getWithAmount()) >= 0) {
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
`create_user_id`, `create_user_id`,
`create_time`, `create_time`,
`update_user_id`, `update_user_id`,
`update_time` `update_time`,
`coupon_vaild`
from tb_cf_coupon a left join tb_cf_coupon_category b on a.coupon_category_id = b.coupon_category_id from tb_cf_coupon a left join tb_cf_coupon_category b on a.coupon_category_id = b.coupon_category_id
where coupon_id = #{id} where coupon_id = #{id}
</select> </select>
...@@ -76,7 +77,8 @@ ...@@ -76,7 +77,8 @@
`create_user_id`, `create_user_id`,
`create_time`, `create_time`,
`update_user_id`, `update_user_id`,
`update_time` `update_time`,
`coupon_vaild`
from tb_cf_coupon a left join tb_cf_coupon_category b on a.coupon_category_id = b.coupon_category_id from tb_cf_coupon a left join tb_cf_coupon_category b on a.coupon_category_id = b.coupon_category_id
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
...@@ -124,7 +126,8 @@ ...@@ -124,7 +126,8 @@
`create_user_id`, `create_user_id`,
`create_time`, `create_time`,
`update_user_id`, `update_user_id`,
`update_time`) `update_time`,
`coupon_vaild`)
values( values(
#{couponId}, #{couponId},
#{couponCategoryId}, #{couponCategoryId},
...@@ -145,7 +148,8 @@ ...@@ -145,7 +148,8 @@
#{createUserId}, #{createUserId},
#{createTime}, #{createTime},
#{updateUserId}, #{updateUserId},
#{updateTime}) #{updateTime}),
#{coupon_vaild})
</insert> </insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"> <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
...@@ -170,6 +174,7 @@ ...@@ -170,6 +174,7 @@
<if test="createTime != null">`create_time` = #{createTime}, </if> <if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateUserId != null">`update_user_id` = #{updateUserId}, </if> <if test="updateUserId != null">`update_user_id` = #{updateUserId}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if> <if test="updateTime != null">`update_time` = #{updateTime}</if>
<if test="couponVaild != null">`coupon_vaild` = #{couponVaild}</if>
</set> </set>
where coupon_id = #{couponId} where coupon_id = #{couponId}
</update> </update>
...@@ -188,8 +193,10 @@ ...@@ -188,8 +193,10 @@
</delete> </delete>
<!--查询用户所有有效的优惠券--> <!--查询用户所有有效的优惠券-->
<!--查询用户所有有效的优惠券-->
<select id="queryUserAvailableCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"> <select id="queryUserAvailableCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select DISTINCT select DISTINCT
t2.coupon_id, t2.coupon_id,
t2.coupon_category_id, t2.coupon_category_id,
t4.coupon_category_name, t4.coupon_category_name,
...@@ -210,14 +217,18 @@ ...@@ -210,14 +217,18 @@
t2.create_user_id, t2.create_user_id,
t2.create_time, t2.create_time,
t2.update_user_id, t2.update_user_id,
t2.update_time t2.update_time,
from tb_cf_take_coupon t1,tb_cf_coupon t2,tb_cf_issue_coupon t3,tb_cf_coupon_category t4 t2.coupon_vaild
where ((t3.user_id=#{userId} and t3.coupon_id=t2.coupon_id and t2.status=1 and t3.enable_flag=1) from tb_cf_coupon t2 left join tb_cf_coupon_category t4 ON t2.coupon_category_id= t4.coupon_category_id
or (t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and t2.status=1 and t1.enable_flag=1)) left join tb_cf_take_coupon t1 on t1.coupon_id=t2.coupon_id
and <![CDATA[ t2.valid_start_time<=#{nowTime}]]> and <![CDATA[t2.valid_end_time>=#{nowTime}]]> left join tb_cf_issue_coupon t3 on t3.coupon_id=t2.coupon_id
where ((t1.user_id=#{userId} and t1.enable_flag=1 )
or (t3.user_id=#{userId} and t3.enable_flag=1))
and t2.status=1 and (<![CDATA[ t2.valid_start_time<=#{nowTime}]]> and <![CDATA[t2.valid_end_time>=#{nowTime}]]>)
</select> </select>
<!--更改优惠券统计-->
<!--更改优惠券统计-->
<update id="updateUsedCount"> <update id="updateUsedCount">
update tb_cf_coupon set used_count=used_count+1 where coupon_id=#{couponId} update tb_cf_coupon set used_count=used_count+1 where coupon_id=#{couponId}
</update> </update>
...@@ -225,7 +236,7 @@ ...@@ -225,7 +236,7 @@
<!--获取已使用的优惠券--> <!--获取已使用的优惠券-->
<select id="queryUserUsedCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"> <select id="queryUserUsedCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select DISTINCT select DISTINCT
t2.coupon_id, t2.coupon_id,
t2.coupon_category_id, t2.coupon_category_id,
t4.coupon_category_name, t4.coupon_category_name,
t2.coupon_use, t2.coupon_use,
...@@ -245,15 +256,19 @@ ...@@ -245,15 +256,19 @@
t2.create_user_id, t2.create_user_id,
t2.create_time, t2.create_time,
t2.update_user_id, t2.update_user_id,
t2.update_time t2.update_time,
from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3,tb_cf_coupon_category t4 t2.coupon_vaild
where ((t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and t1.enable_flag=0) from tb_cf_coupon t2 left join tb_cf_coupon_category t4 ON t2.coupon_category_id= t4.coupon_category_id
or (t3.user_id=#{userId} and t3.coupon_id=t2.coupon_id and t3.enable_flag=0)) left join tb_cf_take_coupon t1 on t1.coupon_id=t2.coupon_id
left join tb_cf_issue_coupon t3 on t3.coupon_id=t2.coupon_id
where (t1.user_id=#{userId} and t1.enable_flag=0)
or (t3.user_id=#{userId} and t3.enable_flag=0)
</select> </select>
<!--获取已过期的优惠券--> <!--获取已过期的优惠券-->
<select id="queryUserExpiredoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"> <select id="queryUserExpiredoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select DISTINCT select DISTINCT
t2.coupon_id, t2.coupon_id,
t2.coupon_category_id, t2.coupon_category_id,
t4.coupon_category_name, t4.coupon_category_name,
t2.coupon_use, t2.coupon_use,
...@@ -273,11 +288,16 @@ ...@@ -273,11 +288,16 @@
t2.create_user_id, t2.create_user_id,
t2.create_time, t2.create_time,
t2.update_user_id, t2.update_user_id,
t2.update_time from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3,tb_cf_coupon_category t4 t2.update_time,
where ((t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t1.enable_flag=1) t2.coupon_vaild
or (t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t1.enable_flag=1)) from tb_cf_coupon t2 left join tb_cf_coupon_category t4 ON t2.coupon_category_id= t4.coupon_category_id
left join tb_cf_take_coupon t1 on t1.coupon_id=t2.coupon_id
left join tb_cf_issue_coupon t3 on t3.coupon_id=t2.coupon_id
where ((t1.user_id=#{userId} and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t1.enable_flag=1)
or (t3.user_id=#{userId} and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t3.enable_flag=1))
</select> </select>
<select id="getCouponAndVaildAll" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"> <select id="getCouponAndVaildAll" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select select
`coupon_id`, `coupon_id`,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论