commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
/** |
|
3 |
* Created by PhpStorm. |
|
4 |
* User: 风哀伤 |
|
5 |
* Date: 2019/2/14 |
|
6 |
* Time: 15:56 |
|
7 |
* @copyright: ©2019 浙江禾匠信息科技 |
|
8 |
* @link: http://www.zjhejiang.com |
|
9 |
*/ |
|
10 |
|
|
11 |
namespace app\jobs; |
|
12 |
|
|
13 |
|
|
14 |
use app\events\OrderEvent; |
|
15 |
use app\models\Mall; |
|
16 |
use app\models\Order; |
|
17 |
use yii\base\Component; |
|
18 |
use yii\queue\JobInterface; |
|
19 |
|
|
20 |
class OrderConfirmJob extends BaseJob implements JobInterface |
|
21 |
{ |
|
22 |
public $orderId; |
|
23 |
|
|
24 |
public function execute($queue) |
|
25 |
{ |
|
26 |
\Yii::error('order confirm job ->>' . $this->orderId); |
|
27 |
$this->setRequest(); |
|
28 |
$order = Order::findOne([ |
|
29 |
'id' => $this->orderId, |
|
30 |
'is_delete' => 0, |
|
31 |
'is_send' => 1, |
|
32 |
'is_confirm' => 0 |
|
33 |
]); |
|
34 |
if (!$order) { |
|
35 |
return true; |
|
36 |
} |
|
37 |
$mall = Mall::findOne(['id' => $order->mall_id]); |
|
38 |
\Yii::$app->setMall($mall); |
|
39 |
if ($order->pay_type == 2) { |
|
40 |
\Yii::error('货到付款的无法自动收货'); |
|
41 |
return true; |
|
42 |
} |
|
43 |
|
|
44 |
// TODO 订单处于售后状态是未处理 |
|
45 |
|
|
46 |
$order->is_confirm = 1; |
|
47 |
$order->confirm_time = mysql_timestamp(); |
|
48 |
if ($order->save()) { |
|
49 |
$event = new OrderEvent([ |
|
50 |
'order' => $order, |
|
51 |
]); |
|
52 |
\Yii::$app->trigger(Order::EVENT_CONFIRMED, $event); |
|
53 |
} |
|
54 |
} |
|
55 |
} |