'require', 'shop_id|用户' => 'require|number|gt:0', 'renew_id|套餐' => 'require|number|gt:0|checkTypePay', 'renew_num|续费数量' => 'require|number|gt:0', 'pay_way|支付方式' => 'require|number|in:1,2', ]; protected $message = [ 'id.require' => '缺少ID字段', ]; protected $scene = [ 'detail' => ['id', 'shop_id'], 'add' => ['shop_id', 'renew_id', 'renew_num'], 'cancel' => ['id', 'shop_id'], 'pay_way' => ['id', 'shop_id', 'pay_way'], ]; // 查看同类型订单是否有待支付状态 protected function checkTypePay($value, $rule, $data) { $renew = ShopGoodsRenew::where('id', $data['renew_id'])->where('status',1)->where("del", 0)->findOrEmpty(); if ($renew->isEmpty()) { return '续费套餐不存在'; } $order = OrderRenew::where(['shop_id' => $data['shop_id'], 'renew_id' => $data['renew_id'], 'order_status' => 0])->findOrEmpty(); if (!$order->isEmpty()) { return '已存在' . $renew['name'] . '待支付的订单'; } return true; } }