更新9.26
This commit is contained in:
parent
bff50c9f3b
commit
eef9acc901
@ -148,7 +148,7 @@ public class CardCouponController extends BaseController {
|
||||
public ResponseObject selectAllByPageAndStoreId(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, @Param("cardCoupon") CardCoupon cardCoupon) {
|
||||
Page page = new Page(pageNo, pageSize);
|
||||
return getSuccessResult(this.cardCouponService.pageVo(page, cardCoupon));
|
||||
return getSuccessResult(this.cardCouponService.selectAllByPageAndStoreId(page, cardCoupon));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,12 @@ 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.CardCoupon;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUniVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 油站优惠卷表2024(CardCoupon)表数据库访问层
|
||||
*
|
||||
@ -17,5 +20,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface CardCouponMapper extends BaseMapper<CardCoupon> {
|
||||
IPage<CardCoupon> pageVo(Page page, @Param("cardCoupon") CardCoupon cardCoupon);
|
||||
|
||||
IPage<CardCouponUniVo> selectAllByPageAndStoreId(Page page, @Param("cardCoupon")CardCoupon cardCoupon);
|
||||
}
|
||||
|
||||
|
@ -27,5 +27,44 @@
|
||||
</where>
|
||||
order by cc.create_time desc
|
||||
</select>
|
||||
<select id="selectAllByPageAndStoreId"
|
||||
resultType="com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUniVo">
|
||||
SELECT
|
||||
cc.*,
|
||||
mt.NAME AS typeName,
|
||||
CASE
|
||||
cc.type
|
||||
WHEN 1 THEN
|
||||
'代金券'
|
||||
WHEN 2 THEN
|
||||
'兑换券'
|
||||
WHEN 3 THEN
|
||||
'折扣券'
|
||||
WHEN 4 THEN
|
||||
'油品立减券'
|
||||
WHEN 5 THEN
|
||||
'单品代金券'
|
||||
END AS statusName
|
||||
FROM
|
||||
card_coupon cc
|
||||
LEFT JOIN mt_store mt ON mt.id = cc.store_id
|
||||
<where>
|
||||
<if test="cardCoupon.storeId!=null and cardCoupon.storeId!=''">
|
||||
and cc.store_id = #{cardCoupon.storeId}
|
||||
</if>
|
||||
<if test="cardCoupon.name!=null and cardCoupon.name!=''">
|
||||
and cc.name like concat('%',#{cardCoupon.name},'%')
|
||||
</if>
|
||||
<if test="cardCoupon.status!=null and cardCoupon.status!=''">
|
||||
and cc.status = #{cardCoupon.status}
|
||||
</if>
|
||||
<if test="cardCoupon.type!=null and cardCoupon.type!=''">
|
||||
and cc.type = #{cardCoupon.type}
|
||||
</if>
|
||||
<if test="cardCoupon.putType!=null and cardCoupon.putType!=''">
|
||||
and cc.put_type = #{cardCoupon.putType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -20,5 +20,7 @@ public interface CardCouponService extends IService<CardCoupon> {
|
||||
* @return
|
||||
*/
|
||||
int isOnLine(Integer id);
|
||||
|
||||
IPage selectAllByPageAndStoreId(Page page, CardCoupon cardCoupon);
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,26 @@
|
||||
package com.fuint.business.marketingActivity.cardCoupon.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.CardCouponMapper;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUniVo;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import com.fuint.business.store.entity.MtStore;
|
||||
import com.fuint.business.store.mapper.MtStoreMapper;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 油站优惠卷表2024(CardCoupon)表服务实现类
|
||||
*
|
||||
@ -18,6 +30,8 @@ import org.springframework.stereotype.Service;
|
||||
@Service("cardCouponService")
|
||||
public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCoupon> implements CardCouponService {
|
||||
|
||||
@Autowired
|
||||
private MtStoreMapper mtStoreMapper;
|
||||
@Override
|
||||
public IPage<CardCoupon> pageVo(Page page, CardCoupon cardCoupon) {
|
||||
return baseMapper.pageVo( page, cardCoupon);
|
||||
@ -32,5 +46,27 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
|
||||
cardCoupon.setStatus(cardCoupon.getStatus().equals("0") ? "1" : "0");
|
||||
return baseMapper.updateById(cardCoupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage selectAllByPageAndStoreId(Page page, CardCoupon cardCoupon) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
//首先查询该店铺所有的优惠券
|
||||
cardCoupon.setPutType("2");
|
||||
cardCoupon.setStatus("1");
|
||||
IPage<CardCouponUniVo> cardCouponUniVos = baseMapper.selectAllByPageAndStoreId(page, cardCoupon);
|
||||
|
||||
List<CardCouponUniVo> cardCouponVos = new ArrayList<>();
|
||||
//循环店铺优惠券
|
||||
for (CardCouponUniVo coupon : cardCouponUniVos.getRecords()) {
|
||||
//查询该优惠券是否已到达限制数量
|
||||
if (coupon.getTfGetNum() < coupon.getTfTotal()){
|
||||
CardCouponUniVo cardCouponUniVo = BeanUtil.copyProperties(coupon, CardCouponUniVo.class);
|
||||
//计算领取的比例
|
||||
double scale = (coupon.getTfGetNum() * 1.0 / coupon.getTfTotal()) * 100;
|
||||
cardCouponUniVo.setScale(scale + "%");
|
||||
}
|
||||
}
|
||||
return cardCouponUniVos;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.fuint.business.marketingActivity.cardCoupon.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CardCouponUniVo extends CardCoupon {
|
||||
//店铺名称
|
||||
private String storeName;
|
||||
//已领取比例
|
||||
private String scale;
|
||||
//兑换券类型
|
||||
private String typeName;
|
||||
}
|
@ -11,6 +11,9 @@
|
||||
<if test="growthValueChange.userId != null and growthValueChange.userId != ''">
|
||||
and gvc.user_id = #{growthValueChange.userId}
|
||||
</if>
|
||||
<if test="growthValueChange.fromType != null and growthValueChange.fromType != ''">
|
||||
and gvc.from_type = #{growthValueChange.fromType}
|
||||
</if>
|
||||
<if test="growthValueChange.startTime != null and growthValueChange.startTime != ''">
|
||||
and gvc.create_time between #{growthValueChange.startTime} and #{growthValueChange.endTime}
|
||||
</if>
|
||||
|
Loading…
Reference in New Issue
Block a user