3a892ee0
xu
app-wx(v0.1.0 bui...
|
1
2
3
4
|
<?php
namespace app\wx\modules\order\controllers;
|
1de3211f
xu
app-wx(v0.1.0 bui...
|
5
|
use Yii;
|
bb9baa4c
xu
app-wx v0.1.0 bui...
|
6
|
use common\helpers\ImageManager;
|
1de3211f
xu
app-wx(v0.1.0 bui...
|
7
|
use common\helpers\Utils;
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
8
9
10
|
use domain\order\RepairOrderRate;
use domain\order\RepairOrderRateRepository;
use domain\order\RepairOrderRepository;
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
11
12
13
14
15
|
use domain\order\RepairOrderStatus;
use stdClass;
/**
|
bb9baa4c
xu
app-wx v0.1.0 bui...
|
16
|
* 控制器
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
*/
class CustomerController extends CustomerBaseController
{
/**
* 首页
*/
public function actionIndex()
{
return $this->render('/default/cindex');
}
/**
* @return string
*/
public function actionOrderDetails()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$e->item = [];
$orderUUId = $this->request->post('id');
|
6bece648
xu
app-wx(v0.1.0 bui...
|
38
|
$md5Mobile = $this->request->post('sn');
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
39
40
41
|
$orderModel = RepairOrderRepository::findOne(['short_uuid' => $orderUUId]);
if (empty($orderModel)) {
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
42
|
$e->message = '找不到该订单';
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
43
44
45
46
|
return $this->renderJson($e);
}
$orderId = $orderModel->id;
$brokenImageModels = RepairOrderRepository::findOrderImageAll(['repair_order_id' => $orderId]);
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
47
48
|
$brokenImages = [];
$baseURL = Yii::$app->request->getHostInfo();
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
49
50
51
|
foreach($brokenImageModels as $k => $v) {
$brokenImages[] = [
'url' => ImageManager::getUrl($v->image_path),
|
1de3211f
xu
app-wx(v0.1.0 bui...
|
52
53
54
55
|
'thumb' => ImageManager::getUrl($v->image_path, 'min')
];
}
$totalPrice = $orderModel->order_price;
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
56
57
|
$rPlans = RepairOrderRepository::findOrderPlansAll(['repair_order_id' => $orderId]);
$repairPlans = [];
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
58
|
foreach($rPlans as $k => $plan) {
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
59
60
61
62
|
$repairPlans[] = ['plan' => $plan['repair_plan'] ,'price' => $plan['price']];
}
$fImages = RepairOrderRepository::findOrderFinishImageAll(['repair_order_id' => $orderId]);
$finishImages = [];
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
63
|
foreach($fImages as $k => $image) {
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
64
65
|
$finishImages[] = [
'url' => ImageManager::getUrl($image['image_path']),
|
1de3211f
xu
app-wx(v0.1.0 bui...
|
66
67
68
69
|
'thumb' => ImageManager::getUrl($image['image_path'], 'min')
];
}
$comments = [];
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
70
|
$hasComment = false;
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
71
|
$rateModel = RepairOrderRateRepository::findOne(['repair_order_id' => $orderId]);
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
72
|
if ($rateModel) {
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
73
74
75
|
$hasComment = true;
$comments = [
'starTxt' => RepairOrderRate::starLabel($rateModel->star_count),
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
76
77
78
79
80
81
82
|
'qualityStarTxt' => RepairOrderRate::starLabel($rateModel->quality_star),
'effectStarTxt' => RepairOrderRate::starLabel($rateModel->effect_star),
'serviceStarTxt' => RepairOrderRate::starLabel($rateModel->service_star),
'comment' => $rateModel->comment,
];
}
$preFinishDate = '暂无';
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
83
|
$predictPrice = '暂无';
|
32926e46
xu
app-wx(v0.1.0 bui...
|
84
85
86
87
88
89
90
91
|
if($orderModel->predict_finish_time) {
$preFinishDate = date('Y-m-d H:00', $orderModel->predict_finish_time);
}
if($orderModel->predict_price) {
$predictPrice = $orderModel->predict_price.'元';
}
$e->success = true;
$e->item = [
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
92
93
94
95
96
97
|
'carNo' => $orderModel->car_no,
'carModel' => $orderModel->car_model,
'customer' => $orderModel->customer,
'mobile' => '1*****'.substr($orderModel->contact_mobile,7,4),
'preRepair' => empty($orderModel->predict_fault)?'暂无':$orderModel->predict_fault,
'repairPrice' => $predictPrice,
|
32926e46
xu
app-wx(v0.1.0 bui...
|
98
99
100
|
'preFinishDate' => $preFinishDate,
'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at),
'status' => RepairOrderStatus::getEnLabel($orderModel->status),
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
101
102
103
|
'hasComment' => $hasComment,
'comments' => $comments,
'brokenImages' => $brokenImages,
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
104
|
'repairPlans' => $repairPlans,
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
'totalPrice' => $totalPrice,
'finishImages' => $finishImages
];
return $this->renderJson($e);
}
/**
* @return string
*/
public function actionSubmitRate()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$qualityStar = $this->request->post('qualityStar');
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
122
123
124
125
|
$effectStar = $this->request->post('effectStar');
$serviceStar = $this->request->post('serviceStar');
$orderUUId = $this->request->post('id');
$comment = $this->request->post('comment');
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
126
|
$images = $this->request->post('images');
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
127
|
$userId = $this->getUserId();
|
bb9baa4c
xu
app-wx v0.1.0 bui...
|
128
|
$orderModel = RepairOrderRepository::findOne(['short_uuid' => $orderUUId]);
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
129
|
if (empty($orderModel)) {
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
$e->message = '找不到订单';
return $this->renderJson($e);
}
if (RepairOrderStatus::WORKING == $orderModel->status) {
$e->message = '订单还在维修中';
return $this->renderJson($e);
}
if(mb_strlen($comment) > 200) {
$e->message = '评论只能200字内';
return $this->renderJson($e);
}
$rateModel = RepairOrderRateRepository::findOne(['repair_order_id' => $orderModel->id]);
if ($rateModel) {
$e->message = '已经评价过了';
return $this->renderJson($e);
}
if ($userId > 0) {
$e->message = '维修厂人员不能评论';
//return $this->renderJson($e);
}
$items = [
|
d11ff394
xu
app-ht(v0.0.1 bui...
|
152
|
'ip_address' => Utils::clientIp(),
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
153
154
155
|
'customer_id' => 0,
'quality_star' => $qualityStar,
'effect_star' => $effectStar,
|
d11ff394
xu
app-ht(v0.0.1 bui...
|
156
|
'service_star' => $serviceStar,
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
157
158
159
|
'repair_order_id' => $orderModel->id,
'comment' => $comment,
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
160
161
|
];
$rateModel = RepairOrderRate::create($items);
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
162
|
$commentImages = RepairOrderRate::mvImages($orderModel->uuid, $images);
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
163
164
|
$images = [];
if ($commentImages) {
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
165
166
|
foreach($commentImages as $k => $v) {
$images[] = $v[0].$v[1];
|
c6779489
xu
app-wx(v0.1.0 bui...
|
167
168
169
170
|
}
}
if ($images) {
|
afd2f743
xu
app-ht(v0.0.1 bui...
|
171
|
$rateModel->images = implode(',', $images);
|
c6779489
xu
app-wx(v0.1.0 bui...
|
172
173
174
175
176
177
178
|
$rateModel->save();
}
if ($rateModel) {
$e->success = true;
$e->message = '提交成功';
} else {
|
6bece648
xu
app-wx(v0.1.0 bui...
|
179
|
$e->message = '提交评论失败';
|
f3ed8f51
xu
app-wx(v0.1.0 bui...
|
180
181
182
183
|
}
return $this->renderJson($e);
}
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
184
|
|
3a892ee0
xu
app-wx(v0.1.0 bui...
|
185
|
}
|