\Config\AppNodeJs\Plugins\fn-common-data-business.js

\Config\AppNodeJs\bt-commons\fn-common-data-business.js

/**
 * 自定义业务数据特殊处理,通过  params={_rmt,_mkey,_resField}
 * @param {结果} result
 * @param {参数} params
 */
function doBusiness(result, params) {
    if (params._showParams) {
        // 显示参数,便于排查和调试
        return params;
    } else if (params._mkey === "menu-nav" && params._resField === "content") {
        return result;
    } else if (params._ownerId && params._ownerId.length > 0) {
        // 通过动态加载,便于业务化扩展
        var fnBusiness = require(`../${params._ownerId[0]}-commons/fn-common-data-business.js`);
        return fnBusiness.doBusiness(result, params);
    } else {
        return result;
    }
}
//业务特殊处理
exports.doBusiness = doBusiness;

/**
 * 自定义业务数据特殊处理,通过  params={_rmt,_mkey,_resField}
 * @param {结果} result
 * @param {参数} params
 */
function doBusiness(result, params) {
    if (params._mkey === "mall-commodity") {
        // merc_coupon_price 优惠价格 merc_discount*sale_price-integral/100
        // points_price 积分可兑换的金额 integral/100 积分和时间金额的换数
        if (params.rmt === 'detail' && params._nodejs === 'common-data') {
            result.data.pointsPrice = (result.data.integral || 0) / 100;
            result.data.mercCouponPrice = (result.data.mercDiscount || 10) / 10 * (result.data.salePrice || 0) - result.data.pointsPrice;
            if (result.data.mercCouponPrice < 0) result.data.mercCouponPrice = 0;

        } else if (params._nodejs === 'common-data') {
            result.data.forEach(temp => {
                temp.pointsPrice = (temp.integral || 0) / 100;
                temp.mercCouponPrice = (temp.mercDiscount || 10) / 10 * (temp.salePrice || 0) - temp.pointsPrice;
                if (temp.mercCouponPrice < 0) temp.mercCouponPrice = 0;
            });
        } else if (params.rmt === 'detail' && params._nodejs === 'common-data-under') {
            temp.points_price = (temp.integral || 0) / 100;
            result.data.merc_coupon_price = (result.data.merc_discount || 10) / 10 * (result.data.sale_price || 0) - temp.points_price;
            if (result.data.merc_coupon_price < 0) result.data.merc_coupon_price = 0;
        } else if (params._nodejs === 'common-data-under') {
            result.data.forEach(temp => {
                temp.points_price = (temp.integral || 0) / 100;
                temp.merc_coupon_price = (temp.merc_discount || 10) / 10 * (temp.sale_price || 0) - temp.points_price;
                if (temp.merc_coupon_price < 0) temp.merc_coupon_price = 0;
            });
        }
        return result;
    } else {
        return result;
    }
}
//业务特殊处理
exports.doBusiness = doBusiness;
文档更新时间: 2022-05-14 06:10   作者:admin