English
price-service.getRealPriceAndCalculate.parseData
About 255 wordsLess than 1 minute
2026-05-08
Execution Timing
After copying, mapping, or draft-box operations, or after main object fields are modified and the pricing API has been called, control whether pricing runs and whether price-change alerts are displayed
Parameters
| Parameter | Description | Type |
|---|---|---|
| data | Detail object data | Array/Object |
| realPriceRes | Pricing service response | Object |
| mdApiName | Metadata API name | String |
| param | Other parameter object | Object |
Return Result
| Parameter | Description | Type |
|---|---|---|
| data | Processed detail object data | Array/Object |
| noGetRealPrice | Whether to skip the pricing service | Boolean |
| noAlert | Whether to suppress warning messages | Boolean |
Notes
- This hook is triggered when real prices are obtained and calculated, and can be used to process data and affect the subsequent flow.
- Data can be formatted, transformed, or supplemented in this hook.
- The returned
datareplaces the original data and is used for subsequent processing. - If the returned
noGetRealPriceis true, the pricing service is skipped. - If the returned
noAlertis true, warning messages are not displayed.
Code Example
export default class Plugin {
apply() {
return [{
event: "price-service.getRealPriceAndCalculate.parseData",
functional: this.parseData.bind(this)
},
];
}
async parseData(context){
let { data, realPriceRes, mdApiName, param } = context;
// Ensure data is in array format
let processedData = Array.isArray(data) ? [...data] : [data];
// Process each data item
processedData = processedData.map(item => {
// Apply specific processing based on the metadata API type
if(mdApiName === "xxx") {
item.currency = param.currency || "CNY";
}
return item;
});
// Decide whether pricing is required
let noGetRealPrice = false;
// Decide whether to display warnings
let noAlert = false;
// Return the processing result
return {
data: Array.isArray(data) ? processedData : processedData[0],
noGetRealPrice,
noAlert
};
}
}