diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponUserController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponUserController.java index 742b85f66..c50768f31 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponUserController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponUserController.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUserVo; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; import org.springframework.web.bind.annotation.*; @@ -88,5 +89,13 @@ public class CardCouponUserController extends BaseController { public ResponseObject delete(@RequestParam("idList") List idList) { return getSuccessResult(this.cardCouponUserService.removeByIds(idList)); } + + @GetMapping("queryPage") + public ResponseObject queryPage(CardCouponUserVo cardCouponUserVo, + @RequestParam(value = "page",defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) { + Page page =new Page(pageNo,pageSize); + return getSuccessResult(cardCouponUserService.queryPage(page, cardCouponUserVo)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java index ac9616b1a..d2a92c445 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java @@ -1,7 +1,10 @@ package com.fuint.business.marketingActivity.cardCoupon.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUserVo; import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -27,5 +30,13 @@ public interface CardCouponUserMapper extends BaseMapper { * @return java.util.List **/ List selectAllList(@Param("storeId") Integer storeId,@Param("userId") Integer userId,@Param("nowDate") String nowDate); + + /** + * 小程序查询优惠券列表信息 + * @param page + * @param cardCouponUserVo + * @return + */ + IPage queryPage(Page page,@Param("entity") CardCouponUserVo cardCouponUserVo); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml index 76a791502..6550b31ef 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml @@ -16,4 +16,17 @@ AND cc.`type` != '2' AND main.start_time <= #{nowDate} AND main.end_time >= #{nowDate} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java index b6a668174..dc104a17e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java @@ -1,7 +1,10 @@ package com.fuint.business.marketingActivity.cardCoupon.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUserVo; import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; import io.swagger.models.auth.In; @@ -33,5 +36,13 @@ public interface CardCouponUserService extends IService { * @return java.util.List **/ List selectAllList(Integer storeId, Integer userId, Date nowDate); + + /** + * 小程序分页查询优惠券信息列表 + * @param page + * @param cardCouponUserVo + * @return + */ + IPage queryPage(Page page,CardCouponUserVo cardCouponUserVo); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java index 7e60c3e60..b73932e9b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java @@ -3,13 +3,18 @@ package com.fuint.business.marketingActivity.cardCoupon.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon; import com.fuint.business.marketingActivity.cardCoupon.mapper.CardCouponUserMapper; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService; import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUserVo; import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,27 +34,29 @@ public class CardCouponUserServiceImpl extends ServiceImpl queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(CardCouponUser::getCardCouponId,couponId).eq(CardCouponUser::getMtUserId,userId); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardCouponUser::getCardCouponId, couponId).eq(CardCouponUser::getMtUserId, userId); List list = this.list(queryWrapper); - if (CollectionUtil.isEmpty(list)){ - list =new ArrayList<>(); + if (CollectionUtil.isEmpty(list)) { + list = new ArrayList<>(); } - if (list.size()>=cardCoupon.getGetNumLimit()){ + if (list.size() >= cardCoupon.getGetNumLimit()) { //当前用户领取已到达上限 return false; } @@ -72,7 +79,71 @@ public class CardCouponUserServiceImpl extends ServiceImpl selectAllList(Integer storeId, Integer userId, Date nowDate) { - return cardCouponUserMapper.selectAllList(storeId,userId, DateUtil.formatDate(nowDate)); + return cardCouponUserMapper.selectAllList(storeId, userId, DateUtil.formatDate(nowDate)); + } + + @Override + public IPage queryPage(Page page, CardCouponUserVo cardCouponUserVo) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardCouponUserVo.setMtUserId(nowAccountInfo.getId()); + IPage cardCouponUserVoIPage = baseMapper.queryPage(page, cardCouponUserVo); + for (CardCouponUserVo record : cardCouponUserVoIPage.getRecords()) { + // 未使用 + if (record.getStatus().equals("0")) { + if (record.getType().equals("1")) { + record.setBgImg("http://47.94.122.58:83/coup1.png"); + } + if (record.getType().equals("2")) { + record.setBgImg("http://47.94.122.58:83/coup5.png"); + } + if (record.getType().equals("3")) { + record.setBgImg("http://47.94.122.58:83/coup2.png"); + } + if (record.getType().equals("4")) { + record.setBgImg("http://47.94.122.58:83/coup3.png"); + } + if (record.getType().equals("5")) { + record.setBgImg("http://47.94.122.58:83/coup4.png"); + } + } + // 已核销 + if (record.getStatus().equals("1")) { + if (record.getType().equals("1")) { + record.setBgImg("http://47.94.122.58:83/youp1.png"); + } + if (record.getType().equals("2")) { + record.setBgImg("http://47.94.122.58:83/youp5.png"); + } + if (record.getType().equals("3")) { + record.setBgImg("http://47.94.122.58:83/youp2.png"); + } + if (record.getType().equals("4")) { + record.setBgImg("http://47.94.122.58:83/youp3.png"); + } + if (record.getType().equals("5")) { + record.setBgImg("http://47.94.122.58:83/youp4.png"); + } + } + // 已过期 + if (record.getStatus().equals("2")) { + if (record.getType().equals("1")) { + record.setBgImg("http://47.94.122.58:83/qoup1.png"); + } + if (record.getType().equals("2")) { + record.setBgImg("http://47.94.122.58:83/qoup5.png"); + } + if (record.getType().equals("3")) { + record.setBgImg("http://47.94.122.58:83/qoup2.png"); + } + if (record.getType().equals("4")) { + record.setBgImg("http://47.94.122.58:83/qoup3.png"); + } + if (record.getType().equals("5")) { + record.setBgImg("http://47.94.122.58:83/qoup4.png"); + } + } + } + return cardCouponUserVoIPage; } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponUserVo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponUserVo.java new file mode 100644 index 000000000..35330311b --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/vo/CardCouponUserVo.java @@ -0,0 +1,26 @@ +package com.fuint.business.marketingActivity.cardCoupon.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import lombok.Data; + +@Data +public class CardCouponUserVo extends CardCouponUser { + /** + * 优惠券名称 + */ + private String couponName; + /** + * 卡券类型 1代金券、2兑换券、3折扣券、4油品立减券、5单品代金券 + */ + private String type; + /** + * 使用条件 + */ + private String useCondition; + /** + * 背景图 + */ + @TableField(exist = false) + private String bgImg; +} diff --git a/gasStation-uni/pagesMy/Coupons/Coupons.vue b/gasStation-uni/pagesMy/Coupons/Coupons.vue index 8d4a4a27f..b552665ac 100644 --- a/gasStation-uni/pagesMy/Coupons/Coupons.vue +++ b/gasStation-uni/pagesMy/Coupons/Coupons.vue @@ -3,7 +3,7 @@ - 我的券 + 我的优惠券 @@ -72,9 +72,8 @@ shows: false, query: { storeId: '', - couponType: '', - useStatus: 0, - pageNo: 1, + status: 0, + page: 1, pageSize: 10 }, title: '', @@ -108,8 +107,6 @@ onLoad() { this.query.storeId = uni.getStorageSync("storeId") this.getGiftRecords() - this.isDrawDown() - this.getAllCardFavorables() }, onShow() { @@ -219,16 +216,14 @@ }, getGiftRecords() { request({ - url: 'business/marketingActivity/cardFavorable/applet', + url: 'cardCouponUser/queryPage', method: 'get', params: this.query }).then(res => { - console.log(res) if (res.code == 200) { this.cardsList = res.data.records } - console.log(res.data.records); - console.log(this.cardsList); + console.log(res.data, this.cardsList, 226); }) } }