调试app支付回调

This commit is contained in:
luofei 2023-07-24 13:38:45 +08:00
parent 7b448db370
commit 8ac105a4aa
3 changed files with 66 additions and 59 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

@ -120,4 +120,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

@ -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', $message->toArray());
if ($message['trade_state'] === 'SUCCESS') {
$extra['transaction_id'] = $message['transaction_id'];
$attach = $message['attach'];