ServiceWorkLogic.php 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\logic\works;
  15. use app\common\enum\ThirdTypeEnum;
  16. use app\common\enum\worker\WorkerAccountLogEnum;
  17. use app\common\logic\ThirdOrderLogic;
  18. use app\common\logic\WorkerAccountLogLogic;
  19. use app\common\model\third\ThirdOrders;
  20. use app\common\model\works\ServiceWorkDeterminedPrice;
  21. use think\Exception;
  22. use think\db\Query;
  23. use think\facade\Db;
  24. use think\facade\Log;
  25. use app\common\logic\BaseLogic;
  26. use app\api\logic\PerformanceLogic;
  27. use app\common\model\dict\DictData;
  28. use app\common\model\coupon\UserCoupon;
  29. use app\common\model\works\ServiceWork;
  30. use app\common\model\recharge\OrderGoods;
  31. use app\common\model\spare_part\SparePart;
  32. use app\common\model\works\ServiceWorkLog;
  33. use app\common\model\coupon\CouponCategory;
  34. use app\common\model\recharge\RechargeOrder;
  35. use app\common\model\works\ServiceWorkSpare;
  36. use app\workerapi\logic\ServiceWorkLogLogic;
  37. use app\common\model\orders\OrderEffectiveLog;
  38. use app\common\model\master_worker\MasterWorker;
  39. use app\common\model\training\TrainingWorkerTask;
  40. use app\common\model\performance\PerformanceRules;
  41. use app\common\model\works\ServiceWorkCustomerLog;
  42. use app\workerapi\logic\ServiceWorkReceiveLogLogic;
  43. use app\common\model\master_worker\MasterWorkerTeam;
  44. use app\common\model\works\ServiceWorkAppointmentLog;
  45. use app\workerapi\logic\ServiceWorkerAllocateWorkerLogic;
  46. use app\common\model\master_worker\MasterWorkerAccountLog;
  47. use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
  48. use app\common\model\master_commission\MasterWorkerCommissionRatio;
  49. use app\common\model\master_commission\MasterWorkerCommissionConfig;
  50. /**
  51. * ServiceWork逻辑
  52. * Class ServiceWorkLogic
  53. * @package app\adminapi\logic\works
  54. */
  55. class ServiceWorkLogic extends BaseLogic
  56. {
  57. /**
  58. * @notes 编辑
  59. * @param array $params
  60. * @return bool
  61. * @author likeadmin
  62. * @date 2024/07/10 18:17
  63. */
  64. public static function edit(array $params): bool
  65. {
  66. Db::startTrans();
  67. try {
  68. ServiceWork::where('id', $params['id'])->update([
  69. 'address' => $params['address'],
  70. 'appointment_time' => strtotime($params['appointment_time']),
  71. 'estimated_finish_time' => $params['estimated_finish_time'],
  72. 'lon' => $params['lon'],
  73. 'lat' => $params['lat'],
  74. ]);
  75. Db::commit();
  76. return true;
  77. } catch (\Exception $e) {
  78. Db::rollback();
  79. self::setError($e->getMessage());
  80. return false;
  81. }
  82. }
  83. /**
  84. *
  85. * @return false|void
  86. */
  87. public static function pickWork($params)
  88. {
  89. Db::startTrans();
  90. try {
  91. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  92. if($work->isEmpty()){
  93. throw new Exception('工单不存在');
  94. }
  95. $receive_time = time();
  96. $work->work_status = 2;//待联系
  97. $work->service_status = 1;//服务中
  98. $work->receive_time = $receive_time;
  99. $work->save();
  100. //添加变更日志
  101. $work_log = [
  102. 'work_id'=>$work->id,
  103. 'master_worker_id'=>$work->master_worker_id,
  104. 'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',$receive_time).'领取了工单',
  105. ];
  106. ServiceWorkLogLogic::add($work_log);
  107. //添加领单日志
  108. ServiceWorkReceiveLogLogic::add($work_log);
  109. Db::commit();
  110. }
  111. catch (\Exception $e) {
  112. Db::rollback();
  113. self::setError($e->getMessage());
  114. return false;
  115. }
  116. }
  117. /**
  118. * 预约成功,等待上门
  119. * @return false|void
  120. */
  121. public static function appointWork($params)
  122. {
  123. Db::startTrans();
  124. try {
  125. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  126. if($work->isEmpty()){
  127. throw new Exception('工单不存在');
  128. }
  129. if($work->work_status != 2){
  130. throw new Exception('请勿重复点击');
  131. }
  132. //验证更改的预约时间必须是在领单时间内的半小内修改,否则不允许修改
  133. if(strtotime($work->appointment_time) != strtotime($params['appointment_time']) && (time()-strtotime($work->receive_time))>1800){
  134. throw new Exception('距离领单时间已超过半小时,无法修改预约时间,请联系客服');
  135. }
  136. $work->work_status = 3;//待上门
  137. $work->appointment_time = strtotime($params['appointment_time']);
  138. $work->save();
  139. //添加变更日志
  140. $work_log = [
  141. 'work_id'=>$work->id,
  142. 'master_worker_id'=>$work->master_worker_id,
  143. 'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'联系了客户,确认了于'.$params['appointment_time'].$params['address'].'预约上门',
  144. ];
  145. ServiceWorkLogLogic::add($work_log);
  146. Db::commit();
  147. }
  148. catch (\Exception $e) {
  149. self::setError($e->getMessage());
  150. return false;
  151. }
  152. }
  153. /**
  154. * 工程师确认上门
  155. * @param $params
  156. * @return false|void
  157. */
  158. public static function confirmDoor($params)
  159. {
  160. Db::startTrans();
  161. try {
  162. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  163. if($work->isEmpty()){
  164. throw new Exception('工单不存在');
  165. }
  166. if($work->work_status != 3){
  167. throw new Exception('请勿重复点击');
  168. }
  169. $work->finally_door_time = time();//最后上门时间
  170. $work->work_status = 4;//已上门
  171. $work->save();
  172. //如果是美团订单,且上门时间小于预约时间,则修改预约时间
  173. if($work->third_type==1 and $work->finally_door_time<$work->appointment_time){
  174. $third_order = ThirdOrders::where('work_id',$work->id)->order('id desc')->findOrEmpty();
  175. if(!$third_order->isEmpty()){
  176. ThirdOrderLogic::merchantmodify([
  177. 'reserveOrderId'=>$third_order['orderId'],
  178. 'reserveUserName'=>$work['real_name'],
  179. "reservePhone"=>$work['mobile'],
  180. "reserveAddress"=>$work['address'],
  181. "bookStartTime"=>$work->finally_door_time*1000,
  182. "bookEndTime"=>($work->finally_door_time+2*3600)*1000,
  183. 'request_msg'=>$third_order['request_msg']
  184. ]);
  185. }
  186. }
  187. //添加变更日志
  188. $work_log = [
  189. 'work_id'=>$work->id,
  190. 'master_worker_id'=>$work->master_worker_id,
  191. 'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'已上门',
  192. ];
  193. ServiceWorkLogLogic::add($work_log);
  194. Db::commit();
  195. }
  196. catch (\Exception $e) {
  197. Db::rollback();
  198. self::setError($e->getMessage());
  199. return false;
  200. }
  201. }
  202. /**
  203. * 工程师确认报价单
  204. * @param $params
  205. * @return false|void
  206. */
  207. public static function confirmPrice($params)
  208. {
  209. Db::startTrans();
  210. try {
  211. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  212. if($work->isEmpty()){
  213. throw new Exception('工单不存在');
  214. }
  215. //搜索待支付订单
  216. $paid_order = RechargeOrder::where(['work_id'=>$work['id'],'pay_status'=>1])->findOrEmpty()->toArray();
  217. if(empty($paid_order)){
  218. throw new Exception('订单错误');
  219. }
  220. if($work->work_status != 4){
  221. throw new Exception('请勿重复操作');
  222. }
  223. // 关联配件信息.计算配件总价 id company_price original_price offering_price number
  224. $spare_total = 0;
  225. isset($params['spare_parts']) && $params['spare_parts'] && $params['spare_parts'] = json_decode($params['spare_parts'], true);
  226. if(isset($params['spare_parts']) && $params['spare_parts']){
  227. $spare_parts = $params['spare_parts'];
  228. foreach ($spare_parts as $spare){
  229. $spare_total += $spare['company_price']*$spare['number'];
  230. }
  231. $work->spare_total = $spare_total;
  232. $service_work_spare = ServiceWorkSpare::where(['service_work_id'=>$work['id']])->findOrEmpty();
  233. if($service_work_spare->isEmpty()){
  234. //新增
  235. $service_work_spare = ServiceWorkSpare::create([
  236. 'service_work_id'=>$work['id'],
  237. 'spare_parts'=>$params['spare_parts'],
  238. 'remark'=>''
  239. ]);
  240. }else{
  241. //修改
  242. $service_work_spare->spare_parts = $params['spare_parts'];
  243. $service_work_spare->save();
  244. }
  245. $work->service_work_spare_id = $service_work_spare->id;
  246. }
  247. // order_amount 原 = $params['amount'] 修改为 = 配件总价 + 服务尾款
  248. $order_amount = $params['amount'] + $spare_total;
  249. //定金存在尾款结算功能,全款直接提交
  250. if($paid_order['payment_type']==1){
  251. $un_order = RechargeOrder::where(['work_id'=>$work['id'],'pay_status'=>0])->findOrEmpty();
  252. if($un_order->isEmpty()){
  253. //新增待支付尾款
  254. $order_data = [
  255. 'order_type'=>$paid_order['order_type'],
  256. 'sn'=>generate_sn(\app\common\model\orders\RechargeOrder::class, 'sn'),
  257. 'work_id'=>$paid_order['work_id'],
  258. 'user_id'=>$paid_order['user_id'],
  259. 'payment_type'=>2,
  260. 'order_total'=>$order_amount,
  261. //'order_amount'=>$params['amount'],
  262. 'order_amount'=>$order_amount,
  263. 'order_terminal'=>$paid_order['order_terminal']
  264. ];
  265. RechargeOrder::create($order_data);
  266. }else{
  267. //修改尾款信息
  268. $un_order->order_total = $order_amount;
  269. //$un_order->order_amount = $params['amount'];
  270. $un_order->order_amount = $order_amount;
  271. $un_order->save();
  272. }
  273. //更新服务费用
  274. $work->service_fee = $paid_order['paid_amount']+$params['amount'];
  275. }
  276. //总工单费用
  277. $work->work_total = $work->service_fee+$spare_total;
  278. $work->work_images = $params['work_images'];
  279. $work->explanation = $params['explanation']??'';
  280. //判断是否是第三个订单,如果是美团订单直接滤过用户确认环节
  281. if($work->third_type==1){
  282. $work->work_status = 5;
  283. $work->user_confirm_status = 2;
  284. }else{
  285. $work->user_confirm_status = 1;//待确认报价
  286. }
  287. if($work->external_platform_id > 0){
  288. $work->work_status = 5;
  289. $work->user_confirm_status = 2;
  290. }
  291. $work->price_approval = 0;
  292. $work->save();
  293. //添加变更日志
  294. $work_log = [
  295. 'work_id'=>$work->id,
  296. 'master_worker_id'=>$work->master_worker_id,
  297. 'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'提交了报价单',
  298. ];
  299. ServiceWorkLogLogic::add($work_log);
  300. // 添加工单尾款报价记录
  301. if(isset($params['price_content'])){
  302. !is_array($params['price_content']) && $params['price_content'] = json_decode($params['price_content'], true);
  303. ServiceWorkDeterminedPrice::where('work_id',$work->id)->delete();
  304. ServiceWorkDeterminedPrice::create([
  305. 'work_id'=>$work->id,
  306. 'content'=>$params['price_content']??[],
  307. ]);
  308. }
  309. Db::commit();
  310. // 外部平台工单 - 通知外边平台
  311. if($work->external_platform_id > 0){
  312. event('ExternalPlatform', [
  313. 'scene' => 'confirm_price',
  314. 'params' => [
  315. 'work_id' => $work->id,
  316. ]
  317. ]);
  318. }
  319. }
  320. catch (\Exception $e) {
  321. Db::rollback();
  322. self::setError($e->getMessage());
  323. return false;
  324. }
  325. }
  326. /**
  327. * 工程师确认服务完成
  328. * @param $params
  329. * @return false|void
  330. */
  331. public static function confirmServiceFinish($params)
  332. {
  333. Db::startTrans();
  334. try {
  335. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  336. if($work->isEmpty()){
  337. throw new Exception('工单不存在');
  338. }
  339. if($work->user_confirm_status !=2){
  340. throw new Exception('请勿重复操作');
  341. }
  342. $work->finished_images = $params['finished_images'];
  343. $work->user_confirm_status = 3;//待确认服务完成
  344. $work->save();
  345. //添加变更日志
  346. $work_log = [
  347. 'work_id'=>$work->id,
  348. 'master_worker_id'=>$work->master_worker_id,
  349. 'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'提交了待用户确认服务完成',
  350. ];
  351. ServiceWorkLogLogic::add($work_log);
  352. Db::commit();
  353. // 外部平台工单 - 通知外边平台
  354. if($work->external_platform_id > 0){
  355. event('ExternalPlatform', [
  356. 'scene' => 'service_finish',
  357. 'params' => [
  358. 'work_id' => $work->id,
  359. ]
  360. ]);
  361. }
  362. } catch (\Exception $e) {
  363. Db::rollback();
  364. self::setError($e->getMessage());
  365. return false;
  366. }
  367. }
  368. public static function allocateWorker($params,$userInfo){
  369. Db::startTrans();
  370. try {
  371. $work = ServiceWork::findOrEmpty($params['id']);
  372. if($work->isEmpty()){
  373. throw new Exception('工单不存在');
  374. }
  375. if($work->work_status >=6 ){
  376. throw new \Exception('工单状态只能修改待结算之前的');
  377. }
  378. if($work->master_worker_id == $params['master_worker_id']){
  379. throw new \Exception('分配的工程师相同');
  380. }
  381. $worker = MasterWorker::where(['id'=>$params['master_worker_id'],'is_disable' =>0])->findOrEmpty();
  382. if($worker->isEmpty()){
  383. throw new \Exception('工程师不存在或被禁用');
  384. }
  385. if($worker->master_worker_id){
  386. MasterWorker::setWorktotal('dec',$worker->master_worker_id);
  387. }
  388. $work->master_worker_id = $params['master_worker_id'];
  389. $work->work_status = 1;
  390. $work->dispatch_time = time();
  391. MasterWorker::setWorktotal('inc',$params['master_worker_id']);
  392. $work->save();
  393. $work_log = [
  394. 'work_id'=>$work->id,
  395. 'master_worker_id'=>$work->master_worker_id,
  396. 'type' => 0,
  397. 'opera_log'=>'后台用户['.$userInfo['admin_id'].']'.$userInfo['name'].'于'.date('Y-m-d H:i:s',time()).'分配了工程师'.'编号['.$worker->worker_number.']'.$worker->real_name
  398. ];
  399. ServiceWorkerAllocateWorkerLogic::add($work_log);
  400. Db::commit();
  401. //美团的订单更新履约状态为已分配
  402. if($work->third_type == 1){
  403. ThirdOrderLogic::updateorderfulfillinfo($work,ThirdTypeEnum::MEITUAN_MEITUAN);
  404. }
  405. // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
  406. $workDetail = ServiceWorkLogic::detail($params);
  407. $res = event('Notice', [
  408. 'scene_id' => 113,
  409. 'params' => [
  410. 'user_id' => $params['master_worker_id'],
  411. 'order_id' => $params['id'],
  412. 'thing9' => $workDetail['title'],
  413. 'time7' => $workDetail['appointment_time'],
  414. 'thing8' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
  415. 'phone_number6' => asteriskString($workDetail['mobile']),
  416. ]
  417. ]);
  418. return true;
  419. }catch(\Exception $e){
  420. Db::rollback();
  421. self::setError($e->getMessage());
  422. return false;
  423. }
  424. }
  425. /**
  426. * 工单详情
  427. * @param $params
  428. * @return array|false
  429. */
  430. public static function detail($params){
  431. $work_where = !empty($params['work_sn'])?['work_sn'=>$params['work_sn']]:['id'=>$params['id']];
  432. $result = ServiceWork::with([
  433. 'worker'=> function(Query $query) {
  434. $query->field('id,worker_number,real_name,mobile');
  435. },
  436. 'allocateWorkerLog' =>function(Query $query){
  437. $query->field('id,work_id,opera_log,create_time');
  438. },
  439. 'serviceWorkLog' =>function(Query $query){
  440. $query->field('id,work_id,opera_log,create_time');
  441. }
  442. ])->append(['id','work_status_text','service_status_text'])
  443. ->where($work_where)
  444. ->findOrEmpty()->toArray();
  445. $result['is_operate_prohibit'] = 0;
  446. if(isset($params['user_id']) && $params['user_id'] && ($params['user_id'] != $result['master_worker_id']) ){
  447. // 带徒师傅的工单
  448. $lead_master_worker_id = TrainingWorkerTask::where('master_worker_id',$params['user_id'])->where('training_status',2)
  449. ->where('operate_status',0)->value('lead_master_worker_id');
  450. // 团队负责人编辑 工单池(包括已派队员) 工单
  451. if($params['user_info']['team_role'] == 1 && $params['user_info']['tenant_id'] == $result['tenant_id'] ){
  452. $result['is_operate_prohibit'] = 0;
  453. }elseif(!empty($lead_master_worker_id) && !empty($result['master_worker_id']) && $lead_master_worker_id == $result['master_worker_id']){
  454. // 徒查看师父的工单 不能编辑可查看
  455. $result['is_operate_prohibit'] = 1;
  456. }else{
  457. throw new \Exception('您没有权限操作该工单');
  458. }
  459. }
  460. //工程师工单按钮状态
  461. $work_service_status = 0;
  462. $work_service_status_text = '待派单';
  463. //工单状态
  464. if($result['work_status'] == 1){
  465. $work_service_status = 1;
  466. $work_service_status_text = '待领单';
  467. }
  468. if($result['work_status'] == 2){
  469. $work_service_status = 2;
  470. $work_service_status_text = '预约上门';
  471. }
  472. if($result['work_status'] == 3){
  473. $work_service_status = 3;
  474. $work_service_status_text = '等待上门';
  475. if(date('Y-m-d') === date('Y-m-d',strtotime($result['appointment_time']))){
  476. $work_service_status = 4;
  477. $work_service_status_text = '确认上门';
  478. }
  479. }
  480. if($result['work_status'] == 4 and $result['user_confirm_status']==0){
  481. $work_service_status = 5;
  482. $work_service_status_text = '确认报价';
  483. }
  484. if($result['work_status'] == 4 and $result['user_confirm_status']==1){
  485. $work_service_status = 6;
  486. $work_service_status_text = '用户确认报价中';
  487. }
  488. if($result['work_status'] == 5 and $result['user_confirm_status']==2){
  489. $work_service_status = 7;
  490. $work_service_status_text = '完成服务';
  491. }
  492. if($result['work_status'] == 5 and $result['user_confirm_status']==3){
  493. $work_service_status = 8;
  494. $work_service_status_text = '用户确认完成服务中';
  495. }
  496. if($result['work_status'] ==6){
  497. $work_service_status = 9;
  498. $work_service_status_text = '待结算';
  499. }
  500. if($result['work_status'] ==7){
  501. $work_service_status = 10;
  502. $work_service_status_text = '已完结';
  503. }
  504. if($result['work_status'] ==8){
  505. $work_service_status = 11;
  506. $work_service_status_text = '已评价';
  507. }
  508. if($result['work_status'] ==9){
  509. $work_service_status = 12;
  510. $work_service_status_text = '已退费';
  511. }
  512. $result['work_service_status'] = $work_service_status;
  513. $result['work_service_status_text'] = $work_service_status_text;
  514. //搜索当前工单下的所有订单记录
  515. $result['pay_orders'] = RechargeOrder::with(['orderGoods'=>function(Query $query){
  516. $query->field('id,sn,goods_id,goods_name,goods_image,goods_number,good_unit,goods_size,goods_payment_type,goods_type,goods_brand,base_service_fee,service_total,service_fee')->order(['id'=>'desc']);
  517. }])->where(['work_id'=>$result['id']])->field('id as order_id,sn,order_type,pay_status,payment_type,pay_way,pay_time,order_amount,order_total,coupon_price,create_time')->order('id asc')->select()->toArray();
  518. $pay_status_data = DictData::where('type_value','pay_status')->column('name','value');
  519. $payment_type_data = DictData::where('type_value','payment_type')->column('name','value');
  520. $pay_way_data = DictData::where('type_value','pay_way')->column('name','value');
  521. $order_type_data = DictData::where('type_value','order_type')->column('name','value');
  522. $coupon_price = 0;
  523. foreach ($result['pay_orders'] as $k=>&$v){
  524. $v['pay_status_name'] = $pay_status_data[$v['pay_status']];
  525. $v['payment_type_name'] = $payment_type_data[$v['payment_type']];
  526. $v['pay_way_name'] = $pay_way_data[$v['pay_way']];
  527. $v['order_type_name'] = $order_type_data[$v['order_type']];
  528. $v['pay_time'] = $v['pay_time'] && is_numeric($v['pay_time']) ? date('Y-m-d H:i:s',$v['pay_time']):'';
  529. if($v['payment_type']!=1 and !empty($result['spare_total'])){
  530. $v['order_total'] = $v['order_total'] - $result['spare_total'];
  531. $v['order_amount'] = $v['order_amount'] - $result['spare_total'];
  532. }
  533. $coupon_price += $v['coupon_price'];
  534. //服务支付类别
  535. if(!empty($v['orderGoods'][0]['goods_payment_type'])){
  536. $goods_payment_type = $v['orderGoods'][0]['goods_payment_type'];
  537. }
  538. }
  539. $result['goods_payment_type'] = !empty($goods_payment_type)?$goods_payment_type:1;
  540. //汇总优惠卷额度
  541. $result['coupon_price'] = $coupon_price;
  542. //工单总支付金额
  543. $result['worker_account'] = $result['work_amount'];
  544. // 配件信息
  545. $result['spare_parts'] = [];
  546. if($result['service_work_spare_id']){
  547. $work_spare_parts = json_decode(ServiceWorkSpare::where('id',$result['service_work_spare_id'])->value('spare_parts'),true);
  548. $spare_parts = SparePart::where('id','in',array_column($work_spare_parts,'id'))
  549. ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit','spare_status'])
  550. ->select()
  551. ->toArray();
  552. $spare_parts = array_column($spare_parts,null,'id');
  553. foreach (array_column($work_spare_parts,null,'id') as $k=>&$v){
  554. $spare_parts[$k] = array_merge($spare_parts[$k],$v);
  555. }
  556. $result['spare_parts'] = array_values($spare_parts)??[];
  557. }
  558. // 保修卡信息
  559. $result['order_effectives'] = OrderEffectiveLog::with(['goods'=>function ($query) {
  560. $query->with(['goodsCategory'=>function ($query1) {
  561. $query1->field(['name','picture']);
  562. }]);
  563. }])->where('work_id',$result['id'])
  564. ->field(['id','goods_id','sn','effective_unit','effective_num','remark','end_effective_time'])
  565. ->append(['effective_unit_text'])
  566. ->order('create_time desc')
  567. ->select()
  568. ->toArray();
  569. //查收工程师提成金额
  570. $change_amount = MasterWorkerAccountLog::where(['work_sn'=>$result['work_sn'],'action'=>1])->value('change_amount');
  571. $result['change_amount'] = !empty($change_amount)?$change_amount:0;
  572. //质保金相关金额
  573. $result['retention'] = MasterWorkerRetentionMoneyLog::where('work_id',$result['id'])->visible(['action','amount'])->select()
  574. ->each(function ($item){
  575. $item['amount'] = $item['action'] == 1 ? '+'.$item['amount'] : '-'.$item['amount'];
  576. })->toArray();
  577. //保修工单时的信息
  578. $result['effective_income_amount'] = 0;
  579. if(!empty($result['order_effective_id'])){
  580. $order_effective = OrderEffectiveLog:: findOrEmpty($result['order_effective_id']);
  581. $serviceWork = ServiceWork::findOrEmpty($order_effective->work_id);
  582. if($serviceWork->master_worker_id != $result['master_worker_id']){
  583. $result['effective_income_amount'] = \app\adminapi\logic\effective\OrderEffectiveLogLogic::commissionAndAssuranceDeposit($serviceWork);
  584. }
  585. }
  586. //获取美团订单信息
  587. $result['meituan_order'] = [];
  588. if($result['third_type']==1){
  589. $result['meituan_order'] = ThirdOrders::where(['work_id'=>$result['id']])->order('create_time desc')->findOrEmpty();
  590. }
  591. return $result;
  592. }
  593. public static function getUserCouponDetails($params)
  594. {
  595. try{
  596. $work = ServiceWork::where('id',$params['id'])->findOrEmpty();
  597. if(!$work){
  598. throw new \Exception('工单不存在');
  599. }
  600. $coupon_all_ids =UserCoupon::where('user_id',$work['user_id'])
  601. ->where('voucher_count','>',0)
  602. ->where('voucher_status',0)
  603. ->where('expire_time','>',time())
  604. ->column('coupon_id');
  605. $coupon_ids = CouponCategory::where('goods_category_id',$work['goods_category_id'])->whereIn('coupon_id',$coupon_all_ids)->column('coupon_id');
  606. $data = UserCoupon::where('user_id',$work['user_id'])
  607. ->where('voucher_count','>',0)
  608. ->where('voucher_status',0)
  609. ->whereIn('coupon_id',$coupon_ids)
  610. ->append(['discount_ratio_text'])
  611. ->where('expire_time','>',time())
  612. ->visible(['id','coupon_id','amount','amount_require','begin_use','discount_ratio','event_name','expire_time','max_deductible_price','server_category_name','mold_type'])
  613. ->select()->toArray();
  614. foreach($data as $k => $v){
  615. $data[$k]['begin_use'] = date("Y-m-d H:i:s",$v['begin_use'] );
  616. $data[$k]['expire_time'] = date("Y-m-d H:i:s",$v['expire_time'] );
  617. $data[$k]['amount_require'] = '满'.$v['amount_require'].'可用';
  618. }
  619. return $data;
  620. } catch(\Exception $e){
  621. self::setError($e->getMessage());
  622. return false;
  623. }
  624. }
  625. public static function getDetailWorkServiceStatus($params)
  626. {
  627. $result = ServiceWork::where('id',$params['id'])->field('work_status,user_confirm_status,appointment_time,price_approval,appoint_approval')->findOrEmpty()->toArray();
  628. //工程师工单按钮状态
  629. $work_service_status = 0;
  630. //工单状态
  631. if($result['work_status'] == 1){
  632. $work_service_status = 1;
  633. }
  634. if($result['work_status'] == 2){
  635. $work_service_status = 2;
  636. }
  637. if($result['work_status'] == 3){
  638. $work_service_status = 3;
  639. if(date('Y-m-d') === date('Y-m-d',strtotime($result['appointment_time']))){
  640. $work_service_status = 4;
  641. }
  642. }
  643. if($result['work_status'] == 4 and $result['user_confirm_status']==0){
  644. $work_service_status = 5;
  645. }
  646. if($result['work_status'] == 4 and $result['user_confirm_status']==1){
  647. $work_service_status = 6;
  648. }
  649. if($result['work_status'] == 5 and $result['user_confirm_status']==2){
  650. $work_service_status = 7;
  651. }
  652. if($result['work_status'] == 5 and $result['user_confirm_status']==3){
  653. $work_service_status = 8;
  654. }
  655. if($result['work_status'] ==6){
  656. $work_service_status = 9;
  657. }
  658. if($result['work_status'] ==7){
  659. $work_service_status = 10;
  660. }
  661. if($result['work_status'] ==8){
  662. $work_service_status = 11;
  663. }
  664. if($result['work_status'] ==9){
  665. $work_service_status = 12;
  666. }
  667. return ['work_service_status'=>$work_service_status,'price_approval'=>$result['price_approval'],'appoint_approval'=>$result['appoint_approval']];
  668. }
  669. /**
  670. * @notes 取消操作
  671. * @param array $params
  672. * @return bool
  673. * @author likeadmin
  674. * @date 2024/09/19 10:48
  675. */
  676. public static function cancel(array $params): bool
  677. {
  678. Db::startTrans();
  679. try {
  680. // 04-11-12 不做任何限制强制取消,已支付的费用给工程师余额
  681. $serviceWorkInfo = ServiceWork::find($params['id']);
  682. if((int)$serviceWorkInfo['user_confirm_status'] === 5 || (int)$serviceWorkInfo['service_status'] > 2){
  683. throw new \Exception('用户已完结该工单或已取消,已退款,不可执行取消');
  684. }
  685. //工单如果存在费用情况,不允许取消
  686. $paid_amount = RechargeOrder::where('work_id', $params['id'])->where('pay_status', 1)->value('paid_amount');
  687. if($paid_amount > 0 and $serviceWorkInfo['third_type'] == 0){
  688. // 4=已上门,5=服务中,6=待结算, 即工程师已上门服务过
  689. throw new Exception('工单存在费用情况,不允许取消,请走退费流程');
  690. }
  691. ServiceWork::where('id', $params['id'])->update([
  692. //'work_status' => 9,
  693. 'service_status' => 4,
  694. 'remark' => $params['remark']??''
  695. ]);
  696. ServiceWorkLog::create([
  697. 'work_id' => $params['id'],
  698. 'master_worker_id' => $serviceWorkInfo['master_worker_id'],
  699. 'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
  700. ]);
  701. Db::commit();
  702. Log::info('取消工单'.json_encode([$serviceWorkInfo]));
  703. return true;
  704. } catch (\Exception $e) {
  705. Db::rollback();
  706. self::setError($e->getMessage());
  707. Log::info('取消工单-Error'.json_encode([$e->getMessage()]));
  708. return false;
  709. }
  710. }
  711. /**
  712. * @notes 工程师结算操作
  713. * @param array $params
  714. * @return bool
  715. * @author likeadmin
  716. * @date 2024/09/19 10:48
  717. */
  718. public static function settlement(array $params): bool
  719. {
  720. Db::startTrans();
  721. try {
  722. $serviceWorkInfo = ServiceWork::find($params['id']);
  723. if((int)$serviceWorkInfo['work_pay_status'] !== 3){
  724. throw new \Exception('该工单非待结算状态');
  725. }
  726. $ratio = 0;
  727. $commissionConfig = MasterWorkerCommissionConfig::where('master_worker_id',$serviceWorkInfo->master_worker_id)->where('voucher_status',2)->findOrEmpty();
  728. !$commissionConfig->isEmpty() && $ratio = MasterWorkerCommissionRatio::where('commission_config_id',$commissionConfig['id'])->where('goods_category_id',$serviceWorkInfo->goods_category_id)->value('ratio')?:0;
  729. if($commissionConfig->isEmpty() || empty($ratio)){
  730. //获取工单对应的商品id
  731. $order_sns = \app\common\model\orders\RechargeOrder::where('work_id',$serviceWorkInfo->id)->column('sn');
  732. $goods_id = OrderGoods::whereIn('sn',$order_sns)->value('goods_id');
  733. $rule = PerformanceRules::whereFindInSet('goods_id',$goods_id)->findOrEmpty();
  734. if($rule->isEmpty()){
  735. throw new \Exception('请配置商品业绩规则');
  736. }
  737. PerformanceLogic::calculatePerformance($serviceWorkInfo);
  738. }else{
  739. // 存在服务分类比例进行结算
  740. PerformanceLogic::calculatePerformanceCommission($serviceWorkInfo);
  741. }
  742. Db::commit();
  743. return true;
  744. } catch (\Exception $e) {
  745. Db::rollback();
  746. self::setError($e->getMessage());
  747. return false;
  748. }
  749. }
  750. /**
  751. * 获取所有改约通知
  752. * @param $userId
  753. * @return array|false
  754. */
  755. public static function getAppointmentNotice($userId)
  756. {
  757. return ServiceWork::where(['master_worker_id'=>$userId,'appoint_approval'=>1])
  758. ->where('work_status','>',1)
  759. ->where('work_status','<',7)
  760. ->field(['id', 'work_sn','real_name','mobile', 'address', 'title', 'appointment_time','work_status'])
  761. ->order(['appointment_time' => 'asc'])//上门时间排序
  762. ->select()->each(function (&$item){
  763. $item['last_appointment_time'] = date('Y-m-d H:i:s',ServiceWorkAppointmentLog::where('work_id',$item['id'])->order('id desc')->value('last_appointment_time'));
  764. })
  765. ->toArray();
  766. }
  767. /**
  768. * @param $params
  769. * @return bool
  770. */
  771. public static function submitAppointment($params)
  772. {
  773. Db::startTrans();
  774. try {
  775. $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
  776. if($serviceWork->isEmpty()){
  777. throw new \Exception('工单不存在');
  778. }
  779. $serviceWork->appoint_approval = 2;
  780. $serviceWork->save();
  781. Db::commit();
  782. return true;
  783. } catch (\Exception $e) {
  784. Db::rollback();
  785. self::setError($e->getMessage());
  786. return false;
  787. }
  788. }
  789. /**
  790. * @param $params
  791. * @return bool
  792. */
  793. public static function submitChangePrice($params)
  794. {
  795. Db::startTrans();
  796. try {
  797. $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
  798. if($serviceWork->isEmpty()){
  799. throw new \Exception('工单不存在');
  800. }
  801. $serviceWork->work_status = 4;
  802. $serviceWork->user_confirm_status = 0;
  803. $serviceWork->price_approval = 2;
  804. $serviceWork->save();
  805. Db::commit();
  806. return true;
  807. } catch (\Exception $e) {
  808. Db::rollback();
  809. self::setError($e->getMessage());
  810. return false;
  811. }
  812. }
  813. public static function notApproved($params)
  814. {
  815. Db::startTrans();
  816. try {
  817. $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
  818. if($serviceWork->isEmpty()){
  819. throw new \Exception('工单不存在');
  820. }
  821. $serviceWork->refund_approval = 3;
  822. $serviceWork->save();
  823. Db::commit();
  824. return true;
  825. } catch (\Exception $e) {
  826. Db::rollback();
  827. self::setError($e->getMessage());
  828. return false;
  829. }
  830. }
  831. public static function againDoor($params)
  832. {
  833. Db::startTrans();
  834. try {
  835. $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
  836. if($serviceWork->isEmpty()){
  837. throw new \Exception('工单不存在');
  838. }
  839. //更新预约日志
  840. //更新工单未确认上门的状态
  841. $serviceWork->work_status = 3;
  842. $serviceWork->user_confirm_status = 0;
  843. $appoint = ServiceWorkAppointmentLog::where(['work_id'=>$serviceWork->id,'worker_id'=>$params['user_id']])->count();
  844. if($appoint > 2){
  845. throw new Exception('您的修改预约时间次数已到上限,请联系客服处理');
  846. }
  847. ServiceWorkAppointmentLog::create([
  848. 'work_id'=>$serviceWork->id,
  849. 'worker_id'=>$params['user_id'],
  850. 'last_appointment_time'=>strtotime($serviceWork->appointment_time),
  851. 'this_appointment_time'=>strtotime($params['appointment_time']),
  852. ]);
  853. $serviceWork->appointment_time = strtotime($params['appointment_time']);
  854. $serviceWork->save();
  855. Db::commit();
  856. return true;
  857. } catch (\Exception $e) {
  858. Db::rollback();
  859. self::setError($e->getMessage());
  860. return false;
  861. }
  862. }
  863. public static function cancelAllocation($params,$userInfo){
  864. Db::startTrans();
  865. try {
  866. $work = ServiceWork::findOrEmpty($params['id']);
  867. if($work->isEmpty()){
  868. throw new Exception('工单不存在');
  869. }
  870. if($work->work_status >=6 ){
  871. throw new \Exception('工单状态只能修改待结算之前的');
  872. }
  873. $worker = MasterWorker::where(['id'=>$work->master_worker_id])->findOrEmpty();
  874. if($worker->isEmpty()){
  875. throw new \Exception('工程师不存在');
  876. }
  877. if ($work->tenant_id > 0) {
  878. //团队订单取消时,派单数量减1
  879. $updateData = date("H",strtotime($work->appointment_time)) < 12 ? ['am_order' => Db::raw('am_order - 1')] : ['pm_order' => Db::raw('pm_order - 1')];
  880. MasterWorkerTeam::where('master_worker_id',$work->master_worker_id)->where('tenant_id',$work->tenant_id)->update($updateData);
  881. }
  882. $params['master_worker_id'] = (isset($params['master_worker_id']) && !empty($params['master_worker_id']))?$params['master_worker_id']:$work->master_worker_id;
  883. MasterWorker::setWorktotal('dec',$work->master_worker_id);
  884. $work->master_worker_id = 0;
  885. $work->tenant_id = 0;
  886. $work->work_status = 0;
  887. $work->dispatch_time = 0;
  888. $work->first_contact_time = 0;
  889. $work->estimated_finish_time = 0;
  890. $work->exec_time = 0;
  891. $work->save();
  892. $work_log = [
  893. 'work_id'=>$work->id,
  894. 'master_worker_id'=>$params['master_worker_id'],
  895. 'type' => 1,
  896. 'opera_log'=>'后台用户['.$userInfo['admin_id'].']'.$userInfo['name'].'于'.date('Y-m-d H:i:s',time()).'取消了工程师'.'编号['.$worker->worker_number.']'.$worker->real_name
  897. ];
  898. ServiceWorkerAllocateWorkerLogic::add($work_log);
  899. Db::commit();
  900. return true;
  901. }catch(\Exception $e){
  902. Db::rollback();
  903. self::setError($e->getMessage());
  904. return false;
  905. }
  906. }
  907. public static function addCustomerLog($params)
  908. {
  909. Db::startTrans();
  910. try {
  911. $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
  912. if($serviceWork->isEmpty()){
  913. throw new \Exception('工单不存在');
  914. }
  915. ServiceWorkCustomerLog::create([
  916. 'work_id'=>$serviceWork->id,
  917. 'content'=>$params['content']??'',
  918. 'admin_id'=>$params['admin_id']??0,
  919. 'create_time'=>time(),
  920. ]);
  921. Db::commit();
  922. return true;
  923. } catch (\Exception $e) {
  924. Db::rollback();
  925. self::setError($e->getMessage());
  926. return false;
  927. }
  928. }
  929. public static function distributeTenants($params,$userInfo)
  930. {
  931. Db::startTrans();
  932. try {
  933. if(empty($params['id']) || empty($params['tenant_id'])){
  934. throw new \Exception('参数错误'.json_encode($params));
  935. }
  936. if (is_array($params['id'])) {
  937. $ids = $params['id'];
  938. } else{
  939. $ids = [$params['id']];
  940. }
  941. // 取消工程师分配
  942. foreach ($ids as $id) {
  943. $res = self::cancelAllocation(['id'=>$id,'master_worker_id'=>''],$userInfo);
  944. if($res === false){
  945. Log::info('分配log'.self::getError());
  946. }
  947. }
  948. ServiceWork::whereIn('id',$ids)->update(['tenant_id'=>$params['tenant_id']]);
  949. Db::commit();
  950. return true;
  951. } catch (\Exception $e) {
  952. Db::rollback();
  953. self::setError($e->getMessage());
  954. return false;
  955. }
  956. }
  957. /**
  958. *
  959. * @return false|void
  960. */
  961. public static function contactCustomer($params)
  962. {
  963. try {
  964. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  965. if($work->isEmpty()){
  966. throw new \Exception('工单不存在');
  967. }
  968. if (empty($work->first_contact_time)) {
  969. $work->first_contact_time = time();
  970. $work->save();
  971. }
  972. return true;
  973. }
  974. catch (\Exception $e) {
  975. Db::rollback();
  976. self::setError($e->getMessage());
  977. return false;
  978. }
  979. }
  980. /**
  981. * 添加第三方平台订单
  982. * @return false|void
  983. */
  984. public static function addThirdPlatformsOrders($params)
  985. {
  986. try {
  987. return ThirdOrderLogic::submitOrders($params);
  988. }catch (\Exception $e) {
  989. self::setError($e->getMessage());
  990. return false;
  991. }
  992. }
  993. /**
  994. * 上门码和完成码
  995. * @param $params
  996. * @return false|array
  997. */
  998. public static function confirmDoorCode($params)
  999. {
  1000. try {
  1001. $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
  1002. if($work->isEmpty()){
  1003. throw new Exception('工单不存在');
  1004. }
  1005. $encryptedData = encrypt($params['work_sn'], \think\facade\Config::get('project.work_sn_key'));
  1006. return ['url'=>\think\facade\Config::get('project.user_website').'?code='.$encryptedData];
  1007. }catch (\Exception $e) {
  1008. self::setError($e->getMessage());
  1009. return false;
  1010. }
  1011. }
  1012. /**
  1013. * 终止结束服务操作
  1014. */
  1015. public static function terminateService($params): bool
  1016. {
  1017. Db::startTrans();
  1018. try {
  1019. $serviceWork = ServiceWork::where('work_pay_status',1)
  1020. ->where('master_worker_id','>',0)
  1021. ->whereIn('work_status',[4,5,6])
  1022. ->where('id',$params['id'])->findOrEmpty();
  1023. if($serviceWork->isEmpty()){
  1024. throw new \Exception('该工单状态不可执行结束服务');
  1025. }
  1026. if($params['isearnest'] == 1){
  1027. ServiceWork::where('id', $params['id'])->update([
  1028. 'work_status' => 7,
  1029. 'user_confirm_status' => 5,
  1030. 'service_status' => 3,
  1031. 'work_pay_status' => 1,
  1032. 'remark' => ($serviceWork->remark?:'')." | 终止结束服务:常规流程"
  1033. ]);
  1034. }else{
  1035. $paid_amount = RechargeOrder::where('work_id', $params['id'])->where('payment_type', 1)->value('paid_amount');
  1036. if($paid_amount > 0){
  1037. // 存在上门费给工程师
  1038. Log::info('终止结束服务工单'.$serviceWork->id.',上门费:'.$paid_amount);
  1039. WorkerAccountLogLogic::addAccountLog($serviceWork,$paid_amount,WorkerAccountLogEnum::UM_INC_ADMIN,WorkerAccountLogEnum::INC);
  1040. }
  1041. ServiceWork::where('id', $params['id'])->update([
  1042. 'work_status' => 7,
  1043. 'user_confirm_status' => 5,
  1044. 'service_status' => 3,
  1045. 'work_pay_status' => 2, // 已结算则不执行 onAfterUpdate
  1046. 'settlement_amount' => $paid_amount??0,
  1047. 'worker_price' => $paid_amount??0,
  1048. 'remark' => ($serviceWork->remark?:'')." | 终止结束服务:上门费-{$paid_amount}"
  1049. ]);
  1050. }
  1051. ServiceWorkLog::create([
  1052. 'work_id' => $params['id'],
  1053. 'master_worker_id' => $serviceWork->master_worker_id,
  1054. 'opera_log' => "工单:{$serviceWork->work_sn} 终止结束服务"
  1055. ]);
  1056. Db::commit();
  1057. Log::info('终止结束服务'.json_encode([$serviceWork]));
  1058. return true;
  1059. } catch (\Exception $e) {
  1060. Db::rollback();
  1061. self::setError($e->getMessage());
  1062. Log::info('终止结束服务-Error'.json_encode([$e->getMessage()]));
  1063. return false;
  1064. }
  1065. }
  1066. }