commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
|
|
3 |
|
|
4 |
namespace app\jobs; |
|
5 |
|
|
6 |
|
|
7 |
use app\core\response\ApiCode; |
|
8 |
use app\forms\api\order\OrderAppraiseForm; |
|
9 |
use app\models\Mall; |
|
10 |
use app\models\OrderDetail; |
|
11 |
use yii\queue\JobInterface; |
|
12 |
|
|
13 |
class OrderAutoComments extends BaseJob implements JobInterface |
|
14 |
{ |
|
15 |
public $orderDetail; |
|
16 |
|
|
17 |
/** |
|
18 |
* @inheritDoc |
|
19 |
*/ |
|
20 |
public function execute($queue) |
|
21 |
{ |
|
22 |
try { |
|
23 |
$this->doSomeThing(); |
|
24 |
} catch (\Exception $e) { |
|
25 |
\Yii::error('默认好评ERROR'); |
|
26 |
\Yii::error($e->getMessage()); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
private function doSomeThing() |
|
31 |
{ |
|
32 |
$mall = Mall::findOne(['id' => $this->orderDetail->order->mall_id]); |
|
33 |
\Yii::$app->setMall($mall); |
|
34 |
|
|
35 |
$form = new OrderAppraiseForm(); |
|
36 |
$form->order_id = $this->orderDetail->order_id; |
|
37 |
$form->appraiseData = json_encode([[ |
|
38 |
'id' => $this->orderDetail->id, |
|
39 |
'grade_level' => 5, |
|
40 |
'content' => '买家未及时作出评价,系统默认好评!', |
|
41 |
'pic_list' => [], |
|
42 |
'is_anonymous' => 1, |
|
43 |
]]); |
|
44 |
$return = $form->appraise(); |
|
45 |
if ($return['code'] !== ApiCode::CODE_SUCCESS) { |
|
46 |
throw new \Exception($return['msg']); |
|
47 |
} |
|
48 |
} |
|
49 |
} |