<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 优惠券管理
 */
namespace app\ais\validate;
use think\Validate;

class Coupon extends Validate{

    protected $rule = [
        'id'         => 'require|number',
        'store_id'   => 'require|number',
        'miniapp_id' => 'require|number',
        'name'       => 'require',
        'tips'       => 'require',
        'types'      => 'require|integer|between:0,2',
        'discount'   => 'require|float|between:0,9',
        'howmuch'    => 'require|integer',
        'price'      => 'require|integer',
        'amount'     => 'require|integer',
        'num'        => 'require|integer|>:0',
        'mode'       => 'require'
    ];

    protected $message = [
        'id'               => 'ID丢失',
        'store_id'         => '好店不存在',
        'miniapp_id'       => '应用失效',
        'name'             => '优惠券名称必须填写',
        'howmuch'          => '满多少钱可用',
        'tips'             => '规则简述必须填写',
        'types'            => '优惠券必须选择',
        'discount'         => '打多少折扣必须填写',
        'discount.between' => '只能输入1 - 9折之间的折扣',
        'price'            => '单价必须填写',
        'num'              => '发现数量必须填写',
        'amount'           => '储值额度必须填写',
        'mode'             => '优惠券类型必须输入',
    ];

    protected $scene = [
        'edit' => ['name','discount','price','amount','howmuch','tips','types','num'],
        'api'  => ['mode']
    ];
}