<?php
/**
*
* Copyright FaShop
* License http://www.fashop.cn
* link http://www.fashop.cn
* Created by FaShop.
* User: hanwenbo
* Date: 2017/11/26
* Time: 下午9:01
*
*/
namespace App\HttpController\Admin;
use App\Utils\Code;
use App\Logic\Wechat\Factory as WechatFactory;
use EasySwoole\Core\Utility\File;
/**
* 微信管理
* Class Wechat
* @package App\HttpController\Admin
* @property \App\Logic\Wechat\Factory $wechat
*/
class Wechat extends Admin
{
protected $wechat;
protected function _initialize()
{
$this->wechat = new WechatFactory();
}
/**
* 获得token
* @method GET
* @param bool $refresh
* @author 韩文博
*/
public function getToken()
{
if( isset( $this->get['refresh'] ) ){
$token = $this->wechat->accessToken->getToken();
} else{
$token = $this->wechat->accessToken->getToken( true );
}
return $this->send( Code::success, $token );
}
/**
* 读取(查询)已设置菜单
* @method GET
* @author 邓凯
*/
public function menuList()
{
$list = $this->wechat->menu->list();
return $this->send( Code::success, $list );
}
/**
* 获取当前菜单
* @method GET
* @author 邓凯
*/
public function menuCurrent()
{
$list = $this->wechat->menu->current();
return $this->send( Code::success, $list );
}
/**
* 创建自定义菜单
* @method POST
* @param array $buttons
* @author 邓凯
*/
public function menuCreate()
{
if( $this->validate( $this->post, 'Admin/Wechat/Menu.create' ) !== true ){
return $this->send( Code::param_error, [], $this->getValidate()->getError() );
} else{
$result = $this->wechat->menu->create( $this->post['buttons'] );
return $this->send( Code::success, $result );
}
}
/**
* 删除菜单
* @method POST
* @param int $menu_id
* 有两种删除方式,一种是全部删除,另外一种是根据菜单 ID 来删除(删除个性化菜单时用,ID 从查询接口获取)
* @author 韩文博
*/
public function menuDelete()
{
if( isset( $this->post['menu_id'] ) ){
$this->wechat->menu->delete( $this->post['id'] );
} else{
$this->wechat->menu->delete();
}
return $this->send( Code::success );
}
/**
* 消息群发用户筛选
* @method POST
* @param string $condition_type 1全部粉丝 2按条件筛选 3手动选择粉丝
* @param int $sex 性别,默认全部,1男2女,3保密
* @param array $province 地区
* @param array $cost_average_price
* @param array $cost_times
* @param array $resent_cost_time
* @param array $resent_visit_time
* @param array $register_time
* @param array user_tag
* @author 韩文博
*/
public function broadcastUserSearch()
{
if( $this->validate( $this->post, 'Admin/Wechat/Broadcast.userSearch' ) !== true ){
$this->send( Code::param_error, [], $this->getValidate()->getError() );
} else{
$db = \ezswoole\Db::name( 'User' );
$db->alias( 'user' );
$db->join( "wechat_user wechat_user", 'wechat_user.openid = user.wechat_openid', 'LEFT' );
$db->join( "user_temp user_temp", 'user.id = user_temp.user_id', 'LEFT' );
if( $this->post['condition_type'] == 1 ){
} elseif( $this->post['condition_type'] == 2 ){
if( isset( $this->post['sex'] ) ){
if( $this->post['sex'] == 3 ){
$db->where( ['wechat_user.sex' => ['notin', [1, 2]]] );
} else{
$db->where( ['wechat_user.sex' => ['in', $this->post['sex']]] );
}
}
if( isset( $this->post['area'] ) ){
$db->where( ['wechat_user.province' => ['in', $this->post['province']]] );
}
if( isset( $this->post['user_tag'] ) ){
$user_tag = $this->post['user_tag'];
$db->where( function( $query ) use ( $user_tag ){
foreach( $user_tag as $tagId ){
$query->whereOr( ['wechat_user.tagid_list' => ['like', '%'.$tagId.'%']] );
}
} );
}
if( isset( $this->post['cost_average_price'] ) ){
$cost_average_price = $this->post['cost_average_price'];
$db->where( function( $query ) use ( $cost_average_price ){
foreach( $cost_average_price as $fromTo ){
$query->whereOr( ['user_temp.cost_average_price' => ['between', $fromTo]] );
}
} );
}
if( isset( $this->post['cost_times'] ) ){
$cost_times = $this->post['cost_times'];
$db->where( function( $query ) use ( $cost_times ){
foreach( $cost_times as $fromTo ){
$query->whereOr( ['user_temp.cost_times' => ['between', $fromTo]] );
}
} );
}
if( isset( $this->post['resent_cost_time'] ) ){
$resent_cost_time = $this->post['resent_cost_time'];
$db->where( function( $query ) use ( $resent_cost_time ){
foreach( $resent_cost_time as $fromTo ){
$query->whereOr( ['user_temp.resent_cost_time' => ['between', $fromTo]] );
}
} );
}
if( isset( $this->post['resent_visit_time'] ) ){
$resent_visit_time = $this->post['resent_visit_time'];
$db->where( function( $query ) use ( $resent_visit_time ){
foreach( $resent_visit_time as $fromTo ){
$query->whereOr( ['user_temp.resent_visit_time' => ['between', $fromTo]] );
}
} );
}
if( isset( $this->post['register_time'] ) ){
$register_time = $this->post['register_time'];
$db->where( function( $query ) use ( $register_time ){
foreach( $register_time as $fromTo ){
$query->whereOr( ['user_temp.register_time' => ['between', $fromTo]] );
}
} );
}
}
$db->where( ["user.wechat_openid" => ['not null']] );
$total_number = $db->count( 'DISTINCT wechat_user.openid' );
$this->send( Code::success, ['total_number' => $total_number] );
}
}
/**
* 群发当日可发送状态检查
* @method GET
* @param string $condition_type 1全部粉丝 2按条件筛选 3手动选择粉丝
* @param int $send_time
* @author 韩文博
*/
public function broadcastSurplus()
{
if( $this->validate( $this->get, 'Admin/Wechat/Broadcast.surplus' ) !== true ){
$this->send( Code::param_error, [], $this->getValidate()->getError() );
} else{
$conf = model( 'Wechat' )->getWechatInfo( ['id' => 1], 'app_key,app_secret,level' );
if( $conf['app_key'] && $conf['app_secret'] && in_array( $conf['level'], [1, 2, 3, 4] ) ){
$model = model( 'WechatBroadcast' );
// 每月4次
$send_time = $this->get['send_time'];
if( in_array( $conf['level'], [2, 4] ) ){
$beginThismonth = mktime( 0, 0, 0, date( 'm', $send_time ), 1, date( 'Y', $send_time ) );
$endThismonth = mktime( 23, 59, 59, date( 'm', $send_time ), date( 't', $send_time ), date( 'Y', $send_time ) );
$condition['send_time'] = ['between', [$beginThismonth, $endThismonth]];
$total_number = $model->where( $condition )->count();
$can_send_state = $total_number >= 4 ? 0 : 1;
} else{
$beginToday = strtotime( date( 'Y-m-d ', $send_time )."00:00:00" );
$endToday = strtotime( date( 'Y-m-d ', $send_time )."23:59:59" );;
$condition['send_time'] = ['between', [$beginToday, $endToday]];
$total_number = $model->where( $condition )->count();
$can_send_state = $total_number > 0 ? 0 : 1;
}
$this->send( Code::success, [
'send_number' => $total_number,
'can_send_state' => $can_send_state,
] );
} else{
$this->send( Code::error, [], '请先配置微信众号秘钥及公类型' );
}
}
}
/**
* 群发创建
* @method POST
* @param string $condition_type 1全部粉丝 2按条件筛选 3手动选择粉丝
* @param array $condition
* @param int $send_time
* @param array $send_content
* @author 韩文博
*/
public function broadcastCreate()
{
if( $this->validate( $this->post, 'Admin/Wechat/Broadcast.create' ) !== true ){
$this->send( Code::param_error, [], $this->getValidate()->getError() );
} else{
$conf = model( 'Wechat' )->getWechatInfo( ['id' => 1], 'app_key,app_secret,level' );
if( $conf['app_key'] &
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计:基于PHP开源商城系统,基于swoole、easyswoole框架开发.zip
共543个文件
php:355个
js:74个
map:73个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 146 浏览量
2023-11-16
09:18:00
上传
评论
收藏 17.95MB ZIP 举报
温馨提示
计算机毕设源码
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计:基于PHP开源商城系统,基于swoole、easyswoole框架开发.zip (543个子文件)
vendor.css 8KB
main.css 0B
Dockerfile 2KB
fashop 12KB
fashop 9KB
.gitignore 243B
.gitignore 226B
index.html 1KB
favicon.ico 1KB
shop-fuzhuang.jpg 939KB
shop-shengxian.jpg 915KB
shop-qiche.jpg 815KB
shop-meizhuang.jpg 760KB
shop-jiaju.jpg 754KB
shop-muying.jpg 582KB
shop-dianzi.jpg 414KB
shop-fen_chaoshi.jpg 54KB
shop-fen_meizhuang.jpg 43KB
shop-fen_dianzi.jpg 39KB
vendor.js 1.57MB
48.js 995KB
45.js 991KB
42.js 985KB
28.js 981KB
12.js 736KB
65.js 685KB
37.js 575KB
36.js 575KB
17.js 497KB
18.js 497KB
31.js 180KB
6.js 178KB
40.js 175KB
27.js 158KB
50.js 157KB
49.js 156KB
32.js 151KB
25.js 146KB
41.js 142KB
15.js 141KB
66.js 105KB
67.js 104KB
22.js 101KB
3.js 88KB
5.js 83KB
58.js 72KB
52.js 64KB
59.js 61KB
56.js 49KB
0.js 49KB
4.js 44KB
68.js 34KB
72.js 30KB
70.js 30KB
8.js 28KB
39.js 27KB
24.js 27KB
54.js 23KB
69.js 20KB
19.js 19KB
34.js 19KB
13.js 19KB
11.js 18KB
10.js 18KB
33.js 18KB
71.js 17KB
2.js 16KB
23.js 15KB
55.js 13KB
47.js 13KB
46.js 12KB
51.js 11KB
53.js 11KB
1.js 11KB
20.js 10KB
60.js 9KB
21.js 9KB
service-worker.js 8KB
57.js 7KB
16.js 7KB
44.js 7KB
43.js 6KB
61.js 5KB
63.js 5KB
62.js 5KB
30.js 3KB
26.js 3KB
29.js 3KB
35.js 3KB
38.js 3KB
14.js 3KB
7.js 3KB
main.js 2KB
asset-manifest.json 8KB
composer.json 1KB
manifest.json 338B
48.js.map 4.13MB
28.js.map 4.12MB
45.js.map 4.12MB
42.js.map 4.11MB
共 543 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
学术菜鸟小晨
- 粉丝: 1w+
- 资源: 4940
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
- 222222222222
- 16张相机标定图片,可复现本文畸变矫正
- dbeaver-ce-23.3.1-x86_64-setup.zip
- 基于X86 AVX2指令的快速卷积实现
- VMware-ESXi-7.0U3n-21930508-depot.zip文件
- MySQL 在 Windows 系统下的安装教程.zip
- Access文件数据库访问的客户端
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功