智简魔方文档

商品价格计算

方法概览

项目内容
文档类型PHP 类方法
方法标识app\common\model\ProductModel::productCalculatePrice
所属业务商品管理
来源模块/系统商品模型

功能说明

商品价格计算

调用示例

$param = ['product_id' => 1, 'qty' => 1];
$config_options = ['string'];
$result = (new \app\common\model\ProductModel())->productCalculatePrice($param, $config_options);

参数

参数类型必填默认值校验规则说明
param.product_idintrequired商品ID
param.qtyintrequired数量
config_optionsarray模块自定义配置参数,格式{"configoption":{1:1,2:[2]},"cycle":2,"promo_code":"Af13S1ACj","event_promotion":12,"qty":1}

返回值

返回项类型说明
statusint状态(200=成功,400=失败)
msgstring信息
data.pricestring价格(订购原价,计算数量)
data.renew_pricestring续费价格(计算折扣,不计算数量)
data.billing_cyclestring周期名称
data.durationint周期时长(秒)
data.descriptionstring订单子项描述
data.base_pricestring基础价格
data.price_totalfloat折扣后金额(各种优惠折扣处理后的金额,没有就是price价格),并且计算数量
data.renew_price_totalfloat续费总价(不计算折扣,计算数量)
data.price_promo_code_discountfloat优惠码折扣金额(当使用优惠码,且有效时,才返回此字段)
data.price_client_level_discountfloat客户等级折扣金额(当客户等级有效时,才返回此字段)
data.price_event_promotion_discountfloat活动促销折扣金额(当活动促销有效时,才返回此字段)
data.event_promotion_exclude_client_levelbool活动促销是否和用户等级互斥(当活动促销有效时,才返回此字段)
data.event_promotion_exclude_client_level_renewbool续费金额活动促销是否和用户等级互斥(当活动促销有效时,才返回此字段)

正常返回

{
  "status": 1,
  "msg": "string",
  "data": {
    "price": "string",
    "renew_price": "string",
    "billing_cycle": "monthly",
    "duration": 1,
    "description": "192.0.2.1",
    "base_price": "string",
    "price_total": 0.01,
    "renew_price_total": 0.01,
    "price_promo_code_discount": 0.01,
    "price_client_level_discount": 0.01,
    "price_event_promotion_discount": 0.01,
    "event_promotion_exclude_client_level": true,
    "event_promotion_exclude_client_level_renew": true
  }
}

异常情况

异常类型说明
Throwable调用失败时由具体实现抛出异常,异常信息以运行时结果为准。