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()));
}
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);
}
}
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();
}
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;
}
}
}
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"));
}
Aggregations