小程序我的券

This commit is contained in:
齐天大圣 2023-12-13 17:09:31 +08:00
parent 273f13cae9
commit e00b708435
9 changed files with 209 additions and 8 deletions

View File

@ -2,9 +2,9 @@ package com.fuint.business.marketingActivity.cardFavorable.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTO;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTOS;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService;
import com.fuint.framework.web.BaseController;
@ -60,7 +60,7 @@ public class CardFavorableController extends BaseController {
/**
* 新增数据
*
* @param cardFavorable 实体对象
* @param cardFavorableDTO 实体对象
* @return 新增结果
*/
@PostMapping
@ -89,5 +89,21 @@ public class CardFavorableController extends BaseController {
public ResponseObject delete(@RequestParam("idList") List<Long> idList) {
return getSuccessResult(this.cardFavorableService.removeByIds(idList));
}
/**
*查询优惠券接口(小程序端)
* @param pageNo
* @param pageSize
* @param cardFavorable
* @return
*/
@GetMapping("applet")
public ResponseObject selectAllByCondition(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("cardFuelDiesel") CardFavorableDTOS cardFavorableDTOS) {
Page page = new Page(pageNo, pageSize);
return getSuccessResult(this.cardFavorableService.selectAllByCondition(page,cardFavorableDTOS));
}
}

View File

@ -0,0 +1,13 @@
package com.fuint.business.marketingActivity.cardFavorable.dto;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import lombok.Data;
import java.io.Serializable;
@Data
public class CardFavorableDTOS extends CardFavorable implements Serializable {
private String couponType;
private Integer useStatus;
}

View File

@ -0,0 +1,11 @@
package com.fuint.business.marketingActivity.cardFavorable.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class QueryDTO implements Serializable {
//券名称
private String couponName;
}

View File

@ -1,9 +1,14 @@
package com.fuint.business.marketingActivity.cardFavorable.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.cardFavorable.dto.CardFavorableDTOS;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord;
import com.fuint.business.marketingActivity.cardFavorable.vo.CouponVO;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
* (CardFavorableRecord)表数据库访问层
@ -18,5 +23,11 @@ public interface CardFavorableRecordMapper extends BaseMapper<CardFavorableRecor
*/
HashMap<String,Integer> selectTotal(@Param("storeId")Integer storeId,@Param("id")Integer id);
/**
* 查询优惠券接口(小程序)
* @param cardFavorableDTOS
*/
// List<CouponVO> selectAllByCondition(Integer id);
IPage<CouponVO> selectAllByCondition(@Param("page") Page page, @Param("cardFavorableDTOS") CardFavorableDTOS cardFavorableDTOS);
}

View File

@ -22,5 +22,55 @@
where store_id = #{storeId}
and card_favorable_id = #{id}
</select>
<select id="selectAllByCondition" resultType="com.fuint.business.marketingActivity.cardFavorable.vo.CouponVO">
SELECT
card_favorables.couponType,
card_favorables.couponName,
card_favorables.id,
card_favorables.couponAmount,
card_favorables.couponContent
from
(SELECT
'优惠券' AS couponType,
cf.NAME couponName ,cf.id id,cf.discount_amount couponAmount,cf.satisfied_amount couponContent
FROM
card_favorable cf
LEFT JOIN card_favorable_record cfr ON cf.id = cfr.card_favorable_id
WHERE
cfr.mt_user_id = #{cardFavorableDTOS.id} UNION ALL
SELECT
'兑换券' AS couponType,
ce.NAME couponName, ce.id id, ce.count couponAmount, ce.use_instructions couponContent
FROM
card_exchange_record cer
LEFT JOIN card_exchange ce ON cer.card_exchange_id = ce.id
WHERE
cer.mt_user_id = #{cardFavorableDTOS.id}
and ce.type = 0 UNION ALL
SELECT
'洗车券' AS couponType,
ce.NAME couponName, ce.id id, ce.count couponAmount, ce.use_instructions couponContent
FROM
card_exchange_record cer
LEFT JOIN card_exchange ce ON cer.card_exchange_id = ce.id
WHERE
cer.mt_user_id = #{cardFavorableDTOS.id}
and ce.type = 1 UNION ALL
SELECT
'洗车卡' AS couponType,
ce.NAME couponName, ce.id id, ce.count couponAmount, ce.use_instructions couponContent
FROM
card_exchange_record cer
LEFT JOIN card_exchange ce ON cer.card_exchange_id = ce.id
WHERE
cer.mt_user_id = #{cardFavorableDTOS.id}
and ce.type = 2) AS card_favorables
<where>
<if test="cardFavorableDTOS.couponType != null">
and card_favorables.couponType = #{cardFavorableDTOS.couponType}
</if>
</where>
</select>
</mapper>

View File

@ -4,6 +4,7 @@ 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.cardFavorable.dto.CardFavorableDTO;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTOS;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableVO;
@ -45,5 +46,13 @@ public interface CardFavorableService extends IService<CardFavorable> {
* @return
*/
Boolean updateOneById(CardFavorableDTO cardFavorableDTO);
/**
* 查询优惠券接口(小程序)
* @param page
* @param cardFavorable
* @return
*/
IPage selectAllByCondition(Page page, CardFavorableDTOS cardFavorableDTOS);
}

View File

@ -5,11 +5,15 @@ 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.cardFavorable.dto.CardFavorableDTO;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTOS;
import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableMapper;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable;
import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableRecordMapper;
import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService;
import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableVO;
import com.fuint.business.marketingActivity.cardFavorable.vo.CouponVO;
import com.fuint.business.store.service.StoreService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
@ -17,6 +21,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
* (CardFavorable)表服务实现类
@ -29,6 +34,8 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
@Resource
private StoreService storeService;
@Resource
private CardFavorableRecordMapper cardFavorableRecordMapper;
/**
* 新增数据
* @param cardFavorableDTO
@ -143,5 +150,21 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
}
return updateById(cardFavorable);
}
/**
* 查询优惠券接口(小程序)
* @param page
* @param cardFavorable
* @return
*/
@Override
public IPage selectAllByCondition(Page page, CardFavorableDTOS cardFavorableDTOS) {
//获取登录用户id
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
Integer id = nowAccountInfo.getId();
cardFavorableDTOS.setId(id);
IPage<CouponVO> couponVOS = cardFavorableRecordMapper.selectAllByCondition(page,cardFavorableDTOS);
return couponVOS;
}
}

View File

@ -0,0 +1,27 @@
package com.fuint.business.marketingActivity.cardFavorable.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class CouponVO implements Serializable {
//券id
private Integer id;
//券类型
private String couponType;
//券金额
private String couponAmount;
//券名称
private String couponName;
//券内容
private String couponContent;
//使用状态 0:未使用 1已使用 2已失效
private String useStatus;
//券有效期
private String couponTime;
//券开始时间
private String startTime;
//券结束时间
private String endTime;
}

View File

@ -16,14 +16,14 @@
<view class="">{{item.name}}</view>
</view>
</view>
<view class="card-box" v-for="(item,index) in 3" :key="index">
<view class="card-box" v-for="(item,index) in cardsList" :key="index">
<view class="left-img">
<view class="huiz">120</view>
<view class="cbai">优惠券</view>
<view class="huiz">{{item.couponAmount}}</view>
<view class="cbai">{{item.couponType}}</view>
</view>
<view class="right-box">
<view class="title">新用户专享5折券</view>
<view class="hui-size">部分产品可用满240可用此券定期可用...</view>
<view class="title">{{item.couponName}}</view>
<view class="hui-size">{{item.couponContent}}</view>
<view class="dis-bt">
<view class="hui-size">有效期2023-11-30</view>
<view class="anniu">
@ -39,9 +39,18 @@
</template>
<script>
import request from "../../utils/request";
export default {
data() {
return {
cardsList: [],
query: {
couponType: '',
useStatus: 0,
pageNo: 1,
pageSize: 10
},
title: '',
tabindex: 0,
tapList: [{
@ -71,16 +80,48 @@
components: {
},
onShow() {
this.getGiftRecords()
},
methods: {
click(item) {
console.log('item', item);
this.cardsList = []
if (item.name == "全部") {
this.query.couponType = ''
this.getGiftRecords()
} else {
this.query.couponType = item.name
console.log(this.query.couponType);
this.getGiftRecords()
}
},
gettabingex(index) {
// useStatus
this.tabindex = index
console.log(index);
this.cardsList = []
this.query.useStatus = index
this.getGiftRecords()
},
goback() {
uni.navigateBack()
},
getGiftRecords() {
request({
url: 'business/marketingActivity/cardFavorable/applet',
method: 'get',
params: this.query
}).then(res => {
console.log(res)
if (res.code == 200) {
this.cardsList = res.data.records
}
})
}
}
}