wang hou sheng 10 months ago
parent 20a6168c33
commit df0e2b4ba1
  1. 86
      app/admin/controller/Wxserve.php
  2. 16
      app/api/controller/Wxserver.php
  3. 23
      app/common/library/wxserver/Server.php

@ -4,8 +4,11 @@ declare (strict_types=1);
namespace app\admin\controller;
use app\common\library\wxserver\Server;
use cores\exception\BaseException;
use PHPQRCode\QRcode;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\response\Json;
@ -70,4 +73,87 @@ class Wxserve extends Controller
}
return $this->renderSuccess(['list' => $list, 'total' => $total]);
}
/**
* @notes:草稿箱列表
* @return Json
* @author: wanghousheng
*/
public function templatedraftlist(): Json
{
$obj = new Server();
$list = $obj->getTemplateDraftList();
return $this->renderSuccess($list);
}
/**
* @notes:添加草稿到模板中
* @return Json
* @author: wanghousheng
*/
public function addTotemplate(): Json
{
$draft_id = $this->request->get('draft_id');
if ($draft_id) {
$obj = new Server();
$res = $obj->addTotemplate($draft_id);
if ($res) {
return $this->renderSuccess('success');
}
}
return $this->renderError('操作失败');
}
/**
* @notes:获取模板列表
* @return Json
* @author: wanghousheng
*/
public function templatelist(): Json
{
$obj = new Server();
$list = $obj->getTemplatelist();
return $this->renderSuccess($list);
}
/**
* @notes:删除模板
* @return Json
* @author: wanghousheng
*/
public function delTemplatelist(): Json
{
$template_id = $this->request->get('template_id');
if ($template_id) {
$obj = new Server();
$res = $obj->deleTetemplate($template_id);
if ($res) {
return $this->renderSuccess('success');
}
}
return $this->renderError('操作失败');
}
/**
* @notes:提交版本审核
* @return Json
* @throws DbException
* @throws BaseException
* @throws DataNotFoundException
* @throws ModelNotFoundException
* @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) {
return $this->renderSuccess('success');
}
}
return $this->renderError('操作失败');
}
}

@ -4,25 +4,9 @@ declare (strict_types=1);
namespace app\api\controller;
use cores\BaseController;
use think\response\Json;
class Wxserver extends BaseController
{
public function index(): Json
{
$obj = new \app\common\library\wxserver\Server();
$url = $this->request->domain(true) . '/api/wxserver/redirect';
$jumUrl = $obj->jumpH5Url($url);
return $this->renderSuccess(compact('jumUrl'));
}
public function indexCount()
{
$obj = new \app\common\library\wxserver\Server();
$list = $obj->getStoreId('wxd87b1a7332d974d0');
return $this->renderSuccess(compact('list'));
}
public function verifyTicket()
{
$xmlData = file_get_contents("php://input");

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace app\common\library\wxserver;
use app\common\model\WxserverAccount;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -115,21 +116,35 @@ class Server
* @notes:发布版本
* @param $appid
* @param $template_id
* @param $version
* @param $desc
* @return true|void
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws ModelNotFoundException|BaseException
* @author: wanghousheng
*/
public function commit($appid, $template_id, $version, $desc)
public function commit($appid, $template_id)
{
$version = '';
$desc = '';
$model = new WxserverAccount();
$info = $model->where(['appid' => $appid])->find();
if (!empty($info)) {
$info = $info->toArray();
$access_token = $this->authorizerAccessToken($appid, $info['refresh_token']);
//获取模板
$templatelist = $this->getTemplatelist();
if ($templatelist) {
foreach ($templatelist as $value) {
if (!empty($value['user_version']) && !empty($value['user_desc']) && $value['template_id'] == $template_id) {
$version = $value['user_version'];
$desc = $value['user_desc'];
break;
}
}
}
if ($version == '' || $desc == '') {
throwError('模板不存在');
}
$data['template_id'] = $template_id;
$data['user_version'] = $version;
$data['user_desc'] = $desc;

Loading…
Cancel
Save