1.子单加价金额合并展示

This commit is contained in:
kuang.yife 2023-08-15 22:57:06 +08:00
parent 8edb26d46f
commit c64902e206
2 changed files with 66 additions and 0 deletions

View File

@ -6,16 +6,20 @@ import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo; import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.enums.*; import com.ghy.common.enums.*;
import com.ghy.common.utils.AdapayUtils;
import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ExceptionUtil;
import com.ghy.common.utils.MoneyUtil;
import com.ghy.common.utils.StringUtils; import com.ghy.common.utils.StringUtils;
import com.ghy.common.utils.poi.ExcelUtil; import com.ghy.common.utils.poi.ExcelUtil;
import com.ghy.customer.domain.Customer; import com.ghy.customer.domain.Customer;
import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService; import com.ghy.customer.service.CustomerAddressService;
import com.ghy.customer.service.CustomerService; import com.ghy.customer.service.CustomerService;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.Goods; import com.ghy.goods.domain.Goods;
import com.ghy.goods.domain.GoodsImgs; import com.ghy.goods.domain.GoodsImgs;
import com.ghy.goods.domain.GoodsStandard; import com.ghy.goods.domain.GoodsStandard;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsImgsService; import com.ghy.goods.service.GoodsImgsService;
import com.ghy.goods.service.GoodsService; import com.ghy.goods.service.GoodsService;
import com.ghy.goods.service.GoodsStandardService; import com.ghy.goods.service.GoodsStandardService;
@ -53,6 +57,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -107,6 +112,8 @@ public class OrderDetailController extends BaseController {
private ThreadPoolTaskExecutor executor; private ThreadPoolTaskExecutor executor;
@Autowired @Autowired
private IOrderCallRecordService orderCallRecordService; private IOrderCallRecordService orderCallRecordService;
@Resource
private DeptGoodsCategoryService deptGoodsCategoryService;
@RequiresPermissions("order:detail:view") @RequiresPermissions("order:detail:view")
@GetMapping() @GetMapping()
@ -319,9 +326,11 @@ public class OrderDetailController extends BaseController {
} }
} }
orderListResponse.setPayMoney(workerFee); orderListResponse.setPayMoney(workerFee);
orderListResponse.setPayAddMoney(workerFee);
orderListResponse.setIsOnlyServ(Boolean.TRUE); orderListResponse.setIsOnlyServ(Boolean.TRUE);
} else { } else {
orderListResponse.setPayMoney(detailPayMoney); orderListResponse.setPayMoney(detailPayMoney);
orderListResponse.setPayAddMoney(detailPayMoney);
orderListResponse.setIsOnlyServ(Boolean.FALSE); orderListResponse.setIsOnlyServ(Boolean.FALSE);
} }
@ -374,6 +383,61 @@ public class OrderDetailController extends BaseController {
// TODO: 超时扣费 // TODO: 超时扣费
orderListResponse.setFinancialChangeRecords(financialChangeRecords); orderListResponse.setFinancialChangeRecords(financialChangeRecords);
if(!CollectionUtils.isEmpty(financialChangeRecords)){
BigDecimal totalAdd = financialChangeRecords.stream().map(FinancialChangeRecord::getChangeMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
Long goodsStandardId = orderStandardList.get(0).getGoodsStandardId();
GoodsStandard standard = goodsStandardService.selectById(goodsStandardId);
// 第四级规格
DeptGoodsCategory childCategory = deptGoodsCategoryService.get(standard.getDeptGoodsCategoryId());
// 需要找第三级规格
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.selectOneByGoodsCategoryId(childCategory.getParentCategoryId());
// 一级分销追加扣点
BigDecimal saleRateOne = new BigDecimal(deptGoodsCategory.getOneRate());
saleRateOne = MoneyUtil.lt0(saleRateOne) ? BigDecimal.ZERO : saleRateOne;
// 二级分销追加扣点
BigDecimal saleRateTwo = new BigDecimal(deptGoodsCategory.getTwoRate());
saleRateTwo = MoneyUtil.lt0(saleRateTwo) ? BigDecimal.ZERO : saleRateTwo;
// 三级分销追加扣点
BigDecimal saleRateThree = new BigDecimal(deptGoodsCategory.getThreeRate());
saleRateThree = MoneyUtil.lt0(saleRateThree) ? BigDecimal.ZERO : saleRateThree;
// 分销扣点合计
saleRateOne = saleRateOne.add(saleRateTwo).add(saleRateThree);
// 大师傅提成
BigDecimal teamRete = new BigDecimal(masterWorker.getLeaderTeamRate());
teamRete = MoneyUtil.lt0(teamRete) ? BigDecimal.ZERO : teamRete;
BigDecimal teamMoney = new BigDecimal(masterWorker.getLeaderTeamMoney());
teamMoney = MoneyUtil.lt0(teamMoney) ? BigDecimal.ZERO : teamMoney;
// 平台加价抽成
BigDecimal deptRate = new BigDecimal(deptGoodsCategory.getDeptRate());
deptRate = MoneyUtil.lt0(deptRate) ? BigDecimal.ZERO : deptRate;
BigDecimal deptMoney = MoneyUtil.lt0(deptGoodsCategory.getDeptMoney()) ? BigDecimal.ZERO : deptGoodsCategory.getDeptMoney();
// 分销抽成
BigDecimal customerFee = totalAdd.multiply(saleRateOne).setScale(2, RoundingMode.UP);
// 平台抽成
BigDecimal platformFee = totalAdd.multiply(deptRate).add(deptMoney).setScale(2, RoundingMode.UP);
// 大师傅抽成
BigDecimal masterFee = totalAdd.multiply(teamRete).add(teamMoney).setScale(2, RoundingMode.UP);
// 如果提成>追加金额 则去掉固定提成 只计算比例提成
if (MoneyUtil.lt(masterFee.add(platformFee), totalAdd)) {
platformFee = totalAdd.multiply(deptRate).setScale(2, RoundingMode.UP);
masterFee = totalAdd.multiply(teamRete).setScale(2, RoundingMode.UP);
}
// 如果是大师傅自己接单,则不需要抽成
if(detail.getWorkerId().equals(orderMaster.getWorkerId())){
masterFee = BigDecimal.ZERO;
}
// 上门师傅应得加价的报酬
BigDecimal workerFee = totalAdd.subtract(platformFee).subtract(masterFee).subtract(customerFee);
orderListResponse.setPayAddMoney(orderListResponse.getPayMoney().add(workerFee));
}
return AjaxResult.success(orderListResponse); return AjaxResult.success(orderListResponse);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -78,6 +78,8 @@ public class OrderListResponse {
private BigDecimal payMoney; private BigDecimal payMoney;
private BigDecimal payAddMoney;
private BigDecimal finalRecvMoney; private BigDecimal finalRecvMoney;
private BigDecimal changeMoney; private BigDecimal changeMoney;