diff --git a/packages/app-client/src/app.config.ts b/packages/app-client/src/app.config.ts index 4a03418..67b4725 100644 --- a/packages/app-client/src/app.config.ts +++ b/packages/app-client/src/app.config.ts @@ -103,5 +103,5 @@ export default defineAppConfig({ navigationBarBackgroundColor: "#fff", navigationBarTitleText: "WeChat", navigationBarTextStyle: "black", - } + }, }); diff --git a/packages/app-client/src/components/delivery/Step1Form.tsx b/packages/app-client/src/components/delivery/Step1Form.tsx index da61327..c48e442 100644 --- a/packages/app-client/src/components/delivery/Step1Form.tsx +++ b/packages/app-client/src/components/delivery/Step1Form.tsx @@ -378,8 +378,8 @@ const Step1Form = forwardRef((props, ref) => { setOrderShip({ ...orderShip!, - shipOrderItemList: - orderShip?.shipOrderItemList?.map( + orderShipItemList: + orderShip?.orderShipItemList?.map( (item: any) => { if (item.itemId === shipOrderItem.itemId) { return { @@ -523,13 +523,13 @@ const Step1Form = forwardRef((props, ref) => { module.config.showGrade ) { console.log( - "orderShip?.shipOrderItemList", - orderShip?.shipOrderItemList, + "orderShip?.orderShipItemList", + orderShip?.orderShipItemList, ); - if (orderShip?.shipOrderItemList) { + if (orderShip?.orderShipItemList) { const itemGradesErrors: { [key: string]: boolean } = {}; - for (let i = 0; i < orderShip.shipOrderItemList.length; i++) { - const item = orderShip.shipOrderItemList[i]; + for (let i = 0; i < orderShip.orderShipItemList.length; i++) { + const item = orderShip.orderShipItemList[i]; if (!item.watermelonGrade) { itemGradesErrors[item.itemId] = true; hasErrors = true; diff --git a/packages/app-client/src/components/purchase/section/CostSummarySection.tsx b/packages/app-client/src/components/purchase/section/CostSummarySection.tsx index eb41de6..99a5264 100644 --- a/packages/app-client/src/components/purchase/section/CostSummarySection.tsx +++ b/packages/app-client/src/components/purchase/section/CostSummarySection.tsx @@ -22,18 +22,21 @@ export default function CostSummarySection(props: { let costWithoutFreight: number; let costWithFreight: number; - // 判断采购成本是否包含运费 + // 判断采购成本是否包含运费,包含运费说明已经加过一次了 if (calculator.getRules().shouldIncludeFreightCost()) { - costWithoutFreight = totalPurchaseCost - freightCost; - costWithFreight = totalPurchaseCost; + costWithFreight = totalPurchaseCost - freightCost; + costWithoutFreight = costWithFreight - freightCost; } else { costWithoutFreight = totalPurchaseCost; costWithFreight = totalPurchaseCost + freightCost; } + console.log("采购成本", costWithoutFreight); + console.log("采购成本(含运费)", costWithFreight); + // 计算单斤成本(不含运费) const unitCostWithoutFreight = - totalNetWeight > 0 ? totalPurchaseCost / totalNetWeight : 0; + totalNetWeight > 0 ? costWithoutFreight / totalNetWeight : 0; // 计算单斤成本(含运费) const unitCostWithFreight = diff --git a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx index 5dd2adb..3d4619c 100644 --- a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx +++ b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx @@ -1,9 +1,6 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { DeliveryStep1Form, DeliveryStep2Preview } from "@/components"; -import { - convertPurchaseOrderToShipOrder, - convertShipOrderVOToExamplesFormat, -} from "@/utils"; +import { convertShipOrderVOToExamplesFormat } from "@/utils"; import { business } from "@/services"; import { Popup } from "@nutui/nutui-react-taro"; import { View } from "@tarojs/components"; @@ -25,7 +22,7 @@ export default forwardRef< const [previewVisible, setPreviewVisible] = useState(false); - const orderShip = convertPurchaseOrderToShipOrder(purchaseOrderVO); + const orderShip = purchaseOrderVO.orderShipList[0]; const init = async (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => { const { data } = await business.dealer.showDealer({ @@ -39,7 +36,7 @@ export default forwardRef< // 将 shipOrderVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据 const convertedData = convertShipOrderVOToExamplesFormat( purchaseOrderVO, - orderShip, + orderShip!, ); const updatedTemplate = await updateTemplateConfig( template, @@ -71,8 +68,10 @@ export default forwardRef< }; useEffect(() => { - init(purchaseOrderVO); - }, [purchaseOrderVO.orderDealer.dealerId]); + if (orderShip) { + init(purchaseOrderVO); + } + }, [purchaseOrderVO.orderDealer.dealerId, orderShip]); // 暴露方法给父组件 useImperativeHandle(ref, () => ({ diff --git a/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx b/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx index 93d65ee..7f3c40a 100644 --- a/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx +++ b/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx @@ -230,6 +230,15 @@ export default function MarketPriceSection(props: { 斤 + {/* 是否包纸箱 */} + + 包纸箱 + + {supplier.pricingMethod === "BY_GROSS_WEIGHT" + ? "包" + : "不包"} + + 采购单价 diff --git a/packages/app-client/src/components/purchase/section/PurchaseFormSection.tsx b/packages/app-client/src/components/purchase/section/PurchaseFormSection.tsx index db338fc..9d4df74 100644 --- a/packages/app-client/src/components/purchase/section/PurchaseFormSection.tsx +++ b/packages/app-client/src/components/purchase/section/PurchaseFormSection.tsx @@ -1,6 +1,6 @@ import { View } from "@tarojs/components"; import { Icon, PurchaseStep1Form } from "@/components"; -import { convertPurchaseOrderToShipOrder } from "@/utils"; +import { convertPurchaseOrderToOrderShip } from "@/utils"; export default function PurchaseFormSection(props: { purchaseOrderVO: BusinessAPI.PurchaseOrderVO; @@ -12,7 +12,7 @@ export default function PurchaseFormSection(props: { const shipOrderVO = purchaseOrderVO.orderShipList && purchaseOrderVO.orderShipList.length > 0 ? purchaseOrderVO.orderShipList[0] - : convertPurchaseOrderToShipOrder(purchaseOrderVO); + : convertPurchaseOrderToOrderShip(purchaseOrderVO); if (!shipOrderVO) { return; diff --git a/packages/app-client/src/constant/app.ts b/packages/app-client/src/constant/app.ts index d3827fe..88d7a17 100644 --- a/packages/app-client/src/constant/app.ts +++ b/packages/app-client/src/constant/app.ts @@ -1,2 +1,2 @@ // App 相关常量 -export const APP_VERSION = "v0.0.35"; +export const APP_VERSION = "v0.0.36"; diff --git a/packages/app-client/src/pages/delivery/document/delivery.tsx b/packages/app-client/src/pages/delivery/document/delivery.tsx index 86fa2aa..77f96fe 100644 --- a/packages/app-client/src/pages/delivery/document/delivery.tsx +++ b/packages/app-client/src/pages/delivery/document/delivery.tsx @@ -71,7 +71,7 @@ const updateOtherFeesModule = async ( export default hocAuth(function Page(props: CommonComponent) { const { router, setLoading } = props; const shipOrderId = router.params - .shipOrderId as BusinessAPI.OrderShipVO["shipOrderId"]; + .shipOrderId as BusinessAPI.OrderShipVO["orderShipId"]; const [step, setStep] = useState(1); const [moduleList, setModuleList] = useState([]); @@ -82,11 +82,11 @@ export default hocAuth(function Page(props: CommonComponent) { const step1FormRef = useRef(null); - const init = async (shipOrderId: BusinessAPI.OrderShipVO["shipOrderId"]) => { + const init = async (orderShipId: BusinessAPI.OrderShipVO["orderShipId"]) => { setLoading(true); - const { data } = await business.shipOrder.showShipOrder({ - shipOrderShowQry: { - shipOrderId, + const { data } = await business.orderShip.showOrderShip({ + orderShipShowQry: { + orderShipId, }, }); const shipOrderVO = data.data; @@ -141,7 +141,7 @@ export default hocAuth(function Page(props: CommonComponent) { const updateTemplateConfig = async ( template: any[], data: any, - shipOrderVO: BusinessAPI.ShipOrderVO, + shipOrderVO: BusinessAPI.OrderShipVO, ) => { let templateList: any[] = []; template.map(async (module: any) => { @@ -226,8 +226,8 @@ export default hocAuth(function Page(props: CommonComponent) { // 存储 至 shipOrder previewUrl if (shipOrderVO) { - let formData: BusinessAPI.ShipOrderGenerateDocumentCmd = { - shipOrderId: shipOrderVO?.shipOrderId, + let formData: BusinessAPI.OrderShipGenerateDocumentCmd = { + orderShipId: shipOrderVO?.orderShipId, document: data?.data?.path, }; // 检查各模块中的必填字段是否已填写 @@ -263,11 +263,11 @@ export default hocAuth(function Page(props: CommonComponent) { } // 检查品级字段是否开启且已填写 else if (column.dataIndex === "requiredGrade") { - formData.shipOrderItemList = shipOrderVO?.shipOrderItemList; + formData.orderShipItemList = shipOrderVO?.orderShipItemList; } } } - business.shipOrder.generateDocumentShipOrder(formData).then(); + business.orderShip.generateDocumentOrderShip(formData).then(); } if (data && data?.data?.path) { diff --git a/packages/app-client/src/pages/delivery/document/purchase.tsx b/packages/app-client/src/pages/delivery/document/purchase.tsx index 6be2da9..455b62c 100644 --- a/packages/app-client/src/pages/delivery/document/purchase.tsx +++ b/packages/app-client/src/pages/delivery/document/purchase.tsx @@ -24,11 +24,11 @@ export default hocAuth(function Page(props: CommonComponent) { const [step, setStep] = useState(1); const [moduleList, setModuleList] = useState([]); const [document, setDocument] = - useState(); + useState(); const [height, setHeight] = useState(); const [purchaseOrderVO, setPurchaseOrderVO] = useState(); - const [shipOrderVO, setShipOrderVO] = useState(); + const [shipOrderVO, setShipOrderVO] = useState(); const step1FormRef = useRef(null); @@ -118,8 +118,8 @@ export default hocAuth(function Page(props: CommonComponent) { // 存储 至 shipOrder previewUrl if (shipOrderVO) { - let formData: BusinessAPI.ShipOrderGenerateDocumentCmd = { - shipOrderId: shipOrderVO?.shipOrderId, + let formData: BusinessAPI.OrderShipGenerateDocumentCmd = { + orderShipId: shipOrderVO?.orderShipId, document: data?.data?.path, }; // 检查各模块中的必填字段是否已填写 @@ -155,11 +155,11 @@ export default hocAuth(function Page(props: CommonComponent) { } // 检查品级字段是否开启且已填写 else if (column.dataIndex === "requiredGrade") { - formData.shipOrderItemList = shipOrderVO?.shipOrderItemList; + formData.orderShipItemList = shipOrderVO?.orderShipItemList; } } } - business.shipOrder.generateDocumentShipOrder(formData).then(); + business.orderShip.generateDocumentOrderShip(formData).then(); } if (data && data?.data?.path) { diff --git a/packages/app-client/src/pages/purchase/audit/audit.tsx b/packages/app-client/src/pages/purchase/audit/audit.tsx index 08df460..aecd1ec 100644 --- a/packages/app-client/src/pages/purchase/audit/audit.tsx +++ b/packages/app-client/src/pages/purchase/audit/audit.tsx @@ -42,6 +42,7 @@ import { import { type DeliveryFormSectionRef } from "@/components/purchase/section/DeliveryFormSection"; import { buildUrl, + convertPurchaseOrderToOrderShip, formatCurrency, generateShortId, PurchaseOrderCalculator, @@ -524,32 +525,41 @@ export default hocAuth(function Page(props: CommonComponent) { }); if (success && purchaseOrderVO) { + if ( + !purchaseOrderVO.orderShipList || + purchaseOrderVO.orderShipList.length === 0 + ) { + purchaseOrderVO.orderShipList = [ + convertPurchaseOrderToOrderShip(purchaseOrderVO), + ]; + } + + console.log( + "purchaseOrderVO.orderShipList", + purchaseOrderVO.orderShipList, + ); + await initDealer(purchaseOrderVO?.orderDealer?.dealerId!); purchaseOrderVO.orderCostList.map((item) => { - item.price = purchaseOrderVO.orderCostItemList - .filter((orderCost) => - item.costItemIds?.includes(orderCost.costItemId!), - ) - ?.reduce( - (acc, cur) => - DecimalUtils.add( - acc, - DecimalUtils.multiply(cur.price || 0, cur.count || 0), - ), - 0, - ); - - console.log("item", item); + if (!item.price) { + item.price = purchaseOrderVO.orderCostItemList + .filter((orderCost) => + item.costItemIds?.includes(orderCost.costItemId!), + ) + ?.reduce( + (acc, cur) => + DecimalUtils.add( + acc, + DecimalUtils.multiply(cur.price || 0, cur.count || 0), + ), + 0, + ); + } return item; }); - console.log( - "purchaseOrderVO.orderCostList", - purchaseOrderVO.orderCostList, - ); - // 计提费 const orderCost = purchaseOrderVO?.orderCostList.find( (item) => item.name === "计提费" && item.type === "OTHER_TYPE", @@ -596,8 +606,11 @@ export default hocAuth(function Page(props: CommonComponent) { } } + const cost1 = costList?.find( + (cost) => cost.name === "运费" && cost.type === "OTHER_TYPE", + ); // 加运费 - if (purchaseOrderVO.orderVehicle.price) { + if (purchaseOrderVO.orderVehicle.price && !cost1) { purchaseOrderVO.orderCostList.push({ orderCostId: generateShortId(), costId: "", @@ -612,8 +625,11 @@ export default hocAuth(function Page(props: CommonComponent) { }); } + const cost2 = costList?.find( + (cost) => cost.name === "草帘费" && cost.type === "OTHER_TYPE", + ); // 加草帘 - if (purchaseOrderVO.orderVehicle.openStrawCurtain) { + if (purchaseOrderVO.orderVehicle.openStrawCurtain && !cost2) { purchaseOrderVO.orderCostList.push({ orderCostId: generateShortId(), costId: "", diff --git a/packages/app-client/src/utils/classes/calculators/core/BusinessRules.ts b/packages/app-client/src/utils/classes/calculators/core/BusinessRules.ts index 63a4401..031f224 100644 --- a/packages/app-client/src/utils/classes/calculators/core/BusinessRules.ts +++ b/packages/app-client/src/utils/classes/calculators/core/BusinessRules.ts @@ -82,15 +82,15 @@ export class PurchaseOrderRules { /** * 获取定价方式 */ - getPricingMethod(): "BY_GROSS_WEIGHT" | "BY_NET_WEIGHT" { - return this.order.pricingMethod!; + getPricingMethod(supplier: BusinessAPI.OrderSupplier): "BY_GROSS_WEIGHT" | "BY_NET_WEIGHT" { + return supplier.pricingMethod!; } /** * 根据定价方式获取重量值 */ getWeightByPricingMethod(supplier: BusinessAPI.OrderSupplier): number { - return this.getPricingMethod() === "BY_GROSS_WEIGHT" + return this.getPricingMethod(supplier) === "BY_GROSS_WEIGHT" ? supplier.grossWeight || 0 : supplier.netWeight || 0; } diff --git a/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts b/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts index 54fc855..0670d23 100644 --- a/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts +++ b/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts @@ -99,6 +99,12 @@ export class CostCalculator { const taxProvision = this.calculateTaxProvision(); const costDifference = this.getCostDifference(); + console.log("melonCost:", melonCost); + console.log("otherCosts:", otherCosts); + console.log("taxSubsidy:", taxSubsidy); + console.log("taxProvision:", taxProvision); + console.log("costDifference:", costDifference); + return DecimalUtils.add( melonCost, otherCosts, @@ -132,6 +138,7 @@ export class CostCalculator { private shouldIncludeCost(cost: BusinessAPI.OrderCost): boolean { // 运费需要特殊判断 if (cost.name === "运费") { + console.log("this.rules.shouldIncludeFreightCost()", this.rules.shouldIncludeFreightCost()) return this.rules.shouldIncludeFreightCost(); } diff --git a/packages/app-client/src/utils/converters/index.ts b/packages/app-client/src/utils/converters/index.ts index 9cdb916..f8f0434 100644 --- a/packages/app-client/src/utils/converters/index.ts +++ b/packages/app-client/src/utils/converters/index.ts @@ -10,5 +10,5 @@ export { convertOrderPackagesToBoxBrands } from './boxBrandConverter' -export { convertPurchaseOrderToShipOrder } from './purchaseOrderConverter' -export { convertShipOrderVOToExamplesFormat } from './shipOrderConverter' \ No newline at end of file +export { convertPurchaseOrderToOrderShip } from './purchaseOrderConverter' +export { convertShipOrderVOToExamplesFormat } from './shipOrderConverter' diff --git a/packages/app-client/src/utils/converters/purchaseOrderConverter.ts b/packages/app-client/src/utils/converters/purchaseOrderConverter.ts index e37cd05..a07d7ec 100644 --- a/packages/app-client/src/utils/converters/purchaseOrderConverter.ts +++ b/packages/app-client/src/utils/converters/purchaseOrderConverter.ts @@ -7,7 +7,7 @@ import { DecimalUtils } from "@/utils/classes/calculators/core/DecimalUtils"; * @param purchaseOrderVO 采购订单对象 * @returns 发货单对象 */ -export const convertPurchaseOrderToShipOrder = ( +export const convertPurchaseOrderToOrderShip = ( purchaseOrderVO: BusinessAPI.PurchaseOrderVO ): BusinessAPI.OrderShip => { // 添加一个辅助函数用于分组