Commit 7a3134eb authored by shiyu's avatar shiyu

拍卖订单,利润计算逻辑修改,原来的分销计算利润废弃,改为介绍费和平台服务费扣除,剩余的为卖家利润

parent 1484c1ff
......@@ -267,22 +267,46 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
map.put("prepayId", null);
//计算分销商的利润
DistributorProfit distributorProfit = new DistributorProfit();
//利润,该记录在用户未付款时未无效,仅用于在分销商查看订单详情时,计算预计利润
Double profit = distributionOrder.getAmount().doubleValue() * 0.03;
//平台服务费,默认15%
CollectorWhiteList collectorWhiteList = collectorWhiteListDao.findById(auctionConfig.getCreatorId());
double channelCostRebate = 0.15;
if (collectorWhiteList != null) {
BigDecimal channelCost = collectorWhiteList.getChannelCostRebate();
channelCost = PriceUtil.convertToDivide(channelCost);
channelCostRebate = channelCost.doubleValue();
}
logger.info("藏家id:{} 生成新拍卖订单,平台服务费比例:{}", auctionConfig.getCreatorId(), channelCostRebate);
double channelServiceCost = distributionOrder.getAmount().doubleValue() * channelCostRebate;
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
//查询该用户和藏家的介绍人
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(auctionConfig.getCreatorId());
followFansRecordRequestDto.setFansId(auctionRecord.getUserId());
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
double introduceCost = distributionOrder.getAmount().doubleValue() * rebate;
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.setItemCost(auctionConfig.getStartPrice());
distributorProfit.setProfit((long) Math.floor(profit));
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
long profit = distributionOrder.getAmount() - distributorProfit.getChannelCost() - distributorProfit.getIntroduceCost();
distributorProfit.setProfit(profit);
distributorProfit.setCreateTime(new Date());
distributorProfit.setType(DistributionEnum.DistributionTypeEnum.AUCTION.getCode());
distributorProfit.setIsValid(false);
distributorProfitDao.insert(distributorProfit);
SupplierItem supplierItem = supplierItemDao.findById(dto.getItemId());
//查询参与出价的所有用户所对应的分销商,可以分成交额的3%的利润
//查询参与出价的所有用户所对应的分销商,可以分成交额的3%的利润
List<AuctionRecord> auctionRecordList = auctionRecordDao.findByItemId(dto.getItemId());
List<AuctionRecord> filterRecordList = auctionRecordList.stream()
.filter(StringUtil.distinctByKey(AuctionRecord::getDistributorId))
......@@ -317,13 +341,13 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
Result result = sendMsgService.auctionSuccessForDistributorsMsg(auctionOfferNoticeMsg);
if (!result.getSuccess()) {
String url = wxAppletApi.getUrlLink(AUCTION_MSG_URL, "itemId=" + supplierItem.getId() + "&shareRecordId=");
String msg = "您分的拍品" + supplierItem.getName() + "已成拍,成交价是" + PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()) +
String msg = "您分的拍品" + supplierItem.getName() + "已成拍,成交价是" + PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()) +
"元,您预计获得利润" + PriceUtil.convertDoubleToString(Math.floor(averageProfit)) + "元。请前往"+ url + "查看";
aliSmsSender.sendSms(record.getDistributorId(), msg);
}
} else {
String url = wxAppletApi.getUrlLink(AUCTION_MSG_URL,"itemId=" + supplierItem.getId() + "&shareRecordId=");
String msg = "您分的拍品" + supplierItem.getName() + "已成拍,成交价是" + PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()) +
String msg = "您分的拍品" + supplierItem.getName() + "已成拍,成交价是" + PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()) +
"元,您预计获得利润" + PriceUtil.convertDoubleToString(Math.floor(averageProfit)) + "元。请前往"+ url + "查看";
aliSmsSender.sendSms(record.getDistributorId(), msg);
}
......
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