活动 添加优惠券名称字段
This commit is contained in:
@@ -19,6 +19,7 @@ public class TbActivate extends Model<TbActivate> {
|
|||||||
private Integer isUseCoupon;
|
private Integer isUseCoupon;
|
||||||
//优惠卷id
|
//优惠卷id
|
||||||
private Integer couponId;
|
private Integer couponId;
|
||||||
|
private String couponName;
|
||||||
//优惠卷数量
|
//优惠卷数量
|
||||||
private Integer num;
|
private Integer num;
|
||||||
|
|
||||||
@@ -76,6 +77,14 @@ public class TbActivate extends Model<TbActivate> {
|
|||||||
this.couponId = couponId;
|
this.couponId = couponId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCouponName() {
|
||||||
|
return couponName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCouponName(String couponName) {
|
||||||
|
this.couponName = couponName;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getNum() {
|
public Integer getNum() {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,51 @@
|
|||||||
package cn.ysk.cashier.mybatis.service.impl;
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
import cn.ysk.cashier.mybatis.entity.TbActivate;
|
import cn.ysk.cashier.mybatis.entity.TbActivate;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.TbActivateMapper;
|
||||||
|
import cn.ysk.cashier.mybatis.service.TbActivateService;
|
||||||
|
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import cn.ysk.cashier.mybatis.service.TbActivateService;
|
|
||||||
import cn.ysk.cashier.mybatis.mapper.TbActivateMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
* @description 针对表【tb_activate】的数据库操作Service实现
|
* @description 针对表【tb_activate】的数据库操作Service实现
|
||||||
* @createDate 2024-09-03 14:08:30
|
* @createDate 2024-09-03 14:08:30
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActivate> implements TbActivateService{
|
public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActivate> implements TbActivateService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbActivateMapper activateMapper;
|
private TbActivateMapper activateMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbShopCouponService tbShopCouponService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object findActivate(String shopId) {
|
public Object findActivate(String shopId) {
|
||||||
QueryWrapper<TbActivate> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TbActivate> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("shop_id",shopId);
|
queryWrapper.eq("shop_id", shopId);
|
||||||
queryWrapper.orderByDesc("id");
|
queryWrapper.orderByDesc("id");
|
||||||
List<TbActivate> list = activateMapper.selectList(queryWrapper);
|
List<TbActivate> list = activateMapper.selectList(queryWrapper);
|
||||||
|
for (TbActivate tbActivate : list) {
|
||||||
|
if (tbActivate.getCouponId() != null) {
|
||||||
|
TbShopCoupon coupon = tbShopCouponService.findById(tbActivate.getCouponId());
|
||||||
|
tbActivate.setCouponName(coupon != null ? coupon.getTitle() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyActivate(TbActivate activate) {
|
public void modifyActivate(TbActivate activate) {
|
||||||
if (Objects.nonNull(activate.getId()) && activate.getId() > 0){
|
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
|
||||||
activateMapper.updateById(activate);
|
activateMapper.updateById(activate);
|
||||||
}else {
|
} else {
|
||||||
activateMapper.insert(activate);
|
activateMapper.insert(activate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user