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