Commit c5fc49f74173e73b84bac851784472271ec4368c
1 parent
d25e945b
Exists in
master
1. 微信扫码功能集成。
Showing
13 changed files
with
100 additions
and
1517 deletions
Show diff stats
app-wx/config/main.php
... | ... | @@ -14,9 +14,6 @@ return [ |
14 | 14 | 'controllerNamespace' => 'app\wx\controllers', |
15 | 15 | 'defaultRoute' => 'smart', |
16 | 16 | 'modules' => [ |
17 | - 'device' => [ | |
18 | - 'class' => 'app\wx\modules\device\Module', | |
19 | - ], | |
20 | 17 | 'smart' => [ |
21 | 18 | 'class' => 'app\wx\modules\smart\Module', |
22 | 19 | ] |
... | ... | @@ -24,7 +21,7 @@ return [ |
24 | 21 | 'components' => [ |
25 | 22 | 'user' => [ |
26 | 23 | 'class'=> 'app\wx\exts\User', |
27 | - 'identityClass' => 'domain\user\UserRepository', | |
24 | + 'identityClass' => 'domain\user\models\User', | |
28 | 25 | 'enableAutoLogin' => true,//是否启用自动登录 |
29 | 26 | ], |
30 | 27 | 'errorHandler' => [ |
... | ... | @@ -34,14 +31,12 @@ return [ |
34 | 31 | 'forceCopy' => true, //每次都发布文件 |
35 | 32 | 'appendTimestamp' => true, //后面加上时间戳,防止缓存。 |
36 | 33 | ], |
37 | - /* | |
38 | 34 | 'urlManager' => [ |
39 | 35 | 'enablePrettyUrl' => true, |
40 | 36 | 'showScriptName' => false, |
41 | 37 | 'rules' => [ |
42 | 38 | ], |
43 | 39 | ], |
44 | - */ | |
45 | 40 | ], |
46 | 41 | 'params' => $params, |
47 | 42 | ]; | ... | ... |
app-wx/config/params.php
... | ... | @@ -3,4 +3,5 @@ return [ |
3 | 3 | 'adminEmail' => 'admin@example.com', |
4 | 4 | 'DEVICE_PAGE_SETTINGS' => ['break_upload' => 0], |
5 | 5 | 'VERSION' => 'v2.1.9 build 3', // 当前发布版本号: v0.1.0 是版本号 | build 1 是编译次数 |
6 | + 'STOP_SITES' => ['stop'=> false, 'stop_head' => '系统维护中...', 'stop_content' => '预计需要25分钟'], | |
6 | 7 | ]; | ... | ... |
app-wx/controllers/BaseController.php
... | ... | @@ -196,17 +196,12 @@ class BaseController extends AppController |
196 | 196 | */ |
197 | 197 | private function handleOAuthRedirect() |
198 | 198 | { |
199 | - $sn = Yii::$app->request->get("sn"); | |
200 | - | |
201 | - if ($sn) { | |
202 | - $redirectUri = WxHelper::getDomain(true) . Url::toRoute(['/wechat/bridging?sn=' . $sn .'&tourl='. urlencode($this->site->url)]); | |
203 | - } else { | |
204 | - $redirectUri = WxHelper::getDomain(true) . Url::toRoute(['/wechat/login-proccess', 'dest' => $this->site->url]); | |
205 | - } | |
199 | + $redirectUri = WxHelper::getDomain(true) . Url::toRoute(['/wechat/login-proccess', 'dest' => $this->site->url]); | |
206 | 200 | |
207 | 201 | AppLog::DEBUG("BaseController::handleOAuthRedirect() --> 开始重定向跳转 redirectUri={$redirectUri}"); |
208 | 202 | $wechat = WxHelper::getWxPHPSDK(); |
209 | - $OAuthUrl = $wechat->getOAuthRedirect($redirectUri, 'jiwork', 'snsapi_base'); | |
203 | + $OAuthUrl = $wechat->getOAuthRedirect($redirectUri, 'smart', 'snsapi_base'); | |
204 | + AppLog::DEBUG("BaseController::handleOAuthRedirect() --> 开始重定向跳转 OAuthUrl={$OAuthUrl}"); | |
210 | 205 | Yii::$app->response->redirect($OAuthUrl)->send(); |
211 | 206 | Yii::$app->end(); |
212 | 207 | } |
... | ... | @@ -479,4 +474,27 @@ class BaseController extends AppController |
479 | 474 | mkdir($tmpFilePath, 0777, true); |
480 | 475 | } |
481 | 476 | } |
477 | + | |
478 | + /**检测用户去到哪个状态,根据状态跳转页面 | |
479 | + * @param string $view | |
480 | + * @param bool|false $return 标明要直接跳转还是要返回数组 | |
481 | + * @return array | |
482 | + */ | |
483 | + public function checkUserlevel($view = '', $return = false, $needPower = "default") | |
484 | + { | |
485 | + // getIdentity 可能要定时更新session 才行,不然审核通过后无法更新这个数据 | |
486 | + $user = Yii::$app->getUser()->getIdentity(); | |
487 | + switch ($needPower) { | |
488 | + case "none": | |
489 | + // 无需验证 | |
490 | + if ($return == true) { | |
491 | + return array('success'=> false, 'redirect_url'=>''); | |
492 | + } | |
493 | + break; | |
494 | + | |
495 | + default: | |
496 | + break; | |
497 | + } | |
498 | + } | |
499 | + | |
482 | 500 | } |
483 | 501 | \ No newline at end of file | ... | ... |
app-wx/modules/smart/controllers/BaseController.php
... | ... | @@ -18,9 +18,7 @@ class BaseController extends AppBaseController |
18 | 18 | public function init() |
19 | 19 | { |
20 | 20 | parent::init(); // TODO: Change the autogenerated stub |
21 | -// $this->checkClientStatus(); | |
22 | -// $this->handleMallAccessCtrl(); | |
23 | -// $this->checkEngineerSubscribe(Yii::$app->user->identity->subscribe); | |
24 | -// $this->checkEngineerBlockOrDisable(Yii::$app->user->identity->status,true); | |
21 | + $this->checkClientStatus(); | |
22 | + $this->handleMallAccessCtrl(); | |
25 | 23 | } |
26 | 24 | } |
27 | 25 | \ No newline at end of file | ... | ... |
app-wx/modules/smart/controllers/DefaultController.php
... | ... | @@ -4,56 +4,12 @@ namespace app\wx\modules\smart\controllers; |
4 | 4 | |
5 | 5 | use Yii; |
6 | 6 | use yii\base\Exception; |
7 | -use yii\data\Pagination; | |
8 | -use yii\db\Query; | |
9 | -use yii\helpers\HtmlPurifier; | |
10 | -use common\business\EngineerLevel; | |
11 | -use domain\engineer\CustomizedQrcodeTemplate; | |
12 | -use domain\engineer\CustomizedQrcodeTemplateRepository; | |
13 | -use domain\trade\RepairOrderType; | |
14 | -use common\models\Address as AddressModel; | |
15 | -use common\models\Client as ClientModel; | |
16 | -use app\wx\models\Engineer as EngineerModel; | |
17 | -use domain\user\models\UserEngineerFav as UserEngineerFavModel; | |
18 | -use domain\engineer\models\EngineerPhoneCode as EngineerPhoneCodeModel; | |
19 | -use domain\engineer\SkillTagRepository as SkillTagRepositoryModel; | |
20 | -use common\models\EngineerProfile as EngineerProfileModel; | |
21 | -use common\models\EngineerScoreRecord as EngineerScoreRecordModel; | |
22 | -use common\models\EngineerSkills as EngineerSkillsModel; | |
23 | -use common\models\RepairOrder as RepairOrderModel; | |
24 | -use common\models\User as UserModel; | |
25 | -use common\models\RepairOrderRateTag as RepairOrderRateTagModel; | |
26 | -use common\models\SysSetting as SysSettingModel; | |
27 | -use domain\finance\models\EngineerOrderIncome as EngineerOrderIncomeModel; | |
28 | -use domain\engineer\EngineerPhoneCode; | |
29 | -use domain\finance\EngineerOrderIncomeRepository; | |
30 | -use domain\trade\RepairOrderRepository; | |
31 | -use common\exts\BDAISDK\AipFace; | |
32 | -use domain\system\message\SmsMessage; | |
33 | -use domain\engineer\EngineerStatus; | |
34 | -use domain\trade\RepairOrderStatus; | |
35 | -use domain\engineer\EngineerHeadphotoUploadLog; | |
36 | -use domain\engineer\EngineerCustomizedQrcodeRepository; | |
37 | -use domain\device\EngineerQrcodeApplyRepository; | |
38 | -use domain\engineer\EngineerPhoneCodeRepository; | |
39 | -use domain\engineer\EngineerRepository; | |
40 | -use domain\engineer\EngineerSkillTags; | |
41 | -use domain\engineer\EngineerSkillTagsRepository; | |
42 | -use common\helpers\Utils; | |
43 | -use common\helpers\Log as AppLog; | |
44 | -use common\helpers\ImageManager; | |
45 | -use common\helpers\OrderSqlHelper; | |
46 | -use common\helpers\WxHelper; | |
47 | -use domain\system\message\CustomMessage; | |
48 | -use domain\engineer\EngineerCustomizedQrcodeApply; | |
49 | -use stdClass; | |
50 | 7 | |
51 | 8 | /** |
52 | 9 | * 用户-控制器 |
53 | 10 | */ |
54 | 11 | class DefaultController extends BaseController |
55 | 12 | { |
56 | - private $userModel; | |
57 | 13 | const CHANGE_PHONE_TIMES = 3; |
58 | 14 | /** |
59 | 15 | * 账号设置 |
... | ... | @@ -62,1400 +18,4 @@ class DefaultController extends BaseController |
62 | 18 | { |
63 | 19 | return $this->render('index'); |
64 | 20 | } |
65 | - | |
66 | - /** | |
67 | - * 更新工程师地址 | |
68 | - * @return stdClass | |
69 | - * @throws yii\base\ErrorException | |
70 | - */ | |
71 | - public function actionUpdateEngineerAddress() | |
72 | - { | |
73 | - $e = new stdClass(); | |
74 | - $e->success = false; | |
75 | - $userModel = $this->getUserModel(); | |
76 | - | |
77 | - if($this->request->isPost && $userModel){ | |
78 | - $address = $this->request->post('address'); | |
79 | - $address = HtmlPurifier::process($address,['HTML.Allowed' => '']); | |
80 | - | |
81 | - $longitude = (float)$this->request->post('longitude'); | |
82 | - $latitude = (float)$this->request->post('latitude'); | |
83 | - | |
84 | - if ($userModel->address_id == 0) { // 地址还不存在, 创建 | |
85 | - $addressModel = new AddressModel([ | |
86 | - 'address' => $address, | |
87 | - 'longitude' => $longitude, | |
88 | - 'latitude' => $latitude, | |
89 | - 'type' => AddressModel::TYPE_LBS | |
90 | - ]); | |
91 | - if ($addressModel->save()) { | |
92 | - $userModel->address_id = $addressModel->id; | |
93 | - if($userModel->save()){ | |
94 | - $e->success = true; | |
95 | - return $e; | |
96 | - }else { | |
97 | - throw new Exception(implode("\r\n", $userModel->getFirstErrors())); | |
98 | - } | |
99 | - } else { | |
100 | - throw new Exception(implode("\r\n", $addressModel->getFirstErrors())); | |
101 | - } | |
102 | - }else { | |
103 | - $addressModel = AddressModel::findOne($userModel->address_id); | |
104 | - $addressModel->address = $address; | |
105 | - $addressModel->longitude = $longitude; | |
106 | - $addressModel->latitude = $latitude; | |
107 | - if ($addressModel->save()) { | |
108 | - $e->success = true; | |
109 | - return $e; | |
110 | - } else { | |
111 | - throw new Exception(implode("\r\n", $addressModel->getFirstErrors())); | |
112 | - } | |
113 | - } | |
114 | - } | |
115 | - | |
116 | - $e->error = '更新工程师地址失败'; | |
117 | - return $e; | |
118 | - } | |
119 | - | |
120 | - /** | |
121 | - * @return string | |
122 | - */ | |
123 | - public function actionAjaxMgets() | |
124 | - { | |
125 | - $e = new stdClass(); | |
126 | - $e->success = true; | |
127 | - $e->content = $this->mgets(); | |
128 | - | |
129 | - return $this->renderJson($e); | |
130 | - } | |
131 | - | |
132 | - /** | |
133 | - * @return stdClass | |
134 | - */ | |
135 | - private function mgets() | |
136 | - { | |
137 | - //获取当前用户的模型model | |
138 | - $userId = $this->getUserId(); | |
139 | - | |
140 | - $home = new stdClass(); | |
141 | - /** | |
142 | - * 构造user的共用信息 | |
143 | - */ | |
144 | - $home->user = $this->buildUserResult($userId); | |
145 | - | |
146 | - return $home; | |
147 | - } | |
148 | - | |
149 | - /** | |
150 | - * @param $engineerModel | |
151 | - * @return stdClass | |
152 | - */ | |
153 | - private function buildUserResult($userId) | |
154 | - { | |
155 | - $query = EngineerModel::find() | |
156 | - ->select(['engineer.*', 'engineer_profile.nickname as nickname', | |
157 | - 'engineer_profile.firstname as firstname','engineer_profile.firstname as firstname', | |
158 | - 'engineer_profile.lastname as lastname', | |
159 | - 'engineer_profile.head_photo as head_photo', | |
160 | - 'engineer_profile.headimgurl as headimgurl', | |
161 | - 'engineer_profile.star as star', | |
162 | - 'engineer_profile.level as level', | |
163 | - 'engineer_profile.level_score as level_score', | |
164 | - 'engineer_wallet.balance as balance', | |
165 | - 'engineer_profile.auto_to_door as auto_to_door' | |
166 | - ]) | |
167 | - ->leftJoin('engineer_profile', "engineer.id = engineer_profile.engineer_id") | |
168 | - ->leftJoin('engineer_wallet', "engineer.id = engineer_wallet.engineer_id") | |
169 | - ->where(['engineer.id' => $userId]); | |
170 | - $query->asArray(); | |
171 | - $engineerArray = $query->one(); | |
172 | - | |
173 | - if(empty($engineerArray)){ | |
174 | - return false; | |
175 | - } | |
176 | - | |
177 | - $engineer = new stdClass(); | |
178 | - $engineer->id = (int)$engineerArray['id']; | |
179 | - $engineer->status = $engineerArray['status']; | |
180 | - $engineer->is_order_sms_notify = $engineerArray['is_order_sms_notify']; | |
181 | - $engineer->is_order_wx_notify = $engineerArray['is_order_wx_notify']; | |
182 | - $engineer->auto_to_door = $engineerArray['auto_to_door']; | |
183 | - | |
184 | - if ( $engineerArray['status'] >= EngineerStatus::STATUS_REALNAME_AUTH && $engineerArray['status'] != EngineerStatus::STATUS_REALNAME_FAIL ){ | |
185 | - //通过实名认证显示认证过的头像 | |
186 | - $engineer->headimgurl = ImageManager::getUrl($engineerArray['head_photo'], ImageManager::$STYLE_180); | |
187 | - $engineer->nickname = $engineerArray['firstname'].$engineerArray['lastname']; | |
188 | - $engineer->auth = 1; | |
189 | - | |
190 | - } else { // 未认证显示微信头像 | |
191 | - $engineer->headimgurl = WxHelper::exchangeHeadImgSize($engineerArray['headimgurl'], 132); | |
192 | - $engineer->nickname = $engineerArray['nickname']; | |
193 | - $engineer->auth=0; | |
194 | - } | |
195 | - $engineer->star = $engineerArray['star']; | |
196 | - if( '' == $engineerArray['balance'] || null == $engineerArray['balance']){ | |
197 | - $balance = '0.00'; | |
198 | - } else { | |
199 | - $balance = $engineerArray['balance']; | |
200 | - } | |
201 | - $engineer->invite_code = $engineerArray['invite_code']; | |
202 | - $engineer->balance = $balance; | |
203 | - $engineer->level = $engineerArray['level']; | |
204 | - $engineer->level_score = $engineerArray['level_score']; | |
205 | - if (empty($engineerArray["level_score"]) || $engineerArray["level_score"] <= 0) { | |
206 | - $result = self::getLevelScoreDetail($engineerArray['id']); | |
207 | - $engineer->level_score = $result->level_score; | |
208 | - } | |
209 | - | |
210 | - // 工程师待入账的订单收入总额 | |
211 | - $engineer->waitIncome = EngineerOrderIncomeRepository::getEngineerTotalAmount($userId, EngineerOrderIncomeModel::STATUS_WAIT); | |
212 | - | |
213 | - // 有【游客权限】 或 已通过【游客设备接单考试】的工程师,可申领二维码 | |
214 | - $canSubmitQrcodeApply = EngineerQrcodeApplyRepository::canSubmitQrcodeApply($userId); | |
215 | - if ($canSubmitQrcodeApply) { | |
216 | - $engineer->canApplyQrcode = true; | |
217 | - } else { | |
218 | - $engineer->canApplyQrcode = false; | |
219 | - } | |
220 | - $engineer->phone = $engineerArray["phone"]; | |
221 | - $engineer->hide_phone = Utils::hidePhoneNumber($engineerArray["phone"]); | |
222 | - | |
223 | - //工程师当前生成模板的模板编号 | |
224 | - $defaultTemplateData = CustomizedQrcodeTemplateRepository::findOne(["is_default" => CustomizedQrcodeTemplate::STATUS_DEFAULT]); | |
225 | - $defaultTemplateId = isset($defaultTemplateData->id) ? $defaultTemplateData->id : EngineerCustomizedQrcodeApply::DEFAULT_QRCODE_TEMPLATE_ID; | |
226 | - $engineer->qrcode_template_id = $defaultTemplateId; | |
227 | - $engineerCustomizedQrcode = EngineerCustomizedQrcodeRepository::findOne(["engineer_id" => $userId]); | |
228 | - if ($engineerCustomizedQrcode) { | |
229 | - $engineer->qrcode_template_id = $engineerCustomizedQrcode->template_id; | |
230 | - } | |
231 | - $engineer->vip_status = $engineerArray["vip_status"]; | |
232 | - $engineer->original_status = $engineerArray["original_status"]; | |
233 | - | |
234 | - // 工程师标签选择 | |
235 | - $engineerSkillTags = EngineerSkillTagsRepository::getEngineerSkillTags($userId); | |
236 | - $engineer->selectTags = false; | |
237 | - if (!empty($engineerSkillTags)) { | |
238 | - $engineer->selectTags = true; | |
239 | - } | |
240 | - | |
241 | - // 工程师已更换手机号码次数 | |
242 | - $engineer->change_phone_times = $engineerArray["change_phone_times"]; | |
243 | - $engineer->limit_change_phone_times = (3 - $engineerArray["change_phone_times"]) >= 0 ? (3 - $engineerArray["change_phone_times"]) : 0; | |
244 | - | |
245 | - return $engineer; | |
246 | - } | |
247 | - | |
248 | - /** | |
249 | - * 个人信息 | |
250 | - * @return string | |
251 | - */ | |
252 | - public function actionAjaxProfile() | |
253 | - { | |
254 | - $e = new stdClass(); | |
255 | - $e->success = false; | |
256 | - $e->user = null; | |
257 | - | |
258 | - if($this->request->isGet){ | |
259 | - $e->success = true; | |
260 | - $userId = $this->getUserId(); | |
261 | - $e->user = $this->buildAjaxProfileResult($userId); | |
262 | - } | |
263 | - | |
264 | - return $this->renderJson($e); | |
265 | - } | |
266 | - | |
267 | - /** | |
268 | - * 构造个人信息返回的AJAX结果 | |
269 | - * @param $userModel | |
270 | - * @return stdClass | |
271 | - */ | |
272 | - private function buildAjaxProfileResult($userId) | |
273 | - { | |
274 | - /** | |
275 | - * 构造user的共用信息 | |
276 | - */ | |
277 | - $user = $this->buildUserResult($userId); | |
278 | - | |
279 | - return $user; | |
280 | - } | |
281 | - | |
282 | - /** | |
283 | - * 保存个人信息 | |
284 | - * @return string | |
285 | - */ | |
286 | - public function actionAjaxSaveProfile() | |
287 | - { | |
288 | - $e = new stdClass(); | |
289 | - $e->success = false; | |
290 | - $userModel = $this->getUserModel(); | |
291 | - | |
292 | - if($this->request->isPost && $userModel){ | |
293 | - $gender = (int)$this->request->post('gender'); | |
294 | - $profile = $userModel->profile; | |
295 | - $profile->gender = $gender; | |
296 | - if($profile->save()){ | |
297 | - $e->success = true; | |
298 | - $e->user = $this->buildAjaxProfileResult($userModel->user_id); | |
299 | - } | |
300 | - } | |
301 | - | |
302 | - return $this->renderJson($e); | |
303 | - } | |
304 | - | |
305 | - | |
306 | - /** | |
307 | - * @return null|static | |
308 | - */ | |
309 | - private function getUserModel() | |
310 | - { | |
311 | - if(null === $this->userModel){ | |
312 | - $appUser = Yii::$app->getUser(); | |
313 | - $this->userModel = EngineerModel::findOne($appUser->getId()); | |
314 | - } | |
315 | - | |
316 | - return $this->userModel; | |
317 | - } | |
318 | - | |
319 | - /** | |
320 | - * 获取个人资料 | |
321 | - */ | |
322 | - public function actionGetProfile() | |
323 | - { | |
324 | - // 获取当前用户的模型model | |
325 | - $userId = $this->getUserId(); | |
326 | - | |
327 | - $e = new stdClass(); | |
328 | - $e->success = true; | |
329 | - | |
330 | - /** | |
331 | - * 构造user的共用信息 | |
332 | - */ | |
333 | - $this->updateEngineerInviteCode($userId); //更新工程师邀请码(有不更新,没有的时候更新) | |
334 | - $e->engineer = $this->buildUserResult($userId); | |
335 | - $rpOrder = RepairOrderModel::find(); | |
336 | - $orderStatus = RepairOrderStatus::completeOrderStatus(); | |
337 | - $rpOrder->where(['repair_order.engineer_id' =>$userId,'status'=>$orderStatus, 'is_system_delete' => 0]); | |
338 | - $occ = $rpOrder->count(); | |
339 | - $e->order_count = $occ?$occ:0; | |
340 | - | |
341 | - | |
342 | - /**************** get settting info start ************************/ | |
343 | - | |
344 | - // 获取当前服务协议版本信息 | |
345 | - $settings = WxHelper::getMpSetting(); | |
346 | - // 资料设置 | |
347 | - $setting = new stdClass(); | |
348 | - // 服务协议版本号 | |
349 | - $setting->agreement_version = isset($settings->agreement_version) ? $settings->agreement_version : ''; | |
350 | - // 服务协议版本更新描述 | |
351 | - $setting->agreement_update_desc = isset($settings->agreement_update_desc) ? str_replace("\n","<br/>",$settings->agreement_update_desc) : ''; | |
352 | - // 工程师认证状态,status是6,即已完成技能认证的时候才弹出协议 | |
353 | - $setting->status = $e->engineer->status; | |
354 | - | |
355 | - $e->setting = $setting; | |
356 | - | |
357 | - /**************** get settting info end ************************/ | |
358 | - | |
359 | - return $this->renderJson($e); | |
360 | - } | |
361 | - | |
362 | - /** | |
363 | - * 更新工程师邀请码 | |
364 | - * @param $engineer_id 工程师编号 | |
365 | - */ | |
366 | - private function updateEngineerInviteCode($engineer_id){ | |
367 | - $engineer_info = EngineerModel::findOne($engineer_id); | |
368 | - if($engineer_info){ | |
369 | - if(empty($engineer_info["invite_code"])){ | |
370 | - $engineer_info->invite_code = EngineerModel::createInviteCode($engineer_id); | |
371 | - $engineer_info->save(); | |
372 | - } | |
373 | - } | |
374 | - } | |
375 | - | |
376 | - /** | |
377 | - * 查看等级得分 | |
378 | - */ | |
379 | - public function actionLevelScoreDetail() | |
380 | - { | |
381 | - $userId = $this->getUserId(); | |
382 | - $e = new stdClass(); | |
383 | - $e->success = false; | |
384 | - $engineerScoreRecord = EngineerScoreRecordModel::findOne(["engineer_id"=>$userId, "FROM_UNIXTIME(created_at,'%Y-%m-%d')" => date("Y-m-d", time())]); | |
385 | - if (!empty($engineerScoreRecord)) { | |
386 | - $e->success = true; | |
387 | - $engineerScoreRecord["level"] = EngineerLevel::levelLabels($engineerScoreRecord["level"]); | |
388 | - $e->engineer_score_record = $engineerScoreRecord; | |
389 | - } else { | |
390 | - $e->success = true; | |
391 | - $e->engineer_score_record = self::getLevelScoreDetail($userId); | |
392 | - } | |
393 | - | |
394 | - return $this->renderJson($e); | |
395 | - } | |
396 | - | |
397 | - /** | |
398 | - * 实时读取工程师等级得分明细 | |
399 | - * @param $engineer | |
400 | - * @return stdClass | |
401 | - */ | |
402 | - private static function getLevelScoreDetail($userId) | |
403 | - { | |
404 | - $engineer = EngineerModel::findOne($userId); | |
405 | - if (false == $engineer) { | |
406 | - return false; | |
407 | - } | |
408 | - | |
409 | - $levelScordDetail = new stdClass(); | |
410 | - | |
411 | - // 工程师综合评分 | |
412 | - $engineerStar = $engineer->engineerProfile->star; | |
413 | - $engineerStarScore = EngineerLevel::calEngineerStarScore($engineerStar); | |
414 | - $levelScordDetail->order_score = $engineerStarScore; | |
415 | - $levelScordDetail->order_star = empty($engineerStar) ? 0 : $engineerStar ; | |
416 | - | |
417 | - // 上个月完单量 | |
418 | - $lastMon = date('Y-m', strtotime('-1 MONTH', time())); | |
419 | - $lastMonOrderCount = RepairOrderModel::find() | |
420 | - ->alias("ro") | |
421 | - ->leftJoin("repair_order_detail rod","rod.repair_order_id = ro.id") | |
422 | - ->where(OrderSqlHelper::SQL_WHERE_DONE ." and DATE_FORMAT(FROM_UNIXTIME(rod.pay_at), '%Y-%m') = '{$lastMon}' and ro.engineer_id={$engineer->id}") | |
423 | - ->count(); | |
424 | - $levelScordDetail->last_month_order_score = EngineerLevel::calLastMonOrderScore($lastMonOrderCount); | |
425 | - $levelScordDetail->last_month_order_count = $lastMonOrderCount; | |
426 | - | |
427 | - // 历史累计订单量 | |
428 | - $totalOrderCount = RepairOrderModel::find() | |
429 | - ->alias("ro") | |
430 | - ->leftJoin("repair_order_detail rod","rod.repair_order_id = ro.id") | |
431 | - ->where(OrderSqlHelper::SQL_WHERE_DONE . " and ro.engineer_id={$engineer->id}") | |
432 | - ->count(); | |
433 | - $levelScordDetail->total_order_score = EngineerLevel::calTotalOrderScore($totalOrderCount); | |
434 | - $levelScordDetail->total_order_count = $totalOrderCount; | |
435 | - | |
436 | - // @TODO: 上个月客户投诉次数[待运营确定投诉规则] | |
437 | - $lastMonUserAppealCount = 0; | |
438 | - $lastMonUserAppealScore = EngineerLevel::calLastMonUserAppealScore($lastMonUserAppealCount); | |
439 | - $levelScordDetail->last_month_user_appeal_score = $lastMonUserAppealScore; | |
440 | - $levelScordDetail->last_month_user_appeal_count = $lastMonUserAppealCount; | |
441 | - | |
442 | - // 线下技能实操考试通过数量 | |
443 | - $passSkillCount = EngineerSkillsModel::find() | |
444 | - ->where(['engineer_id' => $engineer->id, 'status' => EngineerSkillsModel::STATUS_PASS,'pass_pratice'=>true]) | |
445 | - ->count(); | |
446 | - $levelScordDetail->pass_skill_score = EngineerLevel::calPassSkillScore($passSkillCount); | |
447 | - $levelScordDetail->pass_skill_count = $passSkillCount; | |
448 | - | |
449 | - $finalScore = $engineerStarScore + $levelScordDetail->last_month_order_score + $levelScordDetail->total_order_score + $lastMonUserAppealScore + $levelScordDetail->pass_skill_score; | |
450 | - $levelScordDetail->level_score = $finalScore; | |
451 | - | |
452 | - $currentLevelLabel = EngineerLevel::levelLabels($engineer->engineerProfile->level); | |
453 | - $levelScordDetail->level = $currentLevelLabel; | |
454 | - // $newLevel = EngineerLevel::getLevelByScore($finalScore); | |
455 | - // $newLevelLabel = EngineerLevel::levelLabels($newLevel); | |
456 | - // '实时计算等级-' . $newLevelLabel . '(' . $newLevel . ')'; | |
457 | - | |
458 | - return $levelScordDetail; | |
459 | - } | |
460 | - | |
461 | - /** | |
462 | - * 获取用户设备信息 | |
463 | - * 账号状态:0未认证;1手机验证;2实名认证中;3实名认证通过;4实名认证失败;5技能认证中;6技能认证通过;7技能认证失败;101禁用;102封号; | |
464 | - */ | |
465 | - public function actionGetEngineerInfo() | |
466 | - { | |
467 | - $e = new stdClass(); | |
468 | - $e->success = false; | |
469 | - | |
470 | - if (false == $this->request->isPost) { | |
471 | - $e->success = false; | |
472 | - return $this->renderJson($e); | |
473 | - } | |
474 | - | |
475 | - $userId = $this->request->post('engineerId'); | |
476 | - if ($userId) { | |
477 | - if ($userId != $this->getUserId()) { | |
478 | - $e->success = false; | |
479 | - return $this->renderJson($e); | |
480 | - } | |
481 | - } | |
482 | - | |
483 | - $userId = empty($userId) ? $this->getUserId() : $userId; | |
484 | - $result = EngineerModel::getEngineerInfoById($userId); | |
485 | - if ($result == false) { | |
486 | - $e->mes = "工程师不存在"; | |
487 | - return $this->renderJson($e); | |
488 | - } | |
489 | - | |
490 | - $engineerProfile = EngineerProfileModel::find()->where(['engineer_id' => $userId])->one(); | |
491 | - $result["engineer"]["realname"] = $engineerProfile->firstname.$engineerProfile->lastname; | |
492 | - $e->success = true; | |
493 | - $e->engineer = $result["engineer"]; | |
494 | - //$e->rate_tags = $result["rate_tags"]; | |
495 | - $e->rate_orders = $result["rate_orders"]; | |
496 | - | |
497 | - return $this->renderJson($e); | |
498 | - } | |
499 | - | |
500 | - /** | |
501 | - * 获取服务协议版本信息设置 | |
502 | - */ | |
503 | - public function actionGetServiceVersion() | |
504 | - { | |
505 | - $e = new stdClass(); | |
506 | - $e->success = true; | |
507 | - $e->showAgreement = false; | |
508 | - $e->agreement_update_desc = ''; | |
509 | - | |
510 | - $userId = $this->getUserId(); | |
511 | - //获取当前用户的模型model | |
512 | - $engineer = EngineerRepository::selectOne($userId); | |
513 | - | |
514 | - // 获取当前服务协议版本信息 | |
515 | - $settings = WxHelper::getMpSetting(); | |
516 | - | |
517 | - /** | |
518 | - * 只是针对技能审核通过的工程师才阅读协议 | |
519 | - */ | |
520 | - if (EngineerStatus::STATUS_SKILL_AUTH != $engineer->status) { | |
521 | - return $this->renderJson($e); | |
522 | - } | |
523 | - if (empty($engineer->service_agreement_version)) { | |
524 | - $e->showAgreement = true; | |
525 | - $e->agreement_update_desc = isset($settings->agreement_update_desc) ? str_replace("\n", "<br/>", $settings->agreement_update_desc) : ''; | |
526 | - return $this->renderJson($e); | |
527 | - } | |
528 | - if ($engineer->service_agreement_version != $settings->agreement_version) { | |
529 | - $e->showAgreement = true; | |
530 | - $e->agreement_update_desc = isset($settings->agreement_update_desc) ? str_replace("\n", "<br/>", $settings->agreement_update_desc) : ''; | |
531 | - return $this->renderJson($e); | |
532 | - } | |
533 | - | |
534 | - return $this->renderJson($e); | |
535 | - } | |
536 | - | |
537 | - /** | |
538 | - * 阅读 工程师服务 | |
539 | - * @return string | |
540 | - * @throws \yii\base\ErrorException | |
541 | - */ | |
542 | - public function actionReadServiceAgreement() | |
543 | - { | |
544 | - $e = new stdClass(); | |
545 | - $e->success = false; | |
546 | - $e->message = ''; | |
547 | - $userId = $this->getUserId(); | |
548 | - $engineerModel = EngineerRepository::selectOne($userId); | |
549 | - // 获取当前服务协议版本信息 | |
550 | - $settings = WxHelper::getMpSetting(); | |
551 | - $currVersion = $settings->agreement_version; | |
552 | - if(!$engineerModel) { | |
553 | - $e->message = '找不到工程师'; | |
554 | - return $this->renderJson($e); | |
555 | - } | |
556 | - $engineerModel->service_agreement_version = $currVersion; | |
557 | - $result = $engineerModel->save(); | |
558 | - if ($result) { | |
559 | - $e->success = true; | |
560 | - } else { | |
561 | - $e->message = '未阅读成功'; | |
562 | - } | |
563 | - return $this->renderJson($e); | |
564 | - } | |
565 | - | |
566 | - /** | |
567 | - * 获取极办公服务协议是否已阅读 | |
568 | - */ | |
569 | - public function actionShowJiworkServiceAgreement() | |
570 | - { | |
571 | - $e = new stdClass(); | |
572 | - $e->showAgreement = false; | |
573 | - $e->message = ''; | |
574 | - | |
575 | - $userId = $this->getUserId(); | |
576 | - $engineerModel = EngineerRepository::selectOne($userId); | |
577 | - if(!$engineerModel) { | |
578 | - $e->message = '找不到工程师'; | |
579 | - return $this->renderJson($e); | |
580 | - } | |
581 | - | |
582 | - // 已技能认证过的工程师不需要再次阅读 | |
583 | - if (EngineerStatus::STATUS_SKILL_AUTH == $engineerModel->status || !empty($engineerModel->skill_auth_at)) { | |
584 | - $engineerModel->read_jiwork_service_agreement = 1; | |
585 | - $engineerModel->save(); | |
586 | - } | |
587 | - | |
588 | - $e->showAgreement = (0 == $engineerModel->read_jiwork_service_agreement) ? true : false; | |
589 | - return $this->renderJson($e); | |
590 | - } | |
591 | - | |
592 | - /** | |
593 | - * 阅读极办公服务协议 | |
594 | - * @return string | |
595 | - * @throws \yii\base\ErrorException | |
596 | - */ | |
597 | - public function actionReadJiworkServiceAgreement() | |
598 | - { | |
599 | - $e = new stdClass(); | |
600 | - $e->success = false; | |
601 | - $e->message = ''; | |
602 | - $userId = $this->getUserId(); | |
603 | - $engineerModel = EngineerRepository::selectOne($userId); | |
604 | - if(!$engineerModel) { | |
605 | - $e->message = '找不到工程师'; | |
606 | - return $this->renderJson($e); | |
607 | - } | |
608 | - | |
609 | - $engineerModel->read_jiwork_service_agreement = 1; | |
610 | - if ($engineerModel->save()) { | |
611 | - $e->success = true; | |
612 | - } else { | |
613 | - $e->message = '未阅读成功'; | |
614 | - } | |
615 | - | |
616 | - return $this->renderJson($e); | |
617 | - } | |
618 | - | |
619 | - /** | |
620 | - * 通过微信的ServiceId获取图片上传到远程服务器 | |
621 | - * @return string 图片路径 | |
622 | - */ | |
623 | - public function actionUpdateServiceid() | |
624 | - { | |
625 | - $e = new stdClass(); | |
626 | - $e->success = false; | |
627 | - $e->img_path = ""; | |
628 | - $e->msg = '更新头像失败!'; | |
629 | - $result = $this->checkUploadImge(); | |
630 | - if ($result->success == false) { | |
631 | - return $this->renderJson($result); | |
632 | - } | |
633 | - $engineerProfile = $result->engineerProfile; | |
634 | - | |
635 | - $wechat = WxHelper::getWxPHPSDK(); | |
636 | - $user_avatar = $this->request->post('service_id'); | |
637 | - if (!empty($user_avatar)) { | |
638 | - $user_avatar = $this->saveWxImgToRemoveServer($wechat, $user_avatar); | |
639 | - if (empty($user_avatar)) { | |
640 | - $e->success = false; | |
641 | - $e->msg = '图片上传失败'; | |
642 | - return $this->renderJson($e); | |
643 | - } else { | |
644 | - $e->img_path = $user_avatar; | |
645 | - $e->show_img_path = ImageManager::getUrl($user_avatar, ImageManager::$STYLE_180); | |
646 | - // 身份验证 | |
647 | - $verifyResult = self::personVerify($engineerProfile->firstname . $engineerProfile->lastname, $engineerProfile->id_card_no, ImageManager::getUrl($user_avatar)); | |
648 | - $e->msg = isset($verifyResult->msg) ? $verifyResult->msg : ""; | |
649 | - $e->success = false; | |
650 | - // 更新用户更新头像次数 | |
651 | - $engineerProfile->head_photo_upload_times = $engineerProfile->head_photo_upload_times + 1; | |
652 | - if (isset($verifyResult->success) && $verifyResult->success == 101) { | |
653 | - $e->success = true; | |
654 | - // 校验成功更新工程师头像 | |
655 | - $engineerProfile->head_photo = $user_avatar; | |
656 | - // 更新用户更新头像成功次数 | |
657 | - $engineerProfile->head_photo_upload_success_times = $engineerProfile->head_photo_upload_success_times + 1; | |
658 | - if ($engineerProfile->head_photo_upload_success_times >= 2) { | |
659 | - $engineerProfile->head_photo_upload_next_time = strtotime(((int)date("Y", time()) + 1) . "-01-01"); | |
660 | - } | |
661 | - $engineerProfile->head_photo_upload_times = 0; | |
662 | - EngineerHeadphotoUploadLog::createItem(["engineer_id" => $engineerProfile->engineer_id, "head_photo" => $user_avatar, "type" => EngineerHeadphotoUploadLog::TYPE_SUCCESS, "remark" => ""]); | |
663 | - } else { | |
664 | - EngineerHeadphotoUploadLog::createItem(["engineer_id" => $engineerProfile->engineer_id, "head_photo" => $user_avatar, "type" => EngineerHeadphotoUploadLog::TYPE_FAIL, "remark" => $e->msg]); | |
665 | - } | |
666 | - $engineerProfile->save(); | |
667 | - return $this->renderJson($e); | |
668 | - } | |
669 | - } | |
670 | - return $this->renderJson($e); | |
671 | - } | |
672 | - | |
673 | - /** | |
674 | - * 检查工程师是否可以上传图片 | |
675 | - * @return string | |
676 | - */ | |
677 | - public function actionCheckUpload() | |
678 | - { | |
679 | - $result = $this->checkUploadImge(); | |
680 | - return $this->renderJson($result); | |
681 | - } | |
682 | - | |
683 | - /** | |
684 | - * 检查工程师是否可以上传图片 | |
685 | - */ | |
686 | - private function checkUploadImge() | |
687 | - { | |
688 | - $e = new stdClass(); | |
689 | - $e->success = false; | |
690 | - $e->img_path = ""; | |
691 | - $e->confirm = false; | |
692 | - $e->msg = '不能更换头像!'; | |
693 | - $userId = $this->getUserId(); | |
694 | - if (empty($userId)) { | |
695 | - $e->success = false; | |
696 | - $e->msg = '工程师未登录'; | |
697 | - return $e; | |
698 | - } | |
699 | - $engineerProfile = EngineerProfileModel::findOne(["engineer_id" => $userId]); | |
700 | - if (empty($engineerProfile)) { | |
701 | - $e->success = false; | |
702 | - $e->msg = '该工程师不存在'; | |
703 | - return $e; | |
704 | - } | |
705 | - $e->engineerProfile = $engineerProfile; | |
706 | - | |
707 | - if ($engineerProfile->head_photo_upload_times >= 3) { | |
708 | - $e->success = false; | |
709 | - $e->confirm = true; | |
710 | - $e->msg = '每个工程师每次更换头像3次机会已用完,如需更改请联系客服。'; | |
711 | - return $e; | |
712 | - } | |
713 | - | |
714 | - if ($engineerProfile->head_photo_upload_success_times >= 2 && $engineerProfile->head_photo_upload_next_time > 0 && time() < $engineerProfile->head_photo_upload_next_time) { | |
715 | - $e->success = false; | |
716 | - $e->msg = '每年只能更换2次头像,下次更换头像在' . date("Y-m-d H:i:s", $engineerProfile->head_photo_upload_next_time) . "后"; | |
717 | - return $e; | |
718 | - } else if ($engineerProfile->head_photo_upload_success_times >= 2 && $engineerProfile->head_photo_upload_next_time > 0 && time() >= $engineerProfile->head_photo_upload_next_time) { | |
719 | - // 到了下次更新时间后重置次数和时间 | |
720 | - $engineerProfile->head_photo_upload_times = 0; | |
721 | - $engineerProfile->head_photo_upload_success_times = 0; | |
722 | - $engineerProfile->head_photo_upload_next_time = ""; | |
723 | - $engineerProfile->save(); | |
724 | - } | |
725 | - | |
726 | - if ($engineerProfile->head_photo_upload_next_time > 0 && time() < $engineerProfile->head_photo_upload_next_time) { | |
727 | - $e->success = false; | |
728 | - $e->msg = '下次更换头像时间在' . date("Y-m-d H:i:s", $engineerProfile->head_photo_upload_next_time) . "后"; | |
729 | - return $e; | |
730 | - } | |
731 | - $e->success = true; | |
732 | - $e->msg = '可以更换头像!'; | |
733 | - return $e; | |
734 | - } | |
735 | - | |
736 | - /** | |
737 | - * @param $wechat 微信基础类 | |
738 | - * @param string $tr 微信公众号的 media_id | |
739 | - * @return bool|string 返回保存到数据库里面的文件名称是的带URL的,同时会把图片传到阿里云的图片服务器上面 | |
740 | - * $type 这个是类型,根据图片是头像还是身份证来存放,$stat_path 必须根据$type 而改变 | |
741 | - */ | |
742 | - private function saveWxImgToRemoveServer($wechat, $tr = '', $type = 1) | |
743 | - { | |
744 | - if (empty($tr)) { | |
745 | - return false; | |
746 | - } | |
747 | - //$tr='eMybdyIrotir5myoxiM-le-5wcl6z2Sj1zsN2iwuedza6JgcStey8EziRDZxkLUS'; | |
748 | - | |
749 | - $qrcodeArr = $wechat->getMedia($tr, 1); | |
750 | - if (empty($qrcodeArr['body'])) { | |
751 | - return false; | |
752 | - } | |
753 | - //echo $wechat->errCode.' '.$wechat->errMsg; | |
754 | - $filename_root = $_SERVER['DOCUMENT_ROOT']; | |
755 | - //echo $filename_root."\r\n"; | |
756 | - $path = $filename_root . '/tmp'; | |
757 | - | |
758 | - if (!is_dir($path)) { | |
759 | - @mkdir($path, 0777); | |
760 | - } | |
761 | - $fileStr = $tr; | |
762 | - $filename = $path . '/' . time() . '_' . $fileStr . '.jpg'; | |
763 | - $local_file = fopen($filename, 'w'); | |
764 | - if (false !== $local_file) { | |
765 | - if (false !== fwrite($local_file, $qrcodeArr['body'])) { | |
766 | - fclose($local_file); | |
767 | - } | |
768 | - } | |
769 | - $engineer_id = $userId = $this->getUserId(); | |
770 | - $stat_path = ImageManager::getEngineerImgPath($engineer_id, $fileStr); | |
771 | - ImageManager::add($filename, $stat_path); | |
772 | - | |
773 | - return $stat_path; | |
774 | - } | |
775 | - | |
776 | - /** | |
777 | - * 身份验证 | |
778 | - * | |
779 | - * [接口业务能力介绍] | |
780 | - * 1. 质量检测(可选):判断图片中是否包含人脸,以及人脸在姿态、遮挡、模糊、光照等方面是否符合识别条件; | |
781 | - * 2. 活体检测(可选):基于图片中的破绽分析,判断其中的人脸是否为二次翻拍(举例:如用户A用手机拍摄了一张包含人脸的图片一,用户B翻拍了图片一得到了图片二,并用图片二伪造成用户A去进行识别操作,这种情况普遍发生在金融开户、实名认证等环节。); | |
782 | - * 3. 公安验证(必选):基于姓名和身份证号,调取公民身份证小图(源自公安系统),将当前获取的人脸图片,与此证件小图进行对比,得出比对分数,并基于此进行业务判断是否为同一人。由于公安系统小图,具有最权威的身份证明作用,故对用户本人的验证结果可信度也最为合理。 | |
783 | - * | |
784 | - * [业务逻辑] | |
785 | - * 1. 上述三项能力为顺序串行验证,接口默认返回公安身份对比分值,质量检测和活体检测为可选项。如选择了这两项,则验证顺序为人脸质量检测->活体检测->公安身份验证。您也可以根据业务场景,选择这两项中的某一项或都不选择。 | |
786 | - * 2. 如选择了前两个环节,则有任意一个条件不通过,则整个请求流程终止,并返回错误码,描述具体的不符合信息。 | |
787 | - * 3. 基于此顺序串行验证逻辑,可以避免大量不符合条件的请求流转到公安验证,节约您的成本。 | |
788 | - * | |
789 | - * [推荐阈值] | |
790 | - * 1. 此接口使用的对比算法,针对带水纹证件照采用了专项的模型处理,可保证水纹信息的影响降到尽可能低。 | |
791 | - * 2. 如比对成功,最终返回的有效数据为一个对比分值,在0~1之间,您可以设定具体的阈值来判断是否验证通过。 | |
792 | - * 3. 人证相似度的推荐阈值为0.8,对应的误识率为万分之一。 | |
793 | - * @param $e | |
794 | - * @param $engineer | |
795 | - * @param $engineerProfile | |
796 | - * @param $id_card_no | |
797 | - */ | |
798 | - private static function personVerify($engineerName, $id_card_no, $image) | |
799 | - { | |
800 | - $e = new stdClass(); | |
801 | - | |
802 | - $aipFace = new AipFace( Yii::$app->params['BDAIAPPID'], Yii::$app->params['BDAIAPIKEY'], Yii::$app->params['BDAISECRETKEY']); | |
803 | - $options = array(); | |
804 | - $options["quality_control"] = "NORMAL"; | |
805 | - $options["liveness_control"] = "HIGH"; // 较高的活体要求(高攻击拒绝率 低通过率) | |
806 | - $id_card_data = $aipFace->personVerify($image, 'URL', $id_card_no, $engineerName, $options); | |
807 | - if (empty($id_card_data)) { | |
808 | - $e->success = 0; | |
809 | - $e->msg = '头像验证失败, 请联系客服'; | |
810 | - return $e; | |
811 | - } | |
812 | - $errMsg = ""; | |
813 | - AppLog::DEBUG("上传用户头像-百度身份验证结果({$engineerName}-{$id_card_no}):".json_encode($id_card_data)); | |
814 | - if (0 === $id_card_data['error_code']) { | |
815 | - if ($id_card_data["result"]) { | |
816 | - $score = $id_card_data['result']['score']; | |
817 | - $settingScore = SysSettingModel::getRealnameAuthPassScore(); | |
818 | - if ($score >= $settingScore) { | |
819 | - $e->success = 101; | |
820 | - $e->msg = "头像上传成功"; | |
821 | - $e->realname_auth_remark = "自动审核成功(匹配度=" . $score . ")"; | |
822 | - }else { | |
823 | - $e->success = 102; | |
824 | - $e->msg = "匹配度不够,上传失败"; | |
825 | - $e->status = EngineerStatus::STATUS_REALNAME_REVIEW; | |
826 | - $e->realname_auth_remark = "匹配度" . $score . "分,审核失败"; | |
827 | - } | |
828 | - } | |
829 | - } else { // 身份 | |
830 | - if (222202 == $id_card_data['error_code']) { | |
831 | - $errMsg = '头像找不到人脸'; | |
832 | - } elseif (223120 == $id_card_data['error_code']) { | |
833 | - $errMsg = '请上传真人头像'; | |
834 | - } elseif (223114 == $id_card_data['error_code']) { | |
835 | - $errMsg = '头像脸部模糊'; | |
836 | - } elseif (223113 == $id_card_data['error_code']) { | |
837 | - $errMsg = '头像脸部被遮挡'; | |
838 | - } elseif (223115 == $id_card_data['error_code']) { | |
839 | - $errMsg = '头像脸部光照不好'; | |
840 | - } elseif (223116 == $id_card_data['error_code']) { | |
841 | - $errMsg = '头像脸部不完整'; | |
842 | - } elseif ($id_card_data['error_code'] >= 223121 && $id_card_data['error_code'] <= 223127) { // 质量检测未通过 | |
843 | - $errMsg = '头像有遮挡'; | |
844 | - } elseif ($id_card_data['error_code'] >= 222350 && $id_card_data['error_code'] <= 222360) { // 公安验证不通过 | |
845 | - $errMsg = '头像验证失败'; | |
846 | - } else { // 详见错误码: http://ai.baidu.com/docs#/Face-ErrorCode-V3/top 必要情况下提交工单咨询 | |
847 | - $errMsg = "头像验证失败, 请稍后再试"; | |
848 | - } | |
849 | - $e->success = $id_card_data['error_code']; | |
850 | - $e->msg = $errMsg; | |
851 | - $e->realname_auth_remark = $errMsg . '(' . $id_card_data['error_code'] . ': ' . $id_card_data['error_msg'] . ')'; | |
852 | - } | |
853 | - | |
854 | - return $e; | |
855 | - } | |
856 | - | |
857 | - /** | |
858 | - * 获取工程师验证码 | |
859 | - */ | |
860 | - public function actionGetPhoneCode() | |
861 | - { | |
862 | - $e = new stdClass(); | |
863 | - $e->success = false; | |
864 | - $e->msg = ""; | |
865 | - $e->limitTime = 0; | |
866 | - | |
867 | - if (false == $this->request->isPost) { | |
868 | - $e->success = false; | |
869 | - $e->msg = "请求方式不正确"; | |
870 | - return $this->renderJson($e); | |
871 | - } | |
872 | - | |
873 | - $phone = $this->request->post("phone"); | |
874 | - if (empty($phone)) { | |
875 | - $e->success = false; | |
876 | - $e->msg = "手机号码不能为空"; | |
877 | - return $this->renderJson($e); | |
878 | - } | |
879 | - $isBlock = UserModel::findOne(['phone' => $phone, "status" => [UserModel::STATUS_DISABLE, UserModel::STATUS_BLOCK]]); | |
880 | - if ($isBlock) { | |
881 | - $e->success = false; | |
882 | - $e->msg = "手机号码异常"; | |
883 | - return $this->renderJson($e); | |
884 | - } | |
885 | - // 获取手机验证码 | |
886 | - $cTime = EngineerPhoneCodeRepository::getEngineerPhoneCodeCreatedTime($phone); | |
887 | - if ($cTime && (time() - $cTime) <= 120) { | |
888 | - $e->limitTime = 120 - (time() - $cTime); | |
889 | - $e->success = false; | |
890 | - $e->msg = ""; | |
891 | - return $this->renderJson($e); | |
892 | - } | |
893 | - $isNew = $this->request->post("is_new"); | |
894 | - $userId = $this->getUserId(); | |
895 | - if (empty($isNew)) { | |
896 | - if (empty($userId)) { | |
897 | - $e->success = false; | |
898 | - $e->msg = '工程师未登录'; | |
899 | - return $this->renderJson($e); | |
900 | - } | |
901 | - $engineer = EngineerModel::findOne($userId); | |
902 | - if (empty($engineer)) { | |
903 | - $e->success = false; | |
904 | - $e->msg = '工程师不存在'; | |
905 | - return $this->renderJson($e); | |
906 | - } | |
907 | - if ( $engineer->change_phone_times >= self::CHANGE_PHONE_TIMES) { | |
908 | - $e->success = false; | |
909 | - $e->msg = self::CHANGE_PHONE_TIMES . "次修改手机号码的机会已经用完"; | |
910 | - return $this->renderJson($e); | |
911 | - } | |
912 | - if ($phone != $engineer->phone) { | |
913 | - $e->success = false; | |
914 | - $e->msg = "手机号码有误"; | |
915 | - return $this->renderJson($e); | |
916 | - } | |
917 | - } else { | |
918 | - $engineerFind = EngineerModel::findOne(["phone" => $phone]); | |
919 | - if (!empty($engineerFind)) { | |
920 | - $e->success = false; | |
921 | - $e->msg = "该手机号码已经被注册了"; | |
922 | - return $this->renderJson($e); | |
923 | - } | |
924 | - } | |
925 | - // 获取随机的4位验证码 | |
926 | - $numberFour = Utils::rand(4,true); | |
927 | - $tran = Yii::$app->getDb()->beginTransaction(); | |
928 | - try { | |
929 | - // 1 逻辑删除该手机号码其他的未过期的验证码 | |
930 | - EngineerPhoneCodeModel::updateAll(['is_enable' => EngineerPhoneCode::TYPE_DISABLE], ["phone" => $phone, 'is_enable' => EngineerPhoneCode::TYPE_ENABLE]); | |
931 | - | |
932 | - // 2 新增验证码和验证码过期时间到数据库 | |
933 | - $result = EngineerPhoneCode::createItem(["engineer_id" => $userId, "phone" => $phone, "code" => $numberFour]); | |
934 | - if (!$result) { | |
935 | - $tran->rollBack(); | |
936 | - $e->success = false; | |
937 | - $e->msg = "发送验证码失败"; | |
938 | - return $this->renderJson($e); | |
939 | - } | |
940 | - | |
941 | - //3 发送验证码到用户手机 | |
942 | - SmsMessage::sendEngineerPhoneCode($phone, $numberFour); | |
943 | - | |
944 | - //4 返回发送成功信息 | |
945 | - $e->success = true; | |
946 | - $e->msg = "发送成功"; | |
947 | - return $this->renderJson($e); | |
948 | - } catch (Exception $e) { | |
949 | - $tran->rollBack(); | |
950 | - $e->success = false; | |
951 | - $e->msg = "发送验证码异常".$e->getMessage(); | |
952 | - return $this->renderJson($e); | |
953 | - } | |
954 | - } | |
955 | - | |
956 | - // 验证手机验证码 | |
957 | - public function actionVerifyCode() | |
958 | - { | |
959 | - $e = new stdClass(); | |
960 | - $e->success = false; | |
961 | - $e->msg = ""; | |
962 | - | |
963 | - if (false == $this->request->isPost) { | |
964 | - $e->success = false; | |
965 | - $e->msg = "请求方式不正确"; | |
966 | - return $this->renderJson($e); | |
967 | - } | |
968 | - | |
969 | - $phone = $this->request->post("phone"); | |
970 | - if (empty($phone)) { | |
971 | - $e->success = false; | |
972 | - $e->msg = "手机号码不能为空"; | |
973 | - return $this->renderJson($e); | |
974 | - } | |
975 | - | |
976 | - $code = $this->request->post("code"); | |
977 | - if (empty($code)) { | |
978 | - $e->success = false; | |
979 | - $e->msg = "手机验证码不能为空"; | |
980 | - return $this->renderJson($e); | |
981 | - } | |
982 | - $userId = $this->getUserId(); | |
983 | - if (empty($userId)) { | |
984 | - $e->success = false; | |
985 | - $e->msg = '工程师未登录'; | |
986 | - return $this->renderJson($e); | |
987 | - } | |
988 | - $engineer = EngineerModel::findOne($userId); | |
989 | - if (empty($engineer)) { | |
990 | - $e->success = false; | |
991 | - $e->msg = '工程师不存在'; | |
992 | - return $this->renderJson($e); | |
993 | - } | |
994 | - if ($phone != $engineer->phone) { | |
995 | - $e->success = false; | |
996 | - $e->msg = "手机号码有误"; | |
997 | - return $this->renderJson($e); | |
998 | - } | |
999 | - | |
1000 | - // 获取手机验证码 | |
1001 | - $verifyCode = EngineerPhoneCodeRepository::getEngineerPhoneCode($phone); | |
1002 | - if (empty($code)) { | |
1003 | - $e->success = false; | |
1004 | - $e->msg = "该验证码无效,请填写正确的验证码校验"; | |
1005 | - return $this->renderJson($e); | |
1006 | - } | |
1007 | - if ($verifyCode != $code) { | |
1008 | - $e->success = false; | |
1009 | - $e->msg = "请输入正确的手机验证码"; | |
1010 | - return $this->renderJson($e); | |
1011 | - } | |
1012 | - Yii::$app->session['VerifyCodeOK'] = true; | |
1013 | - $e->success = true; | |
1014 | - $e->msg = "验证通过"; | |
1015 | - return $this->renderJson($e); | |
1016 | - } | |
1017 | - | |
1018 | - /** | |
1019 | - * 校验是否通过了验证码验证 | |
1020 | - * @return string | |
1021 | - */ | |
1022 | - public function actionLoadPhoneChage() | |
1023 | - { | |
1024 | - $e = new stdClass(); | |
1025 | - $e->success = false; | |
1026 | - $e->msg = ""; | |
1027 | - $flagVerify = Yii::$app->session['VerifyCodeOK']; | |
1028 | - if ($flagVerify == true) { | |
1029 | - $e->success = true; | |
1030 | - $e->msg = "验证通过"; | |
1031 | - unset(Yii::$app->session['VerifyCodeOK']); | |
1032 | - return $this->renderJson($e); | |
1033 | - } else { | |
1034 | - $e->success = false; | |
1035 | - $e->msg = "验证失败"; | |
1036 | - return $this->renderJson($e); | |
1037 | - } | |
1038 | - } | |
1039 | - | |
1040 | - /** | |
1041 | - * 改变工程师手机号码 | |
1042 | - */ | |
1043 | - public function actionChangeEngineerPhone() | |
1044 | - { | |
1045 | - $e = new stdClass(); | |
1046 | - $e->success = false; | |
1047 | - $e->msg = ""; | |
1048 | - | |
1049 | - if (false == $this->request->isPost) { | |
1050 | - $e->success = false; | |
1051 | - $e->msg = "请求方式不正确"; | |
1052 | - return $this->renderJson($e); | |
1053 | - } | |
1054 | - | |
1055 | - $userId = $this->getUserId(); | |
1056 | - if (empty($userId)) { | |
1057 | - $e->success = false; | |
1058 | - $e->msg = '工程师未登录'; | |
1059 | - return $this->renderJson($e); | |
1060 | - } | |
1061 | - $engineer = EngineerModel::findOne($userId); | |
1062 | - if (empty($engineer)) { | |
1063 | - $e->success = false; | |
1064 | - $e->msg = '工程师不存在'; | |
1065 | - return $this->renderJson($e); | |
1066 | - } | |
1067 | - if ( $engineer->change_phone_times >= self::CHANGE_PHONE_TIMES) { | |
1068 | - $e->success = false; | |
1069 | - $e->msg = self::CHANGE_PHONE_TIMES . "次修改手机号码的机会已经用完"; | |
1070 | - return $this->renderJson($e); | |
1071 | - } | |
1072 | - $engineerProfile = EngineerProfileModel::findOne(["engineer_id" => $userId]); | |
1073 | - if (empty($engineerProfile)) { | |
1074 | - $e->success = false; | |
1075 | - $e->msg = '该工程师不存在'; | |
1076 | - return $e; | |
1077 | - } | |
1078 | - | |
1079 | - $phone = $this->request->post("phone"); | |
1080 | - if (empty($phone)) { | |
1081 | - $e->success = false; | |
1082 | - $e->msg = "手机号码不能为空"; | |
1083 | - return $this->renderJson($e); | |
1084 | - } | |
1085 | - | |
1086 | - if (!Utils::isPhone($phone)) { | |
1087 | - $e->success = false; | |
1088 | - $e->msg = "手机号码不正确"; | |
1089 | - return $this->renderJson($e); | |
1090 | - } | |
1091 | - | |
1092 | - $code = $this->request->post("code"); | |
1093 | - if (empty($code)) { | |
1094 | - $e->success = false; | |
1095 | - $e->msg = "手机验证码不能为空"; | |
1096 | - return $this->renderJson($e); | |
1097 | - } | |
1098 | - $inputCardNo = $this->request->post("inputCardNo"); | |
1099 | - if (empty($code)) { | |
1100 | - $e->success = false; | |
1101 | - $e->msg = "身份证后6位不能为空"; | |
1102 | - return $this->renderJson($e); | |
1103 | - } | |
1104 | - // 获取手机验证码 | |
1105 | - $verifyCode = EngineerPhoneCodeRepository::getEngineerPhoneCode($phone); | |
1106 | - if (empty($code)) { | |
1107 | - $e->success = false; | |
1108 | - $e->msg = "该验证码无效,请填写正确的验证码校验"; | |
1109 | - return $this->renderJson($e); | |
1110 | - } | |
1111 | - if ($verifyCode != $code) { | |
1112 | - $e->success = false; | |
1113 | - $e->msg = "请输入正确的手机验证码"; | |
1114 | - return $this->renderJson($e); | |
1115 | - } | |
1116 | - $verifyCardNo = $engineerProfile->id_card_no; | |
1117 | - AppLog::DEBUG("更换手机号:工程师编号{$userId}, 身份证号码{$verifyCardNo}(输入的身份证后六位:{$inputCardNo})!截取后的身份证后六位:" . substr($verifyCardNo,-6)); | |
1118 | - if (empty($verifyCardNo) || substr($verifyCardNo,-6) != $inputCardNo) { | |
1119 | - $e->success = false; | |
1120 | - $e->msg = "身份证后六位验证失败"; | |
1121 | - return $this->renderJson($e); | |
1122 | - } | |
1123 | - $engineerFind = EngineerModel::findOne(["phone" => $phone]); | |
1124 | - if (!empty($engineerFind)) { | |
1125 | - $e->success = false; | |
1126 | - $e->msg = "该手机号码已经被注册了"; | |
1127 | - return $this->renderJson($e); | |
1128 | - } | |
1129 | - $engineer->phone = $phone; | |
1130 | - $engineer->change_phone_times = $engineer->change_phone_times + 1; | |
1131 | - $engineer->stop_phone_canchange_epired_at = ""; | |
1132 | - $result = $engineer->save(); | |
1133 | - if ($result) { | |
1134 | - /** | |
1135 | - * 发送微信通知 | |
1136 | - */ | |
1137 | - CustomMessage::sendTextMessage(WxHelper::getWxPHPSDK(), $engineer->openid, "您绑定的手机号已经成功修改为[{$phone}]^_^"); | |
1138 | - | |
1139 | - $e->success = true; | |
1140 | - $e->msg = "更换手机号码成功"; | |
1141 | - return $this->renderJson($e); | |
1142 | - } else { | |
1143 | - $e->success = false; | |
1144 | - $e->msg = "更换手机号码失败"; | |
1145 | - return $this->renderJson($e); | |
1146 | - } | |
1147 | - } | |
1148 | - | |
1149 | - /** | |
1150 | - * 检查工程师是否还有更改手机号码的机会 | |
1151 | - */ | |
1152 | - public function actionCheckEngineerChangeTimes() | |
1153 | - { | |
1154 | - | |
1155 | - $e = new stdClass(); | |
1156 | - $e->success = false; | |
1157 | - $e->code = 0; | |
1158 | - $e->msg = ""; | |
1159 | - | |
1160 | - if (false == $this->request->isPost) { | |
1161 | - $e->success = false; | |
1162 | - $e->msg = "请求方式不正确"; | |
1163 | - return $this->renderJson($e); | |
1164 | - } | |
1165 | - | |
1166 | - $userId = $this->getUserId(); | |
1167 | - if (empty($userId)) { | |
1168 | - $e->success = false; | |
1169 | - $e->msg = '工程师未登录'; | |
1170 | - return $this->renderJson($e); | |
1171 | - } | |
1172 | - $engineer = EngineerModel::findOne($userId); | |
1173 | - if (empty($engineer)) { | |
1174 | - $e->success = false; | |
1175 | - $e->msg = '工程师不存在'; | |
1176 | - return $this->renderJson($e); | |
1177 | - } | |
1178 | - if ( $engineer->change_phone_times >= self::CHANGE_PHONE_TIMES) { | |
1179 | - $e->success = false; | |
1180 | - $e->msg = self::CHANGE_PHONE_TIMES . "次修改手机号码的机会已经用完"; | |
1181 | - return $this->renderJson($e); | |
1182 | - } | |
1183 | - if (isset($engineer->stop_phone_canchange_epired_at) && !empty($engineer->stop_phone_canchange_epired_at) && $engineer->stop_phone_canchange_epired_at >= time()) { | |
1184 | - $e->code = 2; | |
1185 | - Yii::$app->session['VerifyCodeOK'] = true; | |
1186 | - } else { | |
1187 | - $e->code = 1; | |
1188 | - } | |
1189 | - $e->success = true; | |
1190 | - $e->msg = "验证通过"; | |
1191 | - return $this->renderJson($e); | |
1192 | - } | |
1193 | - | |
1194 | - /** | |
1195 | - * @return string | |
1196 | - */ | |
1197 | - public function actionGetSkillTags() | |
1198 | - { | |
1199 | - $e = new stdClass(); | |
1200 | - $e->success = false; | |
1201 | - $skillModel = SkillTagRepositoryModel::getSkillTag(); | |
1202 | - $userId = $this->getUserId(); | |
1203 | - | |
1204 | - if (empty($userId)) { | |
1205 | - $e->success = false; | |
1206 | - $e->msg = '工程师未登录'; | |
1207 | - return $this->renderJson($e); | |
1208 | - } | |
1209 | - | |
1210 | - if ($skillModel == '') { | |
1211 | - return $this->renderJson($e); | |
1212 | - } | |
1213 | - | |
1214 | - // 工程师已选技能标签 | |
1215 | - $engineerSkills = EngineerSkillTagsRepository::findAll(['engineer_id' => $userId]); | |
1216 | - $selectSkills = []; | |
1217 | - foreach ($engineerSkills as $k => $v) { | |
1218 | - $selectSkills[] = $v['skill_tag_id']; | |
1219 | - } | |
1220 | - | |
1221 | - // 工程师认证技能 2 网络布线 4 电脑维修(3 电脑网络维修) 5 打印机维修(1 打印机维修) 6 复印机维修(2 复印机维修) | |
1222 | - $enginerAuthSkills = EngineerSkillsModel::findAll(["engineer_id" => $userId]); | |
1223 | - $selectAuthSkillsIds = []; | |
1224 | - foreach ($enginerAuthSkills as $k => $v) { | |
1225 | - if ($v['skill_id'] == 1) { | |
1226 | - $v['skill_id'] = 5; | |
1227 | - } elseif ($v['skill_id'] == 2) { | |
1228 | - $v['skill_id'] = 6; | |
1229 | - } elseif ($v['skill_id'] == 3) { | |
1230 | - $v['skill_id'] = 4; | |
1231 | - } | |
1232 | - $selectAuthSkillsIds[] = $v['skill_id']; | |
1233 | - if ($v['skill_id'] == 4 ) { | |
1234 | - $selectAuthSkillsIds[] = 2; | |
1235 | - } | |
1236 | - } | |
1237 | - | |
1238 | - $img = [ | |
1239 | - ['/i/order/v2_save.png', '/i/order/v2_save_pre.png'], | |
1240 | - ['/i/order/v2_line.png', '/i/order/v2_line_pre.png'], | |
1241 | - ['/i/order/v2_device.png', '/i/order/v2_device_pre.png'], | |
1242 | - ['/i/order/v2_computer.png', '/i/order/v2_computer_pre.png'], | |
1243 | - ['/i/order/v2_printing.png', '/i/order/v2_printing_pre.png'], | |
1244 | - ['/i/order/v2_copier.png', '/i/order/v2_copier_pre.png'], | |
1245 | - ]; | |
1246 | - | |
1247 | - foreach ($skillModel as $kk => $vv) { | |
1248 | - if (in_array($vv['id'], $selectSkills)) { | |
1249 | - $vv['checked'] = true; | |
1250 | - } else { | |
1251 | - $vv['checked'] = false; | |
1252 | - } | |
1253 | - $vv['ic_pic'] = $img[$kk][0]; | |
1254 | - $vv['ic_pic_pre'] = $img[$kk][1]; | |
1255 | - $skillModel[$kk] = $vv; | |
1256 | - } | |
1257 | - | |
1258 | - // 如果工程师未选择技能标签 | |
1259 | - if (empty($engineerSkills)) { | |
1260 | - // 如果工程师未选择技能标签的时候默认保存转换后的技能标签保存到数据库 | |
1261 | - if ($selectAuthSkillsIds) { | |
1262 | - EngineerSkillTags::setEngineerSkillTags($userId, $selectAuthSkillsIds); | |
1263 | - } | |
1264 | - foreach ($skillModel as $kk => $vv) { | |
1265 | - if (in_array($vv['id'], $selectAuthSkillsIds)) { | |
1266 | - $vv['checked'] = true; | |
1267 | - } else { | |
1268 | - $vv['checked'] = false; | |
1269 | - } | |
1270 | - $skillModel[$kk] = $vv; | |
1271 | - } | |
1272 | - } | |
1273 | - | |
1274 | - $e->skill = $skillModel; | |
1275 | - $e->success = true; | |
1276 | - | |
1277 | - return $this->renderJson($e); | |
1278 | - } | |
1279 | - | |
1280 | - /** | |
1281 | - * 保存标签 | |
1282 | - * @return string | |
1283 | - */ | |
1284 | - public function actionSaveSkillTag() | |
1285 | - { | |
1286 | - $e = new stdClass(); | |
1287 | - $e->success = false; | |
1288 | - $e->error = ''; | |
1289 | - $req = Yii::$app->request; | |
1290 | - $userId = $this->getUserId(); | |
1291 | - $skills = $req->post('skills'); | |
1292 | - if (empty($userId)) { | |
1293 | - $e->success = false; | |
1294 | - $e->error = '工程师未登录'; | |
1295 | - return $this->renderJson($e); | |
1296 | - } | |
1297 | - if (empty($skills)) { | |
1298 | - $e->success = false; | |
1299 | - $e->error = '未选择订单类型'; | |
1300 | - return $this->renderJson($e); | |
1301 | - } | |
1302 | - $result = EngineerSkillTags::setEngineerSkillTags($userId, $skills); | |
1303 | - if (!$result) { | |
1304 | - $e->error = '提交失败'; | |
1305 | - return $this->renderJson($e); | |
1306 | - } | |
1307 | - $e->success = true; | |
1308 | - | |
1309 | - return $this->renderJson($e); | |
1310 | - } | |
1311 | - | |
1312 | - | |
1313 | - | |
1314 | - /** | |
1315 | - * 获取订单数据统计 | |
1316 | - */ | |
1317 | - public function actionOrderStatistic() | |
1318 | - { | |
1319 | - $e = new stdClass(); | |
1320 | - $e->success = true; | |
1321 | - $dateTime = date("Y年m月", time()); | |
1322 | - $userId = $this->getUserId(); | |
1323 | - $orderData = []; | |
1324 | - $moneyData = []; | |
1325 | - $customer = []; | |
1326 | - | |
1327 | - // 完成订单统计 | |
1328 | - $orderArr = RepairOrderRepository::getOrderCountByType($userId); | |
1329 | - $orderData["finish_order_count"] = (int) $orderArr['finish_order_count']; | |
1330 | - $orderData["forward_order_count"] = (int) $orderArr['forward_order_count']; | |
1331 | - | |
1332 | - // 财务统计 | |
1333 | - $engineerOrderIncome = EngineerOrderIncomeRepository::getEngineerOrderIncome($userId); | |
1334 | - $platform_order_income = $engineerOrderIncome->platform_order_income; | |
1335 | - $owner_order_income = $engineerOrderIncome->owner_order_income; | |
1336 | - $forward_order_income = $engineerOrderIncome->forward_order_income; | |
1337 | - $moneyData["finish_income"] = sprintf("%.2f", $platform_order_income);; | |
1338 | - $moneyData["private_income"] = sprintf("%.2f", $owner_order_income); | |
1339 | - $moneyData["forward_income"] = sprintf("%.2f", $forward_order_income); | |
1340 | - $moneyData["repair_order_total_income"] = sprintf("%.2f", ($platform_order_income +$forward_order_income + $owner_order_income)); | |
1341 | - | |
1342 | - if (YII_ENV_PROD) { | |
1343 | - $clientId = ClientModel::CLENT_ID_MINA_DDB; | |
1344 | - } else { | |
1345 | - $clientId = ClientModel::CLENT_ID_MINA_DDB_TEST; | |
1346 | - } | |
1347 | - | |
1348 | - // 客户统计 | |
1349 | - $newUsersCount = UserEngineerFavModel::find() | |
1350 | - ->where(["engineer_id" => $userId]) | |
1351 | - ->andWhere(["client_id" => $clientId]) | |
1352 | - ->andFilterWhere(["between", "created_at", strtotime(date('Y-m-01 00:00:00', time())), strtotime(date('Y-m-d 23:59:59', strtotime(date('Y-m-01', time()) . " +1 month -1 day")))]) | |
1353 | - ->count(); | |
1354 | - | |
1355 | - $allUsersCount = UserEngineerFavModel::find() | |
1356 | - ->where(["engineer_id" => $userId]) | |
1357 | - ->andWhere(["client_id" => $clientId]) | |
1358 | - ->count(); | |
1359 | - | |
1360 | - // 下单客户 | |
1361 | - $orderNewUsersCount = RepairOrderModel::find() | |
1362 | - ->where(["engineer_id" => $userId]) | |
1363 | - ->andWhere(["client_id" => $clientId]) | |
1364 | - ->andWhere(["owner_engineer_id" => $userId]) | |
1365 | - ->andWhere(["type" => [RepairOrderType::TYPE_PRIVATE, RepairOrderType::TYPE_FORWARD_TO_FRIEND, RepairOrderType::TYPE_FORWARD_TO_PLATFORM]]) | |
1366 | - ->andFilterWhere(["between", "created_at", strtotime(date('Y-m-01 00:00:00', time())), strtotime(date('Y-m-d 23:59:59', strtotime(date('Y-m-01', time()) . " +1 month -1 day")))]) | |
1367 | - ->groupBy("user_id") | |
1368 | - ->count(); | |
1369 | - | |
1370 | - $orderAllUsersCount = RepairOrderModel::find() | |
1371 | - ->where(["engineer_id" => $userId]) | |
1372 | - ->andWhere(["client_id" => $clientId]) | |
1373 | - ->andWhere(["owner_engineer_id" => $userId]) | |
1374 | - ->andWhere(["type" => [RepairOrderType::TYPE_PRIVATE, RepairOrderType::TYPE_FORWARD_TO_FRIEND, RepairOrderType::TYPE_FORWARD_TO_PLATFORM]]) | |
1375 | - ->groupBy("user_id") | |
1376 | - ->count(); | |
1377 | - | |
1378 | - $customer["new"] = $newUsersCount; | |
1379 | - $customer["all"] = $allUsersCount; | |
1380 | - $customer["order_new"] = $orderNewUsersCount; | |
1381 | - $customer["order_all"] = $orderAllUsersCount; | |
1382 | - $buildData = [ | |
1383 | - 'time' => $dateTime, | |
1384 | - 'order_data' => $orderData, | |
1385 | - 'money_data' => $moneyData, | |
1386 | - 'customer' => $customer | |
1387 | - ]; | |
1388 | - $e->data = $buildData; | |
1389 | - return $this->renderJson($e); | |
1390 | - } | |
1391 | - | |
1392 | - /** | |
1393 | - * 获取收藏工程师的用户 | |
1394 | - */ | |
1395 | - public function actionGetFavuser() | |
1396 | - { | |
1397 | - $e = new stdClass(); | |
1398 | - $e->success = false; | |
1399 | - $e->favlist = []; | |
1400 | - | |
1401 | - $page = empty($this->request->get('page')) ? 1 : $this->request->get('page'); | |
1402 | - $pageSize = empty($this->request->get('pageSize')) ? 8: $this->request->get('pageSize'); | |
1403 | - $getMonth = empty($this->request->get('getMonth')) ? 2 : $this->request->get('getMonth'); | |
1404 | - $pager_offset = ($page - 1) * $pageSize; | |
1405 | - if (false == $this->request->isGet) { | |
1406 | - $e->error = '请求方式错误'; | |
1407 | - return $this->renderJson($e); | |
1408 | - } | |
1409 | - | |
1410 | - $userId = $this->getUserId(); | |
1411 | - if (false == EngineerModel::findOne($userId)){ | |
1412 | - $e->error = '工程师不存在'; | |
1413 | - return $this->renderJson($e); | |
1414 | - } | |
1415 | - if (YII_ENV_PROD) { | |
1416 | - $clientId = ClientModel::CLENT_ID_MINA_DDB; | |
1417 | - } else { | |
1418 | - $clientId = ClientModel::CLENT_ID_MINA_DDB_TEST; | |
1419 | - } | |
1420 | - $favlist = []; | |
1421 | - $query = new Query(); | |
1422 | - $query->select([ | |
1423 | - 'user_engineer_fav.id AS id', | |
1424 | - "cum.nickname as nickname", | |
1425 | - 'cum.headimgurl', | |
1426 | - "from_unixtime(user_engineer_fav.created_at, '%Y-%m-%d') as created_time", | |
1427 | - ]); | |
1428 | - $query->from('user_engineer_fav'); | |
1429 | - $query->leftJoin('client_user cu', "cu.user_id = user_engineer_fav.user_id and cu.client_id = " . $clientId); | |
1430 | - $query->leftJoin('client_user_mina cum', "cu.id = cum.client_user_id"); | |
1431 | - $query->where([ | |
1432 | - 'user_engineer_fav.engineer_id' => $userId, | |
1433 | - 'user_engineer_fav.client_id' => $clientId | |
1434 | - ]); | |
1435 | - if ($getMonth == 1) { | |
1436 | - $query->andFilterWhere(["between", "user_engineer_fav.created_at", strtotime(date('Y-m-01 00:00:00', time())), strtotime(date('Y-m-d 23:59:59', strtotime(date('Y-m-01', time()) . " +1 month -1 day")))]); | |
1437 | - } | |
1438 | - //增加分页 | |
1439 | - $pager = new Pagination(['totalCount' => $query->count(), 'pageSize' => $pageSize]); | |
1440 | - /** | |
1441 | - * 获取总分页数据 | |
1442 | - */ | |
1443 | - $e->page_count = $pager->pageCount; | |
1444 | - $e->page = $page; | |
1445 | - $query->orderBy('user_engineer_fav.created_at DESC'); | |
1446 | - $query->offset($pager_offset)->limit($pageSize); | |
1447 | - $favArray = $query->all(); | |
1448 | - foreach ($favArray as $item) { | |
1449 | - $favItem = new stdClass(); | |
1450 | - $favItem->id = $item['id']; | |
1451 | - $favItem->headimgurl = $item['headimgurl']; | |
1452 | - $favItem->nickname = $item['nickname']; | |
1453 | - $favItem->created_time = $item['created_time']; | |
1454 | - $favlist[] = $favItem; | |
1455 | - } | |
1456 | - | |
1457 | - $e->favlist = $favlist; | |
1458 | - $e->success = true; | |
1459 | - return $this->renderJson($e); | |
1460 | - } | |
1461 | 21 | } |
1462 | 22 | \ No newline at end of file | ... | ... |
app-wx/modules/smart/views/default/index.php
... | ... | @@ -13,6 +13,7 @@ function img($file, $path = '/i/user/') |
13 | 13 | return $baseUrl . $path. $file; |
14 | 14 | } |
15 | 15 | $order_polling_interval = SysSetting::getOrderPollingInterval(); |
16 | +$redirectInfo=$this->context->checkUserLevel('', true, "none"); | |
16 | 17 | ?> |
17 | 18 | <div class="views"> |
18 | 19 | <div class="view view-main"> |
... | ... | @@ -23,12 +24,14 @@ $order_polling_interval = SysSetting::getOrderPollingInterval(); |
23 | 24 | <?=$this->render('pages/index-template', ['asset' => $asset])?> |
24 | 25 | |
25 | 26 | <script> |
27 | + var redirect="<?=$redirectInfo['redirect_url']?>"; | |
28 | + var redirectStatus="<?=$redirectInfo['success']?>"; | |
26 | 29 | window.pollingTimer=null; |
27 | 30 | </script> |
28 | 31 | <script> |
29 | 32 | require.config({baseUrl: $site.assets_url + '/js/',urlArgs : "v=" + require.version}); |
30 | 33 | require([ |
31 | - 'user-app' | |
34 | + 'smart-app' | |
32 | 35 | ], |
33 | 36 | function(app){ |
34 | 37 | app.bootstrap({ | ... | ... |
app-wx/web/dist/js/smart-app.js
1 | -define("smart-app",["mk7/app"],function(n){var e=Dom7,i=function(){var n=e(".ui-loading-block");0==n.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var n=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",n&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',n.appendChild(e))},window.waitingTime))},o=!0;return n.name="smart",n.routes={index:function(){return o=!1,i(),n.runController("index")},"*":function(){return o=!1,i(),n.runController("index")}},n}),define("smart/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin","mk7/agreement-checker"],function(n,e,i,o,r,a){var n=new n,t=Dom7;Template7;return n.run=function(){var n=this;n.onScan()},n.bindEvents=function(){},n.onScan=function(){o.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(n){var e=n.resultStr,o=t.parseUrlQuery(e);null!=o&&void 0!==o&&null!=o.number&&void 0!==o.number||i.toast({content:"请扫描智能防伪二维码"})}})},n}); | |
2 | 1 | \ No newline at end of file |
2 | +define("smart-app",["mk7/app"],function(n){var e=Dom7,i=function(){var n=e(".ui-loading-block");0==n.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var n=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",n&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',n.appendChild(e))},window.waitingTime))},t=!0;return n.name="smart",n.routes={index:function(){return t=!1,i(),n.runController("index")},"*":function(){return t=!1,i(),n.runController("index")}},n}),define("smart/index-controller",["mk7/controller","mk7/url","mk7/utils","mk7/modals","mk7/jweixin"],function(n,e,i,t,o){var n=new n,d=Dom7;Template7;return n.run=function(){var n=this;n.setPageTitle("智能防伪扫码"),n.render(),o.config({debug:!1,appId:window.$site.appid,timestamp:window.$site.timestamp,nonceStr:window.$site.noncestr,signature:window.$site.signature,jsApiList:["openLocation","getLocation","scanQRCode"]}),o.ready(function(){o.scanQRCode({needResult:1,desc:"scanQRCode desc",success:function(n){var e=n.resultStr,t=d.parseUrlQuery(e);if(alert(e),null!=t&&void 0!==t&&null!=t.uuid&&void 0!==t.uuid){var t=t.uuid.split("@");alert(t[0])}else i.toast({content:"请扫描智能防伪二维码"})}})})},n.bindEvents=function(){},n}); | |
3 | 3 | \ No newline at end of file | ... | ... |
app-wx/web/src/course/after-service/index.html
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | }; |
35 | 35 | </script> |
36 | 36 | |
37 | -<script defer src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> | |
37 | +<script defer src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> | |
38 | 38 | |
39 | 39 | <script id="Mugeda_5cdd2adc9bbd0f37f45313f1"> |
40 | 40 | (function () { | ... | ... |
app-wx/web/src/js/smart/index-controller.js
... | ... | @@ -8,71 +8,79 @@ define( |
8 | 8 | 'mk7/url', |
9 | 9 | 'mk7/utils', |
10 | 10 | 'mk7/modals', |
11 | - 'mk7/jweixin', | |
12 | - 'mk7/agreement-checker' | |
11 | + 'mk7/jweixin' | |
13 | 12 | ], |
14 | - function (ctrl, url, utils, jweixin, modals, agreementChecker) { | |
13 | + function (ctrl, url, utils, modals, jweixin) { | |
15 | 14 | var ctrl = new ctrl(); |
16 | 15 | var $$ = Dom7; |
17 | 16 | var t7 = Template7; |
18 | 17 | |
19 | 18 | ctrl.run = function () { |
20 | 19 | var me = this; |
21 | - me.onScan(); | |
22 | - }; | |
23 | - | |
24 | - ctrl.bindEvents = function () { | |
25 | - var me = this; | |
26 | - }; | |
27 | - | |
28 | - ctrl.onScan = function () { | |
29 | - var me = this; | |
30 | - jweixin.scanQRCode({ | |
31 | - needResult: 1, | |
32 | - desc: 'scanQRCode desc', | |
33 | - success: function (res) { | |
34 | - var result = res.resultStr; | |
35 | - var resultArr = $$.parseUrlQuery(result); | |
36 | - //这个二维码必须传到后台去做验证才对, | |
37 | - | |
38 | - if(resultArr != null && resultArr!==undefined && resultArr['number']!=null && resultArr['number']!==undefined) { | |
39 | - /* $$.ajax({ | |
40 | - method : "POST", | |
41 | - url: url.to('smart/default/check-uuid'), | |
42 | - data : {qrcode:resultArr['number']}, | |
43 | - dataType : "json", | |
44 | - beforeSend : function(){ | |
45 | - me.showIndicator(); | |
46 | - }, | |
47 | - success : function(res){ | |
20 | + me.setPageTitle("智能防伪扫码"); | |
21 | + me.render(); | |
22 | + jweixin.config({ | |
23 | + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | |
24 | + appId: window.$site.appid, // 必填,公众号的唯一标识 | |
25 | + timestamp: window.$site.timestamp, // 必填,生成签名的时间戳 | |
26 | + nonceStr: window.$site.noncestr, // 必填,生成签名的随机串 | |
27 | + signature: window.$site.signature,// 必填,签名,见附录1 | |
28 | + jsApiList: ['openLocation','getLocation','scanQRCode'] | |
29 | + }); | |
30 | + jweixin.ready(function(){ | |
31 | + jweixin.scanQRCode({ | |
32 | + needResult: 1, | |
33 | + desc: 'scanQRCode desc', | |
34 | + success: function (res) { | |
35 | + var result = res.resultStr; | |
36 | + var resultArr = $$.parseUrlQuery(result); | |
37 | + //这个二维码必须传到后台去做验证才对, | |
38 | + alert(result); | |
39 | + if(resultArr != null && resultArr!==undefined && resultArr['uuid']!=null && resultArr['uuid']!==undefined) { | |
40 | + //可以用字符或字符串分割 | |
41 | + var resultArr=resultArr['uuid'].split('@'); | |
42 | + alert( resultArr[0]); | |
43 | + /* $$.ajax({ | |
44 | + method : "POST", | |
45 | + url: url.to('smart/default/check-uuid'), | |
46 | + data : {qrcode:resultArr['number']}, | |
47 | + dataType : "json", | |
48 | + beforeSend : function(){ | |
49 | + me.showIndicator(); | |
50 | + }, | |
51 | + success : function(res){ | |
48 | 52 | |
49 | - if(res.success){ | |
50 | - that.attr('data-qrcode', resultArr['number']); | |
51 | - $$("#redpack .scanbtn-box").addClass('qrcode-success'); | |
53 | + if(res.success){ | |
54 | + that.attr('data-qrcode', resultArr['number']); | |
55 | + $$("#redpack .scanbtn-box").addClass('qrcode-success'); | |
52 | 56 | |
53 | - $$('.qrcode-note').html('扫码成功'); | |
54 | - $$('.qrcode-note').css('color', '#00C800'); | |
55 | - me.checkBtnColor(); | |
56 | - }else{ | |
57 | - //resultDom='<div class="qrcode-fail">fail</div>'; | |
58 | - $$('.qrcode-note').html(res.msg) | |
59 | - //utils.toast({content:res.msg}); | |
60 | - } | |
61 | - //that.append(resultDom); | |
62 | - }, | |
63 | - error : function(e){}, | |
64 | - complete : function(e){ | |
65 | - me.hideIndicator(); | |
66 | - }, | |
67 | - });*/ | |
57 | + $$('.qrcode-note').html('扫码成功'); | |
58 | + $$('.qrcode-note').css('color', '#00C800'); | |
59 | + me.checkBtnColor(); | |
60 | + }else{ | |
61 | + //resultDom='<div class="qrcode-fail">fail</div>'; | |
62 | + $$('.qrcode-note').html(res.msg) | |
63 | + //utils.toast({content:res.msg}); | |
64 | + } | |
65 | + //that.append(resultDom); | |
66 | + }, | |
67 | + error : function(e){}, | |
68 | + complete : function(e){ | |
69 | + me.hideIndicator(); | |
70 | + }, | |
71 | + });*/ | |
68 | 72 | |
69 | - }else{ | |
70 | - utils.toast({content:'请扫描智能防伪二维码'}); | |
73 | + }else{ | |
74 | + utils.toast({content:'请扫描智能防伪二维码'}); | |
75 | + } | |
71 | 76 | } |
72 | - } | |
77 | + }); | |
73 | 78 | }); |
74 | 79 | }; |
75 | 80 | |
81 | + ctrl.bindEvents = function () { | |
82 | + var me = this; | |
83 | + }; | |
76 | 84 | return ctrl; |
77 | 85 | } |
78 | 86 | ); |
79 | 87 | \ No newline at end of file | ... | ... |
common/helpers/UrlHelper.php
... | ... | @@ -35,9 +35,9 @@ class UrlHelper |
35 | 35 | */ |
36 | 36 | public static function getWxUrl() { |
37 | 37 | if (YII_ENV == "prod") { |
38 | - $httpUrl = "https://wx.jiwork.com"; | |
38 | + $httpUrl = "http://smart.zhoundlee.com"; | |
39 | 39 | } else if (YII_ENV == "test") { |
40 | - $httpUrl = "https://twx.jiwork.com"; | |
40 | + $httpUrl = "https://tsmart.zhoundlee.com"; | |
41 | 41 | } else { |
42 | 42 | $httpUrl = "http://localhost/jw/src/app-wx/web"; |
43 | 43 | } | ... | ... |
common/helpers/WxHelper.php
... | ... | @@ -26,7 +26,7 @@ use common\exts\wxpay\data\OrderQuery as WxPayOrderQuery; |
26 | 26 | class WxHelper |
27 | 27 | { |
28 | 28 | const TEST_PREFIX = 't'; // 测试系统域名前缀: 'test.' => 't' |
29 | - const HTTP_PREFIX = 'https://'; | |
29 | + const HTTP_PREFIX = 'http://'; | |
30 | 30 | |
31 | 31 | public static $errMsg = ''; |
32 | 32 | private static $wxPHPSDK; | ... | ... |
environments/prod/app-ht/config/params-local.php