|
@@ -340,8 +340,8 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
if (ObjectUtils.isNotNull(bo.getPretaxBrokerage()) && ObjectUtils.isNotNull(bo.getPretax())){
|
|
|
BigDecimal multiply = bo.getPretaxBrokerage().multiply(bo.getPretax());
|
|
|
//总佣金
|
|
|
- brokerage = bo.getPretaxBrokerage().subtract(multiply);
|
|
|
- add.setBrokerage(brokerage);
|
|
|
+ brokerage = bo.getPretaxBrokerage();
|
|
|
+ add.setBrokerage( bo.getPretaxBrokerage().subtract(multiply));
|
|
|
}
|
|
|
// 获取企业默认成本模板
|
|
|
TopCostTp costTp = topCostTpService.getOne(new LambdaQueryWrapper<TopCostTp>()
|
|
@@ -385,7 +385,6 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
}
|
|
|
//换算订单成本和盈亏
|
|
|
BigDecimal cost = new BigDecimal("0.00");//成本
|
|
|
- BigDecimal profit = new BigDecimal("0.00"); //盈亏
|
|
|
BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
TopCostTpItem topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
if (topCostTpItem.getDockStatus() == 1){
|
|
@@ -393,8 +392,8 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
switch (topCostTpItem.getDockType()){
|
|
|
case 1://百分比
|
|
|
//成本扣除金额
|
|
|
- BigDecimal divide = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
- BigDecimal multiply = goodsPrice.multiply(divide);
|
|
|
+ BigDecimal divide1 = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
+ BigDecimal multiply = goodsPrice.multiply(divide1);
|
|
|
goodsPrice = goodsPrice.subtract(multiply);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
@@ -403,25 +402,21 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
switch (topCostTpItem.getItemType()) {
|
|
|
case 1://百分比
|
|
|
BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
cost = goodsPrice.multiply(divide);
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
|
cost = topCostTpItem.getTypeValue();
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
costTotal = costTotal.add(cost);
|
|
|
- profitTotal = profitTotal.add(profit);
|
|
|
}
|
|
|
+ profitTotal = bo.getOrderPrice().subtract(costTotal);
|
|
|
List<TopCostTpItem> costTpItemList = topCostTpItemService
|
|
|
.list(new LambdaQueryWrapper<TopCostTpItem>()
|
|
|
.eq(TopCostTpItem::getTpId, costTp.getTpId())
|
|
@@ -430,8 +425,8 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
List<TopCostTpItemVo> itemVoList = costTpItemList.stream().map(x -> BeanUtil.toBean(x, TopCostTpItemVo.class)).collect(Collectors.toList());
|
|
|
topCostTpVo.setItemList(itemVoList);
|
|
|
}
|
|
|
- add.setOrderCost(costTotal);
|
|
|
- add.setOrderProfit(profitTotal);
|
|
|
+ add.setOrderCost(costTotal.add(brokerage));
|
|
|
+ add.setOrderProfit(profitTotal.subtract(brokerage));
|
|
|
add.setCostJson(JSONObject.toJSONString(topCostTpVo));
|
|
|
}
|
|
|
if (bo.getOrderFrom() == 3){
|
|
@@ -603,10 +598,10 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
List<TopOldOrderGoods> orderGoodsList = topOrderGoodsService.list(new LambdaQueryWrapper<TopOldOrderGoods>()
|
|
|
.eq(TopOldOrderGoods::getOrderSn, order.getOrderSn()).ne(TopOldOrderGoods::getCheckStatus, -1).eq(TopOldOrderGoods::getStatus, 1));
|
|
|
//佣金
|
|
|
- BigDecimal brokerage = order.getBrokerage();
|
|
|
+ BigDecimal brokerage = order.getPretaxBrokerage();
|
|
|
//平摊佣金
|
|
|
BigDecimal halveBrokerage = new BigDecimal("0.0000");
|
|
|
- if (ObjectUtils.isNotNull(order.getBrokerage()) && order.getBrokerage().compareTo(BigDecimal.ZERO) != 0){
|
|
|
+ if (ObjectUtils.isNotNull(order.getPretaxBrokerage()) && order.getPretaxBrokerage().compareTo(BigDecimal.ZERO) != 0){
|
|
|
halveBrokerage = brokerage.divide(new BigDecimal(orderGoodsList.size()),4,BigDecimal.ROUND_DOWN);
|
|
|
}
|
|
|
for (TopOldOrderGoods orderGoods : orderGoodsList) {
|
|
@@ -661,15 +656,14 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
//换算订单成本和盈亏
|
|
|
TopCostTpItemVo topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
BigDecimal cost = new BigDecimal("0.00");//成本
|
|
|
- BigDecimal profit = new BigDecimal("0.00"); //盈亏
|
|
|
BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
if (topCostTpItem.getDockStatus() == 1){
|
|
|
//启用成本扣除项
|
|
|
switch (topCostTpItem.getDockType()){
|
|
|
case 1://百分比
|
|
|
//成本扣除金额
|
|
|
- BigDecimal divide = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
- BigDecimal multiply = goodsPrice.multiply(divide);
|
|
|
+ BigDecimal divide1 = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
+ BigDecimal multiply = goodsPrice.multiply(divide1);
|
|
|
goodsPrice = goodsPrice.subtract(multiply);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
@@ -683,20 +677,18 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
case 1://百分比
|
|
|
BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
cost = goodsPrice.multiply(divide);
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
|
cost = topCostTpItem.getTypeValue();
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
costTotal = costTotal.add(cost);
|
|
|
- profitTotal = profitTotal.add(profit);
|
|
|
}
|
|
|
- order.setOrderCost(costTotal);
|
|
|
- order.setOrderProfit(profitTotal);
|
|
|
+ profitTotal = order.getOrderPrice().subtract(costTotal);
|
|
|
+ order.setOrderCost(costTotal.add(brokerage));
|
|
|
+ order.setOrderProfit(profitTotal.subtract(brokerage));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1805,6 +1797,10 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
+ if (order.getOrderFrom() != 1){
|
|
|
+ order.setCheckBy(bo.getLoginName());
|
|
|
+ updateById(order);
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -2011,7 +2007,7 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
//查询视图 v_top_order
|
|
|
List<TopOldOrderVo> orderVos = baseMapper.queryByOrderSns(bo.getOrderSnList());
|
|
|
if (CollectionUtils.isEmpty(orderVos)) {
|
|
|
- return false;
|
|
|
+ throw new CustomException("订单号有误!");
|
|
|
}
|
|
|
Map<Integer, List<TopOldOrderVo>> map = orderVos.stream().collect(Collectors.groupingBy(TopOldOrderVo::getOrderFrom));
|
|
|
map.forEach((k, v) -> {
|
|
@@ -2094,31 +2090,13 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
|
|
|
}
|
|
|
);
|
|
|
-
|
|
|
- //完单通知业务员
|
|
|
-// Map<String, String> params = new HashMap<>();
|
|
|
-// Long nowTime = DateUtils.getNowTime();
|
|
|
-// String sign = ToolsUtils.EncoderByMd5(nowTime+ "pubilc2022");
|
|
|
-// params.put("stamp", nowTime.toString());
|
|
|
-// params.put("sign", sign);
|
|
|
-// params.put("orderSn", bo.getOrderSnList().stream().collect(Collectors.joining()));
|
|
|
-// String respone = "";
|
|
|
-// try {
|
|
|
-// respone = HttpUtils.postFormBody(FINISH_ORDER, params);
|
|
|
-// if (!respone.contains("\"Status\":true")) {
|
|
|
-// throw new CustomException("旧系统完单接口请求错误");
|
|
|
-// }
|
|
|
-// } catch (IOException e) {
|
|
|
-// log.error("旧系统完单接口请求错误" + respone);
|
|
|
-// throw new CustomException("旧系统完单接口请求错误");
|
|
|
-// }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void calculateDivide(List<TopCostTpItemVo> itemList, TopOldOrder order, Integer divideModel) {
|
|
|
if (CollectionUtils.isEmpty(itemList)){return;}
|
|
|
//佣金
|
|
|
- BigDecimal brokerage = order.getBrokerage();
|
|
|
+ BigDecimal brokerage = order.getPretaxBrokerage();
|
|
|
//平摊佣金
|
|
|
BigDecimal halveBrokerage = new BigDecimal("0.0000");
|
|
|
if (order.getOrderFrom() == 1) {
|
|
@@ -2130,12 +2108,8 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
|
|
|
//成本项
|
|
|
BigDecimal divideTotal = new BigDecimal("0.00");//分成
|
|
|
- if (ObjectUtils.isNotNull(order.getBrokerage()) && order.getBrokerage().compareTo(BigDecimal.ZERO) != 0){
|
|
|
- halveBrokerage = brokerage.divide(new BigDecimal(orderGoodsList.size()),4,BigDecimal.ROUND_DOWN);
|
|
|
- }
|
|
|
for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
- //去除佣金
|
|
|
- BigDecimal goodsPrice = orderGoods.getGoodsRealPrice().subtract(halveBrokerage);
|
|
|
+ BigDecimal goodsPrice = orderGoods.getGoodsRealPrice();
|
|
|
//商品业务层 新系统默认是学校业务
|
|
|
String businessName = orderGoodsService.getBusinessById(orderGoods.getOrderGoodsId());
|
|
|
//业务层次过滤
|
|
@@ -2199,7 +2173,6 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
switch (topCostTpItem.getItemType()) {
|
|
|
case 1://百分比
|
|
@@ -2221,7 +2194,7 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
orgOrder.setFinishStatus(1);//已完单
|
|
|
orgOrder.setDivideModel(divideModel);
|
|
|
orgOrder.setDivideStatus(2);//待审核
|
|
|
- orgOrder.setCancelTime(DateUtils.getNowTime());
|
|
|
+ orgOrder.setAccomplishTime(DateUtils.getNowTime());
|
|
|
if (divideModel == 1) {
|
|
|
//机构分成
|
|
|
orgOrder.setDivideCompanyMoney(divideTotal);
|
|
@@ -2238,11 +2211,13 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
.list(new LambdaQueryWrapper<TopOldOrderGoods>()
|
|
|
.eq(TopOldOrderGoods::getOrderSn, order.getOrderSn())
|
|
|
.eq(TopOldOrderGoods::getStatus, 1));
|
|
|
-
|
|
|
+ if (ObjectUtils.isNotNull(order.getPretaxBrokerage()) && order.getPretaxBrokerage().compareTo(BigDecimal.ZERO) != 0){
|
|
|
+ halveBrokerage = brokerage.divide(new BigDecimal(orderGoodsList.size()),4,BigDecimal.ROUND_DOWN);
|
|
|
+ }
|
|
|
//成本项
|
|
|
BigDecimal divideTotal = new BigDecimal("0.00");//分成
|
|
|
for (TopOldOrderGoods orderGoods : orderGoodsList) {
|
|
|
- BigDecimal goodsPrice = orderGoods.getGoodsRealPrice();
|
|
|
+ BigDecimal goodsPrice = orderGoods.getGoodsRealPrice().subtract(halveBrokerage);
|
|
|
//商品业务层
|
|
|
String businessName = orderGoods.getBusinessFullName();
|
|
|
List<TopCostTpItemVo> items = itemList.stream().filter(x -> {
|
|
@@ -2316,7 +2291,6 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
divide = goodsPrice.multiply(divideNum);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
|
-
|
|
|
divide = topCostTpItem.getTypeValue();
|
|
|
break;
|
|
|
default:
|
|
@@ -2330,7 +2304,7 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
order.setFinishStatus(1);//已完单
|
|
|
order.setDivideModel(divideModel);
|
|
|
order.setDivideStatus(2);//待审核
|
|
|
- order.setCancelTime(DateUtils.getNowTime());
|
|
|
+ order.setAccomplishTime(DateUtils.getNowTime());
|
|
|
if (divideModel == 1) {
|
|
|
//机构分成
|
|
|
order.setDivideCompanyMoney(divideTotal);
|
|
@@ -2374,133 +2348,15 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
logs.add(log);
|
|
|
//佣金审核
|
|
|
if (ObjectUtils.isNotNull(brokerage) && brokerage.compareTo(BigDecimal.ZERO) > 0){
|
|
|
- log.setCheckFrom(4);
|
|
|
- logs.add(log);
|
|
|
+ TopOldOrderCheckLog log1 = BeanUtil.toBean(log, TopOldOrderCheckLog.class);
|
|
|
+ log1.setCheckFrom(4);
|
|
|
+ logs.add(log1);
|
|
|
}
|
|
|
}
|
|
|
topOldOrderCheckLogService.saveBatch(logs);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private BigDecimal calculateRebate(List<TopCostTpItemVo> itemList, TopOldOrder order) {
|
|
|
- BigDecimal rebateTotal = new BigDecimal("0.00");//返佣
|
|
|
- //重新匹配成本和盈亏
|
|
|
- if (order.getOrderFrom() == 1) {
|
|
|
- //新系统订单
|
|
|
- List<OrderGoods> orderGoodsList = orderGoodsService
|
|
|
- .list(new LambdaQueryWrapper<OrderGoods>()
|
|
|
- .eq(OrderGoods::getOrderSn, order.getOrderSn())
|
|
|
- .eq(OrderGoods::getStatus, 1));
|
|
|
-
|
|
|
- //成本项
|
|
|
- for (OrderGoods orderGoods : orderGoodsList) {
|
|
|
- BigDecimal goodsPrice = orderGoods.getGoodsRealPrice();
|
|
|
- //商品业务层 新系统默认是学校业务
|
|
|
- String businessName = orderGoodsService.getBusinessById(orderGoods.getOrderGoodsId());
|
|
|
- List<TopCostTpItemVo> items = itemList.stream().filter(x -> {
|
|
|
- TopCourseEducationType education = topCourseEducationTypeService.getById(x.getEducationTypeId());
|
|
|
- TopCourseProjectType projectType = topCourseProjectTypeService.getById(x.getProjectId());
|
|
|
- TopCourseBusiness business = topCourseBusinessService.getById(x.getBusinessId());
|
|
|
- String name = education.getSchemeName() + education.getEducationName() + projectType.getProjectName() + business.getBusinessName();
|
|
|
- if (name.equals(businessName)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(items)) {
|
|
|
- //匹配不到成本项
|
|
|
- continue;
|
|
|
- }
|
|
|
- //根据订单金额匹配成本阶梯
|
|
|
- List<TopCostTpItemVo> tpItems = items.stream().filter(x ->
|
|
|
- (ObjectUtils.isNull(x.getMinValue()) && ObjectUtils.isNull(x.getMaxValue()))
|
|
|
- || (goodsPrice.compareTo(x.getMinValue()) > 0 && goodsPrice.compareTo(x.getMaxValue()) < 0)
|
|
|
- || (goodsPrice.compareTo(x.getMinValue()) == 0 && goodsPrice.compareTo(x.getMaxValue()) == 0)).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(tpItems)) {
|
|
|
- //匹配不到成本项阶梯值
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (tpItems.size() > 1) {
|
|
|
- //匹配到多个成本项
|
|
|
- throw new CustomException(String.format("成本项阶梯匹配有误!(有多个)请检查【%s,价格:%s】", businessName, goodsPrice.toString()));
|
|
|
- }
|
|
|
- //换算订单成本和盈亏
|
|
|
- TopCostTpItemVo topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
- BigDecimal rebate = new BigDecimal("0.00");//返佣
|
|
|
- BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
- switch (topCostTpItem.getItemType()) {
|
|
|
- case 1://百分比
|
|
|
- BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
- rebate = goodsPrice.multiply(divide);
|
|
|
- break;
|
|
|
- case 2://固定金额
|
|
|
- rebate = topCostTpItem.getTypeValue();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- rebateTotal = rebateTotal.add(rebate);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- List<TopOldOrderGoods> orderGoodsList = topOrderGoodsService
|
|
|
- .list(new LambdaQueryWrapper<TopOldOrderGoods>()
|
|
|
- .eq(TopOldOrderGoods::getOrderSn, order.getOrderSn())
|
|
|
- .eq(TopOldOrderGoods::getStatus, 1));
|
|
|
- //成本项
|
|
|
- for (TopOldOrderGoods orderGoods : orderGoodsList) {
|
|
|
- BigDecimal goodsPrice = orderGoods.getGoodsRealPrice();
|
|
|
- //商品业务层
|
|
|
- TopOldOrderGoods oldOrderGoods = topOrderGoodsService.getById(orderGoods.getGoodsId());
|
|
|
- String businessName = oldOrderGoods.getBusinessFullName();
|
|
|
- List<TopCostTpItemVo> items = itemList.stream().filter(x -> {
|
|
|
- TopCourseEducationType education = topCourseEducationTypeService.getById(x.getEducationTypeId());
|
|
|
- TopCourseProjectType projectType = topCourseProjectTypeService.getById(x.getProjectId());
|
|
|
- TopCourseBusiness business = topCourseBusinessService.getById(x.getBusinessId());
|
|
|
- String name = education.getSchemeName() + education.getEducationName() + projectType.getProjectName() + business.getBusinessName();
|
|
|
- if (name.equals(businessName)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(items)) {
|
|
|
- //匹配不到成本项
|
|
|
- continue;
|
|
|
- }
|
|
|
- //根据订单金额匹配成本阶梯
|
|
|
- List<TopCostTpItemVo> tpItems = items.stream().filter(x ->
|
|
|
- (ObjectUtils.isNull(x.getMinValue()) && ObjectUtils.isNull(x.getMaxValue()))
|
|
|
- || (goodsPrice.compareTo(x.getMinValue()) > 0 && goodsPrice.compareTo(x.getMaxValue()) < 0)
|
|
|
- || (goodsPrice.compareTo(x.getMinValue()) == 0 && goodsPrice.compareTo(x.getMaxValue()) == 0)).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(tpItems)) {
|
|
|
- //匹配不到成本项阶梯值
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (tpItems.size() > 1) {
|
|
|
- //匹配到多个成本项
|
|
|
- throw new CustomException(String.format("成本项阶梯匹配有误!(有多个)请检查【%s,价格:%s】", businessName, goodsPrice.toString()));
|
|
|
- }
|
|
|
- //换算订单成本和盈亏
|
|
|
- TopCostTpItemVo topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
- BigDecimal rebate = new BigDecimal("0.00");//返佣
|
|
|
- BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
- switch (topCostTpItem.getItemType()) {
|
|
|
- case 1://百分比
|
|
|
- BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
- rebate = goodsPrice.multiply(divide);
|
|
|
- break;
|
|
|
- case 2://固定金额
|
|
|
- rebate = topCostTpItem.getTypeValue();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- rebateTotal = rebateTotal.add(rebate);
|
|
|
- }
|
|
|
- }
|
|
|
- return rebateTotal;
|
|
|
- }
|
|
|
-
|
|
|
//完单校验
|
|
|
private void validFinish(TopFinishOrderBo bo) {
|
|
|
//校验当前角色审核权限
|
|
@@ -2747,15 +2603,14 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
//换算订单成本和盈亏
|
|
|
TopCostTpItemVo topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
BigDecimal cost = new BigDecimal("0.00");//成本
|
|
|
- BigDecimal profit = new BigDecimal("0.00"); //盈亏
|
|
|
BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
if (topCostTpItem.getDockStatus() == 1){
|
|
|
//启用成本扣除项
|
|
|
switch (topCostTpItem.getDockType()){
|
|
|
case 1://百分比
|
|
|
//成本扣除金额
|
|
|
- BigDecimal divide = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
- BigDecimal multiply = goodsPrice.multiply(divide);
|
|
|
+ BigDecimal divide1 = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
+ BigDecimal multiply = goodsPrice.multiply(divide1);
|
|
|
goodsPrice = goodsPrice.subtract(multiply);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
@@ -2769,18 +2624,16 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
case 1://百分比
|
|
|
BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
cost = goodsPrice.multiply(divide);
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
|
cost = topCostTpItem.getTypeValue();
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
costTotal = costTotal.add(cost);
|
|
|
- profitTotal = profitTotal.add(profit);
|
|
|
}
|
|
|
+ profitTotal = order.getOrderPrice().subtract(costTotal);
|
|
|
//修改订单成本和盈亏
|
|
|
orderService.update(new LambdaUpdateWrapper<Order>()
|
|
|
.set(Order::getOrderCost, costTotal)
|
|
@@ -2789,6 +2642,10 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
.eq(Order::getOrderSn, orderSn));
|
|
|
|
|
|
} else {
|
|
|
+ //佣金
|
|
|
+ BigDecimal brokerage = ObjectUtils.isNotNull(order.getPretaxBrokerage())?order.getPretaxBrokerage():BigDecimal.ZERO;
|
|
|
+ //平摊佣金
|
|
|
+ BigDecimal halveBrokerage = new BigDecimal("0.0000");
|
|
|
//旧系统订单
|
|
|
if (ObjectUtils.isNull(bo.getCostTpVo()) || CollectionUtils.isEmpty(bo.getCostTpVo().getItemList())) {
|
|
|
//没有设置成本模板
|
|
@@ -2803,12 +2660,14 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
.list(new LambdaQueryWrapper<TopOldOrderGoods>()
|
|
|
.eq(TopOldOrderGoods::getOrderSn, orderSn)
|
|
|
.eq(TopOldOrderGoods::getStatus, 1));
|
|
|
-
|
|
|
+ if (ObjectUtils.isNotNull(order.getPretaxBrokerage()) && order.getPretaxBrokerage().compareTo(BigDecimal.ZERO) != 0){
|
|
|
+ halveBrokerage = brokerage.divide(new BigDecimal(orderGoodsList.size()),4,BigDecimal.ROUND_DOWN);
|
|
|
+ }
|
|
|
//成本项
|
|
|
BigDecimal costTotal = new BigDecimal("0.00");//成本
|
|
|
BigDecimal profitTotal = new BigDecimal("0.00"); //盈亏
|
|
|
for (TopOldOrderGoods orderGoods : orderGoodsList) {
|
|
|
- BigDecimal goodsPrice = orderGoods.getGoodsRealPrice();
|
|
|
+ BigDecimal goodsPrice = orderGoods.getGoodsRealPrice().subtract(halveBrokerage);
|
|
|
List<TopCostTpItemVo> itemList = bo.getCostTpVo().getItemList();
|
|
|
//商品业务层
|
|
|
TopOldOrderGoods oldOrderGoods = topOrderGoodsService.getById(orderGoods.getOrderGoodsId());
|
|
@@ -2861,15 +2720,14 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
//换算订单成本和盈亏
|
|
|
TopCostTpItemVo topCostTpItem = tpItems.stream().findFirst().get();
|
|
|
BigDecimal cost = new BigDecimal("0.00");//成本
|
|
|
- BigDecimal profit = new BigDecimal("0.00"); //盈亏
|
|
|
BigDecimal bigDecimal = new BigDecimal("100");
|
|
|
if (topCostTpItem.getDockStatus() == 1){
|
|
|
//启用成本扣除项
|
|
|
switch (topCostTpItem.getDockType()){
|
|
|
case 1://百分比
|
|
|
//成本扣除金额
|
|
|
- BigDecimal divide = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
- BigDecimal multiply = goodsPrice.multiply(divide);
|
|
|
+ BigDecimal divide1 = topCostTpItem.getDockValue().divide(bigDecimal);
|
|
|
+ BigDecimal multiply = goodsPrice.multiply(divide1);
|
|
|
goodsPrice = goodsPrice.subtract(multiply);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
@@ -2883,22 +2741,20 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
|
|
|
case 1://百分比
|
|
|
BigDecimal divide = topCostTpItem.getTypeValue().divide(bigDecimal);
|
|
|
cost = goodsPrice.multiply(divide);
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
case 2://固定金额
|
|
|
cost = topCostTpItem.getTypeValue();
|
|
|
- profit = goodsPrice.subtract(cost);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
costTotal = costTotal.add(cost);
|
|
|
- profitTotal = profitTotal.add(profit);
|
|
|
}
|
|
|
+ profitTotal = order.getOrderPrice().subtract(costTotal);
|
|
|
//修改订单成本和盈亏
|
|
|
update(new LambdaUpdateWrapper<TopOldOrder>()
|
|
|
- .set(TopOldOrder::getOrderCost, costTotal)
|
|
|
- .set(TopOldOrder::getOrderProfit, profitTotal)
|
|
|
+ .set(TopOldOrder::getOrderCost, costTotal.add(brokerage))
|
|
|
+ .set(TopOldOrder::getOrderProfit, profitTotal.subtract(brokerage))
|
|
|
.set(TopOldOrder::getCostJson, JSONObject.toJSONString(bo.getCostTpVo()))
|
|
|
.eq(TopOldOrder::getOrderSn, orderSn));
|
|
|
}
|