商品价格计算
方法概览
| 项目 | 内容 |
|---|---|
| 文档类型 | 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_id | int | 是 | — | required | 商品ID |
param.qty | int | 是 | — | required | 数量 |
config_options | array | 否 | — | — | 模块自定义配置参数,格式{"configoption":{1:1,2:[2]},"cycle":2,"promo_code":"Af13S1ACj","event_promotion":12,"qty":1} |
返回值
| 返回项 | 类型 | 说明 |
|---|---|---|
status | int | 状态(200=成功,400=失败) |
msg | string | 信息 |
data.price | string | 价格(订购原价,计算数量) |
data.renew_price | string | 续费价格(计算折扣,不计算数量) |
data.billing_cycle | string | 周期名称 |
data.duration | int | 周期时长(秒) |
data.description | string | 订单子项描述 |
data.base_price | string | 基础价格 |
data.price_total | float | 折扣后金额(各种优惠折扣处理后的金额,没有就是price价格),并且计算数量 |
data.renew_price_total | float | 续费总价(不计算折扣,计算数量) |
data.price_promo_code_discount | float | 优惠码折扣金额(当使用优惠码,且有效时,才返回此字段) |
data.price_client_level_discount | float | 客户等级折扣金额(当客户等级有效时,才返回此字段) |
data.price_event_promotion_discount | float | 活动促销折扣金额(当活动促销有效时,才返回此字段) |
data.event_promotion_exclude_client_level | bool | 活动促销是否和用户等级互斥(当活动促销有效时,才返回此字段) |
data.event_promotion_exclude_client_level_renew | bool | 续费金额活动促销是否和用户等级互斥(当活动促销有效时,才返回此字段) |
正常返回
{
"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 | 调用失败时由具体实现抛出异常,异常信息以运行时结果为准。 |