截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OrderRenewValidate.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * @Author: xiaohai zmhwork@qq.com
  4. * @Date: 2025-03-17 10:36:54
  5. * @LastEditors: xiaohai zmhwork@qq.com
  6. * @LastEditTime: 2025-03-17 13:42:47
  7. * @FilePath: \opkpm\app\shop\validate\order\OrderRenewValidate.php
  8. * @Description: 续费订单验证
  9. */
  10. namespace app\shop\validate\order;
  11. use app\common\basics\Validate;
  12. use app\common\model\shop\OrderRenew;
  13. use app\common\model\shop\ShopGoodsRenew;
  14. class OrderRenewValidate extends Validate
  15. {
  16. protected $rule = [
  17. 'id' => 'require',
  18. 'shop_id|用户' => 'require|number|gt:0',
  19. 'renew_id|套餐' => 'require|number|gt:0|checkTypePay',
  20. 'renew_num|续费数量' => 'require|number|gt:0',
  21. 'pay_way|支付方式' => 'require|number|in:1,2',
  22. ];
  23. protected $message = [
  24. 'id.require' => '缺少ID字段',
  25. ];
  26. protected $scene = [
  27. 'detail' => ['id', 'shop_id'],
  28. 'add' => ['shop_id', 'renew_id', 'renew_num'],
  29. 'cancel' => ['id', 'shop_id'],
  30. 'pay_way' => ['id', 'shop_id', 'pay_way'],
  31. ];
  32. // 查看同类型订单是否有待支付状态
  33. protected function checkTypePay($value, $rule, $data)
  34. {
  35. $renew = ShopGoodsRenew::where('id', $data['renew_id'])->where('status',1)->where("del", 0)->findOrEmpty();
  36. if ($renew->isEmpty()) {
  37. return '续费套餐不存在';
  38. }
  39. $order = OrderRenew::where(['shop_id' => $data['shop_id'], 'renew_id' => $data['renew_id'], 'order_status' => 0])->findOrEmpty();
  40. if (!$order->isEmpty()) {
  41. return '已存在' . $renew['name'] . '待支付的订单';
  42. }
  43. return true;
  44. }
  45. }