fixed
This commit is contained in:
parent
990b752339
commit
4d73a75ce6
@ -8,6 +8,7 @@ use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseAdminController
|
||||
@ -17,6 +18,10 @@ class ApproveController extends BaseAdminController
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function lists2()
|
||||
{
|
||||
return $this->success('成功',(new ApproveLists())->lists2());
|
||||
}
|
||||
public function audit()
|
||||
{
|
||||
try {
|
||||
@ -25,6 +30,7 @@ class ApproveController extends BaseAdminController
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
// 拒绝通过 要让用户今天可以继续做任务
|
||||
if ($params['check_status'] == 3) {
|
||||
@ -32,7 +38,27 @@ class ApproveController extends BaseAdminController
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass($approve);
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
$taskTemplate = TaskTemplate::where(['id'=>$approve->business_id])->find();
|
||||
// 提前完成
|
||||
if ($taskTemplate['day_count'] < $taskTemplate['stage_day_one']) {
|
||||
if (bccomp($params['amount'], 300000, 2) == -1) {
|
||||
$this->fail('该任务提前完成条件:销售总额必须达到30万元及以上');
|
||||
} else {
|
||||
// 提前完成标识
|
||||
$extend = json_decode($taskTemplate['extend'], true);
|
||||
$extend['early_finish'] = 1;
|
||||
$taskTemplate->extend = json_encode($extend);
|
||||
$taskTemplate->save();
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve, $params);
|
||||
}
|
||||
} else {
|
||||
$this->pass($approve);
|
||||
}
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
return $this->success('审核成功');
|
||||
@ -42,7 +68,7 @@ class ApproveController extends BaseAdminController
|
||||
}
|
||||
}
|
||||
// 通过
|
||||
private function pass($approve)
|
||||
private function pass($approve, $params=[])
|
||||
{
|
||||
Db::startTrans();
|
||||
$approve->check_status = 2;
|
||||
@ -76,7 +102,7 @@ class ApproveController extends BaseAdminController
|
||||
->where('scheduling.company_type', 17)
|
||||
->find()
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan, $approve);
|
||||
TaskLogic::dealVillageTask6($taskSchedulePlan);
|
||||
}
|
||||
|
||||
if ($approve->type == Approve::APPROVE_TYPE_6) {
|
||||
@ -89,6 +115,11 @@ class ApproveController extends BaseAdminController
|
||||
->toArray();
|
||||
TaskLogic::dealVillageTask8($taskSchedulePlan);
|
||||
}
|
||||
if ($approve->type == Approve::APPROVE_TYPE_7) {
|
||||
// 需要手动输入销售总额
|
||||
$approve->amount = $params['amount'];
|
||||
$approve->save();
|
||||
}
|
||||
}
|
||||
|
||||
// 拒绝
|
||||
|
@ -53,6 +53,26 @@ class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function lists2(): array
|
||||
{
|
||||
return Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->with('task')
|
||||
->field('*')
|
||||
->append(['area_manager', 'company_name'], true)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
||||
})
|
||||
->withAttr('company_name',function($value,$data){
|
||||
$extend = json_decode($data['extend'], true);
|
||||
$company = Db::query("select * from la_company where FIND_IN_SET(:street,responsible_area)", ['street'=>$extend['street']], true);
|
||||
return $company[0]['company_name'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
|
@ -323,6 +323,10 @@ class TaskController extends BaseApiController
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
|
||||
$this->fail('没有上传凭证,无法提交审核');
|
||||
}
|
||||
|
||||
$extend = ['other' => ['is_commit' => 1, 'note' => $parmas['note'], 'annex'=>$parmas['annex'], 'video_annex' => $parmas['video_annex']]];
|
||||
Db::startTrans();
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
@ -504,7 +508,7 @@ class TaskController extends BaseApiController
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_6;
|
||||
$approveModel->type = Approve::APPROVE_TYPE_5;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
@ -558,7 +562,7 @@ class TaskController extends BaseApiController
|
||||
// 没有则创建审批任务
|
||||
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_5;
|
||||
$approveModel->type = Approve::APPROVE_TYPE_6;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
@ -582,4 +586,60 @@ class TaskController extends BaseApiController
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提前完成,截止提交时间,前面的钱一次性结算,往后至任务结束每天发放
|
||||
*/
|
||||
public function commit_town_master_task_type_2()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->param(); // id annex video_annex
|
||||
$task = TaskLogic::detail($parmas);
|
||||
if (empty($task)) {
|
||||
$this->fail('任务不存在');
|
||||
}
|
||||
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
|
||||
$this->fail('没有上传凭证,无法提交审核');
|
||||
}
|
||||
|
||||
$extend = [
|
||||
'other'=> [
|
||||
'is_commit' => 1,
|
||||
'note' => $parmas['note'],
|
||||
'annex' => ['annex'],
|
||||
'video_annex' => ['video_annex'],
|
||||
]
|
||||
];
|
||||
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
|
||||
|
||||
// 片区经理
|
||||
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
|
||||
|
||||
|
||||
// 查询是否 已有审批通过的
|
||||
$approveModel = Approve::where(['business_id' => $task['template_id'], 'check_status' => 2])->findOrEmpty();
|
||||
if ($approveModel->isEmpty()) {
|
||||
$approveModel->type = Approve::APPROVE_TYPE_7;
|
||||
$approveModel->flow_id = 1;
|
||||
$approveModel->name = $task['title'];
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
$approveModel->user_id = $this->userId; // 前台发起人用户id
|
||||
$approveModel->task_id = $task['id']; // 任务id
|
||||
$approveModel->business_id = $task['template_id']; // 关联模板id,结算时用于判断这个任务是否提前完成
|
||||
$approveModel->department_id = '0';
|
||||
$approveModel->check_admin_ids = $areaManagerId; // 当前审批人ID 片区经理的admin_id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$re = $approveModel->save();
|
||||
} else {
|
||||
// 有则更新状态
|
||||
return $this->fail('该任务已完成,请勿重复提交');
|
||||
}
|
||||
return $this->success('ok', []);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ class Approve extends BaseModel
|
||||
const APPROVE_TYPE_5 = 5; // 村联络员任务-信息平台铺设工作任务
|
||||
const APPROVE_TYPE_6 = 6; // 村联络员任务-日常管理及其他临时任务
|
||||
|
||||
const APPROVE_TYPE_7 = 7; // 镇农科负责人任务-应用软件推广
|
||||
|
||||
public function task()
|
||||
{
|
||||
return $this->hasOne(Task::class, 'id', 'task_id');
|
||||
|
Loading…
x
Reference in New Issue
Block a user