| | |
| | | import com.ruoyi.common.core.enums.RequestTypeEnum; |
| | | import com.ruoyi.common.core.enums.ReturnRequestStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | 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.service.IPaylogService; |
| | | import com.ruoyi.order.util.OrderUtil; |
| | | import com.ruoyi.order.util.SinataUtil; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | | 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.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.domain.*; |
| | | 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.feignClient.PromotionClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.function.Function; |
| | | import java.util.regex.Matcher; |
| | |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import lombok.Synchronized; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | } |
| | | if (memberOrderDTO.getOrderFrom()==2){ |
| | | GoodsSeckill data = goodsSkuClient.getGoodsSeckillOne(memberOrderDTO.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | /* String goodsLock = "goods_lock_" + CacheConstants.SECKILL_GOODS + data.getId(); |
| | | String goodsLock = "goods_lock_" + CacheConstants.SECKILL_GOODS + data.getId(); |
| | | RLock redissonLock = redissonClient.getLock(goodsLock); |
| | | Integer surpNum = 0; |
| | | try { |
| | |
| | | |
| | | }catch (Exception e){ |
| | | throw new ServiceException("reids 出错"); |
| | | }*/ |
| | | } |
| | | order.setOrderFrom(OrderFromEnum.SNAP_ORDERS); |
| | | |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | |
| | | order.setPrice(data.getSeckillPrice()); |
| | | order.setCoverPic(goodsSku.getCoverPic()); |
| | | order.setSjPrice(goodsSku.getPrice()); |
| | | /*redisService.setCacheObject(CacheConstants.SECKILL_GOODS + data.getId(), surpNum - memberOrderDTO.getGoodsQuantity());*/ |
| | | redisService.setCacheObject(CacheConstants.SECKILL_GOODS + data.getId(), surpNum - memberOrderDTO.getGoodsQuantity()); |
| | | } |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | | order.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | |
| | | CustomConfig memberPointsMoney = sysUserClient.getconfig("MEMBER_POINTS_MONEY").getData(); |
| | | CustomConfig memberPointsPoints = sysUserClient.getconfig("MEMBER_POINTS_POINTS").getData(); |
| | | |
| | | BigDecimal pic=pice.multiply(new BigDecimal(memberOrderDTO.getGoodsQuantity())); |
| | | Double aDouble= Double.valueOf(memberPointsMoney.getConfigValue()) * Double.valueOf(memberPointsPoints.getConfigValue()); |
| | | BigDecimal pi=pic.multiply(new BigDecimal(aDouble)); |
| | | order.setPoints(pi.intValue()); |
| | | BigDecimal pic=pice.multiply(new BigDecimal(memberOrderDTO.getGoodsQuantity())); |
| | | BigDecimal divide = pic.divide(new BigDecimal(memberPointsMoney.getConfigValue())); |
| | | BigDecimal roundedDown = divide.setScale(0, RoundingMode.DOWN); |
| | | BigDecimal aDouble= roundedDown.multiply(new BigDecimal(memberPointsPoints.getConfigValue())); |
| | | order.setPoints(aDouble.intValue()); |
| | | |
| | | order.setOrderStatus(OrderStatusEnum.TO_PLAY); |
| | | |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | | order.setReceiverName(memberOrderDTO.getReceiverName()); |
| | | order.setReceiverCity(memberOrderDTO.getReceiverCity()); |
| | | order.setReceiverDetailAddress(memberOrderDTO.getReceiverDetailAddress()); |
| | | order.setReceiverPhone(memberOrderDTO.getReceiverphone()); |
| | | }else{ |
| | | MemberAddress data = memberClient.getMemberAddressOne( |
| | | memberOrderDTO.getMemberId(), SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNotNull(data)) { |
| | | order.setReceiverName(data.getRecipientName()); |
| | | order.setReceiverCity(data.getReceiverCity()); |
| | | order.setReceiverDetailAddress(data.getDetailedAddress()); |
| | | order.setReceiverPhone(data.getRecipientPhone()); |
| | | } |
| | | MemberAddress data = memberClient.getMemberAddressOne( |
| | | memberOrderDTO.getMemberId(), SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNotNull(data)) { |
| | | order.setReceiverName(data.getRecipientName()); |
| | | order.setReceiverCity(data.getReceiverCity()); |
| | | order.setReceiverDetailAddress(data.getDetailedAddress()); |
| | | order.setReceiverPhone(data.getRecipientPhone()); |
| | | } |
| | | |
| | | order.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); |
| | |
| | | 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); |
| | | redisService.setCacheObject(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getId(), order.getId() , delayTime.longValue(), TimeUnit.MINUTES); |
| | | |
| | | DelayTask delayTask = new DelayTask(); |
| | | delayTask.setDelFlag(0); |
| | | delayTask.setCreateTime(LocalDateTime.now()); |
| | | delayTask.setExecuteTime(LocalDateTime.now().plusMinutes(30)); |
| | | delayTask.setRedisKey(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getId()); |
| | | sysUserClient.addDelayTask(delayTask, SecurityConstants.INNER); |
| | | |
| | | return memberOrderVO; |
| | | } |
| | |
| | | order.setReceiverCity(memberOrderDTO.getReceiverCity()); |
| | | order.setReceiverDetailAddress(memberOrderDTO.getReceiverDetailAddress()); |
| | | order.setReceiverPhone(memberOrderDTO.getReceiverphone()); |
| | | baseMapper.updateById(order); |
| | | } |
| | | if (memberOrderDTO.getOrderRemark()!=null){ |
| | | order.setOrderRemark(memberOrderDTO.getOrderRemark()); |
| | |
| | | if (pice.doubleValue()>=data.getFullReductionAmount().doubleValue()){ |
| | | pice=pice.subtract(data.getReductionAmount()); |
| | | order.setDiscountMoney(data.getReductionAmount()); |
| | | }else{ |
| | | pice=new BigDecimal(0); |
| | | |
| | | } |
| | | } |
| | | if (data.getCouponType().getCode()==2){ |
| | | pice= order.getTotalAmount(); |
| | | if(pice.compareTo(data.getVoucherAmount())<0){ |
| | | throw new ServiceException("优惠卷抵扣金额不能大于实际支付金额"); |
| | | } |
| | | pice=pice.subtract(data.getVoucherAmount()); |
| | | order.setDiscountMoney(data.getVoucherAmount()); |
| | | } |
| | |
| | | BigDecimal pice1=new BigDecimal(data.getDiscountRate()); |
| | | BigDecimal pice2=new BigDecimal(0.1); |
| | | BigDecimal pice3=pice.multiply(pice1.multiply(pice2)); |
| | | if (pice3.compareTo(new BigDecimal(data.getMaxDiscount().doubleValue()))>0){ |
| | | pice3=new BigDecimal(data.getMaxDiscount().doubleValue()); |
| | | } |
| | | if(pice.compareTo(pice3)<0){ |
| | | throw new ServiceException("优惠卷抵扣金额不能大于实际支付金额"); |
| | | } |
| | | |
| | | BigDecimal pice4= pice.subtract(pice3); |
| | | if (pice4.doubleValue()>data.getMaxDiscount().doubleValue()){ |
| | | pice=pice.subtract(data.getMaxDiscount()); |
| | |
| | | CustomConfig memberPointsMoney = sysUserClient.getconfig("MEMBER_POINTS_MONEY").getData(); |
| | | CustomConfig memberPointsPoints = sysUserClient.getconfig("MEMBER_POINTS_POINTS").getData(); |
| | | |
| | | Double aDouble= Double.valueOf(memberPointsMoney.getConfigValue()) * Double.valueOf(memberPointsPoints.getConfigValue()); |
| | | BigDecimal pi=pice.multiply(new BigDecimal(aDouble)); |
| | | order.setPoints(pi.intValue()); |
| | | if (pice.intValue()>0){ |
| | | BigDecimal divide = pice.divide(new BigDecimal(memberPointsMoney.getConfigValue())); |
| | | BigDecimal roundedDown = divide.setScale(0, RoundingMode.DOWN); |
| | | BigDecimal aDouble= roundedDown.multiply(new BigDecimal(memberPointsPoints.getConfigValue())); |
| | | order.setPoints(aDouble.intValue()); |
| | | }else{ |
| | | order.setPoints(0); |
| | | } |
| | | |
| | | |
| | | baseMapper.updateById(order); |
| | | } |
| | | |