购物车价格计算
方法概览
| 项目 | 内容 |
|---|---|
| 文档类型 | PHP 类方法 |
| 方法标识 | app\common\logic\ModuleLogic::cartCalculatePrice |
| 所属业务 | 商品管理 |
| 来源模块/系统 | 模块逻辑 |
功能说明
购物车价格计算
调用示例
$ProductModel = 'string';
$params = ['string'];
$qty = 1;
$scene = 'buy';
$position = 1;
$result = (new \app\common\logic\ModuleLogic())->cartCalculatePrice($ProductModel, $params, $qty, $scene, $position);参数
| 参数 | 类型 | 必填 | 默认值 | 校验规则 | 说明 |
|---|---|---|---|---|---|
ProductModel | ProductModel | 是 | — | require | 产品模型 |
params | array | 是 | — | required | 模块自定义配置参数 |
qty | int | 否 | 1 | — | 数量 |
scene | string | 否 | buy | — | 场景(cal_price=计算价格,buy=结算) |
position | int | 否 | — | — | 结算位置标识 |
返回值
| 返回项 | 类型 | 说明 |
|---|---|---|
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.host_billing_cycle | string | 当商品是费用类型是多个时,必须返回产品计费周期 |
data.keep_time_price | float | 按需保留期价格 |
data.on_demand_flow_price | float | 按需流量价格 |
正常返回
{
"status": 1,
"msg": "string",
"data": {
"price": "string",
"renew_price": "string",
"billing_cycle": "monthly",
"duration": 1,
"description": "192.0.2.1",
"base_price": "string",
"host_billing_cycle": "monthly",
"keep_time_price": 0.01,
"on_demand_flow_price": 0.01
}
}异常情况
| 异常类型 | 说明 |
|---|---|
Throwable | 调用失败时由具体实现抛出异常,异常信息以运行时结果为准。 |