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