Search in sources :

Example 36 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project lilishop by lilishop.

the class StoreCollectionServiceImpl method addStoreCollection.

@Override
@Transactional(rollbackFor = Exception.class)
public StoreCollection addStoreCollection(String storeId) {
    if (this.getOne(new LambdaUpdateWrapper<StoreCollection>().eq(StoreCollection::getMemberId, UserContext.getCurrentUser().getId()).eq(StoreCollection::getStoreId, storeId)) == null) {
        StoreCollection storeCollection = new StoreCollection(UserContext.getCurrentUser().getId(), storeId);
        this.save(storeCollection);
        storeService.updateStoreCollectionNum(new CollectionDTO(storeId, 1));
        return storeCollection;
    }
    throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) ServiceException(cn.lili.common.exception.ServiceException) CollectionDTO(cn.lili.modules.member.entity.dto.CollectionDTO) StoreCollection(cn.lili.modules.member.entity.dos.StoreCollection) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project lilishop by lilishop.

the class GoodsSkuServiceImpl method updateGoodsSkuStatus.

/**
 * 更新商品sku状态
 *
 * @param goods 商品信息(Id,MarketEnable/AuthFlag)
 */
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGoodsSkuStatus(Goods goods) {
    LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
    updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getId()), GoodsSku::getGoodsId, goods.getId());
    updateWrapper.eq(CharSequenceUtil.isNotEmpty(goods.getStoreId()), GoodsSku::getStoreId, goods.getStoreId());
    updateWrapper.set(GoodsSku::getMarketEnable, goods.getMarketEnable());
    updateWrapper.set(GoodsSku::getAuthFlag, goods.getAuthFlag());
    updateWrapper.set(GoodsSku::getDeleteFlag, goods.getDeleteFlag());
    boolean update = this.update(updateWrapper);
    if (Boolean.TRUE.equals(update)) {
        List<GoodsSku> goodsSkus = this.getGoodsSkuListByGoodsId(goods.getId());
        for (GoodsSku sku : goodsSkus) {
            cache.remove(GoodsSkuService.getCacheKeys(sku.getId()));
            cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
        }
        if (!goodsSkus.isEmpty()) {
            generateEs(goods);
        }
    }
}
Also used : GoodsSku(cn.lili.modules.goods.entity.dos.GoodsSku) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project lilishop by lilishop.

the class GoodsSkuServiceImpl method updateGoodsSkuStatusByStoreId.

/**
 * 更新商品sku状态根据店铺id
 *
 * @param storeId      店铺id
 * @param marketEnable 市场启用状态
 * @param authFlag     审核状态
 */
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGoodsSkuStatusByStoreId(String storeId, String marketEnable, String authFlag) {
    LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
    updateWrapper.eq(GoodsSku::getStoreId, storeId);
    updateWrapper.set(CharSequenceUtil.isNotEmpty(marketEnable), GoodsSku::getMarketEnable, marketEnable);
    updateWrapper.set(CharSequenceUtil.isNotEmpty(authFlag), GoodsSku::getAuthFlag, authFlag);
    boolean update = this.update(updateWrapper);
    if (Boolean.TRUE.equals(update)) {
        if (GoodsStatusEnum.UPPER.name().equals(marketEnable)) {
            applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成店铺商品", GoodsTagsEnum.GENERATOR_STORE_GOODS_INDEX.name(), storeId));
        } else if (GoodsStatusEnum.DOWN.name().equals(marketEnable)) {
            cache.vagueDel(CachePrefix.GOODS_SKU.getPrefix());
            applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("删除店铺商品", GoodsTagsEnum.STORE_GOODS_DELETE.name(), storeId));
        }
    }
}
Also used : GoodsSku(cn.lili.modules.goods.entity.dos.GoodsSku) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) GeneratorEsGoodsIndexEvent(cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project lilishop by lilishop.

the class OrderServiceImpl method deleteOrder.

@Override
@Transactional(rollbackFor = Exception.class)
public void deleteOrder(String sn) {
    Order order = this.getBySn(sn);
    if (order == null) {
        log.error("订单号为" + sn + "的订单不存在!");
        throw new ServiceException();
    }
    LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
    updateWrapper.eq(Order::getSn, sn).set(Order::getDeleteFlag, true);
    this.update(updateWrapper);
    LambdaUpdateWrapper<OrderItem> orderItemLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
    orderItemLambdaUpdateWrapper.eq(OrderItem::getOrderSn, sn).set(OrderItem::getDeleteFlag, true);
    this.orderItemService.update(orderItemLambdaUpdateWrapper);
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) ServiceException(cn.lili.common.exception.ServiceException) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project lilishop by lilishop.

the class AfterSaleServiceImpl method updateOrderItem.

/**
 * 功能描述:  修改orderItem订单
 *
 * @param orderItem
 * @return void
 * @author ftyy
 */
private void updateOrderItem(OrderItem orderItem) {
    // 订单状态不能为新订单,已失效订单或未申请订单才可以去修改订单信息
    OrderItemAfterSaleStatusEnum afterSaleTypeEnum = OrderItemAfterSaleStatusEnum.valueOf(orderItem.getAfterSaleStatus());
    switch(afterSaleTypeEnum) {
        // 售后状态为:未申请 部分售后 已申请
        case NOT_APPLIED:
        case PART_AFTER_SALE:
        case ALREADY_APPLIED:
            {
                // 通过正在售后商品总数修改订单售后状态
                if (orderItem.getReturnGoodsNumber().equals(orderItem.getNum())) {
                    // 修改订单的售后状态--已申请
                    orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.ALREADY_APPLIED.name());
                } else if (orderItem.getReturnGoodsNumber().equals(0)) {
                    // 修改订单的售后状态--未申请
                    orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NOT_APPLIED.name());
                } else {
                    // 修改订单的售后状态--部分售后
                    orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.PART_AFTER_SALE.name());
                }
                break;
            }
        default:
            break;
    }
    orderItemService.update(new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getSn, orderItem.getSn()).set(OrderItem::getAfterSaleStatus, orderItem.getAfterSaleStatus()).set(OrderItem::getReturnGoodsNumber, orderItem.getReturnGoodsNumber()));
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) OrderItemAfterSaleStatusEnum(cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum)

Aggregations

LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)47 Transactional (org.springframework.transaction.annotation.Transactional)11 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)10 Date (java.util.Date)7 Result (org.jeecg.common.api.vo.Result)6 LoginUser (org.jeecg.common.system.vo.LoginUser)6 SysAnnouncementSend (org.jeecg.modules.system.entity.SysAnnouncementSend)6 Test (org.junit.jupiter.api.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 PutMapping (org.springframework.web.bind.annotation.PutMapping)6 OrderItem (cn.lili.modules.order.order.entity.dos.OrderItem)5 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 User (com.maxqiu.demo.entity.User)5 DateTime (cn.hutool.core.date.DateTime)4 UserFile (com.qiwenshare.file.domain.UserFile)4 ServiceException (cn.lili.common.exception.ServiceException)3 Order (cn.lili.modules.order.order.entity.dos.Order)3 SysOssConfig (com.ruoyi.system.domain.SysOssConfig)3 DistributionOrder (cn.lili.modules.distribution.entity.dos.DistributionOrder)2 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)2