Commit 320ae76b authored by wangzhengwen's avatar wangzhengwen

项目拒绝,验证码

parent 97f59ad5
......@@ -99,11 +99,12 @@ class Index extends BaseController
'status',
'tag_ids',
'sh_status_time',
'put_time',
'zhouqi',
// 当 status=3 时,计算截止日期(sh_status_time + zhouqi * 86400)
// 当 status=3 时,计算截止日期(put_time + zhouqi * 86400)
'IF(
status=3 AND sh_status_time IS NOT NULL AND zhouqi IS NOT NULL,
FROM_UNIXTIME(sh_status_time + zhouqi * 86460),
status=3 AND put_time IS NOT NULL AND zhouqi IS NOT NULL,
FROM_UNIXTIME(put_time + zhouqi * 86460),
NULL
) as deadline_date',
])
......
......@@ -170,7 +170,7 @@ class Project extends BaseController
//项目完成
public function confirmCompletion(Request $request)
{
$filed = ['project_put_id'];
$filed = ['project_put_id','type'];
// 验证参数
$vo = (new ProjectValidate())->goCheck($filed);
......@@ -178,7 +178,18 @@ class Project extends BaseController
return $vo;
}
$data = $request->only($filed);
$res = ProjectService::confirmCompletion($data['project_put_id']);
if ($data['type']==1)
{
$userId = $request->userId;
$mobile = \app\model\project\User::where('id',$userId)->value('mobile');
$checkSmsCode = UtilService::checkSmsCode($mobile, $data['code']);
if (!$checkSmsCode) {
return $this->returnMsg('验证码错误');
}
}
$res = ProjectService::confirmCompletion($data['project_put_id'],$data['type']);
if ($res['code'] == 1) {
return $this->returnMsg('success', 1);
}
......@@ -266,6 +277,11 @@ class Project extends BaseController
// 开启事务
Db::startTrans();
if ($data['put_end_time']<time())
{
throw new \Exception('项目截止日期应大于当前日期');
}
//检查用户信用余额是否足够
$user = UserModel::where(['id' => $request->userId, 'is_del' => 0])
......@@ -331,7 +347,12 @@ class Project extends BaseController
return $this->returnMsg('项目不存在');
}
if ($project->sh_status == 2) {
// return $this->returnMsg('项目已审核不能编辑');
return $this->returnMsg('项目已审核不能编辑');
}
if ($data['put_end_time']<$project->createtime)
{
return $this->returnMsg('项目截止日期应大于当前日期');
}
$res = ProjectModel::where(['id' => $id, 'user_id' => $request->userId])->update($data);
......
......@@ -152,7 +152,8 @@ class Project extends BaseController
}
$data = $request->param();
$projectPutData = ProjectPut::where(['id'=>$data['project_put_id'],'user_id'=>$request->userId,'complete_status'=>0])
$projectPutData = ProjectPut::where(['id'=>$data['project_put_id'],'user_id'=>$request->userId])
->whereIn('complete_status',[0,2])
->lock(true)
->find();
......
......@@ -13,7 +13,7 @@ use think\facade\Log;
class ProjectService
{
public static function confirmCompletion($id)
public static function confirmCompletion($id,$type=1)
{
// 定义查询条件
$where = ['id' => $id, 'status' => 2, 'complete_status' => 1];
......@@ -28,6 +28,22 @@ class ProjectService
throw new \Exception('未找到符合条件的接单记录');
}
//验收失败
if ($type==2)
{
$putUpdate = ['complete_status' => 2, 'complete_time' => time()];
$putResult = ProjectPut::where($where)->update($putUpdate);
if (!$putResult) {
throw new \Exception('更新接单状态失败');
}
// 提交事务
Db::commit();
return ['code'=>1,'msg'=>'success'];
}
// 2. 更新接单状态为已完成
$putUpdate = ['complete_status' => 3, 'complete_time' => time()];
$putResult = ProjectPut::where($where)->update($putUpdate);
......
......@@ -209,7 +209,17 @@ class Project extends Model
//项目详情
public function projectDetail($id, $userId)
{
$project = self::with(['getuserdata','projectcatedata','thumb'])->find($id);
$project = self::with(['getuserdata','projectcatedata','thumb'])
->field([
'*',
// 当 status=3 时,计算截止日期(put_time + zhouqi * 86400)
'IF(
status IN (2, 3, 4) AND put_time IS NOT NULL AND zhouqi IS NOT NULL,
FROM_UNIXTIME(put_time + zhouqi * 86400),
NULL
) as deadline_date',
])
->find($id);
if (!$project) {
return [];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment