Commit 765a005c authored by shiyu's avatar shiyu

介绍记录改为全局

parent e5863dea
...@@ -338,54 +338,6 @@ public class GroupPurchaseServiceImpl implements GroupPurchaseService { ...@@ -338,54 +338,6 @@ public class GroupPurchaseServiceImpl implements GroupPurchaseService {
return Result.failed("支付尾款失败"); return Result.failed("支付尾款失败");
}*/ }*/
@Transactional
public Result calculateProfit(GroupPurchaseRecordRequestDto dto) {
try {
String distributionOrderId = dto.getDistributionOrderId();
DistributionOrder distributionOrder = distributionOrderDao.findById(distributionOrderId);
long itemId = distributionOrder.getItemId();
GroupPurchaseConfig groupPurchaseConfig = groupPurchaseConfigDao.findByItemId(itemId);
//计算账单
DistributorProfit distributorProfit = new DistributorProfit();
//查询介绍佣金比例
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(distributionOrder.getSellerId());
followFansRecordRequestDto.setFansId(distributionOrder.getBuyerId());
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
double introduceCost = distributionOrder.getAmount().doubleValue() * rebate;
//实际订单到账金额
double realAmount = distributionOrder.getAmount().doubleValue() * (1 - CommConsts.WX_COMMISSION_REBATE);
//拍卖的平台佣金= 订单金额 - 藏家供货价 - 介绍佣金
double channelServiceCost = distributionOrder.getAmount().doubleValue() - groupPurchaseConfig.getSupplyPrice() - introduceCost;
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
distributorProfit.setDistributionOrderId(distributionOrderId);
distributorProfit.setDistributorId(distributionOrder.getSellerId());
distributorProfit.setItemId(distributionOrder.getItemId());
distributorProfit.setItemNum(distributionOrder.getItemNum());
distributorProfit.setAmount(distributionOrder.getAmount());
distributorProfit.setRealAmount(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(realAmount)));
distributorProfit.setItemCost(groupPurchaseConfig.getSupplyPrice());
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
//团购订单,藏家的利润就是商品设置的供货价
distributorProfit.setProfit(groupPurchaseConfig.getSupplyPrice());
distributorProfit.setCreateTime(new Date());
distributorProfit.setType(DistributionEnum.DistributionTypeEnum.GROUP_PURCHASE.getCode());
distributorProfit.setIsValid(true);
distributorProfitDao.insert(distributorProfit);
} catch(Exception e){
logger.error("团购订单创建失败 error : {}", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return Result.failed("团购订单账单计算失败");
}
@Override @Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment