|
|
@@ -19,11 +19,14 @@ package org.springblade.purchase.sales.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.trade.purchase.order.enums.OrderTypeEnum;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.entity.CorpsDesc;
|
|
|
import org.springblade.client.entity.GoodsDesc;
|
|
|
import org.springblade.client.entity.GoodsType;
|
|
|
+import org.springblade.client.feign.ICorpsDescClient;
|
|
|
import org.springblade.client.feign.IGoodsDescClient;
|
|
|
import org.springblade.client.vo.GoodsDescVO;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
@@ -38,7 +41,7 @@ import org.springblade.purchase.sales.excel.OrderItemsExcel;
|
|
|
import org.springblade.purchase.sales.mapper.OrderItemsMapper;
|
|
|
import org.springblade.purchase.sales.mapper.OrderPartsMapper;
|
|
|
import org.springblade.purchase.sales.service.IOrderItemsService;
|
|
|
-import org.springblade.purchase.sales.vo.OrderItemsVO;
|
|
|
+import org.springblade.purchase.sales.vo.*;
|
|
|
import org.springblade.stock.entity.StockGoods;
|
|
|
import org.springblade.stock.feign.IStockGoodsClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
@@ -83,6 +86,8 @@ public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderIt
|
|
|
private final IUserClient iUserClient;
|
|
|
|
|
|
private final ISalesPolicyClient salesPolicyClient;
|
|
|
+ //获取客户信息
|
|
|
+ private final ICorpsDescClient corpsDescClient;
|
|
|
|
|
|
@Resource
|
|
|
private OrderPartsMapper orderPartsMapper;
|
|
|
@@ -358,4 +363,118 @@ public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderIt
|
|
|
return baseMapper.historyPrice(itemId,typeId,billType,tradeType,SecureUtil.getTenantId());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<OrderDateVo> orderData(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<OrderDateVo> list = new ArrayList<>();
|
|
|
+ //根据所属公司分类获取其对应的销量
|
|
|
+ List<OrderDateVo> orderDateVoList = baseMapper.orderData(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ //获取所属公司
|
|
|
+ List<CorpsDesc> corpsType = corpsDescClient.getCorpsType("GS");
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsType) && CollectionUtils.isNotEmpty(orderDateVoList)){
|
|
|
+ for (CorpsDesc corpsDesc : corpsType) {
|
|
|
+ OrderDateVo orderDateVo = new OrderDateVo();
|
|
|
+ orderDateVo.setBelongToCorpName(corpsDesc.getCname());
|
|
|
+ orderDateVo.setOrderNumber(orderDateVoList.stream().filter(e -> e.getBelongToCorpId().longValue()==corpsDesc.getId().longValue()).map(OrderDateVo::getOrderNumber).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ list.add(orderDateVo);
|
|
|
+ }
|
|
|
+ }else if (CollectionUtils.isNotEmpty(corpsType) && CollectionUtils.isEmpty(orderDateVoList)){
|
|
|
+ for (CorpsDesc corpsDesc : corpsType) {
|
|
|
+ OrderDateVo orderDateVo = new OrderDateVo();
|
|
|
+ orderDateVo.setBelongToCorpName(corpsDesc.getCname());
|
|
|
+ orderDateVo.setOrderNumber(BigDecimal.ZERO);
|
|
|
+ list.add(orderDateVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BrandSalesVo> brandSales(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<BrandSalesVo> list = new ArrayList<>();
|
|
|
+ //根据所属公司分类获取其对应的销量
|
|
|
+ List<OrderDateVo> orderDateVoList = baseMapper.orderData(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ //获取所属公司
|
|
|
+ List<CorpsDesc> corpsType = corpsDescClient.getCorpsType("GS");
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsType) && CollectionUtils.isNotEmpty(orderDateVoList)){
|
|
|
+ //获取总销量
|
|
|
+ BigDecimal decimal = orderDateVoList.stream().map(OrderDateVo::getOrderNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ for (CorpsDesc corpsDesc : corpsType) {
|
|
|
+ BrandSalesVo brandSalesVo = new BrandSalesVo();
|
|
|
+ brandSalesVo.setBelongToCorpName(corpsDesc.getCname());
|
|
|
+ if (decimal.compareTo(BigDecimal.ZERO) >0 ){
|
|
|
+ brandSalesVo.setOrderNumber(orderDateVoList.stream().filter(e -> e.getBelongToCorpId().longValue()==corpsDesc.getId().longValue())
|
|
|
+ .map(OrderDateVo::getOrderNumber).reduce(BigDecimal.ZERO, BigDecimal::add).divide(decimal, 5, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ }else {
|
|
|
+ brandSalesVo.setOrderNumber(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ list.add(brandSalesVo);
|
|
|
+ }
|
|
|
+ }else if (CollectionUtils.isNotEmpty(corpsType) && CollectionUtils.isEmpty(orderDateVoList)){
|
|
|
+ for (CorpsDesc corpsDesc : corpsType) {
|
|
|
+ BrandSalesVo brandSalesVo = new BrandSalesVo();
|
|
|
+ brandSalesVo.setBelongToCorpName(corpsDesc.getCname());
|
|
|
+ brandSalesVo.setOrderNumber(BigDecimal.ZERO);
|
|
|
+ list.add(brandSalesVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BigDecimal orderMonthNUmber(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ return baseMapper.orderMonthNUmber(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TopCorpVo> topCorp(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<TopCorpVo> corpVoList = baseMapper.topCorp(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ if (CollectionUtils.isNotEmpty(corpVoList)){
|
|
|
+ for (TopCorpVo topCorpVo : corpVoList) {
|
|
|
+ if (topCorpVo.getCorpId() !=null){
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(topCorpVo.getCorpId());
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() !=null){
|
|
|
+ topCorpVo.setCorpName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return corpVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ChargeMemberVo> chargeMember(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ return baseMapper.chargeMember(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<OrderSizeVo> orderSize(Order order) {
|
|
|
+ if (StringUtils.isBlank(order.getTenantId())){
|
|
|
+ order.setTenantId(SecureUtil.getTenantId());
|
|
|
+ }
|
|
|
+ List<OrderSizeVo> orderSizeVoList = baseMapper.orderSize(order.getTradeType(), order.getBillType(), order.getTenantId());
|
|
|
+ if (CollectionUtils.isNotEmpty(orderSizeVoList)){
|
|
|
+ //获取总销量
|
|
|
+ BigDecimal decimal = orderSizeVoList.stream().map(OrderSizeVo::getOrderNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ for (OrderSizeVo orderSizeVo : orderSizeVoList) {
|
|
|
+ orderSizeVo.setOrderNumber(orderSizeVo.getOrderNumber().divide(decimal, 5, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderSizeVoList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|