dggjimai/application/common/model/Cart.php

24 lines
554 B
PHP
Executable File

<?php
/**
* 购物车模型
*/
namespace app\common\model;
use think\model\concern\SoftDelete;
use think\Db;
class Cart extends Model
{
protected $name = 'cart';
protected $autoWriteTimestamp = true;
//检查库存
public static function checkStock($item_value, $goods_num,$goods_id)
{
$item_info = Db::name('goods_item')
->where(array('goods_id'=>$goods_id,'spec_value'=>$item_value))->find();
if ($goods_num > $item_info['stock']) {
return true;
}
return false;
}
}