| | |
| | | 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)); |
| | |
| | | BigDecimal bigDecimal = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | bigDecimal = bigDecimal.add(myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber()))); |
| | | myShoppingCartVo.setEarnSpendingPoints(myShoppingCartVo.getEarnSpendingPoints() * myShoppingCartVo.getNumber()); |
| | | } |
| | | confirmOrderVo.setOrderMoney(bigDecimal); |
| | | }else{ |
| | | int sum = 0; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | sum += ((null != myShoppingCartVo.getPoint() ? myShoppingCartVo.getPoint() : 0) * myShoppingCartVo.getNumber()); |
| | | myShoppingCartVo.setEarnSpendingPoints((null != myShoppingCartVo.getEarnSpendingPoints() ? myShoppingCartVo.getEarnSpendingPoints() : 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{ |
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | 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); |
| | | //自提 |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | //构建积分流水记录 |
| | | 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))); |
| | | |
| | | //积分支付不返佣 |
| | | |
| | |
| | | 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); |
| | |
| | | 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); |
| | | |
| | | //处理优惠券 |
| | |
| | | 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); |