Bläddra i källkod

fix 优惠券优惠id查询

zoujiajian 3 år sedan
förälder
incheckning
2708651073

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/manage/coupon/CouponRecommendMapper.java

@@ -23,5 +23,5 @@ public interface CouponRecommendMapper extends BaseMapper<CouponRecommend> {
 
 	List<CouponAvailableRecommendView> getRecommendCouponList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser);
 
-	Page<CouponRecommendView> getRecommendCouponViewList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser, @Param("page") IPage<CouponRecommendView> page);
+	Page<CouponRecommendView> getRecommendCouponViewList(@Param("userId") Long userId, @Param("isNewUser") Boolean isNewUser, @Param("page") IPage<CouponRecommendView> page, @Param("couponId") Long couponId);
 }

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/manage/coupon/CouponUserMapper.java

@@ -24,7 +24,7 @@ public interface CouponUserMapper extends BaseMapper<CouponUser> {
 
 	Page<CouponActiveView> couponCenterList(@Param("userId") Long userId, IPage<CouponUserView> page);
 
-	Page<CouponUserView> couponPersonalList(@Param("userId") Long userId, @Param("page") Page<CouponUserView> page);
+	Page<CouponUserView> couponPersonalList(@Param("userId") Long userId, @Param("page") Page<CouponUserView> page, @Param("couponId") Long couponId);
 
 	CouponUserView getNewUserWelfareCouponsByUserId(@Param("userId") long userId, @Param("channel") CouponUser.Channel channel, @Param("now") DateTime now);
 }

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

@@ -35,6 +35,9 @@
         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
+        <if test="couponId != null">
+            and c.id = #{couponId}
+        </if>
         <if test='!isNewUser'>
             and c.scope !='newUser'
         </if>)s where couponStatus not in ('used','expired','noEffective') and flag is true order by `order`

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

@@ -173,7 +173,10 @@
                  left join `coupon` c on c.id = cu.coupon_id
                  left join `coupon_active` ca on ca.id = cu.coupon_active_id
         where cu.user_id = #{userId}
-          and cu.channel != 'exCode'
+        <if test="couponId !=null">
+            and cu.coupon_id = #{couponId}
+        </if>
+        and cu.channel != 'exCode'
         order by `orderby`)s where s.couponUserStatus != 'expired' and s.couponUserStatus != 'invalid'
     </select>
 

+ 4 - 4
netflix-web/src/main/java/com/cyksj/web/controller/coupon/CouponFrontController.java

@@ -89,9 +89,9 @@ public class CouponFrontController {
 	 * 个人优惠券列表
 	 */
 	@GetMapping("/personal/list")
-	public Result<Page<CouponUserView>> couponPersonalList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit) {
+	public Result<Page<CouponUserView>> couponPersonalList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit, Long couponId) {
 		Long userId = StpUserUtil.getLoginIdAsLong();
-		Page<CouponUserView> page = couponUserMapper.couponPersonalList(userId, new Page<>(start, limit));
+		Page<CouponUserView> page = couponUserMapper.couponPersonalList(userId, new Page<>(start, limit), couponId);
 		page.getRecords().forEach(data -> {
 			String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
 			data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
@@ -146,14 +146,14 @@ public class CouponFrontController {
 	 * 推荐优惠券列表
 	 */
 	@GetMapping("/recommend/list")
-	public Result<Page<CouponRecommendView>> getRecommendList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit) {
+	public Result<Page<CouponRecommendView>> getRecommendList(@RequestParam(defaultValue = "1") Long start, @RequestParam(defaultValue = "5") Long limit, Long couponId) {
 		Long userId = StpUserUtil.getLoginIdAsLong();
 		CouponNewUserView couponNewUserView = beanSearcher.searchFirst(CouponNewUserView.class, MapUtils.builder().field(CouponNewUserView::getUserId, userId).op(Operator.Equal).build());
 		Boolean isNewUser = true;
 		if (couponNewUserView != null) {
 			isNewUser = false;
 		}
-		Page<CouponRecommendView> page = couponRecommendMapper.getRecommendCouponViewList(userId, isNewUser, new Page<>(start, limit));
+		Page<CouponRecommendView> page = couponRecommendMapper.getRecommendCouponViewList(userId, isNewUser, new Page<>(start, limit), couponId);
 		page.getRecords().forEach(data -> {
 			if (data.getCouponStatus() == CouponActiveView.CouponStatus.received) {
 				data.setValidStartTime(data.getUserValidStartTime());