This commit is contained in:
mkm 2023-07-24 14:30:59 +08:00
commit e8c85f8cd4
6 changed files with 309 additions and 61 deletions

View File

@ -5,27 +5,21 @@ namespace app\adminapi\controller;
use think\facade\Db;
use app\common\model\user\Task;
class TaskController extends BaseAdminController
{
private $url;
//获取任务列表
public function list()
public function index()
{
$param = get_params();
$param['uid'] = $this->adminId;
$param['page'] = $param['page'] ?? 1;
$param['limit'] = $param['limit'] ?? 10;
$list = (new Task())->list($param);
return to_assign(200, 'success', $list);
[$param['page'], $param['limit']] = $this->getPage();
[$count, $list] = (new Task())->list($param);
return $this->success('success', ['count' => $count, 'list' => $list]);
}
//新建任务
public function add()
public function create()
{
$param = get_params();
//markdown数据处理
if (isset($param['table-align'])) {
unset($param['table-align']);
@ -57,14 +51,13 @@ class TaskController extends BaseAdminController
$check_time2 = $date + 32400;//早上9点
} else {
$check_time2 = ($date + 32400) + (3600 * $times[0]);//准确时间
}
} else {
$check_time2 = ($date + 32400) + (3600 * $c);//准确时间
}
$times3 = Strtotime(date('Y-m-t', time())) + 64800;
if ($check_time2 > $times3) {
to_assign(1, '验收时间不能大于本月月底18点 跨月时间:' . date('Y-m-d H:i:s', $check_time2));
return $this->fail('验收时间不能大于本月月底18点 跨月时间:' . date('Y-m-d H:i:s', $check_time2));
}
$param['check_time'] = $check_time2;
$param['end_time'] = $param['end_time'] + 86399;
@ -87,7 +80,7 @@ class TaskController extends BaseAdminController
}
unset($param['name'], $param['real_val']);
}
return to_assign(200, '发布成功', 1, 1);
return $this->success('发布成功', [], 1, 1);
} else {
$param['create_time'] = time();
$param['admin_id'] = $this->adminId;
@ -104,56 +97,53 @@ class TaskController extends BaseAdminController
}
$param['initial_end_time'] = $param['end_time'];
$sid = Task::strict(false)->field(true)->insertGetId($param);
return to_assign(200, '发布成功', 1, 1);
return $this->success('发布成功', [], 1, 1);
}
}
// 任务详情
public function read($id)
public function view($id)
{
$detail = (new Task())->detail($id);
if (empty($detail)) {
return to_assign(1, '任务不存在');
} else {
$role_uid = [$detail['admin_id'], $detail['director_uid']];
$role_edit = 'view';
if (in_array($this->adminId, $role_uid)) {
$role_edit = 'edit';
}
$file_array = Db::name('FileInterfix')
->field('mf.id,mf.topic_id,mf.admin_id,f.name,a.name as admin_name')
->alias('mf')
->join('File f', 'mf.file_id = f.id', 'LEFT')
->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
->order('mf.create_time desc')
->where(array('mf.topic_id' => $id, 'mf.module' => 'task'))
->select()->toArray();
$link_array = Db::name('LinkInterfix')
->field('i.id,i.topic_id,i.admin_id,i.desc,i.url,a.name as admin_name')
->alias('i')
->join('Admin a', 'i.admin_id = a.id', 'LEFT')
->order('i.create_time desc')
->where(array('i.topic_id' => $id, 'i.module' => 'task', 'a.delete_time' => 0))
->select()->toArray();
if ($detail['is_bug'] == 0) {
$detail['is_bug'] = '部门工作';
} elseif ($detail['is_bug'] == 1) {
$detail['is_bug'] = '部门协助';
} elseif ($detail['is_bug'] == 2) {
$detail['is_bug'] = '临时任务';
}
$return['bohui'] = [];
$return['count_bohui'] = [];
$return['detail'] = $detail;
$return['file_array'] = $file_array;
$return['link_array'] = $link_array;
$return['role_edit'] = $role_edit;
$return['url'] = $this->url;
$approve_id = Db::name('flow_task')->where('task_id', $id)->value('approve_id');
$return['flow_nodes'] = $this->get_flow_nodes($approve_id);
return to_assign(200, '获取成功', $return);
return $this->fail('任务不存在');
}
$role_uid = [$detail['admin_id'], $detail['director_uid']];
$role_edit = 'view';
if (in_array($this->adminId, $role_uid)) {
$role_edit = 'edit';
}
$file_array = Db::name('FileInterfix')
->field('mf.id,mf.topic_id,mf.admin_id,f.name,a.name as admin_name')
->alias('mf')
->join('File f', 'mf.file_id = f.id', 'LEFT')
->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
->order('mf.create_time desc')
->where(array('mf.topic_id' => $id, 'mf.module' => 'task'))
->select()->toArray();
$link_array = Db::name('LinkInterfix')
->field('i.id,i.topic_id,i.admin_id,i.desc,i.url,a.name as admin_name')
->alias('i')
->join('Admin a', 'i.admin_id = a.id', 'LEFT')
->order('i.create_time desc')
->where(array('i.topic_id' => $id, 'i.module' => 'task', 'a.delete_time' => 0))
->select()->toArray();
if ($detail['is_bug'] == 0) {
$detail['is_bug'] = '部门工作';
} elseif ($detail['is_bug'] == 1) {
$detail['is_bug'] = '部门协助';
} elseif ($detail['is_bug'] == 2) {
$detail['is_bug'] = '临时任务';
}
$return['bohui'] = [];
$return['count_bohui'] = [];
$return['detail'] = $detail;
$return['file_array'] = $file_array;
$return['link_array'] = $link_array;
$return['role_edit'] = $role_edit;
$approve_id = Db::name('flow_task')->where('task_id', $id)->value('approve_id');
$return['flow_nodes'] = $this->get_flow_nodes($approve_id);
return $this->success('success', $return);
}
//获取审核流程节点
@ -214,9 +204,9 @@ class TaskController extends BaseAdminController
);
Db::name('Log')->strict(false)->field(true)->insert($log_data);
}
return to_assign(200, '驳回成功', 1, 1);
return $this->success('驳回成功', [], 1, 1);
} else {
return to_assign(200, '驳回失败', 1, 1);
return $this->fail('驳回失败');
}
}

View File

@ -19,6 +19,7 @@ use app\api\validate\PayValidate;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\PaymentLogic;
use app\common\service\pay\WeChatPayService;
use think\facade\Log;
/**
* 支付
@ -28,7 +29,7 @@ use app\common\service\pay\WeChatPayService;
class PayController extends BaseApiController
{
public array $notNeedLogin = ['notifyMnp', 'notifyOa'];
public array $notNeedLogin = ['notifyMnp', 'notifyOa', 'notifyApp'];
/**
* @notes 支付方式
@ -120,4 +121,19 @@ class PayController extends BaseApiController
}
/**
* @notes app支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @date 2023/2/28 14:21
*/
public function notifyApp()
{
return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify();
}
}

View File

@ -0,0 +1,175 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\common\model\user;
use think\facade\Db;
use think\model;
class Task extends Model
{
const ZERO = 0; //#648A8D
const ONE = 1; //#4AC8BE
const TWO = 2; //#409CDE
const THREE = 3; //#C0DB38
const FOUR = 4; //#4DCE58
const FIVE = 5; //#FEC939
const SIX = 6; //#8838DA
const SEVEN = 7; //#FD6206
const EIGHT = 8; //#F03347
const NINE = 9; //#A38B82
public static $Priority = [
self::ZERO => '未设置',
self::ONE => '一般',
self::TWO => '中',
self::THREE => '高',
self::FOUR => '紧急',
];
public static $FlowStatus = [
self::ZERO => '未设置',
self::ONE => '未开始',
self::TWO => '进行中',
self::THREE => '等待验收',
self::FOUR => '已拒绝',
self::FIVE => '已关闭',
self::SIX => '通过验收',
];
//列表
function list($param, $type = 0)
{
$where = array();
$map1 = [];
$map2 = [];
$map3 = [];
$map4 = [];
if (!empty($param['project_id'])) {
$where[] = ['project_id', '=', $param['project_id']];
}
if (!empty($param['product_id'])) {
$where[] = ['product_id', '=', $param['product_id']];
} else {
$map1[] = ['admin_id', '=', $param['uid']];
$map2[] = ['director_uid', '=', $param['uid']];
$map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$param['uid']},assist_admin_ids)")];
}
if (!empty($param['type'])) {
$where[] = ['type', '=', $param['type']];
}
if (!empty($param['flow_status'])) {
$where[] = ['flow_status', '=', $param['flow_status']];
}
if (!empty($param['priority'])) {
$where[] = ['priority', '=', $param['priority']];
}
if (!empty($param['cate'])) {
$where[] = ['cate', '=', $param['cate']];
}
if (!empty($param['director_uid'])) {
$where[] = ['director_uid', 'in', $param['director_uid']];
}
if (!empty($param['keywords'])) {
$where[] = ['title|content', 'like', '%' . $param['keywords'] . '%'];
}
if (!empty($param['did'])) {
$where[] = ['did', '=', $param['did']];
}
if (!empty($param['create_time'])) {
$where[] = ['create_time', 'BETWEEN', [strtotime($param['create_time']), strtotime($param['create_time'] . " +1 month -1 day")]];
}
if (!empty($param['types']) && $param['types'] == 9) {
$where = [];
$where[] = ['end_time', 'BETWEEN', [strtotime(date('Y-m-d'), time()), strtotime(date('Y-m-d'), time()) + 86399]];
$where[] = ['flow_status', '=', 2];
}
$where[] = ['delete_time', '=', 0];
if ($type == 1) {
unset($where['project_id']);
$map1 = [];
$map2 = [];
$map3 = [];
$map4 = [];
}
$query = Db::name('Task')->where(function ($query) use ($map1, $map2, $map3, $map4) {
$query->where($map1)->whereor($map2)->whereor($map3);
})->where($where);
$count = $query->count();
$list = $query->withoutField('content,md_content')
->order('flow_status asc')
->order('id desc')
->page($param['page'])
->limit($param['limit'])
->select()
->each(function ($item, $key) {
$item['director_name'] = Db::name('Admin')->where(['id' => $item['director_uid']])->value('name');
$item['admin_name'] = Db::name('Admin')->where(['id' => $item['admin_id']])->value('name');
$assist_admin_names = Db::name('Admin')->where([['id', 'in', $item['assist_admin_ids']]])->column('name');
$item['cate_name'] = Db::name('WorkCate')->where(['id' => $item['cate']])->value('title');
$item['type_name'] = Db::name('TaskCate')->where(['id' => $item['type']])->value('title');
$item['did_name'] = Db::name('department')->where(['id' => $item['did']])->value('title');
if (empty($assist_admin_names)) {
$item['assist_admin_names'] = '-';
} else {
$item['assist_admin_names'] = implode(',', $assist_admin_names);
}
$item['end_time'] = date('Y-m-d', $item['end_time']);
$item['delay'] = 0;
if ($item['over_time'] > 0 && $item['flow_status'] > 3 && $item['initial_end_time'] < time()) {
$item['delay'] = countDays(date('Y-m-d', $item['initial_end_time']), date('Y-m-d', $item['over_time']));
}
if ($item['over_time'] == 0 && $item['flow_status'] < 2 && $item['initial_end_time'] < time()) {
$item['delay'] = countDays(date('Y-m-d', time()), $item['initial_end_time']);
}
$item['priority_name'] = self::$Priority[(int)$item['priority']];
$item['flow_name'] = self::$FlowStatus[(int)$item['flow_status']];
return $item;
});
return [$count, $list];
}
//详情
public function detail($id)
{
$detail = Db::name('Task')->where(['id' => $id])->find();
if (!empty($detail)) {
$detail['product_name'] = '';
$detail['project_name'] = '';
if ($detail['project_id'] > 0) {
$project = Db::name('Project')->where(['id' => $detail['project_id']])->field('product_id,name')->find();
$detail['product_name'] = Db::name('Product')->where(['id' => $project['product_id']])->value('name');
$detail['project_name'] = $project['name'];
}
$detail['admin_name'] = Db::name('Admin')->where(['id' => $detail['admin_id']])->value('name');
$detail['work_hours'] = Db::name('Schedule')->where(['delete_time' => 0, 'tid' => $detail['id']])->sum('labor_time');
$detail['cate_name'] = Db::name('WorkCate')->where(['id' => $detail['cate']])->value('title');
$detail['type_name'] = Db::name('TaskCate')->where(['id' => $detail['type']])->value('title');
$find = Db::name('Admin')->where(['id' => $detail['director_uid']])->field('name,total_working_hours')->find();
$detail['director_name'] = $find['name'] ?? '';
$detail['assist_admin_names'] = '';
if (!empty($detail['assist_admin_ids'])) {
$assist_admin_names = Db::name('Admin')->where('id', 'in', $detail['assist_admin_ids'])->column('name');
$detail['assist_admin_names'] = implode(',', $assist_admin_names);
}
$detail['priority_name'] = self::$Priority[(int)$detail['priority']];
$detail['flow_name'] = self::$FlowStatus[(int)$detail['flow_status']];
$detail['times'] = time_trans($detail['create_time']);
$detail['end_time'] = date('Y-m-d H:i', $detail['end_time']);
$detail['delay'] = 0;
if ($detail['over_time'] > 0 && $detail['flow_status'] > 3 && $detail['initial_end_time'] < time()) {
$detail['delay'] = countDays(date('Y-m-d', $detail['initial_end_time']), date('Y-m-d', $detail['over_time']));
}
if ($detail['over_time'] == 0 && $detail['flow_status'] < 2 && $detail['initial_end_time'] < time()) {
$detail['delay'] = countDays(date('Y-m-d', time()), $detail['initial_end_time']);
}
}
return $detail;
}
}

View File

@ -24,6 +24,7 @@ use app\common\model\user\UserAuth;
use app\common\service\wechat\WeChatConfigService;
use EasyWeChat\Pay\Application;
use EasyWeChat\Pay\Message;
use think\facade\Log;
/**
@ -366,6 +367,7 @@ class WeChatPayService extends BasePayService
$server = $this->app->getServer();
// 支付通知
$server->handlePaid(function (Message $message) {
Log::info('wechat pay notify', ['trade_state' => $message['trade_state'], 'out_trade_no' => $message['out_trade_no'], 'transaction_id' => $message['transaction_id'], 'attach' => $message['attach']]);
if ($message['trade_state'] === 'SUCCESS') {
$extra['transaction_id'] = $message['transaction_id'];
$attach = $message['attach'];

65
config/approve.php Normal file
View File

@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | 审批类型
// +----------------------------------------------------------------------
return [
// 审批类型
'type' => [
[
'id' => '1',
'title'=> '假勤',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '2',
'title'=> '行政',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '3',
'title'=> '财务',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '4',
'title'=> '人事',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '5',
'title'=> '其他',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '9',
'title'=> '任务',
'db_type'=>1,
'db_name'=>'',
],
[
'id' => '6',
'title'=> '报销' ,
'db_type'=>2,
'db_name'=>'',
],
[
'id' => '7',
'title'=> '发票',
'db_type'=>3,
'db_name'=>'',
],
[
'id' => '8',
'title'=> '合同',
'db_type'=>4,
'db_name'=>'',
]
],
];

View File

@ -7,7 +7,7 @@ return [
// 默认日志记录通道
'default' => env('log.channel', 'file'),
// 日志记录级别
'level' => [],
'level' => ['info', 'error', 'sql'],
// 日志类型记录的通道 ['error'=>'email',...]
'type_channel' => [],
// 关闭全局日志写入