StatusAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 18 4
1
<?php
2
namespace graychen\yii2\jd\deposit\actions;
3
4
use graychen\yii2\jd\deposit\models\Order;
5
use Yii;
6
use yii\web\NotFoundHttpException;
7
8
class StatusAction extends JdVerifyAction
9
{
10
    public function run()
11
    {
12
        $params = Yii::$app->request->getBodyParams();
13
        $arrayData = json_decode(base64_decode($params['data']), true);
14
        $orderId = $arrayData['orderId'];
15
        if (($order = Order::findOne(['sn' => Order::SOURCE_JD . $orderId])) == null) {
16
            throw new NotFoundHttpException('订单不存在');
17
        }
18
        $data = [];
19
        if ($order->status > 2) {
20
            $data['orderStatus'] = 0;
21
        } elseif ($order->status > -1) {
22
            $data['orderStatus'] = 1;
23
        } else {
24
            $data['orderStatus'] = 2;
25
        }
26
        return $data;
27
    }
28
}
29