活动 添加优惠券名称字段
This commit is contained in:
parent
0d5a8b66ca
commit
4f209176e4
|
|
@ -19,6 +19,7 @@ public class TbActivate extends Model<TbActivate> {
|
|||
private Integer isUseCoupon;
|
||||
//优惠卷id
|
||||
private Integer couponId;
|
||||
private String couponName;
|
||||
//优惠卷数量
|
||||
private Integer num;
|
||||
|
||||
|
|
@ -76,6 +77,14 @@ public class TbActivate extends Model<TbActivate> {
|
|||
this.couponId = couponId;
|
||||
}
|
||||
|
||||
public String getCouponName() {
|
||||
return couponName;
|
||||
}
|
||||
|
||||
public void setCouponName(String couponName) {
|
||||
this.couponName = couponName;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,51 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
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.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.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_activate】的数据库操作Service实现
|
||||
* @createDate 2024-09-03 14:08:30
|
||||
*/
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_activate】的数据库操作Service实现
|
||||
* @createDate 2024-09-03 14:08:30
|
||||
*/
|
||||
@Service
|
||||
public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActivate> implements TbActivateService{
|
||||
public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActivate> implements TbActivateService {
|
||||
|
||||
@Autowired
|
||||
private TbActivateMapper activateMapper;
|
||||
@Autowired
|
||||
private TbShopCouponService tbShopCouponService;
|
||||
|
||||
@Override
|
||||
public Object findActivate(String shopId) {
|
||||
QueryWrapper<TbActivate> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("shop_id",shopId);
|
||||
queryWrapper.eq("shop_id", shopId);
|
||||
queryWrapper.orderByDesc("id");
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyActivate(TbActivate activate) {
|
||||
if (Objects.nonNull(activate.getId()) && activate.getId() > 0){
|
||||
if (Objects.nonNull(activate.getId()) && activate.getId() > 0) {
|
||||
activateMapper.updateById(activate);
|
||||
}else {
|
||||
} else {
|
||||
activateMapper.insert(activate);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue