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