123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /*
- * @Author: xiaohai zmhwork@qq.com
- * @Date: 2025-03-17 10:36:54
- * @LastEditors: xiaohai zmhwork@qq.com
- * @LastEditTime: 2025-03-17 13:42:47
- * @FilePath: \opkpm\app\shop\validate\order\OrderRenewValidate.php
- * @Description: 续费订单验证
- */
-
- namespace app\shop\validate\order;
-
- use app\common\basics\Validate;
-
- use app\common\model\shop\OrderRenew;
- use app\common\model\shop\ShopGoodsRenew;
-
- class OrderRenewValidate extends Validate
- {
- protected $rule = [
- 'id' => '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;
- }
- }
|