Order.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhengmingwei
  5. * Date: 2019/11/5
  6. * Time: 11:00 下午
  7. */
  8. namespace addons\unishop\validate;
  9. use think\Validate;
  10. class Order extends Validate
  11. {
  12. /**
  13. * 验证规则
  14. */
  15. protected $rule = [
  16. 'product_id' => 'require',
  17. 'number' => 'require',
  18. 'city_id' => 'require|integer',
  19. 'delivery_id' => 'require|integer',
  20. 'remark' => 'max:250',
  21. 'address_id' => 'require',
  22. 'flash_id' => 'require',
  23. ];
  24. /**
  25. * 提示消息
  26. */
  27. protected $message = [
  28. 'product_id.required' => '产品编号不能为空',
  29. 'number.require' => '商品数量不能为空',
  30. 'city_id.require' => '收货地址不能为空',
  31. 'city_id.integer' => '收货地址格式错误',
  32. 'delivery_id.require' => '请选择配送方式',
  33. 'delivery_id.integer' => '配送方式格式错误',
  34. 'remark.max' => '备注不能超过250个文字',
  35. 'address_id.require' => '请选择收货地址',
  36. 'flash_id.require' => '秒杀id不能为空',
  37. ];
  38. /**
  39. * 验证场景
  40. */
  41. protected $scene = [
  42. 'submit' => ['product_id', 'number', /*'city_id', 'address_id', 'delivery_id',*/ 'remark'], // 创建订单
  43. 'submitFlash' => ['product_id', 'number', /*'city_id', 'address_id', 'delivery_id',*/ 'remark', 'flash_id'], // 秒杀创建订单
  44. ];
  45. }