| | |
| | | import com.ruoyi.account.api.vo.PaymentUserCoupon; |
| | | import com.ruoyi.account.api.vo.PaymentUserCouponVo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.event.PayEvent; |
| | | import com.ruoyi.order.mapper.ShoppingCartMapper; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.model.OrderBalancePayment; |
| | |
| | | import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds; |
| | | import com.ruoyi.other.api.vo.GetSeckillActivityInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.*; |
| | | import java.util.concurrent.ArrayBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | |
| | | private CommissionService commissionService; |
| | | |
| | | @Resource |
| | | private VipSettingClient vipSettingClient; |
| | | |
| | | @Resource |
| | | private UserChangeLogClient userChangeLogClient; |
| | | |
| | | @Resource |
| | | private PointSettingClient pointSettingClient; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private ApplicationEventPublisher applicationEventPublisher; |
| | | |
| | | |
| | | |
| | |
| | | throw new RuntimeException("根据类型(1=服务商品,2=单品商品)获取商品数据失败"); |
| | | } |
| | | List<Integer> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList()); |
| | | if(goodsIds.isEmpty()){ |
| | | return new ArrayList<>(); |
| | | } |
| | | //查询符合商品类型的商品数据 |
| | | List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) |
| | | .in(ShoppingCart::getGoodsId, goodsIds).eq(ShoppingCart::getStatus, 1)); |
| | | //删除过期的秒杀活动商品 |
| | | List<ShoppingCart> list1 = new ArrayList<>(); |
| | | for (ShoppingCart shoppingCart : list) { |
| | | if(shoppingCart.getType() == 2){ |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(shoppingCart.getGoodsId()); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill data1 = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null != data1){ |
| | | SeckillActivityInfo seckillActivityInfo = seckillActivityInfoClient.getSeckillActivityInfoById(data1.getSeckillActivityInfoId()).getData(); |
| | | if(null != seckillActivityInfo && (seckillActivityInfo.getIsShelves() == 1 && |
| | | seckillActivityInfo.getStartTime().isBefore(LocalDateTime.now()) && seckillActivityInfo.getEndTime().isAfter(LocalDateTime.now()))){ |
| | | |
| | | list1.add(shoppingCart); |
| | | continue; |
| | | } |
| | | } |
| | | this.removeById(shoppingCart.getId()); |
| | | }else{ |
| | | list1.add(shoppingCart); |
| | | } |
| | | } |
| | | |
| | | //构建返回数据 |
| | | List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null); |
| | | List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list1, null); |
| | | return page; |
| | | } |
| | | |
| | |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格 |
| | | if(null == goodsSeckill || type == 1){ |
| | | if((null == goodsSeckill || (null == goodsSeckill.getCashPayment() && null == goodsSeckill.getPointPayment())) || type == 1){ |
| | | //没有秒杀价,则判断门店特价 |
| | | GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice(); |
| | | goodsBargainPrice.setGoodsId(goodsId); |
| | |
| | | area.setVip(appUser.getVipId()); |
| | | area.setGoodsId(goodsId); |
| | | GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); |
| | | if(null == goodsArea){ |
| | | if(null == goodsArea || (null == goodsArea.getCashPayment() && null == goodsArea.getPointPayment())){ |
| | | //没有地区价格,则使用会员价格 |
| | | GoodsVip goodsVip = goodsVipClient.getGoodsVip(goodsId, appUser.getVipId()).getData(); |
| | | if(null == goodsVip){ |
| | | if(null == goodsVip || (null == goodsVip.getCashPayment() && null == goodsVip.getPointPayment())){ |
| | | //没有配置价格,直接使用原始基础价格 |
| | | return null; |
| | | }else{ |
| | | price.setCash(goodsVip.getSellingPrice()); |
| | | price.setPoint(goodsVip.getIntegral()); |
| | | price.setCashPayment(goodsVip.getCashPayment() == 1); |
| | | price.setPointPayment(goodsVip.getPointPayment() == 1); |
| | | price.setCashPayment(null != goodsVip.getCashPayment() && goodsVip.getCashPayment() == 1); |
| | | price.setPointPayment(null != goodsVip.getPointPayment() && goodsVip.getPointPayment() == 1); |
| | | price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints()); |
| | |
| | | }else{ |
| | | price.setCash(goodsArea.getSellingPrice()); |
| | | price.setPoint(goodsArea.getIntegral()); |
| | | price.setCashPayment(goodsArea.getCashPayment() == 1); |
| | | price.setPointPayment(goodsArea.getPointPayment() == 1); |
| | | price.setCashPayment(null !=goodsArea.getCashPayment() && goodsArea.getCashPayment() == 1); |
| | | price.setPointPayment(null !=goodsArea.getPointPayment() && goodsArea.getPointPayment() == 1); |
| | | price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | |
| | | if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){ |
| | | price.setPoint(goodsSeckill.getIntegral()); |
| | | } |
| | | price.setCashPayment(goodsSeckill.getCashPayment() == 1); |
| | | price.setPointPayment(goodsSeckill.getPointPayment() == 1); |
| | | price.setCashPayment(null != goodsSeckill.getCashPayment() && goodsSeckill.getCashPayment() == 1); |
| | | price.setPointPayment(null != goodsSeckill.getPointPayment() && goodsSeckill.getPointPayment() == 1); |
| | | price.setEndTime(goodsSeckill.getEndTime()); |
| | | price.setEarnSpendingPoints(goodsSeckill.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsSeckill.getSuperiorSubcommission()); |
| | |
| | | @Override |
| | | public Long addGoods(ShoppingCart shoppingCart) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | long goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid); |
| | | long count = count(new LambdaQueryWrapper<ShoppingCart>() |
| | | .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()) |
| | | .eq(ShoppingCart::getStatus,1) |
| | | .eq(ShoppingCart::getAppUserId, userid)); |
| | | goodsSaleNum += count; |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | |
| | | Integer maxNum = 0; |
| | | if(shoppingCart.getType() == 2){ |
| | | R<SeckillActivityInfo> r = seckillActivityInfoClient.getSeckillActivityInfoByGoodsId(shoppingCart.getGoodsId()); |
| | | if (R.isError(r)){ |
| | | throw new ServiceException("获取秒杀商品失败!"); |
| | | } |
| | | SeckillActivityInfo seckillActivityInfo = r.getData(); |
| | | maxNum = seckillActivityInfo.getMaxNum(); |
| | | }else { |
| | | maxNum = goods.getPurchaseLimit(); |
| | | } |
| | | |
| | | if(null != goods.getPurchaseLimit() && -1 != maxNum && (goodsSaleNum + shoppingCart.getNumber()) > maxNum){ |
| | | throw new ServiceException("超出购买数量限制"); |
| | | } |
| | | ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) |
| | | .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1)); |
| | | if(null != one){ |
| | |
| | | */ |
| | | @Override |
| | | public R setGoodsNumber(SetGoodsNumber setGoodsNumber) { |
| | | |
| | | ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); |
| | | if(0 >= setGoodsNumber.getNumber()){ |
| | | return R.fail("修改数量不能小于等于0"); |
| | | } |
| | | ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); |
| | | |
| | | if(null != shoppingCart){ |
| | | |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && goods.getPurchaseLimit() < setGoodsNumber.getNumber()){ |
| | | Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | if(null != goods1.getPurchaseLimit() && -1 != goods1.getPurchaseLimit() |
| | | && goods1.getPurchaseLimit() < setGoodsNumber.getNumber() |
| | | && setGoodsNumber.getNumber() >= shoppingCart.getNumber()){ |
| | | return R.fail("修改数量不能大于限购数量"); |
| | | } |
| | | |
| | |
| | | }else{ |
| | | int sum = 0; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | sum += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber()); |
| | | sum += ((null != myShoppingCartVo.getPoint() ? myShoppingCartVo.getPoint() : 0) * myShoppingCartVo.getNumber()); |
| | | } |
| | | confirmOrderVo.setOrderPoint(sum); |
| | | } |
| | |
| | | BigDecimal paymentMoney = orderMoney; |
| | | //总优惠金额 |
| | | BigDecimal activityAmount = BigDecimal.ZERO; |
| | | |
| | | |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | | confirmOrderVo.setUseSimultaneously(JSON.parseObject(baseSetting.getContent()).getInteger("status") == 1); |
| | |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | String goodsId = myShoppingCartVo.getGoodsId().toString(); |
| | | BigDecimal cash = myShoppingCartVo.getCash(); |
| | | BigDecimal cash = myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber())); |
| | | if(parseArray.contains(goodsId)){ |
| | | goodsMoney = goodsMoney.add(cash); |
| | | }else{ |
| | |
| | | confirmOrderVo.setDiscountAmount(activityAmount); |
| | | int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum(); |
| | | confirmOrderVo.setEarnPoint(earnPoint); |
| | | if(BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | if(null != paymentMoney && BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | | |
| | |
| | | UserAddress userAddress = userAddressClient.getDefaultUserAddress(userid).getData(); |
| | | if(null != userAddress){ |
| | | userAddress.setIdStr(userAddress.getId().toString()); |
| | | userAddress.setRecieveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); |
| | | confirmOrderVo.setUserAddress(userAddress); |
| | | } |
| | | confirmOrderVo.setPaymentType(confirmOrder.getPaymentType()); |
| | |
| | | } |
| | | }else{ |
| | | //部分商品适用 |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | Integer goodsId = myShoppingCartVo.getGoodsId(); |
| | | BigDecimal cash = myShoppingCartVo.getCash(); |
| | | if(forGoodIds.contains(goodsId)){ |
| | | if(forGoodIds.contains(String.valueOf(goodsId))){ |
| | | goodsMoney = goodsMoney.add(cash); |
| | | } |
| | | } |
| | |
| | | vo.setPurchaseLimitNum(goods.getPurchaseLimit() - sum); |
| | | } |
| | | vo.setDistributionMode(goods.getDistributionMode()); |
| | | vo.setEarnSpendingPoints(price.getEarnSpendingPoints()); |
| | | vo.setSuperiorSubcommission(price.getSuperiorSubcommission()); |
| | | vo.setSuperiorRebatePoints(price.getSuperiorRebatePoints()); |
| | | vo.setEarnSpendingPoints(price.getEarnSpendingPoints() * shoppingCart.getNumber()); |
| | | vo.setSuperiorSubcommission(price.getSuperiorSubcommission().multiply(new BigDecimal(shoppingCart.getNumber()))); |
| | | vo.setSuperiorRebatePoints(price.getSuperiorRebatePoints() * shoppingCart.getNumber()); |
| | | vo.setSuperiorType(price.getSuperiorType()); |
| | | vo.setSuperiorPriceType(price.getSuperiorPriceType()); |
| | | vo.setServuceShopCharges(price.getServuceShopCharges()); |
| | | vo.setServuceShopPoints(price.getServuceShopPoints()); |
| | | vo.setTechnicianPoints(price.getTechnicianPoints()); |
| | | vo.setBoundShopCharges(price.getBoundShopCharges()); |
| | | vo.setBoundShopPoints(price.getBoundShopPoints()); |
| | | vo.setBoundShopSuperiorsCharges(price.getBoundShopSuperiorsCharges()); |
| | | vo.setBoundShopSuperiorsPoints(price.getBoundShopSuperiorsPoints()); |
| | | vo.setServuceShopCharges(price.getServuceShopCharges().multiply(new BigDecimal(shoppingCart.getNumber()))); |
| | | vo.setServuceShopPoints(price.getServuceShopPoints() * shoppingCart.getNumber()); |
| | | vo.setTechnicianPoints(price.getTechnicianPoints() * shoppingCart.getNumber()); |
| | | vo.setBoundShopCharges(price.getBoundShopCharges().multiply(new BigDecimal(shoppingCart.getNumber()))); |
| | | vo.setBoundShopPoints(price.getBoundShopPoints() * shoppingCart.getNumber()); |
| | | vo.setBoundShopSuperiorsCharges(price.getBoundShopSuperiorsCharges().multiply(new BigDecimal(shoppingCart.getNumber()))); |
| | | vo.setBoundShopSuperiorsPoints(price.getBoundShopSuperiorsPoints() * shoppingCart.getNumber()); |
| | | page.add(vo); |
| | | } |
| | | return page; |
| | |
| | | num += num1; |
| | | ShoppingCart shoppingCart = this.getById(id); |
| | | //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) |
| | | Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type); |
| | | Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type, userid); |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | if(1 == type){ |
| | | if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + num1) > goods.getPurchaseLimit()){ |
| | |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | String goodsId = myShoppingCartVo.getGoodsId().toString(); |
| | | BigDecimal cash = myShoppingCartVo.getCash(); |
| | | BigDecimal cash = myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber())); |
| | | if(parseArray.contains(goodsId)){ |
| | | goodsMoney = goodsMoney.add(cash); |
| | | }else{ |
| | |
| | | //可获得的消费积分 |
| | | int earnPoint = 0; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | earnPoint += (myShoppingCartVo.getEarnSpendingPoints() * myShoppingCartVo.getNumber()); |
| | | earnPoint += myShoppingCartVo.getEarnSpendingPoints(); |
| | | } |
| | | |
| | | //获取快递策略,计算快递费 |
| | |
| | | } |
| | | } |
| | | } |
| | | paymentMoney = paymentMoney.add(expressFee); |
| | | if(BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | |
| | | order.setGoodName(goodName.substring(0, goodName.length() - 1)); |
| | | Goods goods = goodsClient.getGoodsById(goodsList.get(0).getGoodsId()).getData(); |
| | | order.setOrderType(goods.getType()); |
| | | order.setOrderStatus(goods.getType() == 1 ? 3 : 1); |
| | | order.setOrderStatus(goods.getType() == 1 ? 3 : (shoppingCartPayment.getDistributionMode() == 2 ? 1 : 2)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | order.setOrderNumber("QJS" + getNumber(3) + sdf.format(new Date())); |
| | | order.setTotalAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN)); |
| | |
| | | if(null != orderActivityInfo1){ |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo1)); |
| | | } |
| | | if(null != shoppingCartPayment.getUserAddressId()){ |
| | | if(2 == shoppingCartPayment.getDistributionMode()){ |
| | | UserAddress address = userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData(); |
| | | order.setExpressAmount(expressFee); |
| | | order.setAddressJson(JSON.toJSONString(address)); |
| | |
| | | order.setDelFlag(0); |
| | | order.setCreateTime(LocalDateTime.now()); |
| | | order.setExpressPayMethod(shoppingCartPayment.getFreightPaymentType()); |
| | | order.setDistributionMode(shoppingCartPayment.getDistributionMode()); |
| | | |
| | | if(2 == shoppingCartPayment.getPaymentType()){ |
| | | BigDecimal balance = appUser.getBalance(); |
| | |
| | | } |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | | Integer availablePoint = appUser.getAvailablePoint(); |
| | | if(availablePoint < orderPoint){ |
| | | if(availablePoint.compareTo(orderPoint) < 0){ |
| | | return R.fail("账户可用积分不足"); |
| | | } |
| | | } |
| | |
| | | jsonObject.put("transferablePoint", earnPoint1); |
| | | } |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(earnPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | } |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | applicationEventPublisher.publishEvent(new PayEvent(JSON.toJSONString(appUser))); |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | | //自提 |
| | |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | |
| | | //删除购物车数据 |
| | | userid = tokenService.getLoginUserApplet().getUserid(); |
| | |
| | | BigDecimal balance = appUser.getBalance(); |
| | | //红包金额满足支付 |
| | | BigDecimal paymentMoney1 = paymentMoney; |
| | | if(paymentMoney1.compareTo(totalRedPacketAmount) <= 0){ |
| | | totalRedPacketAmount = totalRedPacketAmount.subtract(paymentMoney1); |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setBalance(balance); |
| | | redPacketAmount = paymentMoney1; |
| | | }else{ |
| | | paymentMoney1 = paymentMoney1.subtract(totalRedPacketAmount); |
| | | redPacketAmount = totalRedPacketAmount; |
| | | totalRedPacketAmount = BigDecimal.ZERO; |
| | | if(paymentMoney1.compareTo(totalDistributionAmount) <= 0){ |
| | | totalDistributionAmount = totalDistributionAmount.subtract(paymentMoney1); |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = paymentMoney1; |
| | | }else{ |
| | | paymentMoney1 = paymentMoney1.subtract(totalDistributionAmount); |
| | | totalDistributionAmount = BigDecimal.ZERO; |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = totalDistributionAmount; |
| | | } |
| | | } |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setBalance(balance); |
| | | |
| | | // if(paymentMoney1.compareTo(totalRedPacketAmount) <= 0){ |
| | | // totalRedPacketAmount = totalRedPacketAmount.subtract(paymentMoney1); |
| | | // balance = balance.subtract(paymentMoney1); |
| | | // appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | // appUser.setBalance(balance); |
| | | // redPacketAmount = paymentMoney1; |
| | | // }else{ |
| | | // paymentMoney1 = paymentMoney1.subtract(totalRedPacketAmount); |
| | | // redPacketAmount = totalRedPacketAmount; |
| | | // totalRedPacketAmount = BigDecimal.ZERO; |
| | | // if(paymentMoney1.compareTo(totalDistributionAmount) <= 0){ |
| | | //// totalDistributionAmount = totalDistributionAmount.subtract(paymentMoney1); |
| | | // balance = balance.subtract(paymentMoney1); |
| | | // appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | //// appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | // appUser.setBalance(balance); |
| | | // distributionAmount = paymentMoney1; |
| | | // }else{ |
| | | // paymentMoney1 = paymentMoney1.subtract(totalDistributionAmount); |
| | | // totalDistributionAmount = BigDecimal.ZERO; |
| | | // balance = balance.subtract(paymentMoney1); |
| | | // appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | //// appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | // appUser.setBalance(balance); |
| | | // distributionAmount = totalDistributionAmount; |
| | | // } |
| | | // } |
| | | //构建积分流水记录 |
| | | if(earnPoint > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | |
| | | if(earnPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | } |
| | |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | applicationEventPublisher.publishEvent(new PayEvent(JSON.toJSONString(appUser))); |
| | | //构建余额明细变动记录 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(5); |
| | | balanceChangeRecord.setBeforeAmount(balance.add(paymentMoney)); |
| | | balanceChangeRecord.setChangeAmount(paymentMoney); |
| | | balanceChangeRecord.setAfterAmount(balance); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | } |
| | | //积分支付 |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | |
| | | } |
| | | |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(orderPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(orderPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setVariablePoint(orderPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | applicationEventPublisher.publishEvent(new PayEvent(JSON.toJSONString(appUser))); |
| | | |
| | | //积分支付不返佣 |
| | | |
| | |
| | | totalDistributionAmount = totalDistributionAmount.subtract(expressFee1); |
| | | balance = balance.subtract(expressFee1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | // appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = expressFee1; |
| | | }else{ |
| | |
| | | totalDistributionAmount = BigDecimal.ZERO; |
| | | balance = balance.subtract(expressFee1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | // appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = totalDistributionAmount; |
| | | } |
| | |
| | | //构建余额明细变动记录 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(5); |
| | | balanceChangeRecord.setBeforeAmount(balance.add(expressFee)); |
| | | balanceChangeRecord.setChangeAmount(expressFee); |
| | | balanceChangeRecord.setAfterAmount(balance); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | |
| | | //删除购物车数据 |
| | | this.removeBatchByIds(ids); |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Integer waitTime = jsonObject.getInteger("waitTime"); |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | } |
| | | |
| | | //添加账户余额支付明细 |
| | |
| | | orderBalancePayment.setDistributionAmount(distributionAmount); |
| | | orderBalancePaymentService.save(orderBalancePayment); |
| | | } |
| | | |
| | | commissionService.calculationCommissionUser(order.getId()); |
| | | return R.ok(order.getId().toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public String getNumber(Integer size){ |
| | |
| | | jsonObject.put("transferablePoint", earnPoint1); |
| | | } |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(earnPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | } |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | applicationEventPublisher.publishEvent(new PayEvent(JSON.toJSONString(appUser))); |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | | //自提 |
| | | if(order.getOrderType() == 1 && StringUtils.isEmpty(order.getAddressJson())){ |
| | | order.setOrderStatus(2); |
| | | } |
| | | |
| | | String r7TrxNo = uniPayCallbackResult.getR9_BankTrxNo(); |
| | | order.setSerialNumber(r7TrxNo); |
| | | orderService.updateById(order); |
| | | |
| | | //处理优惠券 |
| | |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | //删除购物车数据 |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Long userid = order.getAppUserId(); |
| | | List<OrderGood> list = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, order.getId())); |
| | | List<Integer> goodsIds = list.stream().map(OrderGood::getGoodsId).collect(Collectors.toList()); |
| | | this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds)); |
| | | |
| | | //商品销量增加 |
| | | for (Integer goodsId : goodsIds) { |
| | | goodsClient.editGoodsNum(goodsId, 1); |
| | | } |
| | | |
| | | commissionService.calculationCommissionUser(order.getId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(orderPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(orderPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setVariablePoint(orderPoint); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | |
| | | //积分支付不反积分 |
| | | |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | applicationEventPublisher.publishEvent(new PayEvent(JSON.toJSONString(appUser))); |
| | | |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |