|
|
@@ -17,6 +17,7 @@ use app\BaseController;
|
|
|
use app\model\api\ContractComment as ContractCommentModel;
|
|
|
use app\model\api\ContractRecord as UserContractRecordModel;
|
|
|
use app\model\api\User as UserModel;
|
|
|
+use app\model\api\UserClock as UserClockModel;
|
|
|
use app\model\api\UserDetail as UserDetailModel;
|
|
|
use app\model\api\ServiceType as ServiceTypeModel;
|
|
|
use app\model\api\InfoAudit;
|
|
|
@@ -1193,6 +1194,7 @@ class User extends BaseController
|
|
|
$post = UtilService::getMore([
|
|
|
['id',0],
|
|
|
['uid','0'], //甲方uid
|
|
|
+ ['name',''], //甲方姓名
|
|
|
['phone',''], //甲方手机号
|
|
|
['address',''], //甲方地址
|
|
|
['card',''], //甲方身份证号
|
|
|
@@ -1222,8 +1224,11 @@ class User extends BaseController
|
|
|
}
|
|
|
$post['start_time'] = strtotime($post['start_time']);
|
|
|
$post['end_time'] = strtotime($post['end_time']);
|
|
|
- $start=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('start_time','<',$post['end_time'])->find();
|
|
|
- $end=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('end_time','>',$post['start_time'])->find();
|
|
|
+ $start=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('status',1)->whereBetween('start_time',[$post['start_time'],$post['end_time']])->find();
|
|
|
+ $end=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('status',1)->whereBetween('end_time',[$post['start_time'],$post['end_time']])->find();
|
|
|
+// $start2=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('status',0)->whereBetween('start_time',[$post['start_time'],$post['end_time']])->find();
|
|
|
+// $end2=(new UserContractRecordModel)->where('to_uid',$post['to_uid'])->where('status',0)->whereBetween('end_time',[$post['start_time'],$post['end_time']])->find();
|
|
|
+// if (!empty($start)||!empty($end)||!empty($start2)||!empty($end2)){
|
|
|
if (!empty($start)||!empty($end)){
|
|
|
return app('json')->fail("与对方其他合约时间有冲突,请与对方协商");
|
|
|
}
|
|
|
@@ -1295,11 +1300,12 @@ class User extends BaseController
|
|
|
if (empty($post['check_time'])) {
|
|
|
return app('json')->fail("日期参数错误");
|
|
|
}
|
|
|
+ $post['check_time'] = strtotime($post['check_time']);
|
|
|
|
|
|
// $post['status'] = 1;
|
|
|
$post['from_check'] = 1;
|
|
|
if ($info['to_check']==1){
|
|
|
- $post['status']==1;
|
|
|
+ $post['status']=1;
|
|
|
}
|
|
|
|
|
|
// $post['contract_no'] = makeOrderId($post['uid'],"CR");
|
|
|
@@ -1328,9 +1334,10 @@ class User extends BaseController
|
|
|
if (empty($post['to_check_time'])) {
|
|
|
return app('json')->fail("日期参数错误");
|
|
|
}
|
|
|
+ $post['to_check_time'] = strtotime($post['to_check_time']);
|
|
|
$post['to_check'] = 1;
|
|
|
if ($info['from_check']==1){
|
|
|
- $post['status']==1;
|
|
|
+ $post['status']=1;
|
|
|
}
|
|
|
$r = (new UserContractRecordModel)->where("id",$post["id"])->update($post);
|
|
|
return app('json')->success("数据保存成功");
|
|
|
@@ -1338,23 +1345,24 @@ class User extends BaseController
|
|
|
// 员工签到
|
|
|
public function clock_in(Request $request){
|
|
|
$post = UtilService::getMore([
|
|
|
- ['id','0'], //合约id
|
|
|
+ ['contract_id','0'], //合约id
|
|
|
['longitude',''], //经度
|
|
|
['latitude',''], //纬度
|
|
|
-
|
|
|
+// ['uid',0]
|
|
|
],$request);
|
|
|
- $uid = (int)$post["uid"];
|
|
|
+ $uid = $request->user["uid"];
|
|
|
+// $uid = (int)$post["uid"];
|
|
|
// 检查签约时间是否为空
|
|
|
- if (empty($post['id'])) {
|
|
|
+ if (empty($post['contract_id'])) {
|
|
|
return app('json')->fail("签字错误");
|
|
|
}
|
|
|
$nickname=\app\model\api\User::where('uid',$uid)->value('nickname');
|
|
|
- $r = (new UserContractRecordModel)->where("id",$post["id"])->save([
|
|
|
+ $r = (new UserClockModel)->save([
|
|
|
'uid'=>$uid,
|
|
|
'nickname' => $nickname,
|
|
|
'longitude'=>$post['longitude'],
|
|
|
'latitude'=>$post['latitude'],
|
|
|
- 'contract_id'=>$post['id'],
|
|
|
+ 'contract_id'=>$post['contract_id'],
|
|
|
'create_time'=>time()
|
|
|
]);
|
|
|
return app('json')->success("数据保存成功");
|
|
|
@@ -1362,27 +1370,52 @@ class User extends BaseController
|
|
|
// 添加客户评论
|
|
|
public function comment(Request $request){
|
|
|
$post = UtilService::getMore([
|
|
|
- ['id','0'], //合约id
|
|
|
+ ['contract_id','0'], //合约id
|
|
|
['content',''], //评论内容
|
|
|
+ ['uid',0]
|
|
|
],$request);
|
|
|
- $uid = (int)$post["uid"];
|
|
|
- $info = (new UserContractRecordModel)->where("id",$post["id"])->find();
|
|
|
- if(empty($info)){
|
|
|
- return app('json')->fail("合约不存在");
|
|
|
+// $uid = $request->user["uid"];
|
|
|
+ $uid = $post['uid'];
|
|
|
+ $time=time();
|
|
|
+ $info = (new UserContractRecordModel)->where("id",$post["contract_id"])->where('start_time','>',$time)->where('end_time','<',$time)->find();
|
|
|
+ if (!empty($info)){
|
|
|
+ $info = $info->toArray();
|
|
|
}
|
|
|
if ($info['status']!=1){
|
|
|
return app('json')->fail("只能在签约期间才能发表评论");
|
|
|
}
|
|
|
- // 检查签约时间是否为空
|
|
|
- if (empty($post['id'])) {
|
|
|
- return app('json')->fail("签字错误");
|
|
|
+ if(empty($info)){
|
|
|
+ return app('json')->fail("没有签约中的合约");
|
|
|
}
|
|
|
+ // 检查签约时间是否为空
|
|
|
+// if (empty($post['id'])) {
|
|
|
+// return app('json')->fail("签字错误");
|
|
|
+// }
|
|
|
$r = (new ContractCommentModel)->save([
|
|
|
'uid'=>$uid,
|
|
|
- 'contract_id'=>$post['id'],
|
|
|
+ 'contract_id'=>$post['contract_id'],
|
|
|
+ 'contract_no'=>$info['contract_no'],
|
|
|
+ 'to_uid'=>$info['to_uid'],
|
|
|
'content'=>$post['content'],
|
|
|
'create_time'=>time()
|
|
|
]);
|
|
|
return app('json')->success("数据保存成功");
|
|
|
}
|
|
|
+// 甲方主动解约
|
|
|
+ public function lift_contract(Request $request){
|
|
|
+ $post = UtilService::getMore([
|
|
|
+ ['contract_id','0'], //合约id
|
|
|
+// ['uid',0]
|
|
|
+ ],$request);
|
|
|
+
|
|
|
+ // 检查签约时间是否为空
|
|
|
+ if (empty($post['contract_id'])) {
|
|
|
+ return app('json')->fail("没有该合约");
|
|
|
+ }
|
|
|
+ $r = (new UserContractRecordModel())->where('id',$post['contract_id'])->update([
|
|
|
+ 'status'=>-1,
|
|
|
+ 'delete_time'=>time()
|
|
|
+ ]);
|
|
|
+ return app('json')->success("解约成功");
|
|
|
+ }
|
|
|
}
|