WIN-2308041133\Administrator 3 days ago
parent
commit
ef4cb940d8
2 changed files with 264 additions and 256 deletions
  1. 8 4
      app/api/controller/User.php
  2. 256 252
      app/system/controller/Contract.php

+ 8 - 4
app/api/controller/User.php

@@ -1150,8 +1150,6 @@ class User extends BaseController
         $uid = UtilService::getMore([
             ['uid', 0],
         ], $request);
-//        $uid= $request->user["uid"];
-//        var_dump($uid);die();
         $uid=$uid['uid'];
 //        if ($uid>0){
 //            $where[]=["uid","=",$uid];
@@ -1365,7 +1363,10 @@ class User extends BaseController
             ['latitude',''],  //纬度
 //            ['uid',0]
         ],$request);
-        $uid = $request->user["uid"];
+        $uid = UtilService::getMore([
+            ['uid', 0],
+        ], $request);
+        $uid=$uid['uid'];
 //        $uid = (int)$post["uid"];
         // 检查签约时间是否为空
         if (empty($post['contract_id'])) {
@@ -1397,7 +1398,10 @@ class User extends BaseController
             ['content',''],  //评论内容
             ['uid',0]
         ],$request);
-        $uid = $request->user["uid"];
+        $uid = UtilService::getMore([
+            ['uid', 0],
+        ], $request);
+        $uid=$uid['uid'];
 //        $uid = $post['uid'];
         $time=time();
         $info = (new UserContractRecordModel)->where("id",$post["contract_id"])->where('start_time','>',$time)->where('end_time','<',$time)->find();

+ 256 - 252
app/system/controller/Contract.php

@@ -377,265 +377,269 @@ class Contract extends BaseController
 
 
 
-
-    /**
-     * 合约列表
-     * @param \app\Request $request
-     * @return mixed
-     */
-    public function getContractList(\think\Request $request)
-    {
-//        $pageSize = 50;
-//        $post =  UtilService::getMore([
-//            ['page',1],
-//            ['pageSize',50],
-//            ['nickname',''],
-////            ['uid',''],
-//            ['parent_uid',''],
-//            ['mobile',''],
-//            ['status',''],
-//            ['time',[]],
+//
+//    /**
+//     * 合约列表
+//     * @param \app\Request $request
+//     * @return mixed
+//     */
+//    public function getContractList(\think\Request $request)
+//    {
+////        $pageSize = 50;
+////        $post =  UtilService::getMore([
+////            ['page',1],
+////            ['pageSize',50],
+////            ['nickname',''],
+//////            ['uid',''],
+////            ['parent_uid',''],
+////            ['mobile',''],
+////            ['status',''],
+////            ['time',[]],
+////        ],$request);
+//////        $post['uid']=$request->user["uid"];
+////        $data = (new UserModel)->getDataList($post,"*",1);
+////        return app('json')->success([
+////            'list'      => $data["list"],
+////            'pageCount' => $data["totalCount"],
+////            'pageSize'  => $data["pageSize"],
+////            'page'      => $data["page"],
+////        ]);
+//        $post = UtilService::getMore([
+//            ['page', 1],
+//            ['pageSize', 50],
+//            ['status',-2] //1未签约 2已签约 3已解约
+//        ], $request);
+//        $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
+//        $post["page"]     = $post["page"]<=0 ? 1 : (int)$post["page"];
+//        $where=[];
+//        $uid = UtilService::getMore([
+//            ['uid', 0],
+//        ], $request);
+//        $uid=$uid['uid'];
+//        $where[]=["uid","=",$uid];
+//        $totalCount = (new UserContractRecordModel)->where($where)->count();
+//        if ($post["status"]!=-2){
+//            $where[]=['status','=',$post["status"]];
+//        }
+//        $data=null;
+//        if($totalCount>0){
+//            $data = (new UserContractRecordModel)
+////                ->field("")
+////                ->alias("ut")
+////                ->join("show_template t", "t.id = show_template_id","left")
+//                ->where($where)
+//                ->order("is_default", "desc")
+//                ->order("id", "desc")
+//                ->page($post["page"], $post["pageSize"])
+//                ->select();
+//            foreach($data as $k=>$v){
+//                $data[$k]["is_use"]      = 1;//是否已经购买或者可以使用
+//                switch ($data[$k]["status"]){
+//                    case 0:
+//                        $data[$k]["status_name"] = "未签约";
+//                        break;
+//                    case 1:
+//                        $data[$k]["status_name"] = "已签约";
+//                        break;
+//                    case -1:
+//                        $data[$k]["status_name"] = "已解约";
+//                        break;
+//                }
+//            }
+//        }
+//        $data = empty($data)?[]:$data;
+//        return app('json')->success(["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount]);
+//    }
+//
+//    /**
+//     * 甲方创建合约
+//     */
+//    public function form_save(Request $request){
+//        $post = UtilService::getMore([
+//            ['uid','0'],  //甲方uid
+//            ['phone',''],  //甲方手机号
+//            ['address',''], //甲方地址
+//            ['card',''], //甲方身份证号
+//            ['to_uid','0'], //员工uid
+//            ['price',0],  //服务费
+//            ['deposit',0], // 定金
+//            ['balance',0], //余款
+//            ['period',0], // 周期天数
+//            ['start_time',''], // 开始时间
+//            ['end_time',''], // 结束时间
+//
+////            ['uid_img','']  //甲方签名图片路径
+////            ['to_phone',''].
+////            ['to_address',''],
+////            ['to_card',''],
+////            ['data',[]],
+////            ['year',''],
+////            ['month',''],
+////            ['day',''],
+//
 //        ],$request);
-////        $post['uid']=$request->user["uid"];
-//        $data = (new UserModel)->getDataList($post,"*",1);
-//        return app('json')->success([
-//            'list'      => $data["list"],
-//            'pageCount' => $data["totalCount"],
-//            'pageSize'  => $data["pageSize"],
-//            'page'      => $data["page"],
-//        ]);
-        $post = UtilService::getMore([
-            ['page', 1],
-            ['pageSize', 50],
-            ['status',-2] //1未签约 2已签约 3已解约
-        ], $request);
-        $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
-        $post["page"]     = $post["page"]<=0 ? 1 : (int)$post["page"];
-        $where=[];
-        $where[]=["uid","=",$request->user["uid"]];
-        $totalCount = (new UserContractRecordModel)->where($where)->count();
-        if ($post["status"]!=-2){
-            $where[]=['status','=',$post["status"]];
-        }
-        $data=null;
-        if($totalCount>0){
-            $data = (new UserContractRecordModel)
-//                ->field("")
-//                ->alias("ut")
-//                ->join("show_template t", "t.id = show_template_id","left")
-                ->where($where)
-                ->order("is_default", "desc")
-                ->order("id", "desc")
-                ->page($post["page"], $post["pageSize"])
-                ->select();
-            foreach($data as $k=>$v){
-                $data[$k]["is_use"]      = 1;//是否已经购买或者可以使用
-                switch ($data[$k]["status"]){
-                    case 0:
-                        $data[$k]["status_name"] = "未签约";
-                        break;
-                    case 1:
-                        $data[$k]["status_name"] = "已签约";
-                        break;
-                    case -1:
-                        $data[$k]["status_name"] = "已解约";
-                        break;
-                }
-            }
-        }
-        $data = empty($data)?[]:$data;
-        return app('json')->success(["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount]);
-    }
-
-    /**
-     * 甲方创建合约
-     */
-    public function form_save(Request $request){
-        $post = UtilService::getMore([
-            ['uid','0'],  //甲方uid
-            ['phone',''],  //甲方手机号
-            ['address',''], //甲方地址
-            ['card',''], //甲方身份证号
-            ['to_uid','0'], //员工uid
-            ['price',0],  //服务费
-            ['deposit',0], // 定金
-            ['balance',0], //余款
-            ['period',0], // 周期天数
-            ['start_time',''], // 开始时间
-            ['end_time',''], // 结束时间
-
-//            ['uid_img','']  //甲方签名图片路径
-//            ['to_phone',''].
-//            ['to_address',''],
-//            ['to_card',''],
-//            ['data',[]],
-//            ['year',''],
-//            ['month',''],
-//            ['day',''],
-
-        ],$request);
-        $id = (int)$post["id"];
-
-        $uid = (int)$post["uid"];
-        if(empty($uid)){
-            return app('json')->fail("参数错误");
-        }
-//        $year = $post['year'];
-//        $month = $post['month'];
-//        $day = $post['day'];
+//        $id = (int)$post["id"];
+//
+//        $uid = (int)$post["uid"];
+//        if(empty($uid)){
+//            return app('json')->fail("参数错误");
+//        }
+////        $year = $post['year'];
+////        $month = $post['month'];
+////        $day = $post['day'];
+////
+////// 检查年月日是否为空
+////        if (empty($year) || empty($month) || empty($day)) {
+////            return app('json')->fail("日期参数错误");
+////        }
+////
+////// 创建 DateTime 对象
+////        $date = \DateTime::createFromFormat('Y-m-d', "$year-$month-$day");
+////
+////// 检查日期是否有效
+////        if (!$date || $date->format('Y-m-d') !== "$year-$month-$day") {
+////            return app('json')->fail("无效的日期");
+////        }
+////        unset($post['year']);
+////        unset($post['month']);
+////        unset($post['day']);
+////// 转换为时间戳
+////        $timestamp = $date->getTimestamp();
+////
+////        $post['create_time'] = $timestamp;
+//        //用户信息
+////        if(!empty($post["uid_img"])){
+////            $post['status'] = 2;
+////        }else{
+//        $post['status'] = 0;
+////        }
+//        if (empty($id)){
+//            $post['contract_no'] = makeOrderId($post['uid'],"CR");
+//            $r = (new UserContractRecordModel)->save($post);
+//        }else{
+//            $r = (new UserContractRecordModel)->where("id",$id)->update($post);
+//        }
+//
+//        return app('json')->success("数据保存成功");
+//    }
+//    /**
+//     * 甲方签约合约
+//     */
+//    public function check(Request $request){
+//        $post = UtilService::getMore([
+//            ['id',0],  //合约id
+//            ['uid_img',''],  //甲方签名图片路径
+//            ['check_time','']//签约时间
+////            ['to_phone',''].
+////            ['to_address',''],
+////            ['to_card',''],
+////            ['data',[]],
+////            ['year',''],
+////            ['month',''],
+////            ['day',''],
 //
-//// 检查年月日是否为空
-//        if (empty($year) || empty($month) || empty($day)) {
+//        ],$request);
+//        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
+//        if(empty($info)){
+//            return app('json')->fail("合约不存在");
+//        }
+//
+//        // 检查签约时间是否为空
+//        if (empty($post['uid_img'])) {
+//            return app('json')->fail("签字错误");
+//        }
+//// 检查签约时间是否为空
+//        if (empty($post['check_time'])) {
 //            return app('json')->fail("日期参数错误");
 //        }
 //
-//// 创建 DateTime 对象
-//        $date = \DateTime::createFromFormat('Y-m-d', "$year-$month-$day");
+////        $post['status'] = 1;
+//        $post['from_check'] = 1;
+//        if ($info['to_check']==1){
+//            $post['status']==1;
+//        }
 //
-//// 检查日期是否有效
-//        if (!$date || $date->format('Y-m-d') !== "$year-$month-$day") {
-//            return app('json')->fail("无效的日期");
+////        $post['contract_no'] = makeOrderId($post['uid'],"CR");
+//        $r = (new UserContractRecordModel)->where("id",$post["id"])->update($post);
+//        return app('json')->success("数据保存成功");
+//    }
+////    乙方确认
+//    public function to_check(Request $request){
+//        $post = UtilService::getMore([
+//            ['id','0'],  //
+//            ['to_uid_img',''],  //乙方签名图片路径
+//            ['to_phone',''], //乙方手机号
+//            ['to_address',''], //乙方地址
+//            ['to_card',''], //乙方身份证号
+//            ['to_check_time','']//签约时间
+//        ],$request);
+//        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
+//        if(empty($info)){
+//            return app('json')->fail("合约不存在");
+//        }
+//        // 检查签约时间是否为空
+//        if (empty($post['to_uid_img'])) {
+//            return app('json')->fail("签字错误");
+//        }
+//// 检查签约时间是否为空
+//        if (empty($post['to_check_time'])) {
+//            return app('json')->fail("日期参数错误");
 //        }
-//        unset($post['year']);
-//        unset($post['month']);
-//        unset($post['day']);
-//// 转换为时间戳
-//        $timestamp = $date->getTimestamp();
+//        $post['to_check'] = 1;
+//        if ($info['from_check']==1){
+//            $post['status']==1;
+//        }
+//        $r = (new UserContractRecordModel)->where("id",$post["id"])->update($post);
+//        return app('json')->success("数据保存成功");
+//    }
+////    员工签到
+//    public function clock_in(Request $request){
+//        $post = UtilService::getMore([
+//            ['id','0'],  //合约id
+//            ['longitude',''],  //经度
+//            ['latitude',''],  //纬度
 //
-//        $post['create_time'] = $timestamp;
-        //用户信息
-//        if(!empty($post["uid_img"])){
-//            $post['status'] = 2;
-//        }else{
-        $post['status'] = 0;
+//        ],$request);
+//        $uid = (int)$post["uid"];
+//        // 检查签约时间是否为空
+//        if (empty($post['id'])) {
+//            return app('json')->fail("签字错误");
 //        }
-        if (empty($id)){
-            $post['contract_no'] = makeOrderId($post['uid'],"CR");
-            $r = (new UserContractRecordModel)->save($post);
-        }else{
-            $r = (new UserContractRecordModel)->where("id",$id)->update($post);
-        }
-
-        return app('json')->success("数据保存成功");
-    }
-    /**
-     * 甲方签约合约
-     */
-    public function check(Request $request){
-        $post = UtilService::getMore([
-            ['id',0],  //合约id
-            ['uid_img',''],  //甲方签名图片路径
-            ['check_time','']//签约时间
-//            ['to_phone',''].
-//            ['to_address',''],
-//            ['to_card',''],
-//            ['data',[]],
-//            ['year',''],
-//            ['month',''],
-//            ['day',''],
-
-        ],$request);
-        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
-        if(empty($info)){
-            return app('json')->fail("合约不存在");
-        }
-
-        // 检查签约时间是否为空
-        if (empty($post['uid_img'])) {
-            return app('json')->fail("签字错误");
-        }
-// 检查签约时间是否为空
-        if (empty($post['check_time'])) {
-            return app('json')->fail("日期参数错误");
-        }
-
-//        $post['status'] = 1;
-        $post['from_check'] = 1;
-        if ($info['to_check']==1){
-            $post['status']==1;
-        }
-
-//        $post['contract_no'] = makeOrderId($post['uid'],"CR");
-        $r = (new UserContractRecordModel)->where("id",$post["id"])->update($post);
-        return app('json')->success("数据保存成功");
-    }
-//    乙方确认
-    public function to_check(Request $request){
-        $post = UtilService::getMore([
-            ['id','0'],  //
-            ['to_uid_img',''],  //乙方签名图片路径
-            ['to_phone',''], //乙方手机号
-            ['to_address',''], //乙方地址
-            ['to_card',''], //乙方身份证号
-            ['to_check_time','']//签约时间
-        ],$request);
-        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
-        if(empty($info)){
-            return app('json')->fail("合约不存在");
-        }
-        // 检查签约时间是否为空
-        if (empty($post['to_uid_img'])) {
-            return app('json')->fail("签字错误");
-        }
-// 检查签约时间是否为空
-        if (empty($post['to_check_time'])) {
-            return app('json')->fail("日期参数错误");
-        }
-        $post['to_check'] = 1;
-        if ($info['from_check']==1){
-            $post['status']==1;
-        }
-        $r = (new UserContractRecordModel)->where("id",$post["id"])->update($post);
-        return app('json')->success("数据保存成功");
-    }
-//    员工签到
-    public function clock_in(Request $request){
-        $post = UtilService::getMore([
-            ['id','0'],  //合约id
-            ['longitude',''],  //经度
-            ['latitude',''],  //纬度
-
-        ],$request);
-        $uid = (int)$post["uid"];
-        // 检查签约时间是否为空
-        if (empty($post['id'])) {
-            return app('json')->fail("签字错误");
-        }
-        $nickname=\app\model\api\User::where('uid',$uid)->value('nickname');
-        $r = (new UserContractRecordModel)->where("id",$post["id"])->save([
-            'uid'=>$uid,
-            'nickname' => $nickname,
-            'longitude'=>$post['longitude'],
-            'latitude'=>$post['latitude'],
-            'contract_id'=>$post['id'],
-            'create_time'=>time()
-        ]);
-        return app('json')->success("数据保存成功");
-    }
-//  添加客户评论
-    public function comment(Request $request){
-        $post = UtilService::getMore([
-            ['id','0'],  //合约id
-            ['content',''],  //评论内容
-        ],$request);
-        $uid = (int)$post["uid"];
-        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
-        if(empty($info)){
-            return app('json')->fail("合约不存在");
-        }
-        if ($info['status']!=1){
-            return app('json')->fail("只能在签约期间才能发表评论");
-        }
-        // 检查签约时间是否为空
-        if (empty($post['id'])) {
-            return app('json')->fail("签字错误");
-        }
-        $r = (new ContractCommentModel)->save([
-            'uid'=>$uid,
-            'contract_id'=>$post['id'],
-            'content'=>$post['content'],
-            'create_time'=>time()
-        ]);
-        return app('json')->success("数据保存成功");
-    }
+//        $nickname=\app\model\api\User::where('uid',$uid)->value('nickname');
+//        $r = (new UserContractRecordModel)->where("id",$post["id"])->save([
+//            'uid'=>$uid,
+//            'nickname' => $nickname,
+//            'longitude'=>$post['longitude'],
+//            'latitude'=>$post['latitude'],
+//            'contract_id'=>$post['id'],
+//            'create_time'=>time()
+//        ]);
+//        return app('json')->success("数据保存成功");
+//    }
+////  添加客户评论
+//    public function comment(Request $request){
+//        $post = UtilService::getMore([
+//            ['id','0'],  //合约id
+//            ['content',''],  //评论内容
+//        ],$request);
+//        $uid = (int)$post["uid"];
+//        $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
+//        if(empty($info)){
+//            return app('json')->fail("合约不存在");
+//        }
+//        if ($info['status']!=1){
+//            return app('json')->fail("只能在签约期间才能发表评论");
+//        }
+//        // 检查签约时间是否为空
+//        if (empty($post['id'])) {
+//            return app('json')->fail("签字错误");
+//        }
+//        $r = (new ContractCommentModel)->save([
+//            'uid'=>$uid,
+//            'contract_id'=>$post['id'],
+//            'content'=>$post['content'],
+//            'create_time'=>time()
+//        ]);
+//        return app('json')->success("数据保存成功");
+//    }
 }