Commit 08291522 by 吕明尚

首页的用户信息添加优惠卷数量

parent 538f83d0
package share.web.controller.system;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
......@@ -28,9 +28,13 @@ public class SConsumerCouponController extends BaseController {
/**
* 查询优惠券领取记录列表
*/
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/list")
public TableDataInfo list(SConsumerCoupon sConsumerCoupon) {
public TableDataInfo list( String useStatus) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
if(StringUtils.isNotBlank(useStatus)){
sConsumerCoupon.setUseStatus(useStatus);
}
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setConsumerId(user.getId());
startPage();
......@@ -41,17 +45,19 @@ public class SConsumerCouponController extends BaseController {
/**
* 获取优惠券领取记录详细信息
*/
@PreAuthorize("@ss.hasPermi('system:coupon:query')")
// @PreAuthorize("@ss.hasPermi('system:coupon:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(sConsumerCouponService.selectSConsumerCouponById(id));
}
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/query")
public List<SConsumerCoupon> query(SConsumerCoupon sConsumerCoupon) {
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
@PostMapping("/query")
public List<SConsumerCoupon> query(@RequestBody SConsumerCoupon sConsumerCoupon) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setUseStatus("0");
sConsumerCoupon.setConsumerId(user.getId());
return sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
}
......
......@@ -18,7 +18,7 @@ import share.common.core.domain.BaseEntity;
* @date 2023-09-27
*/
@Data
public class SConsumer extends BaseEntity
public class SConsumer
{
private static final long serialVersionUID = 1L;
......@@ -88,4 +88,7 @@ public class SConsumer extends BaseEntity
@ApiModelProperty(value = "最后一次登录时间")
private Date lastLoginTime;
@ApiModelProperty(value = "优惠卷数量")
private Integer number;
}
......@@ -59,4 +59,6 @@ public interface SConsumerCouponMapper extends BaseMapper<SConsumerCoupon>
* @return 结果
*/
public int deleteSConsumerCouponByIds(Long[] ids);
int selectSConsumerCouponConut(SConsumerCoupon sConsumerCoupon);
}
......@@ -59,4 +59,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
* @return 结果
*/
public int deleteSConsumerCouponById(Long id);
int selectSConsumerCouponConut(SConsumerCoupon sConsumerCoupon);
}
......@@ -94,4 +94,9 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
{
return sConsumerCouponMapper.deleteSConsumerCouponById(id);
}
@Override
public int selectSConsumerCouponConut(SConsumerCoupon sConsumerCoupon) {
return sConsumerCouponMapper.selectSConsumerCouponConut(sConsumerCoupon);
}
}
......@@ -15,11 +15,13 @@ import share.common.constant.SmsConstants;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.system.domain.SConsumerCoupon;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper;
import share.system.domain.SConsumer;
import share.system.request.RegisterThirdSConsumerRequest;
import share.system.service.ISConsumerCouponService;
import share.system.service.SConsumerService;
/**
......@@ -37,6 +39,9 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Autowired
private FrontTokenComponent tokenComponet;
@Autowired
private ISConsumerCouponService sConsumerCouponService;
/**
* 查询会员用户
*
......@@ -153,6 +158,13 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Override
public SConsumer getSConsumer() {
SConsumer currentUser = getInfo();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(currentUser.getId());
sConsumerCoupon.setUseStatus("0");
int count = sConsumerCouponService.selectSConsumerCouponConut(sConsumerCoupon);
if(count>0){
currentUser.setNumber(count);
}
if (ObjectUtil.isNull(currentUser)) {
throw new BaseException("您的登录已过期,请先登录");
}
......
......@@ -67,6 +67,9 @@
<include refid="selectSConsumerCouponVo"/>
where id = #{id}
</select>
<select id="selectSConsumerCouponConut" resultType="java.lang.Integer">
select count(1) from s_consumer_coupon where consumer_id = #{consumerId} and use_status = 0
</select>
<insert id="insertSConsumerCoupon" parameterType="SConsumerCoupon" useGeneratedKeys="true" keyProperty="id">
insert into s_consumer_coupon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment