This commit is contained in:
cun-nan 2024-09-24 16:30:49 +08:00
parent 507bc794c5
commit a68677f0b8
7 changed files with 155 additions and 19 deletions

View File

@ -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<Long> 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));
}
}

View File

@ -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<CardCouponUser> {
* @return java.util.List<com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO>
**/
List<CardCouponVO> selectAllList(@Param("storeId") Integer storeId,@Param("userId") Integer userId,@Param("nowDate") String nowDate);
/**
* 小程序查询优惠券列表信息
* @param page
* @param cardCouponUserVo
* @return
*/
IPage<CardCouponUserVo> queryPage(Page page,@Param("entity") CardCouponUserVo cardCouponUserVo);
}

View File

@ -16,4 +16,17 @@
AND cc.`type` != '2'
AND main.start_time &lt;= #{nowDate} AND main.end_time &gt;= #{nowDate}
</select>
<select id="queryPage" resultType="com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUserVo">
SELECT ccu.*,cc.`name` couponName,cc.type,cc.use_condition FROM card_coupon_user ccu
LEFT JOIN card_coupon cc ON ccu.card_coupon_id = cc.id
<where>
ccu.mt_user_id = #{entity.mtUserId}
<if test="entity.storeId != null and entity.storeId != ''">
and ccu.store_id = #{entity.storeId}
</if>
<if test="entity.status != null and entity.status != ''">
and ccu.status = #{entity.status}
</if>
</where>
</select>
</mapper>

View File

@ -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<CardCouponUser> {
* @return java.util.List<com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO>
**/
List<CardCouponVO> selectAllList(Integer storeId, Integer userId, Date nowDate);
/**
* 小程序分页查询优惠券信息列表
* @param page
* @param cardCouponUserVo
* @return
*/
IPage<CardCouponUserVo> queryPage(Page page,CardCouponUserVo cardCouponUserVo);
}

View File

@ -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<CardCouponUserMapper,
private CardCouponService cardCouponService;
@Autowired
private CardCouponUserMapper cardCouponUserMapper;
/**
* 判断用户是否还能领取该优惠卷
*
* @param couponId 优惠卷id
* @param userId 用户主键
* @param userId 用户主键
* @return true false 不能
*/
@Override
public boolean userCanGet(Integer couponId, Integer userId) {
CardCoupon cardCoupon = cardCouponService.getById(couponId);
if (cardCoupon.getTfTotal()<=cardCoupon.getTfGetNum()){
if (cardCoupon.getTfTotal() <= cardCoupon.getTfGetNum()) {
//领取数量大于策略中的送出总量
return false;
return false;
}
String nowDate = DateUtil.format(new Date(), "yyyy-MM-dd");
LambdaQueryWrapper<CardCouponUser> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.eq(CardCouponUser::getCardCouponId,couponId).eq(CardCouponUser::getMtUserId,userId);
LambdaQueryWrapper<CardCouponUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardCouponUser::getCardCouponId, couponId).eq(CardCouponUser::getMtUserId, userId);
List<CardCouponUser> 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<CardCouponUserMapper,
**/
@Override
public List<CardCouponVO> 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<CardCouponUserVo> queryPage(Page page, CardCouponUserVo cardCouponUserVo) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
cardCouponUserVo.setMtUserId(nowAccountInfo.getId());
IPage<CardCouponUserVo> 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;
}
}

View File

@ -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;
}

View File

@ -3,7 +3,7 @@
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">我的</view>
<view class="my-text">我的优惠</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
@ -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);
})
}
}