UserController.php 47.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/13
 * Time: 17:04
 */

namespace api\index\controller;


use cmf\controller\RestBaseController;
use think\Cache;
use think\cache\driver\Redis;
use think\Validate;
use think\Db;
use cmf\lib\Storage;

/**
 * @title 个人中心
 * @description
 */
class UserController extends RestBaseController
{
    /**
     * @title 登录注册
     * @description 接口说明
     * @author Guosheng
     * @url /index/User/login
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:phone type:int require:1 default: other: desc:手机号
     * @param name:code type:string require:1 default: other: desc:验证码
     *
     */
    public function login()
    {
        $user_id = $this->getUserId();
        $param = $this->request->param();
        $validate = new Validate([
            'phone' => 'require|max:11',
            'code'=>'require'
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
        $code = Cache::get($param['phone']);
        if($code == $param['code']){
            $res['user_id'] = $user_id;
            $res['create_time'] = time();
            $res['phone'] = $param['phone'];
            $data = Db::name('integral')
                ->insert($res);
            if($data){
                $this->success('SUCCESS');
            }
        }else{
            $this->error(['code'=>40002,'msg'=>'验证码错误或者失效,请重新发送']);
        }
    }

    /**
     * @title 获取验证码
     * @description
     * @author Guosheng
     * @url /index/User/getcode
     * @method POST
     *
     * @param name:phone type:string require:1 other: desc:手机号码
     *
     * @return code:验证码
     */
    public function getcode()
    {
        $phone = $this->request->param('phone');
        if (empty($phone)) {
            $this->error(['code' => 40005, 'msg' => '缺少必要参数']);
        }
        if (!preg_match('/^1[0-9]{10}$/', $phone)) {
            $this->error(['code' => 40005, 'msg' => "请输入正确的手机格式!"]);
        }
        //生成验证码
        $number = generateCode();
        //发送验证码
        $data = array(
            'content' => "【蓝科环保】垃圾分类,共创绿色生活,您的验证码是:" .$number.",十分钟之内有效,请勿向他人泄漏您的验证码",//短信内容
            'mobile' => $phone,//手机号码
            'productid' => '676767',//产品id
            'xh' => ''//小号
        );
        $result = send_sms($data);
        if (substr($result, 0, strpos($result, ',')) != "1") {
            $this->error(['code' => 42001, 'msg' => $result]);
        }
        Cache::set($phone,$number,600);
//        $code = Db::name('code')
//            ->where('phone',$phone)
//            ->find();
//        if (empty($code)) {
//            $arr['phone'] = $phone;
//            $arr['create_time'] = time();
//            $arr['expire_time'] = time() + 60;
//            $arr['code'] = $number;
//            $result = Db::name('code')
//                ->insertGetId($arr);
//        } else {
//            $arr['code'] = $number;
//            $arr['update_time'] = time();
//            $arr['expire_time'] = time() + 60;
//            $result = Db::name('code')
//                ->where('phone',$phone)
//                ->update($arr);
//        }
//        if (empty($result)) {
//            $this->error(['code' => 40006, 'msg' => 'sql执行失败']);
//        }

        $this->success('SUCCESS');
    }

    /**
     * @title 判断用户身份
     * @description 接口说明
     * @author Guosheng
     * @url /index/User/judge
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return is_set:0不是回收员  1是回收员
     */
    public function judge()
    {
        $user_id = $this->getUserId();
        $data = Db::name('user')
            ->where('id',$user_id)
            ->field('is_set')
            ->find();
        $this->success('success',$data);
    }

    /**
     * @title 我的首页
     * @description 接口说明
     * @author Guosheng
     * @url /index/User/userInfo
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return user_nickname:昵称
     * @return avatar:头像
     * @return now:当前积分
     * @return num:参与次数
     * @return add_total:累计积分
     *
     */
    public function userInfo()
    {
        $user_id = $this->getUserId();
        $info = Db::name('integral')
            ->alias('a')
            ->join('user b','a.user_id = b.id')
            ->field('a.*,b.user_nickname,b.avatar')
            ->where('a.user_id',$user_id)
            ->find();
        if(empty($info)){
            $this->error(['code'=>40006,'msg'=>'您还没有注册,请先注册!']);
        }
        $this->success('SUCCESS',$info);

    }

    /**
     * @title 充值积分列表
     * @description 接口说明
     * @author Guosheng
     * @url /index/User/pay
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return integral:积分
     * @return money:金额
     *
     */
    public function pay(){
        $user_id = $this->getUserId();
        $data = Db::name('pay')
            ->where('delete_time',0)
            ->select();
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 提现金额列表
     * @description 接口说明
     * @author Guosheng
     * @url /index/User/money
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return integral:积分
     * @return money:金额
     *
     */
    public function money(){
        $user_id = $this->getUserId();
        $data = Db::name('money')
            ->where('delete_time',0)
            ->select();
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 我的回收订单
     * @description 我的回收订单
     * @author Guosheng
     * @url /index/User/recycleorder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:status require:1 other desc:订单状态(不传或者为0是 已预约,1已接单,2已完成)
     *
     * @return id:订单ID
     * @return num:订单号
     * @return rgoods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     * @return ping:是否评价过 (1未评价2已评价过)
     *
     */
    public function recycleorder()
    {
        $user_id = $this->getUserId();
        $status = $this->request->param('status',0,'intval');
        if(empty($status) || $status == 0){
            //已预约的回收订单
           $data = Db::name('subscribe')
               ->where('user_id',$user_id)
               ->where('status',0)
               ->field('id,num,create_time,sub_time,attr_id')
               ->select()
               ->toArray();
            $res = $this->r_foreach($data);
            $this->success('SUCCESS',$res);
        }elseif ($status == 1){
            //已接单的回收订单
            $data = Db::name('subscribe')
                ->where('user_id',$user_id)
                ->where('status',1)
                ->field('id,num,create_time,sub_time,attr_id')
                ->select()
                ->toArray();
            $res = $this->r_foreach($data);
            $this->success('SUCCESS',$res);
        }elseif ($status == 2){
            //已完成的回收订单
            $data = Db::name('subscribe')
                ->where('user_id',$user_id)
                ->where('status',2)
                ->field('id,num,create_time,sub_time,attr_id')
                ->select()
                ->toArray();
            foreach ($data as &$v){
                $arr = Db::name('recyclecomment')
                    ->where('user_id',$user_id)
                    ->where('recycleorder_id',$v['id'])
                    ->find();
                if(empty($arr)){
                    $v['ping'] = 1;
                }else{
                    $v['ping'] = 2;
                }
                $v['attr_id'] = explode(',',$v['attr_id']);
                $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
                foreach ($v['attr_id'] as &$v1){
                    $v1 = Db::name('attr')
                        ->alias('a')
                        ->join('rgoods r','a.rgoods_id=r.id')
                        ->field('r.rgoods_name')
                        ->where('a.id',$v1)
                        ->find();
                }
            }
            $this->success('SUCCESS',$data);
        }
    }

    //封装回收订单循环逻辑
    public function r_foreach($res){
        foreach ($res as &$v){
            $v['attr_id'] = explode(',',$v['attr_id']);
            $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
            foreach ($v['attr_id'] as &$v1){
                $v1 = Db::name('attr')
                    ->alias('a')
                    ->join('rgoods r','a.rgoods_id=r.id')
                    ->field('r.rgoods_name')
                    ->where('a.id',$v1)
                    ->find();
            }
        }
        return $res;
    }

    /**
     * @title 取消回收订单
     * @description 取消回收订单
     * @author Guosheng
     * @url /index/User/cancleorder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id require:1 other desc:订单id
     *
     *
     */
    public function cancleorder(){
        $id = $this->request->param('order_id');
        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $data = Db::name('subscribe')
            ->where('id',$id)
            ->delete();
        if($data){
            $this->success('SUCCESS');
        }else{
            $this->error('sql语句执行失败');
        }
    }

    /**
     * @title 取消商城订单
     * @description 取消商城订单
     * @author Guosheng
     * @url /index/User/cancleshoporder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id require:1 other desc:订单id
     *
     *
     */
    public function cancleshoporder(){
        $user_id = $this->getUserId();
        $id = $this->request->param('order_id');
        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $list = Db::name('shoporder')
            ->where('id',$id)
            ->find();
        $info['total'] = $list['total'];
        $info['type'] = 7;
        $info['create_time'] = time();
        $info['user_id'] = $user_id;
        Db::name('detail')->insertGetId($info);
        $login = Db::name('integral')
            ->where('user_id',$user_id)
            ->find();
        $now_integral = $login['now_integral'] + $list['total'];
        $update_time = time();
        Db::name('integral')->where('user_id',$user_id)->update(['now_integral'=>$now_integral,'update_time'=>$update_time]);
        $data = Db::name('shoporder')
            ->where('id',$id)
            ->delete();
        if($data){
            $this->success('SUCCESS');
        }else{
            $this->error('sql语句执行失败');
        }
    }

    /**
     * @title 取消家政预约订单
     * @description 取消家政预约订单
     * @author Guosheng
     * @url /index/User/canclehomeorder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id require:1 other desc:订单id
     *
     *
     */
    public function canclehomeorder(){
        $user_id = $this->getUserId();
        $id = $this->request->param('order_id');
        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $list = Db::name('subhome')
            ->where('id',$id)
            ->find();
        $info['total'] = $list['total'];
        $info['type'] = 8;
        $info['create_time'] = time();
        $info['user_id'] = $user_id;
        Db::name('detail')->insertGetId($info);
        $login = Db::name('integral')
            ->where('user_id',$user_id)
            ->find();
        $now_integral = $login['now_integral'] + $list['total'];
        $update_time = time();
        Db::name('integral')->where('user_id',$user_id)->update(['now_integral'=>$now_integral,'update_time'=>$update_time]);
        $data = Db::name('subhome')
            ->where('id',$id)
            ->delete();
        if($data){
            $this->success('SUCCESS');
        }else{
            $this->error('sql语句执行失败');
        }
    }

    /**
     * @title 回收订单详情
     * @description
     * @author GuoSheng
     * @url /index/User/orderDetail
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 default:desc:回收订单ID
     *
     * @return status:状态(0已预约,1已接单,2已完成)
     * @return num:订单号
     * @return create_time:下单时间
     * @return sub_time:预约时间
     * @return image:回收物品图片
     * @return content:留言备注
     * @return attr_id:[attr_name:属性名称 rgoods_name:商品名称]
     * @return serve:服务费
     * @return get_integral:获得积分
     *
     */
    public function orderDetail()
    {
        $user_id = $this->getUserId();
        //接收订单ID
        $id = $this->request->param('order_id');

        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $res = Db::name('subscribe')
            ->where('id',$id)
            ->find();
        $data['status'] = $res['status'];
        $data['num'] = $res['num'];
        $data['create_time'] = date('Y-m-d H:i:s',$res['create_time']);
        $recycle_id = Db::name('recycle')->where('id',$res['recycle_id'])->field('address')->find();
        $data['recycle_id'] = $recycle_id['address'];
        $data['attr_id'] = explode(',',$res['attr_id']);
        foreach ($data['attr_id'] as &$v){
            $v = Db::name('attr')
                ->alias('a')
                ->join('rgoods r','a.rgoods_id = r.id')
                ->where('a.id',$v)
                ->field('a.attr_name,r.rgoods_name')
                ->find();
        }
        $data['sub_time'] = $res['sub_time'];
        $data['image'] = explode(',',$res['image']);
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($res['content']));
        $data['get_integral'] = $res['get_integral'];
        $serve = Db::name('recyclefee')->where('id',1)->field('fee')->find();
        $data['serve'] = $serve['fee'];
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 我的商城订单
     * @description 我的商城订单
     * @author Guosheng
     * @url /index/User/shoporder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:status require:1 other desc:订单状态(不传或者为1是 已兑换,2已发货,3已完成)
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return num:购买数量
     * @return total:总价
     *
     */
    public function shoporder()
    {
        $user_id = $this->getUserId();
        $status = $this->request->param('status',0,'intval');
        if(empty($status) || $status == 1){
            //已兑换的商城订单
            $data = Db::name('shoporder')
                ->where('user_id',$user_id)
                ->where('orderstatus',1)
                ->field('id,number,create_time,num,shopgoods_id')
                ->select()
                ->toArray();
            $data = $this->s_foreach($data);
            $this->success('SUCCESS',$data);
        }elseif ($status == 2){
            //已发货的商城订单
            $data = Db::name('shoporder')
                ->where('user_id',$user_id)
                ->where('orderstatus',2)
                ->field('id,number,create_time,num,shopgoods_id')
                ->select()
                ->toArray();
            $data = $this->s_foreach($data);
            $this->success('SUCCESS',$data);
        }elseif ($status == 3){
            //已完成的商城订单
            $data = Db::name('shoporder')
                ->where('user_id',$user_id)
                ->where('orderstatus',3)
                ->field('id,number,create_time,num,shopgoods_id')
                ->select()
                ->toArray();
            foreach ($data as &$v){
                $arr = Db::name('shopcomment')
                    ->where('user_id',$user_id)
                    ->where('shoporder_id',$v['id'])
                    ->find();
                if(empty($arr)){
                    $v['ping'] = 1;
                }else{
                    $v['ping'] = 2;
                }
                $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
                $v['shopgoods_id'] = Db::name('shopgoods')
                    ->where('id',$v['shopgoods_id'])
                    ->field('id as goods_id,goods_name,thumbnail,price')
                    ->find();
            }
            $this->success('SUCCESS',$data);
        }
    }

    //封装商城订单循环逻辑
    public function s_foreach($res){
        foreach ($res as &$v){
            $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
            $v['shopgoods_id'] = Db::name('shopgoods')
                ->where('id',$v['shopgoods_id'])
                ->field('goods_name,thumbnail,price')
                ->find();
        }
        return $res;
    }

    /**
     * @title 商城订单详情
     * @description 商城订单详情
     * @author GuoSheng
     * @url /index/User/sorderDetail
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 default: desc:商城订单ID
     *
     * @return status:状态(0已下单,1已发货,2已完成)
     * @return number:订单号
     * @return create_time:下单时间
     * @return express_num:快递单号
     * @return shoprecycle_id:收货地址
     * @return thumbnail:商品图片
     * @return goods_id:商品ID
     * @return goods_name:商品名称
     * @return content:留言备注
     * @return freight:运费
     * @return total:价格
     * @return num:购买数量
     * @return total_sum:总计
     * @return shopgoods_id:商品信息
     *
     */
    public function sorderDetail()
    {
        $user_id = $this->getUserId();
        //接收商品订单ID
        $id = $this->request->param('order_id');
        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $res = Db::name('shoporder')
            ->where('id',$id)
            ->find();
        $data['status'] = $res['status'];
        $data['number'] = $res['number'];
        $data['create_time'] = date('Y-m-d H:i:s',$res['create_time']);
        $data['express_num'] = $res['express_num'];
        $recycle_id = Db::name('shoprecycle')->where('id',$res['shoprecycle_id'])->field('address')->find();
        $data['shoprecycle_id'] = $recycle_id['address'];
        $shopgoods_id = Db::name('shopgoods')
            ->where('id',$res['shopgoods_id'])
            ->field('id,goods_name,thumbnail,freight,price')
            ->find();
        $data['goods_id'] = $res['shopgoods_id'];
        $data['freight'] = $shopgoods_id['freight'];
        $data['price'] = $shopgoods_id['price'];
        $data['total'] = $res['total'];
        $data['num'] = $res['num'];
        $data['total_sum'] = $data['total'] + $data['freight'];
        $data['thumbnail'] = cmf_get_image_preview_url($shopgoods_id['thumbnail']);
        $data['goods_name'] = $shopgoods_id['goods_name'];
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($res['content']));
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 我的家政预约订单
     * @description 我的家政预约订单
     * @author Guosheng
     * @url /index/User/subhomeorder
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:status require:1 other desc:订单状态(1已预约,2已接单,3已完成)
     *
     * @return id:订单ID
     * @return num:订单号
     * @return home_id:家政公司名称
     * @return service_id:服务项目名称
     * @return price:价格
     * @return sub_time:预约时间
     *
     */
    public function subhomeorder()
    {
        $user_id = $this->getUserId();
        $status = $this->request->param('status',0,'intval');
        if(empty($status) || $status == 1){
            //已预约的回收订单
            $data = Db::name('subhome')
                ->where('user_id',$user_id)
                ->where('status',1)
                ->field('id,num,create_time,sub_time,home_id,service_id')
                ->select()
                ->toArray();
            foreach ($data as &$v){
                $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
                $home = Db::name('home')->where('id',$v['home_id'])->field('home_name')->find();
                $v['home_id'] = $home['home_name'];
                $service = Db::name('service')->where('id',$v['service_id'])->field('sever_name,price')->find();
                $v['service_id'] = $service['sever_name'];
                $v['price'] = $service['price'];
            }
            $this->success('SUCCESS',$data);
        }elseif ($status == 2){
            //已接单的回收订单
            $data = Db::name('subhome')
                ->where('user_id',$user_id)
                ->where('status',2)
                ->field('id,num,create_time,sub_time,home_id,service_id')
                ->select()
                ->toArray();
            foreach ($data as &$v){
                $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
                $home = Db::name('home')->where('id',$v['home_id'])->field('home_name')->find();
                $v['home_id'] = $home['home_name'];
                $service = Db::name('service')->where('id',$v['service_id'])->field('sever_name,price')->find();
                $v['service_id'] = $service['sever_name'];
                $v['price'] = $service['price'];
            }
            $this->success('SUCCESS',$data);
        }elseif ($status == 3){
            //已完成的回收订单
            $data = Db::name('subhome')
                ->where('user_id',$user_id)
                ->where('status',3)
                ->field('id,num,create_time,sub_time,home_id,service_id')
                ->select()
                ->toArray();
            foreach ($data as &$v){
                $arr = Db::name('homecomment')
                    ->where('user_id',$user_id)
                    ->where('order_id',$v['id'])
                    ->find();
                if(empty($arr)){
                    $v['ping'] = 1;
                }else{
                    $v['ping'] = 2;
                }
                $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
                $home = Db::name('home')->where('id',$v['home_id'])->field('home_name')->find();
                $v['home_name'] = $home['home_name'];
                $service = Db::name('service')->where('id',$v['service_id'])->field('sever_name,price')->find();
                $v['service_id'] = $service['sever_name'];
                $v['price'] = $service['price'];
            }
            $this->success('SUCCESS',$data);
        }
    }

    /**
     * @title 家政预约订单详情
     * @description 家政预约订单详情
     * @author GuoSheng
     * @url /index/User/homeOrderDetail
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 default: desc:家政预约订单ID
     *
     * @return status:状态(1已预约,2已接单,3已完成)
     * @return num:订单号
     * @return create_time:下单时间
     * @return sub_time:预约时间
     * @return homeaddress_id:预约地址
     * @return home_id:家政公司名称
     * @return thumbnail:家政公司缩略图
     * @return price:价格
     * @return service_id:服务名称
     * @return content:留言备注
     *
     */
    public function homeOrderDetail()
    {
        $user_id = $this->getUserId();
        //接收订单ID
        $id = $this->request->param('order_id');
        if(empty($id)){
            $this->error(['code'=>41006,'msg'=>'缺少必要参数']);
        }
        $res = Db::name('subhome')
            ->where('id',$id)
            ->find();
        $data['status'] = $res['status'];
        $data['num'] = $res['num'];
        $data['create_time'] = date('Y-m-d H:i:s',$res['create_time']);
        $data['sub_time'] = $res['sub_time'];
        $homeaddress_id = Db::name('homeadress')->where('id',$res['homeaddress_id'])->field('name')->find();
        $data['homeaddress_id'] = $homeaddress_id['name'];
        $home = Db::name('home')->where('id',$res['home_id'])->field('id,home_name,thumbnail')->find();
        $service = Db::name('service')->where('id',$res['service_id'])->field('sever_name,price')->find();
        $data['thumbnail'] = $home['thumbnail'];
        $data['home_id'] = $res['home_id'];
        $data['home_name'] = $home['home_name'];
        $data['service_id'] = $service['sever_name'];
        $data['price'] = $service['price'];
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($res['content']));
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 回收员已预约订单
     * @description 回收员已预约订单
     * @author Guosheng
     * @url /index/User/collect
     * @method POST
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     *
     */
    public function collect()
    {
        $user_id = $this->getUserId();
        $where['status'] = ['eq',0];
        $data = Db::name('subscribe')
            ->where($where)
            ->field('id,num,create_time,sub_time,attr_id')
            ->select()
            ->toArray();
        foreach ($data as &$v){
            $v['goods_name'] = [];
            $attr_id = explode(',',$v['attr_id']);
            foreach ($attr_id as &$v1){
                $v1 = Db::name('attr')
                    ->alias('a')
                    ->join('rgoods r','a.rgoods_id=r.id')
                    ->field('r.rgoods_name')
                    ->where('a.id',$v1)
                    ->find();
                array_push($v['goods_name'],$v1['rgoods_name']);
            }
            $v['goods_name'] = implode(',',$v['goods_name']);
        }
        $this->success('success',$data);
    }

    /**
     * @title 回收员已接单订单
     * @description 回收员已接单订单
     * @author Guosheng
     * @url /index/User/jie
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     *
     */
    public function jie()
    {
        $user_id = $this->getUserId();
        $list = Db::name('collector')
            ->where('user_id',$user_id)
            ->where('status',1)
            ->column('order_id');
        foreach ($list as &$val){
            $val = Db::name('subscribe')
                ->where('id',$val)
                ->field('id,num,create_time,sub_time,attr_id')
                ->find();
            $val['create_time'] = date('Y-m-d H:i:s',$val['create_time']);
            $val['attr_id'] = explode(',',$val['attr_id']);
            $val['goods_name'] = [];
            foreach ($val['attr_id'] as &$v){
                $v1 = Db::name('attr')
                    ->alias('a')
                    ->join('rgoods r','a.rgoods_id=r.id')
                    ->field('r.rgoods_name')
                    ->where('a.id',$v)
                    ->find();
                array_push($val['goods_name'],$v1['rgoods_name']);

            }
            $val['goods_name'] = implode(',',$val['goods_name']);
        }
        $this->success('success',$list);


    }

    /**
     * @title 回收员已完成订单
     * @description 回收员已完成订单
     * @author Guosheng
     * @url /index/User/finish
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     *
     */
    public function finish()
    {
        $user_id = $this->getUserId();
        $list = Db::name('collector')
            ->where('user_id',$user_id)
            ->where('status',2)
            ->column('order_id');
        foreach ($list as &$val){
            $val = Db::name('subscribe')
                ->where('id',$val)
                ->field('id,num,create_time,sub_time,attr_id,get_integral')
                ->find();
            $val['create_time'] = date('Y-m-d H:i:s',$val['create_time']);
            $val['attr_id'] = explode(',',$val['attr_id']);
            $val['goods_name'] = [];
            foreach ($val['attr_id'] as &$v){
                $v1 = Db::name('attr')
                    ->alias('a')
                    ->join('rgoods r','a.rgoods_id=r.id')
                    ->field('r.rgoods_name')
                    ->where('a.id',$v)
                    ->find();
                array_push($val['goods_name'],$v1['rgoods_name']);

            }
            $val['goods_name'] = implode(',',$val['goods_name']);
        }
        $this->success('success',$list);


    }

    /**
     * @title 回收员确认接单
     * @description 回收员确认接单
     * @author Guosheng
     * @url /index/User/affirm
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 other: desc:订单ID
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     *
     */
    public function affirm()
    {
        $user_id = $this->getUserId();
        $order_id = $this->request->param('order_id');
        if(empty($order_id)){
            $this->error('缺少必要参数');
        }
        $data['order_id'] = $order_id;
        $data['user_id'] = $user_id;
        $data['create_time'] = time();
        Db::name('subscribe')
            ->where('id',$order_id)
            ->update(['status'=>1]);
        $res = Db::name('collector')
            ->insertGetId($data);
        if($res){
            $this->success('接单成功');
        }else{
            $this->error('sql语句错误');
        }
    }

    /**
     * @title 回收员确认完成
     * @description 回收员确认完成
     * @author Guosheng
     * @url /index/User/aff_finish
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 other: desc:订单ID
     * @param name:get_integral type:int require:1 other: desc:获得积分
     *
     * @return id:订单ID
     * @return num:订单号
     * @return goods_name:商品名称
     * @return create_time:创建时间
     * @return sub_time:预约时间
     *
     */
    public function aff_finish()
    {
        $user_id = $this->getUserId();
        $order_id = $this->request->param('order_id');
        $get_integral = $this->request->param('get_integral');
        if(empty($order_id)){
            $this->error('缺少必要参数');
        }
        //对应的数据加入回收员已完成订单中
        $data['order_id'] = $order_id;
        $data['user_id'] = $user_id;
        $data['create_time'] = time();
        $data['status'] = 2;

        //查询我的积分信息
        $info = Db::name('integral')
            ->where('user_id',$user_id)
            ->find();
        $res['num'] = $info['num'] + 1;
        $res['add_total'] = $info['add_total'] + $get_integral;
        $res['now_integral'] = $info['now_integral'] + $get_integral;

        //添加对应的积分明细
        $detail['user_id'] = $user_id;
        $detail['total'] = $get_integral;
        $detail['create_time'] = time();
        $detail['type'] = 5;

        // 启动事务
        Db::startTrans();
        try{
            $result = Db::name('subscribe')
                ->where('id',$order_id)
                ->update(['status'=>2,'get_integral'=>$get_integral]);
            $integral = Db::name('integral')
                ->where('user_id',$user_id)
                ->update($res);
            $detail = Db::name('detail')->insertGetId($detail);

            //对应的数据加入回收员已完成订单中
            $collector = Db::name('collector')
                ->insertGetId($data);
            if($result && $integral && $detail && $collector){
                // 提交事务
                Db::commit();
                true;
            }
        } catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
        }
        $this->success('成功');
    }

    /**
     * @title 有奖分享(二维码)
     * @description 有奖分享(二维码)
     * @author Guosheng
     * @url /index/User/code
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:route type:string require:1 other: desc:页面路径与参数
     *
     */
    public function code()
    {
        $user_id = $this->getUserId();
        $url = $this->request->param('route');
        if(empty($url)){
            $this->error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $savePath = './../upload/poster/';
        if (!file_exists($savePath)){
            mkdir($savePath, 0777,true);
        }
        if(!file_exists("./upload/qrcode/code_$user_id.jpg")){
            $code = $this->getusercode($user_id,$url);
        }else{
            $code = "qrcode/code_$user_id.jpg";
        }
        $data = 'http://scrap.w.bronet.cn/upload/'.$code;
        $this->success('SUCCESS',$data);
    }

    //判断当前操作系统
    public function getOperateSys(){
        $os_name = php_uname('s');
        //判断
        if(strpos($os_name,"Linux")!==false){
            $os_str="Linux";
        }else if(strpos($os_name,"Windows")!==false){
            $os_str="Windows";
        }else{
            $os_str='';
        }
        return $os_str;
    }

    public function getusercode($user_id,$url){
        $savePath = './../upload/get_code/';
        $filename = "code_$user_id.jpg";
        if(!file_exists($savePath.$filename)){
            $access_token = $this->get_access_token();
            $qrcode = $this->imgShare($user_id,$access_token,$url);
        }elsE{
            $qrcode = "qrcode/code_".$user_id.".jpg";
        }
        return $qrcode;
    }

    public function imgShare($user_id,$access_token,$path){
        $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=".$access_token;
        $post['path'] = $path;
        $post['width'] = 280;
        $result = $this->curl($url, json_encode($post));
        $array = json_decode($result, true);
        if($array['errmsg']) {
            return false;
        }
        // 分享二维码保存到用户数据
        if (!file_exists(ROOT_PATH . 'public' . DS . 'upload/qrcode/')) {
            mkdir(ROOT_PATH . 'public' . DS . 'upload/qrcode/', 0777, true);
        }
        $filename = "code_".$user_id.".jpg";
        $furl = ROOT_PATH . 'public' . DS . 'upload/qrcode/'.$filename;
        file_put_contents($furl, $result);
        return "qrcode/".$filename;
    }
    // curl方法
    protected function curl($url, $post = null, $header = null) {
        // 初始化
        $curl = curl_init();
        // 设置抓取的url
        curl_setopt($curl, CURLOPT_URL, $url);
        // 请求头
        if($header) {
            curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
        }
        // 设置头文件的信息作为数据流输出
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_NOBODY, 0);
        curl_setopt($curl, CURLOPT_TIMEOUT, 500);
        // 设置获取的信息以文件流的形式返回,而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if($post) {
            curl_setopt($curl, CURLOPT_POST, 1);
            //把POST的变量加上
            curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
        }
        // 执行命令
        $data = curl_exec($curl);
        if (curl_errno($curl)) {
            $data = curl_error($curl);
        }
        return $data;
    }
    //获取access_token
    public function get_access_token()
    {
        $app_id = config('app_id');
        $app_secret = config('app_secret');
        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$app_id.'&secret='.$app_secret;
        $res = $this->http_get($url);
        $json_arr = json_decode($res,true);
        $token = $json_arr['access_token'];
        return $token;
    }
    //curl  get请求
    public function http_get($url){
        $curl = curl_init();//启动一个CURL会话
        curl_setopt($curl, CURLOPT_URL,$url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
        curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
        curl_setopt($curl, CURLOPT_HEADER, false);//不开启header
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
        $result = curl_exec($curl); //执行操作
        curl_close($curl);
        return $result;
    }
    //curl post请求
    public function http_post($url,$data){
        $curl = curl_init();//启动一个CURL会话
        curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
        curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); // Post提交的数据包
        curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
        curl_setopt($curl, CURLOPT_HEADER, false); // 开启header
        //curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);//请求头部
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
        $result = curl_exec($curl); //执行操作
        curl_close($curl);
        return $result;
    }

    /**
     * @title 添加回收订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/comment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:recycleorder_id type:int require:1 other: desc:订单id
     * @param name:speed type:int require:1 other: desc:上门速度
     * @param name:service type:int require:1 other: desc:服务态度
     * @param name:recycle type:int require:1 other: desc:回收体验
     * @param name:content type:string require:1 other: desc:评价内容
     * @param name:thumbnail type:string require:1 other: desc:图片
     *
     */
    public function comment()
    {
        $user_id = $this->getUserId();
        $param = $this->request->param();
        $param['user_id'] = $user_id;
        $param['create_time'] = time();
        $validate = new Validate([
            'recycleorder_id' => 'require',
            'speed' => 'require',
            'service'=>'require',
            'recycle'=>'require',
            'content'=>'require'
        ]);
        $validate->message([
            'recycle_id'=>'订单ID不能为空',
            'speed'=>'上门速度不能为空',
            'service'=>'服务态度不能为空',
            'recycle'=>'回收体验不能为空',
            'content'=>'评价不能为空'
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
        $data = Db::name('recyclecomment')
            ->insert($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');

    }

    /**
     * @title 添加商城订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/shopcomment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:shoporder_id type:int require:1 other: desc:订单id
     * @param name:shopgood_id type:int require:1 other: desc:商品ID
     * @param name:speed type:int require:1 other: desc:上门速度
     * @param name:service type:int require:1 other: desc:服务态度
     * @param name:recycle type:int require:1 other: desc:回收体验
     * @param name:content type:string require:1 other: desc:评价内容
     * @param name:thumbnail type:string require:1 other: desc:图片
     *
     */
    public function shopcomment()
    {
        $user_id = $this->getUserId();
        $param = $this->request->param();
        $param['user_id'] = $user_id;
        $param['create_time'] = time();
        $validate = new Validate([
            'shoporder_id' => 'require',
            'shopgood_id'=>'require',
            'speed' => 'require',
            'service'=>'require',
            'recycle'=>'require',
            'content'=>'require'
        ]);
        $validate->message([
            'shoporder_id'=>'订单ID不能为空',
            'shopgood_id'=>'商品ID不能为空',
            'speed'=>'上门速度不能为空',
            'service'=>'服务态度不能为空',
            'recycle'=>'回收体验不能为空',
            'content'=>'评价不能为空'
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
        $data = Db::name('shopcomment')
            ->insert($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');

    }

    /**
     * @title 添加家政预约订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/homecomment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 other: desc:订单ID
     * @param name:home_id type:int require:1 other: desc:家政公司ID
     * @param name:speed type:int require:1 other: desc:服务质量
     * @param name:service type:int require:1 other: desc:服务态度
     * @param name:recycle type:int require:1 other: desc:服务体验
     * @param name:content type:string require:1 other: desc:评价内容
     * @param name:thumbnail type:string require:1 other: desc:图片
     *
     */
    public function homecomment()
    {
        $user_id = $this->getUserId();
        $param = $this->request->param();
        $param['user_id'] = $user_id;
        $param['create_time'] = time();
        $validate = new Validate([
            'order_id' => 'require',
            'home_id'=>'require',
            'speed' => 'require',
            'service'=>'require',
            'recycle'=>'require',
            'content'=>'require'
        ]);
        $validate->message([
            'order_id'=>'订单ID不能为空',
            'home_id'=>'家政公司ID不能为空',
            'speed'=>'服务质量不能为空',
            'service'=>'服务态度不能为空',
            'recycle'=>'服务体验不能为空',
            'content'=>'评价不能为空'
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
        $data = Db::name('homecomment')
            ->insert($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');

    }


    /**
     * @title 查看回收订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/selectcomment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:recycleorder_id type:int require:1 other: desc:订单id
     *
     * @return speed:上门速度
     * @return service:服务态度
     * @return recycle:回收体验
     * @return content:评价内容
     * @return thumbnail:图片
     *
     */
    public function selectcomment()
    {
        $user_id = $this->getUserId();
        $recycleorder_id = $this->request->param('recycleorder_id');
        if(empty($recycleorder_id)){
            $this->error(['code'=>2,'msg'=>'缺少必要参数']);
        }
        $data = Db::name('recyclecomment')
            ->where('recycleorder_id',$recycleorder_id)
            ->find();
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
        $data['thumbnail'] = explode(',',$data['thumbnail']);
        $this->success('SUCCESS',$data);

    }

    /**
     * @title 查看商城订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/selshopcomment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:shoporder_id type:int require:1 other: desc:订单id
     *
     * @return speed:上门速度
     * @return service:服务态度
     * @return recycle:回收体验
     * @return content:评价内容
     * @return thumbnail:图片
     *
     */
    public function selshopcomment()
    {
        $user_id = $this->getUserId();
        $shoporder_id = $this->request->param('shoporder_id');
        if(empty($shoporder_id)){
            $this->error(['code'=>2,'msg'=>'缺少必要参数']);
        }

        $data = Db::name('shopcomment')
            ->where('user_id',$user_id)
            ->where('shoporder_id',$shoporder_id)
            ->find();
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
        $data['thumbnail'] = explode(',',$data['thumbnail']);
        $this->success('SUCCESS',$data);

    }

    /**
     * @title 查看家政预约订单评价
     * @description
     * @author GuoSheng
     * @url /index/User/selhomecomment
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:order_id type:int require:1 other: desc:订单ID
     *
     * @return speed:服务质量
     * @return service:服务态度
     * @return recycle:服务体验
     * @return content:评价内容
     * @return thumbnail:图片
     *
     */
    public function selhomecomment()
    {
        $user_id = $this->getUserId();
        $num = $this->request->param('order_id');
        if(empty($num)){
            $this->error(['code'=>2,'msg'=>'缺少必要参数']);
        }
        $data = Db::name('homecomment')
            ->where('user_id',$user_id)
            ->where('order_id',$num)
            ->find();
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
        $data['thumbnail'] = explode(',',$data['thumbnail']);
        $this->success('SUCCESS',$data);

    }


}