Files
duolamaojiazhen/application/admin/logic/OaLogic.php
2025-12-22 13:59:40 +08:00

140 lines
5.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 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团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\logic\LogicBase;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
use think\Db;
use EasyWeChat\Kernel\Exceptions\Exception;
class OaLogic extends LogicBase{
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', 'LikeShop'),
'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 setOa($post){
if($post){
if(!isset($post['encryption_type'])){
$post['encryption_type'] = '';
}
ConfigServer::set('oa','name',$post['name']);
ConfigServer::set('oa','original_id',$post['original_id']);
ConfigServer::set('oa','qr_code',$post['qr_code']);
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']);
}
return true;
}
public static function pulishMenu($buttons){
try {
$config = WeChatServer::getOaConfig();
if(empty($config['app_id']) || empty($config['secret'])){
return self::dataError('请先配置微信公众号参数');
}
$app = Factory::officialAccount($config);
$result = $app->menu->create($buttons);
if($result['errcode'] == 0){
ConfigServer::set('menu','wechat_menu',$buttons);
return self::dataSuccess('菜单发布成功');
}
return self::dataError('菜单发布失败:'.json_encode($result));
} catch (Exception $e){
return self::dataError($e->getMessage());
}
}
public static function data($get){
$where = [];
// //查询
if(isset($get['order_sn']) && $get['order_sn']!=''){
$where[] = ['order_sn','=',$get['order_sn']];
}
if(isset($get['order_sn']) && $get['order_sn']!=''){
$where[] = ['order_sn','=',$get['order_sn']];
}
if(isset($get['phone']) && $get['phone']!=''){
// $where[] = [$get['phone'],'like','%'.$get['phone'].'%'];
$where[] = ['phone','=',$get['phone']];
}
if(isset($get['area_id']) && $get['area_id']!=''){
$where[] = ['area_id','=',$get['area_id']];
}
if(isset($get['channel_id']) && $get['channel_id']!=''){
$where[] = ['channel_id','=',$get['channel_id']];
}
if(isset($get['status']) && $get['status']!=''){
$where[] = ['status','=',$get['status']];
}
//下单时间检索
if(isset($get['start_time']) && $get['start_time']!=''){
$where[] = ['createtime','>=',strtotime($get['start_time'])];
}
if(isset($get['end_time']) && $get['end_time']!=''){
$where[] = ['createtime','<=',strtotime($get['end_time'])];
}
if(isset($get['consignee']) && $get['consignee']!=''){
$where[] = ['consignee', 'like', '%' . $get['consignee'] . '%'];
}
$user_count =Db::name('order_yearcard')
->where($where)
->count();
$user_list =Db::name('order_yearcard')
->where($where)
->page($get['page'],$get['limit'])
->order('id desc')
->select();
return ['count'=>$user_count , 'lists'=>$user_list];
}
}