| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | import com.ruoyi.common.core.enums.OrderStatusEnum; |
| | | import com.ruoyi.common.core.enums.PaymentMethodEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.order.domain.MemberInvoiceRise; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.order.controller.management.dto.MgtMallOrderQuery; |
| | | import com.ruoyi.order.controller.management.dto.MgtOrderConfirmShipmentDTO; |
| | | import com.ruoyi.order.controller.management.vo.MgtMallOrderVO; |
| | | import com.ruoyi.order.controller.management.vo.MgtOrderReturnRequestVO; |
| | | import com.ruoyi.order.domain.OrderReturnRequest; |
| | | import com.ruoyi.order.domain.Paylog; |
| | | import com.ruoyi.order.mapper.OrderAuctionBondMapper; |
| | | import com.ruoyi.order.mapper.OrderMapper; |
| | | import com.ruoyi.order.service.IOrderAuctionBondService; |
| | | import com.ruoyi.order.service.IOrderReturnRequestService; |
| | | import com.ruoyi.order.service.IOrderService; |
| | | import com.ruoyi.order.service.IPaylogService; |
| | | import com.ruoyi.order.util.OrderUtil; |
| | | import com.ruoyi.system.api.domain.*; |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import com.ruoyi.order.util.SinataUtil; |
| | | import com.ruoyi.system.api.domain.CouponMember; |
| | | import com.ruoyi.system.api.domain.CustomConfig; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.domain.MemberAddress; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.OrderAuctionBond; |
| | | import com.ruoyi.system.api.domain.dto.CouponMemberDTO; |
| | | import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberOrderDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberOrderListDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderDTO; |
| | | import com.ruoyi.system.api.domain.dto.updMembeOneDTO; |
| | | import com.ruoyi.system.api.domain.vo.MemberOrderListVO; |
| | | import com.ruoyi.system.api.domain.vo.MemberTiOrderVO; |
| | | import com.ruoyi.system.api.domain.vo.OrderVO; |
| | |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import com.ruoyi.system.api.feignClient.PromotionClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | |
| | | import lombok.Synchronized; |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private IOrderReturnRequestService orderReturnRequestService; |
| | | |
| | | @Resource |
| | | private RedissonClient redissonClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Synchronized |
| | | public MemberTiOrderVO saveMemberOrder(MemberOrderDTO memberOrderDTO) { |
| | | |
| | | MemberTiOrderVO memberOrderVO=new MemberTiOrderVO(); |
| | |
| | | pice=goodsSku.getPrice(); |
| | | } |
| | | if (memberOrderDTO.getOrderFrom()==2){ |
| | | order.setOrderFrom(OrderFromEnum.SNAP_ORDERS); |
| | | GoodsSeckill data = goodsSkuClient.getGoodsSeckillOne(memberOrderDTO.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | /* String goodsLock = "goods_lock_" + CacheConstants.SECKILL_GOODS + data.getId(); |
| | | RLock redissonLock = redissonClient.getLock(goodsLock); |
| | | Integer surpNum = 0; |
| | | try { |
| | | redissonLock.lock(30, TimeUnit.SECONDS); |
| | | surpNum = redisService.getCacheObject(CacheConstants.SECKILL_GOODS + data.getId()); |
| | | if (surpNum == null || surpNum < memberOrderDTO.getGoodsQuantity()) { |
| | | throw new ServiceException("商品已被抢完"); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | throw new ServiceException("reids 出错"); |
| | | }*/ |
| | | order.setOrderFrom(OrderFromEnum.SNAP_ORDERS); |
| | | |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); |
| | | memberOrderVO.setPrice(goodsSku.getPrice()); |
| | |
| | | order.setSkuName(goodsSku.getSkuName()); |
| | | order.setPrice(data.getSeckillPrice()); |
| | | order.setCoverPic(goodsSku.getCoverPic()); |
| | | |
| | | /*redisService.setCacheObject(CacheConstants.SECKILL_GOODS + data.getId(), surpNum - memberOrderDTO.getGoodsQuantity());*/ |
| | | } |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | |
| | | memberOrderVO.setReceiverCity(order.getReceiverCity()); |
| | | memberOrderVO.setReceiverDetailAddress(order.getReceiverDetailAddress()); |
| | | memberOrderVO.setReceiverphone(order.getReceiverphone()); |
| | | Integer delayTime = 30; |
| | | redisService.setCacheObject(CacheConstants.ORDER_AUTOMATIC_CANCEL + "-" + order.getId(), order.getId() , delayTime.longValue(), TimeUnit.MINUTES); |
| | | |
| | | return memberOrderVO; |
| | | } |
| | |
| | | Order order = baseMapper.selectById(memberOrderListDTO.getId()); |
| | | OrderVO orderVO=new OrderVO(); |
| | | try { |
| | | BeanUtils.copyProperties(orderVO,order); |
| | | orderVO = BeanUtils.copyBean(order, OrderVO.class); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | baseMapper.updateById(order); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据优惠券id集合查询订单列表 |
| | | * |
| | | * @param couponIds 优惠券id集合 |
| | | * @return List<Order> |
| | | */ |
| | | @Override |
| | | public List<Order> getOrderByCouponIds(Collection<Long> couponIds) { |
| | | return this.lambdaQuery().in(Order::getCouponId, couponIds) |
| | | .eq(Order::getOrderStatus, OrderStatusEnum.FINISHED).list(); |
| | | } |
| | | |
| | | /** |
| | | * 商城订单分页列表 |
| | | * |
| | | * @param query 商城订单查询对象 |
| | | * @return PageDTO<MgtMallOrderVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtMallOrderVO> getMallOrderPage(MgtMallOrderQuery query) { |
| | | PageDTO<MgtMallOrderVO> pageVO; |
| | | // 封装会员条件查询对象 |
| | | MemberDTO memberDTO = null; |
| | | Set<Long> memberIdSet = null; |
| | | Page<Order> page = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | if (StringUtils.isNotBlank(query.getNickname()) || StringUtils.isNotBlank( |
| | | query.getPhone())) { |
| | | memberDTO = new MemberDTO(); |
| | | memberDTO.setNickname(query.getNickname()); |
| | | memberDTO.setPhone(query.getPhone()); |
| | | } |
| | | if (StringUtils.isNotNull(memberDTO)) { |
| | | // 远程调用会员服务进行条件查询 |
| | | List<Member> memberList = memberClient.getMemberListByCondition(memberDTO, |
| | | SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isEmpty(memberList)) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | memberIdSet = memberList.stream().map(Member::getId) |
| | | .collect(Collectors.toSet()); |
| | | } |
| | | page = this.lambdaQuery() |
| | | .in(StringUtils.isNotEmpty(memberIdSet), Order::getMemberId, memberIdSet) |
| | | .like(StringUtils.isNotBlank(query.getOrderNo()), Order::getOrderNo, |
| | | query.getOrderNo()) |
| | | .eq(StringUtils.isNotNull(query.getOrderFrom()), Order::getOrderFrom, |
| | | query.getOrderFrom()) |
| | | .like(StringUtils.isNotBlank(query.getSkuName()), Order::getSkuName, |
| | | query.getSkuName()) |
| | | .eq(StringUtils.isNotNull(query.getOrderStatus()), Order::getOrderStatus, |
| | | query.getOrderStatus()) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | if (StringUtils.isEmpty(page.getRecords())) { |
| | | pageVO = PageDTO.empty(page); |
| | | } |
| | | pageVO = PageDTO.of(page, MgtMallOrderVO.class); |
| | | return pageVO; |
| | | } |
| | | |
| | | /** |
| | | * 获取商城订单详情 |
| | | * |
| | | * @param id 订单id |
| | | * @return MgtMallOrderVO |
| | | */ |
| | | @Override |
| | | public MgtMallOrderVO getMallOrderDetail(Long id) { |
| | | Order order = this.getById(id); |
| | | MgtMallOrderVO mgtMallOrderVO = BeanUtils.copyBean(order, MgtMallOrderVO.class); |
| | | // 查询用户信息 |
| | | Member member = memberClient.getMembeOne(order.getMemberId(), SecurityConstants.INNER) |
| | | .getData(); |
| | | if (StringUtils.isNotNull(member)) { |
| | | mgtMallOrderVO.setNickname(member.getNickname()); |
| | | mgtMallOrderVO.setPhone(member.getPhone()); |
| | | } |
| | | // 查询售后信息 |
| | | if (order.getOrderStatus() == OrderStatusEnum.AFTER_SALE) { |
| | | OrderReturnRequest orderReturnRequest = orderReturnRequestService.getOne( |
| | | Wrappers.lambdaQuery(OrderReturnRequest.class) |
| | | .eq(OrderReturnRequest::getOrderId, |
| | | order.getId()).last("limit 1")); |
| | | if (StringUtils.isNotNull(orderReturnRequest)) { |
| | | mgtMallOrderVO.setReturnRequestVO(BeanUtils.copyBean(orderReturnRequest, |
| | | MgtOrderReturnRequestVO.class)); |
| | | } |
| | | } |
| | | return mgtMallOrderVO; |
| | | } |
| | | |
| | | /** |
| | | * 确认发货 |
| | | * |
| | | * @param dto 确认收货请求对象 |
| | | */ |
| | | @Override |
| | | public void confirmShipmentOrder(MgtOrderConfirmShipmentDTO dto) { |
| | | Order order = this.getById(dto.getId()); |
| | | if (StringUtils.isNull(order)) { |
| | | throw new ServiceException("订单不存在"); |
| | | } |
| | | order.setOrderStatus(OrderStatusEnum.GOODS_TO_BE_RECEIVED); |
| | | order.setDeliveryTime(LocalDateTime.now()); |
| | | order.setCourierNumber(dto.getCourierNumber()); |
| | | order.setLogisticsNum(dto.getLogisticsNum()); |
| | | this.updateById(order); |
| | | } |
| | | |
| | | /** |
| | | * 已收货 |
| | | * |
| | | * @param id 订单id |
| | | */ |
| | | @Override |
| | | public void receivedGoods(Long id) { |
| | | Order order = this.getById(id); |
| | | if (StringUtils.isNull(order)) { |
| | | throw new ServiceException("订单不存在"); |
| | | } |
| | | if (order.getOrderStatus() == OrderStatusEnum.GOODS_TO_BE_RECEIVED) { |
| | | order.setOrderStatus(OrderStatusEnum.FINISHED); |
| | | order.setReceiveTime(LocalDateTime.now()); |
| | | this.updateById(order); |
| | | } |
| | | } |
| | | } |