其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

View File

@ -0,0 +1,85 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use think\facade\Env;
class HfiveLogic extends Logic
{
/**
* 获取H5商城设置
*/
public static function getConfig()
{
$config = [
'is_open' => ConfigServer::get('h5', 'is_open', 1),
'page' => ConfigServer::get('h5', 'page', 1),
'page_url' => ConfigServer::get('h5', 'page_url', ''),
'h5_url' => request()->domain() . '/mobile'
];
return $config;
}
/**
* H5商城设置
*/
public static function set($params)
{
ConfigServer::set('h5', 'is_open', $params['is_open']);
ConfigServer::set('h5', 'page', $params['page']);
ConfigServer::set('h5', 'page_url', $params['page_url']);
// 恢复原入口
if(file_exists('./mobile/index_lock.html')) {
// 存在则原商城入口被修改过,先清除修改后的入口
unlink('./mobile/index.html');
// 恢复原入口
rename('./mobile/index_lock.html', './mobile/index.html');
// 删除旧的缓存文件
array_map('unlink', glob('../runtime/index/temp/'.'*.php'));
}
// H5商城关闭 且 显示空白页
if($params['is_open'] == 0 && $params['page'] == 1) {
// 变更文件名
rename('./mobile/index.html', './mobile/index_lock.html');
// 创建新空白文件
$newfile = fopen('./mobile/index.html', 'w');
fclose($newfile);
}
// H5商城关闭 且 跳转指定页
if($params['is_open'] == 0 && $params['page'] == 2 && !empty($params['page_url'])) {
// 变更文件名
rename('./mobile/index.html', './mobile/index_lock.html');
// 创建重定向文件
$newfile = fopen('./mobile/index.html', 'w');
$content = '<script>window.location.href = "' . $params['page_url'] . '";</script>';
fwrite($newfile, $content);
fclose($newfile);
}
}
}

View File

@ -0,0 +1,189 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
use think\facade\Db;
class MnpLogic extends Logic
{
/**
* 获取小程序配置
*/
public static function getMnp()
{
$domain_name = $_SERVER['SERVER_NAME'];
$qr_code = ConfigServer::get('mnp', 'qr_code', '');
$config = [
'name' => ConfigServer::get('mnp', 'name', ''),
'original_id' => ConfigServer::get('mnp', 'original_id', ''),
'qr_code' => $qr_code,
'abs_qr_code' => UrlServer::getFileUrl($qr_code),
'app_id' => ConfigServer::get('mnp', 'app_id', ''),
'app_secret' => ConfigServer::get('mnp', 'secret', ''),
'request_domain' => 'https://'.$domain_name,
'socket_domain' => 'wss://'.$domain_name,
'uploadfile_domain' => 'https://'.$domain_name,
'downloadfile_domain' => 'https://'.$domain_name,
'udp_domain' => 'udp://'.$domain_name,
'tcp_domain' => 'tcp://'.$domain_name,
'business_domain' => $domain_name,
'url' => url('api/wechat/index',[],'',true),
'token' => ConfigServer::get('mnp', 'token', 'LikeMall'),
'encoding_ses_key' => ConfigServer::get('mnp', 'encoding_ses_key', ''),
'encryption_type' => ConfigServer::get('mnp', 'encryption_type', ''),
'data_type' => ConfigServer::get('mnp', 'data_type', ''),
// 小程序同步发货开关 1开启 0关闭
'express_send_sync' => ConfigServer::get('mnp', 'express_send_sync', 1),
//代码上传密钥
'private_key' => ConfigServer::get('mnp', 'private_key', ''),
];
return $config;
}
public static function setMnp($post)
{
if($post){
$encryption_type = $post['encryption_type'] ?? '';
$data_type = $post['data_type'] ?? '';
ConfigServer::set('mnp','name',$post['name']);
ConfigServer::set('mnp','original_id',$post['original_id']);
ConfigServer::set('mnp','qr_code', $post['qr_code']);
ConfigServer::set('mnp','app_id',$post['app_id']);
ConfigServer::set('mnp','secret',$post['app_secret']);
// ConfigServer::set('mnp','token',$post['token']);
// ConfigServer::set('mnp','encoding_ses_key',$post['encoding_ses_key']);
// ConfigServer::set('mnp','encryption_type', $encryption_type);
// ConfigServer::set('mnp','data_type', $data_type);
ConfigServer::set('mnp','express_send_sync', $post['express_send_sync'] ?? 1);
if (!empty($post['private_key'])) {
$saveDir = '../extend/miniprogram-ci/';
if (!file_exists($saveDir)) {
mkdir($saveDir, 0775, true);
}
//保存文件
$savePath = $saveDir.'private.'.$post['app_id'].'.key';
$f = fopen($savePath, 'w');
fwrite($f, $post['private_key']);
fclose($f);
ConfigServer::set('mnp','private_key',$post['private_key']);
}
}
return true;
}
//一键上传
public static function uploadMnp($post)
{
Db::startTrans();
try {
//校验是否已安装miniprogram-ci工具
if (!file_exists('../extend/miniprogram-ci/node_modules/miniprogram-ci')) {
throw new \think\Exception('请先安装miniprogram-ci工具');
}
$baseUrl = 'mp-weixin/common/vendor.js';
//判断是否已存在 vendor_example.js 备份文件,如果不存在则备份
$exampleUrl = 'mp-weixin/common/vendor_example.js';
if(!file_exists($exampleUrl)){
copy($baseUrl, $exampleUrl);
}
//更换小程序域名
$baseUrlData = file_get_contents($exampleUrl);
$domain = request()->domain(true);
$baseUrlData = str_replace("[baseUrl]",$domain,$baseUrlData);
$f = fopen($baseUrl,"w");
fwrite($f,$baseUrlData);
fclose($f);
//插入上传日志
$uploadMnpLogId = Db::name('upload_mnp_log')->insertGetId([
'admin_id' => $post['admin_id'],
'version' => $post['version'],
'create_time' => time(),
]);
//上传小程序代码
$data = [
'version' => $post['version'],
'desc' => $post['upload_desc'] ?? '',
'appid' => ConfigServer::get('mnp', 'app_id', ''),
];
$json_data = json_encode($data);
$command = 'node ../extend/miniprogram-ci/upload.js '.escapeshellarg($json_data).' 2>&1';
$output=null;
$retval = null;
exec($command, $output, $retval);
//获取错误信息
$errors = preg_grep('/\[error\]/', is_array($output) ? $output : [$output]);
if ($retval || !empty($errors)) {
//错误
Db::name('upload_mnp_log')->where('id', $uploadMnpLogId)->update([
'status' => 2,
'fail_reason' => is_array($output) ? json_encode($output) : $output,
]);
} else {
//成功
Db::name('upload_mnp_log')->where('id', $uploadMnpLogId)->update([
'status' => 1
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
return $e->getMessage();
}
}
//小程序上传日志
public static function uploadMnpLog($get)
{
$lists = Db::name('upload_mnp_log')
->field('admin_id,version,status,fail_reason,create_time')
->withAttr('admin_desc', function ($value,$data){
return Db::name('admin')->where(['id'=>$data['admin_id']])->value('name');
})
->withAttr('status_desc', function ($value,$data){
$statusDesc = ['上传中','上传成功','上传失败'];
return $statusDesc[$data['status']];
})
->withAttr('create_time', function ($value,$data){
return date('Y-m-d H:i:s', $data['create_time']);
})
->page($get['page'], $get['limit'])
->order('id', 'desc')
->select();
$count = Db::name('upload_mnp_log')->count();
return ['count' => $count, 'lists' => $lists];
}
}

View File

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
use EasyWeChat\Kernel\Exceptions\Exception;
class OaLogic extends Logic
{
public static function setOa($post)
{
ConfigServer::set('oa','name', trim($post['name']));
ConfigServer::set('oa','original_id', trim($post['original_id']));
ConfigServer::set('oa','app_id',$post['app_id']);
ConfigServer::set('oa','secret',$post['app_secret']);
ConfigServer::set('oa','token',$post['token']);
ConfigServer::set('oa','encoding_ses_key',$post['encoding_ses_key']);
ConfigServer::set('oa','encryption_type',$post['encryption_type']);
ConfigServer::set('oa','qr_code',$post['qr_code']);
}
public static function getOa()
{
$domain_name = $_SERVER['SERVER_NAME'];
$qr_code = ConfigServer::get('oa', 'qr_code', '');
$config = [
'name' => ConfigServer::get('oa', 'name', ''),
'original_id' => ConfigServer::get('oa', 'original_id', ''),
'qr_code' => $qr_code,
'abs_qr_code' => UrlServer::getFileUrl($qr_code),
'app_id' => ConfigServer::get('oa', 'app_id', ''),
'app_secret' => ConfigServer::get('oa', 'secret', ''),
'url' => url('api/wechat/index',[],'',true),
'token' => ConfigServer::get('oa', 'token', 'LikeMall'),
'encoding_ses_key' => ConfigServer::get('oa', 'encoding_ses_key', ''),
'encryption_type' => ConfigServer::get('oa', 'encryption_type', 1),
'business_domain' => $domain_name,
'safety_domain' => $domain_name,
'auth_domain' => $domain_name,
];
return $config;
}
/**
* 发布菜单
*/
public static function pulishMenu($menu)
{
try {
$config = WeChatServer::getOaConfig();
if(empty($config['app_id']) || empty($config['secret'])){
throw new \think\Exception('请先配置微信公众号参数');
}
$app = Factory::officialAccount($config);
$result = $app->menu->create($menu);
if($result['errcode'] == 0){
ConfigServer::set('menu','wechat_menu',$menu);
return true;
}
self::$error = '菜单发布失败:'.json_encode($result);
return false;
} catch (\think\Exception $e){
self::$error = $e->getError();
return false;
} catch(\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View File

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
class OpLogic extends Logic
{
public static function getConfig($config_list)
{
$config = [];
foreach ($config_list as $config_name){
$value = ConfigServer::get('op', $config_name, '');
$config[$config_name] = $value;
}
return $config;
}
public static function setConfig($config_list)
{
foreach ($config_list as $config_name => $config_value){
ConfigServer::set('op',$config_name,$config_value);
}
return true;
}
}

View File

@ -0,0 +1,84 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
class PcLogic extends Logic
{
/**
* 获取PC商城设置
*/
public static function getConfig()
{
$config = [
'is_open' => ConfigServer::get('pc', 'is_open', 1),
'page' => ConfigServer::get('pc', 'page', 1),
'page_url' => ConfigServer::get('pc', 'page_url', ''),
'pc_url' => request()->domain() . '/pc'
];
return $config;
}
/**
* PC商城设置
*/
public static function set($params)
{
ConfigServer::set('pc', 'is_open', $params['is_open']);
ConfigServer::set('pc', 'page', $params['page']);
ConfigServer::set('pc', 'page_url', $params['page_url']);
// 恢复原入口
if(file_exists('./pc/index_lock.html')) {
// 存在则原商城入口被修改过,先清除修改后的入口
unlink('./pc/index.html');
// 恢复原入口
rename('./pc/index_lock.html', './pc/index.html');
// 删除旧的缓存文件
array_map('unlink', glob('../runtime/index/temp/'.'*.php'));
}
// pc商城关闭 且 显示空白页
if($params['is_open'] == 0 && $params['page'] == 1) {
// 变更文件名
rename('./pc/index.html', './pc/index_lock.html');
// 创建新空白文件
$newfile = fopen('./pc/index.html', 'w');
fclose($newfile);
}
// pc商城关闭 且 跳转指定页
if($params['is_open'] == 0 && $params['page'] == 2 && !empty($params['page_url'])) {
// 变更文件名
rename('./pc/index.html', './pc/index_lock.html');
// 创建重定向文件
$newfile = fopen('./pc/index.html', 'w');
$content = '<script>window.location.href = "' . $params['page_url'] . '";</script>';
fwrite($newfile, $content);
fclose($newfile);
}
}
}

View File

@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic\wechat;
use app\common\basics\Logic;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
use EasyWeChat\Kernel\Exceptions\Exception;
use app\common\model\wechat\WechatReply;
use app\common\model\wechat\Wechat;
class ReplyLogic extends Logic
{
public static function lists($get)
{
$where[] = ['del','=',0];
if(isset($get['type'])){ // 回复类型
$where[] = ['reply_type','=',$get['type']];
}
$count = WechatReply::where($where)->count();
$list = WechatReply::where($where)
->order([
'sort' => 'asc',
'id' => 'desc'
])
->page($get['page'],$get['limit'])
->select()
->toArray();
foreach ($list as $key => $reply) {
// 内容类型
$reply['content_type'] && $list[$key]['content_type'] = '文本';
// 匹配类型
switch ($reply['matching_type']){
case 1:
$list[$key]['matching_type'] = '全匹配';
break;
case 2:
$list[$key]['matching_type'] = '模糊匹配';
break;
}
}
return ['count'=>$count,'list'=>$list];
}
public static function add($post)
{
$post['create_time'] = time();
$post['del'] = 0;
if($post['reply_type'] !== WeChat::msg_type_text && $post['status']){
// 除了关键词回复,其他回复类型开启记录只允许一条,若当前正在新增的记录将是开启状态,则该回复类型下的现有记录需先更新为停用状态
WechatReply::where(['reply_type'=>$post['reply_type']])->update(['update_time'=>time(),'status'=>0]);
}
return WechatReply::insert($post);
}
public static function getReply($id)
{
$detail = WechatReply::findOrEmpty($id);
$detail = $detail->isEmpty() ? [] : $detail->toArray();
return $detail;
}
public static function edit($post){
$post['update_time'] = time();
if($post['reply_type'] !== WeChat::msg_type_text && $post['status']){
WechatReply::where(['reply_type'=>$post['reply_type']])->update(['update_time'=>time(),'status'=>0]);
}
return WechatReply::where(['id'=>$post['id']])->update($post);
}
public static function del($id){
return WechatReply::where(['id'=>$id])->update(['update_time'=>time(),'del'=>1]);
}
public static function changeFields($id,$field,$field_value,$reply_type){
if( 'status' === $field && $field_value && $reply_type !== WeChat::msg_type_text){
WechatReply::where(['reply_type'=>$reply_type])->update(['update_time'=>time(),'status'=>0]);
}
return WechatReply::where(['id'=>$id])->update(['update_time'=>time(),$field=>$field_value]);
}
}