其余文件
This commit is contained in:
45
app/api/validate/IntegralGoodsValidate.php
Normal file
45
app/api/validate/IntegralGoodsValidate.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\IntegralGoodsEnum;
|
||||
use app\common\model\integral\IntegralGoods;
|
||||
|
||||
/**
|
||||
* 积分商品验证
|
||||
* Class IntegralOrderValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class IntegralGoodsValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number|checkGoods',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'id.number' => '参数类型错误',
|
||||
];
|
||||
|
||||
|
||||
// 验证商品
|
||||
protected function checkGoods($value, $rule, $data)
|
||||
{
|
||||
$goods = IntegralGoods::where([
|
||||
'id' => $value,
|
||||
'del' => IntegralGoodsEnum::DEL_NORMAL,
|
||||
])->findOrEmpty();
|
||||
|
||||
if ($goods->isEmpty()) {
|
||||
return '积分商品不存在';
|
||||
}
|
||||
|
||||
if ($goods['status'] != IntegralGoodsEnum::STATUS_SHELVES) {
|
||||
return '商品已下架';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user