zoujiajian 3 anos atrás
pai
commit
7cf143ef65

+ 1 - 0
netflix-dao/src/main/resources/mapper/CouponRecommendMapper.xml

@@ -30,6 +30,7 @@
         from coupon_recommend cr left join coupon c on c.id = cr.coupon_id
         left join coupon_user cu on cu.coupon_id = c.id and cu.user_id = #{userId}
         where cr.deleted is true and c.deleted is true and cr.status = 1
+        and cu.id is null
         <if test='!isNewUser'>
             and c.scope !='newUser'
         </if>)s where couponStatus != 'used' and flag is true order by `order`

+ 6 - 6
netflix-dao/src/main/resources/mapper/CouponUserMapper.xml

@@ -129,19 +129,19 @@
                cu.valid_end_time,
                c.is_renew,
                (case
-                    when cu.valid_end_time &lt; now() then 'expired'
-                    when ca.status = 0 then 'invalid'
+                    when cu.status != 'used' and cu.valid_end_time &lt; now() then 'expired'
+                    when cu.status != 'used' and ca.status = 0 then 'invalid'
                     else cu.status end) as couponUserStatus,
                (case
-                    when cu.status = 'unused' then 0
+                    when cu.status = 'used' then 4
+                    when ca.status = 0 then 3
                     when cu.valid_start_time &lt; now() then 1
                     when cu.valid_end_time &lt; now() then 2
-                    when ca.status = 0 then 3
-                    when cu.status = 'used' then 4
+                    when cu.status = 'unused' then 0
                    end)                 as orderby
         from `coupon_user` cu
                  left join `coupon` c on c.id = cu.coupon_id
-                 left join `coupon_active` ca on ca.coupon_id = c.id
+                 left join `coupon_active` ca on ca.id = cu.coupon_active_id
         where cu.user_id = #{userId}
           and cu.channel != 'exCode'
           and ca.id is not null