mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-12 10:52:48 +00:00
update niucloud
This commit is contained in:
parent
f3b5985c79
commit
fea7a98dce
@ -52,8 +52,7 @@ class Version extends BaseAdminController
|
||||
$data = $this->request->params([
|
||||
['desc', '']
|
||||
]);
|
||||
$id = (new WeappVersionService())->add($data);
|
||||
return success('ADD_SUCCESS');
|
||||
return success(data:(new WeappVersionService())->add($data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,35 +77,11 @@ class Version extends BaseAdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态
|
||||
* @param int $id
|
||||
* @param $status
|
||||
* 获取小程序上传日志
|
||||
* @param string $key
|
||||
* @return Response
|
||||
*/
|
||||
public function setStatus(int $id, $status)
|
||||
{
|
||||
(new WeappVersionService())->setStatus($id, $status);
|
||||
return success('EDIT_SUCCESS');
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序包上传
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function document()
|
||||
{
|
||||
$data = $this->request->params([
|
||||
['file', 'file'],
|
||||
]);
|
||||
return success(data: (new WeappVersionService())->document($data['file']));
|
||||
}
|
||||
|
||||
public function examine()
|
||||
{
|
||||
$data = $this->request->params([
|
||||
['id', ''],
|
||||
]);
|
||||
(new WeappVersionService())->weappExamine($data['id']);
|
||||
public function uploadLog(string $key) {
|
||||
return success(data: (new WeappVersionService())->getUploadLog($key));
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,17 +29,14 @@ Route::group('weapp', function () {
|
||||
//同步订阅消息
|
||||
Route::put('template/sync', 'weapp.Template/sync');
|
||||
Route::get('template', 'weapp.Template/lists');
|
||||
|
||||
//上传版本包
|
||||
Route::post('upload', 'weapp.Version/document');
|
||||
//添加版本
|
||||
Route::post('version', 'weapp.Version/add');
|
||||
//版本列表
|
||||
Route::get('version', 'weapp.Version/lists');
|
||||
//版本 提交审核
|
||||
Route::post('examine', 'weapp.Version/examine');
|
||||
//获取预览码
|
||||
Route::get('preview', 'weapp.Version/preview');
|
||||
//获取小程序上传日志
|
||||
Route::get('upload/:key', 'weapp.Version/uploadLog');
|
||||
})->middleware([
|
||||
AdminCheckToken::class,
|
||||
AdminCheckRole::class,
|
||||
|
||||
@ -71,10 +71,10 @@ return
|
||||
]
|
||||
],
|
||||
[
|
||||
'menu_name' => '网站装修',
|
||||
'menu_name' => '装修发布',
|
||||
'menu_key' => 'website',
|
||||
'menu_type' => 0,
|
||||
'icon' => 'iconfont-iconwangzhan1',
|
||||
'icon' => 'iconfont-iconicon_huojian',
|
||||
'api_url' => '',
|
||||
'router_path' => 'website',
|
||||
'view_path' => '',
|
||||
@ -183,7 +183,7 @@ return
|
||||
'menu_name' => '渠道管理',
|
||||
'menu_key' => 'channel',
|
||||
'menu_type' => 0,
|
||||
'icon' => 'iconfont-iconqudaoguanli2',
|
||||
'icon' => 'iconfont-iconicon_huojian',
|
||||
'api_url' => '',
|
||||
'router_path' => 'channel',
|
||||
'view_path' => '',
|
||||
|
||||
@ -44,7 +44,7 @@ class WeappVersionService extends BaseAdminService
|
||||
$version_no += 1;
|
||||
$version = "1.0.{$version_no}";
|
||||
|
||||
(new CoreWeappCloudService())->uploadWeapp([
|
||||
$upload_res = (new CoreWeappCloudService())->uploadWeapp([
|
||||
'version' => $version,
|
||||
'desc' => $data['desc'] ?? ''
|
||||
]);
|
||||
@ -53,7 +53,8 @@ class WeappVersionService extends BaseAdminService
|
||||
'version' => $version,
|
||||
'version_no' => $version_no,
|
||||
'desc' => $data['desc'] ?? '',
|
||||
'create_time' => time()
|
||||
'create_time' => time(),
|
||||
'task_key' => $upload_res['key']
|
||||
]);
|
||||
return $res->id;
|
||||
}
|
||||
@ -73,7 +74,7 @@ class WeappVersionService extends BaseAdminService
|
||||
*/
|
||||
public function getPage(array $where = [])
|
||||
{
|
||||
$field = 'id, version, version_no, desc, create_time, status, fail_reason';
|
||||
$field = 'id, version, version_no, desc, create_time, status, fail_reason, task_key';
|
||||
$order = 'version_no desc';
|
||||
$search_model = $this->model->field($field)->order($order)->append(['status_name']);
|
||||
return $this->pageQuery($search_model);
|
||||
@ -93,20 +94,6 @@ class WeappVersionService extends BaseAdminService
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param $file
|
||||
* @param string $type
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function document($file){
|
||||
$core_upload_service = new CoreUploadService();
|
||||
$type = FileDict::APPLET;
|
||||
$dir = '/applet/'.$type.'/version/';
|
||||
return $core_upload_service->document($file, $type, $dir, StorageDict::LOCAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param int $id
|
||||
@ -117,20 +104,12 @@ class WeappVersionService extends BaseAdminService
|
||||
return true;
|
||||
}
|
||||
|
||||
public function weappExamine($id)
|
||||
{
|
||||
$info = $this->model->where([['id', '=', $id]])->findOrEmpty()->toArray();
|
||||
if(empty($info)) return;
|
||||
|
||||
$url = 'http://127.0.0.1:36949/v2/upload?project='. $info['path'] .'&version=v'.$info['code'];
|
||||
// $url = "http://www.example.com/api/getdata.php?id=12";
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
echo $output;
|
||||
|
||||
|
||||
/**
|
||||
* 获取小程序上传日志
|
||||
* @param string $key
|
||||
* @return null
|
||||
*/
|
||||
public function getUploadLog(string $key) {
|
||||
return (new CoreWeappCloudService())->getWeappCompileLog($key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的多应用管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\core\member;
|
||||
|
||||
use app\model\member\MemberAddress;
|
||||
use app\model\member\MemberLabel;
|
||||
use core\base\BaseCoreService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 会员标签服务层
|
||||
* Class CoreMemberAccountService
|
||||
* @package app\service\core\member
|
||||
*/
|
||||
class CoreMemberAddressService extends BaseCoreService
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->model = new MemberAddress();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取会员默认地址
|
||||
* @param int $member_id
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultAddressByMemberId(int $member_id){
|
||||
$field = 'id,member_id,name,mobile,telephone,province_id,city_id,district_id,community_id,address,full_address,longitude,latitude,is_default,type';
|
||||
return $this->model->where([['member_id', '=', $member_id]])->field($field)->findOrEmpty()->toArray();
|
||||
}
|
||||
}
|
||||
@ -58,11 +58,11 @@ class CoreMemberService extends BaseCoreService
|
||||
* @param int $member_id
|
||||
* @return array
|
||||
*/
|
||||
public function getInfoByMemberId(int $member_id){
|
||||
public function getInfoByMemberId(int $member_id, string $field = '*'){
|
||||
$where = array(
|
||||
['member_id', '=', $member_id]
|
||||
);
|
||||
return $this->model->where($where)->findOrEmpty()->toArray();
|
||||
return $this->model->where($where)->field($field)->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -34,6 +34,7 @@ class CoreConfigService extends BaseCoreService
|
||||
*/
|
||||
public function getConfig(string $key)
|
||||
{
|
||||
|
||||
$where = array(
|
||||
['config_key', '=', $key],
|
||||
);
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
|
||||
namespace app\service\core\weapp;
|
||||
|
||||
use app\dict\sys\CloudDict;
|
||||
use app\model\addon\Addon;
|
||||
use app\model\weapp\WeappVersion;
|
||||
use app\service\core\addon\CoreAddonDevelopDownloadService;
|
||||
use app\service\core\niucloud\CoreCloudBaseService;
|
||||
use core\exception\CommonException;
|
||||
@ -68,9 +70,10 @@ class CoreWeappCloudService extends CoreCloudBaseService
|
||||
'appid' => $config['app_id'],
|
||||
'version' => $data['version'] ?? '',
|
||||
'desc' => $data['desc'] ?? '',
|
||||
'do' => 1
|
||||
'do' => 1,
|
||||
'timestamp' => time()
|
||||
];
|
||||
(new CloudService())->httpPost('cloud/wechat?' . http_build_query($query), [
|
||||
(new CloudService())->httpPost('cloud/weapp?' . http_build_query($query), [
|
||||
'multipart' => [
|
||||
[
|
||||
'name' => 'file',
|
||||
@ -83,7 +86,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
|
||||
// 删除临时文件
|
||||
del_target_dir(runtime_path() . 'backup' . DIRECTORY_SEPARATOR . 'weapp', true);
|
||||
|
||||
return ['key' => $task_key];
|
||||
return ['key' => $query['timestamp'] ];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,6 +128,31 @@ class CoreWeappCloudService extends CoreCloudBaseService
|
||||
$query = [
|
||||
'authorize_code' => $this->auth_code,
|
||||
];
|
||||
return (new CloudService())->httpGet('cloud/get_wechat_preview?' . http_build_query($query));
|
||||
return (new CloudService())->httpGet('cloud/get_weapp_preview?' . http_build_query($query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序编译日志
|
||||
* @param string $timestamp
|
||||
* @return void
|
||||
*/
|
||||
public function getWeappCompileLog(string $timestamp) {
|
||||
$query = [
|
||||
'authorize_code' => $this->auth_code,
|
||||
'timestamp' => $timestamp
|
||||
];
|
||||
$build_log = (new CloudService())->httpGet('cloud/get_weapp_logs?' . http_build_query($query));
|
||||
|
||||
if (isset($build_log['data']) && isset($build_log['data'][0]) && is_array($build_log['data'][0])) {
|
||||
$last = end($build_log['data'][0]);
|
||||
if ($last['code'] == 0) {
|
||||
(new WeappVersion())->update(['status' => CloudDict::APPLET_UPLOAD_FAIL, 'fail_reason' => $last['msg'] ?? '', 'update_time' => time() ], ['task_key' => $timestamp]);
|
||||
return $build_log;
|
||||
}
|
||||
if ($last['percent'] == 100) {
|
||||
(new WeappVersion())->update(['status' => CloudDict::APPLET_UPLOAD_SUCCESS, 'update_time' => time() ], ['task_key' => $timestamp]);
|
||||
}
|
||||
}
|
||||
return $build_log;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user