| | |
| | | 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.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.order.controller.management.dto.MgtMallOrderQuery; |
| | | import com.ruoyi.order.controller.management.vo.MgtMallOrderVO; |
| | | import com.ruoyi.order.domain.Paylog; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | 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 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; |
| | | } |