50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\admin\validate\order;
|
||
|
|
||
|
use app\common\enum\OrderEnum;
|
||
|
use think\Validate;
|
||
|
use app\common\model\order\Order;
|
||
|
use app\common\model\team\Team;
|
||
|
|
||
|
class OrderValidate extends Validate
|
||
|
{
|
||
|
/**
|
||
|
* @notes 发货操作验证
|
||
|
* @param $post
|
||
|
* @return bool|string
|
||
|
* @author suny
|
||
|
* @date 2021/7/14 10:10 上午
|
||
|
* @throws \think\db\exception\DbException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
*/
|
||
|
protected function checkDelivery($post)
|
||
|
{
|
||
|
|
||
|
$id = $post['id'];
|
||
|
$order = Order::where(['id' => $id])->find();
|
||
|
|
||
|
if (!$order) {
|
||
|
return '订单失效';
|
||
|
}
|
||
|
|
||
|
if ($order['del'] == 1) {
|
||
|
return '订单已删除';
|
||
|
}
|
||
|
|
||
|
if ($order['shipping_status'] == 1) {
|
||
|
return '此订单已发货';
|
||
|
}
|
||
|
|
||
|
if ($order['order_type'] == OrderEnum::TEAM_ORDER) {
|
||
|
$found = Order::where(['id' => $order['team_found_id']])->find();
|
||
|
if ($found['status'] != Team::STATUS_SUCCESS) {
|
||
|
return '已支付的拼团订单需要等待拼团成功后才能发货';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|