From 199861555473ab50f2fafa3d58e42e64e838c039 Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期一, 24 二月 2025 22:47:18 +0800 Subject: [PATCH] 修改物流信息导入模板 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java | 567 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 418 insertions(+), 149 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java index ef55d38..88e630a 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java @@ -1,12 +1,8 @@ package com.ruoyi.order.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.ruoyi.account.api.feignClient.AppUserClient; -import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient; -import com.ruoyi.account.api.feignClient.UserPointClient; -import com.ruoyi.account.api.model.AppUser; -import com.ruoyi.account.api.model.BalanceChangeRecord; -import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.account.api.feignClient.*; +import com.ruoyi.account.api.model.*; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.order.service.CommissionService; @@ -16,6 +12,7 @@ import com.ruoyi.other.api.feignClient.*; import com.ruoyi.order.model.Order; import com.ruoyi.order.model.OrderGood; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -30,6 +27,7 @@ import java.util.stream.Collectors; @Service +@Slf4j public class CommissionServiceImpl implements CommissionService { @Resource private OrderService orderService; @@ -58,19 +56,19 @@ @Transactional(rollbackFor = Exception.class) public void calculationCommission() { List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getIsCommission, 0).isNotNull(Order::getAfterSaleTime) - .eq(Order::getDelFlag, 0).last(" and after_sale_time <= now()")); + .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){ return; } - + for (Order order : list) { - if(order.getPayMethod() == 3){ - continue; - } List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() .eq(OrderGood::getOrderId, order.getId())); AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); + if(null == appUser){ + continue; + } //直推上级分佣金额 BigDecimal ztsj_price = BigDecimal.ZERO; //直帮上级分佣金额 @@ -124,7 +122,7 @@ } } } - + //核销门店获取服务费 hxmd_price = hxmd_price.add(orderGood.getServuceShopCharges()); //核销门店可获得积分 @@ -143,60 +141,65 @@ bdmdsj_point += orderGood.getBoundShopSuperiorsPoints(); } //直推上级 - AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId()); - if(null != inviteUser){ - BigDecimal balance = inviteUser.getBalance(); - Integer lavePoint = inviteUser.getLavePoint(); - if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){ - inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); - inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); - inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); - } - if(ztsj_point > 0){ - PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); - int earnPoint1 = 0; - //计算可用积分比例 - if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){ - earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue(); + if(null != appUser.getInviteUserId()){ + AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId()); + if(null != inviteUser){ + BigDecimal balance = inviteUser.getBalance(); + Integer lavePoint = inviteUser.getLavePoint(); + if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){ + inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); + inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); + inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); } - inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point); - inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point); - inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1); - if(null != pointSetting && 1 == pointSetting.getSharePointGift()){ - inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1); + if(ztsj_point > 0){ + PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); + int earnPoint1 = 0; + //计算可用积分比例 + if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){ + earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue(); + } + inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point); + inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point); + inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1); + inviteUser.setTotalAvailablePoint(inviteUser.getTotalAvailablePoint() + earnPoint1); + if(null != pointSetting && 1 == pointSetting.getSharePointGift()){ + inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1); + } + inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point); } - inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point); - } - appUserClient.editAppUserById(inviteUser); - //添加明细记录 - if(!inviteUser.getBalance().equals(balance)){ - BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); - balanceChangeRecord.setAppUserId(inviteUser.getId()); - balanceChangeRecord.setOrderId(order.getId()); - balanceChangeRecord.setChangeType(4); - balanceChangeRecord.setBeforeAmount(balance); - balanceChangeRecord.setChangeAmount(ztsj_price); - balanceChangeRecord.setAfterAmount(inviteUser.getBalance()); - balanceChangeRecord.setDelFlag(0); - balanceChangeRecord.setCreateTime(LocalDateTime.now()); - balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); - } - //添加积分明细 - if(!inviteUser.getLavePoint().equals(lavePoint)){ - UserPoint userPoint = new UserPoint(); - userPoint.setType(2); - userPoint.setHistoricalPoint(lavePoint); - userPoint.setVariablePoint(ztsj_point); - userPoint.setBalance(inviteUser.getLavePoint()); - userPoint.setCreateTime(LocalDateTime.now()); - userPoint.setAppUserId(inviteUser.getId()); - userPoint.setObjectId(order.getId()); - userPoint.setExtention(order.getOrderNumber()); - userPointClient.saveUserPoint(userPoint); - //变更等级 - appUserClient.vipUpgrade(inviteUser.getId()); + appUserClient.editAppUserById(inviteUser); + //添加明细记录 + if(!inviteUser.getBalance().equals(balance)){ + BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); + balanceChangeRecord.setAppUserId(inviteUser.getId()); + balanceChangeRecord.setVipId(inviteUser.getVipId()); + balanceChangeRecord.setOrderId(order.getId()); + balanceChangeRecord.setChangeType(4); + balanceChangeRecord.setBeforeAmount(balance); + balanceChangeRecord.setChangeAmount(ztsj_price); + balanceChangeRecord.setAfterAmount(inviteUser.getBalance()); + balanceChangeRecord.setDelFlag(0); + balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); + } + //添加积分明细 + if(!inviteUser.getLavePoint().equals(lavePoint)){ + UserPoint userPoint = new UserPoint(); + userPoint.setType(2); + userPoint.setHistoricalPoint(lavePoint); + userPoint.setVariablePoint(ztsj_point); + userPoint.setBalance(inviteUser.getLavePoint()); + userPoint.setCreateTime(LocalDateTime.now()); + userPoint.setAppUserId(inviteUser.getId()); + userPoint.setObjectId(order.getId()); + userPoint.setExtention(order.getOrderNumber()); + userPointClient.saveUserPoint(userPoint); + //变更等级 + appUserClient.vipUpgrade(inviteUser.getId()); + } } } + //直帮上级 AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData(); if(null != superiorLeader){ @@ -217,6 +220,7 @@ superiorLeader.setSharePoint(superiorLeader.getSharePoint() + zbsj_point); superiorLeader.setLavePoint(superiorLeader.getLavePoint() + zbsj_point); superiorLeader.setAvailablePoint(superiorLeader.getAvailablePoint() + earnPoint1); + superiorLeader.setTotalAvailablePoint(superiorLeader.getTotalAvailablePoint() + earnPoint1); if(null != pointSetting && 1 == pointSetting.getSharePointGift()){ superiorLeader.setTransferablePoint(superiorLeader.getTransferablePoint() + earnPoint1); } @@ -227,6 +231,7 @@ if(!superiorLeader.getBalance().equals(balance)){ BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); balanceChangeRecord.setAppUserId(superiorLeader.getId()); + balanceChangeRecord.setVipId(superiorLeader.getVipId()); balanceChangeRecord.setOrderId(order.getId()); balanceChangeRecord.setChangeType(4); balanceChangeRecord.setBeforeAmount(balance); @@ -252,12 +257,11 @@ appUserClient.vipUpgrade(superiorLeader.getId()); } } - + //核销门店 Shop shop = shopClient.getShopById(order.getShopId()).getData(); AppUser shopAppUser = appUserClient.getAppUserById(shop.getAppUserId()); if(null != shopAppUser){ - BigDecimal balance = shopAppUser.getBalance(); BigDecimal shopBalance = shop.getBalance(); Integer lavePoint = shopAppUser.getLavePoint(); Integer shopLavePoint = shop.getLavePoint(); @@ -277,6 +281,7 @@ } shopAppUser.setLavePoint(shopAppUser.getLavePoint() + hxmd_point); shopAppUser.setAvailablePoint(shopAppUser.getAvailablePoint() + earnPoint1); + shopAppUser.setTotalAvailablePoint(shopAppUser.getTotalAvailablePoint() + earnPoint1); if(null != pointSetting && 1 == pointSetting.getShopPointGift()){ shopAppUser.setTransferablePoint(shopAppUser.getTransferablePoint() + earnPoint1); } @@ -290,19 +295,6 @@ appUserClient.editAppUserById(shopAppUser); shopClient.updateShop(shop); //添加明细记录 - if(!shopAppUser.getBalance().equals(balance)){ - BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); - balanceChangeRecord.setAppUserId(shopAppUser.getId()); - balanceChangeRecord.setOrderId(order.getId()); - balanceChangeRecord.setChangeType(4); - balanceChangeRecord.setBeforeAmount(balance); - balanceChangeRecord.setChangeAmount(hxmd_price); - balanceChangeRecord.setAfterAmount(shopAppUser.getBalance()); - balanceChangeRecord.setDelFlag(0); - balanceChangeRecord.setCreateTime(LocalDateTime.now()); - balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); - } - if(!shop.getBalance().equals(shopBalance)){ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop.getId()); @@ -319,7 +311,7 @@ //添加积分明细 if(!shopAppUser.getLavePoint().equals(lavePoint)){ UserPoint userPoint = new UserPoint(); - userPoint.setType(9); + userPoint.setType(8); userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(hxmd_point); userPoint.setBalance(shopAppUser.getLavePoint()); @@ -331,11 +323,11 @@ //变更等级 appUserClient.vipUpgrade(shopAppUser.getId()); } - + if(!shop.getLavePoint().equals(shopLavePoint)){ ShopPoint shopPoint = new ShopPoint(); shopPoint.setShopId(shop.getId()); - shopPoint.setType(4); + shopPoint.setType(1); shopPoint.setHistoricalPoint(shopLavePoint); shopPoint.setVariablePoint(hxmd_point); shopPoint.setBalance(shop.getLavePoint()); @@ -346,53 +338,56 @@ shopPointClient.saveShopPoint(shopPoint); } } - + //技师服务积分 if(order.getOrderType() == 1){ Technician technician = technicianClient.shopdetail(order.getTechnicianId()).getData(); if(null != technician){ AppUser technicianAppUser = appUserClient.getAppUserById(technician.getAppUserId()); - 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(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); + if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){ + technicianAppUser.setTransferablePoint(technicianAppUser.getTransferablePoint() + earnPoint1); + } + technicianAppUser.setTotalPoint(technicianAppUser.getTotalPoint() + js_point); + technicianAppUser.setTotalPerformancePoint(technicianAppUser.getTotalPerformancePoint() + js_point); } - technicianAppUser.setLavePoint(technicianAppUser.getLavePoint() + js_point); - technicianAppUser.setAvailablePoint(technicianAppUser.getAvailablePoint() + earnPoint1); - if(null != pointSetting && 1 == pointSetting.getPersonPointGift()){ - technicianAppUser.setTransferablePoint(technicianAppUser.getTransferablePoint() + earnPoint1); + appUserClient.editAppUserById(technicianAppUser); + //添加积分明细 + if(!technicianAppUser.getLavePoint().equals(lavePoint)){ + UserPoint userPoint = new UserPoint(); + userPoint.setType(10); + userPoint.setHistoricalPoint(lavePoint); + userPoint.setVariablePoint(js_point); + userPoint.setBalance(technicianAppUser.getLavePoint()); + userPoint.setCreateTime(LocalDateTime.now()); + userPoint.setAppUserId(technicianAppUser.getId()); + userPoint.setObjectId(order.getId()); + userPoint.setExtention(order.getOrderNumber()); + userPointClient.saveUserPoint(userPoint); + //变更等级 + appUserClient.vipUpgrade(technicianAppUser.getId()); } - technicianAppUser.setTotalPoint(technicianAppUser.getTotalPoint() + js_point); - technicianAppUser.setTotalPerformancePoint(technicianAppUser.getTotalPerformancePoint() + js_point); } - appUserClient.editAppUserById(technicianAppUser); - //添加积分明细 - if(!technicianAppUser.getLavePoint().equals(lavePoint)){ - UserPoint userPoint = new UserPoint(); - userPoint.setType(10); - userPoint.setHistoricalPoint(lavePoint); - userPoint.setVariablePoint(js_point); - userPoint.setBalance(technicianAppUser.getLavePoint()); - userPoint.setCreateTime(LocalDateTime.now()); - userPoint.setAppUserId(technicianAppUser.getId()); - userPoint.setObjectId(order.getId()); - userPoint.setExtention(order.getOrderNumber()); - userPointClient.saveUserPoint(userPoint); - //变更等级 - appUserClient.vipUpgrade(technicianAppUser.getId()); - } + } } - - //绑定门店分佣 - Shop shop1 = shopClient.getShopById(appUser.getShopId()).getData(); + + //服务商分佣 + Shop shop1 = shopClient.getServiceProvider(appUser.getId()).getData(); if(null != shop1){ AppUser bdShopAppUser = appUserClient.getAppUserById(shop1.getAppUserId()); if(null != bdShopAppUser){ - BigDecimal balance = bdShopAppUser.getBalance(); BigDecimal shopBalance = shop1.getBalance(); Integer lavePoint = bdShopAppUser.getLavePoint(); Integer shopLavePoint = shop1.getLavePoint(); @@ -412,6 +407,7 @@ } bdShopAppUser.setLavePoint(bdShopAppUser.getLavePoint() + bdmd_point); bdShopAppUser.setAvailablePoint(bdShopAppUser.getAvailablePoint() + earnPoint1); + bdShopAppUser.setTotalAvailablePoint(bdShopAppUser.getTotalAvailablePoint() + earnPoint1); if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ bdShopAppUser.setTransferablePoint(bdShopAppUser.getTransferablePoint() + earnPoint1); } @@ -425,23 +421,10 @@ appUserClient.editAppUserById(bdShopAppUser); shopClient.updateShop(shop1); //添加明细记录 - if(!bdShopAppUser.getBalance().equals(balance)){ - BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); - balanceChangeRecord.setAppUserId(bdShopAppUser.getId()); - balanceChangeRecord.setOrderId(order.getId()); - balanceChangeRecord.setChangeType(4); - balanceChangeRecord.setBeforeAmount(balance); - balanceChangeRecord.setChangeAmount(bdmd_price); - balanceChangeRecord.setAfterAmount(bdShopAppUser.getBalance()); - balanceChangeRecord.setDelFlag(0); - balanceChangeRecord.setCreateTime(LocalDateTime.now()); - balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); - } - if(!shop1.getBalance().equals(shopBalance)){ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop1.getId()); - shopBalanceStatement.setType(4); + shopBalanceStatement.setType(1); shopBalanceStatement.setHistoricalBalance(shopBalance); shopBalanceStatement.setVariableAmount(bdmd_price); shopBalanceStatement.setBalance(shop1.getBalance()); @@ -466,7 +449,7 @@ //变更等级 appUserClient.vipUpgrade(bdShopAppUser.getId()); } - + if(!shop1.getLavePoint().equals(shopLavePoint)){ ShopPoint shopPoint = new ShopPoint(); shopPoint.setShopId(shop1.getId()); @@ -482,14 +465,12 @@ } } } - - //上级门店分佣 - Integer pid = shop1.getPid(); - Shop shop2 = shopClient.getShopById(pid).getData(); + + //高级服务商 + Shop shop2 = shopClient.getSuperiorServiceProvider(order.getAppUserId()).getData(); if(null != shop2){ AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); if(null != sjShopAppUser){ - BigDecimal balance = sjShopAppUser.getBalance(); BigDecimal shopBalance = shop2.getBalance(); Integer lavePoint = sjShopAppUser.getLavePoint(); Integer shopLavePoint = shop2.getLavePoint(); @@ -509,6 +490,7 @@ } sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); + sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); } @@ -522,19 +504,6 @@ appUserClient.editAppUserById(sjShopAppUser); shopClient.updateShop(shop2); //添加明细记录 - if(!sjShopAppUser.getBalance().equals(balance)){ - BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); - balanceChangeRecord.setAppUserId(sjShopAppUser.getId()); - balanceChangeRecord.setOrderId(order.getId()); - balanceChangeRecord.setChangeType(4); - balanceChangeRecord.setBeforeAmount(balance); - balanceChangeRecord.setChangeAmount(bdmdsj_price); - balanceChangeRecord.setAfterAmount(sjShopAppUser.getBalance()); - balanceChangeRecord.setDelFlag(0); - balanceChangeRecord.setCreateTime(LocalDateTime.now()); - balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); - } - if(!shop2.getBalance().equals(shopBalance)){ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop2.getId()); @@ -563,7 +532,7 @@ //变更等级 appUserClient.vipUpgrade(sjShopAppUser.getId()); } - + if(!shop2.getLavePoint().equals(shopLavePoint)){ ShopPoint shopPoint = new ShopPoint(); shopPoint.setShopId(shop2.getId()); @@ -579,11 +548,311 @@ } } } + order.setIsCommission(1); orderService.updateById(order); } - + } + public void calculationCommissionCopy(Order order){ + List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() + .eq(OrderGood::getOrderId, order.getId())); + AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); + //直推上级分佣金额 + BigDecimal ztsj_price = BigDecimal.ZERO; + //直帮上级分佣金额 + BigDecimal zbsj_price = BigDecimal.ZERO; + //直推上级分佣积分 + Integer ztsj_point = 0; + //直帮上级分佣积分 + Integer zbsj_point = 0; + //核销门店分佣金额 + BigDecimal hxmd_price = BigDecimal.ZERO; + //核销门店分佣积分 + Integer hxmd_point = 0; + //技师分佣积分 + Integer js_point = 0; + //绑定门店分佣金额 + BigDecimal bdmd_price = BigDecimal.ZERO; + //绑定门店分佣积分 + Integer bdmd_point = 0; + //绑定门店上级门店分佣金额 + BigDecimal bdmdsj_price = BigDecimal.ZERO; + //绑定门店上级门店分佣积分 + Integer bdmdsj_point = 0; + for (OrderGood orderGood : orderGoods) { + //上级获得分佣金额(直推上级|直帮上级) + BigDecimal superiorSubcommission = orderGood.getSuperiorSubcommission(); + //上级获得分佣积分(直推上级|直帮上级) + Integer superiorRebatePoints = orderGood.getSuperiorRebatePoints(); + if(StringUtils.isNotEmpty(orderGood.getSuperiorPriceType())){ + String[] split = orderGood.getSuperiorPriceType().split(","); + for (String s : split) { + //直推上级 + if("1".equals(s)){ + ztsj_price = ztsj_price.add(superiorSubcommission); + } + //直帮上级 + if("2".equals(s)){ + zbsj_price = zbsj_price.add(superiorSubcommission); + } + } + } + if(StringUtils.isNotEmpty(orderGood.getSuperiorType())){ + String[] split = orderGood.getSuperiorType().split(","); + for (String s : split) { + //直推上级 + if("1".equals(s)){ + ztsj_point += superiorRebatePoints; + } + //直帮上级 + if("2".equals(s)){ + zbsj_point += superiorRebatePoints; + } + } + } + //核销门店获取服务费 + hxmd_price = hxmd_price.add(orderGood.getServuceShopCharges()); + //核销门店可获得积分 + hxmd_point += orderGood.getServuceShopPoints(); + //技师分佣金额 + if(order.getOrderType() == 1){ + js_point += orderGood.getTechnicianPoints(); + } + //绑定门店分佣金额 + bdmd_price = bdmd_price.add(orderGood.getBoundShopCharges()); + //绑定门店分佣积分 + bdmd_point += orderGood.getBoundShopPoints(); + //绑定门店上级门店分佣金额 + bdmdsj_price = bdmdsj_price.add(orderGood.getBoundShopSuperiorsCharges()); + //绑定门店上级门店分佣积分 + bdmdsj_point += orderGood.getBoundShopSuperiorsPoints(); + } + //直推上级 +// if(null != appUser.getInviteUserId()){ +// AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId()); +// if(null != inviteUser){ +// BigDecimal balance = inviteUser.getBalance(); +// Integer lavePoint = inviteUser.getLavePoint(); +// //添加明细记录 +// if(!inviteUser.getBalance().equals(balance)){ +// BalanceChangeRecordCopy balanceChangeRecordCopy = new BalanceChangeRecordCopy(); +// balanceChangeRecordCopy.setAppUserId(inviteUser.getId()); +// balanceChangeRecordCopy.setVipId(inviteUser.getVipId()); +// balanceChangeRecordCopy.setOrderId(order.getId()); +// balanceChangeRecordCopy.setChangeType(4); +// balanceChangeRecordCopy.setBeforeAmount(balance); +// balanceChangeRecordCopy.setChangeAmount(ztsj_price); +// balanceChangeRecordCopy.setAfterAmount(inviteUser.getBalance()); +// balanceChangeRecordCopy.setDelFlag(0); +// balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); +// balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecordCopy); +// } +// //添加积分明细 +// if(!inviteUser.getLavePoint().equals(lavePoint)){ +// +// UserPointCopy userPointCopy = new UserPointCopy(); +// userPointCopy.setType(2); +// userPointCopy.setHistoricalPoint(lavePoint); +// userPointCopy.setVariablePoint(ztsj_point); +// userPointCopy.setBalance(inviteUser.getLavePoint()); +// userPointCopy.setCreateTime(LocalDateTime.now()); +// userPointCopy.setAppUserId(inviteUser.getId()); +// userPointCopy.setObjectId(order.getId()); +// userPointCopy.setExtention(order.getOrderNumber()); +// userPointClient.saveUserPoint(userPointCopy); +// } +// } +// } + + //指导老师 + AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData(); + if(null != superiorLeader){ + log.info("指导老师:{}",superiorLeader); + BigDecimal balance = superiorLeader.getBalance(); + Integer lavePoint = superiorLeader.getLavePoint(); + //添加明细记录 + BalanceChangeRecordCopy balanceChangeRecord = new BalanceChangeRecordCopy(); + balanceChangeRecord.setAppUserId(superiorLeader.getId()); + balanceChangeRecord.setVipId(superiorLeader.getVipId()); + balanceChangeRecord.setOrderId(order.getId()); + balanceChangeRecord.setChangeType(4); + balanceChangeRecord.setBeforeAmount(balance); + balanceChangeRecord.setChangeAmount(zbsj_price); + balanceChangeRecord.setAfterAmount(superiorLeader.getBalance()); + balanceChangeRecord.setDelFlag(0); + balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); + //添加积分明细 + UserPointCopy userPointCopy = new UserPointCopy(); + userPointCopy.setType(2); + userPointCopy.setHistoricalPoint(lavePoint); + userPointCopy.setVariablePoint(zbsj_point); + userPointCopy.setBalance(superiorLeader.getLavePoint()); + userPointCopy.setCreateTime(LocalDateTime.now()); + userPointCopy.setAppUserId(superiorLeader.getId()); + userPointCopy.setObjectId(order.getId()); + userPointCopy.setExtention(order.getOrderNumber()); + userPointClient.saveUserPoint(userPointCopy); + } + + //核销门店 + 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(); + //添加明细记录 + 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.saveShopBalanceStatement(shopBalanceStatementCopy); + //添加积分明细 + 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.saveUserPoint(userPointCopy); + 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.saveShopPoint(shopPointCopy); + } + + //技师服务积分 + 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(); + //添加积分明细 + 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.saveUserPoint(userPointCopy); + } + + } + } + + //服务商分佣 + 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(); + //添加明细记录 + ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy(); + shopBalanceStatementCopy.setShopId(shop1.getId()); + shopBalanceStatementCopy.setType(1); + shopBalanceStatementCopy.setHistoricalBalance(shopBalance); + shopBalanceStatementCopy.setVariableAmount(bdmd_price); + shopBalanceStatementCopy.setBalance(shop1.getBalance()); + shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); + shopBalanceStatementCopy.setCreateUserId(order.getAppUserId()); + shopBalanceStatementCopy.setObjectId(order.getId()); + shopBalanceStatementCopy.setExtension(order.getOrderNumber()); + shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatementCopy); + //添加积分明细 + UserPointCopy userPointCopy = new UserPointCopy(); + userPointCopy.setType(9); + userPointCopy.setHistoricalPoint(lavePoint); + userPointCopy.setVariablePoint(bdmd_point); + userPointCopy.setBalance(bdShopAppUser.getLavePoint()); + userPointCopy.setCreateTime(LocalDateTime.now()); + userPointCopy.setAppUserId(bdShopAppUser.getId()); + userPointCopy.setObjectId(order.getId()); + userPointCopy.setExtention(order.getOrderNumber()); + userPointClient.saveUserPoint(userPointCopy); + + ShopPointCopy shopPointCopy = new ShopPointCopy(); + shopPointCopy.setShopId(shop1.getId()); + shopPointCopy.setType(2); + shopPointCopy.setHistoricalPoint(shopLavePoint); + shopPointCopy.setVariablePoint(bdmd_point); + shopPointCopy.setBalance(shop1.getLavePoint()); + shopPointCopy.setCreateTime(LocalDateTime.now()); + shopPointCopy.setCreateUserId(order.getAppUserId()); + shopPointCopy.setObjectId(order.getId()); + shopPointCopy.setOrderNum(order.getOrderNumber()); + shopPointClient.saveShopPoint(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(); + //添加明细记录 + ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy(); + shopBalanceStatementCopy.setShopId(shop2.getId()); + shopBalanceStatementCopy.setType(2); + shopBalanceStatementCopy.setHistoricalBalance(shopBalance); + shopBalanceStatementCopy.setVariableAmount(bdmdsj_price); + shopBalanceStatementCopy.setBalance(shop2.getBalance()); + shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); + shopBalanceStatementCopy.setCreateUserId(order.getAppUserId()); + shopBalanceStatementCopy.setObjectId(order.getId()); + shopBalanceStatementCopy.setExtension(order.getOrderNumber()); + shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatementCopy); + //添加积分明细 + UserPointCopy userPointCopy = new UserPointCopy(); + userPointCopy.setType(14); + userPointCopy.setHistoricalPoint(lavePoint); + userPointCopy.setVariablePoint(bdmdsj_point); + userPointCopy.setBalance(sjShopAppUser.getLavePoint()); + userPointCopy.setCreateTime(LocalDateTime.now()); + userPointCopy.setAppUserId(sjShopAppUser.getId()); + userPointCopy.setObjectId(order.getId()); + userPointCopy.setExtention(order.getOrderNumber()); + userPointClient.saveUserPoint(userPointCopy); + + ShopPointCopy shopPointCopy = new ShopPointCopy(); + shopPointCopy.setShopId(shop2.getId()); + shopPointCopy.setType(3); + shopPointCopy.setHistoricalPoint(shopLavePoint); + shopPointCopy.setVariablePoint(bdmdsj_point); + shopPointCopy.setBalance(shop2.getLavePoint()); + shopPointCopy.setCreateTime(LocalDateTime.now()); + shopPointCopy.setCreateUserId(order.getAppUserId()); + shopPointCopy.setObjectId(order.getId()); + shopPointCopy.setOrderNum(order.getOrderNumber()); + shopPointClient.saveShopPoint(shopPointCopy); + } + } } } -- Gitblit v1.7.1