Commit d4a9d030 by 杨浩

bug修复;

客户对账
parent d6ed695b
package cn.iocoder.foodnexus.module.order.enums;
package cn.iocoder.foodnexus.framework.common.enums;
import cn.iocoder.foodnexus.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
......
......@@ -64,7 +64,7 @@ public class ErpSupplierController {
@PostMapping("/audit")
@Operation(summary = "审核供应商")
@PreAuthorize("@ss.hasPermission('erp:supplier:update')")
public CommonResult<Boolean> auditSupplier(@Valid @RequestBody AuditCommonReqVO updateReqVO) {
public CommonResult<Boolean> auditSupplier(@Valid @RequestBody ErpSupplierAuditReqVO updateReqVO) {
supplierService.audit(updateReqVO);
return success(true);
}
......
......@@ -112,6 +112,9 @@ public class ErpPurchaseOrderPageReqVO extends PageParam {
@Schema(description = "客户订单id")
private Long customerOrderId;
@Schema(description = "客户订单code")
private String customerOrderCode;
@Schema(description = "客户名称")
private String customerName;
......
......@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.order.dto.CustomerAddressInfo;
......@@ -115,6 +116,14 @@ public class ErpPurchaseOrderRespVO {
@Schema(description = "发货状态")
private String deliveryStatus;
/**
* 质检状态
*
* 枚举 {@link CheckTaskStatus}
*/
@Schema(description = "质检状态")
private String checkTaskStatus;
/* ------ 客户订单 ------ */
@Schema(description = "客户收货地址info")
......
......@@ -73,6 +73,9 @@ public class ErpPurchaseReturnPageReqVO extends PageParam {
@Schema(description = "客户订单id")
private Long customerOrderId;
@Schema(description = "客户订单code")
private String customerOrderCode;
@Schema(description = "客户名称")
private String customerName;
......
package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier;
import cn.iocoder.foodnexus.module.system.controller.admin.vo.AuditCommonReqVO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author : yanghao
* create at: 2025/11/1 14:19
* @description: 供应商 - 审核
*/
@Data
public class ErpSupplierAuditReqVO extends AuditCommonReqVO {
@Schema(description = "入驻初始评分")
@NotNull(message = "入驻初始评分不能为空")
private Integer auditScore;
}
......@@ -35,4 +35,10 @@ public class ErpSupplierPageReqVO extends PageParam {
@Schema(description = "统一社会信用代码")
private String unifiedSocialCreditCode;
@Schema(description = "审核状态")
private String auditStatus;
@Schema(description = "状态")
private Integer status;
}
\ No newline at end of file
......@@ -131,6 +131,8 @@ public class ErpSupplierRespVO {
@Schema(description = "审核意见")
private String auditReason;
@Schema(description = "入驻初始评分")
private Integer auditScore;
/**
* 关联部门id
......
......@@ -48,6 +48,9 @@ public class ErpSupplierSimpleRespVO {
@Schema(description = "统一社会信用代码")
private String unifiedSocialCreditCode;
@Schema(description = "入驻初始评分")
private Integer auditScore;
/**
* 关联部门id
*/
......
package cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.iocoder.foodnexus.framework.excel.core.annotations.DictFormat;
import cn.iocoder.foodnexus.framework.excel.core.convert.DictConvert;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - ERP 客户 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ErpCustomerSimpleRespVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520")
@ExcelProperty("客户编号")
private Long id;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ExcelProperty("客户名称")
private String name;
@Schema(description = "是否确认")
private Boolean confirm;
}
......@@ -5,6 +5,7 @@ import cn.iocoder.foodnexus.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.excel.core.util.ExcelUtils;
......@@ -37,9 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import static cn.iocoder.foodnexus.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
......@@ -120,13 +119,15 @@ public class ErpStockController {
convertSet(pageResult.getList(), ErpStockDO::getProductId));
Map<Long, String> warehouseMap = warehouseService.getNameWithParentMap(
convertSet(pageResult.getList(), ErpStockDO::getWarehouseId));
Map<Long, String> categoryMap = productCategoryService.getMap(productMap.keySet());
Map<Long, String> categoryMap = productCategoryService.getMap(CommonUtil.listConvertSet(new ArrayList<>(productMap.values()), ProductSpuDO::getCategoryId));
Map<Long, Long> supplierCountMap = productSupplierService.getCountMap(productMap.keySet());
return BeanUtils.toBean(pageResult, ErpStockRespVO.class, stock -> {
MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName())
.setUnitName(product.getUnitName())
.setIntroduction(product.getIntroduction()));
MapUtils.findAndThen(categoryMap, stock.getProductId(), stock::setCategoryName);
MapUtils.findAndThen(productMap, stock.getProductId(), product -> {
stock.setProductName(product.getName())
.setUnitName(product.getUnitName())
.setIntroduction(product.getIntroduction());
MapUtils.findAndThen(categoryMap, product.getCategoryId(), stock::setCategoryName);
});
MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), stock::setWarehouseName);
MapUtils.findAndThen(supplierCountMap, stock.getProductId(), stock::setProductSupplierCount);
});
......
......@@ -87,7 +87,7 @@ public class ErpWarehouseController {
public CommonResult<ErpWarehouseRespVO> getWarehouse(@RequestParam("id") Long id) {
ErpWarehouseDO warehouse = warehouseService.getWarehouse(id);
return success(BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class, item -> {
if (!Objects.equals(item.getParentId(), ErpWarehouseDO.PARENT_ID_ROOT)) {
if (Objects.equals(item.getParentId(), ErpWarehouseDO.PARENT_ID_ROOT)) {
item.setParentName("");
} else {
item.setParentName(Optional.ofNullable(warehouseService.getWarehouse(item.getParentId())).map(ErpWarehouseDO::getName).orElse(""));
......@@ -101,7 +101,7 @@ public class ErpWarehouseController {
@PreAuthorize("@ss.hasPermission('erp:warehouse:query')")
public CommonResult<List<ErpWarehouseRespVO>> getWarehouse(@RequestParam("ids") List<Long> ids) {
List<ErpWarehouseDO> warehouseList = warehouseService.getWarehouseList(ids);
Map<Long, String> nameMap = warehouseService.queryNameByIds(CommonUtil.listConvertSet(warehouseList, ErpWarehouseDO::getId));
Map<Long, String> nameMap = warehouseService.queryNameByIds(CommonUtil.listConvertSet(warehouseList, ErpWarehouseDO::getParentId));
return success(BeanUtils.toBean(warehouseList, ErpWarehouseRespVO.class, item -> {
MapUtils.findAndThen(nameMap, item.getParentId(), item::setParentName);
}));
......@@ -112,7 +112,7 @@ public class ErpWarehouseController {
@PreAuthorize("@ss.hasPermission('erp:warehouse:query')")
public CommonResult<PageResult<ErpWarehouseRespVO>> getWarehousePage(@Valid ErpWarehousePageReqVO pageReqVO) {
PageResult<ErpWarehouseDO> pageResult = warehouseService.getWarehousePage(pageReqVO);
Map<Long, String> nameMap = warehouseService.queryNameByIds(CommonUtil.listConvertSet(pageResult.getList(), ErpWarehouseDO::getId));
Map<Long, String> nameMap = warehouseService.queryNameByIds(CommonUtil.listConvertSet(pageResult.getList(), ErpWarehouseDO::getParentId));
return success(BeanUtils.toBean(pageResult, ErpWarehouseRespVO.class, item -> {
MapUtils.findAndThen(nameMap, item.getParentId(), item::setParentName);
}));
......
package cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
......@@ -127,4 +128,11 @@ public class ErpPurchaseOrderDO extends BaseDO {
*/
private String deliveryStatus;
/**
* 质检状态
*
* 枚举 {@link CheckTaskStatus}
*/
private String checkTaskStatus;
}
\ No newline at end of file
......@@ -177,4 +177,9 @@ public class ErpSupplierDO extends BaseDO {
*/
private Long systemDeptId;
/**
* 入驻初始评分
*/
private Integer auditScore;
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderI
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order.SupplierMonthOrderRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -129,6 +130,11 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
query.likeIfExists("oco2.address_info", reqVO.getContactPhone());
query.likeIfExists("oco2.address_info", reqVO.getContactUser());
}
if (CommonUtil.isNotBlank(reqVO.getCustomerOrderCode())) {
query.leftJoin("order_customer_order oco3 on oco3.id = t.customer_order_id");
query.eq("oco3.code", reqVO.getCustomerOrderCode());
query.groupBy(ErpPurchaseReturnDO::getId);
}
return query;
}
......
......@@ -76,6 +76,11 @@ public interface ErpPurchaseReturnMapper extends BaseMapperX<ErpPurchaseReturnDO
query.betweenIfPresent(ErpSaleReturnDO::getDeliveryTime, reqVO.getDeliveryTime());
query.groupBy(ErpPurchaseReturnDO::getId);
}
if (CommonUtil.isNotBlank(reqVO.getCustomerOrderCode())) {
query.leftJoin("order_customer_order oco3 on oco3.id = t.customer_order_id");
query.eq("oco3.code", reqVO.getCustomerOrderCode());
query.groupBy(ErpPurchaseReturnDO::getId);
}
return selectJoinPage(reqVO, ErpPurchaseReturnDO.class, query);
}
......
......@@ -27,6 +27,8 @@ public interface ErpSupplierMapper extends BaseMapperX<ErpSupplierDO> {
.likeIfPresent(ErpSupplierDO::getTelephone, reqVO.getTelephone())
.eqIfPresent(ErpSupplierDO::getUnifiedSocialCreditCode, reqVO.getUnifiedSocialCreditCode())
.likeIfPresent(ErpSupplierDO::getContact, reqVO.getContact())
.eqIfPresent(ErpSupplierDO::getAuditStatus, reqVO.getAuditStatus())
.eqIfPresent(ErpSupplierDO::getStatus, reqVO.getStatus())
.orderByDesc(ErpSupplierDO::getId));
}
......
package cn.iocoder.foodnexus.module.erp.service.purchase;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseInDO;
......@@ -41,6 +42,8 @@ public interface ErpPurchaseInService {
*/
void updatePurchaseInStatus(Long id, Integer status);
void updatePurchaseInStatusByPurchaseOrderId(Long purchaseOrderId, ErpAuditStatus erpAuditStatus);
/**
* 更新采购入库的付款金额
*
......
......@@ -96,7 +96,7 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
// 3. 更新采购订单的入库数量
updatePurchaseOrderInCount(createReqVO.getOrderId());
this.updatePurchaseInStatus(purchaseIn.getId(), ErpAuditStatus.APPROVE.getStatus());
// this.updatePurchaseInStatus(purchaseIn.getId(), ErpAuditStatus.APPROVE.getStatus());
return purchaseIn.getId();
}
......@@ -189,6 +189,17 @@ public class ErpPurchaseInServiceImpl implements ErpPurchaseInService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updatePurchaseInStatusByPurchaseOrderId(Long purchaseOrderId, ErpAuditStatus erpAuditStatus) {
List<ErpPurchaseInDO> erpPurchaseInDOS = purchaseInMapper.selectList(ErpPurchaseInDO::getOrderId, purchaseOrderId);
if (CommonUtil.isNotEmpty(erpPurchaseInDOS)) {
for (ErpPurchaseInDO item : erpPurchaseInDOS) {
this.updatePurchaseInStatus(item.getId(), erpAuditStatus.getStatus());
}
}
}
@Override
public void updatePurchaseInPaymentPrice(Long id, BigDecimal paymentPrice) {
ErpPurchaseInDO purchaseIn = purchaseInMapper.selectById(id);
if (purchaseIn.getPaymentPrice().equals(paymentPrice)) {
......
......@@ -131,4 +131,6 @@ public interface ErpPurchaseOrderService {
void reconciliation(List<ErpPurchaseOrderDO> purchaseOrderList, Long supplierId);
Map<Long, ErpPurchaseOrderDO> getMap(List<Long> longs);
void abnormalPurchaseOrder(Long purchaseOrderId);
}
\ No newline at end of file
......@@ -2,9 +2,12 @@ package cn.iocoder.foodnexus.module.erp.service.purchase;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.framework.common.util.spring.SpringUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.PurchaseOrderSplitEvent;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO;
......@@ -20,6 +23,7 @@ import cn.iocoder.foodnexus.module.erp.service.finance.ErpAccountService;
import cn.iocoder.foodnexus.module.order.api.CheckTaskApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderApi;
import cn.iocoder.foodnexus.module.order.api.CustomerOrderRecordApi;
import cn.iocoder.foodnexus.module.order.api.DeliveryStaffApi;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderItemDTO;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderRecordEvent;
......@@ -32,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
......@@ -324,7 +329,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
* @param supplierId
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public void delivery(List<Long> ids, Long supplierId, ErpDeliveryStatus oriStatus, ErpDeliveryStatus updateStatus, CustomerOrderStatus updateOrderStatus) {
List<ErpPurchaseOrderDO> orderList = purchaseOrderMapper.selectList(Wrappers.<ErpPurchaseOrderDO>lambdaQuery()
.in(ErpPurchaseOrderDO::getId, ids)
......@@ -342,12 +347,15 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
if (!oriStatus.getStatus().equals(item.getDeliveryStatus())) {
throw exception(PURCHASE_DELIVERY_STATUS_ERROR);
}
boolean isReCheck = CheckTaskStatus.ABNORMAL.getKey().equals(item.getCheckTaskStatus());
CustomerOrderDTO customerOrder = customerOrderApi.queryById(item.getCustomerOrderId());
if (CommonUtil.isEmpty(customerOrder)) {
throw exception("订单不存在");
}
if (!customerOrderSet.contains(item.getCustomerOrderId())) {
if (!customerOrderSet.contains(item.getCustomerOrderId()) && !isReCheck) {
// 添加订单进度记录
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(updateOrderStatus);
......@@ -365,19 +373,21 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
if (updateStatus.equals(ErpDeliveryStatus.ARRIVAL)) {
orderList.forEach(purchaseOrder -> {
// 新增采购入库单
ErpPurchaseInSaveReqVO inSaveReqVO = new ErpPurchaseInSaveReqVO();
inSaveReqVO.setInTime(LocalDateTime.now());
inSaveReqVO.setOrderId(purchaseOrder.getId());
inSaveReqVO.setFileUrl(purchaseOrder.getFileUrl());
inSaveReqVO.setRemark(purchaseOrder.getRemark());
List<ErpPurchaseOrderItemDO> purchaseOrderItems = purchaseOrderItemMapper.selectListByOrderId(purchaseOrder.getId());
inSaveReqVO.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem ->
getItem(purchaseOrderItem, customerOrderApi.queryById(purchaseOrder.getCustomerOrderId()))));
purchaseInService.createPurchaseIn(inSaveReqVO);
// 新增来料质检
checkTaskApi.createByPurchaseOrderId(purchaseOrder.getId());
if (!Objects.equals(purchaseOrder.getCheckTaskStatus(), CheckTaskStatus.ABNORMAL.getKey())) {
// 新增采购入库单
ErpPurchaseInSaveReqVO inSaveReqVO = new ErpPurchaseInSaveReqVO();
inSaveReqVO.setInTime(LocalDateTime.now());
inSaveReqVO.setOrderId(purchaseOrder.getId());
inSaveReqVO.setFileUrl(purchaseOrder.getFileUrl());
inSaveReqVO.setRemark(purchaseOrder.getRemark());
List<ErpPurchaseOrderItemDO> purchaseOrderItems = purchaseOrderItemMapper.selectListByOrderId(purchaseOrder.getId());
inSaveReqVO.setItems(CommonUtil.listConvert(purchaseOrderItems, purchaseOrderItem ->
getItem(purchaseOrderItem, customerOrderApi.queryById(purchaseOrder.getCustomerOrderId()))));
purchaseInService.createPurchaseIn(inSaveReqVO);
// 新增来料质检
checkTaskApi.createByPurchaseOrderId(purchaseOrder.getId());
}
});
}
}
......@@ -460,6 +470,14 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
return CommonUtil.listConvertMap(erpPurchaseOrderDOS, ErpPurchaseOrderDO::getId);
}
@Override
public void abnormalPurchaseOrder(Long purchaseOrderId) {
purchaseOrderMapper.update(Wrappers.<ErpPurchaseOrderDO>lambdaUpdate()
.set(ErpPurchaseOrderDO::getCheckTaskStatus, CheckTaskStatus.ABNORMAL.getKey())
.set(ErpPurchaseOrderDO::getDeliveryStatus, ErpDeliveryStatus.NOT_YET.getStatus())
.eq(ErpPurchaseOrderDO::getId, purchaseOrderId));
}
@Async
@TransactionalEventListener(classes = PurchaseOrderSplitEvent.class, phase = TransactionPhase.AFTER_COMMIT)
public void orderSplit(PurchaseOrderSplitEvent event) {
......@@ -473,6 +491,7 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
}
Map<Long, List<CustomerOrderItemDTO>> supplierMap = CommonUtil.listConvertListMap(customerOrderItemDTOS, CustomerOrderItemDTO::getSupplierId);
List<Long> purchaseOrderIds = new ArrayList<>();
for (Map.Entry<Long, List<CustomerOrderItemDTO>> entry : supplierMap.entrySet()) {
Long supplierId = entry.getKey();
List<CustomerOrderItemDTO> list = entry.getValue();
......@@ -494,7 +513,8 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
purchaseOrder.put(purhcaseOrderItem);
}
this.createPurchaseOrder(purchaseOrder);
ErpPurchaseOrderServiceImpl proxyService = SpringUtils.getBean(ErpPurchaseOrderServiceImpl.class);
Long purchaseOrderId = this.createPurchaseOrder(purchaseOrder);
CustomerOrderRecordEvent recordEvent = new CustomerOrderRecordEvent();
recordEvent.setOrderStatus(CustomerOrderStatus.ORDER_MATCH);
......@@ -502,6 +522,15 @@ public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService {
recordEvent.setSupplierId(supplierId);
recordEvent.setCopyWriter(CommonUtil.asList(list.get(0).getSupplierName()));
orderRecordApi.recordEvent(recordEvent);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// 通过代理对象调用,事务生效
proxyService.delivery(CommonUtil.asList(purchaseOrderId), supplierId,
ErpDeliveryStatus.MATCHED, ErpDeliveryStatus.NOT_YET, CustomerOrderStatus.SUPPLIER_ACCEPT_ORDER);
}
}
}
......@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.service.purchase;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpProductSupplierBindReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierAuditReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
......@@ -94,7 +95,7 @@ public interface ErpSupplierService {
*/
List<ErpSupplierDO> getSupplierListByStatus(Integer status);
void audit(AuditCommonReqVO auditReqVO);
void audit(ErpSupplierAuditReqVO auditReqVO);
void bindProduct(ErpProductSupplierBindReqVO bindReqVO);
......
......@@ -8,6 +8,7 @@ import cn.iocoder.foodnexus.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.api.vo.supplier.SupplierAddReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpProductSupplierBindReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierAuditReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.product.ProductSupplierDO;
......@@ -131,7 +132,7 @@ public class ErpSupplierServiceImpl implements ErpSupplierService, ErpSupplierAp
}
@Override
public void audit(AuditCommonReqVO auditReqVO) {
public void audit(ErpSupplierAuditReqVO auditReqVO) {
Long id = auditReqVO.getId();
int status = Integer.parseInt(auditReqVO.getAuditStatus());
ErpSupplierDO supplier = supplierMapper.selectById(id);
......@@ -151,6 +152,7 @@ public class ErpSupplierServiceImpl implements ErpSupplierService, ErpSupplierAp
.set(ErpSupplierDO::getAuditReason, CommonUtil.getEls(auditReqVO.getAuditReason(), ""))
.set(ErpSupplierDO::getAuditTime, LocalDateTime.now())
.set(ErpSupplierDO::getAuditStatus, auditReqVO.getAuditStatus())
.set(ErpSupplierDO::getAuditScore, auditReqVO.getAuditScore())
.eq(ErpSupplierDO::getId, id));
}
......
package cn.iocoder.foodnexus.module.operations.controller.admin.inquireprice;
import cn.iocoder.foodnexus.framework.common.pojo.ImportResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemImportVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemSaveReqVO;
import cn.iocoder.foodnexus.module.operations.service.inquirecustomerpush.InquireCustomerPushService;
import cn.iocoder.foodnexus.module.operations.service.inquirepriceitem.InquirePriceItemService;
import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.controller.admin.user.vo.user.UserImportExcelVO;
......@@ -55,6 +59,9 @@ public class InquirePriceController {
@Autowired
private ProductSpuService productService;
@Autowired
private InquireCustomerPushService inquireCustomerPushService;
@PostMapping("/create")
@Operation(summary = "创建询价管理")
@PreAuthorize("@ss.hasPermission('operations:inquire-price:create')")
......@@ -106,6 +113,7 @@ public class InquirePriceController {
item.setItems(BeanUtils.toBean(inquirePriceItemService.queryByInquireId(item.getId()), InquirePriceItemRespVO.class, inquireItem -> {
inquireItem.setProductName(productService.queryName(inquireItem.getProductId()));
}));
item.setPushCustomerInfo(inquireCustomerPushService.getSimpCustomer(item.getId()));
}));
}
......@@ -114,7 +122,10 @@ public class InquirePriceController {
@PreAuthorize("@ss.hasPermission('operations:inquire-price:query')")
public CommonResult<PageResult<InquirePriceRespVO>> getInquirePricePage(@Valid InquirePricePageReqVO pageReqVO) {
PageResult<InquirePriceDO> pageResult = inquirePriceService.getInquirePricePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, InquirePriceRespVO.class));
Map<Long, List<ErpCustomerSimpleRespVO>> customerMap = inquireCustomerPushService.getSimpCustomerMap(CommonUtil.listConvert(pageResult.getList(), InquirePriceDO::getId));
return success(BeanUtils.toBean(pageResult, InquirePriceRespVO.class, item -> {
MapUtils.findAndThen(customerMap, item.getId(), item::setPushCustomerInfo);
}));
}
@GetMapping("/export-excel")
......
package cn.iocoder.foodnexus.module.operations.controller.admin.inquireprice.vo;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
......@@ -25,21 +27,13 @@ public class InquirePriceRespVO {
@ExcelProperty("询价年月")
private String inquiryYearMonth;
@Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6248")
@ExcelProperty("客户id")
private Long customerId;
@Schema(description = "客户名称", example = "李四")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "是否推送", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否推送")
private Boolean isPush;
@Schema(description = "推送客户明细")
@ExcelProperty("推送客户明细")
private String pushCustomerInfo;
private List<ErpCustomerSimpleRespVO> pushCustomerInfo;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
......
......@@ -22,13 +22,6 @@ public class InquirePriceSaveReqVO {
@Schema(description = "询价年月")
private String inquiryYearMonth;
@Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "6248")
@NotNull(message = "客户id不能为空")
private Long customerId;
@Schema(description = "客户名称", example = "李四")
private String customerName;
@Schema(description = "items")
@Size(min = 1, message = "items不能为空")
@Valid
......
......@@ -2,9 +2,11 @@ package cn.iocoder.foodnexus.module.operations.controller.admin.inquiresupplierp
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils;
import cn.iocoder.foodnexus.framework.common.util.collection.MapUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.service.ErpSupplierApi;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquirepriceitem.vo.InquirePriceItemRespVO;
......@@ -13,6 +15,7 @@ import cn.iocoder.foodnexus.module.operations.controller.admin.inquiresupplierpu
import cn.iocoder.foodnexus.module.operations.controller.admin.inquiresupplierpush.vo.AppInquireSupplierPushPageReqVO;
import cn.iocoder.foodnexus.module.operations.controller.admin.inquiresupplierpush.vo.AppInquireSupplierPushRespVO;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.inquirepriceitem.InquirePriceItemDO;
import cn.iocoder.foodnexus.module.operations.service.inquirecustomerpush.InquireCustomerPushService;
import cn.iocoder.foodnexus.module.operations.service.inquirepriceitem.InquirePriceItemService;
import cn.iocoder.foodnexus.module.product.controller.admin.spu.vo.ProductSpuRespVO;
import cn.iocoder.foodnexus.module.product.dal.dataobject.spu.ProductSpuDO;
......@@ -69,15 +72,18 @@ public class InquireSupplierPushController {
@Autowired
private ErpSupplierService supplierService;
@Autowired
private InquireCustomerPushService inquireCustomerPushService;
@PostMapping("/confirm")
/*@PostMapping("/confirm")
@Operation(summary = "确认询价")
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<Boolean> updateInquireSupplierPush(@Valid @RequestBody AppInquireSupplierPushConfirmReqVO updateReqVO) {
updateReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
inquireSupplierPushService.confirm(updateReqVO);
return success(true);
}
}*/
@GetMapping("/get")
@Operation(summary = "获得询价推送")
......@@ -129,8 +135,15 @@ public class InquireSupplierPushController {
PageResult<AppInquireSupplierPushRespVO> result = inquireSupplierPushService.getAppInquireSupplierPushPage(pageReqVO);
if (CommonUtil.isNotEmpty(result) && CommonUtil.isNotEmpty(result.getList())) {
AppInquireSupplierPushRespVO inquirePrice = result.getList().get(0);
if (!inquirePrice.getIsConfirm()) {
AppInquireSupplierPushConfirmReqVO confirmReqVO = new AppInquireSupplierPushConfirmReqVO();
confirmReqVO.setInquirePriceId(inquirePrice.getId());
confirmReqVO.setSupplierId(pageReqVO.getSupplierId());
inquireSupplierPushService.confirm(confirmReqVO);
}
return success(BeanUtils.toBean(inquirePrice, AppInquireSupplierPushDetailsRespVO.class, item -> {
item.setSupplierItems(inquirePriceItemService.queryListWithSupplierQuote(item.getId(), pageReqVO.getSupplierId()));
item.setPushCustomerInfo(inquireCustomerPushService.getSimpCustomer(item.getId()));
}));
}
return success(new AppInquireSupplierPushDetailsRespVO());
......@@ -141,7 +154,13 @@ public class InquireSupplierPushController {
@AppSystemAuth(UserSystemEnum.SUPPLIER)
public CommonResult<PageResult<AppInquireSupplierPushRespVO>> getInquireSupplierPushPage(@Valid AppInquireSupplierPushPageReqVO pageReqVO) {
pageReqVO.setSupplierId(supplierApi.querySupplierIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
return success(inquireSupplierPushService.getAppInquireSupplierPushPage(pageReqVO));
PageResult<AppInquireSupplierPushRespVO> appInquireSupplierPushPage = inquireSupplierPushService.getAppInquireSupplierPushPage(pageReqVO);
Map<Long, List<ErpCustomerSimpleRespVO>> customerMap = inquireCustomerPushService.getSimpCustomerMap(CommonUtil.listConvertSet(appInquireSupplierPushPage.getList(), AppInquireSupplierPushRespVO::getId));
CollectionUtils.convertList(appInquireSupplierPushPage.getList(), item -> {
MapUtils.findAndThen(customerMap, item.getId(), item::setPushCustomerInfo);
return item;
});
return success(appInquireSupplierPushPage);
}
@GetMapping("/export-excel")
......
......@@ -23,7 +23,7 @@ public class AppInquireSupplierPushConfirmReqVO {
@Schema(hidden = true)
private Long supplierId;
@Schema(description = "子项")
/* @Schema(description = "子项")
@Valid
@NotNull(message = "子项不能为空")
@Size(min = 1, message = "子项不能为空")
......@@ -40,5 +40,5 @@ public class AppInquireSupplierPushConfirmReqVO {
@NotNull(message = "报价不能为空")
private Integer supplierQuote;
}
}*/
}
......@@ -33,4 +33,7 @@ public class ScoringWeightPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(hidden = true)
private Boolean webDisplay = Boolean.TRUE;
}
\ No newline at end of file
......@@ -36,21 +36,9 @@ public class InquirePriceDO extends BaseDO {
*/
private String inquiryYearMonth;
/**
* 客户id
*/
private Long customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 是否推送
*/
private Boolean isPush;
/**
* 推送客户明细
*/
private String pushCustomerInfo;
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
*
* @author 超级管理员
*/
@TableName("oper_inquire_supplier_push")
@TableName(value = "oper_inquire_supplier_push", autoResultMap = true)
@KeySequence("oper_inquire_supplier_push_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
......
......@@ -51,5 +51,10 @@ public class ScoringWeightDO extends BaseDO {
*/
private Integer sort;
/**
* web端是否展示
*/
private Boolean webDisplay;
}
\ No newline at end of file
......@@ -21,10 +21,7 @@ public interface InquirePriceMapper extends BaseMapperX<InquirePriceDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<InquirePriceDO>()
.likeIfPresent(InquirePriceDO::getInquiryName, reqVO.getInquiryName())
.eqIfPresent(InquirePriceDO::getInquiryYearMonth, reqVO.getInquiryYearMonth())
.eqIfPresent(InquirePriceDO::getCustomerId, reqVO.getCustomerId())
.likeIfPresent(InquirePriceDO::getCustomerName, reqVO.getCustomerName())
.eqIfPresent(InquirePriceDO::getIsPush, reqVO.getIsPush())
.eqIfPresent(InquirePriceDO::getPushCustomerInfo, reqVO.getPushCustomerInfo())
.betweenIfPresent(InquirePriceDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(InquirePriceDO::getCreator, reqVO.getCreator())
.orderByDesc(InquirePriceDO::getId));
......
......@@ -25,6 +25,7 @@ public interface ScoringWeightMapper extends BaseMapperX<ScoringWeightDO> {
.eqIfPresent(ScoringWeightDO::getUserSystem, reqVO.getUserSystem())
.eqIfPresent(ScoringWeightDO::getSort, reqVO.getSort())
.betweenIfPresent(ScoringWeightDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(ScoringWeightDO::getWebDisplay, reqVO.getWebDisplay())
.orderByDesc(ScoringWeightDO::getId));
}
......
......@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.operations.service.inquirecustomerpush;
import java.util.*;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.operations.controller.app.inquirecustomerpush.vo.AppInquireCustomerPushPageReqVO;
import cn.iocoder.foodnexus.module.operations.controller.app.inquirecustomerpush.vo.AppInquireCustomerPushRespVO;
import jakarta.validation.*;
......@@ -82,4 +83,8 @@ public interface InquireCustomerPushService {
* @return
*/
PageResult<AppInquireCustomerPushRespVO> getAppInquireCustomerPushPage(AppInquireCustomerPushPageReqVO pageReqVO);
List<ErpCustomerSimpleRespVO> getSimpCustomer(Long inquireId);
Map<Long, List<ErpCustomerSimpleRespVO>> getSimpCustomerMap(Collection<Long> inquireIds);
}
\ No newline at end of file
......@@ -2,9 +2,13 @@ package cn.iocoder.foodnexus.module.operations.service.inquirecustomerpush;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.controller.admin.sale.vo.customer.ErpCustomerSimpleRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.erp.dal.mysql.sale.ErpCustomerMapper;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.inquirepriceitem.InquirePriceItemDO;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.inquiresupplierpush.InquireSupplierPushDO;
import cn.iocoder.foodnexus.module.operations.dal.mysql.inquiresupplierpush.InquireSupplierPushMapper;
import cn.iocoder.foodnexus.module.order.api.OrderScoreApi;
import cn.iocoder.foodnexus.module.product.api.dto.CustomerVisibleProductRespDTO;
import cn.iocoder.foodnexus.module.operations.controller.app.inquirecustomerpush.vo.AppInquireCustomerPushPageReqVO;
import cn.iocoder.foodnexus.module.operations.controller.app.inquirecustomerpush.vo.AppInquireCustomerPushRespVO;
......@@ -46,6 +50,12 @@ public class InquireCustomerPushServiceImpl implements InquireCustomerPushServic
@Autowired
private InquireSupplierPushMapper supplierPushMapper;
@Autowired
private ErpCustomerMapper customerMapper;
@Autowired
private OrderScoreApi orderScoreApi;
@Override
public Long createInquireCustomerPush(InquireCustomerPushSaveReqVO createReqVO) {
// 插入
......@@ -123,6 +133,35 @@ public class InquireCustomerPushServiceImpl implements InquireCustomerPushServic
return inquireCustomerPushMapper.selectPage(pageReqVO);
}
@Override
public List<ErpCustomerSimpleRespVO> getSimpCustomer(Long inquireId) {
List<InquireCustomerPushDO> inquireCustomerPushDOS = inquireCustomerPushMapper.selectList(InquireCustomerPushDO::getInquirePriceId, inquireId);
return CommonUtil.listConvert(inquireCustomerPushDOS, item -> {
ErpCustomerDO customer = customerMapper.selectOne(Wrappers.<ErpCustomerDO>lambdaQuery()
.select(ErpCustomerDO::getId, ErpCustomerDO::getName)
.eq(ErpCustomerDO::getId, item.getCustomerId()));
return BeanUtils.toBean(customer, ErpCustomerSimpleRespVO.class, i -> i.setConfirm(item.getConfirm()));
});
}
@Override
public Map<Long, List<ErpCustomerSimpleRespVO>> getSimpCustomerMap(Collection<Long> inquireIds) {
if (CommonUtil.isEmpty(inquireIds)) {
return new HashMap<>();
}
List<InquireCustomerPushDO> inquireCustomerPushDOS = inquireCustomerPushMapper.selectList(Wrappers.<InquireCustomerPushDO>lambdaQuery()
.in(InquireCustomerPushDO::getInquirePriceId, inquireIds));
if (CommonUtil.isEmpty(inquireCustomerPushDOS)) {
return new HashMap<>();
}
return CommonUtil.listConvertListMap(inquireCustomerPushDOS, InquireCustomerPushDO::getInquirePriceId, item -> {
ErpCustomerDO customer = customerMapper.selectOne(Wrappers.<ErpCustomerDO>lambdaQuery()
.select(ErpCustomerDO::getId, ErpCustomerDO::getName)
.eq(ErpCustomerDO::getId, item.getCustomerId()));
return BeanUtils.toBean(customer, ErpCustomerSimpleRespVO.class, i -> i.setConfirm(item.getConfirm()));
});
}
@Override
@Cacheable(cacheNames = RedisKeyConstants.CUSTOMER_VISIBLE_PRODUCT, key = "#customerId", unless = "#result == null")
......@@ -155,7 +194,9 @@ public class InquireCustomerPushServiceImpl implements InquireCustomerPushServic
supplierProductMap.forEach((productId, list) -> {
// TODO 根据供应商评分排序等....
if (CommonUtil.isNotEmpty(list)) {
InquireSupplierPushDO push = list.get(0);
// InquireSupplierPushDO push = list.get(0);
Long topRankSupplierId = orderScoreApi.queryTopSupplierRank(CommonUtil.listConvert(list, InquireSupplierPushDO::getSupplierId));
InquireSupplierPushDO push = list.stream().filter(i -> i.getSupplierId().equals(topRankSupplierId)).findFirst().get();
InquirePriceItemDO inquirePriceItemDO = inquirePriceMap.get(push.getInquirePriceItemId());
dto.put(push.getId(), push.getProductId(), push.getSupplierQuote(), inquirePriceItemDO.getMarketPrice(), inquirePriceItemDO.getFloatingRate());
}
......
......@@ -108,9 +108,9 @@ public class InquireSupplierPushServiceImpl implements InquireSupplierPushServic
return ;
}
Map<Long, Integer> itemsMap = CommonUtil.listConvertMap(updateReqVO.getItems(),
/*Map<Long, Integer> itemsMap = CommonUtil.listConvertMap(updateReqVO.getItems(),
AppInquireSupplierPushConfirmReqVO.Item::getProductId,
AppInquireSupplierPushConfirmReqVO.Item::getSupplierQuote);
AppInquireSupplierPushConfirmReqVO.Item::getSupplierQuote);*/
// 更新数据
List<InquireSupplierPushDO> updateBatch = CommonUtil.listConvert(inquireSupplierPushDOS, push -> {
......@@ -119,12 +119,12 @@ public class InquireSupplierPushServiceImpl implements InquireSupplierPushServic
update.setConfirm(Boolean.TRUE);
update.setConfirmUser(SecurityFrameworkUtils.getLoginUserId());
update.setConfirmTime(LocalDateTime.now());
if (itemsMap.containsKey(push.getProductId())) {
/*if (itemsMap.containsKey(push.getProductId())) {
update.setSupplierQuote(itemsMap.get(push.getProductId()));
} else {
update.setSupplierQuote(Optional.ofNullable(inquirePriceItemService.getInquirePriceItem(push.getInquirePriceItemId()))
.map(InquirePriceItemDO::getFloatingPrice).orElse(null));
}
}*/
return update;
});
......
......@@ -9,6 +9,7 @@ import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.util.*;
import cn.iocoder.foodnexus.module.operations.controller.admin.scoringweight.vo.*;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.scoringweight.ScoringWeightDO;
......@@ -109,10 +110,13 @@ public class ScoringWeightServiceImpl implements ScoringWeightService {
throw exception(SCORING_WEIGHT_WEIGHTRATIO_ERROR);
}
List<ScoringWeightDO> scoringWeightDOS = CommonUtil.listConvert(reqVO.getEditItems(), item -> {
List<ScoringWeightDO> allData = scoringWeightMapper.selectList();
Map<Long, BigDecimal> itemMap = CommonUtil.listConvertMap(reqVO.getEditItems(), ScoringWeightEditReqVO.EditItems::getId, ScoringWeightEditReqVO.EditItems::getWeightRatio);
List<ScoringWeightDO> scoringWeightDOS = CommonUtil.listConvert(allData, data -> {
ScoringWeightDO scoringWeightDO = new ScoringWeightDO();
scoringWeightDO.setId(item.getId());
scoringWeightDO.setWeightRatio(item.getWeightRatio());
scoringWeightDO.setId(data.getId());
scoringWeightDO.setWeightRatio(itemMap.getOrDefault(data.getId(), BigDecimal.ZERO));
return scoringWeightDO;
});
scoringWeightMapper.updateBatch(scoringWeightDOS);
......@@ -121,6 +125,7 @@ public class ScoringWeightServiceImpl implements ScoringWeightService {
@Override
public List<ScoringWeightDO> listAll() {
return scoringWeightMapper.selectList(Wrappers.<ScoringWeightDO>lambdaQuery()
.eq(ScoringWeightDO::getWebDisplay, Boolean.TRUE)
.orderByAsc(ScoringWeightDO::getSort));
}
......
package cn.iocoder.foodnexus.module.order.api;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* @author : yanghao
* create at: 2025/11/3 10:50
* @description:
*/
public interface OrderScoreApi {
Long queryTopSupplierRank(List<Long> longs);
}
package cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo;
import cn.iocoder.foodnexus.framework.common.validation.InEnum;
import cn.iocoder.foodnexus.module.order.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
......
......@@ -45,4 +45,16 @@ public class CheckTaskPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "商品名称")
private String productName;
@Schema(description = "供应商名称")
private String supplierName;
@Schema(description = "采购订单编号")
private String purchaseOrderNo;
@Schema(description = "客户名称")
private String customerName;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo.CustomerOrderReconPageRespVO;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.foodnexus.framework.common.pojo.CommonResult.success;
/**
* @author : yanghao
* create at: 2025/11/3 16:16
* @description: 管理后台 - 客户对账
*/
@RestController
@RequestMapping("/oper/customr-order/reconciliation")
@Validated
public class OperCustomerOrderReconciliationController {
@Autowired
private CustomerOrderService customerOrderService;
@GetMapping("/page")
@Operation(summary = "分页获取月度账单")
public CommonResult<PageResult<CustomerOrderReconPageRespVO>> page(@Valid CustomerOrderReconPageReqVO pageReqVO) {
return success(customerOrderService.pageReconciliation(pageReqVO));
}
}
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author : yanghao
* create at: 2025/11/3 16:25
* @description:
*/
@Data
public class CustomerOrderReconPageReqVO extends PageParam {
@Schema(description = "对账月度")
private String yearMonth;
@Schema(description = "客户名称")
private String customerName;
}
package cn.iocoder.foodnexus.module.order.controller.admin.customerorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author : yanghao
* create at: 2025/11/3 16:19
* @description:
*/
@Data
public class CustomerOrderReconPageRespVO {
@Schema(description = "对账月度")
private String yearMonth;
@Schema(description = "客户id")
private Long customerId;
@Schema(description = "客户名称")
private String customerName;
@Schema(description = "订单总数")
private Long orderCount;
@Schema(description = "订单总金额(单位:分)")
private Integer orderAmount;
@Schema(description = "应对账总金额(单位:分)")
private Integer actualAmount;
@Schema(description = "对账状态")
private Boolean isFinish;
}
......@@ -45,6 +45,13 @@ public class OrderScoreController {
return success(scoreService.supplierPage(pageReqVO));
}
@GetMapping("/customer/get-by-customer-order-id")
@Operation(summary = "根据客户订单id查询对应评价")
@Parameter(name = "customerOrderId", description = "编号", required = true)
public CommonResult<List<OrderScoreRespVO>> getByCustomerOrderId(@RequestParam("customerOrderId") Long customerOrderId) {
return success(BeanUtils.toBean(scoreService.listByOrderId(customerOrderId), OrderScoreRespVO.class));
}
/*@PostMapping("/create")
@Operation(summary = "创建订单评价")
@PreAuthorize("@ss.hasPermission('order:score:create')")
......
......@@ -7,6 +7,7 @@ import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.foodnexus.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
......@@ -36,4 +37,7 @@ public class OrderScoreSupplierPageReqVO extends PageParam {
@Schema(description = "统一社会信用代码")
private String unifiedSocialCreditCode;
@Schema(description = "ids")
private List<Long> idList;
}
\ No newline at end of file
package cn.iocoder.foodnexus.module.order.dal.dataobject.checktask;
import cn.iocoder.foodnexus.module.order.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.foodnexus.framework.mybatis.core.dataobject.BaseDO;
......
......@@ -3,9 +3,15 @@ package cn.iocoder.foodnexus.module.order.dal.mysql.checktask;
import java.util.*;
import cn.iocoder.foodnexus.framework.common.pojo.PageResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.foodnexus.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.foodnexus.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.checktask.CheckTaskDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.checktaskitems.CheckTaskItemsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.*;
......@@ -18,7 +24,7 @@ import cn.iocoder.foodnexus.module.order.controller.admin.checktask.vo.*;
public interface CheckTaskMapper extends BaseMapperX<CheckTaskDO> {
default PageResult<CheckTaskDO> selectPage(CheckTaskPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CheckTaskDO>()
MPJLambdaWrapperX<CheckTaskDO> wrapper = new MPJLambdaWrapperX<CheckTaskDO>()
.eqIfPresent(CheckTaskDO::getNo, reqVO.getNo())
.eqIfPresent(CheckTaskDO::getStatus, reqVO.getStatus())
.eqIfPresent(CheckTaskDO::getSupplierId, reqVO.getSupplierId())
......@@ -29,7 +35,28 @@ public interface CheckTaskMapper extends BaseMapperX<CheckTaskDO> {
.eqIfPresent(CheckTaskDO::getRemark, reqVO.getRemark())
.eqIfPresent(CheckTaskDO::getFiles, reqVO.getFiles())
.betweenIfPresent(CheckTaskDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(CheckTaskDO::getId));
.orderByDesc(CheckTaskDO::getId);
if (CommonUtil.isNotBlank(reqVO.getProductName())) {
wrapper.leftJoin(CheckTaskItemsDO.class, CheckTaskItemsDO::getCheckTaskId, CheckTaskDO::getId);
wrapper.like(CheckTaskItemsDO::getProductName, reqVO.getProductName());
wrapper.groupBy(CheckTaskDO::getId);
}
if (CommonUtil.isNotBlank(reqVO.getSupplierName())) {
wrapper.leftJoin(ErpSupplierDO.class, ErpSupplierDO::getId, CheckTaskDO::getSupplierId);
wrapper.like(ErpSupplierDO::getName, reqVO.getSupplierName());
wrapper.groupBy(CheckTaskDO::getId);
}
if (CommonUtil.isNotBlank(reqVO.getCustomerName())) {
wrapper.leftJoin(ErpCustomerDO.class, ErpCustomerDO::getId, CheckTaskDO::getCustomerId);
wrapper.like(ErpCustomerDO::getName, reqVO.getCustomerName());
wrapper.groupBy(CheckTaskDO::getId);
}
if (CommonUtil.isNotBlank(reqVO.getPurchaseOrderNo())) {
wrapper.leftJoin(ErpPurchaseOrderDO.class, ErpPurchaseOrderDO::getId, CheckTaskDO::getPurchaseOrderId);
wrapper.like(ErpPurchaseOrderDO::getNo, reqVO.getPurchaseOrderNo());
wrapper.groupBy(CheckTaskDO::getId);
}
return selectPage(reqVO, wrapper);
}
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ import cn.iocoder.foodnexus.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.foodnexus.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.foodnexus.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.sale.ErpSaleOrderDO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderRespVO;
import cn.iocoder.foodnexus.module.order.controller.app.customerOrder.vo.AppCustomerMonthOrderTotalRespVO;
......@@ -131,4 +133,34 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.orderByDesc("id");
return this.selectJoinOne(AppCustomerMonthOrderTotalRespVO.class, queryWrapperX);
}
default PageResult<CustomerOrderReconPageRespVO> pageReconciliation(CustomerOrderReconPageReqVO pageReqVO) {
MPJLambdaWrapperX<CustomerOrderDO> wrapperX = new MPJLambdaWrapperX<>();
wrapperX.rightJoin(ErpCustomerDO.class, ErpCustomerDO::getId, CustomerOrderDO::getCustomerId);
wrapperX.select("DATE_FORMAT( t.create_time, '%Y-%m' ) AS 'yearMonth'");
wrapperX.select("t1.id AS 'customerId'");
wrapperX.select("t1.NAME AS 'customerName'");
wrapperX.select("count(t.id) as 'orderCount'");
wrapperX.select("IFNULL(SUM(t.order_amount),0) as 'orderAmount'");
wrapperX.select("IFNULL(sum(t.actual_amount),0) as 'actualAmount'");
wrapperX.select("CASE WHEN SUM(CASE WHEN t.order_status='SIGN_RECEIPT' THEN 1 ELSE 0 END)> 0 THEN 0 ELSE 1 END AS 'isFinish'");
wrapperX.in(CustomerOrderDO::getOrderStatus, CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey()));
wrapperX.likeIfPresent(ErpCustomerDO::getName, pageReqVO.getCustomerName());
if (CommonUtil.isNotBlank(pageReqVO.getYearMonth())) {
String createMonth = pageReqVO.getYearMonth().trim();
String startOfMonth = createMonth + "-01 00:00:00";
String[] parts = createMonth.split("-");
int year = Integer.parseInt(parts[0]);
int nextMonth = Integer.parseInt(parts[1]) + 1;
String endOfMonth = nextMonth > 12 ?
(year + 1) + "-01-01 00:00:00" :
year + "-" + (nextMonth < 10 ? "0" + nextMonth : nextMonth) + "-01 00:00:00";
wrapperX.between(CustomerOrderDO::getCreateTime, startOfMonth, endOfMonth);
}
wrapperX.groupBy("DATE_FORMAT( t.create_time, '%Y-%m' )", "t1.id");
wrapperX.orderByDesc("DATE_FORMAT( t.create_time, '%Y-%m' )", "t1.id");
return this.selectJoinPage(pageReqVO, CustomerOrderReconPageRespVO.class, wrapperX);
}
}
\ No newline at end of file
......@@ -37,6 +37,8 @@ public interface ErrorCodeConstants {
ErrorCode CHECK_TASK_CREATE_ERROR = new ErrorCode(1_023_100_002, "来料质检新增失败");
ErrorCode CHECK_TASK_STATUS_ERROR = new ErrorCode(1_023_100_003, "来料质检已质检");
ErrorCode CHECK_TASK_TO_BE_CHECK = new ErrorCode(1_023_100_003, "请先完成质检");
ErrorCode CHECK_TASK_PURCHASE_ORDER_NOT_EXISTS = new ErrorCode(1_023_100_004, "关联采购订单不存在");
ErrorCode CHECK_TASK_PURCHASE_ORDER_STATUS_ERROR = new ErrorCode(1_023_100_005, "关联采购订单未到货");
// ========== 订单评价 1_024_100_001 ==========
ErrorCode SCORE_NOT_EXISTS = new ErrorCode(1_024_100_001, "订单评价不存在");
......
......@@ -2,13 +2,14 @@ package cn.iocoder.foodnexus.module.order.service.checktask;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.framework.common.util.spring.SpringUtils;
import cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.foodnexus.module.erp.api.PurchaseOrderSplitEvent;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.erp.api.vo.warehouse.WarehouseInfo;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO;
import cn.iocoder.foodnexus.module.erp.dal.mysql.purchase.ErpPurchaseOrderMapper;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseInService;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpPurchaseOrderService;
import cn.iocoder.foodnexus.module.erp.service.sale.ErpSaleOrderService;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.scoringweight.ScoringWeightDO;
......@@ -18,11 +19,9 @@ import cn.iocoder.foodnexus.module.order.api.CustomerOrderRecordApi;
import cn.iocoder.foodnexus.module.order.controller.admin.orderScore.vo.OrderScoreSaveReqVO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.checktaskitems.CheckTaskItemsDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorderitem.CustomerOrderItemDO;
import cn.iocoder.foodnexus.module.order.dal.mysql.checktaskitems.CheckTaskItemsMapper;
import cn.iocoder.foodnexus.module.order.dto.CheckTaskCreateEvent;
import cn.iocoder.foodnexus.module.order.dto.CustomerOrderRecordEvent;
import cn.iocoder.foodnexus.module.order.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.framework.common.enums.CheckTaskStatus;
import cn.iocoder.foodnexus.module.order.enums.CustomerOrderStatus;
import cn.iocoder.foodnexus.module.order.service.checktaskitems.CheckTaskItemsService;
import cn.iocoder.foodnexus.module.order.service.customerorder.CustomerOrderService;
......@@ -33,15 +32,12 @@ import cn.iocoder.foodnexus.module.product.service.spu.ProductSpuService;
import cn.iocoder.foodnexus.module.system.util.GenCodeUtils;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
......@@ -108,6 +104,9 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
@Autowired
private OrderScoreService orderScoreService;
@Autowired
private ErpPurchaseInService purchaseInService;
@Autowired
private GenCodeUtils genCodeUtils;
......@@ -181,10 +180,24 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
if (checkTaskDO == null) {
throw exception(CHECK_TASK_NOT_EXISTS);
}
if (!CheckTaskStatus.TO_BE_CHECK.getKey().equals(checkTaskDO.getStatus())) {
if (CheckTaskStatus.NORMAL.getKey().equals(checkTaskDO.getStatus())) {
throw exception(CHECK_TASK_STATUS_ERROR);
}
ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(checkTaskDO.getPurchaseOrderId());
if (CommonUtil.isEmpty(purchaseOrder)) {
throw exception(CHECK_TASK_PURCHASE_ORDER_NOT_EXISTS);
}
if (!Objects.equals(purchaseOrder.getDeliveryStatus(), ErpDeliveryStatus.ARRIVAL.getStatus())) {
throw exception(CHECK_TASK_PURCHASE_ORDER_NOT_EXISTS);
}
if (CheckTaskStatus.NORMAL.getKey().equals(updateReqVO.getStatus())) {
purchaseOrderMapper.update(Wrappers.<ErpPurchaseOrderDO>lambdaUpdate()
.set(ErpPurchaseOrderDO::getCheckTaskStatus, CheckTaskStatus.NORMAL.getKey())
.eq(ErpPurchaseOrderDO::getId, purchaseOrder.getId()));
}
LambdaUpdateWrapper<CheckTaskDO> updateWrapper = Wrappers.<CheckTaskDO>lambdaUpdate()
.set(CheckTaskDO::getRemark, updateReqVO.getRemark())
.set(CheckTaskDO::getFiles, updateReqVO.getFiles())
......@@ -221,6 +234,12 @@ public class CheckTaskServiceImpl implements CheckTaskService, CheckTaskApi {
event.setCustomerOrderId(checkTaskDO.getCustomerOrderId());
event.setCopyWriter(CommonUtil.asList(warehouseName, updateReqVO.getFiles()));
orderRecordApi.recordEvent(event);
// 采购入库审核成功
purchaseInService.updatePurchaseInStatusByPurchaseOrderId(checkTaskDO.getPurchaseOrderId(), ErpAuditStatus.APPROVE);
} else if (CheckTaskStatus.ABNORMAL.getKey().equals(updateReqVO.getStatus())) {
purchaseOrderService.abnormalPurchaseOrder(checkTaskDO.getPurchaseOrderId());
}
if (CommonUtil.isNotEmpty(updateReqVO.getScore())) {
......
......@@ -144,4 +144,6 @@ public interface CustomerOrderService {
* @return
*/
AppCustomerOrderReturnRespVO queryReturn(Long id);
PageResult<CustomerOrderReconPageRespVO> pageReconciliation(CustomerOrderReconPageReqVO pageReqVO);
}
\ No newline at end of file
......@@ -296,7 +296,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
CustomerOrderRecordEvent event = new CustomerOrderRecordEvent();
event.setOrderStatus(CustomerOrderStatus.ORDER_SUCCESS);
event.setCustomerOrderId(customerOrderId);
event.setCopyWriter(CommonUtil.asList(String.valueOf(createOrder.getOrderAmount()),
event.setCopyWriter(CommonUtil.asList(String.valueOf((double) createOrder.getOrderAmount() / 100),
String.valueOf(createOrder.getProductCount())));
orderRecordApi.recordEvent(event);
} finally {
......@@ -355,7 +355,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
// 标记销售订单状态取消
saleOrderMapper.update(Wrappers.<ErpSaleOrderDO>lambdaUpdate()
.eq(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.CANCEL.getType())
.set(ErpSaleOrderDO::getPickUpStatus, SaleOrderPickUpStatus.CANCEL.getType())
.eq(ErpSaleOrderDO::getCustomerOrderId, customerOrder.getId()));
// 订单记录
......@@ -741,6 +741,11 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
return result;
}
@Override
public PageResult<CustomerOrderReconPageRespVO> pageReconciliation(CustomerOrderReconPageReqVO pageReqVO) {
return customerOrderMapper.pageReconciliation(pageReqVO);
}
private List<AppCustomerOrderReturnRespVO.ReturnsRecords> transform(ErpSaleReturnDO saleReturn) {
return Arrays.stream(SaleOrderPickUpStatus.values()).filter(SaleOrderPickUpStatus::isReturns).map(em -> {
AppCustomerOrderReturnRespVO.ReturnsRecords returnsRecords = new AppCustomerOrderReturnRespVO.ReturnsRecords();
......
......@@ -2,15 +2,18 @@ package cn.iocoder.foodnexus.module.order.service.orderScore;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.foodnexus.framework.common.enums.CommonStatusEnum;
import cn.iocoder.foodnexus.framework.common.enums.UserSystemEnum;
import cn.iocoder.foodnexus.framework.common.pojo.CommonResult;
import cn.iocoder.foodnexus.framework.common.util.CommonUtil;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpAuditStatus;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO;
import cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSimpleRespVO;
import cn.iocoder.foodnexus.module.erp.dal.dataobject.purchase.ErpSupplierDO;
import cn.iocoder.foodnexus.module.erp.service.purchase.ErpSupplierService;
import cn.iocoder.foodnexus.module.operations.dal.dataobject.scoringweight.ScoringWeightDO;
import cn.iocoder.foodnexus.module.operations.service.scoringweight.ScoringWeightService;
import cn.iocoder.foodnexus.module.order.api.OrderScoreApi;
import cn.iocoder.foodnexus.module.order.dal.dataobject.customerorder.CustomerOrderDO;
import cn.iocoder.foodnexus.module.order.dal.mysql.customerorder.CustomerOrderMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
......@@ -36,6 +40,7 @@ import cn.iocoder.foodnexus.framework.common.util.object.BeanUtils;
import cn.iocoder.foodnexus.module.order.dal.mysql.orderScore.OrderScoreMapper;
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.diffList;
import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*;
......@@ -47,7 +52,7 @@ import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*;
*/
@Service
@Validated
public class OrderScoreServiceImpl implements OrderScoreService {
public class OrderScoreServiceImpl implements OrderScoreService, OrderScoreApi {
@Resource
private OrderScoreMapper scoreMapper;
......@@ -128,7 +133,10 @@ public class OrderScoreServiceImpl implements OrderScoreService {
@Override
public PageResult<OrderScoreSupplierRespVO> supplierPage(OrderScoreSupplierPageReqVO pageReqVO) {
PageResult<ErpSupplierDO> supplierPage = supplierService.getSupplierPage(BeanUtils.toBean(pageReqVO, ErpSupplierPageReqVO.class));
ErpSupplierPageReqVO supplierPageReqVO = BeanUtils.toBean(pageReqVO, ErpSupplierPageReqVO.class);
supplierPageReqVO.setAuditStatus(ErpAuditStatus.APPROVE.getStatus().toString());
// supplierPageReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
PageResult<ErpSupplierDO> supplierPage = supplierService.getSupplierPage(supplierPageReqVO);
if (CommonUtil.isNotEmpty(supplierPage.getList())) {
Map<Long, ErpSupplierDO> supplierMap = CommonUtil.listConvertMap(supplierPage.getList(), ErpSupplierDO::getId);
List<ScoringWeightDO> scoringWeightDOS = scoringWeightService.listAll();
......@@ -163,18 +171,22 @@ public class OrderScoreServiceImpl implements OrderScoreService {
for (Map.Entry<Long, ScoringWeightDO> entry : scoringWeightMap.entrySet()) {
Long scoreId = entry.getKey();
ScoringWeightDO scoreInfo = entry.getValue();
OrderScoreSupplierRespVO.ScoreItems scoreItem = new OrderScoreSupplierRespVO.ScoreItems();
List<OrderScoreDO> supplierScores = scoreSupplierMap.get(scoreId);
if (CommonUtil.isNotEmpty(supplierScores)) {
scoreItem.setAllScore(supplierScores.stream().mapToInt(OrderScoreDO::getScore).sum());
scoreItem.setScoreCount(supplierScores.size());
scoreItem.setScore(this.divideInts(scoreItem.getAllScore(), scoreItem.getScoreCount()));
}
scoreItem.setScoreId(scoreId);
scoreItem.setScoreName(scoreInfo.getScoreName() + "(" + UserSystemEnum.getByKey(scoreInfo.getUserSystem()).getLabel() + ")");
items.add(scoreItem);
if (CommonUtil.isNotEmpty(scoreItem.getScore()) && scoreInfo.getWeightRatio().compareTo(BigDecimal.ZERO) > 0) {
finalScore = finalScore.add(this.calculate(scoreItem.getScore(), scoreInfo.getWeightRatio()));
if (scoreId == 100L) {
finalScore = finalScore.add(this.calculate(BigDecimal.valueOf(Optional.ofNullable(supplierInfo.getAuditScore()).orElse(0)), scoreInfo.getWeightRatio()));
} else {
OrderScoreSupplierRespVO.ScoreItems scoreItem = new OrderScoreSupplierRespVO.ScoreItems();
List<OrderScoreDO> supplierScores = scoreSupplierMap.get(scoreId);
if (CommonUtil.isNotEmpty(supplierScores)) {
scoreItem.setAllScore(supplierScores.stream().mapToInt(OrderScoreDO::getScore).sum());
scoreItem.setScoreCount(supplierScores.size());
scoreItem.setScore(this.divideInts(scoreItem.getAllScore(), scoreItem.getScoreCount()));
}
scoreItem.setScoreId(scoreId);
scoreItem.setScoreName(scoreInfo.getScoreName() + "(" + UserSystemEnum.getByKey(scoreInfo.getUserSystem()).getLabel() + ")");
items.add(scoreItem);
if (CommonUtil.isNotEmpty(scoreItem.getScore()) && scoreInfo.getWeightRatio().compareTo(BigDecimal.ZERO) > 0) {
finalScore = finalScore.add(this.calculate(scoreItem.getScore(), scoreInfo.getWeightRatio()));
}
}
}
orderScoreSupplier.setScoreItems(items);
......@@ -186,6 +198,28 @@ public class OrderScoreServiceImpl implements OrderScoreService {
return null;
}
@Override
public Long queryTopSupplierRank(List<Long> ids) {
OrderScoreSupplierPageReqVO reqVO = new OrderScoreSupplierPageReqVO();
reqVO.setIdList(ids);
LocalDate today = LocalDate.now();
int year = today.getYear();
reqVO.setYear(String.valueOf(year));
reqVO.setPageNo(1);
reqVO.setPageSize(PAGE_SIZE_NONE);
PageResult<OrderScoreSupplierRespVO> result = this.supplierPage(reqVO);
if (CommonUtil.isEmpty(result) || CommonUtil.isEmpty(result.getList())) {
return ids.get(0);
} else {
List<OrderScoreSupplierRespVO> list = result.getList();
// 按 finalScore 降序排序
list.sort((s1, s2) ->
s2.getFinalScore().compareTo(s1.getFinalScore()));
return list.get(0).getSupplierId();
}
}
@Override
public List<OrderScoreDO> listByOrderId(Long id) {
return scoreMapper.selectList(OrderScoreDO::getOrderId, id);
......
......@@ -97,5 +97,5 @@ public interface ProductCategoryService {
.map(ProductCategoryDO::getName).orElse("");
}
Map<Long, String> getMap(Set<Long> productIds);
Map<Long, String> getMap(Collection<Long> categoryIds);
}
......@@ -128,7 +128,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
}
@Override
public Map<Long, String> getMap(Set<Long> ids) {
public Map<Long, String> getMap(Collection<Long> ids) {
if (CommonUtil.isEmpty(ids)) {
return new HashMap<>(1);
}
......
......@@ -112,7 +112,7 @@ public interface RedisKeyConstants {
* KEY:{customerId}
* VALUE 客户id
*/
String CUSTOMER_VISIBLE_PRODUCT = "customer_visible_products";
String CUSTOMER_VISIBLE_PRODUCT = "customer_visible_products_1";
/**
* 用户绑定的配送员id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment