zoujiajian 3 жил өмнө
parent
commit
22e5df4058

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

@@ -20,7 +20,11 @@
         cp.is_renew,
         cu.status as couponUserStatus,
         if(ck.id is null, 0, 1) as 'isAvailable',
-        if(ca.id is not null and ca.expiry_status = 0,false,true) flag
+        if(ca.id is not null and ca.expiry_status = 0,false,true) flag,
+        (case
+        when cu.valid_start_time > now() then 1
+        when cu.status = 'unused' then 0
+        end)                 as orderby
         from `coupon_user` cu
         left join `coupon` cp on cp.id = cu.coupon_id
         left join `coupon_active` ca on ca.id = cu.coupon_active_id
@@ -38,10 +42,10 @@
         and cu.channel != 'exCode'
         and cu.valid_end_time > now()
         <if test="couponId == null">
-            order by isAvailable desc
+            order by isAvailable desc,orderby
         </if>
         <if test="couponId != null">
-            order by case when cp.id = #{couponId} then 2 else isAvailable end desc
+            order by case when cp.id = #{couponId} then 2 else isAvailable end desc,orderby
         </if>)s where flag = 1 and couponUserStatus != 'used'
     </select>
 

+ 0 - 2
netflix-service/src/main/java/com/cyksj/service/coupon/impl/CouponFontServiceImpl.java

@@ -26,7 +26,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
 
@@ -170,7 +169,6 @@ public class CouponFontServiceImpl implements CouponFontService {
 				this.setCouponUserStatus(data, now);
 			});
 		});
-		availableCouponList.getRecords().stream().sorted(Comparator.comparing(CouponUserView::getIsAvailable).reversed());
 		return availableCouponList;
 	}