Search in sources :

Example 31 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project demo-SpringBoot by Max-Qiu.

the class TestUser method update3.

@Test
void update3() {
    // UPDATE smp_user SET age=? WHERE (username = ?)
    LambdaUpdateWrapper<User> wrapper = new LambdaUpdateWrapper<>();
    wrapper.eq(User::getUsername, "xxxxxx").set(User::getAge, 88);
    boolean i = new User().update(wrapper);
    System.out.println("更新结果:" + i);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) User(com.maxqiu.demo.entity.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with LambdaUpdateWrapper

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

the class DistributionOrderServiceImpl method calculationDistribution.

/**
 * 1.查看订单是否为分销订单
 * 2.查看店铺流水计算分销总佣金
 * 3.修改分销员的分销总金额、冻结金额
 *
 * @param orderSn 订单编号
 */
@Override
@Transactional(rollbackFor = Exception.class)
public void calculationDistribution(String orderSn) {
    // 根据订单编号获取订单数据
    Order order = orderService.getBySn(orderSn);
    // 判断是否为分销订单,如果为分销订单则获取分销佣金
    if (order.getDistributionId() != null) {
        // 根据订单编号获取有分销金额的店铺流水记录
        List<StoreFlow> storeFlowList = storeFlowService.listStoreFlow(StoreFlowQueryDTO.builder().justDistribution(true).orderSn(orderSn).build());
        double rebate = 0.0;
        // 包含分销商品则进行记录分销订单、计算分销总额
        for (StoreFlow storeFlow : storeFlowList) {
            rebate = CurrencyUtil.add(rebate, storeFlow.getDistributionRebate());
            DistributionOrder distributionOrder = new DistributionOrder(storeFlow);
            distributionOrder.setDistributionId(order.getDistributionId());
            // 分销员信息
            Distribution distribution = distributionService.getById(order.getDistributionId());
            distributionOrder.setDistributionName(distribution.getMemberName());
            // 设置结算天数(解冻日期)
            Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
            DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
            // 默认解冻1天
            if (distributionSetting.getCashDay().equals(0)) {
                distributionOrder.setSettleCycle(new DateTime());
            } else {
                DateTime dateTime = new DateTime();
                dateTime = dateTime.offsetNew(DateField.DAY_OF_MONTH, distributionSetting.getCashDay());
                distributionOrder.setSettleCycle(dateTime);
            }
            // 添加分销订单
            this.save(distributionOrder);
            // 记录会员的分销总额
            if (rebate != 0.0) {
                distributionService.addRebate(rebate, order.getDistributionId());
                // 如果天数写0则立即进行结算
                if (distributionSetting.getCashDay().equals(0)) {
                    DateTime dateTime = new DateTime();
                    dateTime = dateTime.offsetNew(DateField.MINUTE, 5);
                    // 计算分销提佣
                    this.baseMapper.rebate(DistributionOrderStatusEnum.WAIT_BILL.name(), dateTime);
                    // 修改分销订单状态
                    this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.WAIT_BILL.name()).le(DistributionOrder::getSettleCycle, dateTime).set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.WAIT_CASH.name()));
                }
            }
        }
    }
}
Also used : DistributionOrder(cn.lili.modules.distribution.entity.dos.DistributionOrder) Order(cn.lili.modules.order.order.entity.dos.Order) DistributionOrder(cn.lili.modules.distribution.entity.dos.DistributionOrder) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) DistributionSetting(cn.lili.modules.system.entity.dto.DistributionSetting) Distribution(cn.lili.modules.distribution.entity.dos.Distribution) DistributionSetting(cn.lili.modules.system.entity.dto.DistributionSetting) Setting(cn.lili.modules.system.entity.dos.Setting) StoreFlow(cn.lili.modules.order.order.entity.dos.StoreFlow) DateTime(cn.hutool.core.date.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 33 with LambdaUpdateWrapper

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

the class OrderEveryDayTaskExecute method closeAfterSale.

/**
 * 关闭允许售后申请
 *
 * @param orderSetting 订单设置
 */
private void closeAfterSale(OrderSetting orderSetting) {
    // 订单关闭售后申请时间 = 当前时间 - 自动关闭售后申请天数
    DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseAfterSale());
    // 关闭售后订单=未售后订单+小于订单关闭售后申请时间
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.le("o.complete_time", receiveTime);
    queryWrapper.eq("oi.after_sale_status", OrderItemAfterSaleStatusEnum.NOT_APPLIED.name());
    List<OrderItem> orderItems = orderItemMapper.waitOperationOrderItem(queryWrapper);
    // 判断是否有符合条件的订单,关闭允许售后申请处理
    if (!orderItems.isEmpty()) {
        // 获取订单货物ID
        List<String> orderItemIdList = orderItems.stream().map(OrderItem::getId).collect(Collectors.toList());
        // 修改订单售后状态
        LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<OrderItem>().set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.EXPIRED.name()).in(OrderItem::getId, orderItemIdList);
        orderItemService.update(lambdaUpdateWrapper);
    }
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) DateTime(cn.hutool.core.date.DateTime)

Example 34 with LambdaUpdateWrapper

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

the class CategoryServiceImpl method updateCategoryStatus.

@Override
@Transactional(rollbackFor = Exception.class)
public void updateCategoryStatus(String categoryId, Boolean enableOperations) {
    // 禁用子分类
    CategoryVO categoryVO = new CategoryVO(this.getById(categoryId));
    List<String> ids = new ArrayList<>();
    ids.add(categoryVO.getId());
    this.findAllChild(categoryVO);
    this.findAllChildIds(categoryVO, ids);
    LambdaUpdateWrapper<Category> updateWrapper = new LambdaUpdateWrapper<>();
    updateWrapper.in(Category::getId, ids);
    updateWrapper.set(Category::getDeleteFlag, enableOperations);
    this.update(updateWrapper);
    removeCache();
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Category(cn.lili.modules.goods.entity.dos.Category) ArrayList(java.util.ArrayList) CategoryVO(cn.lili.modules.goods.entity.vos.CategoryVO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with LambdaUpdateWrapper

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

the class MemberServiceImpl method updateMemberLoginTime.

/**
 * 更新会员登录时间为最新时间
 *
 * @param memberId 会员id
 * @return 是否更新成功
 */
@Override
public boolean updateMemberLoginTime(String memberId) {
    LambdaUpdateWrapper<Member> updateWrapper = new LambdaUpdateWrapper<>();
    updateWrapper.eq(Member::getId, memberId);
    updateWrapper.set(Member::getLastLoginDate, new Date());
    return this.update(updateWrapper);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Member(cn.lili.modules.member.entity.dos.Member) Date(java.util.Date)

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