coupon-admin/app/validate/CouponRelease.php

45 lines
1.4 KiB
PHP

<?php
namespace app\validate;
use think\Validate;
class CouponRelease extends Validate
{
protected $rule = [
'business_code|商家code' => 'require',
//'lng|经度' => 'require',
//'lat|纬度' => 'require',
'count|总数' => 'require|number|>:0',
'type|优惠券类型' => 'require',
'start_time|开始时间' => 'require|date',
'end_time|结束时间' => 'require|date|checkEndTime',
'name|优惠券名称' => 'require|length:3,32',
'money|金额' => 'require|>:0|<:5000',
// 'deduction_money|扣除金额' => 'require|>=:0|<:5000',
//'image_url|预览图' => '',
//'using_rule|使用规则' => '',
//'punishing_rule|处罚规则' => '',
//'using_count|使用中' => '',
//'received_count|已领取的优惠券数量' => '',
//'edition|发布的版本' => '',
'status|状态' => 'require|in:1,0',
'on_shelf|上架状态' => 'require|in:1,0',
//'intro|详情' => '',
];
protected $scene = [
'edit' => ['start_time', 'end_time', 'name',"status","on_shelf"],
];
protected function checkEndTime($value, $rule, $data = [])
{
if (strtotime($value) <= strtotime($data['start_time'])) {
return "结束时间不能小于等于开始时间";
}
return true;
}
}