Commit f86e3c65 by 杨浩

bug调整

parent cc58b6b0
......@@ -154,6 +154,7 @@ public class ErpSaleOrderController {
if (CommonUtil.isNotEmpty(saleOrderVO.getDeliveryStaffId())) {
saleOrderVO.setDeliveryStaffInfo(deliveryStaffApi.querybyStaffId(saleOrderVO.getDeliveryStaffId()));
}
saleOrderVO.setCustomerName(Optional.ofNullable(customerService.getCustomer(saleOrderVO.getCustomerId())).map(ErpCustomerDO::getName).orElse(""));
saleOrderVO.setItems(BeanUtils.toBean(saleOrderItemList, ErpSaleOrderRespVO.Item.class, item -> {
MapUtils.findAndThen(supplierMap, item.getSupplierId(), item::setSupplierName);
MapUtils.findAndThen(purchaseOrderMap, item.getPurchaseOrderId(), purchaseOrder ->
......
......@@ -163,4 +163,5 @@ public interface ErpSaleOrderService {
*/
List<DeliveryStatusCountRespVO> statusCount(Long userId, Set<Long> deptIds);
void update(ErpSaleOrderDO updateSaleOrder, List<ErpSaleOrderItemDO> updateSaleOrderItems);
}
\ No newline at end of file
......@@ -700,4 +700,16 @@ public class ErpSaleOrderServiceImpl implements ErpSaleOrderService {
return result;
}
@Override
public void update(ErpSaleOrderDO updateSaleOrder, List<ErpSaleOrderItemDO> updateSaleOrderItems) {
saleOrderMapper.updateById(updateSaleOrder);
if (CommonUtil.isNotEmpty(updateSaleOrderItems)) {
saleOrderItemMapper.updateBatch(updateSaleOrderItems);
} else {
saleOrderItemMapper.update(Wrappers.<ErpSaleOrderItemDO>lambdaUpdate()
.set(ErpSaleOrderItemDO::getPickUpStatus, updateSaleOrder.getPickUpStatus())
.eq(ErpSaleOrderItemDO::getOrderId, updateSaleOrder.getId()));
}
}
}
......@@ -105,9 +105,9 @@ public interface ErpSaleReturnService {
*/
ErpSaleReturnDO queryByCustomerOrderId(Long id);
void accept(Long id, Long deliveryStaffId);
void accept(Long saleOrderId, Long deliveryStaffId);
void delivery(Long id, Long deliveryStaffId);
void delivery(Long saleOrderId, Long deliveryStaffId);
void arrival(DeliveryOrderUpdateReqVO reqVO, Long aLong);
......
......@@ -257,6 +257,12 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
customerOrderApi.updateActualAmount(saleReturn.getCustomerOrderId(), - returnsTotal);
customerOrderApi.updateItems(updateItems);
// 销售订单状态变更
ErpSaleOrderDO updateSaleOrder = new ErpSaleOrderDO();
updateSaleOrder.setId(saleReturn.getOrderId());
updateSaleOrder.setPickUpStatus(RETURNS_APPROVE);
saleOrderService.update(updateSaleOrder, null);
// TODO 退款确认后才进行库存变更
/*Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_RETURN.getType()
: ErpStockRecordBizTypeEnum.SALE_RETURN_CANCEL.getType();
......@@ -419,6 +425,19 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
return saleReturn;
}
private ErpSaleReturnDO validateBySaleOrderId(Long saleOrderId) {
ErpSaleReturnDO saleReturn = saleReturnMapper.selectOne(Wrappers.<ErpSaleReturnDO>lambdaQuery()
.eq(ErpSaleReturnDO::getOrderId, saleOrderId)
.last("LIMIT 1"));
if (saleReturn == null) {
throw exception(SALE_RETURN_NOT_EXISTS);
}
if (ObjectUtil.notEqual(saleReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) {
throw exception(SALE_RETURN_NOT_APPROVE);
}
return saleReturn;
}
@Override
public PageResult<ErpSaleReturnDO> getSaleReturnPage(ErpSaleReturnPageReqVO pageReqVO) {
return saleReturnMapper.selectPage(pageReqVO);
......@@ -454,9 +473,9 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
@Override
@Transactional(rollbackFor = Exception.class)
public void accept(Long id, Long deliveryStaffId) {
ErpSaleReturnDO saleReturn = validateSaleReturn(id);
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleReturn.getOrderId());
public void accept(Long saleOrderId, Long deliveryStaffId) {
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleOrderId);
ErpSaleReturnDO saleReturn = validateBySaleOrderId(saleOrderId);
if (!saleReturn.getReturnsStatus().equals(RETURNS_APPROVE.getType()) || !saleOrder.getPickUpStatus().equals(RETURNS_APPROVE)) {
throw exception(SALE_ORDER_PICKUP_STATUS_FAIL);
......@@ -490,9 +509,9 @@ public class ErpSaleReturnServiceImpl implements ErpSaleReturnService {
@Override
@Transactional(rollbackFor = Exception.class)
public void delivery(Long id, Long deliveryStaffId) {
ErpSaleReturnDO saleReturn = validateSaleReturn(id);
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleReturn.getOrderId());
public void delivery(Long saleOrderId, Long deliveryStaffId) {
ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(saleOrderId);
ErpSaleReturnDO saleReturn = validateBySaleOrderId(saleOrderId);
if (!saleReturn.getReturnsStatus().equals(RETURNS_STAFF_ACCEPT.getType()) || !saleOrder.getPickUpStatus().equals(RETURNS_STAFF_ACCEPT)) {
throw exception(SALE_ORDER_PICKUP_STATUS_FAIL);
......
......@@ -86,15 +86,16 @@ public class FileTypeUtils {
if (StrUtil.containsIgnoreCase(contentType, "image/")) {
// 参见 https://github.com/YunaiV/ruoyi-vue-pro/issues/692 讨论
response.setHeader("Content-Disposition", "inline;filename=" + HttpUtils.encodeUtf8(filename));
} else {
response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename));
}
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
if (StrUtil.containsIgnoreCase(contentType, "video")) {
}// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
else if (StrUtil.containsIgnoreCase(contentType, "video")) {
response.setHeader("Content-Disposition", "inline;filename=" + HttpUtils.encodeUtf8(filename));
response.setHeader("Content-Length", String.valueOf(content.length));
response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length);
response.setHeader("Accept-Ranges", "bytes");
} else {
response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename));
}
// 输出附件
IoUtil.write(response.getOutputStream(), false, content);
}
......
......@@ -98,9 +98,9 @@ public class SupplierPurchaseOrderController {
purchaseOrder.setPlanDeliveryStartTime(customerOrder.getPlanDeliveryStartTime());
purchaseOrder.setPlanDeliveryEndTime(customerOrder.getPlanDeliveryEndTime());
// TODO 待定
// purchaseOrder.setPayablePrice();
purchaseOrder.setSignedTotal(customerOrderItemDOS.stream().mapToInt(CustomerOrderItemDO::getSignedTotal).sum());
purchaseOrder.setReturnsTotal(customerOrderItemDOS.stream().mapToInt(CustomerOrderItemDO::getReturnsTotal).sum());
purchaseOrder.setPayablePrice(CommonUtil.getEls(purchaseOrder.getSignedTotal(), 0) - CommonUtil.getEls(purchaseOrder.getReturnsTotal(), 0));
purchaseOrder.setSupplierName(customerOrderItemDOS.get(0).getSupplierName());
StringBuilder productNames = new StringBuilder();
......
......@@ -50,9 +50,15 @@ public class AppCustomerOrderReconciliationController {
@GetMapping("/page-year")
@Operation(summary = "分页获取月度账单(按年份)")
public CommonResult<AppCustomerMonthOrderRespVO> pageYear(@Valid AppCustomerYearOrderPageReqVO reqVO) {
reqVO.setDeptIds(customerApi.queryCustomerDeptIdsByUserId(getLoginUserId()));
if (CommonUtil.isEmpty(reqVO.getDeptIds())) {
return success(null);
// reqVO.setDeptIds(customerApi.queryCustomerDeptIdsByUserId(getLoginUserId()));
Pair<Boolean, Set<Long>> pair = customerApi.queryCustomerOrUserByUserId(getLoginUserId());
if (pair.getKey()) {
if (CommonUtil.isEmpty(pair.getValue())) {
return success(null);
}
reqVO.setDeptIds(pair.getValue());
} else {
reqVO.setCreator(getLoginUserId());
}
return success(customerOrderService.reconciliationPageYear(reqVO));
}
......@@ -61,8 +67,17 @@ public class AppCustomerOrderReconciliationController {
@Operation(summary = "分页获取客户订单(按月份)")
@Parameter(name = "yearMonth", description = "年月(yyyy-MM)", required = true)
public CommonResult<AppCustomerMonthOrderTotalRespVO> monthTotal(@RequestParam("yearMonth") String yearMonth) {
Set<Long> deptIds = customerApi.queryCustomerDeptIdsByUserId(getLoginUserId());
return success(customerOrderService.monthTotal(yearMonth, deptIds));
// Set<Long> deptIds = customerApi.queryCustomerDeptIdsByUserId(getLoginUserId());
Pair<Boolean, Set<Long>> pair = customerApi.queryCustomerOrUserByUserId(getLoginUserId());
if (pair.getKey()) {
if (CommonUtil.isEmpty(pair.getValue())) {
return success(null);
}
return success(customerOrderService.monthTotal(yearMonth, pair.getValue(), null));
} else {
return success(customerOrderService.monthTotal(yearMonth, null, getLoginUserId()));
}
}
@PostMapping("/confirm")
......
......@@ -25,6 +25,9 @@ public class AppCustomerYearOrderPageReqVO extends PageParam {
@Schema(description = "客户灶点集合", hidden = true)
private Set<Long> deptIds;
@Schema(description = "用户id", hidden = true)
private Long creator;
/*@Schema(description = "月份(1-12)")
@Max(value = 12, message = "异常月份")
@Min(value = 1, message = "异常月份")
......
......@@ -89,7 +89,7 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
return this.selectMaps(queryWrapper);
}
default AppCustomerMonthOrderRespVO reconciliationPageYearTotal(String year, Set<Long> deptIds) {
default AppCustomerMonthOrderRespVO reconciliationPageYearTotal(String year, Set<Long> deptIds, Long creator) {
year = year.trim();
String begin = year + "-01-01 00:00:00";
String end = year + "-12-31 23:59:59";
......@@ -99,7 +99,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey(),
CustomerOrderStatus.RETURN.getKey()));
queryWrapperX.in("customer_dept_id", deptIds);
queryWrapperX.in(CommonUtil.isNotEmpty(deptIds), "customer_dept_id", deptIds);
queryWrapperX.eq(CommonUtil.isNotEmpty(creator), "creator", creator);
return this.selectJoinOne(AppCustomerMonthOrderRespVO.class, queryWrapperX);
}
......@@ -114,14 +115,15 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey(),
CustomerOrderStatus.RETURN.getKey()));
queryWrapperX.in("customer_dept_id", reqVO.getDeptIds());
queryWrapperX.in(CommonUtil.isNotEmpty(reqVO.getDeptIds()), "customer_dept_id", reqVO.getDeptIds());
queryWrapperX.eq(CommonUtil.isNotEmpty(reqVO.getCreator()), "creator", reqVO.getCreator());
queryWrapperX.groupBy("DATE_FORMAT(create_time, '%Y-%m') ");
queryWrapperX.orderByDesc("id");
return this.selectJoinPage(reqVO, AppCustomerMonthOrderRespVO.MonthItems.class, queryWrapperX);
}
default AppCustomerMonthOrderTotalRespVO reconciliationMonthTotal(String yearMonth, Set<Long> deptIds) {
default AppCustomerMonthOrderTotalRespVO reconciliationMonthTotal(String yearMonth, Set<Long> deptIds, Long creator) {
String createMonth = yearMonth.trim();
String startOfMonth = createMonth + "-01 00:00:00";
String[] parts = createMonth.split("-");
......@@ -137,7 +139,8 @@ public interface CustomerOrderMapper extends BaseMapperX<CustomerOrderDO> {
queryWrapperX.in("order_status", CommonUtil.asList(CustomerOrderStatus.SIGN_RECEIPT.getKey(),
CustomerOrderStatus.FINISH.getKey(),
CustomerOrderStatus.RETURN.getKey()));
queryWrapperX.in("customer_dept_id", deptIds);
queryWrapperX.in(CommonUtil.isNotEmpty(deptIds), "customer_dept_id", deptIds);
queryWrapperX.eq(CommonUtil.isNotEmpty(creator), "creator", creator);
queryWrapperX.orderByDesc("id");
return this.selectJoinOne(AppCustomerMonthOrderTotalRespVO.class, queryWrapperX);
}
......
......@@ -11,6 +11,7 @@ public interface ErrorCodeConstants {
// ========== 购物车 1_018-000-000 ==========
ErrorCode SHOPPING_CART_NOT_EXISTS = new ErrorCode(1_018_100_000, "购物车不存在");
ErrorCode PRODUCT_DISABLE = new ErrorCode(1_018_100_001, "商品【{}】已下架");
ErrorCode PRODUCT_NO_EXISTS = new ErrorCode(1_018_100_002, "商品不存在");
// ========== 客户总订单 1_019_100_0001 ==========
ErrorCode CUSTOMER_ORDER_NOT_EXISTS = new ErrorCode(1_019_100_001, "客户总订单不存在");
......
......@@ -130,7 +130,7 @@ public interface CustomerOrderService {
* @param yearMonth
* @return
*/
AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds);
AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds, Long creator);
/**
* 对账确认
......
......@@ -524,7 +524,14 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnSaveReqVO.setWarehouseInfo(saleOrderDO.getWarehouseInfo());
returnSaveReqVO.setAddressId(saleOrderDO.getAddressId());
returnSaveReqVO.setAddressInfo(saleOrderDO.getAddressInfo());
// 更新销售订单
ErpSaleOrderDO updateSaleOrder = new ErpSaleOrderDO();
updateSaleOrder.setId(saleOrderDO.getId());
updateSaleOrder.setPickUpStatus(SaleOrderPickUpStatus.RETURNS_PROCESS);
List<ErpSaleReturnSaveReqVO.Item> items = new ArrayList<>(reqVO.getOrderItems().size());
List<ErpSaleOrderItemDO> updateSaleOrderItems = new ArrayList<>(reqVO.getOrderItems().size());
for (AppCustomerReturnOrderReqVO.ReturnItems item : reqVO.getOrderItems()) {
CustomerOrderItemDO customerOrderItemDO = orderItemMap.get(item.getCustomerOrderItemId());
if (!Objects.equals(customerOrderItemDO.getProductId(), item.getProductId())) {
......@@ -532,6 +539,9 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
}
ErpSaleReturnSaveReqVO.Item returnItem = new ErpSaleReturnSaveReqVO.Item();
ErpSaleOrderItemDO saleOrderItemDO = saleOrderService.queryItemByCustomerOrderItemId(customerOrderItemDO.getId());
ErpSaleOrderItemDO updateSaleOrderitem = new ErpSaleOrderItemDO();
updateSaleOrderitem.setId(saleOrderItemDO.getId());
updateSaleOrderitem.setPickUpStatus(SaleOrderPickUpStatus.RETURNS_PROCESS);
if (customerOrderItemDO.getSignedQuantity() - CommonUtil.getEls(customerOrderItemDO.getReturnsQuantity(), 0)
< item.getReturnCount()) {
throw exception(CUSTOMER_ORDER_RETURN_COUNT_ERROR, customerOrderItemDO.getProductName());
......@@ -547,9 +557,13 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
returnItem.setRemark(item.getRemark());
returnItem.setSupplierId(customerOrderItemDO.getSupplierId());
items.add(returnItem);
updateSaleOrderItems.add(updateSaleOrderitem);
}
returnSaveReqVO.setItems(items);
saleReturnService.createSaleReturn(returnSaveReqVO);
saleOrderService.update(updateSaleOrder, updateSaleOrderItems);
} finally {
RedisUtils.unLockRds(lock);
}
......@@ -660,7 +674,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
*/
@Override
public AppCustomerMonthOrderRespVO reconciliationPageYear(AppCustomerYearOrderPageReqVO reqVO) {
AppCustomerMonthOrderRespVO respVO = customerOrderMapper.reconciliationPageYearTotal(reqVO.getYear(), reqVO.getDeptIds());
AppCustomerMonthOrderRespVO respVO = customerOrderMapper.reconciliationPageYearTotal(reqVO.getYear(), reqVO.getDeptIds(), reqVO.getCreator());
if (CommonUtil.isNotEmpty(respVO)) {
respVO.setPageResult(customerOrderMapper.reconciliationPageYearPage(reqVO));
}
......@@ -674,8 +688,8 @@ public class CustomerOrderServiceImpl implements CustomerOrderService, CustomerO
* @return
*/
@Override
public AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds) {
return customerOrderMapper.reconciliationMonthTotal(yearMonth, deptIds);
public AppCustomerMonthOrderTotalRespVO monthTotal(String yearMonth, Set<Long> deptIds, Long loginUserId) {
return customerOrderMapper.reconciliationMonthTotal(yearMonth, deptIds, loginUserId);
}
@Override
......
......@@ -77,12 +77,18 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
@Transactional(rollbackFor = Exception.class)
public void createBatch(ShoppingCartSaveBatchReqVO createReqVO) {
List<ProductSpuDO> spuList = productSpuService.getSpuList(CommonUtil.listConvert(createReqVO.getItems(), ShoppingCartSaveReqVO::getProductId));
if (CommonUtil.isEmpty(spuList)) {
throw exception(PRODUCT_NO_EXISTS);
}
List<ProductSpuDO> collect = spuList.stream().filter(item -> ProductSpuStatusEnum.isEnable(item.getStatus())).toList();
if (CommonUtil.isEmpty(collect)) {
throw exception(PRODUCT_DISABLE, String.join(",", CommonUtil.listConvertSet(createReqVO.getItems(), ShoppingCartSaveReqVO::getProductName)));
}
List<Long> productIds = CommonUtil.listConvert(collect, ProductSpuDO::getId);
for (ShoppingCartSaveReqVO item : createReqVO.getItems()) {
this.createShoppingCart(item);
if (productIds.contains(item.getProductId())) {
this.createShoppingCart(item);
}
}
}
......
......@@ -79,9 +79,9 @@ public class AppProductSpuController {
if (spu == null) {
throw exception(SPU_NOT_EXISTS);
}
if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) {
/*if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) {
throw exception(SPU_NOT_ENABLE, spu.getName());
}
}*/
// 增加浏览量
productSpuService.updateBrowseCount(id, 1);
......
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