Search in sources :

Example 16 with LambdaUpdateWrapper

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

the class DistributionOrderExecute method execute.

@Override
public void execute() {
    // 计算分销提佣
    distributionOrderMapper.rebate(DistributionOrderStatusEnum.WAIT_BILL.name(), new DateTime());
    // 修改分销订单状态
    distributionOrderService.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.WAIT_BILL.name()).le(DistributionOrder::getSettleCycle, new DateTime()).set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.WAIT_CASH.name()));
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) DistributionOrder(cn.lili.modules.distribution.entity.dos.DistributionOrder) DateTime(cn.hutool.core.date.DateTime)

Example 17 with LambdaUpdateWrapper

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

the class OrderEveryDayTaskExecute method closeComplaint.

/**
 * 关闭允许交易投诉
 *
 * @param orderSetting 订单设置
 */
private void closeComplaint(OrderSetting orderSetting) {
    // 订单关闭交易投诉申请时间 = 当前时间 - 自动关闭交易投诉申请天数
    DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseComplaint());
    // 关闭售后订单=未售后订单+小于订单关闭售后申请时间
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.le("o.complete_time", receiveTime);
    queryWrapper.eq("oi.complain_status", OrderComplaintStatusEnum.NO_APPLY.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::getComplainStatus, 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 18 with LambdaUpdateWrapper

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

the class ScheduleJobController method reset.

@OperationLog
@ApiOperation(value = "重置任务")
@RequiresPermissions("job:schedule:reset")
@PostMapping("/reset")
public Result<Object> reset(@RequestBody Long[] jobIds) {
    ScheduleJob scheduleJob = new ScheduleJob();
    scheduleJob.setCount(0);
    scheduleJobService.update(scheduleJob, new LambdaUpdateWrapper<ScheduleJob>().in(ScheduleJob::getId, ListUtil.of(jobIds)));
    return Result.ok();
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) ScheduleJob(top.longmarch.job.entity.ScheduleJob) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) ApiOperation(io.swagger.annotations.ApiOperation) OperationLog(top.longmarch.lmcore.annotation.OperationLog)

Example 19 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project mybatis-plus-domain-plugin by liyang920716.

the class DomainPlugin method update.

/**
 * 修改处理
 *
 * @param o
 * @param ms
 * @throws Exception
 */
private void update(Object o, MappedStatement ms) throws Exception {
    if (o instanceof MapperMethod.ParamMap) {
        // 对mybatis-plus处理
        MapperMethod.ParamMap paramMap = (MapperMethod.ParamMap) o;
        if (paramMap.containsKey("et") && !paramMap.containsKey("ew")) {
            Object et = paramMap.get("et");
            Class<?> aClass = et.getClass();
            if (!aClass.isAnnotationPresent(Domain.class)) {
                return;
            }
            Field[] declaredFields = null;
            if (classField.containsKey(aClass.getName())) {
                declaredFields = classField.get(aClass.getName());
            } else {
                declaredFields = FieldUtils.getAllFields(aClass);
                classField.put(aClass.getName(), declaredFields);
            }
            for (Field declaredField : declaredFields) {
                if (declaredField.isAnnotationPresent(DomainField.class)) {
                    declaredField.setAccessible(true);
                    Object o1 = declaredField.get(et);
                    if (o1 != null && o1 instanceof String) {
                        declaredField.set(et, o1.toString().replaceAll(domain, REGEX_BASE_URL));
                    }
                }
            }
            return;
        } else if (paramMap.containsKey("et") && paramMap.containsKey("ew")) {
            Object ew = paramMap.get("ew");
            Object et = paramMap.get("et");
            if (ew != null && et == null) {
                LambdaUpdateWrapper<?> lambdaUpdateWrapper = (LambdaUpdateWrapper<?>) ew;
                Class<?> entityClass = lambdaUpdateWrapper.getEntityClass();
                if (entityClass == null) {
                    return;
                }
                if (!entityClass.isAnnotationPresent(Domain.class)) {
                    return;
                }
                Map<String, String> valMap = new HashMap<>();
                String[] split = lambdaUpdateWrapper.getSqlSet().split(",");
                for (String s1 : split) {
                    valMap.put(Pattern.compile(REGEX_VAL).matcher(s1).group(1), Pattern.compile(REGEX_VAL).matcher(s1).group(2));
                }
                Field[] declaredFields = null;
                if (classField.containsKey(entityClass.getName())) {
                    declaredFields = classField.get(entityClass.getName());
                } else {
                    declaredFields = FieldUtils.getAllFields(entityClass);
                    classField.put(entityClass.getName(), declaredFields);
                }
                Map<String, Object> paramNameValuePairs = lambdaUpdateWrapper.getParamNameValuePairs();
                for (Field declaredField : declaredFields) {
                    if (declaredField.isAnnotationPresent(DomainField.class)) {
                        String key = valMap.get(declaredField.getName());
                        Object o1 = paramNameValuePairs.get(key);
                        if (o1 instanceof String) {
                            paramNameValuePairs.put(key, o1.toString().replaceAll(domain, REGEX_BASE_URL));
                        }
                    }
                }
            }
            if (ew == null && et != null) {
                Class<?> aClass = et.getClass();
                if (!aClass.isAnnotationPresent(Domain.class)) {
                    return;
                }
                Field[] declaredFields = null;
                if (classField.containsKey(aClass.getName())) {
                    declaredFields = classField.get(aClass.getName());
                } else {
                    declaredFields = FieldUtils.getAllFields(aClass);
                    classField.put(aClass.getName(), declaredFields);
                }
                for (Field declaredField : declaredFields) {
                    if (declaredField.isAnnotationPresent(DomainField.class)) {
                        declaredField.setAccessible(true);
                        Object o1 = declaredField.get(et);
                        if (o1 != null && o1 instanceof String) {
                            declaredField.set(et, o1.toString().replaceAll(domain, REGEX_BASE_URL));
                        }
                    }
                }
            }
            if (ew != null && et != null) {
                Class<?> aClass = et.getClass();
                if (!aClass.isAnnotationPresent(Domain.class)) {
                    return;
                }
                Field[] declaredFields = null;
                if (classField.containsKey(aClass.getName())) {
                    declaredFields = classField.get(aClass.getName());
                } else {
                    declaredFields = FieldUtils.getAllFields(aClass);
                    classField.put(aClass.getName(), declaredFields);
                }
                for (Field declaredField : declaredFields) {
                    if (declaredField.isAnnotationPresent(DomainField.class)) {
                        declaredField.setAccessible(true);
                        Object o1 = declaredField.get(et);
                        if (o1 != null && o1 instanceof String) {
                            declaredField.set(et, o1.toString().replaceAll(domain, REGEX_BASE_URL));
                        }
                    }
                }
            }
            return;
        } else {
            // 对非实体类处理
            dealNoEntity(ms, paramMap);
            return;
        }
    } else {
        if (o != null) {
            Class<?> aClass = o.getClass();
            if (!aClass.isAnnotationPresent(Domain.class)) {
                return;
            }
            Field[] declaredFields = null;
            if (classField.containsKey(aClass.getName())) {
                declaredFields = classField.get(aClass.getName());
            } else {
                declaredFields = FieldUtils.getAllFields(aClass);
                classField.put(aClass.getName(), declaredFields);
            }
            for (Field declaredField : declaredFields) {
                if (declaredField.isAnnotationPresent(DomainField.class)) {
                    declaredField.setAccessible(true);
                    Object o1 = declaredField.get(o);
                    if (o1 != null && o1 instanceof String) {
                        declaredField.set(o, o1.toString().replaceAll(domain, REGEX_BASE_URL));
                    }
                }
            }
            return;
        }
    }
}
Also used : DomainField(com.github.liyang920716.domain.annotation.DomainField) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Field(java.lang.reflect.Field) DomainField(com.github.liyang920716.domain.annotation.DomainField) MapperMethod(org.apache.ibatis.binding.MapperMethod) Domain(com.github.liyang920716.domain.annotation.Domain) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 20 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project mybatis-plus-samples by baomidou.

the class UpdateWrapperTest method testLambda.

/**
 * 使用lambda条件构造器
 * UPDATE user SET age=?, email=? WHERE (name = ?)
 */
@Test
public void testLambda() {
    // 方式一:
    User user = new User();
    user.setAge(29);
    user.setEmail("test3update@baomidou.com");
    userMapper.update(user, new LambdaUpdateWrapper<User>().eq(User::getName, "Tom"));
    // 方式二:
    // 不创建User对象
    userMapper.update(null, new LambdaUpdateWrapper<User>().set(User::getAge, 29).set(User::getEmail, "test3update@baomidou.com").eq(User::getName, "Tom"));
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) User(com.baomidou.mybatisplus.samples.wrapper.entity.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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