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