...
|
...
|
@@ -280,6 +280,31 @@ class Order extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (判断库存)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="sku_id", type="integer", required=true, description="规格id")
|
|
|
* @ApiParams (name="number", type="integer", required=true, description="购买数量")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'SUCCESS'
|
|
|
'data': code 等于1表示未超出最大值
|
|
|
})
|
|
|
*/
|
|
|
public function checkStock()
|
|
|
{
|
|
|
$sku_id = $this->request->post('sku_id');
|
|
|
$number = $this->request->post('number');
|
|
|
if (!$number) $this->error('请选择购买数量');
|
|
|
if (!$sku_id) $this->error('请选择规格');
|
|
|
$model = new GoodsSpec();
|
|
|
$sku = $model::get($sku_id);
|
|
|
if (!$sku) $this->error('规格已失效,请重新选择');
|
|
|
if ($sku['stock_num'] < $number) $this->error('已超出最大库存');
|
|
|
$this->success('SUCCESS');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (计算运费)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
...
|
...
|
|