Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangtao
projecttwo
Commits
8b43c884
Commit
8b43c884
authored
May 21, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.21
parent
6c5dd3f6
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
706 additions
and
6 deletions
+706
-6
StatusConstants.php
app/api/common/StatusConstants.php
+36
-0
Sms.php
app/api/controller/Sms.php
+1
-2
Index.php
app/api/controller/manage/Index.php
+98
-0
Project.php
app/api/controller/manage/Project.php
+338
-0
ProjectTag.php
app/api/controller/manage/ProjectTag.php
+42
-0
User.php
app/api/controller/mine/User.php
+4
-3
ProjectService.php
app/api/service/ProjectService.php
+102
-0
ProjectTagValidate.php
app/api/validate/ProjectTagValidate.php
+32
-0
ProjectValidate.php
app/api/validate/ProjectValidate.php
+42
-0
Project.php
app/model/Project.php
+4
-0
ProjectTag.php
app/model/ProjectTag.php
+6
-0
UserWithdrawal.php
app/model/project/UserWithdrawal.php
+1
-1
No files found.
app/api/common/StatusConstants.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\common
;
class
StatusConstants
{
const
STATUS_MAP
=
[
'apply'
=>
[
0
=>
'申请中'
,
1
=>
'申请失败'
,
2
=>
'申请成功'
],
'complete'
=>
[
0
=>
'未上传'
,
1
=>
'验收中'
,
2
=>
'验收失败'
,
3
=>
'验收成功'
]
];
const
PROGRESS_RULES
=
[
'apply'
=>
[
0
=>
10
,
// 申请中
1
=>
0
,
// 申请失败
2
=>
20
// 申请成功
],
'complete'
=>
[
0
=>
0
,
// 等待审核
1
=>
20
,
// 验收中
2
=>
30
,
// 进行中
3
=>
60
,
// 待验收
4
=>
100
,
//已完成
5
=>
0
//已取消
]
];
}
\ No newline at end of file
app/api/controller/Sms.php
View file @
8b43c884
...
...
@@ -24,14 +24,13 @@ class Sms extends BaseController
$data
=
$request
->
param
();
$code
=
str_pad
(
random_int
(
0
,
9999
),
4
,
'0'
,
STR_PAD_LEFT
);
$code
=
str_pad
(
random_int
(
0
,
9999
99
),
6
,
'0'
,
STR_PAD_LEFT
);
// halt($code);
$SMS
=
new
SendSms
();
$res
=
$SMS
->
aliyun_send
(
$data
[
'mobile'
],
$code
);
return
$this
->
returnMsg
(
$res
[
'msg'
],
$res
[
'code'
]);
}
...
...
app/api/controller/manage/Index.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\controller\manage
;
use
app\api\middleware\Auth
;
use
app\api\service\UtilService
;
use
app\BaseController
;
use
think\facade\Db
;
use
think\Request
;
class
Index
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
//看板统计
public
function
index
(
Request
$request
)
{
$userId
=
$request
->
userId
;
try
{
Db
::
startTrans
();
// 1. 获取基础数据
$courseStats
=
Db
::
name
(
'course'
)
->
where
(
'user_id'
,
$userId
)
->
field
([
'COUNT(id) as course_count'
,
'SUM(tvclick) as pv_count'
,
'GROUP_CONCAT(id) as course_ids'
])
->
find
();
$courseIds
=
$courseStats
[
'course_ids'
]
?
explode
(
','
,
$courseStats
[
'course_ids'
])
:
[];
// 2. 获取支付相关统计数据
$paymentStats
=
Db
::
name
(
'payment'
)
->
where
(
'sf_id'
,
'in'
,
$courseIds
)
->
where
(
'order_type'
,
1
)
->
field
([
'SUM(CASE WHEN pay_status = 1 THEN pay_amount ELSE 0 END) as order_money_sum'
,
'COUNT(id) as order_count'
])
->
find
();
// 3. 获取项目统计数据
$projectStats
=
Db
::
name
(
'project'
)
->
where
(
'user_id'
,
$userId
)
->
field
([
'COUNT(id) as project_count'
,
'SUM(CASE WHEN status IN (0,1,3) THEN 1 ELSE 0 END) as project_pending_count'
,
'SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as project_progress_count'
,
'SUM(CASE WHEN status = 4 THEN 1 ELSE 0 END) as project_finished_count'
])
->
find
();
// 组装返回数据
$result
=
[
'orderMoneySum'
=>
(
int
)
$paymentStats
[
'order_money_sum'
]
??
0
,
'orderCount'
=>
(
int
)
$paymentStats
[
'order_count'
]
??
0
,
'courseCount'
=>
(
int
)
$courseStats
[
'course_count'
]
??
0
,
'pvCount'
=>
(
int
)
$courseStats
[
'pv_count'
]
??
0
,
'projectCount'
=>
(
int
)
$projectStats
[
'project_count'
]
??
0
,
'projectPendingCount'
=>
(
int
)
$projectStats
[
'project_pending_count'
]
??
0
,
'projectProgressCount'
=>
(
int
)
$projectStats
[
'project_progress_count'
]
??
0
,
'projectFinishedCount'
=>
(
int
)
$projectStats
[
'project_finished_count'
]
??
0
,
'projectPendingList'
=>
$this
->
getProjectPendingList
(
$userId
)
];
Db
::
commit
();
return
$this
->
returnMsg
(
'success'
,
1
,
$result
);
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
$this
->
returnMsg
(
'系统错误,请稍后再试'
);
}
}
public
function
getProjectPendingList
(
$userId
)
{
$list
=
\app\model\Project
::
where
(
'user_id'
,
$userId
)
->
where
(
'status'
,
'in'
,[
0
,
1
,
3
])
->
field
([
'id'
,
'title'
,
'status'
,
'tag_ids'
])
->
select
();
$list
=
$list
->
map
(
function
(
$item
){
return
UtilService
::
infoWithTags
(
$item
,
\app\model\ProjectTag
::
class
,
'tag_ids'
);
});
return
$list
;
}
}
\ No newline at end of file
app/api/controller/manage/Project.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\controller\manage
;
use
app\api\common\StatusConstants
;
use
app\api\middleware\Auth
;
use
app\api\service\ProjectService
;
use
app\api\service\UtilService
;
use
app\api\validate\ProjectValidate
;
use
app\BaseController
;
use
app\model\Project
as
ProjectModel
;
use
app\model\project\User
as
UserModel
;
use
app\model\ProjectPut
;
use
think\facade\Db
;
use
think\Log
;
use
think\Request
;
class
Project
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
public
function
getProjectList
(
Request
$request
)
{
$data
=
$request
->
param
();
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$where
=
[
'user_id'
=>
$request
->
userId
];
if
(
!
empty
(
$data
[
'status'
])
||
$data
[
'status'
]
==
0
)
{
$where
[
'status'
]
=
(
int
)
$data
[
'status'
];
}
if
(
!
empty
(
$data
[
'sh_status'
]))
{
$where
[
'sh_status'
]
=
$data
[
'sh_status'
];
}
$query
=
ProjectModel
::
where
(
$where
);
if
(
!
empty
(
$data
[
'search_str'
]))
{
$searchStr
=
trim
(
$data
[
'search_str'
]);
$query
->
where
(
function
(
$q
)
use
(
$searchStr
)
{
$q
->
where
(
'title|sn'
,
'like'
,
"%
{
$searchStr
}
%"
);
});
}
if
(
!
empty
(
$data
[
'start_date'
])
||
!
empty
(
$data
[
'end_date'
]))
{
if
(
!
empty
(
$data
[
'start_date'
]))
{
$startTimestamp
=
strtotime
(
$data
[
'start_date'
]);
$query
->
where
(
'createtime'
,
'>='
,
$startTimestamp
);
}
if
(
!
empty
(
$data
[
'end_date'
]))
{
$endTimestamp
=
strtotime
(
$data
[
'end_date'
]);
$query
->
where
(
'createtime'
,
'<='
,
$endTimestamp
);
}
}
$list
=
$query
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
// 处理结果集
// 添加调试信息
$list
->
each
(
function
(
$item
)
{
$applyProgress
=
StatusConstants
::
PROGRESS_RULES
[
'apply'
][
$item
->
sh_status
]
??
0
;
$completeProgress
=
(
$item
->
sh_status
==
2
)
?
(
StatusConstants
::
PROGRESS_RULES
[
'complete'
][
$item
->
status
]
??
0
)
:
0
;
$item
->
progress
=
max
(
1
,
min
(
100
,
$applyProgress
+
$completeProgress
));
return
$item
;
});
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
public
function
getProjectDetail
(
Request
$request
)
{
$filed
=
[
'project_id'
];
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
$res
=
ProjectModel
::
where
([
'id'
=>
$data
[
'project_id'
],
'user_id'
=>
$request
->
userId
])
->
find
();
$applyProgress
=
StatusConstants
::
PROGRESS_RULES
[
'apply'
][
$res
->
sh_status
]
??
0
;
$completeProgress
=
(
$res
->
sh_status
==
2
)
?
(
StatusConstants
::
PROGRESS_RULES
[
'complete'
][
$res
->
status
]
??
0
)
:
0
;
$res
->
progress
=
max
(
1
,
min
(
100
,
$applyProgress
+
$completeProgress
));
$res
=
UtilService
::
infoWithTags
(
$res
,
\app\model\ProjectTag
::
class
,
'tag_ids'
);
return
$this
->
returnMsg
(
'success'
,
1
,
$res
);
}
public
function
getProjectPutList
(
Request
$request
)
{
$filed
=
[
'project_id'
];
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$where
=
[
'project_id'
=>
$data
[
'project_id'
]];
$query
=
ProjectPut
::
with
([
'getuserdata'
])
->
where
(
$where
);
$order_status
=
ProjectModel
::
where
(
'id'
,
$request
->
param
(
'project_id'
))
->
value
(
'status'
);
if
(
$order_status
>=
2
)
{
$query
->
where
([
'project_put.status'
=>
2
]);
}
if
(
!
empty
(
$data
[
'search_str'
]))
{
$searchStr
=
trim
(
$data
[
'search_str'
]);
$query
->
hasWhere
(
'getuserdata'
,
function
(
$q
)
use
(
$searchStr
)
{
$q
->
where
(
'username'
,
'like'
,
"%
{
$searchStr
}
%"
);
});
}
$list
=
$query
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
$list
->
each
(
function
(
$item
)
{
$item
->
done_num
=
ProjectPut
::
where
([
'user_id'
=>
$item
->
user_id
,
'complete_status'
=>
3
])
->
count
();;
return
$item
;
});
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//项目完成
public
function
confirmCompletion
(
Request
$request
)
{
$filed
=
[
'project_put_id'
];
// 验证参数
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
$res
=
ProjectService
::
confirmCompletion
(
$data
[
'project_put_id'
]);
if
(
$res
[
'code'
]
==
1
)
{
return
$this
->
returnMsg
(
'success'
,
1
);
}
return
$this
->
returnMsg
(
$res
[
'msg'
]);
}
//确认接单人
public
function
confirmOrderUser
(
Request
$request
)
{
$filed
=
[
'project_id'
,
'user_id'
];
// 验证参数
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
try
{
// 开启事务
Db
::
startTrans
();
// 检查项目状态
$isConfirm
=
ProjectModel
::
where
([
'id'
=>
$data
[
'project_id'
],
'sh_status'
=>
2
])
->
where
(
'status'
,
'!='
,
1
)
->
lock
(
true
)
->
count
();
if
(
!
$isConfirm
)
{
throw
new
\Exception
(
'当前项目已完成或已确认接单人'
);
}
// 更新项目状态
$projectUpdate
=
[
'status'
=>
2
,
'updatetime'
=>
time
()];
$projectResult
=
ProjectModel
::
where
(
'id'
,
$data
[
'project_id'
])
->
update
(
$projectUpdate
);
if
(
!
$projectResult
)
{
throw
new
\Exception
(
'更新项目状态失败'
);
}
// 更新接单记录
$putUpdate
=
[
'put_time'
=>
time
(),
'status'
=>
2
];
$putResult
=
ProjectPut
::
where
(
'project_id'
,
$data
[
'project_id'
])
->
where
(
'user_id'
,
$data
[
'user_id'
])
->
update
(
$putUpdate
);
if
(
!
$putResult
)
{
throw
new
\Exception
(
'更新接单记录失败'
);
}
// 提交事务
Db
::
commit
();
return
$this
->
returnMsg
(
'success'
,
1
);
}
catch
(
\Exception
$e
)
{
// 回滚事务
Db
::
rollback
();
return
$this
->
returnMsg
(
$e
->
getMessage
());
}
}
//创建项目
public
function
createProject
(
Request
$request
)
{
$filed
=
[
'title'
,
'cate_id'
,
'tag_ids'
,
'yusuan'
,
'zhouqi'
,
'description'
,
'content'
,
'file_id_str'
];
// 参数验证
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
$data
[
'sn'
]
=
UtilService
::
generateCompactOrderNo
(
null
,
'xm'
);
$data
[
'user_id'
]
=
$request
->
userId
;
try
{
// 开启事务
Db
::
startTrans
();
//检查用户信用余额是否足够
$user
=
UserModel
::
where
([
'id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
lock
(
true
)
// 加锁防止并发修改
->
find
();
if
(
!
$user
)
{
throw
new
\Exception
(
'用户不存在或已被删除'
);
}
if
(
$user
->
credit_money
<
$data
[
'yusuan'
])
{
throw
new
\Exception
(
'企业信用金额不足,当前可用金额:'
.
$user
->
credit_money
);
}
// 1. 创建项目
$res
=
ProjectModel
::
create
(
$data
);
if
(
!
$res
)
{
throw
new
\Exception
(
'项目创建失败'
);
}
// 2. 更新用户金额(扣除预算)
$moneyResult
=
UserModel
::
where
([
'id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
dec
(
'credit_money'
,
$data
[
'yusuan'
])
->
update
();
if
(
!
$moneyResult
)
{
throw
new
\Exception
(
'企业信用金额更新失败'
);
}
// 提交事务
Db
::
commit
();
return
$this
->
returnMsg
(
'success'
,
1
,
$res
);
}
catch
(
\Exception
$e
)
{
// 回滚事务
Db
::
rollback
();
// 记录错误日志
return
$this
->
returnMsg
(
$e
->
getMessage
());
}
}
//编辑项目
public
function
editProject
(
Request
$request
)
{
$filed
=
[
'project_id'
,
'title'
,
'cate_id'
,
'tag_ids'
,
'yusuan'
,
'zhouqi'
,
'description'
,
'content'
,
'file_id_str'
];
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
$id
=
$data
[
'project_id'
];
unset
(
$data
[
'project_id'
]);
$res
=
ProjectModel
::
where
([
'id'
=>
$id
,
'user_id'
=>
$request
->
userId
])
->
update
(
$data
);
return
$this
->
returnMsg
(
'success'
,
1
,
$res
);
}
//删除项目
public
function
delProject
(
Request
$request
)
{
$filed
=
[
'project_id'
];
$vo
=
(
new
ProjectValidate
())
->
goCheck
(
$filed
);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
only
(
$filed
);
$res
=
ProjectModel
::
where
([
'id'
=>
$data
[
'project_id'
],
'user_id'
=>
$request
->
userId
])
->
find
();
if
(
!
$res
)
{
return
$this
->
returnMsg
(
'项目不存在或无权删除'
);
}
$res
->
delete
();
return
$this
->
returnMsg
(
'success'
,
1
,
$res
);
}
}
\ No newline at end of file
app/api/controller/manage/ProjectTag.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\controller\manage
;
use
app\api\middleware\Auth
;
use
app\api\validate\ProjectTagValidate
;
use
app\BaseController
;
use
app\model\ProjectTag
as
ProjectTagModel
;
use
think\Request
;
class
ProjectTag
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
public
function
createProjectTag
(
Request
$request
)
{
$vo
=
(
new
ProjectTagValidate
())
->
goCheck
();
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$parm
[
'user_id'
]
=
$request
->
userId
;
$result
=
ProjectTagModel
::
create
(
$parm
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//标签列表
public
function
getProjectTagList
(
Request
$request
)
{
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$request
->
userId
];
$list
=
ProjectTagModel
::
where
(
$where
)
->
order
(
'createtime desc'
)
->
select
()
->
toArray
();
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
}
\ No newline at end of file
app/api/controller/mine/User.php
View file @
8b43c884
...
...
@@ -139,7 +139,9 @@ class User extends BaseController
// return $this->returnMsg('每天只能提现一次');
}
$sum
=
UserMoneyLog
::
where
([
'user_id'
=>
$userId
,
'type'
=>
1
])
$UserWithdrawalModel
=
new
UserWithdrawal
();
$sum
=
$UserWithdrawalModel
->
where
([
'user_id'
=>
$userId
,
'type'
=>
1
])
->
whereBetween
(
'createtime'
,
[
strtotime
(
'today'
),
strtotime
(
'tomorrow'
)
-
1
])
->
sum
(
'money'
);
...
...
@@ -148,10 +150,9 @@ class User extends BaseController
return
$this
->
returnMsg
(
'超出每日限额'
);
}
$userAccount
=
UserAccount
::
where
([
'user_id'
=>
$userId
,
'is_del'
=>
0
,
'type'
=>
$data
[
'txType'
]])
->
find
();
$UserWithdrawalModel
=
new
UserWithdrawal
();
$commission
=
vconfig
(
'commission'
)
?
:
0
;
halt
(
$commission
);
//
halt($commission);
$res
=
$UserWithdrawalModel
->
applyWithdrawal
(
$userId
,
$data
[
'amount'
],
$data
[
'txType'
],
$userAccount
[
'account'
],
$userInfo
[
'realname'
],
$commission
,
$userInfo
[
'money'
]);
...
...
app/api/service/ProjectService.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\service
;
use
app\BaseController
;
use
app\model\Project
;
use
app\model\project\User
as
UserModel
;
use
app\model\project\UserMoneyLog
;
use
app\model\ProjectPut
;
use
think\facade\Db
;
use
think\facade\Log
;
class
ProjectService
{
public
static
function
confirmCompletion
(
$id
)
{
// 定义查询条件
$where
=
[
'id'
=>
$id
,
'status'
=>
2
,
'complete_status'
=>
1
];
try
{
// 开启事务
Db
::
startTrans
();
// 1. 查询并验证接单数据
$putData
=
ProjectPut
::
where
(
$where
)
->
lock
(
true
)
->
find
();
if
(
!
$putData
)
{
throw
new
\Exception
(
'未找到符合条件的接单记录'
);
}
// 2. 更新接单状态为已完成
$putUpdate
=
[
'complete_status'
=>
3
,
'complete_time'
=>
time
()];
$putResult
=
ProjectPut
::
where
(
$where
)
->
update
(
$putUpdate
);
if
(
!
$putResult
)
{
throw
new
\Exception
(
'更新接单状态失败'
);
}
// 3. 查询项目信息
$projectData
=
Project
::
where
(
'id'
,
$putData
[
'project_id'
])
->
lock
(
true
)
->
find
();
if
(
!
$projectData
)
{
throw
new
\Exception
(
'项目不存在'
);
}
// 4. 更新项目状态为已完成
$projectUpdate
=
[
'status'
=>
4
,
'updatetime'
=>
time
()];
$projectResult
=
Project
::
where
(
'id'
,
$putData
[
'project_id'
])
->
update
(
$projectUpdate
);
if
(
!
$projectResult
)
{
throw
new
\Exception
(
'更新项目状态失败'
);
}
// 5. 查询用户信息
$user
=
UserModel
::
where
(
'id'
,
$putData
[
'user_id'
])
->
lock
(
true
)
->
find
();
if
(
!
$user
)
{
throw
new
\Exception
(
'用户不存在'
);
}
// 6. 给用户增加金额
$moneyResult
=
UserModel
::
where
([
'id'
=>
$user
[
'id'
],
'is_del'
=>
0
])
->
inc
(
'money'
,
$projectData
[
'yusuan'
])
->
update
();
if
(
!
$moneyResult
)
{
throw
new
\Exception
(
'用户金额更新失败'
);
}
// 7. 恢复企业高校信用额度
$moneyResult
=
UserModel
::
where
([
'id'
=>
$user
[
'id'
],
'is_del'
=>
0
])
->
inc
(
'credit_money'
,
$projectData
[
'yusuan'
])
->
update
();
if
(
!
$moneyResult
)
{
throw
new
\Exception
(
'企业信用金额更新失败'
);
}
// 8. 记录资金流水
$logResult
=
UserMoneyLog
::
addUserMoneyLog
(
$user
[
'id'
],
$projectData
[
'yusuan'
],
$user
[
'money'
],
1
,
'项目完成奖励'
,
$projectData
[
'id'
]
);
if
(
!
$logResult
)
{
throw
new
\Exception
(
'资金流水记录失败'
);
}
// 提交事务
Db
::
commit
();
return
[
'code'
=>
1
,
'msg'
=>
'success'
];
}
catch
(
\Exception
$e
)
{
// 回滚事务
Db
::
rollback
();
// 记录错误日志
return
[
'code'
=>
0
,
'msg'
=>
$e
->
getMessage
()];
}
}
}
\ No newline at end of file
app/api/validate/ProjectTagValidate.php
0 → 100644
View file @
8b43c884
<?php
namespace
app\api\validate
;
use
app\model\CourseTag
;
use
app\model\ProjectTag
;
use
app\Request
;
use
think\Validate
;
class
ProjectTagValidate
extends
BaseValidate
{
protected
$rule
=
[
'title'
=>
'require|checktitle'
];
protected
$message
=
[
'title.require'
=>
'标签名不能为空'
,
'title.checktitle'
=>
'标签名重复'
,
];
protected
function
checktitle
(
$value
,
$rule
,
$data
=
[])
{
$uesrid
=
request
()
->
userId
;
$result
=
ProjectTag
::
where
([
'title'
=>
$value
,
'user_id'
=>
$uesrid
,
'is_del'
=>
0
])
->
count
();
if
(
$result
)
return
false
;
return
true
;
}
}
\ No newline at end of file
app/api/validate/ProjectValidate.php
View file @
8b43c884
...
...
@@ -2,6 +2,8 @@
namespace
app\api\validate
;
use
app\model\Project
;
class
ProjectValidate
extends
BaseValidate
{
protected
$rule
=
[
...
...
@@ -20,6 +22,46 @@ class ProjectValidate extends BaseValidate
'pay_type'
=>
'require|number'
,
'project_put_id'
=>
'require|number'
,
'complete_file_id_str'
=>
'require'
,
'project_name'
=>
'require'
,
'tag_ids'
=>
'require'
,
'yusuan'
=>
'require'
,
'zhouqi'
=>
'require'
,
'description'
=>
'require'
,
'content'
=>
'require'
,
'file_id_str'
=>
'require'
,
'cate_id'
=>
'require|number'
,
'title'
=>
'require|checktitle'
,
'user_id'
=>
'require|number'
,
];
protected
$message
=
[
'title.require'
=>
'项目名不能为空'
,
'title.checktitle'
=>
'项目名重复'
,
];
protected
function
checktitle
(
$value
,
$rule
,
$data
=
[])
{
$userId
=
request
()
->
userId
;
// 如果是编辑操作(有传递ID)
if
(
!
empty
(
$data
[
'project_id'
]))
{
$originalTitle
=
Project
::
where
(
'id'
,
$data
[
'project_id'
])
->
value
(
'title'
);
// 如果标题没有改变,直接通过验证
if
(
$originalTitle
===
$value
)
{
return
true
;
}
$result
=
Project
::
where
(
'title'
,
$value
)
->
where
(
'user_id'
,
$userId
)
->
where
(
'id'
,
'<>'
,
$data
[
'project_id'
])
// 排除当前项目
->
count
();
return
!
$result
;
}
$result
=
Project
::
where
([
'title'
=>
$value
,
'user_id'
=>
$userId
])
->
count
();
if
(
$result
)
return
false
;
return
true
;
}
}
\ No newline at end of file
app/model/Project.php
View file @
8b43c884
...
...
@@ -27,6 +27,10 @@ class Project extends Model
use
SoftDelete
;
protected
$deleteTime
=
'deletetime'
;
protected
$autoWriteTimestamp
=
true
;
protected
$createTime
=
'createtime'
;
protected
$updateTime
=
'updatetime'
;
public
function
getCreatetimeAttr
(
$value
)
...
...
app/model/ProjectTag.php
View file @
8b43c884
...
...
@@ -6,5 +6,11 @@ use think\Model;
class
ProjectTag
extends
Model
{
// 设置完整表名
protected
$table
=
'fj_project_tag'
;
// 自动时间戳(将createtime转换为时间戳自动管理)
protected
$autoWriteTimestamp
=
true
;
protected
$createTime
=
'createtime'
;
protected
$updateTime
=
false
;
}
\ No newline at end of file
app/model/project/UserWithdrawal.php
View file @
8b43c884
...
...
@@ -83,7 +83,7 @@ class UserWithdrawal extends Model
// 提交事务
$this
->
commit
();
UserMoneyLog
::
addUserMoneyLog
(
$userId
,
$amount
,
$front_money
,
1
,
'用户提现'
,
$withdrawalId
);
//
UserMoneyLog::addUserMoneyLog($userId,$amount,$front_money,1,'用户提现',$withdrawalId);
return
[
'status'
=>
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment