Search in sources :

Example 56 with UpdateWrapper

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

the class MemberReceiptServiceImpl method addMemberReceipt.

@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addMemberReceipt(MemberReceiptAddVO memberReceiptAddVO, String memberId) {
    // 校验发票抬头是否重复
    List<MemberReceipt> receipts = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId).eq("receipt_title", memberReceiptAddVO.getReceiptTitle()));
    if (!receipts.isEmpty()) {
        throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR);
    }
    // 参数封装
    MemberReceipt memberReceipt = new MemberReceipt();
    BeanUtil.copyProperties(memberReceiptAddVO, memberReceipt);
    // 根据会员信息查询会员
    Member member = memberService.getById(memberId);
    if (member != null) {
        memberReceipt.setMemberId(memberId);
        memberReceipt.setMemberName(member.getUsername());
        // 设置发票默认
        List<MemberReceipt> list = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId));
        // 如果当前会员只有一个发票则默认为默认发票,反之需要校验参数默认值,做一些处理
        if (list.isEmpty()) {
            memberReceipt.setIsDefault(1);
        } else {
            if (memberReceiptAddVO.getIsDefault().equals(1)) {
                // 如果参数传递新添加的发票信息为默认,则需要把其他发票置为非默认
                this.update(new UpdateWrapper<MemberReceipt>().eq("member_id", memberId));
                // 设置当前发票信息为默认
                memberReceipt.setIsDefault(memberReceiptAddVO.getIsDefault());
            } else {
                memberReceiptAddVO.setIsDefault(0);
            }
        }
        return this.baseMapper.insert(memberReceipt) > 0 ? true : false;
    }
    throw new ServiceException(ResultCode.USER_RECEIPT_NOT_EXIST);
}
Also used : MemberReceipt(cn.lili.modules.member.entity.dos.MemberReceipt) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 57 with UpdateWrapper

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

the class MemberReceiptServiceImpl method editMemberReceipt.

@Override
@Transactional(rollbackFor = Exception.class)
public Boolean editMemberReceipt(MemberReceiptAddVO memberReceiptAddVO, String memberId) {
    // 根据会员id查询发票信息
    MemberReceipt memberReceiptDb = this.baseMapper.selectById(memberReceiptAddVO.getId());
    if (memberReceiptDb != null) {
        // 检验是否有权限修改
        if (!memberReceiptDb.getMemberId().equals(memberId)) {
            throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
        }
        // 校验发票抬头是否重复
        List<MemberReceipt> receipts = this.baseMapper.selectList(new QueryWrapper<MemberReceipt>().eq("member_id", memberId).eq("receipt_title", memberReceiptAddVO.getReceiptTitle()).ne("id", memberReceiptAddVO.getId()));
        if (!receipts.isEmpty()) {
            throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR);
        }
        BeanUtil.copyProperties(memberReceiptAddVO, memberReceiptDb);
        // 对发票默认进行处理  如果参数传递新添加的发票信息为默认,则需要把其他发票置为非默认
        if (memberReceiptAddVO.getIsDefault().equals(1)) {
            this.update(new UpdateWrapper<MemberReceipt>().eq("member_id", memberId));
        }
        return this.baseMapper.updateById(memberReceiptDb) > 0 ? true : false;
    }
    throw new ServiceException(ResultCode.USER_RECEIPT_NOT_EXIST);
}
Also used : MemberReceipt(cn.lili.modules.member.entity.dos.MemberReceipt) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 58 with UpdateWrapper

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

the class MemberEvaluationServiceImpl method updateStatus.

@Override
public boolean updateStatus(String id, String status) {
    UpdateWrapper updateWrapper = Wrappers.update();
    updateWrapper.eq("id", id);
    updateWrapper.set("status", status.equals(SwitchEnum.OPEN.name()) ? SwitchEnum.OPEN.name() : SwitchEnum.CLOSE.name());
    return this.update(updateWrapper);
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)

Example 59 with UpdateWrapper

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

the class OrderServiceImpl method delivery.

@Override
@OrderLogPoint(description = "'订单['+#orderSn+']发货,发货单号['+#logisticsNo+']'", orderSn = "#orderSn")
@Transactional(rollbackFor = Exception.class)
public Order delivery(String orderSn, String logisticsNo, String logisticsId) {
    Order order = OperationalJudgment.judgment(this.getBySn(orderSn));
    // 如果订单未发货,并且订单状态值等于待发货
    if (order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && order.getOrderStatus().equals(OrderStatusEnum.UNDELIVERED.name())) {
        // 获取对应物流
        Logistics logistics = logisticsService.getById(logisticsId);
        if (logistics == null) {
            throw new ServiceException(ResultCode.ORDER_LOGISTICS_ERROR);
        }
        // 写入物流信息
        order.setLogisticsCode(logistics.getId());
        order.setLogisticsName(logistics.getName());
        order.setLogisticsNo(logisticsNo);
        order.setLogisticsTime(new Date());
        order.setDeliverStatus(DeliverStatusEnum.DELIVERED.name());
        this.updateById(order);
        // 修改订单状态为已发送
        this.updateStatus(orderSn, OrderStatusEnum.DELIVERED);
        // 修改订单货物可以进行售后、投诉
        orderItemService.update(new UpdateWrapper<OrderItem>().eq(ORDER_SN_COLUMN, orderSn).set("after_sale_status", OrderItemAfterSaleStatusEnum.NOT_APPLIED).set("complain_status", OrderComplaintStatusEnum.NO_APPLY));
        // 发送订单状态改变消息
        OrderMessage orderMessage = new OrderMessage();
        orderMessage.setNewStatus(OrderStatusEnum.DELIVERED);
        orderMessage.setOrderSn(order.getSn());
        this.sendUpdateStatusMessage(orderMessage);
    } else {
        throw new ServiceException(ResultCode.ORDER_DELIVER_ERROR);
    }
    return order;
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) PintuanOrderMessage(cn.lili.trigger.message.PintuanOrderMessage) OrderMessage(cn.lili.modules.order.order.entity.dto.OrderMessage) Logistics(cn.lili.modules.system.entity.dos.Logistics) OrderLogPoint(cn.lili.modules.order.order.aop.OrderLogPoint) Transactional(org.springframework.transaction.annotation.Transactional)

Example 60 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project shopzz by whoiszxl.

the class PurchaseOrderServiceImpl method updatePurchaseOrder.

@Transactional
@Override
public Boolean updatePurchaseOrder(PurchaseOrderVO purchaseOrderVO) {
    // 1. 更新采购订单
    purchaseOrderVO.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
    PurchaseOrder purchaseOrder = purchaseOrderVO.clone(PurchaseOrder.class);
    boolean orderFlag = this.updateById(purchaseOrder);
    // 2. 删除原来的订单商品详情
    boolean removeFlag = purchaseOrderItemService.remove(new UpdateWrapper<PurchaseOrderItem>().eq("purchase_order_id", purchaseOrderVO.getId()));
    // 2. 新增订单商品详情
    List<PurchaseOrderItemVO> items = purchaseOrderVO.getItems();
    items.forEach(item -> item.setPurchaseOrderId(purchaseOrder.getId()));
    List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(items, PurchaseOrderItem::new);
    boolean itemFlag = purchaseOrderItemService.saveBatch(purchaseOrderItems);
    if (!orderFlag || !removeFlag || !itemFlag) {
        ExceptionCatcher.catchDatabaseFailEx();
    }
    return true;
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.entity.vo.PurchaseOrderItemVO) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)97 Transactional (org.springframework.transaction.annotation.Transactional)41 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)40 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)34 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)28 Session (org.apache.shiro.session.Session)24 StatusForbiddenException (top.hcode.hoj.common.exception.StatusForbiddenException)21 Judge (top.hcode.hoj.pojo.entity.judge.Judge)17 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)16 HttpSession (javax.servlet.http.HttpSession)14 Problem (top.hcode.hoj.pojo.entity.problem.Problem)14 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)13 StatusNotFoundException (top.hcode.hoj.common.exception.StatusNotFoundException)11 Group (top.hcode.hoj.pojo.entity.group.Group)11 Date (java.util.Date)10 Discussion (top.hcode.hoj.pojo.entity.discussion.Discussion)10 Contest (top.hcode.hoj.pojo.entity.contest.Contest)8 User (com.baomidou.mybatisplus.samples.wrapper.entity.User)5 Result (org.jeecg.common.api.vo.Result)5 LoginUser (org.jeecg.common.system.vo.LoginUser)5