wang hou sheng 11 months ago
parent f7c64f71f7
commit c3733e04e2
  1. 26
      app/admin/controller/Wxserve.php
  2. 58
      app/job/controller/Wxserver.php

@ -4,7 +4,7 @@ declare (strict_types=1);
namespace app\admin\controller; namespace app\admin\controller;
use app\common\library\wxserver\Server; use app\common\library\wxserver\Server;
use cores\exception\BaseException; use app\job\controller\Wxserver as WxserverJob;
use PHPQRCode\QRcode; use PHPQRCode\QRcode;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\facade\Db; use think\facade\Db;
@ -172,17 +172,18 @@ class Wxserve extends Controller
/** /**
* @notes:提交体验版 * @notes:提交体验版
* @return Json * @return Json
* @throws BaseException
* @author: wanghousheng * @author: wanghousheng
*/ */
public function commit(): Json public function commit(): Json
{ {
$appid = $this->request->get('appid'); $appid = $this->request->get('appid');
$template_id = $this->request->get('template_id'); $template_id = $this->request->get('template_id');
if ($template_id && $appid) { if ($appid && $template_id) {
$obj = new Server(); $appids = explode(',', $appid);
$res = $obj->commit($appid, $template_id); if ($appids) {
if ($res) { foreach ($appids as $item) {
WxserverJob::dispatch(['appid' => $item, 'template_id' => $template_id]);
}
return $this->renderSuccess('success'); return $this->renderSuccess('success');
} }
} }
@ -215,16 +216,13 @@ class Wxserve extends Controller
{ {
$appid = $this->request->get('appid'); $appid = $this->request->get('appid');
if ($appid) { if ($appid) {
$obj = new Server(); $appids = explode(',', $appid);
$res = $obj->privacyInfo($appid); if ($appids) {
if ($res == 'ok') { foreach ($appids as $item) {
if ($obj->submitAudit($appid)) { WxserverJob::dispatch(['appid' => $item]);
return $this->renderSuccess('success');
} }
} else { return $this->renderSuccess('success');
return $this->renderError($res);
} }
} }
return $this->renderError('操作失败'); return $this->renderError('操作失败');
} }

@ -0,0 +1,58 @@
<?php
namespace app\job\controller;
use app\common\library\wxserver\Server;
use cores\BaseJob;
use cores\exception\BaseException;
use cores\traits\QueueTrait;
class Wxserver extends BaseJob
{
use QueueTrait;
/**
* 消费队列任务:输出测试信息
* @param array $data 参数
* @return bool 返回结果
* @throws BaseException
*/
public function handle(array $data): bool
{
if (!empty($data['appid'])) {
if (!empty($data['template_id'])) {
$this->sendTestVersion($data['appid'], $data['template_id']);
} else {
$this->sendOfficialVersion($data['appid']);
}
}
return true;
}
/**
* @notes:发布正式版
* @param $appid
* @author: wanghousheng
*/
private function sendOfficialVersion($appid)
{
$obj = new Server();
$res = $obj->privacyInfo($appid);
if ($res == 'ok') {
$obj->submitAudit($appid);
}
}
/**
* @notes:发布体验版
* @param $appid
* @param $template_id
* @throws BaseException
* @author: wanghousheng
*/
private function sendTestVersion($appid, $template_id)
{
$obj = new Server();
$res = $obj->commit($appid, $template_id);
}
}
Loading…
Cancel
Save