Pu Zhibing
2025-02-26 ed76f62db481ab1a8c125cf01d5122d1e1606266
修改分佣逻辑
18个文件已修改
1165 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserGiveawayTemporaryClientFallbackFactory.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserGiveawayTemporaryClient.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopGiveawayTemporary.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopGiveawayTemporaryClientFallbackFactory.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopGiveawayTemporaryClient.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserGiveawayTemporaryController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java 1032 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/TaskUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopGiveawayTemporaryController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
@@ -43,7 +43,6 @@
                throw new RuntimeException("获取优惠券数量失败");
            }
            @GetMapping("/appUserShop/shop/{userId}")
            @Override
            public R<List<AppUserShop>> getAppUserShop(Long userId) {
                log.error("获取用户门店信息失败:{}", cause.getMessage());
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserGiveawayTemporaryClientFallbackFactory.java
@@ -24,9 +24,11 @@
            public R<List<AppUserGiveawayTemporary>> getAppUserGiveawayTemporary(Long orderId) {
                return R.fail("查询订单临时分佣数据失败:" + cause.getMessage());
            }
        };
            @Override
            public R delAppUserGiveawayTemporary(Long orderId) {
                return R.fail("删除订单临时分佣数据失败:" + cause.getMessage());
            }};
        
        
        
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserGiveawayTemporaryClient.java
@@ -33,4 +33,13 @@
     */
    @PostMapping("/appUserGiveawayTemporary/getAppUserGiveawayTemporary")
    R<List<AppUserGiveawayTemporary>> getAppUserGiveawayTemporary(@RequestParam("orderId") Long orderId);
    /**
     * 删除订单临时分佣数据
     * @param orderId
     * @return
     */
    @PostMapping("/appUserGiveawayTemporary/delAppUserGiveawayTemporary")
    R delAppUserGiveawayTemporary(@RequestParam("orderId") Long orderId);
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopGiveawayTemporary.java
@@ -30,8 +30,8 @@
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @TableId("id")
    private Long id;
    @ApiModelProperty(value = "门店id")
    @TableField("shop_id")
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopGiveawayTemporaryClientFallbackFactory.java
@@ -24,6 +24,9 @@
            public R<List<ShopGiveawayTemporary>> getShopGiveawayTemporary(Long orderId) {
                return R.fail("获取订单相关门店分佣临时数据失败:" + cause.getMessage());
            }
        };
            @Override
            public R delShopGiveawayTemporary(Long orderId) {
                return R.fail("删除订单相关门店分佣临时数据失败:" + cause.getMessage());
            }};
    }
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopGiveawayTemporaryClient.java
@@ -34,4 +34,11 @@
     */
    @PostMapping("/shopGiveawayTemporary/getShopGiveawayTemporary")
    R<List<ShopGiveawayTemporary>> getShopGiveawayTemporary(@RequestParam("orderId") Long orderId);
    /**
     * 删除订单相关门店分佣临时数据
     * @param orderId
     */
    @PostMapping("/shopGiveawayTemporary/delShopGiveawayTemporary")
    R delShopGiveawayTemporary(@RequestParam("orderId") Long orderId);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -481,21 +481,13 @@
                .ifPresent(superiors -> {
                    user.setTeacher(superiors.getName());
                });
        //当前绑定门店的店铺信息(服务商)
        for (AppUser allSuperior : allSuperiors) {
            List<Shop> shopList = shopClient.getShopByUserId(allSuperior.getId()).getData();
            if (!CollectionUtils.isEmpty(shopList)){
                user.setShopName(shopList.get(0).getName());
                break;
            }
        Shop shop1 = shopClient.getServiceProvider(userId).getData();
        if(null != shop1){
            user.setShopName(shop1.getName());
            user.setShopId(shop1.getId());
        }
//        if (user.getShopId() != null) {
//            R<Shop> storeById = shopClient.getShopById(user.getShopId());
//            if (storeById.getData() != null) {
//                Shop shop = storeById.getData();
//                user.setShopName(shop.getName());
//            }
//        }
        ArrayList<Long> userIds = new ArrayList<>();
        userIds.add(userId);
        // 获取当前用户的所有下级
@@ -891,11 +883,9 @@
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
        AppUser byId = appUserService.getById(id);
        if (byId.getShopId() != null) {
            R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId())));
            if (shopById.getData() != null) {
                byId.setShopName(shopById.getData().getName());
            }
        Shop shop1 = shopClient.getServiceProvider(id).getData();
        if(null != shop1){
            byId.setShopName(shop1.getName());
        }
        R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id);
        if (shopByUserId.getData() != null) {
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserGiveawayTemporaryController.java
@@ -38,4 +38,16 @@
        List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getOrderId, orderId));
        return R.ok(list);
    }
    /**
     * 删除订单临时分佣数据
     * @param orderId
     * @return
     */
    @PostMapping("/delAppUserGiveawayTemporary")
    public R delAppUserGiveawayTemporary(@RequestParam("orderId") Long orderId){
        appUserGiveawayTemporaryService.remove(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getOrderId, orderId));
        return R.ok();
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java
@@ -131,7 +131,7 @@
    }
    
    
    @DeleteMapping("/getUserPointCopy")
    @PostMapping("/getUserPointCopy")
    public R<List<UserPointCopy>> getUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) {
        List<UserPointCopy> list = userPointCopyMapper.selectList(new LambdaQueryWrapper<UserPointCopy>().in(UserPointCopy::getType, type)
                .eq(UserPointCopy::getObjectId, orderId));
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserPointMapper.xml
@@ -90,6 +90,6 @@
            <if test="null != type">
                and type = #{type}
            </if>
        ) as a order by a.create_time desc
        ) as a order by a.createTime desc
    </select>
</mapper>
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -176,7 +176,6 @@
        Long days = jsonObject.getLong("days");
        Order order = orderService.getById(orderId);
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        order.setIsCommission(0);
        order.setOrderStatus(OrderStatus.COMPLETED.getCode());
        orderService.updateById(order);
        return R.ok();
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java
@@ -14,12 +14,12 @@
    /**
     * 构建个人分佣临时数据
     */
    void calculationCommissionUser();
    void calculationCommissionUser(Long orderId);
    
    /**
     * 构建门店及技师分佣临时数据
     */
    void calculationCommissionShop();
    void calculationCommissionShop(Long orderId);
    
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
@@ -90,7 +90,7 @@
                    Integer totalAvailablePoint = 0;
                    Integer transferablePoint = 0;
                    for (AppUserGiveawayTemporary datum : data) {
                        if(datum.getAppUserId().longValue() != appUserId){
                        if(datum.getAppUserId().longValue() == appUserId){
                            sharePoint += datum.getSharePoint();
                            balance = balance.add(datum.getBalance());
                            withdrawableAmount = withdrawableAmount.add(datum.getWithdrawableAmount());
@@ -180,43 +180,54 @@
            
            //开始处理明细流水
            List<BalanceChangeRecordCopy> data2 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData();
            for(BalanceChangeRecordCopy item : data2){
                BalanceChangeRecord changeRecord = new BalanceChangeRecord();
                BeanUtil.copyProperties(item, changeRecord);
                changeRecord.setId(null);
                balanceChangeRecordClient.saveBalanceChangeRecord(changeRecord);
            if(null != data2){
                for(BalanceChangeRecordCopy item : data2){
                    BalanceChangeRecord changeRecord = new BalanceChangeRecord();
                    BeanUtil.copyProperties(item, changeRecord);
                    changeRecord.setId(null);
                    balanceChangeRecordClient.saveBalanceChangeRecord(changeRecord);
                }
            }
            balanceChangeRecordClient.deleteBalanceChangeRecordCopy(order.getId(), Arrays.asList(4));
            
            List<UserPointCopy> data3 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14)).getData();
            for(UserPointCopy item : data3){
                UserPoint userPoint = new UserPoint();
                BeanUtil.copyProperties(item, userPoint);
                userPoint.setId(null);
                userPointClient.saveUserPoint(userPoint);
            if(null != data3){
                for(UserPointCopy item : data3){
                    UserPoint userPoint = new UserPoint();
                    BeanUtil.copyProperties(item, userPoint);
                    userPoint.setId(null);
                    userPointClient.saveUserPoint(userPoint);
                }
            }
            userPointClient.deleteUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14));
            
            
            List<ShopBalanceStatementCopy> data4 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)).getData();
            for(ShopBalanceStatementCopy item : data4){
                ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
                BeanUtil.copyProperties(item, shopBalanceStatement);
                shopBalanceStatement.setId(null);
                shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
            if(null != data4){
                for(ShopBalanceStatementCopy item : data4){
                    ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
                    BeanUtil.copyProperties(item, shopBalanceStatement);
                    shopBalanceStatement.setId(null);
                    shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
                }
            }
            shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3));
            
            List<ShopPointCopy> data5 = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1,2,3)).getData();
            for(ShopPointCopy item : data5){
                ShopPoint shopPoint = new ShopPoint();
                BeanUtil.copyProperties(item, shopPoint);
                shopPoint.setId(null);
                shopPointClient.saveShopPoint(shopPoint);
            if(null != data5){
                for(ShopPointCopy item : data5){
                    ShopPoint shopPoint = new ShopPoint();
                    BeanUtil.copyProperties(item, shopPoint);
                    shopPoint.setId(null);
                    shopPointClient.saveShopPoint(shopPoint);
                }
            }
            shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3));
            order.setIsCommission(3);
            orderService.updateById(order);
            appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId());
            shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId());
        }
        
    }
@@ -225,77 +236,74 @@
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void calculationCommissionUser() {
        List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().ne(Order::getIsCommission, 1).isNotNull(Order::getAfterSaleTime)
                .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()"));
        List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList());
        if(collect.size() == 0){
    public void calculationCommissionUser(Long orderId) {
        Order order = orderService.getById(orderId);
        List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
                .eq(OrderGood::getOrderId, order.getId()));
        AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
        if(null == appUser){
            log.error("无效的用户数据");
            return;
        }
        for (Order order : list) {
            List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
                    .eq(OrderGood::getOrderId, order.getId()));
            AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
            if(null == appUser){
                continue;
            }
            //指导老师分佣金额
            BigDecimal zdls_price = BigDecimal.ZERO;
            //指导老师分佣积分
            Integer zdls_point = 0;
            //服务商分佣金额
            BigDecimal fws_price = BigDecimal.ZERO;
            //服务商分佣积分
            Integer fws_point = 0;
            //高级服务商分佣金额
            BigDecimal gjfws_price = BigDecimal.ZERO;
            //高级服务商分佣积分
            Integer gjfws_point = 0;
            for (OrderGood orderGood : orderGoods) {
                //上级获得分佣金额(直推上级|直帮上级)
                BigDecimal superiorSubcommission = orderGood.getSuperiorSubcommission();
                //上级获得分佣积分(直推上级|直帮上级)
                Integer superiorRebatePoints = orderGood.getSuperiorRebatePoints();
                zdls_price = zdls_price.add(superiorSubcommission);
                zdls_point += superiorRebatePoints;
                //绑定门店分佣金额
                fws_price = fws_price.add(orderGood.getBoundShopCharges());
                //绑定门店分佣积分
                fws_point += orderGood.getBoundShopPoints();
                //绑定门店上级门店分佣金额
                gjfws_price = gjfws_price.add(orderGood.getBoundShopSuperiorsCharges());
                //绑定门店上级门店分佣积分
                gjfws_point += orderGood.getBoundShopSuperiorsPoints();
            }
            //直帮上级
            AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData();
            if(null != superiorLeader){
                BigDecimal balance = superiorLeader.getBalance();
                Integer lavePoint = superiorLeader.getLavePoint();
                if(zdls_price.compareTo(BigDecimal.ZERO) > 0){
        //指导老师分佣金额
        BigDecimal zdls_price = BigDecimal.ZERO;
        //指导老师分佣积分
        Integer zdls_point = 0;
        //服务商分佣金额
        BigDecimal fws_price = BigDecimal.ZERO;
        //服务商分佣积分
        Integer fws_point = 0;
        //高级服务商分佣金额
        BigDecimal gjfws_price = BigDecimal.ZERO;
        //高级服务商分佣积分
        Integer gjfws_point = 0;
        for (OrderGood orderGood : orderGoods) {
            //上级获得分佣金额(直推上级|直帮上级)
            BigDecimal superiorSubcommission = orderGood.getSuperiorSubcommission();
            //上级获得分佣积分(直推上级|直帮上级)
            Integer superiorRebatePoints = orderGood.getSuperiorRebatePoints();
            zdls_price = zdls_price.add(superiorSubcommission);
            zdls_point += superiorRebatePoints;
            //绑定门店分佣金额
            fws_price = fws_price.add(orderGood.getBoundShopCharges());
            //绑定门店分佣积分
            fws_point += orderGood.getBoundShopPoints();
            //绑定门店上级门店分佣金额
            gjfws_price = gjfws_price.add(orderGood.getBoundShopSuperiorsCharges());
            //绑定门店上级门店分佣积分
            gjfws_point += orderGood.getBoundShopSuperiorsPoints();
        }
        //直帮上级
        AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData();
        if(null == superiorLeader){
            log.error("指导老师查询失败");
        }
        if(null != superiorLeader){
            BigDecimal balance = superiorLeader.getBalance();
            Integer lavePoint = superiorLeader.getLavePoint();
            if(zdls_price.compareTo(BigDecimal.ZERO) > 0){
//                    superiorLeader.setTotalDistributionAmount(superiorLeader.getTotalDistributionAmount().add(zdls_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                    superiorLeader.setBalance(superiorLeader.getBalance().add(zdls_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                    superiorLeader.setWithdrawableAmount(superiorLeader.getWithdrawableAmount().add(zdls_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
                    //添加临时分佣数据
                    AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                    appUserGiveawayTemporary.setOrderId(order.getId());
                    appUserGiveawayTemporary.setAppUserId(superiorLeader.getId());
                    appUserGiveawayTemporary.setTotalDistributionAmount(zdls_price);
                    appUserGiveawayTemporary.setBalance(zdls_price);
                    appUserGiveawayTemporary.setWithdrawableAmount(zdls_price);
                    appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                //添加临时分佣数据
                AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                appUserGiveawayTemporary.setOrderId(order.getId());
                appUserGiveawayTemporary.setAppUserId(superiorLeader.getId());
                appUserGiveawayTemporary.setTotalDistributionAmount(zdls_price);
                appUserGiveawayTemporary.setBalance(zdls_price);
                appUserGiveawayTemporary.setWithdrawableAmount(zdls_price);
                appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
            }
            if(zdls_point > 0){
                PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                int earnPoint1 = 0;
                //计算可用积分比例
                if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){
                    earnPoint1 = new BigDecimal(zdls_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue();
                }
                if(zdls_point > 0){
                    PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                    int earnPoint1 = 0;
                    //计算可用积分比例
                    if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){
                        earnPoint1 = new BigDecimal(zdls_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue();
                    }
//                    superiorLeader.setSharePoint(superiorLeader.getSharePoint() + zdls_point);
//                    superiorLeader.setLavePoint(superiorLeader.getLavePoint() + zdls_point);
//                    superiorLeader.setAvailablePoint(superiorLeader.getAvailablePoint() + earnPoint1);
@@ -304,87 +312,93 @@
//                        superiorLeader.setTransferablePoint(superiorLeader.getTransferablePoint() + earnPoint1);
//                    }
//                    superiorLeader.setTotalPoint(superiorLeader.getTotalPoint() + zdls_point);
                    //添加临时分佣数据
                    AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                    appUserGiveawayTemporary.setOrderId(order.getId());
                    appUserGiveawayTemporary.setAppUserId(superiorLeader.getId());
                    appUserGiveawayTemporary.setSharePoint(zdls_point);
                    appUserGiveawayTemporary.setLavePoint(zdls_point);
                    appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                    appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                    if(null != pointSetting && 1 == pointSetting.getSharePointGift()){
                        appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                    }
                    appUserGiveawayTemporary.setTotalPoint(zdls_point);
                    appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                //添加临时分佣数据
                AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                appUserGiveawayTemporary.setOrderId(order.getId());
                appUserGiveawayTemporary.setAppUserId(superiorLeader.getId());
                appUserGiveawayTemporary.setSharePoint(zdls_point);
                appUserGiveawayTemporary.setLavePoint(zdls_point);
                appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                if(null != pointSetting && 1 == pointSetting.getSharePointGift()){
                    appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                }
//                appUserClient.editAppUserById(superiorLeader);
                //添加明细记录
                if(zdls_price.compareTo(BigDecimal.ZERO) > 0){
                    //添加临时明细记录数据
                    BalanceChangeRecordCopy balanceChangeRecordCopy = new BalanceChangeRecordCopy();
                    balanceChangeRecordCopy.setAppUserId(superiorLeader.getId());
                    balanceChangeRecordCopy.setVipId(superiorLeader.getVipId());
                    balanceChangeRecordCopy.setOrderId(order.getId());
                    balanceChangeRecordCopy.setChangeType(4);
                    balanceChangeRecordCopy.setBeforeAmount(balance);
                    balanceChangeRecordCopy.setChangeAmount(zdls_price);
                    balanceChangeRecordCopy.setAfterAmount(superiorLeader.getBalance());
                    balanceChangeRecordCopy.setDelFlag(0);
                    balanceChangeRecordCopy.setCreateTime(LocalDateTime.now());
                    balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy);
                }
                //添加积分明细
                if(zdls_point > 0){
                    UserPointCopy userPointCopy = new UserPointCopy();
                    userPointCopy.setType(2);
                    userPointCopy.setHistoricalPoint(lavePoint);
                    userPointCopy.setVariablePoint(zdls_point);
                    userPointCopy.setBalance(superiorLeader.getLavePoint());
                    userPointCopy.setCreateTime(LocalDateTime.now());
                    userPointCopy.setAppUserId(superiorLeader.getId());
                    userPointCopy.setObjectId(order.getId());
                    userPointCopy.setExtention(order.getOrderNumber());
                    userPointClient.saveUserPointCopy(userPointCopy);
                    //变更等级
//                    appUserClient.vipUpgrade(superiorLeader.getId());
                }
                appUserGiveawayTemporary.setTotalPoint(zdls_point);
                appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
            }
            //服务商分佣
            Shop shop1 = shopClient.getServiceProvider(appUser.getId()).getData();
            if(null != shop1){
                AppUser bdShopAppUser = appUserClient.getAppUserById(shop1.getAppUserId());
                if(null != bdShopAppUser){
                    BigDecimal shopBalance = shop1.getBalance();
                    Integer lavePoint = bdShopAppUser.getLavePoint();
                    Integer shopLavePoint = shop1.getLavePoint();
                    if(fws_price.compareTo(BigDecimal.ZERO) > 0){
                        //门店返佣
//                appUserClient.editAppUserById(superiorLeader);
            //添加明细记录
            if(zdls_price.compareTo(BigDecimal.ZERO) > 0){
                //添加临时明细记录数据
                BalanceChangeRecordCopy balanceChangeRecordCopy = new BalanceChangeRecordCopy();
                balanceChangeRecordCopy.setAppUserId(superiorLeader.getId());
                balanceChangeRecordCopy.setVipId(superiorLeader.getVipId());
                balanceChangeRecordCopy.setOrderId(order.getId());
                balanceChangeRecordCopy.setChangeType(4);
                balanceChangeRecordCopy.setBeforeAmount(balance);
                balanceChangeRecordCopy.setChangeAmount(zdls_price);
                balanceChangeRecordCopy.setAfterAmount(superiorLeader.getBalance());
                balanceChangeRecordCopy.setDelFlag(0);
                balanceChangeRecordCopy.setCreateTime(LocalDateTime.now());
                balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy);
            }
            //添加积分明细
            if(zdls_point > 0){
                UserPointCopy userPointCopy = new UserPointCopy();
                userPointCopy.setType(2);
                userPointCopy.setHistoricalPoint(lavePoint);
                userPointCopy.setVariablePoint(zdls_point);
                userPointCopy.setBalance(superiorLeader.getLavePoint());
                userPointCopy.setCreateTime(LocalDateTime.now());
                userPointCopy.setAppUserId(superiorLeader.getId());
                userPointCopy.setObjectId(order.getId());
                userPointCopy.setExtention(order.getOrderNumber());
                userPointClient.saveUserPointCopy(userPointCopy);
                //变更等级
//                    appUserClient.vipUpgrade(superiorLeader.getId());
            }
        }
        //服务商分佣
        Shop shop1 = shopClient.getServiceProvider(appUser.getId()).getData();
        if(null == shop1){
            log.error("服务商查询失败");
        }
        if(null != shop1){
            AppUser bdShopAppUser = appUserClient.getAppUserById(shop1.getAppUserId());
            if(null == bdShopAppUser){
                log.error("服务商用户查询失败");
            }
            if(null != bdShopAppUser){
                BigDecimal shopBalance = shop1.getBalance();
                Integer lavePoint = bdShopAppUser.getLavePoint();
                Integer shopLavePoint = shop1.getLavePoint();
                if(fws_price.compareTo(BigDecimal.ZERO) > 0){
                    //门店返佣
//                        shop1.setGiveawayAllMoney(shop1.getGiveawayAllMoney().add(fws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop1.setGiveawayMoney(shop1.getGiveawayMoney().add(fws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop1.setCanWithdrawMoney(shop1.getCanWithdrawMoney().add(fws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop1.setBalance(shop1.getBalance().add(fws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
                        //添加临时数据
                        ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                        shopGiveawayTemporary.setShopId(shop1.getId());
                        shopGiveawayTemporary.setOrderId(order.getId());
                        shopGiveawayTemporary.setGiveawayAllMoney(fws_price);
                        shopGiveawayTemporary.setGiveawayMoney(fws_price);
                        shopGiveawayTemporary.setCanWithdrawMoney(fws_price);
                        shopGiveawayTemporary.setBalance(fws_price);
                        shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                    //添加临时数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop1.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setGiveawayAllMoney(fws_price);
                    shopGiveawayTemporary.setGiveawayMoney(fws_price);
                    shopGiveawayTemporary.setCanWithdrawMoney(fws_price);
                    shopGiveawayTemporary.setBalance(fws_price);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                }
                if(fws_point > 0){
                    PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                    int earnPoint1 = 0;
                    //计算可用积分比例
                    if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
                        earnPoint1 = new BigDecimal(fws_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
                    }
                    if(fws_point > 0){
                        PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                        int earnPoint1 = 0;
                        //计算可用积分比例
                        if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
                            earnPoint1 = new BigDecimal(fws_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
                        }
//                        bdShopAppUser.setLavePoint(bdShopAppUser.getLavePoint() + fws_point);
//                        bdShopAppUser.setAvailablePoint(bdShopAppUser.getAvailablePoint() + earnPoint1);
//                        bdShopAppUser.setTotalAvailablePoint(bdShopAppUser.getTotalAvailablePoint() + earnPoint1);
@@ -393,115 +407,121 @@
//                        }
//                        bdShopAppUser.setTotalPoint(bdShopAppUser.getTotalPoint() + fws_point);
//                        bdShopAppUser.setShopSharePoint(bdShopAppUser.getShopSharePoint() + fws_point);
                        //添加临时分佣数据
                        AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                        appUserGiveawayTemporary.setOrderId(order.getId());
                        appUserGiveawayTemporary.setAppUserId(bdShopAppUser.getId());
                        appUserGiveawayTemporary.setLavePoint(fws_point);
                        appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                        appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                        if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
                            appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                        }
                        appUserGiveawayTemporary.setTotalPoint(fws_point);
                        appUserGiveawayTemporary.setShopSharePoint(fws_point);
                        appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                        //门店返佣
                    //添加临时分佣数据
                    AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                    appUserGiveawayTemporary.setOrderId(order.getId());
                    appUserGiveawayTemporary.setAppUserId(bdShopAppUser.getId());
                    appUserGiveawayTemporary.setLavePoint(fws_point);
                    appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                    appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                    if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
                        appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                    }
                    appUserGiveawayTemporary.setTotalPoint(fws_point);
                    appUserGiveawayTemporary.setShopSharePoint(fws_point);
                    appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                    //门店返佣
//                        shop1.setShopAllPoint(shop1.getShopAllPoint() + fws_point);
//                        shop1.setSharePoint(shop1.getSharePoint() + fws_point);
//                        shop1.setLavePoint(shop1.getLavePoint() + fws_point);
                        //添加临时分佣数据
                        ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                        shopGiveawayTemporary.setShopId(shop1.getId());
                        shopGiveawayTemporary.setOrderId(order.getId());
                        shopGiveawayTemporary.setShopAllPoint(fws_point);
                        shopGiveawayTemporary.setSharePoint(fws_point);
                        shopGiveawayTemporary.setLavePoint(fws_point);
                        shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                    }
                    //添加临时分佣数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop1.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setShopAllPoint(fws_point);
                    shopGiveawayTemporary.setSharePoint(fws_point);
                    shopGiveawayTemporary.setLavePoint(fws_point);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                }
//                    appUserClient.editAppUserById(bdShopAppUser);
//                    shopClient.updateShop(shop1);
                    //添加明细记录
                    if(fws_price.compareTo(BigDecimal.ZERO) > 0){
                        ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                        shopBalanceStatementCopy.setShopId(shop1.getId());
                        shopBalanceStatementCopy.setType(1);
                        shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                        shopBalanceStatementCopy.setVariableAmount(fws_price);
                        shopBalanceStatementCopy.setBalance(shop1.getBalance());
                        shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                        shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                        shopBalanceStatementCopy.setObjectId(order.getId());
                        shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                        shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                    }
                    //添加积分明细
                    if(fws_point > 0){
                        UserPointCopy userPointCopy = new UserPointCopy();
                        userPointCopy.setType(9);
                        userPointCopy.setHistoricalPoint(lavePoint);
                        userPointCopy.setVariablePoint(fws_point);
                        userPointCopy.setBalance(bdShopAppUser.getLavePoint());
                        userPointCopy.setCreateTime(LocalDateTime.now());
                        userPointCopy.setAppUserId(bdShopAppUser.getId());
                        userPointCopy.setObjectId(order.getId());
                        userPointCopy.setExtention(order.getOrderNumber());
                        userPointClient.saveUserPointCopy(userPointCopy);
                        //变更等级
                //添加明细记录
                if(fws_price.compareTo(BigDecimal.ZERO) > 0){
                    ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                    shopBalanceStatementCopy.setShopId(shop1.getId());
                    shopBalanceStatementCopy.setType(1);
                    shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                    shopBalanceStatementCopy.setVariableAmount(fws_price);
                    shopBalanceStatementCopy.setBalance(shop1.getBalance());
                    shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                    shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                    shopBalanceStatementCopy.setObjectId(order.getId());
                    shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                    shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                }
                //添加积分明细
                if(fws_point > 0){
                    UserPointCopy userPointCopy = new UserPointCopy();
                    userPointCopy.setType(9);
                    userPointCopy.setHistoricalPoint(lavePoint);
                    userPointCopy.setVariablePoint(fws_point);
                    userPointCopy.setBalance(bdShopAppUser.getLavePoint());
                    userPointCopy.setCreateTime(LocalDateTime.now());
                    userPointCopy.setAppUserId(bdShopAppUser.getId());
                    userPointCopy.setObjectId(order.getId());
                    userPointCopy.setExtention(order.getOrderNumber());
                    userPointClient.saveUserPointCopy(userPointCopy);
                    //变更等级
//                        appUserClient.vipUpgrade(bdShopAppUser.getId());
                    }
                    if(shopLavePoint > 0){
                        ShopPointCopy shopPointCopy = new ShopPointCopy();
                        shopPointCopy.setShopId(shop1.getId());
                        shopPointCopy.setType(2);
                        shopPointCopy.setHistoricalPoint(shopLavePoint);
                        shopPointCopy.setVariablePoint(fws_point);
                        shopPointCopy.setBalance(shop1.getLavePoint());
                        shopPointCopy.setCreateTime(LocalDateTime.now());
                        shopPointCopy.setCreateUserId(order.getAppUserId());
                        shopPointCopy.setObjectId(order.getId());
                        shopPointCopy.setOrderNum(order.getOrderNumber());
                        shopPointClient.saveShopPointCopy(shopPointCopy);
                    }
                }
                if(shopLavePoint > 0){
                    ShopPointCopy shopPointCopy = new ShopPointCopy();
                    shopPointCopy.setShopId(shop1.getId());
                    shopPointCopy.setType(2);
                    shopPointCopy.setHistoricalPoint(shopLavePoint);
                    shopPointCopy.setVariablePoint(fws_point);
                    shopPointCopy.setBalance(shop1.getLavePoint());
                    shopPointCopy.setCreateTime(LocalDateTime.now());
                    shopPointCopy.setCreateUserId(order.getAppUserId());
                    shopPointCopy.setObjectId(order.getId());
                    shopPointCopy.setOrderNum(order.getOrderNumber());
                    shopPointClient.saveShopPointCopy(shopPointCopy);
                }
            }
            //高级服务商
            Shop shop2 = shopClient.getSuperiorServiceProvider(order.getAppUserId()).getData();
            if(null != shop2){
                AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId());
                if(null != sjShopAppUser){
                    BigDecimal shopBalance = shop2.getBalance();
                    Integer lavePoint = sjShopAppUser.getLavePoint();
                    Integer shopLavePoint = shop2.getLavePoint();
                    if(gjfws_price.compareTo(BigDecimal.ZERO) > 0){
                        //门店返佣
        }
        //高级服务商
        Shop shop2 = shopClient.getSuperiorServiceProvider(order.getAppUserId()).getData();
        if(null == shop2){
            log.error("高级服务商查询失败");
        }
        if(null != shop2){
            AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId());
            if(null == sjShopAppUser){
                log.error("高级服务商用户查询失败");
            }
            if(null != sjShopAppUser){
                BigDecimal shopBalance = shop2.getBalance();
                Integer lavePoint = sjShopAppUser.getLavePoint();
                Integer shopLavePoint = shop2.getLavePoint();
                if(gjfws_price.compareTo(BigDecimal.ZERO) > 0){
                    //门店返佣
//                        shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(gjfws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(gjfws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(gjfws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                        shop2.setBalance(shop2.getBalance().add(gjfws_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
                        //添加临时分佣数据
                        ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                        shopGiveawayTemporary.setShopId(shop2.getId());
                        shopGiveawayTemporary.setOrderId(order.getId());
                        shopGiveawayTemporary.setGiveawayAllMoney(gjfws_price);
                        shopGiveawayTemporary.setLowerLevelGiveawayMoney(gjfws_price);
                        shopGiveawayTemporary.setCanWithdrawMoney(gjfws_price);
                        shopGiveawayTemporary.setBalance(gjfws_price);
                        shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                    //添加临时分佣数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop2.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setGiveawayAllMoney(gjfws_price);
                    shopGiveawayTemporary.setLowerLevelGiveawayMoney(gjfws_price);
                    shopGiveawayTemporary.setCanWithdrawMoney(gjfws_price);
                    shopGiveawayTemporary.setBalance(gjfws_price);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                }
                if(gjfws_point > 0){
                    PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                    int earnPoint1 = 0;
                    //计算可用积分比例
                    if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
                        earnPoint1 = new BigDecimal(gjfws_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
                    }
                    if(gjfws_point > 0){
                        PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                        int earnPoint1 = 0;
                        //计算可用积分比例
                        if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
                            earnPoint1 = new BigDecimal(gjfws_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
                        }
//                        sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + gjfws_point);
//                        sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1);
//                        sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1);
@@ -510,156 +530,156 @@
//                        }
//                        sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + gjfws_point);
//                        sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + gjfws_point);
                        //添加临时分佣数据
                        AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                        appUserGiveawayTemporary.setOrderId(order.getId());
                        appUserGiveawayTemporary.setAppUserId(sjShopAppUser.getId());
                        appUserGiveawayTemporary.setLavePoint(gjfws_point);
                        appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                        appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                        if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
                            appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                        }
                        appUserGiveawayTemporary.setTotalPoint(gjfws_point);
                        appUserGiveawayTemporary.setLowerLevelSharePoint(gjfws_point);
                        appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                        //门店返佣
                    //添加临时分佣数据
                    AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                    appUserGiveawayTemporary.setOrderId(order.getId());
                    appUserGiveawayTemporary.setAppUserId(sjShopAppUser.getId());
                    appUserGiveawayTemporary.setLavePoint(gjfws_point);
                    appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                    appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                    if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
                        appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                    }
                    appUserGiveawayTemporary.setTotalPoint(gjfws_point);
                    appUserGiveawayTemporary.setLowerLevelSharePoint(gjfws_point);
                    appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                    //门店返佣
//                        shop2.setShopAllPoint(shop2.getShopAllPoint() + gjfws_point);
//                        shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + gjfws_point);
//                        shop2.setLavePoint(shop2.getLavePoint() + gjfws_point);
                        //添加临时分佣数据
                        ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                        shopGiveawayTemporary.setShopId(shop2.getId());
                        shopGiveawayTemporary.setOrderId(order.getId());
                        shopGiveawayTemporary.setShopAllPoint(gjfws_point);
                        shopGiveawayTemporary.setLowerLevelSharePoint(gjfws_point);
                        shopGiveawayTemporary.setLavePoint(gjfws_point);
                        shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                    }
                    //添加临时分佣数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop2.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setShopAllPoint(gjfws_point);
                    shopGiveawayTemporary.setLowerLevelSharePoint(gjfws_point);
                    shopGiveawayTemporary.setLavePoint(gjfws_point);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                }
//                    appUserClient.editAppUserById(sjShopAppUser);
//                    shopClient.updateShop(shop2);
                    //添加明细记录
                    if(gjfws_price.compareTo(BigDecimal.ZERO) > 0){
                        ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                        shopBalanceStatementCopy.setShopId(shop2.getId());
                        shopBalanceStatementCopy.setType(2);
                        shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                        shopBalanceStatementCopy.setVariableAmount(gjfws_price);
                        shopBalanceStatementCopy.setBalance(shop2.getBalance());
                        shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                        shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                        shopBalanceStatementCopy.setObjectId(order.getId());
                        shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                        shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                    }
                    //添加积分明细
                    if(gjfws_point > 0){
                        UserPointCopy userPointCopy = new UserPointCopy();
                        userPointCopy.setType(14);
                        userPointCopy.setHistoricalPoint(lavePoint);
                        userPointCopy.setVariablePoint(gjfws_point);
                        userPointCopy.setBalance(sjShopAppUser.getLavePoint());
                        userPointCopy.setCreateTime(LocalDateTime.now());
                        userPointCopy.setAppUserId(sjShopAppUser.getId());
                        userPointCopy.setObjectId(order.getId());
                        userPointCopy.setExtention(order.getOrderNumber());
                        userPointClient.saveUserPointCopy(userPointCopy);
                        //变更等级
                //添加明细记录
                if(gjfws_price.compareTo(BigDecimal.ZERO) > 0){
                    ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                    shopBalanceStatementCopy.setShopId(shop2.getId());
                    shopBalanceStatementCopy.setType(2);
                    shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                    shopBalanceStatementCopy.setVariableAmount(gjfws_price);
                    shopBalanceStatementCopy.setBalance(shop2.getBalance());
                    shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                    shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                    shopBalanceStatementCopy.setObjectId(order.getId());
                    shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                    shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                }
                //添加积分明细
                if(gjfws_point > 0){
                    UserPointCopy userPointCopy = new UserPointCopy();
                    userPointCopy.setType(14);
                    userPointCopy.setHistoricalPoint(lavePoint);
                    userPointCopy.setVariablePoint(gjfws_point);
                    userPointCopy.setBalance(sjShopAppUser.getLavePoint());
                    userPointCopy.setCreateTime(LocalDateTime.now());
                    userPointCopy.setAppUserId(sjShopAppUser.getId());
                    userPointCopy.setObjectId(order.getId());
                    userPointCopy.setExtention(order.getOrderNumber());
                    userPointClient.saveUserPointCopy(userPointCopy);
                    //变更等级
//                        appUserClient.vipUpgrade(sjShopAppUser.getId());
                    }
                    if(gjfws_point > 0){
                        ShopPointCopy shopPointCopy = new ShopPointCopy();
                        shopPointCopy.setShopId(shop2.getId());
                        shopPointCopy.setType(3);
                        shopPointCopy.setHistoricalPoint(shopLavePoint);
                        shopPointCopy.setVariablePoint(gjfws_point);
                        shopPointCopy.setBalance(shop2.getLavePoint());
                        shopPointCopy.setCreateTime(LocalDateTime.now());
                        shopPointCopy.setCreateUserId(order.getAppUserId());
                        shopPointCopy.setObjectId(order.getId());
                        shopPointCopy.setOrderNum(order.getOrderNumber());
                        shopPointClient.saveShopPointCopy(shopPointCopy);
                    }
                }
                if(gjfws_point > 0){
                    ShopPointCopy shopPointCopy = new ShopPointCopy();
                    shopPointCopy.setShopId(shop2.getId());
                    shopPointCopy.setType(3);
                    shopPointCopy.setHistoricalPoint(shopLavePoint);
                    shopPointCopy.setVariablePoint(gjfws_point);
                    shopPointCopy.setBalance(shop2.getLavePoint());
                    shopPointCopy.setCreateTime(LocalDateTime.now());
                    shopPointCopy.setCreateUserId(order.getAppUserId());
                    shopPointCopy.setObjectId(order.getId());
                    shopPointCopy.setOrderNum(order.getOrderNumber());
                    shopPointClient.saveShopPointCopy(shopPointCopy);
                }
            }
            order.setIsCommission(1);
            orderService.updateById(order);
        }
        //自提单品和服务需要走线下核销流程
        if(order.getOrderType() == 2 && order.getDistributionMode() == 2){
            order.setIsCommission(2);
        }else{
            order.setIsCommission(1);
        }
        orderService.updateById(order);
    }
    
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void calculationCommissionShop() {
        List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().ne(Order::getIsCommission, 2).isNotNull(Order::getAfterSaleTime)
                .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()"));
        List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList());
        if(collect.size() == 0){
    public void calculationCommissionShop(Long orderId) {
        Order order = orderService.getById(orderId);
        List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
                .eq(OrderGood::getOrderId, order.getId()));
        AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
        if(null == appUser){
            return;
        }
        for (Order order : list) {
            List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
                    .eq(OrderGood::getOrderId, order.getId()));
            AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
            if(null == appUser){
                continue;
        //核销门店分佣金额
        BigDecimal hxmd_price = BigDecimal.ZERO;
        //核销门店分佣积分
        Integer hxmd_point = 0;
        //技师分佣积分
        Integer js_point = 0;
        for (OrderGood orderGood : orderGoods) {
            //核销门店获取服务费
            hxmd_price = hxmd_price.add(orderGood.getServuceShopCharges());
            //核销门店可获得积分
            hxmd_point += orderGood.getServuceShopPoints();
            //技师分佣金额
            if(order.getOrderType() == 1){
                js_point += orderGood.getTechnicianPoints();
            }
            //核销门店分佣金额
            BigDecimal hxmd_price = BigDecimal.ZERO;
            //核销门店分佣积分
            Integer hxmd_point = 0;
            //技师分佣积分
            Integer js_point = 0;
            for (OrderGood orderGood : orderGoods) {
                //核销门店获取服务费
                hxmd_price = hxmd_price.add(orderGood.getServuceShopCharges());
                //核销门店可获得积分
                hxmd_point += orderGood.getServuceShopPoints();
                //技师分佣金额
                if(order.getOrderType() == 1){
                    js_point += orderGood.getTechnicianPoints();
                }
            }
            //核销门店
            Shop shop = shopClient.getShopById(order.getShopId()).getData();
            AppUser shopAppUser = appUserClient.getAppUserById(shop.getAppUserId());
            if(null != shopAppUser){
                BigDecimal shopBalance = shop.getBalance();
                Integer lavePoint = shopAppUser.getLavePoint();
                Integer shopLavePoint = shop.getLavePoint();
                if(hxmd_price.compareTo(BigDecimal.ZERO) > 0){
                    //门店返佣
        }
        //核销门店
        Shop shop = shopClient.getShopById(order.getShopId()).getData();
        AppUser shopAppUser = appUserClient.getAppUserById(shop.getAppUserId());
        if(null == shopAppUser){
            log.error("核销门店用户查询失败");
        }
        if(null != shopAppUser){
            BigDecimal shopBalance = shop.getBalance();
            Integer lavePoint = shopAppUser.getLavePoint();
            Integer shopLavePoint = shop.getLavePoint();
            if(hxmd_price.compareTo(BigDecimal.ZERO) > 0){
                //门店返佣
//                    shop.setGiveawayAllMoney(shop.getGiveawayAllMoney().add(hxmd_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                    shop.setServerGiveawayMoney(shop.getServerGiveawayMoney().add(hxmd_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                    shop.setCanWithdrawMoney(shop.getCanWithdrawMoney().add(hxmd_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
//                    shop.setBalance(shop.getBalance().add(hxmd_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
                    //添加临时分佣数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setGiveawayAllMoney(hxmd_price);
                    shopGiveawayTemporary.setServerGiveawayMoney(hxmd_price);
                    shopGiveawayTemporary.setCanWithdrawMoney(hxmd_price);
                    shopGiveawayTemporary.setBalance(hxmd_price);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                //添加临时分佣数据
                ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                shopGiveawayTemporary.setShopId(shop.getId());
                shopGiveawayTemporary.setOrderId(order.getId());
                shopGiveawayTemporary.setGiveawayAllMoney(hxmd_price);
                shopGiveawayTemporary.setServerGiveawayMoney(hxmd_price);
                shopGiveawayTemporary.setCanWithdrawMoney(hxmd_price);
                shopGiveawayTemporary.setBalance(hxmd_price);
                shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
            }
            if(hxmd_point > 0){
                PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                int earnPoint1 = 0;
                //计算可用积分比例
                if(null != pointSetting && 1 == pointSetting.getShopPointOpen()){
                    earnPoint1 = new BigDecimal(hxmd_point).multiply(pointSetting.getShopPoint().divide(new BigDecimal(100))).intValue();
                }
                if(hxmd_point > 0){
                    PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                    int earnPoint1 = 0;
                    //计算可用积分比例
                    if(null != pointSetting && 1 == pointSetting.getShopPointOpen()){
                        earnPoint1 = new BigDecimal(hxmd_point).multiply(pointSetting.getShopPoint().divide(new BigDecimal(100))).intValue();
                    }
//                    shopAppUser.setLavePoint(shopAppUser.getLavePoint() + hxmd_point);
//                    shopAppUser.setAvailablePoint(shopAppUser.getAvailablePoint() + earnPoint1);
//                    shopAppUser.setTotalAvailablePoint(shopAppUser.getTotalAvailablePoint() + earnPoint1);
@@ -668,97 +688,100 @@
//                    }
//                    shopAppUser.setTotalPoint(shopAppUser.getTotalPoint() + hxmd_point);
//                    shopAppUser.setShopAchievementPoint(shopAppUser.getShopAchievementPoint() + hxmd_point);
                    //添加临时分佣数据
                    AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                    appUserGiveawayTemporary.setOrderId(order.getId());
                    appUserGiveawayTemporary.setAppUserId(shopAppUser.getId());
                    appUserGiveawayTemporary.setLavePoint(hxmd_point);
                    appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                    appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                    if(null != pointSetting && 1 == pointSetting.getShopPointGift()){
                        appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                    }
                    appUserGiveawayTemporary.setTotalPoint(hxmd_point);
                    appUserGiveawayTemporary.setShopAchievementPoint(hxmd_point);
                    appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                    //门店返佣
                //添加临时分佣数据
                AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                appUserGiveawayTemporary.setOrderId(order.getId());
                appUserGiveawayTemporary.setAppUserId(shopAppUser.getId());
                appUserGiveawayTemporary.setLavePoint(hxmd_point);
                appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                if(null != pointSetting && 1 == pointSetting.getShopPointGift()){
                    appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                }
                appUserGiveawayTemporary.setTotalPoint(hxmd_point);
                appUserGiveawayTemporary.setShopAchievementPoint(hxmd_point);
                appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                //门店返佣
//                    shop.setShopAllPoint(shop.getShopAllPoint() + hxmd_point);
//                    shop.setServerPoint(shop.getServerPoint() + hxmd_point);
//                    shop.setLavePoint(shop.getLavePoint() + hxmd_point);
                    //添加临时分佣数据
                    ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                    shopGiveawayTemporary.setShopId(shop.getId());
                    shopGiveawayTemporary.setOrderId(order.getId());
                    shopGiveawayTemporary.setShopAllPoint(hxmd_point);
                    shopGiveawayTemporary.setServerPoint(hxmd_point);
                    shopGiveawayTemporary.setLavePoint(hxmd_point);
                    shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
                }
                //添加临时分佣数据
                ShopGiveawayTemporary shopGiveawayTemporary = new ShopGiveawayTemporary();
                shopGiveawayTemporary.setShopId(shop.getId());
                shopGiveawayTemporary.setOrderId(order.getId());
                shopGiveawayTemporary.setShopAllPoint(hxmd_point);
                shopGiveawayTemporary.setServerPoint(hxmd_point);
                shopGiveawayTemporary.setLavePoint(hxmd_point);
                shopGiveawayTemporaryClient.saveShopGiveawayTemporary(shopGiveawayTemporary);
            }
//                appUserClient.editAppUserById(shopAppUser);
//                shopClient.updateShop(shop);
                //添加明细记录
                if(hxmd_price.compareTo(BigDecimal.ZERO) > 0){
                    ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                    shopBalanceStatementCopy.setShopId(shop.getId());
                    shopBalanceStatementCopy.setType(3);
                    shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                    shopBalanceStatementCopy.setVariableAmount(hxmd_price);
                    shopBalanceStatementCopy.setBalance(shop.getBalance());
                    shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                    shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                    shopBalanceStatementCopy.setObjectId(order.getId());
                    shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                    shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
                }
                //添加积分明细
                if(!shopAppUser.getLavePoint().equals(lavePoint)){
                    UserPointCopy userPointCopy = new UserPointCopy();
                    userPointCopy.setType(8);
                    userPointCopy.setHistoricalPoint(lavePoint);
                    userPointCopy.setVariablePoint(hxmd_point);
                    userPointCopy.setBalance(shopAppUser.getLavePoint());
                    userPointCopy.setCreateTime(LocalDateTime.now());
                    userPointCopy.setAppUserId(shopAppUser.getId());
                    userPointCopy.setObjectId(order.getId());
                    userPointCopy.setExtention(order.getOrderNumber());
                    userPointClient.saveUserPointCopy(userPointCopy);
                    //变更等级
//                    appUserClient.vipUpgrade(shopAppUser.getId());
                }
                if(!shop.getLavePoint().equals(shopLavePoint)){
                    ShopPointCopy shopPointCopy = new ShopPointCopy();
                    shopPointCopy.setShopId(shop.getId());
                    shopPointCopy.setType(1);
                    shopPointCopy.setHistoricalPoint(shopLavePoint);
                    shopPointCopy.setVariablePoint(hxmd_point);
                    shopPointCopy.setBalance(shop.getLavePoint());
                    shopPointCopy.setCreateTime(LocalDateTime.now());
                    shopPointCopy.setCreateUserId(order.getAppUserId());
                    shopPointCopy.setObjectId(order.getId());
                    shopPointCopy.setOrderNum(order.getOrderNumber());
                    shopPointClient.saveShopPointCopy(shopPointCopy);
                }
            //添加明细记录
            if(hxmd_price.compareTo(BigDecimal.ZERO) > 0){
                ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy();
                shopBalanceStatementCopy.setShopId(shop.getId());
                shopBalanceStatementCopy.setType(3);
                shopBalanceStatementCopy.setHistoricalBalance(shopBalance);
                shopBalanceStatementCopy.setVariableAmount(hxmd_price);
                shopBalanceStatementCopy.setBalance(shop.getBalance());
                shopBalanceStatementCopy.setCreateTime(LocalDateTime.now());
                shopBalanceStatementCopy.setCreateUserId(order.getAppUserId());
                shopBalanceStatementCopy.setObjectId(order.getId());
                shopBalanceStatementCopy.setExtension(order.getOrderNumber());
                shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy);
            }
            //技师服务积分
            if(order.getOrderType() == 1){
                Technician technician = technicianClient.shopdetail(order.getTechnicianId()).getData();
                if(null != technician){
                    AppUser technicianAppUser = appUserClient.getAppUserById(technician.getAppUserId());
                    if(null != technicianAppUser){
                        Integer lavePoint = technicianAppUser.getLavePoint();
                        if(js_point > 0){
                            PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                            int earnPoint1 = 0;
                            //计算可用积分比例
                            if(null != pointSetting && 1 == pointSetting.getPersonPointOpen()){
                                earnPoint1 = new BigDecimal(js_point).multiply(pointSetting.getPersonPoint().divide(new BigDecimal(100))).intValue();
                            }
            //添加积分明细
            if(hxmd_point > 0){
                UserPointCopy userPointCopy = new UserPointCopy();
                userPointCopy.setType(8);
                userPointCopy.setHistoricalPoint(lavePoint);
                userPointCopy.setVariablePoint(hxmd_point);
                userPointCopy.setBalance(shopAppUser.getLavePoint());
                userPointCopy.setCreateTime(LocalDateTime.now());
                userPointCopy.setAppUserId(shopAppUser.getId());
                userPointCopy.setObjectId(order.getId());
                userPointCopy.setExtention(order.getOrderNumber());
                userPointClient.saveUserPointCopy(userPointCopy);
                //变更等级
//                    appUserClient.vipUpgrade(shopAppUser.getId());
            }
            if(hxmd_point > 0){
                ShopPointCopy shopPointCopy = new ShopPointCopy();
                shopPointCopy.setShopId(shop.getId());
                shopPointCopy.setType(1);
                shopPointCopy.setHistoricalPoint(shopLavePoint);
                shopPointCopy.setVariablePoint(hxmd_point);
                shopPointCopy.setBalance(shop.getLavePoint());
                shopPointCopy.setCreateTime(LocalDateTime.now());
                shopPointCopy.setCreateUserId(order.getAppUserId());
                shopPointCopy.setObjectId(order.getId());
                shopPointCopy.setOrderNum(order.getOrderNumber());
                shopPointClient.saveShopPointCopy(shopPointCopy);
            }
        }
        //技师服务积分
        if(order.getOrderType() == 1){
            Technician technician = technicianClient.shopdetail(order.getTechnicianId()).getData();
            if(null == technician){
                log.error("技师查询失败");
            }
            if(null != technician){
                AppUser technicianAppUser = appUserClient.getAppUserById(technician.getAppUserId());
                if(null != technicianAppUser){
                    Integer lavePoint = technicianAppUser.getLavePoint();
                    if(js_point > 0){
                        PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
                        int earnPoint1 = 0;
                        //计算可用积分比例
                        if(null != pointSetting && 1 == pointSetting.getPersonPointOpen()){
                            earnPoint1 = new BigDecimal(js_point).multiply(pointSetting.getPersonPoint().divide(new BigDecimal(100))).intValue();
                        }
//                            technicianAppUser.setLavePoint(technicianAppUser.getLavePoint() + js_point);
//                            technicianAppUser.setAvailablePoint(technicianAppUser.getAvailablePoint() + earnPoint1);
//                            technicianAppUser.setTotalAvailablePoint(technicianAppUser.getTotalAvailablePoint() + earnPoint1);
@@ -767,46 +790,45 @@
//                            }
//                            technicianAppUser.setTotalPoint(technicianAppUser.getTotalPoint() + js_point);
//                            technicianAppUser.setTotalPerformancePoint(technicianAppUser.getTotalPerformancePoint() + js_point);
                            //添加临时分佣数据
                            AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                            appUserGiveawayTemporary.setOrderId(order.getId());
                            appUserGiveawayTemporary.setAppUserId(technicianAppUser.getId());
                            appUserGiveawayTemporary.setLavePoint(js_point);
                            appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                            appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                            if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){
                                appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                            }
                            appUserGiveawayTemporary.setTotalPoint(js_point);
                            appUserGiveawayTemporary.setTotalPerformancePoint(js_point);
                            appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                        }
//                        appUserClient.editAppUserById(technicianAppUser);
                        //添加积分明细
                        if(!technicianAppUser.getLavePoint().equals(lavePoint)){
                            UserPointCopy userPointCopy = new UserPointCopy();
                            userPointCopy.setType(10);
                            userPointCopy.setHistoricalPoint(lavePoint);
                            userPointCopy.setVariablePoint(js_point);
                            userPointCopy.setBalance(technicianAppUser.getLavePoint());
                            userPointCopy.setCreateTime(LocalDateTime.now());
                            userPointCopy.setAppUserId(technicianAppUser.getId());
                            userPointCopy.setObjectId(order.getId());
                            userPointCopy.setExtention(order.getOrderNumber());
                            userPointClient.saveUserPointCopy(userPointCopy);
                            //变更等级
//                            appUserClient.vipUpgrade(technicianAppUser.getId());
                        }
                    }
                    
                        //添加临时分佣数据
                        AppUserGiveawayTemporary appUserGiveawayTemporary = new AppUserGiveawayTemporary();
                        appUserGiveawayTemporary.setOrderId(order.getId());
                        appUserGiveawayTemporary.setAppUserId(technicianAppUser.getId());
                        appUserGiveawayTemporary.setLavePoint(js_point);
                        appUserGiveawayTemporary.setAvailablePoint(earnPoint1);
                        appUserGiveawayTemporary.setTotalAvailablePoint(earnPoint1);
                        if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){
                            appUserGiveawayTemporary.setTransferablePoint(earnPoint1);
                        }
                        appUserGiveawayTemporary.setTotalPoint(js_point);
                        appUserGiveawayTemporary.setTotalPerformancePoint(js_point);
                        appUserGiveawayTemporaryClient.saveAppUserGiveawayTemporary(appUserGiveawayTemporary);
                    }
//                        appUserClient.editAppUserById(technicianAppUser);
                    //添加积分明细
                    if(js_point > 0){
                        UserPointCopy userPointCopy = new UserPointCopy();
                        userPointCopy.setType(10);
                        userPointCopy.setHistoricalPoint(lavePoint);
                        userPointCopy.setVariablePoint(js_point);
                        userPointCopy.setBalance(technicianAppUser.getLavePoint());
                        userPointCopy.setCreateTime(LocalDateTime.now());
                        userPointCopy.setAppUserId(technicianAppUser.getId());
                        userPointCopy.setObjectId(order.getId());
                        userPointCopy.setExtention(order.getOrderNumber());
                        userPointClient.saveUserPointCopy(userPointCopy);
                        //变更等级
//                            appUserClient.vipUpgrade(technicianAppUser.getId());
                    }
                }
            }
            
            order.setIsCommission(2);
            orderService.updateById(order);
            }
        }
        order.setIsCommission(2);
        orderService.updateById(order);
    }
    
    
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -133,6 +133,10 @@
    @Resource
    private RegionClient regionClient;
    @Resource
    private AppUserGiveawayTemporaryClient appUserGiveawayTemporaryClient;
    @Resource
    private ShopGiveawayTemporaryClient shopGiveawayTemporaryClient;
    @Override
@@ -293,15 +297,14 @@
        JSONObject jsonObject = JSONObject.parseObject(content);
        Long days = jsonObject.getLong("days");
        order.setOrderStatus(OrderStatus.COMPLETED.getCode());
        order.setIsCommission(0);
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        order.setEndTime(LocalDateTime.now());
        order.setCancellerAppUserId(loginUserApplet.getUserid());
        if (StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)) {
            order.setTechnicianId(Integer.valueOf(technicianId));
        }
        // TODO
        orderMapper.updateById(order);
        commissionService.calculationCommissionShop(order.getId());
    }
@@ -456,6 +459,8 @@
            throw new RuntimeException("订单取消失败");
        }
        shopPointClient.deleteShopPointCopy(orderId, Arrays.asList(1,2,3));
        appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(orderId);
        shopGiveawayTemporaryClient.delShopGiveawayTemporary(orderId);
        return r;
    }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -1435,15 +1435,7 @@
            orderBalancePaymentService.save(orderBalancePayment);
        }
        
        //异步线程执行分佣临时数据构建
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), new ThreadPoolExecutor.DiscardPolicy());
        threadPoolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                commissionService.calculationCommissionUser();
                commissionService.calculationCommissionShop();
            }
        });
        commissionService.calculationCommissionUser(order.getId());
        return R.ok(order.getId().toString());
    }
@@ -1548,15 +1540,7 @@
            goodsClient.editGoodsNum(goodsId, 1);
        }
        
        //异步线程执行分佣临时数据构建
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), new ThreadPoolExecutor.DiscardPolicy());
        threadPoolExecutor.execute(new Runnable() {
            @Override
            public void run() {
                commissionService.calculationCommissionUser();
                commissionService.calculationCommissionShop();
            }
        });
        commissionService.calculationCommissionUser(order.getId());
        return R.ok();
    }
    
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/TaskUtil.java
@@ -30,7 +30,7 @@
    @Scheduled(fixedRate = 60000)
    public void taskMonth() {
        commissionService.calculationCommission(); //2.18版本修改为下单后计算返佣金额
        commissionService.calculationCommission();
        shoppingCartService.closeOrder();
        orderService.taskExpress();
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -869,10 +869,10 @@
     * @return
     */
    @GetMapping("/getServiceProvider")
    public R<Shop> getServiceProvider(Long userId){
    public R<Shop> getServiceProvider(@RequestParam("appUserId") Long appUserId){
        //向上找获取第一个开店的门店
        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
        AppUser appUser = appUserClient.getAppUserById(userId);
        AppUser appUser = appUserClient.getAppUserById(appUserId);
        //上级集合,防止循环关联
        Set<Long> pid = new HashSet<>();
        Shop shop = getSuperiorStore(appUser, list, 1, 1, pid);
@@ -913,10 +913,10 @@
     * @return
     */
    @GetMapping("/getSuperiorServiceProvider")
    public R<Shop> getSuperiorServiceProvider(Long userId){
    public R<Shop> getSuperiorServiceProvider(@RequestParam("appUserId") Long appUserId){
        //向上找获取第一个开店的门店
        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
        AppUser appUser = appUserClient.getAppUserById(userId);
        AppUser appUser = appUserClient.getAppUserById(appUserId);
        //上级集合,防止循环关联
        Set<Long> pid = new HashSet<>();
        Shop shop = getSuperiorStore(appUser, list, 2, 1, pid);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopGiveawayTemporaryController.java
@@ -42,4 +42,15 @@
        List<ShopGiveawayTemporary> list = shopGiveawayTemporaryService.list(new LambdaQueryWrapper<ShopGiveawayTemporary>().eq(ShopGiveawayTemporary::getOrderId, orderId));
        return R.ok(list);
    }
    /**
     * 删除订单相关门店分佣临时数据
     * @param orderId
     */
    @PostMapping("/delShopGiveawayTemporary")
    public R delShopGiveawayTemporary(@RequestParam("orderId") Long orderId){
        shopGiveawayTemporaryService.remove(new LambdaQueryWrapper<ShopGiveawayTemporary>().eq(ShopGiveawayTemporary::getOrderId, orderId));
        return R.ok();
    }
}