銷售訂單新增利潤率
This commit is contained in:
parent
0a450d882b
commit
3d167f3688
@ -201,8 +201,12 @@ public class GetSaleOrderBo extends BaseBo<SaleOrderFullDto> {
|
||||
@ApiModelProperty("订单明细")
|
||||
private List<OrderDetailBo> details;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 毛利率 仅做校验,不做存储
|
||||
* 毛利率 = 本单利润/含税总金额* 100%
|
||||
*/
|
||||
@ApiModelProperty("毛利率")
|
||||
private String grossMargin;
|
||||
|
||||
public GetSaleOrderBo() {
|
||||
|
||||
|
@ -186,6 +186,12 @@ public class QuerySaleOrderBo extends BaseBo<SaleOrder> implements BaseDto {
|
||||
@ApiModelProperty(value = "序列号")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 毛利率 仅做计算,不做存储
|
||||
* 毛利率 = 本单利润/含税总金额* 100%
|
||||
*/
|
||||
@ApiModelProperty("毛利率")
|
||||
private String grossMargin;
|
||||
|
||||
public QuerySaleOrderBo(SaleOrder dto) {
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.lframework.xingyun.sc.excel.sale.SaleOrderExportModel;
|
||||
import com.lframework.xingyun.sc.mappers.SaleOrderDetailMapper;
|
||||
import com.lframework.xingyun.sc.service.sale.SaleOrderDetailService;
|
||||
import com.lframework.xingyun.sc.service.sale.SaleOrderService;
|
||||
import com.lframework.xingyun.sc.util.CalUtils;
|
||||
import com.lframework.xingyun.sc.vo.sale.ApprovePassSaleOrderVo;
|
||||
import com.lframework.xingyun.sc.vo.sale.ApproveRefuseSaleOrderVo;
|
||||
import com.lframework.xingyun.sc.vo.sale.BatchApprovePassSaleOrderVo;
|
||||
@ -123,7 +124,7 @@ public class SaleOrderController extends DefaultBaseController {
|
||||
public InvokeResult<PageResult<QuerySaleOrderBo>> query(@Valid QuerySaleOrderVo vo) {
|
||||
|
||||
PageResult<SaleOrder> pageResult = saleOrderService.query(getPageIndex(vo), getPageSize(vo),
|
||||
vo);
|
||||
vo);
|
||||
|
||||
List<SaleOrder> datas = pageResult.getDatas();
|
||||
List<QuerySaleOrderBo> results = null;
|
||||
@ -134,6 +135,9 @@ public class SaleOrderController extends DefaultBaseController {
|
||||
if(results!=null){
|
||||
for (QuerySaleOrderBo result : results) {
|
||||
List<SaleOrderDetail> orderDetails=saleOrderDetailMapper.getBySaleOrderId(result.getId());
|
||||
// 计算毛利率 = 本单利润/含税总金额* 100%
|
||||
String grossMargin = CalUtils.CalGrossMargin(result.getThisOrderProfit(),result.getTotalAmount());
|
||||
result.setGrossMargin(grossMargin);
|
||||
|
||||
List<String> productNames = new ArrayList<>();
|
||||
for (SaleOrderDetail orderDetail : orderDetails) {
|
||||
@ -146,9 +150,6 @@ public class SaleOrderController extends DefaultBaseController {
|
||||
result.setProductName(String.join(", ", productNames));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
|
||||
}
|
||||
|
||||
@ -187,6 +188,10 @@ public class SaleOrderController extends DefaultBaseController {
|
||||
//拼接产品名称
|
||||
for (QuerySaleOrderBo result : results) {
|
||||
List<SaleOrderDetail> orderDetails = OrderIdDetailMap.get(result.getId());
|
||||
// 计算毛利率 = 本单利润/含税总金额* 100%
|
||||
String grossMargin = CalUtils.CalGrossMargin(result.getThisOrderProfit(),result.getTotalAmount());
|
||||
result.setGrossMargin(grossMargin);
|
||||
|
||||
List<String> productNames = new ArrayList<>();
|
||||
for (SaleOrderDetail orderDetail : orderDetails) {
|
||||
Product product= productService.findById(orderDetail.getProductId());
|
||||
@ -243,6 +248,8 @@ public class SaleOrderController extends DefaultBaseController {
|
||||
detail.setPurchaseDecimal(purchaseDecimal);
|
||||
detail.setTotalPurchasePrice(totalPurchasePrice);
|
||||
}
|
||||
// 计算毛利率 = 本单利润/含税总金额* 100%
|
||||
result.setGrossMargin(CalUtils.CalGrossMargin(result.getThisOrderProfit(),result.getTotalAmount()));
|
||||
}
|
||||
|
||||
return InvokeResultBuilder.success(result);
|
||||
|
@ -86,6 +86,14 @@ public class SaleOrderExportModel extends BaseBo<QuerySaleOrderBo> implements Ex
|
||||
@ExcelProperty("利润")
|
||||
private BigDecimal thisOrderProfit;
|
||||
|
||||
/**
|
||||
* 毛利率 仅做计算,不做存储
|
||||
* 毛利率 = 本单利润/含税总金额* 100%
|
||||
*/
|
||||
@ExcelProperty("毛利率")
|
||||
private String grossMargin;
|
||||
|
||||
|
||||
/**
|
||||
* 销售数量
|
||||
*/
|
||||
@ -181,6 +189,7 @@ public class SaleOrderExportModel extends BaseBo<QuerySaleOrderBo> implements Ex
|
||||
this.setTotalAmount(dto.getTotalAmount());
|
||||
this.setCustomMoney(dto.getCustomMoney());
|
||||
this.setThisOrderProfit(dto.getThisOrderProfit());
|
||||
this.setGrossMargin(dto.getGrossMargin());
|
||||
this.setTotalNum(dto.getTotalNum());
|
||||
this.setTotalGiftNum(dto.getTotalGiftNum());
|
||||
this.setIsLease(dto.getIsLease() == 1 ? "是" : "否");
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.lframework.xingyun.sc.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public class CalUtils {
|
||||
|
||||
// 计算毛利率 = 本单利润/含税总金额* 100%
|
||||
public static String CalGrossMargin(BigDecimal thisOrderProfit, BigDecimal totalAmount) {
|
||||
if (totalAmount == null || totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return "0.000%";
|
||||
}
|
||||
|
||||
BigDecimal margin = thisOrderProfit
|
||||
.divide(totalAmount, 6, RoundingMode.HALF_UP) // 增加到6位小数
|
||||
.multiply(BigDecimal.valueOf(100))
|
||||
.setScale(3, RoundingMode.HALF_UP);
|
||||
|
||||
return margin.stripTrailingZeros().toPlainString() + "%";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user