|
@@ -11,6 +11,7 @@ import com.fjhx.file.utils.ObsFileUtil;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
|
+import com.sd.business.entity.order.po.OrderSku;
|
|
import com.sd.business.entity.statement.dto.FileUploadDto;
|
|
import com.sd.business.entity.statement.dto.FileUploadDto;
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountDto;
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountDto;
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
|
|
@@ -21,6 +22,8 @@ import com.sd.business.entity.statement.vo.StatementOfAccountVo;
|
|
import com.sd.business.mapper.statement.StatementOfAccountMapper;
|
|
import com.sd.business.mapper.statement.StatementOfAccountMapper;
|
|
import com.sd.business.service.department.DepartmentService;
|
|
import com.sd.business.service.department.DepartmentService;
|
|
import com.sd.business.service.order.OrderService;
|
|
import com.sd.business.service.order.OrderService;
|
|
|
|
+import com.sd.business.service.order.OrderSkuService;
|
|
|
|
+import com.sd.business.service.sku.SkuSpecService;
|
|
import com.sd.business.service.statement.StatementOfAccountService;
|
|
import com.sd.business.service.statement.StatementOfAccountService;
|
|
import com.sd.business.util.CodeEnum;
|
|
import com.sd.business.util.CodeEnum;
|
|
import com.sd.framework.util.Assert;
|
|
import com.sd.framework.util.Assert;
|
|
@@ -28,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@@ -46,14 +50,20 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
private OrderService orderService;
|
|
private OrderService orderService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private OrderSkuService orderSkuService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private DepartmentService departmentService;
|
|
private DepartmentService departmentService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SkuSpecService skuSpecService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Page<StatementOfAccountVo> getPage(StatementOfAccountSelectDto dto) {
|
|
public Page<StatementOfAccountVo> getPage(StatementOfAccountSelectDto dto) {
|
|
|
|
|
|
IWrapper<StatementOfAccount> wrapper = getWrapper();
|
|
IWrapper<StatementOfAccount> wrapper = getWrapper();
|
|
- wrapper.eq("soa", StatementOfAccount::getDepartmentId, dto.getDepartmentId());
|
|
|
|
wrapper.like("soa", StatementOfAccount::getCode, dto.getCode());
|
|
wrapper.like("soa", StatementOfAccount::getCode, dto.getCode());
|
|
|
|
+ wrapper.eq("soa", StatementOfAccount::getDepartmentId, dto.getDepartmentId());
|
|
wrapper.ge("soa", StatementOfAccount::getCreateTime, dto.getBeginTime());
|
|
wrapper.ge("soa", StatementOfAccount::getCreateTime, dto.getBeginTime());
|
|
wrapper.le("soa", StatementOfAccount::getCreateTime, dto.getEndTime());
|
|
wrapper.le("soa", StatementOfAccount::getCreateTime, dto.getEndTime());
|
|
wrapper.orderByDesc("soa", StatementOfAccount::getId);
|
|
wrapper.orderByDesc("soa", StatementOfAccount::getId);
|
|
@@ -183,12 +193,57 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<DocumentBySkuVo> getDocumentBySku(Long id) {
|
|
public List<DocumentBySkuVo> getDocumentBySku(Long id) {
|
|
|
|
+
|
|
Assert.notNull(id, "对账单id不能为空");
|
|
Assert.notNull(id, "对账单id不能为空");
|
|
StatementOfAccount statementOfAccount = getById(id);
|
|
StatementOfAccount statementOfAccount = getById(id);
|
|
Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
|
|
|
|
|
+ List<String> ordedrIdList = Arrays.stream(statementOfAccount.getOrderIdJoin().split(","))
|
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ if (ordedrIdList.size() == 0) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, ordedrIdList));
|
|
|
|
+
|
|
|
|
+ // 生成结果集
|
|
|
|
+ List<DocumentBySkuVo> result = orderSkuList.stream()
|
|
|
|
+ .map(item -> DocumentBySkuVo.builder()
|
|
|
|
+ .skuSpecId(item.getSkuId())
|
|
|
|
+ .quantity(item.getQuantity())
|
|
|
|
+ .unitPrice(item.getUnitPrice())
|
|
|
|
+ .subtotal(item.getUnitPrice()
|
|
|
|
+ .add(item.getCustomProcessingFee())
|
|
|
|
+ .add(item.getLssueFee())
|
|
|
|
+ .add(item.getDeliveryMaterialsFee())
|
|
|
|
+ .add(item.getPackingLabor())
|
|
|
|
+ .add(item.getPackagingMaterialCost()))
|
|
|
|
+ .build())
|
|
|
|
+ .peek(item -> item.setTotal(item.getQuantity().multiply(item.getSubtotal())))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 赋值sku规格品名和品号
|
|
|
|
+ skuSpecService.attributeAssign(result, DocumentBySkuVo::getSkuSpecId, (item, skuSpec) -> {
|
|
|
|
+ item.setSkuSpecCode(skuSpec.getCode());
|
|
|
|
+ item.setSkuSpecName(skuSpec.getName());
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 合并单价、小计、sku规格id系统的对账数据
|
|
|
|
+ Collection<DocumentBySkuVo> documentBySkuVoCollection = result.stream()
|
|
|
|
+ .sorted(Comparator.comparing(DocumentBySkuVo::getSkuSpecCode))
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
+ item -> item.getUnitPrice() + ":" + item.getSubtotal() + ":" + item.getSkuSpecId(),
|
|
|
|
+ Function.identity(),
|
|
|
|
+ (v1, v2) -> {
|
|
|
|
+ v1.setQuantity(v2.getQuantity());
|
|
|
|
+ v1.setTotal(v2.getTotal());
|
|
|
|
+ return v1;
|
|
|
|
+ }
|
|
|
|
+ )).values();
|
|
|
|
+
|
|
|
|
+ return new ArrayList<>(documentBySkuVoCollection);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|