first commit
This commit is contained in:
parent
fe1dfab2a4
commit
1076c99daf
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
CHANGELOG.md export-ignore
|
||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/qrcode
|
||||
/storage/circleImg
|
||||
/storage/export
|
||||
/storage/laravels.json
|
||||
/storage/laravels.pid
|
||||
/storage/framework/laravel-excel
|
||||
/vendor
|
||||
/.idea
|
||||
/.vagrant
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.env
|
||||
/laravel-echo-server.json
|
||||
/laravel-echo-server.json.example
|
||||
dump.rdb
|
||||
composer.lock
|
||||
.vscode/*
|
||||
.DS_Store
|
||||
18
Envoy.blade.php
Normal file
18
Envoy.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
@servers(['s02' => [" -p 2222 -i ~/.ssh/insecure_id_rsa root@s02p2222"], 's03' => [" -p 2222 -i ~/.ssh/insecure_id_rsa root@s03p2222"], 's08' => [" -p 2222 -i ~/.ssh/insecure_id_rsa root@s08p2222"]])
|
||||
|
||||
@setup
|
||||
|
||||
$server = isset($server)?$server:"s02";
|
||||
|
||||
@endsetup
|
||||
|
||||
@task('deploy', ['on' => $server])
|
||||
export NVM_DIR="/home/laradock/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
cd /var/www/love
|
||||
# npm run dev
|
||||
composer update
|
||||
# php artisan migrate --force
|
||||
@endtask
|
||||
|
||||
|
||||
231
README.txt
Normal file
231
README.txt
Normal file
@ -0,0 +1,231 @@
|
||||
**福恋交友平台**
|
||||
|
||||
#version
|
||||
* V2.4
|
||||
#repos
|
||||
* ufutx.love: 福恋基础库
|
||||
* ufutx.love.admin: 福恋后台前端库
|
||||
* ufutx.love.mp: 福恋小程序库
|
||||
|
||||
|
||||
#域名主机配置
|
||||
参考:[跨域配置](http://to-u.xyz/2016/06/30/nginx-cors/)
|
||||
|
||||
```nginx
|
||||
add_header Access-Control-Allow-Origin *; //http://m.licaigou.com.cn;
|
||||
add_header Access-Control-Allow-Headers X-Requested-With;
|
||||
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
|
||||
location /mobile {
|
||||
alias /var/www/mobile/release/mobile;
|
||||
index index.html;
|
||||
}
|
||||
|
||||
location /static {
|
||||
alias /var/www/mobile/release/static;
|
||||
index index.html;
|
||||
}
|
||||
```
|
||||
|
||||
# 网站安装
|
||||
|
||||
```
|
||||
git clone git@repo.ufutx.net:ufutx.love
|
||||
cd ufutx.love
|
||||
composer update -vvv
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
## 后端初始化需要执行
|
||||
# php artisan migrate:install
|
||||
# php artisan migrate
|
||||
php artisan passport:install
|
||||
#linux/unix or mac
|
||||
chmod 777 -R bootstrap/cache/ storage/logs/ storage/framework/ storage/app/
|
||||
```
|
||||
|
||||
# 数据库
|
||||
* user 用户信息
|
||||
* mobile
|
||||
* type: 用户类型: 单身signle, 介绍人marriage
|
||||
* marriage_linkings: 介绍人人脉数
|
||||
* single_male_linkings: 单身男
|
||||
* single_female_linkings: 单身女
|
||||
* request_num: 请求处理数量:1. 人脉请求
|
||||
* password_reset 重置密码
|
||||
* wechat 微信信息
|
||||
* message 验证码短信记录
|
||||
* salary 薪水表:
|
||||
* id
|
||||
* min 区间最小值: null是以下
|
||||
* max 区间最大值: null是以上
|
||||
* text 薪水文本: 如3K-6K, 50K以上
|
||||
* profile_courtship 单身资料: 求偎贴
|
||||
* user_id:
|
||||
* age: 年龄
|
||||
* sex: 性别,从微信中获取
|
||||
* state:单身状态:未婚,离异,丧偶
|
||||
* stature: 身高按cm
|
||||
* weight: 体重按Kg
|
||||
* province: 省
|
||||
* city: 城市
|
||||
* resident_type: 户口
|
||||
* resident_provice: 户口省份
|
||||
* resident_city: 户口城市
|
||||
* degree: 最高学历(大专,本科,硕士,博士, 其他)
|
||||
* graduate_school: 毕业学校
|
||||
* work_sort: 单位性质(事业单位,公务员,央企,国企,私企,外企)
|
||||
* salary_id: 新水ID
|
||||
* h_car: 有车
|
||||
* h_housing: 有房
|
||||
* introduction: 个人介绍(家庭情况,兴趣爱好,自我评价)
|
||||
* ideal_mate: 理想伴侣(写下你对另一半的期望)
|
||||
* photos: 生活照(PS,艺术照不受欢迎)(json数组,下同)
|
||||
* graduate_photos: 毕业证
|
||||
* identification_photos:身份证
|
||||
* other_photots: 其他证件(注册会计师, 律师资格证等)
|
||||
* wechat_id: 微信ID
|
||||
* wechat_qrcode: 微信二维码
|
||||
|
||||
* profile_marriage 已婚资料:介绍人资料,后期婚恋状态里也会提供服务
|
||||
* user_id:
|
||||
* company: 工作单位
|
||||
* degree: 学历
|
||||
* slogan: 服务格言: 乐意为单身的幸福生活服务
|
||||
* wechat_id: 微信号
|
||||
* wechat_qrcode: 微信二维码
|
||||
* linking 人脉表: 互相确认关注后
|
||||
* user_id: 用户id
|
||||
* user_linking_id:用户人脉id
|
||||
* linking_request 人脉请求:
|
||||
* user_id: 用户id
|
||||
* user_linking_id:用户人脉id
|
||||
* status: 0: 请求 1: 已处理
|
||||
* message:留言
|
||||
* reply: 回复
|
||||
* follow 关注与粉丝: 关注,订阅和赞,收藏
|
||||
* profile_right 访问权限: 自定义资料访问权限
|
||||
* user_id:
|
||||
* profile_name
|
||||
* type: 权限类型open: 公开, friend: 好友可见, right:特定条件, 参考right_id; user:仅用户可见
|
||||
* right_id:
|
||||
|
||||
* right 权限定义: 好友及特定权限定义
|
||||
* user_id:
|
||||
* type: 类型:friend,right, user
|
||||
* config: 权限配置
|
||||
* friend: follow, fan, linking
|
||||
* right: 以后再定义
|
||||
* user: 用户id json数组
|
||||
|
||||
* 接口设计
|
||||
* 引导页:
|
||||
* @POST:/api/login/wechat
|
||||
* @desc: 服务器端登录
|
||||
* @input: code: 微信用户登录凭证, 参考:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-login.html#wxloginobject
|
||||
* @output:
|
||||
* user: 用户信息, 如未注册此信息为null
|
||||
* user->register_status: 0:已完成(跳转到人脉), 1:等待完成第一步(单身第一步,介绍人资料填写 ) 2:等待完成第二步(单身第二步)
|
||||
* token: 后期接口token
|
||||
* @POST:/api/wechat/register
|
||||
* @desc: 完成手机认证后调用此注册,同时完成登录
|
||||
* @input:
|
||||
* mobile 手机号.
|
||||
* name: 姓名.
|
||||
* wechat_code: 微信用户登录凭证.
|
||||
* type: 用户类型.
|
||||
* info: 小程序登录返回的res.userInfo
|
||||
* from_openid: (从分享链接里获取)推荐人的openid, 可能没有
|
||||
* @output:
|
||||
* user: 用户信息
|
||||
* token: 后期接口token
|
||||
* 用户资料填写
|
||||
* @PUT:/api/users/marrriage
|
||||
* @desc: 修改介绍人资料
|
||||
* @input:
|
||||
* name: 姓名
|
||||
* industry: 行业
|
||||
* industry_sub: 子行业
|
||||
* company: 工作单位
|
||||
* degree: 学历
|
||||
* slogan: 服务格言: 乐意为单身的幸福生活服务
|
||||
* wechat_id: 微信号
|
||||
|
||||
* @get:/api/users/courtship/status
|
||||
* @desc: 获取单身资料完成情况,没有完成提示还有哪些需要填写
|
||||
* @PUT:/api/users/courtship/text
|
||||
* @desc: 修改单身文件资料
|
||||
* @input:
|
||||
* name: 姓名
|
||||
* industry: 行业
|
||||
* industry_sub: 子行业
|
||||
* state:单身状态:未婚,离异,丧偶
|
||||
* stature: 身高按cm
|
||||
* weight: 体重按Kg
|
||||
* province: 省
|
||||
* city: 城市
|
||||
* resident_type: 户口
|
||||
* resident_province: 户口省份
|
||||
* resident_city: 户口城市
|
||||
* degree: 最高学历(大专,本科,硕士,博士, 其他)
|
||||
* graduate_school: 毕业学校
|
||||
* work_sort: 单位性质(事业单位,公务员,央企,国企,私企,外企)
|
||||
* salary_id: 新水ID
|
||||
* h_car: 有车
|
||||
* h_housing: 有房
|
||||
* introduction: 个人介绍(家庭情况,兴趣爱好,自我评价)
|
||||
* ideal_mate: 理想伴侣(写下你对另一半的期望)
|
||||
|
||||
* @PUT:/api/users/courtship/media
|
||||
* @desc: 修改单身多媒体资料
|
||||
* @input:
|
||||
* photos: 生活照(PS,艺术照不受欢迎)(json数组,下同)
|
||||
* graduate_photos: 毕业证
|
||||
* identification_photos:身份证
|
||||
* other_photos: 其他证件(注册会计师, 律师资格证等)
|
||||
* wechat_qrcode: 微信二维码
|
||||
*
|
||||
* 人脉
|
||||
* @GET: /api/linking
|
||||
* @desc: 我的人脉详情
|
||||
* @output:
|
||||
* user: 用户信息
|
||||
* user.wechat: 用户微信消息
|
||||
* user.marriage: 介绍人的资料
|
||||
* user.courtship:单身人的资料
|
||||
* @GET: /api/users/{id}/linkings
|
||||
* @desc 人脉列表
|
||||
* @input:
|
||||
* type: marriage|courtship
|
||||
* sex: 男, 女
|
||||
* @GET: /api/users/{id}
|
||||
* @desc: 用户详情
|
||||
* @output: 数据结构同/api/user
|
||||
* @POST: /api/users/{id}/follow
|
||||
* @desc: 关注用户(toggle), 关注了再调用会取消关注
|
||||
* @POST: /api/users/{user_id}/linking
|
||||
* @desc: 申请加入人脉
|
||||
* @PUT: /api/linkings/{id}
|
||||
* @desc: 同意申请人脉
|
||||
* @DELETE: /api/linkings/{id}
|
||||
* input:
|
||||
@reply: 忽略原因
|
||||
* @desc: 勿略人脉请求
|
||||
* @DELETE: /api/users/{id}/linking
|
||||
* @desc: 取消人脉
|
||||
|
||||
* 我的
|
||||
* @GET: /api/user
|
||||
* @desc: 我的
|
||||
* @output:
|
||||
* salaries
|
||||
* user
|
||||
* @GET: /api/linkings
|
||||
* @desc: 我的人脉列表
|
||||
* @input:
|
||||
* status: 1: 已加入 0:待处理(default)
|
||||
* @GET: /api/follows
|
||||
* @desc: 我的关注
|
||||
* 基础
|
||||
* @GET: /api/industry/json
|
||||
* 返回行业数据
|
||||
|
||||
|
||||
11
app/Common/cache/redis/AdminRedisKey.php
vendored
Normal file
11
app/Common/cache/redis/AdminRedisKey.php
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\cache\redis;
|
||||
|
||||
/**
|
||||
* 福恋后台 redis key
|
||||
*/
|
||||
class AdminRedisKey
|
||||
{
|
||||
|
||||
}
|
||||
52
app/Common/cache/redis/ApiRedisKey.php
vendored
Normal file
52
app/Common/cache/redis/ApiRedisKey.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\cache\redis;
|
||||
|
||||
/**
|
||||
* 福恋小程序接口 redis key
|
||||
*/
|
||||
class ApiRedisKey
|
||||
{
|
||||
/**
|
||||
* 获取某个群聊未读人数集合
|
||||
* @param int $team_id 群聊id
|
||||
* @return string
|
||||
*/
|
||||
public static function getGroupChatUnreadKey(int $team_id): string
|
||||
{
|
||||
return "chat:group:unread:team_id_{$team_id}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 群聊回复上下文消息
|
||||
* @param $team_id
|
||||
* @param $user_id
|
||||
* @return string
|
||||
*/
|
||||
public static function getGroupChatGptReplyKey($team_id,$user_id): string
|
||||
{
|
||||
return "chat:group:gpt_reply_context:team_id{$team_id}:{$user_id}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页弹框点击用户集合
|
||||
* @param $id
|
||||
* @return string
|
||||
*/
|
||||
public static function getHomePopoutClickUserKey($id): string
|
||||
{
|
||||
return "home_popout:id{$id}_click_user";
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户关注他人 关注锁
|
||||
* @param $user_id
|
||||
* @param $other_user_id
|
||||
* @return string
|
||||
*/
|
||||
public static function getFollowOtherUserLock($user_id, $other_user_id): string
|
||||
{
|
||||
return sprintf("user:%s:follow:%s:lock", $user_id, $other_user_id);
|
||||
}
|
||||
|
||||
}
|
||||
78
app/Console/Commands/ActivitySms.php
Normal file
78
app/Console/Commands/ActivitySms.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\Message;
|
||||
use App\Utils\Messenger;
|
||||
use App\Jobs\SendSmsBatch;
|
||||
|
||||
class ActivitySms extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:sms';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '时隔两小时发送短信,不重复发(发过了的不发)';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user_open_ids = User::where('created_at','>','2021-05-20 00:00:00')->whereNotNull('from_openid')->pluck('from_openid')->toArray();
|
||||
$counts = array_count_values($user_open_ids);
|
||||
$final_openids = [];//收短信人from_openid
|
||||
foreach ($counts as $key => $count) {
|
||||
if ($count >= 10) {
|
||||
$final_openids[] = $key;
|
||||
}
|
||||
}
|
||||
$user_ids = Wechat::whereIn('openid',$final_openids)->pluck('user_id')->toArray();
|
||||
|
||||
$mobiles = User::whereIn('id',$user_ids)->pluck('mobile')->toArray();
|
||||
|
||||
$phone = Message::where('message','like','%可得电影首映礼观影票一张,点击领取%')->pluck('phone')->toArray();
|
||||
|
||||
$mobiles = array_diff($mobiles,$phone);//发短信号码集合
|
||||
foreach ($mobiles as $mobile) {
|
||||
$m = Message::create([
|
||||
'phone' => $mobile,
|
||||
'message' => '',
|
||||
'confirmed' => 1,
|
||||
'code' => '活动',
|
||||
'ip' => request() ? request()->ip() : '127.0.0.1',
|
||||
]);
|
||||
|
||||
$url = \CommonUtilsService::shortUrl('https://love.ufutx.com/api/admin/get/phone?&uri=http://love.ufutx.com/h5/#/holidayActivity&message_id='.$m->id);
|
||||
$url = $url ['url'];
|
||||
$message = "恭喜!您已推荐10位小伙伴成功注册福恋,可得电影首映礼观影票一张,点击领取";
|
||||
$m->message = $message;
|
||||
|
||||
Messenger::sendSMS($mobile, $message);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
111
app/Console/Commands/AutomaticCheckBadWord.php
Normal file
111
app/Console/Commands/AutomaticCheckBadWord.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\Message;
|
||||
use App\Utils\Messenger;
|
||||
use App\Jobs\SendSmsBatch;
|
||||
use App\Models\BadWord;
|
||||
use App\Models\HandleLogs;
|
||||
use App\Models\Moment;
|
||||
use App\Models\VerifyLog;
|
||||
use App\Services\CommonUtilsService;
|
||||
use App\Services\UserService;
|
||||
|
||||
class AutomaticCheckBadWord extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'automatic_check_bad_word';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每天01.30 自动校验敏感词';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
try{
|
||||
$t1=microtime(true);
|
||||
$momentList = Moment::get();
|
||||
$illegality_keyword = BadWord::get();
|
||||
$violation_moment_list = [];
|
||||
$violation_userinfo_list = [];
|
||||
VerifyLog::where('id','>=','1')->delete();
|
||||
foreach ($momentList as $m_i){
|
||||
$res = \CommonUtilsService::verifyTextV2([$m_i->content],$illegality_keyword,1);
|
||||
if($res['code'] != 1){
|
||||
$violation_moment_list[] = $this->verifyStatisticsArray('moment',$m_i->id,$res['detail_context'],$res['code'],$res['type'],$res['context'],'content');
|
||||
}
|
||||
}
|
||||
$userCount = User::where('type','signle')->count();
|
||||
for($uc=0;$uc<=$userCount;$uc+=10000){
|
||||
$thisUserCount = $uc;
|
||||
$userList = User::with('profileCourtship')
|
||||
->whereHas('profileCourtship', function ($sql){
|
||||
$sql->where('introduction','<>','');
|
||||
$sql->where('ideal_mate','<>','');
|
||||
})
|
||||
->where('type','single')
|
||||
->limit(10000)
|
||||
->offset($thisUserCount)
|
||||
->get();
|
||||
foreach ($userList as $u){
|
||||
$introduction = $u->profileCourtship->introduction;
|
||||
$ideal_mate = $u->profileCourtship->ideal_mate;
|
||||
$res = \CommonUtilsService::verifyTextV2([$introduction],$illegality_keyword,1);
|
||||
if($res['code'] != 1){
|
||||
$violation_userinfo_list[] = $this->verifyStatisticsArray('user',$u->id,$res['detail_context'],$res['code'],$res['type'],$res['context'],'introduction');
|
||||
}
|
||||
$res = \CommonUtilsService::verifyTextV2([$ideal_mate],$illegality_keyword,1);
|
||||
if($res['code'] != 1){
|
||||
$violation_userinfo_list[] = $this->verifyStatisticsArray('user',$u->id,$res['detail_context'],$res['code'],$res['type'],$res['context'],'ideal_mate');
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['violation_moment_list'] = $violation_moment_list;
|
||||
$data['violation_userinfo_list'] = $violation_userinfo_list;
|
||||
$HandleLogsData['elapsed_time']='耗时:'.(microtime(true)-$t1);
|
||||
HandleLogs::add(1,'检验敏感词完成',$HandleLogsData,'log_sensitive_word');
|
||||
} catch (\Exception $e) {
|
||||
HandleLogs::add(2,'检验敏感词失败 ',$e->getMessage(),'log_sensitive_word');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***/
|
||||
protected function verifyStatisticsArray($sourceType,$sourceId,$context,$errorCode,$errorType,$errorContext,$source_context_field){
|
||||
VerifyLog::create([
|
||||
'source_type'=>$sourceType,
|
||||
'source_id'=>$sourceId,
|
||||
'source_context'=>$context,
|
||||
'source_context_field'=>$source_context_field,
|
||||
'error_code'=>$errorCode,
|
||||
'error_type'=>$errorType,
|
||||
'error_context'=>$errorContext
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
80
app/Console/Commands/BirthdayRemind.php
Normal file
80
app/Console/Commands/BirthdayRemind.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\Message;
|
||||
use App\Utils\Messenger;
|
||||
use App\Jobs\SendSmsBatch;
|
||||
use App\Services\CommonUtilsService;
|
||||
use App\Services\UserService;
|
||||
|
||||
class BirthdayRemind extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:birthday';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每天10.00 发送生日提醒给当天生日的用户';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$todayBirthdayUserList = UserService::getTodayBirthdayUserList();
|
||||
foreach ($todayBirthdayUserList as $user_item) {
|
||||
$this->sendBirthdayBlessing($user_item->mobile,$user_item->nickname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送生日短信
|
||||
function sendBirthdayBlessing($mobile,$nickname){
|
||||
$code = '生日提醒短信';
|
||||
//如果今年已经发送过一次短信则不在发送
|
||||
$this_year_initial_date = date('Y-01-01');
|
||||
if (empty($mobile)) return false;
|
||||
// $result = Message::where('phone', $mobile)
|
||||
// ->where('created_at','>=', $this_year_initial_date)
|
||||
// ->where('code', $code)
|
||||
// ->count();
|
||||
// if($result){
|
||||
// return false;
|
||||
// }
|
||||
$m = Message::create([
|
||||
'phone' => $mobile,
|
||||
'message' => '',
|
||||
'confirmed' => 1,
|
||||
'code' => $code,
|
||||
'ip' => request() ? request()->ip() : '127.0.0.1',
|
||||
]);
|
||||
$url = '';
|
||||
$wecharLink = \CommonUtilsService::getWecharLink('/pages/home/birthdayPresent');
|
||||
$url = \CommonUtilsService::createShortUrl(env('APP_URL').'/h5/#/jump_url?url='.$wecharLink,$m->id);
|
||||
$message = "亲爱的 $nickname 生日快乐! 福恋悄悄给你送了一个神秘的专属礼物哦,点击链接 $url 拆开你的礼物吧!";
|
||||
$m->message = $message;
|
||||
$m->save();
|
||||
Messenger::sendSMS($mobile, $message);
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
44
app/Console/Commands/CheckChooseTemplate.php
Normal file
44
app/Console/Commands/CheckChooseTemplate.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\MerchantAccount;
|
||||
|
||||
class CheckChooseTemplate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'checkChooseTemplate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '老师没有选择模板给默认值';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
MerchantAccount::whereNull('template_position')->update(['template_position'=>'[{"name":"\u8d44\u8baf","position":1},{"name":"\u670d\u52a1","position":1},{"name":"\u6d3b\u52a8","position":1},{"name":"\u8bfe\u7a0b","position":1},{"name":"\u54a8\u8be2","position":1},{"name":"\u6211\u7684","position":1}]']);
|
||||
MerchantAccount::whereNull('choose_tarbar')->update(['choose_tarbar'=>'[{"title":"\u54a8\u8be2","to":"\/information","active":"https:\/\/image.fulllinkai.com\/202109\/02\/9905f4767819a71f3937d7fb5fd4945b.png","inactive":"https:\/\/image.fulllinkai.com\/202109\/02\/b59301e4d4208377b68717af663429d9.png"},{"title":"\u670d\u52a1","to":"\/serve","active":"https:\/\/image.fulllinkai.com\/202109\/02\/67a27b4505f91092ab4f813ea239f489.png","inactive":"https:\/\/image.fulllinkai.com\/202109\/02\/811f648fb0f1a88b6ae16ebc24a983ce.png"},{"title":"\u6211\u7684","to":"\/my","active":"https:\/\/images.ufutx.com\/202108\/18\/30d2812a7acf8f0f35a0671cfa5c2fc9.png","inactive":"https:\/\/images.ufutx.com\/202108\/18\/e2ca747feef9cbabedd5a9dfe2a70d31.png"}]']);
|
||||
}
|
||||
}
|
||||
49
app/Console/Commands/CheckSmsComplete.php
Normal file
49
app/Console/Commands/CheckSmsComplete.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\ClientMessage;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CheckSmsComplete extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'checkSmsComplete';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '检查短信是否循环发送完毕';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$messages = ClientMessage::withCount('recive')->where('is_completed',0)->get();
|
||||
foreach ($messages as $key => $value) {
|
||||
$nicknames = json_decode($value->nicknames);
|
||||
if($value->recive_count >= count($nicknames)){
|
||||
$value->update(['is_completed'=>1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/CreateParticipantPacket.php
Normal file
42
app/Console/Commands/CreateParticipantPacket.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use CronService;
|
||||
class CreateParticipantPacket extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:packet';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'create participant packet';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
CronService::createParticipantPacket();
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/CreateTestPaticipantPacket.php
Normal file
42
app/Console/Commands/CreateTestPaticipantPacket.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use CronService;
|
||||
class CreateTestPaticipantPacket extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:test_packet';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'create test packet';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
CronService::testcreateParticipantPacket();
|
||||
}
|
||||
}
|
||||
136
app/Console/Commands/InterruptCall.php
Normal file
136
app/Console/Commands/InterruptCall.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\ConsultationRecords;
|
||||
use App\Models\PayLog;
|
||||
|
||||
class InterruptCall extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'InterruptCall';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '咨询-通话中断';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$result = ConsultationRecords::where('pay_status',1)->where('status',1)->orderBy('id','desc')->get();
|
||||
foreach ($result as $key => $value) {
|
||||
$this->InterruptCall($value);
|
||||
}
|
||||
}
|
||||
|
||||
//主动挂断通话
|
||||
|
||||
public function InterruptCall($request)
|
||||
{
|
||||
//参数缺失
|
||||
if(!$request->recorder_id||!$request->trade_no){
|
||||
return false;
|
||||
}
|
||||
$pay = new PayLog();
|
||||
$pay->type = 'InterruptCall';
|
||||
$pay->trade_no= $request->trade_no;
|
||||
$time = time()-strtotime($request->begin_time);
|
||||
$Remaining_time = $request->duration*60 -$time;
|
||||
|
||||
if($Remaining_time>0){
|
||||
$pay->remark = '剩余时间'. $Remaining_time.'秒';
|
||||
$pay->save();
|
||||
return false;
|
||||
}
|
||||
$request->Remaining_duration = 0;
|
||||
$request->save();
|
||||
$data = [
|
||||
// 以下代码以ax为例,选填参数以实际需求,对应填写
|
||||
"corp_key" => "7574596477198833",//企业账户key 必填
|
||||
"request_id" => $request->trade_no,// 企业每个请求Id唯一,如果是同一个请求重复提交,则Id保持相同 必填
|
||||
"recorder_id" => $request->recorder_id,//企业本次通话唯一标识
|
||||
];
|
||||
$data['ts'] = time();
|
||||
$data['sign'] = $this->sign($data, '8uM2Mxe7EaCU8XXW4FHjaq6m8N3794Xv');//密钥信息
|
||||
// print_r(json_encode($data));
|
||||
$url = 'http://124.160.62.210:9092/ykt-open/hold/hangup2';//请求地址
|
||||
$curl = curl_init($url);
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($data),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Accept: */*",
|
||||
"Accept-Encoding: gzip, deflate",
|
||||
"Cache-Control: no-cache",
|
||||
"Connection: keep-alive",
|
||||
"Content-Type: application/json;charset=utf-8",
|
||||
"cache-control: no-cache"
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
if ($err) {
|
||||
$pay->remark = '错误:'.$err;
|
||||
$pay->save();
|
||||
return false;
|
||||
} else {
|
||||
$response = json_decode($response,true);
|
||||
$pay->remark = $response;
|
||||
$pay->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sign($data, $key){
|
||||
if (isset($data['sign'])) {
|
||||
unset($data['sign']);
|
||||
}
|
||||
$data_str = $this->signStr($data) . '&corp_secret=' . $key;
|
||||
return md5($data_str);
|
||||
}
|
||||
|
||||
function signStr($data){
|
||||
|
||||
$array_keys = array_keys($data);
|
||||
asort($array_keys);
|
||||
$newData = [];
|
||||
foreach ($array_keys as $v) {
|
||||
if ($v && !empty($data[$v])) {
|
||||
$newData[] = "{$v}={$data[$v]}";
|
||||
}
|
||||
}
|
||||
return implode('&', $newData);
|
||||
}
|
||||
}
|
||||
75
app/Console/Commands/LiveRemind.php
Normal file
75
app/Console/Commands/LiveRemind.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Live\Live;
|
||||
use App\Models\Live\AnchorViewer;
|
||||
use App\Jobs\SendTemplateMsg;
|
||||
use App\Models\Live\Viewer;
|
||||
use App\Models\Live\Anchor;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
class LiveRemind extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'liveRemind';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '开播前一个小时通知已经关注的用户';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$Live = Live::where('status',0)->where('is_show',1)->get();
|
||||
|
||||
foreach ($Live as $key => $value) {
|
||||
$time = strtotime($value->start_time);
|
||||
$Remaining_time = $time-(time()+60*60);
|
||||
if($Remaining_time<=0){
|
||||
$key = 'liveRemind'.$value->id;
|
||||
if(Redis::get($key)){
|
||||
continue;
|
||||
}else{
|
||||
Redis::setex($key,100*60,1);
|
||||
$teacher = Anchor::where('id', $value->anchor_id)->value('name');
|
||||
$followers = AnchorViewer::where('anchor_id', $value->anchor_id)->where('focusing', 1)->pluck('viewer_id')->toArray();
|
||||
$data['touser'] = Viewer::whereIn('id', $followers)->pluck('openid')->toArray();
|
||||
$data['template_id'] = 'BinirgWI3EAYs9jindxPBwUm-rAceTu9T4H02m-sq5g';
|
||||
$data['url'] = env('APP_URL').'/api/official/live/wechat/oauth?live_id='.$value->id;
|
||||
$data['data'] = [
|
||||
'first' => '您关注的老师即将在1小时后开始直播课。',
|
||||
'keyword1' => $value->start_time,
|
||||
'keyword2' => $teacher,
|
||||
'reamrk' => '点击详情,即可观看预告',
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
}
|
||||
}
|
||||
# code...
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
48
app/Console/Commands/MatchingRate.php
Normal file
48
app/Console/Commands/MatchingRate.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\CronService;
|
||||
use App\Repositories\Eloquent\SmsRepository as Sms;
|
||||
use Illuminate\Container\Container as App;
|
||||
|
||||
class MatchingRate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'match:make';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '生成匹配记录';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$cron = new CronService();
|
||||
$result = $cron->newUserMatchingRate();
|
||||
|
||||
$this->info($result);
|
||||
}
|
||||
}
|
||||
82
app/Console/Commands/SendActivityCommentNotice.php
Normal file
82
app/Console/Commands/SendActivityCommentNotice.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendTemplateMsg;
|
||||
use App\Models\CommunityActivity;
|
||||
use App\Models\Server\TouristOrder;
|
||||
use App\Models\TemplateMsgLog;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendActivityCommentNotice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sendActivityCommentNotice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '活动结束1小时发送 去评价通知';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$now_date = date('Y-m-d H:i:s');
|
||||
$now_time = time();
|
||||
$activities = CommunityActivity::whereNotNull('end_time')->where('type','business')->where('class','one')->get();
|
||||
$list = [];
|
||||
foreach ($activities as $key => $activity) {
|
||||
//未结束或结束不到一小时 不发
|
||||
if($activity->end_time > $now_date || $now_time - strtotime($activity->end_time) < 3600) continue;
|
||||
if($this->isSendNotice($activity->id)) continue;
|
||||
//发送通知的活动id
|
||||
$list[] = $activity->id;
|
||||
}
|
||||
if(empty($list)) return ;
|
||||
foreach ($list as $value) { //value 活动id
|
||||
$com = CommunityActivity::where('id',$value)->first();
|
||||
//已经评价过的不发
|
||||
$orders = TouristOrder::where('type','community')->where('type_id',$value)->whereIn('pay_status',[1,4])->whereNull('Praise')->get();
|
||||
foreach ($orders as $order) {
|
||||
$data['touser'] = $order->openid;
|
||||
$data['template_id'] = '9aPSHmzsULb-YnSkJ1Y4B-larsOKdURX6UlfatPZxgY';
|
||||
$data['activity_id'] = $value;
|
||||
$data['url'] = env('APP_URL').'/pu/#/mySignUp?merchant_id='.$com->merchant_id.'&actioveLabel=1';
|
||||
$data['data'] = [
|
||||
'first' => '您好,你参与的活动《'.$com->title.'》已经结束',
|
||||
'keyword1' =>$com->title,
|
||||
'keyword2' =>$com->end_time,
|
||||
'remark' => '点击进入详情页可对我们的活动进行评价哦!',
|
||||
'activity_id'=>$value
|
||||
];
|
||||
SendTemplateMsg::dispatch($data)->onQueue('template_message');
|
||||
}
|
||||
}
|
||||
}
|
||||
//判断该活动是否发送过通知
|
||||
public function isSendNotice($activity_id){
|
||||
$log = TemplateMsgLog::where('user_id',$activity_id)->where('template_id','9aPSHmzsULb-YnSkJ1Y4B-larsOKdURX6UlfatPZxgY')->first();
|
||||
if($log) return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
72
app/Console/Commands/SendActivityQuestionnaireSurvey.php
Normal file
72
app/Console/Commands/SendActivityQuestionnaireSurvey.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Activity;
|
||||
use App\Models\User;
|
||||
use App\Models\ActivityMember;
|
||||
|
||||
class SendActivityQuestionnaireSurvey extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:sendActivityQuestionnaireSurvey';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '活动结束15分钟 发送【问卷调查】服务通知';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
//每1分钟调一次接口
|
||||
public function handle()
|
||||
{
|
||||
$date = date('Y-m-d H:i:s');//当前时间
|
||||
$late_date = date('Y-m-d H:i:s',strtotime('-15 minutes',strtotime($date)));//当前时间-15分钟 防止不发通知
|
||||
$activity_ids = Activity::whereBetween('end_time',[$late_date,$date])->pluck('id')->toArray();
|
||||
if (!empty($activity_ids)) { //如果有在此期间结束的活动 ==> 发送【问卷调查】服务通知
|
||||
$activities = Activity::whereIn('id',$activity_ids)->orderBy('end_time','desc')->get();//要发送的活动
|
||||
foreach ($activities as $activity) {
|
||||
|
||||
//参与活动的成员id
|
||||
$member_ids = ActivityMember::where('activity_id',$activity->id)->where('is_joined',1)->pluck('user_id')->toArray();
|
||||
|
||||
foreach ($member_ids as $member_id) {
|
||||
$member = User::find($member_id);
|
||||
$param = $this->getParams($activity,$member);
|
||||
\WechatService::sendActivityQuestionaireSurvey($param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getParams($activity,$user){
|
||||
$param['activity_id'] = $activity->id;
|
||||
$param['openid'] = $user->wechat ? $user->wechat->openid : null;
|
||||
$param['nickname'] = $user->nickname ? $user->nickname : $user->name;
|
||||
$param['theme'] = $activity->theme;
|
||||
$param['time'] = $activity->start_time;
|
||||
$param['desc'] = '点击参与活动问卷调查,帮助我们做得更好。';
|
||||
return $param;
|
||||
}
|
||||
}
|
||||
102
app/Console/Commands/SendActivitySmsBeforeBeginning.php
Normal file
102
app/Console/Commands/SendActivitySmsBeforeBeginning.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\ActivityMember;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Message;
|
||||
use App\Jobs\SendSmsBatch;
|
||||
|
||||
class SendActivitySmsBeforeBeginning extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:send_sms_to_activity_members';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '活动开始前15分钟 发送短信通知';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
//每1分钟调一次接口
|
||||
public function handle()
|
||||
{
|
||||
//获取活动开始前15分钟的活动
|
||||
$now_date = date('Y-m-d H:i:s');
|
||||
$send_time = date('Y-m-d H:i:s',strtotime('+15 minutes',strtotime($now_date)));
|
||||
$activities = Activity::whereBetween('start_time',[$now_date,$send_time])->get();
|
||||
if (!empty($activities)){//要发送通知的活动
|
||||
foreach ($activities as $activity) {
|
||||
$message = '【福恋】恭喜您,您参加的“'.$activity->theme.'”活动报名成功,请于'.$activity->start_time.'准时参与。如有问题,请联系:18922809346,退订回N';
|
||||
$members = ActivityMember::where('activity_id',$activity->id)->where('is_joined',1)->get();
|
||||
$mobile = [];
|
||||
foreach ($members as $member) {
|
||||
$result = $this->isSendSms($activity,$member);
|
||||
if ($result) { //没有发送过 就发
|
||||
$mobile[] = $result;
|
||||
}
|
||||
}
|
||||
if(!empty($mobile) && is_array($mobile)){
|
||||
//批量发送
|
||||
$array = [
|
||||
'mobile' => $mobile,
|
||||
'message' => $message
|
||||
];
|
||||
//添加记录
|
||||
$this->addSmsRecord($mobile,$activity);
|
||||
SendSmsBatch::dispatch($array)->onQueue('love');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否发送过该短信
|
||||
public function isSendSms($activity,$member){
|
||||
$code = '活动短信通知'.$activity->id;
|
||||
$is_send = Message::where('phone',$member->mobile)->where('code',$code)->count();
|
||||
if ($is_send) {
|
||||
return false;
|
||||
}else{
|
||||
return $member->mobile;
|
||||
}
|
||||
}
|
||||
|
||||
//增加短信记录
|
||||
public function addSmsRecord($mobile,$activity){
|
||||
$code = '活动短信通知'.$activity->id;
|
||||
$message = '【福恋】恭喜您,您参加的“'.$activity->theme.'”活动报名成功,请于'.$activity->start_time.'准时参与。如有问题,请联系4000401707,退订回N';
|
||||
if(!empty($mobile) && is_array($mobile)){
|
||||
foreach($mobile as $mob){
|
||||
Message::create([
|
||||
'phone'=>$mob,
|
||||
'message'=>$message,
|
||||
'code'=>$code,
|
||||
'confirmed'=>1,
|
||||
'ip' => request() ? request()->ip() : '127.0.0.1',
|
||||
'is_click'=>0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/Swoole.php
Normal file
42
app/Console/Commands/Swoole.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Swoole extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
47
app/Console/Commands/TestExport.php
Normal file
47
app/Console/Commands/TestExport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Imports\TestImport;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class TestExport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'excel:export {name} {--id=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$path = storage_path('test.xlsx');
|
||||
\Excel::import(new TestImport, $path);
|
||||
$name = $this->argument('name');
|
||||
$id = $this->option('id');
|
||||
\Excel::store(new \App\Exports\TestExport($id), $name, 'public');
|
||||
}
|
||||
}
|
||||
124
app/Console/Commands/signNotice.php
Normal file
124
app/Console/Commands/signNotice.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\UserInfo;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Jobs\SendIMPushMsg;
|
||||
use App\Models\PayLog;
|
||||
use App\Models\SignLog;
|
||||
use App\Services\IMService;
|
||||
use App\Models\User;
|
||||
|
||||
class signNotice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'signNotice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '每天九点发送推送通知用户签到';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//获取设置签到提醒的用户
|
||||
$ids = UserInfo::where('sign_notice',1)->pluck('user_id')->toarray();
|
||||
//查询今日是否已经签到
|
||||
$start = Date('Y-m-d 00:00:00',time());
|
||||
$sign_ids = SignLog::wherein('user_id',$ids)->wherebetween('sign_date',[$start,now()])->pluck('user_id')->toarray();
|
||||
// 取差集
|
||||
$sign_ids = array_diff($ids,$sign_ids);
|
||||
|
||||
foreach ($sign_ids as $key => $value) {
|
||||
$user = User::select('id','app_avatar','photo','circle_avatar','nickname')->where('id',$value)->first();
|
||||
if($user){
|
||||
$content = '亲爱的'. $user->nickname.',您今日还未签到,赶快签到领取更多的奖励把~';
|
||||
$pay = new PayLog();
|
||||
$pay->type = 'signNotice';
|
||||
$pay->user_id = $user->id;
|
||||
$pay->remark = $content;
|
||||
$pay->save();
|
||||
$this->sendAttachMsg($user->id, 'sign_notice', $content, 0,$user->id,$user->avatar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送推送消息
|
||||
* @param [type] $type_id 类型id
|
||||
* @param [type] $type 类型
|
||||
* @param [type] $content 推送文字
|
||||
* @param [type] $from 来自用户
|
||||
* @param [type] $to 接收用户
|
||||
* @param [type] $image 来自用户头像
|
||||
* @return [type] 是否成功
|
||||
*/
|
||||
public function sendAttachMsg($type_id, $type, $content, $from, $to, $image)
|
||||
{
|
||||
$body = "点击查看>>";
|
||||
//发送评论自定义系统消息
|
||||
$im_service = new IMService();
|
||||
$attach = ["myattach"=>$content, $type.'_id'=>$type_id];
|
||||
$payload = [
|
||||
"apsField"=>[
|
||||
"alert"=>[
|
||||
"title"=>'每日签到提醒通知',
|
||||
"body"=> $body,
|
||||
],
|
||||
"mutable-content"=>1
|
||||
],
|
||||
"hwField"=>[
|
||||
"click_action"=>[
|
||||
"type"=>1,
|
||||
"intent"=>"intent://com.huawei.codelabpush/deeplink?id=".$type_id."&customType=".$type."#Intent;scheme=pushscheme;launchFlags=0x4000000;end",
|
||||
],
|
||||
"title"=>'每日签到提醒通知',
|
||||
"body"=>$body,
|
||||
],
|
||||
"oppoField"=>[
|
||||
"click_action_type"=>1,
|
||||
"click_action_activity"=>"com.oppo.codelabpush.intent.action.test",
|
||||
"action_parameters"=>[
|
||||
"id"=>$type_id,
|
||||
"customType"=>"moment",
|
||||
],
|
||||
],
|
||||
"apnsText"=>$body,
|
||||
"pushTitle"=>'每日签到提醒通知',
|
||||
"customType"=>$type,
|
||||
"content"=>$body,
|
||||
"media_image"=>$image,
|
||||
"media_type"=>'image',
|
||||
"id"=>$type_id,
|
||||
"type"=>$type,
|
||||
'passThrough'=>1,
|
||||
];
|
||||
$result = $im_service->sendAttachMsg($from,0,$to,json_encode($attach),$content,$payload);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
1739
app/Console/Kernel.php
Normal file
1739
app/Console/Kernel.php
Normal file
File diff suppressed because it is too large
Load Diff
20
app/Contracts/ActivityContract.php
Normal file
20
app/Contracts/ActivityContract.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
interface ActivityContract
|
||||
{
|
||||
//活动列表
|
||||
public function officialActivities($request);
|
||||
//活动详情
|
||||
public function officialActivity($activity_id,$user);
|
||||
//活动报名
|
||||
public function officailJoinActivity($request, $activity_id);
|
||||
//活动置顶
|
||||
public function topActivity($activity_id);
|
||||
//取消置顶
|
||||
public function cancelActivityTop($activity_id);
|
||||
//取消活动
|
||||
public function cancelActivity($request, $activity_id);
|
||||
//复制活动
|
||||
public function copyActivity($request, $activity_id);
|
||||
}
|
||||
14
app/Contracts/Collageable.php
Normal file
14
app/Contracts/Collageable.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Collageable
|
||||
{
|
||||
public function getPrimaryId(): string;
|
||||
public function collageGroup(): MorphMany;
|
||||
public function getCurrentClass(Collageable $collageable);
|
||||
public function hasGroup(Collageable $collageable);
|
||||
public function groupInformation(Collageable $collageable);
|
||||
}
|
||||
11
app/Contracts/Likerable.php
Normal file
11
app/Contracts/Likerable.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Likerable
|
||||
{
|
||||
public function Likers(): MorphMany;
|
||||
public function primaryId(): string;
|
||||
}
|
||||
70
app/Contracts/LiveContract.php
Normal file
70
app/Contracts/LiveContract.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface LiveContract
|
||||
|
||||
{
|
||||
//创建互动直播
|
||||
public function storeInteractLive();
|
||||
//创建互动直播V2
|
||||
public function storeInteractLiveV2();
|
||||
//直播列表
|
||||
public function liveList();
|
||||
//直播列表
|
||||
public function liveListV2();
|
||||
//直播首页轮播
|
||||
public function liveCarousel();
|
||||
//直播间在线用户
|
||||
public function inLiveMembers($live, $limit);
|
||||
//直播详情
|
||||
public function live($live_id, $match_maker=false, $leisureLiveLog=false, $lastLiveLog=false);
|
||||
//通过聊天室id查询直播间
|
||||
public function liveByChatroom($room_id);
|
||||
//申请相亲直播
|
||||
public function applyInteractLive($live_id);
|
||||
//赠送相亲卡
|
||||
public function daliySendLiveCard($user_id);
|
||||
//申请相亲记录
|
||||
public function liveApplyLogs($live_id, $is_audited=0);
|
||||
//审核相亲记录
|
||||
public function auditedApplyLog($log);
|
||||
//直播间只用用户信息
|
||||
public function liveUsersInfo($live_id);
|
||||
//直播间踢人
|
||||
public function banLiveUser($live_id, $user_id);
|
||||
//加入互动直播
|
||||
public function joinInteractLive($live_id);
|
||||
//开播
|
||||
public function onLive();
|
||||
//下播
|
||||
public function offLive();
|
||||
//直播卡列表
|
||||
public function liveCards($is_used=null, $nopage=0);
|
||||
//主动退出互动直播
|
||||
public function leaveInteractLive($live_id);
|
||||
//被动退出互动直播
|
||||
public function askLeaveInteractLive($live_id, $user_id);
|
||||
//邀请用户参加互动直播
|
||||
public function inviteJoinLive($user_id, $live_id);
|
||||
//推荐房间
|
||||
public function recommendLive();
|
||||
//直播礼物列表带福币信息
|
||||
public function liveGifts();
|
||||
//充值信息列表
|
||||
public function ratioCoins();
|
||||
//赠送礼物
|
||||
public function sendLiveGift($user_id, $gift_id);
|
||||
//福币记录
|
||||
public function userCoinLogs();
|
||||
//在线用户列表
|
||||
public function liveOnlineUsers();
|
||||
//房间用户
|
||||
public function liveMembers($live, $nopage=0, $limit=0);
|
||||
//上线直播间用户
|
||||
public function addLiveMember($live, $user);
|
||||
//下线直播间用户
|
||||
public function leaveLiveMember($live_id, $user_id);
|
||||
//直播间观众用户信息
|
||||
public function liveUserInfo($user);
|
||||
}
|
||||
8
app/Contracts/Logable.php
Normal file
8
app/Contracts/Logable.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface Logable
|
||||
{
|
||||
public function primaryId(): string;
|
||||
}
|
||||
7
app/Contracts/MomentContract.php
Normal file
7
app/Contracts/MomentContract.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
interface MomentContract
|
||||
{
|
||||
|
||||
}
|
||||
13
app/Contracts/OrderContract.php
Normal file
13
app/Contracts/OrderContract.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface OrderContract
|
||||
|
||||
{
|
||||
//充值会员
|
||||
public function officialMemberCharge($request, $rank_name, $rank_month, $discount_price, $score, $trade_type);
|
||||
//赠送认证订单
|
||||
public function addApproveOrder($user_id);
|
||||
|
||||
}
|
||||
46
app/Contracts/PaasContract.php
Normal file
46
app/Contracts/PaasContract.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
interface PaasContract
|
||||
{
|
||||
//平台列表
|
||||
public function paasList($request);
|
||||
//平台详情
|
||||
public function paas($paas_id);
|
||||
//添加平台
|
||||
public function createPaas($array);
|
||||
//修改平台信息
|
||||
public function updatePaas($array, $paas_id);
|
||||
//删除平台
|
||||
public function deletePaas($paas_id);
|
||||
//渠道列表
|
||||
public function paasPlatforms($paas_id, $nopage, $limit);
|
||||
//添加渠道
|
||||
public function createPlatform($array);
|
||||
//渠道详情
|
||||
public function platform($platform_id);
|
||||
//修改渠道
|
||||
public function updatePlatform($array, $platform_id);
|
||||
//删除渠道
|
||||
public function deletePlatform($platform_id);
|
||||
//同工列表
|
||||
public function paasWorkers($request, $paas_id, $nopage, $limit);
|
||||
//添加同工
|
||||
public function createPaasWorker($array);
|
||||
//同工
|
||||
public function paasWorker($worker_id);
|
||||
//删除同工
|
||||
public function deletePaasWorker($worker_id);
|
||||
//平台客户
|
||||
public function paasClients($request, $paas_id, $nopage=0);
|
||||
//绑定提现账号
|
||||
public function paasBindAccount($request, $user_id);
|
||||
//提现账号详情
|
||||
public function paasAccount($request);
|
||||
//提现记录
|
||||
public function paasWithdraws($request);
|
||||
//提现
|
||||
public function withdraw($request, $official_openid);
|
||||
//平台管理员列表
|
||||
public function paasAdmins($request, $nopage=0);
|
||||
}
|
||||
11
app/Contracts/Previewable.php
Normal file
11
app/Contracts/Previewable.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Previewable
|
||||
{
|
||||
public function previews(): MorphMany;
|
||||
// public function primaryId(): string;
|
||||
}
|
||||
11
app/Contracts/Rewardable.php
Normal file
11
app/Contracts/Rewardable.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Rewardable
|
||||
{
|
||||
public function rewards(): MorphMany;
|
||||
public function primaryId(): string;
|
||||
}
|
||||
7
app/Contracts/SmsContract.php
Normal file
7
app/Contracts/SmsContract.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
interface SmsContract
|
||||
{
|
||||
|
||||
}
|
||||
119
app/Contracts/UserContract.php
Normal file
119
app/Contracts/UserContract.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace App\Contracts;
|
||||
|
||||
interface UserContract
|
||||
{
|
||||
//成为临时会员
|
||||
public function getTempMember($user_id);
|
||||
//用户对所有人隐身
|
||||
public function userHidden($user_id,$other_user_id=null);
|
||||
//是否隐身
|
||||
public function isHidden($user_id, $other_user_id, $type);
|
||||
//将好友加入黑名单
|
||||
public function blacklistFriend($user_id, $other_user_id);
|
||||
//黑名单
|
||||
public function blacklist($user_id);
|
||||
//移除黑名单
|
||||
public function deleteBlacklist($id);
|
||||
//移除黑名单通过user_Id
|
||||
public function deleteBlacklistByUser($user_id);
|
||||
//举报
|
||||
public function complaint($request, $user_id, $other_user_id);
|
||||
//反馈
|
||||
public function feedback($request, $user_id);
|
||||
//是否在黑名单
|
||||
public function isBlacklist($user_id, $other_user_id);
|
||||
//动态数
|
||||
public function momentCount($user_id);
|
||||
//反馈列表
|
||||
public function feedbacks($request);
|
||||
//修改反馈状态
|
||||
public function changeFeedbackStatus($request, $feedback_id);
|
||||
//修改投诉状态
|
||||
public function changeComplaintStatus($request, $complaint_id);
|
||||
//修改隐藏信息状态
|
||||
public function changeHiddenProfile($request);
|
||||
//发系统消息
|
||||
public function sendNotice($user_id, $send_user_id, $type, $content, $message = '', $type_id = 0, $path_url=null, $path_type = null);
|
||||
//浏览人数
|
||||
public static function previewCount($user_id, $start_time, $end_time);
|
||||
//是否完成资料
|
||||
public static function isCompleteProfile($user_id);
|
||||
//生活照
|
||||
public function lifePhotos($user_id, $limit=0);
|
||||
//单身个人资料
|
||||
public function singleProfile($user_id);
|
||||
//介绍人个人资料
|
||||
public function marriageProfile($user_id);
|
||||
//人脸识别
|
||||
public function faceDelect($img_url);
|
||||
public function wechatfaceDelect($user_id);
|
||||
//邀请用户列表
|
||||
public function inviteUsers($user_id, $nopage=0);
|
||||
public function inviteUsersCount($wechat, $user);
|
||||
//注册用户信息
|
||||
public function registerAfficial($request);
|
||||
//通过openid判断注册过
|
||||
public function isRegisterByOpenid($openid);
|
||||
//添加公众号信息
|
||||
public function addWechat($request, $openid, $user_id);
|
||||
public function userProfile($user);
|
||||
public function users($request);
|
||||
//公众号奖励
|
||||
public function officialReferreAward($from_user_id, $user_id, $type);
|
||||
//首页征婚
|
||||
public function homeRecommend($request);
|
||||
//平台用户组
|
||||
public function paasUserIds($paas, $type);
|
||||
//注册时有from_user_id
|
||||
public function hasFromUserId($from_user_id, $user_id);
|
||||
//是否已经注册福恋
|
||||
public function getUserByMobile($request);
|
||||
//添加平台与用户关系
|
||||
public function addPaasUser($pass_id, $user_id, $type);
|
||||
//平台注册更新信息
|
||||
public function updateUserProfile($request);
|
||||
//审核头像通过file
|
||||
public function faceDelectByData($data);
|
||||
//首页公告
|
||||
public function announcements($request);
|
||||
//聊天数
|
||||
public function chatMessageNum($status);
|
||||
//系统通知数
|
||||
public function noticeNum($status = 0);
|
||||
//我的
|
||||
public function officialMine();
|
||||
//用户详情
|
||||
public function officialUser($user_id);
|
||||
//添加好友
|
||||
public function officailAddFriend($user_id);
|
||||
public function officialMessageLinkmanList();
|
||||
public function officialMessageLinkmen($request);
|
||||
public function officialUserProfile();
|
||||
//管理员列表
|
||||
public function admins($request);
|
||||
//创建管理员
|
||||
public function createAdmin($request);
|
||||
//修改管理员
|
||||
public function updateAdmin($request, $admin_id);
|
||||
//删除管理员
|
||||
public function deleteAdmin($admin_id);
|
||||
//隐藏手机号
|
||||
public function hideMobile($request, $user_id);
|
||||
//是否是好友
|
||||
public function isFriend($user_id, $id=0);
|
||||
//最近一条系统消息
|
||||
public function lastNotice();
|
||||
//联系人列表
|
||||
public function messageLinkmen();
|
||||
//最近一条助手消息
|
||||
public function lastAssistantMessage();
|
||||
//所有未读消息数
|
||||
public function newNoticeCount($user_id);
|
||||
//app在线用户列表
|
||||
public function onlineUsers();
|
||||
|
||||
public function addUnionUser($mobile, $password, $source, $email, $openid);
|
||||
// public function changeUnionUser(string $mobile, string $password, int $uuid);
|
||||
|
||||
}
|
||||
72
app/Events/ChatMessages.php
Normal file
72
app/Events/ChatMessages.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use App\Models\User;
|
||||
use App\Models\ChatMessage;
|
||||
use App\Models\Notice;
|
||||
class ChatMessages implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
public $user;
|
||||
public $message;
|
||||
public $new_notice_count;
|
||||
public $new_message_count;
|
||||
public $tries = 3;
|
||||
/**
|
||||
* 指定事件被放置在哪个队列上
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $broadcastQueue = 'love';
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message, User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->message = $message;
|
||||
$new_notice_count = Notice::where('user_id', $user->id)->where('status', 0)->count();
|
||||
if (empty($new_notice_count)) {
|
||||
$new_notice_count = 0;
|
||||
}
|
||||
$new_message_count = ChatMessage::where('other_user_id', $user->id)->where('status', 0)->count();
|
||||
if (empty($new_message_count)) {
|
||||
$new_message_count = 0;
|
||||
}
|
||||
$this->new_notice_count = $new_notice_count;
|
||||
$this->new_message_count = $new_message_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
return;
|
||||
}
|
||||
return new PrivateChannel('users.'.$this->user->id.'.chat.message');
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 事件的广播名称。
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function broadcastAs()
|
||||
// {
|
||||
// return 'chat.message';
|
||||
// }
|
||||
}
|
||||
54
app/Events/MessagePosted.php
Normal file
54
app/Events/MessagePosted.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\ChatMessage;
|
||||
use App\Models\User;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class MessagePosted implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Message
|
||||
*
|
||||
* @var Message
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ChatMessage $message, User $user)
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('chat.with.users');
|
||||
}
|
||||
}
|
||||
38
app/Events/News.php
Normal file
38
app/Events/News.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class News implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
|
||||
public $message;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($news_message)
|
||||
{
|
||||
$this->message = $news_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('news');
|
||||
}
|
||||
}
|
||||
93
app/Events/NoticeServer.php
Normal file
93
app/Events/NoticeServer.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use App\Models\Notice;
|
||||
use App\Models\User;
|
||||
use App\Models\ChatMessage;
|
||||
use App\Models\AssistantUser;
|
||||
class NoticeServer implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $user;
|
||||
public $new_notice_count;
|
||||
public $new_message_count;
|
||||
public $new_assistant_message_count;
|
||||
|
||||
/**
|
||||
* 指定事件被放置在哪个队列上
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $broadcastQueue = 'love';
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->new_notice_count = Notice::where('user_id', $this->user->id)->where('status', 0)->count();
|
||||
$this->new_message_count = ChatMessage::where('other_user_id', $this->user->id)->where('user_id', '<>', 1)->where('status', 0)->count();
|
||||
$this->new_assistant_message_count = AssistantUser::where('user_id', $this->user->id)->where('status', 0)->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
return;
|
||||
}
|
||||
if (empty($this->user->id)) {
|
||||
return;
|
||||
}
|
||||
return new PrivateChannel('users.'.$this->user->id.'.notices');
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 事件的广播名称。
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function broadcastAs()
|
||||
// {
|
||||
// return 'notice.server';
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 指定广播数据
|
||||
// *
|
||||
// * @return array
|
||||
// */
|
||||
// public function broadcastWith()
|
||||
// {
|
||||
// return [
|
||||
// 'new_notice_count' => $this->new_notice_count,
|
||||
// 'new_message_count'=> $this->new_message_count,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Determine if this event should broadcast.
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function broadcastWhen()
|
||||
// {
|
||||
// return $this->new_notice_count > 0 || $this->new_notice_count > 0;
|
||||
// }
|
||||
}
|
||||
39
app/Events/OutUserMatch.php
Normal file
39
app/Events/OutUserMatch.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Server\TouristOrder;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
|
||||
class OutUserMatch
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var TouristOrder
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param TouristOrder $order
|
||||
*/
|
||||
public function __construct(TouristOrder $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('UserMatch');
|
||||
}
|
||||
}
|
||||
161
app/Exceptions/Handler.php
Normal file
161
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Http\Response\ResponseJson;
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use App\Utils\Messenger;
|
||||
use App\Mail\ErrorMessage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Jobs\SendMail;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
use ResponseJson;
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
"\league\oauth2-server\src\Exception\OAuthServerException",
|
||||
"\League\OAuth2\Server\Exception\OAuthServerException",
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
$error = $exception->getMessage();
|
||||
$error_arr = [
|
||||
'The resource owner or authorization server denied the request.',
|
||||
'The given payload is invalid.'
|
||||
];
|
||||
if (app()->bound('sentry') && $this->shouldReport($exception) && !in_array($error, $error_arr)) {
|
||||
app('sentry')->captureException($exception);
|
||||
}
|
||||
parent::report($exception);
|
||||
// if(method_exists($exception, 'getStatusCode')){
|
||||
// $status = $exception->getStatusCode();
|
||||
// if ($status == 405 || $status == 404) return;
|
||||
// }elseif($exception instanceof AuthenticationException){
|
||||
// //403不报警
|
||||
// return;
|
||||
// }else{
|
||||
// $status = get_class($exception);
|
||||
// }
|
||||
// $route = Request()->getMethod().':'.Request()->getRequestUri();
|
||||
// if(\Route::getFacadeRoot()->current()){
|
||||
// $action = $status.':'.\Route::getCurrentRoute()->getActionName();
|
||||
// }else{
|
||||
// $action = $status.':非法路由访问错误';
|
||||
// }
|
||||
// if (method_exists($exception, 'getPrevious')) {
|
||||
// $err = $exception->getPrevious();
|
||||
// if (!empty($err)) {
|
||||
// $error = $err->getMessage();
|
||||
// }
|
||||
// }
|
||||
// $files = explode('/', $exception->getFile());
|
||||
// $file = $files[count($files)-1];
|
||||
// $host = request()->gethost();
|
||||
// //参数
|
||||
// $params = json_encode(request()->all());
|
||||
// //服务器ip
|
||||
// $server_ip = isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'';
|
||||
// $client = Request()->header('client-os')?:'other';
|
||||
// if ($error != 'The given payload is invalid.' && $error != 'The resource owner or authorization server denied the request.') {
|
||||
// $message = '服务器异常,前端:'.$client.',ip:'.$server_ip.',域名:'.$host.',位置:'.$route.',操作:'.$action.',控制器:'.$file.',Line:'.$exception->getLine().',参数:'.$params.',用户id:'.(auth()->id()?:'无').',报错内容:'.$error;
|
||||
//// SendMail::dispatch($message)->onQueue('error_email');
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
DB::rollBack();
|
||||
if (method_exists($e, 'getStatusCode')) {
|
||||
if ($e->getStatusCode() == 405) {
|
||||
return $this->failure("没有对应的路由方法");
|
||||
}elseif ($e->getStatusCode() == 404) {
|
||||
return $this->failure("没有对应的路由");
|
||||
}
|
||||
}
|
||||
$this->getError($e);
|
||||
$msg = $e->getMessage();
|
||||
if ($msg == 'Route [login] not defined.') return $this->authFail();
|
||||
if (config('app.env') == 'production') return $this->failure();
|
||||
return $request->expectsJson()
|
||||
? $this->prepareJsonResponse($request, $e)
|
||||
: $this->prepareResponse($request, $e);
|
||||
}
|
||||
|
||||
public function prepareJsonResponse($request, Exception $e)
|
||||
{
|
||||
$data['status'] = $this->isHttpException($e) ? $e->getStatusCode() : 500;
|
||||
if(config('app.debug')){
|
||||
$data['file'] = $e->getFile();
|
||||
$data['line'] = $e->getLine();
|
||||
$data['traces'] = $e->getTrace();
|
||||
}
|
||||
|
||||
$headers = $this->isHttpException($e) ? $e->getHeaders() : [];
|
||||
$message = $e->getMessage();
|
||||
if ($message == 'The given payload is invalid.') {
|
||||
$message = '服务错误,请重试';
|
||||
}
|
||||
return new JsonResponse(
|
||||
[ 'code'=>1,
|
||||
'data'=>$data,
|
||||
'message'=>$data['status'].':'.$message
|
||||
], 200, $headers,
|
||||
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['code'=>2, 'message' => '请登录后访问.'], 200);
|
||||
}
|
||||
|
||||
return redirect()->guest(route('login'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
47
app/Exports/ActiveUserExport.php
Normal file
47
app/Exports/ActiveUserExport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveActiveUser;
|
||||
use App\Exports\Sheets\SaasActiveUser;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class ActiveUserExport implements WithMultipleSheets
|
||||
{
|
||||
protected $start_date, $end_date, $type;
|
||||
public function __construct($start_date, $end_date, $type)
|
||||
{
|
||||
$this->start_date = date('Y-m-d', strtotime($start_date));
|
||||
$this->end_date = date("Y-m-d", strtotime($end_date));
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
if ($this->type) {
|
||||
if ($this->type == "mp") {
|
||||
$sheets = [
|
||||
//福恋用户
|
||||
new LoveActiveUser($this->start_date,$this->end_date),
|
||||
];
|
||||
}else {
|
||||
$sheets = [
|
||||
//Saas用户
|
||||
new SaasActiveUser($this->start_date, $this->end_date),
|
||||
|
||||
];
|
||||
}
|
||||
}else {
|
||||
$sheets = [
|
||||
//福恋用户
|
||||
new LoveActiveUser($this->start_date,$this->end_date),
|
||||
//Saas用户
|
||||
new SaasActiveUser($this->start_date, $this->end_date),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
49
app/Exports/ActivityApplyUserExport.php
Normal file
49
app/Exports/ActivityApplyUserExport.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class ActivityApplyUserExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
'手机号',
|
||||
'是否签到',
|
||||
'签到时间',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $data) {
|
||||
$arr[] = ['name'=>$data->name, 'mobile'=>$data->mobile, 'sex'=>(empty($data->sex)?"未知":($data->sex == 1?"男":"女")), 'hidden_profile'=>$data->hidden_profile == 'ALLSEX'?"已关闭":"未关闭",
|
||||
'is_sign'=>$data->is_sign?'已签到':'未签到','sign_time'=>$data->sign_time];
|
||||
}
|
||||
$arr = collect($arr);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
52
app/Exports/ActivityMemberExport.php
Normal file
52
app/Exports/ActivityMemberExport.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class ActivityMemberExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
'手机号',
|
||||
'性别',
|
||||
'年龄',
|
||||
'介绍人',
|
||||
'身份证号',
|
||||
'是否认证',
|
||||
'生活省份',
|
||||
'生活城市',
|
||||
'成长省份',
|
||||
'成长城市',
|
||||
'微信号'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
45
app/Exports/ActivityMemberExportV2.php
Normal file
45
app/Exports/ActivityMemberExportV2.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class ActivityMemberExportV2 implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
"真实姓名",
|
||||
'手机号',
|
||||
'是否认证',
|
||||
'性别',
|
||||
'编号',
|
||||
'參保信息',
|
||||
'机构'
|
||||
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
73
app/Exports/CityUsersExport.php
Normal file
73
app/Exports/CityUsersExport.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use CommonUtilsService;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
|
||||
class CityUsersExport implements FromCollection ,WithHeadings,WithColumnFormatting,ShouldAutoSize,WithTitle
|
||||
{
|
||||
private $data, $index;
|
||||
public function __construct($data, $index)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->index =$index;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'姓名',
|
||||
'昵称',
|
||||
"手机号",
|
||||
'性别',
|
||||
'年龄',
|
||||
'学历',
|
||||
'省-市',
|
||||
'行业',
|
||||
'信仰',
|
||||
"情感状态",
|
||||
"收入"
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $data) {
|
||||
if ($data->sex > 0 ) {
|
||||
$sex = $data->sex == 1?"男":"女";
|
||||
}else {
|
||||
$sex ="未知";
|
||||
}
|
||||
$age = CommonUtilsService::getAge($data->profileCourtship->birthday);
|
||||
$arr[] = [
|
||||
$data->id, $data->name, $data->nickname, $data->mobile, $sex, $age, $data->profileCourtship->degree, $data->profileCourtship->province."-".$data->profileCourtship->city,
|
||||
$data->industry."/".$data->industry_sub, $data->profileCourtship->belief, $data->profileCourtship->state, $data->profileCourtship->income
|
||||
];
|
||||
}
|
||||
$arr = collect($arr);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return $this->index. "-用户列表";
|
||||
}
|
||||
}
|
||||
35
app/Exports/CommunityActivityExport.php
Normal file
35
app/Exports/CommunityActivityExport.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class CommunityActivityExport implements FromCollection,WithHeadings
|
||||
{
|
||||
protected $activities;
|
||||
|
||||
public function __construct($activities)
|
||||
{
|
||||
$this->activities = $activities;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'标题',
|
||||
'价格',
|
||||
'阅读数',
|
||||
'订单数',
|
||||
'发布时间',
|
||||
'活动时间',
|
||||
'线上/线下',
|
||||
];
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->activities);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
42
app/Exports/DailyMessengerData.php
Normal file
42
app/Exports/DailyMessengerData.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class DailyMessengerData implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'用户直播id',
|
||||
'昵称',
|
||||
'真实姓名',
|
||||
'分享婚姻使者通过人数',
|
||||
'分享新用户人数',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
40
app/Exports/DailyViewerData.php
Normal file
40
app/Exports/DailyViewerData.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
class DailyViewerData implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'用户id',
|
||||
'昵称',
|
||||
'真实姓名',
|
||||
'分享新用户人数',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
49
app/Exports/EvalOrdersExprt.php
Normal file
49
app/Exports/EvalOrdersExprt.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class EvalOrdersExprt implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'名称',
|
||||
'金额',
|
||||
'姓名',
|
||||
'支付状态',
|
||||
'支付类型',
|
||||
'是否使用',
|
||||
'订单号',
|
||||
'时间'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $data) {
|
||||
$arr[] = ['title'=>$data->goods, 'amount'=>$data->price, 'name'=>$data->name, 'pay_status'=>$data->pay_status?"已支付":"未支付",
|
||||
'pay_type'=>($data->pay_type == 'free')?'优惠券':"微信", ''=>($data->user_evaluate&&$data->user_evaluate->evaluate_report)?"已使用":"未使用", 'trade_no'=>$data->trade_no.' ', 'time'=>$data->created_at->toDateTimeString()];
|
||||
}
|
||||
$arr = collect($arr);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
81
app/Exports/FeedbackExport.php
Normal file
81
app/Exports/FeedbackExport.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\User;
|
||||
use App\Models\FeedbackHistory;
|
||||
|
||||
class FeedbackExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $status;
|
||||
private $keyword;
|
||||
private $limit;
|
||||
private $offset;
|
||||
public function __construct($status, $keyword, $limit=15, $offset)
|
||||
{
|
||||
$this->status = $status;
|
||||
$this->keyword = $keyword;
|
||||
$this->limit = $limit;
|
||||
$this->offset = $offset;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'反馈人ID',
|
||||
'反馈人',
|
||||
'反馈人头像地址',
|
||||
'联系方式',
|
||||
'反馈内容',
|
||||
'反馈图片',
|
||||
'反馈时间',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$status = $this->status;
|
||||
$histories = FeedbackHistory::with('user')->whereHas('user', function($sql){
|
||||
$sql->where('id', '>', 0);
|
||||
})->where('status', $status);
|
||||
$keyword = $this->keyword;
|
||||
if ($keyword) {
|
||||
$keyword = trim($keyword);
|
||||
$histories = $histories->where(function($sql) use($keyword){
|
||||
$sql->whereHas('user', function($sql) use($keyword){
|
||||
$sql->where('name', 'like', '%'.$keyword.'%')
|
||||
->orWhere('mobile', 'like', '%'.$keyword.'%');
|
||||
})->orWhere('content', 'like', '%'.$keyword.'%');
|
||||
});
|
||||
|
||||
}
|
||||
$histories = $histories->limit($this->limit)->offset($this->offset)->orderBY('id', 'desc')->get();
|
||||
$data = [];
|
||||
foreach ($histories as $k => &$history) {
|
||||
$data[$k]['user_id'] = $history->user_id;
|
||||
$data[$k]['name'] = $history->user->name;
|
||||
$data[$k]['photo'] = $history->user->photo;
|
||||
$data[$k]['mobile'] = $history->user->mobile;
|
||||
$data[$k]['content'] = $history->content;
|
||||
$data[$k]['photos'] = $history->photos;
|
||||
$data[$k]['created_at'] = $history->created_at;
|
||||
|
||||
}
|
||||
return collect($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
34
app/Exports/LiveLogData.php
Normal file
34
app/Exports/LiveLogData.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\User;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
|
||||
class LiveLogData implements WithMultipleSheets
|
||||
{
|
||||
use Exportable;
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
$sheets = [];
|
||||
$arr = [];
|
||||
foreach ($this->data as $data) {
|
||||
$log_arr = $data['log_arr'];
|
||||
$sheets[] = new \App\Exports\LiveLogDataV2($log_arr,$data['live_id'].'号直播间记录');
|
||||
unset($data['log_arr']);
|
||||
$arr[] = $data;
|
||||
}
|
||||
|
||||
array_unshift($sheets, new \App\Exports\LiveLogDataV3($arr));
|
||||
return $sheets;
|
||||
}
|
||||
|
||||
}
|
||||
48
app/Exports/LiveLogDataV2.php
Normal file
48
app/Exports/LiveLogDataV2.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\User;
|
||||
use App\Models\FeedbackHistory;
|
||||
|
||||
class LiveLogDataV2 implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'直播id',
|
||||
'红娘昵称',
|
||||
'直播次数',
|
||||
'直播开始时间',
|
||||
'直播结束时间',
|
||||
'总时长{单位、秒}',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
43
app/Exports/LiveLogDataV3.php
Normal file
43
app/Exports/LiveLogDataV3.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\User;
|
||||
use App\Models\FeedbackHistory;
|
||||
|
||||
class LiveLogDataV3 implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'直播id',
|
||||
'红娘昵称',
|
||||
'总时长{单位、秒}',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
46
app/Exports/LiveLogDataV4.php
Normal file
46
app/Exports/LiveLogDataV4.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\User;
|
||||
use App\Models\FeedbackHistory;
|
||||
|
||||
class LiveLogDataV4 implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'红娘id',
|
||||
'红娘昵称',
|
||||
'女嘉宾id',
|
||||
'女嘉宾名单',
|
||||
'男嘉宾id',
|
||||
'男家宾名单',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Exports/LiveMakerCoinLog.php
Normal file
66
app/Exports/LiveMakerCoinLog.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
|
||||
use App\Models\MakerScoreLog;
|
||||
use App\Models\User;
|
||||
class LiveMakerCoinLog implements FromCollection,WithHeadings
|
||||
{
|
||||
protected $start_time;
|
||||
protected $end_time;
|
||||
protected $time_arr;
|
||||
public function headings(): array
|
||||
{
|
||||
$start_time = request()->input('start_time');
|
||||
$end_time = request()->input('end_time');
|
||||
//开始时间 周日0点
|
||||
$this->start_time = $start_time?:date('Y-m-d', strtotime('-2 sunday', time()));
|
||||
//结束时间 周六23:59:59
|
||||
$this->end_time = $end_time?:date('Y-m-d' , strtotime('-1 Saturday', time()));
|
||||
$this->time_arr = \CommonUtilsService::daliy($start_time, $end_time);
|
||||
$array = ['id','昵称', '真实姓名'];
|
||||
foreach ($this->time_arr as $time) {
|
||||
$array[] = $time;
|
||||
}
|
||||
$array[] = '剩余福币';
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
|
||||
$data = [];
|
||||
$user_ids = MakerScoreLog::whereBetween('start_time', [$this->start_time, $this->end_time])->distinct()->pluck('user_id');
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$user = User::find($user_id);
|
||||
if (empty($user)) {
|
||||
continue;
|
||||
}
|
||||
$arr['id'] = $user->id;
|
||||
$arr['nickname'] = $user->nickname;
|
||||
$arr['name'] = $user->name;
|
||||
$logs = MakerScoreLog::with('user.coin')->where('user_id', $user_id)->get();
|
||||
foreach ($this->time_arr as $key=>$time) {
|
||||
foreach ($logs as $log) {
|
||||
if ($log->start_time == $time.' 00:00:00') {
|
||||
$arr['coin-'.+ $key] = $log->score;
|
||||
break;
|
||||
}else{
|
||||
$arr['coin-'.+ $key] = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
//剩余福币
|
||||
$arr['remain_amount'] = $user->coin->remain_amount?:'0';
|
||||
$data[]=$arr;
|
||||
}
|
||||
return collect($data);
|
||||
}
|
||||
}
|
||||
52
app/Exports/MarriageExport.php
Normal file
52
app/Exports/MarriageExport.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class MarriageExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'是否认证',
|
||||
'姓名',
|
||||
'手机号',
|
||||
'性别',
|
||||
'身份证号',
|
||||
'信仰',
|
||||
'出生日期',
|
||||
'公司',
|
||||
'省份',
|
||||
'城市',
|
||||
'服务格言',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
42
app/Exports/MatchmakerExport.php
Normal file
42
app/Exports/MatchmakerExport.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class MatchmakerExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
'手机号',
|
||||
'省份',
|
||||
'城市'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
49
app/Exports/MerchantEarningExport.php
Normal file
49
app/Exports/MerchantEarningExport.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class MerchantEarningExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
"ID",
|
||||
"订单号",
|
||||
"来源商家",
|
||||
'订单金额',
|
||||
'订单退款金额',
|
||||
'微信手续费',
|
||||
'提现手续费',
|
||||
'订单时间',
|
||||
'月份'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$arr = [];
|
||||
foreach ($this->data as $data) {
|
||||
$arr[] = ['id'=>$data->id, '订单号'=>$data->trade_no.' ','name'=>$data->goods, 'amount'=>$data->price, 'refund'=>0, 'ratio'=>0.006, 'w_ratio'=>0, 'date'=>$data->created_at->toDateTimeString(), 'month'=> date('m', strtotime($data->created_at->toDateTimeString()))];
|
||||
}
|
||||
$arr = collect($arr);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
54
app/Exports/MessengerExport.php
Normal file
54
app/Exports/MessengerExport.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Models\Live\Messenger;
|
||||
class MessengerExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'姓名',
|
||||
'头像',
|
||||
'手机',
|
||||
'性别',
|
||||
'年龄代',
|
||||
'婚恋状态',
|
||||
'信仰',
|
||||
'出生地',
|
||||
'工作地',
|
||||
'学历',
|
||||
'分享人',
|
||||
'申请时间',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
67
app/Exports/NewUserExport.php
Normal file
67
app/Exports/NewUserExport.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
class NewUserExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'姓名',
|
||||
'昵称',
|
||||
'手机',
|
||||
'性别',
|
||||
'年龄',
|
||||
'学历',
|
||||
'行业',
|
||||
'信仰',
|
||||
'常居地',
|
||||
'情感状态',
|
||||
'收入',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
'D' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = [];
|
||||
foreach($this->data as $row) {
|
||||
switch($row["sex"]) {
|
||||
case 1:
|
||||
$sex = "男";
|
||||
break;
|
||||
case 2:
|
||||
$sex = "女";
|
||||
break;
|
||||
default:
|
||||
$sex = "未知";
|
||||
}
|
||||
$data[] = [
|
||||
$row["user_id"], $row["name"], $row["nickname"], $row["mobile"], $sex, $row["age"],
|
||||
$row["degree"], $row["industry"]."/".$row["industry_sub"], $row["belief"],
|
||||
$row["province"]."-".$row["city"], $row['state'], $row["income"]
|
||||
];
|
||||
}
|
||||
$data = collect($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
49
app/Exports/OrderWorthExport.php
Normal file
49
app/Exports/OrderWorthExport.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
|
||||
class OrderWorthExport implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'订单id',
|
||||
'用户id',
|
||||
'昵称',
|
||||
'价格',
|
||||
'产品',
|
||||
'直接分享人openid',
|
||||
'直接分享人用户id',
|
||||
'是否是同一个用户',
|
||||
'直接分享人收益',
|
||||
'直接分享人昵称',
|
||||
'间接分享人id',
|
||||
'间接分享人手机号',
|
||||
'间接分享人收益',
|
||||
'注册分享人id',
|
||||
'注册分享人手机号',
|
||||
'注册分享人收益'
|
||||
];
|
||||
}
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
50
app/Exports/OrdersExport.php
Normal file
50
app/Exports/OrdersExport.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class OrdersExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
'出生日期',
|
||||
'手机号',
|
||||
'省份',
|
||||
'城市',
|
||||
'是否认证',
|
||||
'年龄',
|
||||
'婚姻状态',
|
||||
'服务',
|
||||
'类型',
|
||||
'购买日期',
|
||||
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
50
app/Exports/ParticipantExport.php
Normal file
50
app/Exports/ParticipantExport.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ParticipantExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'昵称',
|
||||
'性别',
|
||||
'果子数',
|
||||
'领取机会',
|
||||
'关注状态',
|
||||
'领取鼓励金?',
|
||||
'领取最终红包?',
|
||||
'手机号',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
28
app/Exports/ProvinceUserExport.php
Normal file
28
app/Exports/ProvinceUserExport.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveActiveUser;
|
||||
use App\Exports\Sheets\SaasActiveUser;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class ProvinceUserExport implements WithMultipleSheets
|
||||
{
|
||||
protected $users;
|
||||
public function __construct($users)
|
||||
{
|
||||
$this->users = $users;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
$users = $this->users;
|
||||
$sheets = [];
|
||||
$chunks = $users->chunk(1000);
|
||||
for ($i=0; $i < count($chunks); $i++) {
|
||||
$sheets[] = new CityUsersExport($chunks[$i], $i);
|
||||
}
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
48
app/Exports/RedPacketExport.php
Normal file
48
app/Exports/RedPacketExport.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class RedPacketExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'用户id',
|
||||
'类型',
|
||||
'openid',
|
||||
'金额',
|
||||
'是否发放',
|
||||
'手机号',
|
||||
'名字'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
59
app/Exports/ReferreExport.php
Normal file
59
app/Exports/ReferreExport.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Referre;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class ReferreExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'姓名',
|
||||
'邀请人openid',
|
||||
'第一周邀请人数',
|
||||
'其他周邀请人数',
|
||||
'总邀请人数',
|
||||
'额外奖励',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
// dd($this->referres);
|
||||
// $data = ReferreAwardHistory::where('user_id', $this->user_id)->distinct('other_user_id')->select('user_id','other_user_id')->get();
|
||||
// $data = $this->referres;
|
||||
// foreach ($data as $k => $v) {
|
||||
// $data[$k]['name'] = $v['name'];
|
||||
// $data[$k]['openid'] = $v['openid'];
|
||||
// $data[$k]['first_week_count'] = $v['first_week_count'];
|
||||
// $data[$k]['other_week_count'] = $v['other_week_count'];
|
||||
// $data[$k]['bonus_count'] = $v['bonus_count'];
|
||||
// $data[$k]['award'] = $v['award'];
|
||||
// }
|
||||
// dd($data);
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
67
app/Exports/ReferrerInviteUsersExport.php
Normal file
67
app/Exports/ReferrerInviteUsersExport.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Referre;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
class ReferrerInviteUsersExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $user_id;
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'邀请人ID',
|
||||
'被邀请人ID',
|
||||
'姓名',
|
||||
'电话',
|
||||
'类型',
|
||||
'是否认证',
|
||||
'收益金额',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = ReferreAwardHistory::where('user_id', $this->user_id)->distinct('other_user_id')->select('user_id','other_user_id')->get()->toArray();
|
||||
foreach ($data as $k => $v) {
|
||||
$user = User::withTrashed()->where('id', $v['other_user_id'])->first();
|
||||
$amount = ReferreAwardHistory::where('user_id', $this->user_id)->where('other_user_id', $v['other_user_id'])->where('is_hooked', 1)->sum('amount');
|
||||
if (empty($user)) {
|
||||
$data[$k]['name'] = '未知';
|
||||
//行业
|
||||
$data[$k]['mobile'] = '未知';
|
||||
//子行业
|
||||
$data[$k]['type'] = '未知';
|
||||
//团契
|
||||
$data[$k]['is_approved'] = '未知';
|
||||
}else{
|
||||
$data[$k]['name'] = $user->name;
|
||||
$data[$k]['mobile'] = $user->mobile;
|
||||
$data[$k]['type'] = $user->type=='single'?'单身':'介绍人';
|
||||
$data[$k]['is_approved'] = $user->is_approved?'是':'否';
|
||||
}
|
||||
$data[$k]['amount'] = $amount;
|
||||
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
148
app/Exports/ReportExport.php
Normal file
148
app/Exports/ReportExport.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Http\Controllers\UploadController;
|
||||
use App\Models\Server\MerchantReport;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use App\Models\Server\ReportAnswer;
|
||||
use App\Models\Server\TouristOrder;
|
||||
use App\Server\ReportFile;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use PhpOffice\PhpWord\IOFactory;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
class ReportExport
|
||||
{
|
||||
protected $user;
|
||||
public static function export(TouristOrder $order, $start_date=null, $end_date=null)
|
||||
{
|
||||
ini_set('memory_limit', -1);
|
||||
//活动名称
|
||||
$activity_name = $order->desc;
|
||||
//用户报告日期
|
||||
$time_arr = ReportAnswer::where([ 'm_order_id'=> $order->id])->distinct('commitd_at')->pluck('commitd_at')->toArray();
|
||||
sort($time_arr);
|
||||
$new_time_arr = [];
|
||||
if ($start_date && $end_date) {
|
||||
foreach ($time_arr as $time) {
|
||||
if (strtotime($time) >= strtotime($start_date) && strtotime($time) <= strtotime($end_date)) {
|
||||
$new_time_arr[] = $time;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
$new_time_arr = $time_arr;
|
||||
}
|
||||
$php_word = new PhpWord();
|
||||
|
||||
//设置默认样式
|
||||
$php_word->setDefaultFontName('宋体');//字体
|
||||
$php_word->setDefaultFontSize(14);//字号
|
||||
|
||||
$section = $php_word->addSection();
|
||||
|
||||
//预定义样式
|
||||
$imageStyle = ['width' => 150, 'height' => 150, 'align' => 'left'];
|
||||
$font_center = ['align'=>'center'];
|
||||
$font_left = ['align'=>'left'];
|
||||
$pic_height = $pic_width = 150;
|
||||
|
||||
$php_word->addTitleStyle(1, ['bold' => true, 'color' => '000', 'size' => 22, 'name' => '宋体'],$font_center);
|
||||
$section->addTitle(ReportExport::filterOutXMLIllicit($activity_name). '用户报告',1);
|
||||
$section->addTextBreak(2);
|
||||
$php_word->addTitleStyle(2, ['bold' => true, 'color' => '000', 'size' => 16, 'name' => '宋体'],$font_left);
|
||||
|
||||
$fontStyleName = 'textstyle';
|
||||
$php_word->addFontStyle(
|
||||
$fontStyleName,
|
||||
array('name' => '宋体', 'size' => 16, 'color' => '1B2232', 'bold' => true)
|
||||
);
|
||||
foreach ($new_time_arr as $time) {
|
||||
$section->addTitle('·'.date("Y-m-d", strtotime($time)), 2);
|
||||
$section->addTextBreak(1);
|
||||
$answers = ReportAnswer::with('question')->where(['m_order_id'=> $order->id])->where('commitd_at', $time)->get();
|
||||
$index = 1;
|
||||
foreach ($answers as $answer) {
|
||||
if (empty($answer->question)) continue;
|
||||
$section->addText(ReportExport::filterOutXMLIllicit($index.'. '.$answer->question->title), $fontStyleName);
|
||||
if (is_array(json_decode($answer->answer2)) && count(json_decode($answer->answer2))) {
|
||||
$res = implode('、', json_decode($answer->answer2));
|
||||
$section->addText(ReportExport::filterOutXMLIllicit($res), $fontStyleName);
|
||||
}elseif($answer->answer2) {
|
||||
$section->addText(ReportExport::filterOutXMLIllicit($answer->answer2), $fontStyleName);
|
||||
}
|
||||
$section->addText(ReportExport::filterOutXMLIllicit($answer->answer), $fontStyleName);
|
||||
if ($answer->pics) {
|
||||
$pics = json_decode($answer->pics, true);
|
||||
//添加表格
|
||||
$styleTable = [
|
||||
'borderColor' => '006699',
|
||||
'borderSize' => 6,
|
||||
'cellMargin' => 50,
|
||||
];
|
||||
$php_word->addTableStyle('pic_table', $styleTable);
|
||||
$table = $section->addTable('pic_table');
|
||||
|
||||
$cell_index = 1;
|
||||
if ($pics && count($pics)) {
|
||||
foreach ($pics as $pic) {
|
||||
if ($cell_index % 3 == 1) {
|
||||
$table->addRow($pic_height);
|
||||
}
|
||||
if (!strstr($pic, 'x-oss-process')) {
|
||||
$pic = $pic.'?x-oss-process=image/auto-orient,1/resize,p_30/quality,q_80';
|
||||
}
|
||||
try {
|
||||
$table->addCell($pic_width)->addImage($pic, $imageStyle);
|
||||
$cell_index++;
|
||||
}catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$index++;
|
||||
$section->addTextBreak(1);
|
||||
}
|
||||
$section->addTextBreak(1);
|
||||
}
|
||||
|
||||
$writer = IOFactory::createWriter($php_word, 'Word2007');
|
||||
$fileName = '用户报告--' . $order->name .$order->id. '.docx';
|
||||
$path = storage_path('qrcode/') . $fileName;
|
||||
$writer->save($path);
|
||||
$url = '';
|
||||
if (file_exists($path)) {
|
||||
$url = self::uploadFile($path);
|
||||
unlink($path);
|
||||
}
|
||||
ReportFile::updateOrCreate(['order_id'=>$order->id], ['url'=>$url, 'file_type'=>'docx']);
|
||||
// return $url;
|
||||
// return response()->download($url);
|
||||
}
|
||||
|
||||
public static function uploadFile($file)
|
||||
{
|
||||
$ossClient = UploadController::getOssClient();
|
||||
//生成file
|
||||
$object = date('Y').date('m')."/".date('d')."/".basename($file);
|
||||
$url = 'https://'.config('alioss.picture_domain').'/'.$object;
|
||||
try {
|
||||
$ossClient->uploadFile(config('alioss.buckets.picture'), $object, $file);
|
||||
} catch(\OSS\Core\OssException $e) {
|
||||
Log::info($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
private static function filterOutXMLIllicit($htmlStr) {
|
||||
if (empty($htmlStr)) return $htmlStr;
|
||||
$xmlStr=str_replace('<','<',$htmlStr);
|
||||
$xmlStr=str_replace('>','>',$xmlStr);
|
||||
$xmlStr=str_replace('"','"',$xmlStr);
|
||||
$xmlStr=str_replace("'",''',$xmlStr);
|
||||
$xmlStr=str_replace("&",'&',$xmlStr);
|
||||
return $xmlStr;
|
||||
}
|
||||
}
|
||||
42
app/Exports/ReportFormExport.php
Normal file
42
app/Exports/ReportFormExport.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveIncomDetail;
|
||||
use App\Exports\Sheets\LoveIncome;
|
||||
use App\Exports\Sheets\SaasIncome;
|
||||
use App\Exports\Sheets\SaasLoveIncome;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class ReportFormExport implements WithMultipleSheets
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date)
|
||||
{
|
||||
$this->start_date = date('Y-m-d', strtotime($start_date));
|
||||
$this->end_date = date("Y-m-d", strtotime('next month', strtotime($start_date)));
|
||||
}
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
$sheets = [
|
||||
//福恋收入明细
|
||||
new SaasLoveIncome($this->start_date,$this->end_date),
|
||||
//Saas收入明细
|
||||
new SaasIncome($this->start_date, $this->end_date),
|
||||
//福恋小程序会员汇总
|
||||
new LoveIncome($this->start_date, $this->end_date),
|
||||
//福恋小程序会员明细
|
||||
new LoveIncomDetail($this->start_date, $this->end_date)
|
||||
];
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
47
app/Exports/ReportQuarterExport.php
Normal file
47
app/Exports/ReportQuarterExport.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveQuarterIncomDetail;
|
||||
use App\Exports\Sheets\LoveQuarterIncome;
|
||||
use App\Exports\Sheets\SaasLoveQuarterIncome;
|
||||
use App\Exports\Sheets\SaasQuarterIncome;
|
||||
use App\Exports\Sheets\SaasQuarterIncomeDetail;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class ReportQuarterExport implements WithMultipleSheets
|
||||
{
|
||||
|
||||
protected $date_arr;
|
||||
public function __construct($year)
|
||||
{
|
||||
$date_arr = [];
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$start_date = date('Y-'.$i.'-01', strtotime($year));
|
||||
$end_date = date("Y-m-d", strtotime('+1 month', strtotime($start_date)));
|
||||
if ($i <= 3 ) {
|
||||
$date_arr[0][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||||
}elseif ($i > 3 && $i <= 6) {
|
||||
$date_arr[1][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||||
}elseif ($i > 6 && $i <= 9) {
|
||||
$date_arr[2][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||||
}else {
|
||||
$date_arr[3][] = ['start_date'=>$start_date, 'end_date'=>$end_date];
|
||||
}
|
||||
|
||||
}
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
public function sheets(): array
|
||||
{
|
||||
$sheets = [];
|
||||
foreach ($this->date_arr as $key=>$date_arr) {
|
||||
$sheets[] = new SaasLoveQuarterIncome($key, $date_arr);
|
||||
$sheets[] = new SaasQuarterIncome($key, $date_arr);
|
||||
$sheets[] = new SaasQuarterIncomeDetail($key, $date_arr);
|
||||
$sheets[] = new LoveQuarterIncome($key, $date_arr);
|
||||
$sheets[] = new LoveQuarterIncomDetail($key, $date_arr);
|
||||
}
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
50
app/Exports/Sheets/LoveActiveUser.php
Normal file
50
app/Exports/Sheets/LoveActiveUser.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
|
||||
class LoveActiveUser implements FromCollection, WithTitle
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$start_date = $this->start_date;
|
||||
$end_date = $this->end_date;
|
||||
Log::info($start_date.'---'.$end_date);
|
||||
$users = User::with("profileCourtship")->where("type", "<>", "marriage")->whereBetween('last_visit', [$start_date, $end_date])->get();
|
||||
$rows = [
|
||||
["ID", "姓名", "昵称", "联系电话", "是否有过消费", "常住地"]
|
||||
];
|
||||
foreach ($users as $user) {
|
||||
$has_order = Order::where("user_id", $user->id)->where("pay_status", "<>", "UNPAID")->count()?"有":"无";
|
||||
$province = $user->profileCourtship?$user->profileCourtship->province:"";
|
||||
$city = $user->profileCourtship?$user->profileCourtship->city:"";
|
||||
$rows[] = [$user->id, $user->name, $user->nickname, $user->mobile, $has_order, $province, $city];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return '小程序用户';
|
||||
}
|
||||
}
|
||||
79
app/Exports/Sheets/LoveIncomDetail.php
Normal file
79
app/Exports/Sheets/LoveIncomDetail.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
|
||||
class LoveIncomDetail implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$start_date = $this->start_date;
|
||||
$end_date = $this->end_date;
|
||||
Log::info($start_date.'---'.$end_date);
|
||||
$orders = Order::with('refundOrders')->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
友福小程序会员收入明细表", '', '', '', '','','','',''],
|
||||
['ID',"订单号", '商品名册好难过', '订单金额', '订单退款金额', '微信上手续费', '提现手续费', '订单时间', '月份']
|
||||
];
|
||||
$sum = 0;
|
||||
foreach ($orders as $order) {
|
||||
$refund_price = $order->refundOrders->sum('refund_fee');
|
||||
$sum += $order->price;
|
||||
$rows[] = [$order->id, $order->trade_no, $order->goods,$order->price, $refund_price, 0.006, 0, $order->created_at, date('m', strtotime($start_date))];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H",'I'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:I1');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return '友福小程序会员收入明细';
|
||||
}
|
||||
}
|
||||
140
app/Exports/Sheets/LoveIncome.php
Normal file
140
app/Exports/Sheets/LoveIncome.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Course\Course;
|
||||
use App\Models\Live\Anchor;
|
||||
use App\Models\MerchantShop;
|
||||
use App\Models\Order;
|
||||
use App\Models\Server\CommunityActivity;
|
||||
use App\Models\Server\MEarning;
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use App\Models\Server\MerchantEvaluate;
|
||||
use App\Models\Server\MerchantTransferLog;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class LoveIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
|
||||
public function loveContent()
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
福恋产品收入明细表", '', '', '', '', '', '', '', '', '', ''],
|
||||
['ID', "订单号", "商户", "类型", '商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '月份',"支付方式"]
|
||||
];
|
||||
$orders = Order::with('payOrder')->whereBetween('created_at', [$this->start_date, $this->end_date])->where('pay_status', '<>', "UNPAID")->get();
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$pay_type = "微信支付";
|
||||
if ($order->pay_type == 'ios') {
|
||||
$pay_type = "苹果支付";
|
||||
}
|
||||
$merchant_name = "商家(福恋平台)";
|
||||
$refund_fee = $order->refundOrders()->sum("refund_fee");
|
||||
$service_fee = number_format(($order->price - $refund_fee) * 0.006 * -1, 2, '.', '');
|
||||
$earnings = $order->earning()->where('value', '>', 0)->get();
|
||||
$index = 1;
|
||||
if (count($earnings->toArray()) && $earnings->where('user_id', '<>', 0)->count()) {
|
||||
foreach ($earnings as $earning) {
|
||||
$charge = 0.006;
|
||||
$type = "营收";
|
||||
$value = $earning->value;
|
||||
if ($earning->user_id) {
|
||||
$name = User::where('id', $earning->user_id)->value('nickname');
|
||||
$merchant_name = "用户($name)";
|
||||
$charge = 0.02;
|
||||
$service_fee = number_format($earning->value * $charge,2, '.','');
|
||||
$type = "服务费";
|
||||
$value = $earning->value * -1;
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no.' ', $merchant_name, $type, $order->goods, $value, 0, $charge, $service_fee, $order->created_at, date('m', strtotime($this->start_date)), $pay_type];
|
||||
$index++;
|
||||
}
|
||||
}else {
|
||||
Log::info("订单号 ". $order->trade_no);
|
||||
$price = $order->payOrder->cash;
|
||||
$rows[] = [$order->id.'-1', $order->trade_no.' ', $merchant_name, "营收", $order->goods, $price, $refund_fee, '0.006', $service_fee, $order->created_at, date('m', strtotime($this->start_date)), $pay_type];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public function collection()
|
||||
{
|
||||
|
||||
$rows = $this->loveContent();
|
||||
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H",'I','J','K', 'L'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
$event->sheet->getDelegate()->getColumnDimension("C")->setWidth(50);
|
||||
$event->sheet->getDelegate()->getColumnDimension("E")->setWidth(50);
|
||||
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:L1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:L1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:L1265')->getAlignment()->setHorizontal('center');
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:L1');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
// 'B' => NumberFormat::FORMAT_NUMBER, //订单号
|
||||
'F' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'G' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'H' => NumberFormat::FORMAT_PERCENTAGE_00, //金额保留两位小数
|
||||
'I' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return '福恋产品收入';
|
||||
}
|
||||
}
|
||||
151
app/Exports/Sheets/LoveQuarterIncomDetail.php
Normal file
151
app/Exports/Sheets/LoveQuarterIncomDetail.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class LoveQuarterIncomDetail implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $date_arr, $key;
|
||||
public function __construct($key, $date_arr)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'E' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet数据
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
福恋小程序会员收款明细表", '', '', ''],
|
||||
['ID',"订单号", '商品名册好难过', '订单金额', '订单退款金额', '微信上手续费', '提现手续费', '订单时间', '月份']
|
||||
];
|
||||
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$date = date('m', strtotime($start_date));
|
||||
|
||||
$orders = Order::with('refundOrders')->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$sum = 0;
|
||||
foreach ($orders as $order) {
|
||||
$refund_price = $order->refundOrders->sum('refund_fee');
|
||||
|
||||
$sum += $order->price;
|
||||
$rows[] = [$order->id, $order->trade_no, $order->goods,$order->price, $refund_price, 0.006, 0, $order->created_at, $date];
|
||||
}
|
||||
if ($sum) {
|
||||
$rows[] = ['','','合计', $sum, '', '', '', '', ''];
|
||||
}
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
$sum = 0;
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$orders = Order::with('refundOrders')->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
|
||||
$count = count($orders);
|
||||
if ($count) {
|
||||
$count = $count +1;
|
||||
}
|
||||
$sum = $sum + $count;
|
||||
}
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) use($sum){
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F',"G","H",'I'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(80);
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A2:I'.($sum+2))->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A1:I1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 14,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A2:I1080')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 11,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:I1');
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[0]).':E'.($data[0]));
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[1]).':E'.($data[1]));
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[2]).':E'.($data[2]));
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet标题
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return "第".($this->key + 1)."季度福恋程序会员收款明细表";
|
||||
}
|
||||
}
|
||||
|
||||
149
app/Exports/Sheets/LoveQuarterIncome.php
Normal file
149
app/Exports/Sheets/LoveQuarterIncome.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class LoveQuarterIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $date_arr, $key;
|
||||
public function __construct($key, $date_arr)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet数据
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
福恋小程序会员收款明细表", '', '', ''],
|
||||
["序号", '日期', '商品名称', '订单金额', '微信手续费']
|
||||
];
|
||||
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$date = date('Y-m', strtotime($start_date));
|
||||
|
||||
$orders = DB::table("orders")->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->groupBy("goods")->selectRaw('goods, sum(price) as price')->get();
|
||||
$index = 1;
|
||||
$sum = 0;
|
||||
foreach ($orders as $order) {
|
||||
$sum += $order->price;
|
||||
$rows[] = [$index, $date, $order->goods, $order->price, 0.006];
|
||||
$index++;
|
||||
}
|
||||
if ($sum) {
|
||||
$rows[] = ['','','合计', $sum, ''];
|
||||
}
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
$sum = 0;
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$orders = DB::table("orders")->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->groupBy("goods")->selectRaw('goods, sum(price) as price')->get()->toArray();
|
||||
$count = count($orders);
|
||||
if ($count) {
|
||||
$count = $count +1;
|
||||
}
|
||||
$sum = $sum + $count;
|
||||
}
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) use($sum){
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F',"G","H"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(80);
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A2:H'.($sum+2))->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A1:H1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 14,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A2:H'.($sum+2))->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 12,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:H1');
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[0]).':E'.($data[0]));
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[1]).':E'.($data[1]));
|
||||
// $event->sheet->getDelegate()->mergeCells('D'.($data[2]).':E'.($data[2]));
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet标题
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return "第".($this->key + 1)."季度福恋小程序会员汇总";
|
||||
}
|
||||
}
|
||||
57
app/Exports/Sheets/SaasActiveUser.php
Normal file
57
app/Exports/Sheets/SaasActiveUser.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
|
||||
class SaasActiveUser implements FromCollection, WithTitle
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$start_date = $this->start_date;
|
||||
$end_date = $this->end_date;
|
||||
Log::info($start_date.'---'.$end_date);
|
||||
$users = MerchantUser::with("mpUser.profileCourtship","mUserProfile")->whereBetween('authorize_at', [$start_date, $end_date])->get();
|
||||
$rows = [
|
||||
["ID", "姓名", "联系电话", "是否有过消费", "常住地"]
|
||||
];
|
||||
foreach ($users as $user) {
|
||||
$has_order = $user->orders()->where("merchant_id", 491)->where("pay_status", "<>", 0)->where("price", ">", 0)->count()?"有":"无";
|
||||
$mp_user = $user->mpUser;
|
||||
$mp_profile = $user->mpUser?$user->mpUser->profileCourtship:null;
|
||||
$merchant_profile = $user->mUserProfile;
|
||||
$profile = $merchant_profile?:$mp_profile;
|
||||
$province = $profile?$profile->province:"";
|
||||
$city = $profile?$profile->city:"";
|
||||
$nickname = $mp_user?$mp_user->nickname:$user->nickname;
|
||||
$mobile = $mp_user?$mp_user->mobile:$user->mobile;
|
||||
$rows[] = [$user->id, $nickname, $mobile, $has_order, $province."-".$city];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'saas用户';
|
||||
}
|
||||
}
|
||||
173
app/Exports/Sheets/SaasIncome.php
Normal file
173
app/Exports/Sheets/SaasIncome.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Course\Course;
|
||||
use App\Models\Live\Anchor;
|
||||
use App\Models\MerchantShop;
|
||||
use App\Models\Server\CommunityActivity;
|
||||
use App\Models\Server\MEarning;
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use App\Models\Server\MerchantEvaluate;
|
||||
use App\Models\Server\MerchantTransferLog;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SaasIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
public function saasContent($start_date, $end_date)
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS收入明细表", '', '', '', '','','','','','',''],
|
||||
['ID',"订单号", "商户", "性质", "类型",'商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '结算时间', '结算月份']
|
||||
];
|
||||
$earnings = MEarning::with('order', 'order.refunds')->whereHas('order')->where('value', ">", 0)->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$pre_id = null;
|
||||
foreach ($earnings as $earning)
|
||||
{
|
||||
$order = $earning->order;
|
||||
// if(empty($order)) dd($earning->m_order_id);
|
||||
$goods_name = $order->desc;
|
||||
if (empty($order->desc)) {
|
||||
switch ($order->type) {
|
||||
case "community":
|
||||
$goods_name = CommunityActivity::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "course":
|
||||
$goods_name = Course::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "consult":
|
||||
$goods_name = Consultation::where('id', $order->type_id)->value("title");
|
||||
break;
|
||||
case "evaluate":
|
||||
$goods_name = MerchantEvaluate::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
case "shop":
|
||||
$goods_name = MerchantShop::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($order) {
|
||||
if ($earning->m_user_id) {
|
||||
$name = MerchantUser::where('id', $earning->m_user_id)->value('nickname')?:"";
|
||||
$name = "用户( $name )";
|
||||
$poundage = 0.02;
|
||||
}else{
|
||||
$name = Anchor::where('m_id', $earning->m_id)->value('name')?:"";
|
||||
$name = "商家( $name )";
|
||||
$poundage = $order->merchant?($order->merchant->poundage / 100) :0.02;
|
||||
}
|
||||
$type = "代付";
|
||||
$nature = "代收代付";
|
||||
if ($order->merchant_id == 491) {
|
||||
$nature = "福恋";
|
||||
}elseif ($order->merchant_id == 44) {
|
||||
$nature = "福恋(友福)";
|
||||
}
|
||||
$value = "-".$earning->value;
|
||||
if ($order->type == 'transfer') {
|
||||
$log = MerchantTransferLog::where('m_earning_id', $earning->id)->first();
|
||||
if (empty($log)) dd($earning->id);
|
||||
$merchant = MerchantAccount::where('id', $log->m_id)->first();
|
||||
$merchant_name = $merchant&&$merchant->anchorV2?$merchant->anchorV2->name:"未知";
|
||||
$type = "<$merchant_name>转账";
|
||||
$value = $earning->value;
|
||||
}else{
|
||||
if ($pre_id != $earning->m_order_id) {//新订单
|
||||
$index = 0;
|
||||
//提现费率
|
||||
//订单退款
|
||||
$refund_price = $order->refunds->sum('refund_fee')?:0;
|
||||
//订单代收
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, "福恋平台", $nature, "代收", $goods_name, $order->price, $refund_price, 0.006, "-".number_format(($order->price - $refund_price) * 0.006, 2, '.',''), $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
}
|
||||
}
|
||||
|
||||
$index++;
|
||||
if ($order->merchant_id == 491 && $earning->m_user_id == 0) {
|
||||
$poundage_fee = 0;
|
||||
}else {
|
||||
$poundage_fee = number_format($earning->value * $poundage, 4, '.','');
|
||||
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, $name, $nature, $type, $goods_name, $value, 0, $poundage, $poundage_fee, $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
|
||||
$pre_id = $earning->m_order_id;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$rows = $this->saasContent($this->start_date, $this->end_date);
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'G' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'H' => NumberFormat::FORMAT_GENERAL, //金额保留两位小数
|
||||
'I' => NumberFormat::FORMAT_GENERAL, //金额保留两位小数
|
||||
'J' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'B' => NumberFormat::FORMAT_NUMBER, //订单号
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H",'I','J','K', 'L',"M"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
$event->sheet->getDelegate()->getColumnDimension("C")->setWidth(50);
|
||||
$event->sheet->getDelegate()->getColumnDimension("F")->setWidth(50);
|
||||
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:M1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:M1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:M1265')->getAlignment()->setHorizontal('center');
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:M1');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Saas收入';
|
||||
}
|
||||
}
|
||||
181
app/Exports/Sheets/SaasIncomeV2.php
Normal file
181
app/Exports/Sheets/SaasIncomeV2.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Course\Course;
|
||||
use App\Models\Live\Anchor;
|
||||
use App\Models\MerchantShop;
|
||||
use App\Models\Order;
|
||||
use App\Models\Server\CommunityActivity;
|
||||
use App\Models\Server\MEarning;
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use App\Models\Server\MerchantEvaluate;
|
||||
use App\Models\Server\MerchantTransferLog;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use App\Models\TouristOrder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SaasIncomeV2 implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
public function saasContent($start_date, $end_date)
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS收入明细表", '', '', '', '','','','','','',''],
|
||||
['ID',"订单号", "商户", "性质", "类型",'商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '结算时间', '下单月份']
|
||||
];
|
||||
// $earnings = MEarning::with('order', 'order.refunds')->whereHas('order')->where('value', ">", 0)->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$orders = TouristOrder::with("refunds",'earnings')->where('pay_type', '!=', 'free')->where("price", '>', 0)->where('pay_status', "!=", 0)->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$pre_id = null;
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$goods_name = $order->desc;
|
||||
if (empty($order->desc)) {
|
||||
switch ($order->type) {
|
||||
case "community":
|
||||
$goods_name = CommunityActivity::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "course":
|
||||
$goods_name = Course::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "consult":
|
||||
$goods_name = Consultation::where('id', $order->type_id)->value("title");
|
||||
break;
|
||||
case "evaluate":
|
||||
$goods_name = MerchantEvaluate::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
case "shop":
|
||||
$goods_name = MerchantShop::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
}
|
||||
}
|
||||
$nature = "代收代付";
|
||||
if ($order->merchant_id == 491) {
|
||||
$nature = "福恋";
|
||||
}elseif ($order->merchant_id == 44) {
|
||||
$nature = "福恋(友福)";
|
||||
}
|
||||
if ($order->earnings()->count()) {
|
||||
foreach ($order->earnings as $earning) {
|
||||
if ($earning->m_user_id) {
|
||||
$name = MerchantUser::where('id', $earning->m_user_id)->value('nickname')?:"";
|
||||
$name = "用户( $name )";
|
||||
$poundage = 0.02;
|
||||
}else{
|
||||
$name = Anchor::where('m_id', $earning->m_id)->value('name')?:"";
|
||||
$name = "商家( $name )";
|
||||
$poundage = $order->merchant?($order->merchant->poundage / 100) :0.02;
|
||||
}
|
||||
$type = "代付";
|
||||
$value = "-".$earning->value;
|
||||
if ($order->type == 'transfer') {
|
||||
$log = MerchantTransferLog::where('m_earning_id', $earning->id)->first();
|
||||
if (empty($log)) dd($earning->id);
|
||||
$merchant = MerchantAccount::where('id', $log->m_id)->first();
|
||||
$merchant_name = $merchant&&$merchant->anchorV2?$merchant->anchorV2->name:"未知";
|
||||
$type = "<$merchant_name>转账";
|
||||
$value = $earning->value;
|
||||
}else{
|
||||
if ($pre_id != $earning->m_order_id) {//新订单
|
||||
$index = 0;
|
||||
//提现费率
|
||||
//订单退款
|
||||
$refund_price = $order->refunds->sum('refund_fee')?:0;
|
||||
//订单代收
|
||||
$rows[] = [$order->id."-$index", $order->trade_no.' ', "福恋平台", $nature, "代收", $goods_name, $order->price, $refund_price, 0.006, "-".number_format(($order->price - $refund_price) * 0.006, 2, '.',''), $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
}
|
||||
}
|
||||
|
||||
$index++;
|
||||
if ($order->merchant_id == 491 && $earning->m_user_id == 0) {
|
||||
$poundage_fee = 0;
|
||||
}else {
|
||||
$poundage_fee = number_format($earning->value * $poundage, 4, '.','');
|
||||
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no.' ', $name, $nature, $type, $goods_name, $value, 0, $poundage, $poundage_fee, $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
|
||||
$pre_id = $earning->m_order_id;
|
||||
}
|
||||
|
||||
}else {
|
||||
$value = $order->price;
|
||||
$refund_price = $order->refunds->sum('refund_fee')?:0;
|
||||
$rows[] = [$order->id, $order->trade_no.' ', "福恋平台", $nature, "代收", $goods_name, $value, $refund_price, 0, 0, $order->created_at, "未结算", date('m', strtotime($start_date))];
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$rows = $this->saasContent($this->start_date, $this->end_date);
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'G' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'H' => NumberFormat::FORMAT_GENERAL, //金额保留两位小数
|
||||
'I' => NumberFormat::FORMAT_GENERAL, //金额保留两位小数
|
||||
'J' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
// 'B' => NumberFormat::FORMAT_NUMBER, //订单号
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H",'I','J','K', 'L',"M"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
$event->sheet->getDelegate()->getColumnDimension("C")->setWidth(50);
|
||||
$event->sheet->getDelegate()->getColumnDimension("F")->setWidth(50);
|
||||
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:M1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:M1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:M1265')->getAlignment()->setHorizontal('center');
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:M1');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Saas收入';
|
||||
}
|
||||
}
|
||||
192
app/Exports/Sheets/SaasLoveIncome.php
Normal file
192
app/Exports/Sheets/SaasLoveIncome.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
|
||||
class SaasLoveIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date, $end_date)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$start_date = $this->start_date;
|
||||
$end_date = $this->end_date;
|
||||
Log::info($start_date.'---'.$end_date);
|
||||
$merchants = MerchantAccount::with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->whereIn('id', [491, 71])->get();
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS系统 直属福恋收入明细表", '', '', '', '','','',''],
|
||||
["序号", '日期', '收款名称', '金额', '收款手续费','实际到账额','收入到账银行','备注']
|
||||
];
|
||||
$date = date('Y-m', strtotime($start_date));
|
||||
$index = 1;
|
||||
$sum = 0;
|
||||
foreach ($merchants as $merchant) {
|
||||
$amount = $merchant->earnings->sum('value');
|
||||
$sum += $amount;
|
||||
$amount = number_format($merchant->earnings->sum('value'), 2, '.', '') ;
|
||||
$rows[] = [$index, $date, $merchant->anchorV2->name, $amount, '', '', '微信', ''];
|
||||
$index++;
|
||||
}
|
||||
$rows[] = ['', '合计','', $sum, '', '', '', ''];
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F',"G","H"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
// $event->sheet->getDelegate()->getStyle('A11:F18')->getAlignment()->setHorizontal('center');
|
||||
//
|
||||
// //设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
// $event->sheet->getDelegate()->getStyle('A1:F9')->applyFromArray([
|
||||
// 'borders'=> [
|
||||
// 'allBorders' => [
|
||||
// 'borderStyle' =>'thin',
|
||||
// ]
|
||||
// ]
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('A11:F19')->applyFromArray([
|
||||
// 'borders'=> [
|
||||
// 'allBorders' => [
|
||||
// 'borderStyle' =>'thin',
|
||||
// ]
|
||||
// ]
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('1')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => true,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 20,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
// ],
|
||||
// // 'fill' => [
|
||||
// // 'fillType' => 'linear', //线性填充,类似渐变
|
||||
// // 'rotation' => 45, //渐变角度
|
||||
// // 'startColor' => [
|
||||
// // 'rgb' => '000000' //初始颜色
|
||||
// // ],
|
||||
// // //结束颜色,如果需要单一背景色,请和初始颜色保持一致
|
||||
// // 'endColor' => [
|
||||
// // 'argb' => 'FFFFFF'
|
||||
// // ]
|
||||
// // ],
|
||||
//
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('2:9')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => false,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 12,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('11')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => true,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 20,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ]
|
||||
// ],
|
||||
//
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('12:19')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => false,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 12,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// ]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:H1');
|
||||
$event->sheet->getDelegate()->mergeCells('B5:C5');
|
||||
// $event->sheet->getDelegate()->mergeCells('B4:F4');
|
||||
// $event->sheet->getDelegate()->mergeCells('B5:F5');
|
||||
// $event->sheet->getDelegate()->mergeCells('B6:F6');
|
||||
// $event->sheet->getDelegate()->mergeCells('D7:F7');
|
||||
// $event->sheet->getDelegate()->mergeCells('C8:F8');
|
||||
// $event->sheet->getDelegate()->mergeCells('A9:F9');
|
||||
// $event->sheet->getDelegate()->mergeCells('A11:F11');
|
||||
// $event->sheet->getDelegate()->mergeCells('B13:F13');
|
||||
// $event->sheet->getDelegate()->mergeCells('B14:F14');
|
||||
// $event->sheet->getDelegate()->mergeCells('B15:F15');
|
||||
// $event->sheet->getDelegate()->mergeCells('B16:F16');
|
||||
// $event->sheet->getDelegate()->mergeCells('D17:F17');
|
||||
// $event->sheet->getDelegate()->mergeCells('C18:F18');
|
||||
// $event->sheet->getDelegate()->mergeCells('A19:F19');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return '福恋收入明细';
|
||||
}
|
||||
}
|
||||
227
app/Exports/Sheets/SaasLoveQuarterIncome.php
Normal file
227
app/Exports/Sheets/SaasLoveQuarterIncome.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SaasLoveQuarterIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $date_arr, $key;
|
||||
public function __construct($key, $date_arr)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'E' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet数据
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [
|
||||
['',"深圳福恋智能信息科技有限公司
|
||||
|
||||
福恋收款明细表", '', '', '', '','','',''],
|
||||
['',"序号", '日期', '项目名称', '金额', '收款手续费','收入到账银行','备注']
|
||||
];
|
||||
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$date = date('Y年m月', strtotime($start_date));
|
||||
//悦睦、福恋收入
|
||||
$merchants = MerchantAccount::with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->whereIn('id', [491, 71])->get();
|
||||
$sum1 = 0;
|
||||
foreach ($merchants as $merchant) {
|
||||
$amount = $merchant->earnings->sum('value');
|
||||
$sum1 += $amount;
|
||||
}
|
||||
$rows[] = ['',1, $date, '悦睦、福恋', $sum1, 0, '', '微信', ''];
|
||||
|
||||
//SAAS平台收款收入
|
||||
$merchants = MerchantAccount::with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->whereNotIn('id', [491, 71])->get();
|
||||
$sum2 = 0;
|
||||
foreach ($merchants as $merchant) {
|
||||
$amount = $merchant->earnings->sum('value');
|
||||
$sum2 += $amount;
|
||||
}
|
||||
$rows[] = ['',2, $date, 'SAAS平台收款', $sum2, '收取2%手续费收入', '', '微信', ''];
|
||||
|
||||
//小程序收入
|
||||
$sum3 = DB::table("orders")->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->sum('price');
|
||||
$rows[] = ['',3, $date, '小程序会员收款', $sum3, 0, '', '微信', ''];
|
||||
|
||||
$rows[] = ['','', '','合计', $sum1+$sum2+$sum3, '', '', ''];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("B1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(80);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
// $event->sheet->getDelegate()->getStyle('A11:F18')->getAlignment()->setHorizontal('center');
|
||||
//
|
||||
// //设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('B2:H14')->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
//抬头
|
||||
$event->sheet->getDelegate()->getStyle('B1:H1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 14,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
//正文
|
||||
$event->sheet->getDelegate()->getStyle('A2:H14')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 12,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
// $event->sheet->getDelegate()->getStyle('A11:F19')->applyFromArray([
|
||||
// 'borders'=> [
|
||||
// 'allBorders' => [
|
||||
// 'borderStyle' =>'thin',
|
||||
// ]
|
||||
// ]
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('1')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => false,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 14,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
// ],
|
||||
// 'fill' => [
|
||||
// 'fillType' => 'linear', //线性填充,类似渐变
|
||||
// 'rotation' => 45, //渐变角度
|
||||
// 'startColor' => [
|
||||
// 'rgb' => '000000' //初始颜色
|
||||
// ],
|
||||
// //结束颜色,如果需要单一背景色,请和初始颜色保持一致
|
||||
// 'endColor' => [
|
||||
// 'argb' => 'FFFFFF'
|
||||
// ]
|
||||
// ],
|
||||
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('2:9')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => false,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 12,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('11')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => true,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 20,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ]
|
||||
// ],
|
||||
//
|
||||
// ]);
|
||||
// $event->sheet->getDelegate()->getStyle('12:19')->applyFromArray([
|
||||
// 'font' => [
|
||||
// 'name' => 'Arial',
|
||||
// 'bold' => false,
|
||||
// 'italic' => false,
|
||||
// 'strikethrough' => false,
|
||||
// 'size' => 12,
|
||||
// 'color' => [
|
||||
// 'rgb' => '000000'
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// ]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('B1:H1');
|
||||
$event->sheet->getDelegate()->mergeCells('B6:C6');
|
||||
$event->sheet->getDelegate()->mergeCells('B10:C10');
|
||||
$event->sheet->getDelegate()->mergeCells('B14:C14');
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet标题
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return "第".($this->key + 1)."季度福恋各项收款汇总表";
|
||||
}
|
||||
}
|
||||
147
app/Exports/Sheets/SaasQuarterIncome.php
Normal file
147
app/Exports/Sheets/SaasQuarterIncome.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SaasQuarterIncome implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
|
||||
protected $date_arr, $key;
|
||||
public function __construct($key, $date_arr)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet数据
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS系统 直属福恋收款明细表", '', '', '', '','','',''],
|
||||
["序号", '日期', '收款名称', '金额', '收款手续费', '收款手续费','收入到账银行','备注']
|
||||
];
|
||||
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$date = date('Y-m', strtotime($start_date));
|
||||
|
||||
$merchant1 = MerchantAccount::with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->where('id', 71)->first();
|
||||
if ($merchant1) {
|
||||
$amount1 = number_format($merchant1->earnings->sum('value'), 2, '.', '') ;
|
||||
}else {
|
||||
$amount1 = 0;
|
||||
}
|
||||
$rows[] = [1, $date, '悦睦', $amount1, '', '', '微信', ''];
|
||||
$merchant2 = MerchantAccount::with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->where('id', 491)->first();
|
||||
if ($merchant2) {
|
||||
$amount2 = number_format($merchant2->earnings->sum('value'), 2, '.', '') ;
|
||||
}else {
|
||||
$amount2 = 0;
|
||||
}
|
||||
|
||||
$rows[] = [2, $date, "福恋", $amount2, '', '', '微信', ''];
|
||||
$rows[] = ['','', '合计', number_format($amount1 + $amount2, 2, '.', ''), '', '', ''];
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F',"G","H"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(80);
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A2:H11')->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A1:H1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 14,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A2:H1080')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 11,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:H1');
|
||||
$event->sheet->getDelegate()->mergeCells('A5:B5');
|
||||
$event->sheet->getDelegate()->mergeCells('A8:B8');
|
||||
$event->sheet->getDelegate()->mergeCells('A11:B11');
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet标题
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return "第".($this->key + 1)."季度福恋收款明细";
|
||||
}
|
||||
}
|
||||
171
app/Exports/Sheets/SaasQuarterIncomeDetail.php
Normal file
171
app/Exports/Sheets/SaasQuarterIncomeDetail.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SaasQuarterIncomeDetail implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize,WithColumnFormatting
|
||||
{
|
||||
protected $date_arr, $key;
|
||||
public function __construct($key, $date_arr)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->date_arr = $date_arr;
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'D' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'F' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet数据
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS平台收款明细表", '', '', '', '','','',''],
|
||||
["序号", '日期', '收款名称', '金额', '收款手续费2%', 'SAAS平台收款','收入到账银行','备注']
|
||||
];
|
||||
|
||||
foreach ($this->date_arr as $date) {
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$date = date('Y-m', strtotime($start_date));
|
||||
|
||||
$merchants = MerchantAccount::whereNotIn('id', [71,491])->with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->whereHas('anchorV2')->whereHas('earnings', function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
})->get();
|
||||
$index = 1;
|
||||
$sum = 0;
|
||||
foreach ($merchants as $merchant) {
|
||||
$amount = $merchant->earnings->sum('value');
|
||||
$fee = number_format($amount * $merchant->poundage / 100, 2, '.', '');
|
||||
$rows[] = [$index, $date, $merchant->anchorV2->name, $amount, $merchant->poundage .'%', $fee, '微信基本户', ''];
|
||||
$index++;
|
||||
$sum += $fee;
|
||||
}
|
||||
if ($sum) {
|
||||
$rows[] = ['','','', '合计', '', $sum, '', ''];
|
||||
}
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
$data = [];
|
||||
$sum = 0;
|
||||
$index = 0;
|
||||
foreach ($this->date_arr as $date)
|
||||
{
|
||||
$start_date = $date['start_date'];
|
||||
$end_date = $date['end_date'];
|
||||
$count = MerchantAccount::whereNotIn('id', [71,491])->with(['earnings'=> function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
}, 'anchorV2'])->whereHas('anchorV2')->whereHas('earnings', function($sql) use($start_date, $end_date){
|
||||
$sql->where('m_user_id', 0)->whereBetween('created_at', [$start_date, $end_date]);
|
||||
})->count();
|
||||
if ($count == 0) {
|
||||
$data[] = $sum;
|
||||
continue;
|
||||
}
|
||||
if ($index == 0) {
|
||||
$sum += $count+3;
|
||||
}else {
|
||||
$sum += $count+1;
|
||||
}
|
||||
$index ++;
|
||||
$data[] = $sum;
|
||||
}
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) use($data){
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F',"G","H"];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:F1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(80);
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A2:H'.$data[2])->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A1:H1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 14,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A2:H1080')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => '宋体',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 11,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:H1');
|
||||
if (($data[0])) {
|
||||
$event->sheet->getDelegate()->mergeCells('D'.($data[0]).':E'.($data[0]));
|
||||
$event->sheet->getDelegate()->mergeCells('D'.($data[1]).':E'.($data[1]));
|
||||
$event->sheet->getDelegate()->mergeCells('D'.($data[2]).':E'.($data[2]));
|
||||
}
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* sheet标题
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return "第".($this->key + 1)."季度Saas收款明细";
|
||||
}
|
||||
}
|
||||
183
app/Exports/Sheets/TestSheet.php
Normal file
183
app/Exports/Sheets/TestSheet.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnWidths;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
class TestSheet implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$data = $this->data;
|
||||
$rows = [
|
||||
['赤壁市解除医学观察证明书', '', '','','',''],
|
||||
['姓名', $data[0], '性别', $data[1],'联系电话',$data[3]],
|
||||
['身份证号', strval($data[2]).' ', '', '', '', ''],
|
||||
['解除隔离目的地', $data[4], '', '', '', ''],
|
||||
['隔离观察地点', '赤壁市铜锣湾酒店集中隔离医学观察点', '', '', '', ''],
|
||||
['观察时间', '2022年6月7日至2022年6月13日', '','','',''],
|
||||
['是否接触', '否', '解除单位', '赤壁市铜锣湾酒店集中隔离医学观察点', '', ''],
|
||||
['负责人签字', '', '(盖章)', '','',''],
|
||||
['赤壁市新型冠状病毒感染的肺炎防控指挥部 (存根联)', '','','','',''],
|
||||
['', '', '','','',''],
|
||||
['赤壁市解除医学观察证明书', '', '','','',''],
|
||||
['姓名', $data[0], '性别', $data[1],'联系电话',$data[3]],
|
||||
['身份证号', strval($data[2]).' ', '', '', '', ''],
|
||||
['解除隔离目的地', $data[4], '', '', '', ''],
|
||||
['隔离观察地点', '赤壁市铜锣湾酒店集中隔离医学观察点', '', '', '', ''],
|
||||
['观察时间', '2022年6月7日至2022年6月11日', '','','',''],
|
||||
['是否接触', '否', '解除单位', '赤壁市铜锣湾酒店集中隔离医学观察点', '', ''],
|
||||
['负责人签字', '', '(盖章)', '','',''],
|
||||
['赤壁市新型冠状病毒感染的肺炎防控指挥部 (出具联)', '','','','',''],
|
||||
];
|
||||
return collect($rows);
|
||||
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 0; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:F8')->getAlignment()->setHorizontal('center');
|
||||
$event->sheet->getDelegate()->getStyle('A11:F18')->getAlignment()->setHorizontal('center');
|
||||
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A1:F9')->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('A11:F19')->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => true,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 20,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
],
|
||||
// 'fill' => [
|
||||
// 'fillType' => 'linear', //线性填充,类似渐变
|
||||
// 'rotation' => 45, //渐变角度
|
||||
// 'startColor' => [
|
||||
// 'rgb' => '000000' //初始颜色
|
||||
// ],
|
||||
// //结束颜色,如果需要单一背景色,请和初始颜色保持一致
|
||||
// 'endColor' => [
|
||||
// 'argb' => 'FFFFFF'
|
||||
// ]
|
||||
// ],
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('2:9')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 12,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
|
||||
],
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('11')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => true,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 20,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
]
|
||||
],
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('12:19')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 12,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
|
||||
],
|
||||
]);
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:F1');
|
||||
// $event->sheet->getDelegate()->mergeCells('B2:F2');
|
||||
$event->sheet->getDelegate()->mergeCells('B3:F3');
|
||||
$event->sheet->getDelegate()->mergeCells('B4:F4');
|
||||
$event->sheet->getDelegate()->mergeCells('B5:F5');
|
||||
$event->sheet->getDelegate()->mergeCells('B6:F6');
|
||||
$event->sheet->getDelegate()->mergeCells('D7:F7');
|
||||
$event->sheet->getDelegate()->mergeCells('C8:F8');
|
||||
$event->sheet->getDelegate()->mergeCells('A9:F9');
|
||||
$event->sheet->getDelegate()->mergeCells('A11:F11');
|
||||
$event->sheet->getDelegate()->mergeCells('B13:F13');
|
||||
$event->sheet->getDelegate()->mergeCells('B14:F14');
|
||||
$event->sheet->getDelegate()->mergeCells('B15:F15');
|
||||
$event->sheet->getDelegate()->mergeCells('B16:F16');
|
||||
$event->sheet->getDelegate()->mergeCells('D17:F17');
|
||||
$event->sheet->getDelegate()->mergeCells('C18:F18');
|
||||
$event->sheet->getDelegate()->mergeCells('A19:F19');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return ($this->data)[0].'__sheet';
|
||||
}
|
||||
}
|
||||
164
app/Exports/Sheets/TestSheetII.php
Normal file
164
app/Exports/Sheets/TestSheetII.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace App\Exports\Sheets;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnWidths;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
class TestSheetII implements FromCollection, WithTitle, WithEvents, WithStrictNullComparison, ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$data = $this->data;
|
||||
$birthday = \CommonUtilsService::checkCardBirhday($data[2]);
|
||||
$age = \CommonUtilsService::getAge($birthday['tdate']);
|
||||
$rows = [
|
||||
['医学观察解除审批表', '', '','','','','',''],
|
||||
['姓名', $data[0], '性别', $data[1],'年龄',$age,'观察开始日期','6月7日'],
|
||||
['集中医学
|
||||
观察地点', '赤壁市铜锣湾酒店集中隔离医学观察点', '', '', '最后暴露
|
||||
时间', '6月7日','',''],
|
||||
['解除隔离目的地', $data[4], '', '', '身份证号', strval($data[2]).' ','',''],
|
||||
['联系电话', $data[3], '', '', '病例类型', '中高风险地区返赤 (上海)', '', ''],
|
||||
['隔离观察点临床医生意见', '
|
||||
该留观人员于6月7日入住赤壁市铜锣湾酒店集中隔离医学观察点,隔离期间6次核酸检测及4次抗原检测(间隔时间超过24小时)均正常,隔离期间无发热,咳嗽,腹泻等症状。
|
||||
|
||||
签字: 年 月 日', '','','','','',''],
|
||||
['观察点会商意见', '
|
||||
|
||||
|
||||
签字: 年 月 日', '', '', '', '','',''],
|
||||
['指挥部医疗组意见', '', '', '','','','',''],
|
||||
['隔离点落实情况', '隔离点负责人签字: 年 月 日','','','','','',''],
|
||||
];
|
||||
return collect($rows);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['A','B','C','D','E','F','G', 'H'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
|
||||
//设置行高,$i为数据行数
|
||||
for ($i = 0; $i<=5; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
for ($i = 6; $i<=9; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(90);
|
||||
}
|
||||
//设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setVertical('center');
|
||||
//设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:K1265')->getAlignment()->setHorizontal('center');
|
||||
// $event->sheet->getDelegate()->getStyle('B7')->getAlignment()->setVertical('bottom');
|
||||
// $event->sheet->getDelegate()->getStyle('A11:F18')->getAlignment()->setHorizontal('center');
|
||||
//自动换行
|
||||
$event->sheet->getStyle('A1:H9')->getAlignment()->setWrapText(TRUE);
|
||||
|
||||
//设置区域单元格字体、颜色、背景等,其他设置请查看 applyFromArray 方法,提供了注释
|
||||
$event->sheet->getDelegate()->getStyle('A1:H9')->applyFromArray([
|
||||
'borders'=> [
|
||||
'allBorders' => [
|
||||
'borderStyle' =>'thin',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('1')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => true,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 20,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
],
|
||||
// 'fill' => [
|
||||
// 'fillType' => 'linear', //线性填充,类似渐变
|
||||
// 'rotation' => 45, //渐变角度
|
||||
// 'startColor' => [
|
||||
// 'rgb' => '000000' //初始颜色
|
||||
// ],
|
||||
// //结束颜色,如果需要单一背景色,请和初始颜色保持一致
|
||||
// 'endColor' => [
|
||||
// 'argb' => 'FFFFFF'
|
||||
// ]
|
||||
// ],
|
||||
|
||||
]);
|
||||
$event->sheet->getDelegate()->getStyle('2:9')->applyFromArray([
|
||||
'font' => [
|
||||
'name' => 'Arial',
|
||||
'bold' => false,
|
||||
'italic' => false,
|
||||
'strikethrough' => false,
|
||||
'size' => 12,
|
||||
'color' => [
|
||||
'rgb' => '000000'
|
||||
],
|
||||
|
||||
],
|
||||
]);
|
||||
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:H1');
|
||||
// // $event->sheet->getDelegate()->mergeCells('B2:F2');
|
||||
$event->sheet->getDelegate()->mergeCells('B3:D3');
|
||||
$event->sheet->getDelegate()->mergeCells('F3:H3');
|
||||
$event->sheet->getDelegate()->mergeCells('B4:D4');
|
||||
$event->sheet->getDelegate()->mergeCells('F4:H4');
|
||||
$event->sheet->getDelegate()->mergeCells('B5:D5');
|
||||
$event->sheet->getDelegate()->mergeCells('F5:H5');
|
||||
$event->sheet->getDelegate()->mergeCells('B6:H6');
|
||||
$event->sheet->getDelegate()->mergeCells('B7:H7');
|
||||
$event->sheet->getDelegate()->mergeCells('B8:H8');
|
||||
$event->sheet->getDelegate()->mergeCells('B9:H9');
|
||||
// $event->sheet->getDelegate()->mergeCells('B5:F5');
|
||||
// $event->sheet->getDelegate()->mergeCells('B6:F6');
|
||||
// $event->sheet->getDelegate()->mergeCells('D7:F7');
|
||||
// $event->sheet->getDelegate()->mergeCells('C8:F8');
|
||||
// $event->sheet->getDelegate()->mergeCells('A9:F9');
|
||||
// $event->sheet->getDelegate()->mergeCells('A11:F11');
|
||||
// $event->sheet->getDelegate()->mergeCells('B13:F13');
|
||||
// $event->sheet->getDelegate()->mergeCells('B14:F14');
|
||||
// $event->sheet->getDelegate()->mergeCells('B15:F15');
|
||||
// $event->sheet->getDelegate()->mergeCells('B16:F16');
|
||||
// $event->sheet->getDelegate()->mergeCells('D17:F17');
|
||||
// $event->sheet->getDelegate()->mergeCells('C18:F18');
|
||||
// $event->sheet->getDelegate()->mergeCells('A19:F19');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return ($this->data)[0].'__sheet';
|
||||
}
|
||||
}
|
||||
53
app/Exports/SingleExport.php
Normal file
53
app/Exports/SingleExport.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\Wechat;
|
||||
use App\Models\User;
|
||||
use App\Models\ReferreAwardHistory;
|
||||
use Illuminate\Support\Collection;
|
||||
class SingleExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'是否认证',
|
||||
'姓名',
|
||||
'手机号',
|
||||
'性别',
|
||||
'身份证号',
|
||||
'信仰',
|
||||
'出生日期',
|
||||
'公司',
|
||||
'工作省份',
|
||||
'工作城市',
|
||||
'成长省份',
|
||||
'成长城市',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
293
app/Exports/StatementExport.php
Normal file
293
app/Exports/StatementExport.php
Normal file
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Course\Course;
|
||||
use App\Models\Live\Anchor;
|
||||
use App\Models\MerchantShop;
|
||||
use App\Models\Order;
|
||||
use App\Models\Server\CommunityActivity;
|
||||
use App\Models\Server\MEarning;
|
||||
use App\Models\Server\MerchantAccount;
|
||||
use App\Models\Server\MerchantEvaluate;
|
||||
use App\Models\Server\MerchantTransferLog;
|
||||
use App\Models\Server\MerchantUser;
|
||||
use App\Models\Server\TouristOrder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class StatementExport implements FromCollection,WithColumnFormatting, WithEvents, WithStrictNullComparison, ShouldAutoSize
|
||||
{
|
||||
protected $start_date, $end_date, $type;
|
||||
public function __construct($start_date, $type="")
|
||||
{
|
||||
$this->start_date = date('Y-m-d', strtotime($start_date));
|
||||
$this->end_date = date("Y-m-d", strtotime('next month', strtotime($start_date)));
|
||||
$this->type = $type;
|
||||
}
|
||||
public function saasContentV2($start_date, $end_date)
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS收入明细表", '', '', '', '','','','','','',''],
|
||||
['ID',"订单号", "商户", "性质", "类型",'商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '月份']
|
||||
];
|
||||
$orders = TouristOrder::with('mEarning', 'refunds')->where('price', ">", 0)->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$goods_name = $order->goods;
|
||||
if (empty($order->goods)) {
|
||||
switch ($order->type) {
|
||||
case "community":
|
||||
$goods_name = CommunityActivity::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "course":
|
||||
$goods_name = Course::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "consult":
|
||||
$goods_name = Consultation::where('id', $order->type_id)->value("title");
|
||||
break;
|
||||
case "evaluate":
|
||||
$goods_name = MerchantEvaluate::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
case "shop":
|
||||
$goods_name = MerchantShop::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($order) {
|
||||
$earnings = $order->mEarning;
|
||||
$refund_price = $order->refunds->sum('refund_fee')?:0;
|
||||
$poundage = 0.006;
|
||||
$rows[] = [$order->id."-1", $order->trade_no, "福恋平台", "代收", $goods_name, "-".$order->price, $refund_price, $poundage, number_format($order->price * $poundage, 2, '.',''), $order->created_at, date('m', strtotime($start_date))];
|
||||
$index = 2;
|
||||
foreach ($earnings as $earning) {
|
||||
if ($earning->m_user_id) {
|
||||
$name = MerchantUser::where('id', $earning->m_user_id)->value('nickname')?:"";
|
||||
$name = "用户( $name )";
|
||||
$poundage = 0.02;
|
||||
}else{
|
||||
$name = Anchor::where('m_id', $earning->m_id)->value('name')?:"";
|
||||
$name = "商家( $name )";
|
||||
$poundage = $order->merchant?($order->merchant->poundage / 100) :0.02;
|
||||
}
|
||||
$type = "代收";
|
||||
if ($order->type == 'transfer') {
|
||||
$log = MerchantTransferLog::where('m_earning_id', $earning->id)->first();
|
||||
if (empty($log)) dd($earning->id);
|
||||
$merchant = MerchantAccount::where('id', $log->m_id)->first();
|
||||
$merchant_name = $merchant&&$merchant->anchorV2?$merchant->anchorV2->name:"未知";
|
||||
$type = "<$merchant_name>转账";
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, $name, $type, $goods_name, $earning->price, 0, $poundage, number_format($earning->value * $poundage, 2, '.',''), $order->created_at, date('m', strtotime($start_date))];
|
||||
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function saasContent($start_date, $end_date)
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
SAAS收入明细表", '', '', '', '','','','','','',''],
|
||||
['ID',"订单号", "商户", "性质", "类型",'商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '结算时间', '下单月份']
|
||||
];
|
||||
$earnings = MEarning::with('order', 'order.refunds')->whereHas('order')->where('value', ">", 0)->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$pre_id = null;
|
||||
foreach ($earnings as $earning)
|
||||
{
|
||||
$order = $earning->order;
|
||||
// if(empty($order)) dd($earning->m_order_id);
|
||||
$goods_name = $order->goods;
|
||||
if (empty($order->goods)) {
|
||||
switch ($order->type) {
|
||||
case "community":
|
||||
$goods_name = CommunityActivity::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "course":
|
||||
$goods_name = Course::where('id', $order->type_id)->value('title');
|
||||
break;
|
||||
case "consult":
|
||||
$goods_name = Consultation::where('id', $order->type_id)->value("title");
|
||||
break;
|
||||
case "evaluate":
|
||||
$goods_name = MerchantEvaluate::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
case "shop":
|
||||
$goods_name = MerchantShop::where("id", $order->type_id)->value("title");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($order) {
|
||||
if ($earning->m_user_id) {
|
||||
$name = MerchantUser::where('id', $earning->m_user_id)->value('nickname')?:"";
|
||||
$name = "用户( $name )";
|
||||
$poundage = 0.02;
|
||||
}else{
|
||||
$name = Anchor::where('m_id', $earning->m_id)->value('name')?:"";
|
||||
$name = "商家( $name )";
|
||||
$poundage = $order->merchant?($order->merchant->poundage / 100) :0.02;
|
||||
}
|
||||
$type = "代付";
|
||||
$nature = "代收代付";
|
||||
if ($order->merchant_id == 491) {
|
||||
$nature = "福恋";
|
||||
}elseif ($order->merchant_id == 44) {
|
||||
$nature = "福恋(友福)";
|
||||
}
|
||||
$value = "-".$earning->value;
|
||||
if ($order->type == 'transfer') {
|
||||
$log = MerchantTransferLog::where('m_earning_id', $earning->id)->first();
|
||||
if (empty($log)) dd($earning->id);
|
||||
$merchant = MerchantAccount::where('id', $log->m_id)->first();
|
||||
$merchant_name = $merchant&&$merchant->anchorV2?$merchant->anchorV2->name:"未知";
|
||||
$type = "<$merchant_name>转账";
|
||||
$value = $earning->value;
|
||||
}else{
|
||||
if ($pre_id != $earning->m_order_id) {//新订单
|
||||
$index = 0;
|
||||
//提现费率
|
||||
//订单退款
|
||||
$refund_price = $order->refunds->sum('refund_fee')?:0;
|
||||
//订单代收
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, "福恋平台", $nature, "代收", $goods_name, $order->price, $refund_price, 0.006, "-".number_format(($order->price - $refund_price) * 0.006, 2, '.',''), $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
}
|
||||
}
|
||||
|
||||
$index++;
|
||||
if ($order->merchant_id == 491) {
|
||||
$poundage_fee = 0;
|
||||
}else {
|
||||
$poundage_fee = number_format($earning->value * $poundage, 2, '.','');
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, $name, $nature, $type, $goods_name, $value, 0, $poundage, $poundage_fee, $order->created_at, $earning->created_at, date('m', strtotime($start_date))];
|
||||
|
||||
$pre_id = $earning->m_order_id;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function loveContent($start_date, $end_date)
|
||||
{
|
||||
$rows = [
|
||||
["深圳福恋智能信息科技有限公司
|
||||
|
||||
福恋产品收入明细表", '', '', '', '', '', '', '', '', '', ''],
|
||||
['ID', "订单号", "商户", "类型", '商品名称', '金额', '订单退款金额', '手续费率', '手续费', '订单时间', '月份',"支付方式"]
|
||||
];
|
||||
$orders = Order::whereBetween('created_at', [$this->start_date, $this->end_date])->where('pay_status', '<>', "UNPAID")->get();
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$pay_type = "微信支付";
|
||||
if ($order->pay_type == 'ios') {
|
||||
$pay_type = "苹果支付";
|
||||
}
|
||||
$merchant_name = "商家(福恋平台)";
|
||||
$refund_fee = $order->refundOrders()->sum("refund_fee");
|
||||
$service_fee = number_format(($order->price - $refund_fee) * 0.006, 2, '.', '');
|
||||
$earnings = $order->earning()->where('value', '>', 0)->get();
|
||||
$index = 1;
|
||||
if (count($earnings->toArray()) && $earnings->where('user_id', '<>', 0)->count()) {
|
||||
foreach ($earnings as $earning) {
|
||||
$charge = 0.006;
|
||||
$type = "营收";
|
||||
if ($earning->user_id) {
|
||||
$name = User::where('id', $earning->user_id)->value('nickname');
|
||||
$merchant_name = "用户($name)";
|
||||
$charge = 0.02;
|
||||
$service_fee = number_format($earning->value * $charge,2, '.','');
|
||||
$type = "服务费";
|
||||
}
|
||||
$rows[] = [$order->id."-$index", $order->trade_no, $merchant_name, $type, $order->goods, $earning->value, 0, $charge, $service_fee, $order->created_at, date('m', strtotime($this->start_date)), $pay_type];
|
||||
$index++;
|
||||
}
|
||||
}else {
|
||||
$rows[] = [$order->id.'-1', $order->trade_no, $merchant_name, "营收", $order->goods, $order->price, $refund_fee, '0.006', $service_fee, $order->created_at, date('m', strtotime($this->start_date)), $pay_type];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$start_date = $this->start_date;
|
||||
$end_date = $this->end_date;
|
||||
Log::info($start_date.'---'.$end_date);
|
||||
// $orders = Order::with('refundOrders')->where('pay_status','PAID')->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
if ($this->type) {
|
||||
$rows = $this->loveContent($start_date, $end_date);
|
||||
}else {
|
||||
$rows = $this->saasContent($start_date, $end_date);
|
||||
}
|
||||
return collect($rows);
|
||||
}
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'G' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'H' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'I' => NumberFormat::FORMAT_PERCENTAGE_00, //金额保留两位小数
|
||||
'J' => NumberFormat::FORMAT_NUMBER_00, //金额保留两位小数
|
||||
'B' => NumberFormat::FORMAT_NUMBER, //订单号
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
//设置列宽
|
||||
$arr = ['B','C','D','E','F',"G","H",'I','J','K', 'L'];
|
||||
foreach ($arr as $value) {
|
||||
$event->sheet->getDelegate()->getColumnDimension($value)->setWidth(20);
|
||||
}
|
||||
$event->sheet->getDelegate()->getColumnDimension("C")->setWidth(50);
|
||||
|
||||
//自动换行
|
||||
$event->sheet->getStyle("A1:L1")->getAlignment()->setWrapText(TRUE);
|
||||
$event->sheet->getDelegate()->getRowDimension(1)->setRowHeight(50);
|
||||
// //设置行高,$i为数据行数
|
||||
for ($i = 2; $i<=1265; $i++) {
|
||||
$event->sheet->getDelegate()->getRowDimension($i)->setRowHeight(30);
|
||||
}
|
||||
// //设置区域单元格垂直居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:L1265')->getAlignment()->setVertical('center');
|
||||
// //设置区域单元格水平居中
|
||||
$event->sheet->getDelegate()->getStyle('A1:L1265')->getAlignment()->setHorizontal('center');
|
||||
//合并单元格
|
||||
$event->sheet->getDelegate()->mergeCells('A1:L1');
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Saas收入明细';
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Exports/StatementExportV2.php
Normal file
30
app/Exports/StatementExportV2.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveIncome;
|
||||
use App\Exports\Sheets\SaasIncome;
|
||||
|
||||
class StatementExportV2 implements \Maatwebsite\Excel\Concerns\WithMultipleSheets
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date)
|
||||
{
|
||||
$this->start_date = date('Y-m-d', strtotime($start_date));
|
||||
$this->end_date = date("Y-m-d", strtotime('next month', strtotime($start_date)));
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function sheets(): array
|
||||
{
|
||||
// TODO: Implement sheets() method.
|
||||
$sheets = [
|
||||
//Saas收入明细
|
||||
new SaasIncome($this->start_date, $this->end_date),
|
||||
//福恋产品收入明细
|
||||
new LoveIncome($this->start_date,$this->end_date),
|
||||
];
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
32
app/Exports/StatementExportV3.php
Normal file
32
app/Exports/StatementExportV3.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Exports\Sheets\LoveIncome;
|
||||
use App\Exports\Sheets\SaasIncomeV2;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class StatementExportV3 implements WithMultipleSheets
|
||||
{
|
||||
protected $start_date, $end_date;
|
||||
public function __construct($start_date)
|
||||
{
|
||||
$this->start_date = date('Y-m-d', strtotime($start_date));
|
||||
$this->end_date = date("Y-m-d", strtotime('next month', strtotime($start_date)));
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function sheets(): array
|
||||
{
|
||||
// TODO: Implement sheets() method.
|
||||
$sheets = [
|
||||
//Saas收入明细
|
||||
new SaasIncomeV2($this->start_date, $this->end_date),
|
||||
//福恋产品收入明细
|
||||
new LoveIncome($this->start_date,$this->end_date),
|
||||
];
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
97
app/Exports/TestExport.php
Normal file
97
app/Exports/TestExport.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Sheets\TestSheet;
|
||||
use App\Exports\Sheets\TestSheetII;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class TestExport implements WithEvents,WithDrawings,FromArray
|
||||
{
|
||||
use Exportable;
|
||||
protected $data;
|
||||
protected $id;
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return [
|
||||
['供应商名称', '经营许可证'],
|
||||
['测试供应商1', 'https://image.fulllinkai.com/202302/06/01728541-EE2A-4F20-A897-805050FF1748.png',],
|
||||
['测试供应商2', ''],
|
||||
];
|
||||
}
|
||||
|
||||
//自定义单元格格式
|
||||
public function columnFormats(): array
|
||||
{ dd(2);
|
||||
// return [
|
||||
// 'B' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||
// 'C' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,
|
||||
// ];
|
||||
return [];
|
||||
}
|
||||
|
||||
//自定义宽
|
||||
public function columnWidths(): array
|
||||
{ dd(3);
|
||||
return [
|
||||
'A'=>'20',
|
||||
'B'=>'20',
|
||||
'C'=>'20',
|
||||
'D'=>'20',
|
||||
'E'=>'20',
|
||||
'F'=>'20',
|
||||
'G'=>'20',
|
||||
'H'=>'20',
|
||||
'I'=>'20',
|
||||
'J'=>'20',
|
||||
'K'=>'20',
|
||||
'L'=>'20',
|
||||
'M'=>'20',
|
||||
'N'=>'20',
|
||||
];
|
||||
}
|
||||
//导出图片
|
||||
public function drawings()
|
||||
{
|
||||
// $draw_arr = [1=>'img.png',2=>'img1.png'];
|
||||
$draw_arr = ['https://image.fulllinkai.com/202302/06/01728541-EE2A-4F20-A897-805050FF1748.png', 'https://image.fulllinkai.com/202302/06/timg%20(2).jpg'];
|
||||
$result = [];
|
||||
foreach ($draw_arr as $k => $v) {
|
||||
${'drawing'.$k} = new Drawing();
|
||||
${'drawing'.$k}->setName('Other image');
|
||||
${'drawing'.$k}->setDescription('This is a second image');
|
||||
//图片路径
|
||||
// ${'drawing'.$k}->setPath(public_path($v));
|
||||
${'drawing'.$k}->setPath($v);
|
||||
|
||||
${'drawing'.$k}->setIsURL(true);
|
||||
${'drawing'.$k}->setHeight(50);
|
||||
//设置图片列
|
||||
${'drawing'.$k}->setCoordinates('B'.$k);
|
||||
$result[] = ${'drawing'.$k};
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
//自定义高
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event){
|
||||
$event->sheet->getDelegate()->getDefaultRowDimension()->setRowHeight(50);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
52
app/Exports/TongMessengerData.php
Normal file
52
app/Exports/TongMessengerData.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class TongMessengerData implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'等级id',
|
||||
'用户id',
|
||||
'等级名称',
|
||||
'昵称',
|
||||
'手机号',
|
||||
'性别',
|
||||
'年龄',
|
||||
'婚姻状态',
|
||||
'信仰',
|
||||
'学历',
|
||||
'出生省份',
|
||||
'出生城市',
|
||||
'工作省份',
|
||||
'工作城市',
|
||||
'时间'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
97
app/Exports/TouristOrdersEarningExport.php
Normal file
97
app/Exports/TouristOrdersEarningExport.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;//设置单元格数据格式
|
||||
|
||||
|
||||
class TouristOrdersEarningExport //implements FromCollection //,WithHeadings//,WithStrictNullComparison,ShouldAutoSize,WithStyles//,WithCustomValueBinder //,WithColumnFormatting
|
||||
{
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
protected $data;
|
||||
private $title;
|
||||
private $earningNum = []; //一个订单的商品数量
|
||||
private $column; //总行数
|
||||
public function __construct($data, $title = '')
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->title = $title;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'订单号','序号(系统订单号)','支付微信昵称','手机号','订单金额', '商家收入','系统支付状态', '系统支付时间', '购买渠道', '物品名称', '推广用户昵称',
|
||||
'推广用户手机号','推广比例','推广金额','推广类型','分成时间',
|
||||
];
|
||||
}
|
||||
|
||||
public function collection_a()
|
||||
{
|
||||
$list = [];
|
||||
$data = $this->data;
|
||||
foreach ($data as $key =>$value){
|
||||
$this->earningNum[] = count($value['m_earning']);
|
||||
if(!empty($value['m_earning'])) {
|
||||
foreach ($value['m_earning'] as $k => $item) {
|
||||
if (!empty($item['user'])) {
|
||||
$share_name = $item['user']['nickname'];
|
||||
$share_mobile = $item['user']['mobile'];
|
||||
} elseif (!empty($item['merchant'])) {
|
||||
$share_name = $item['merchant']['share_title'];
|
||||
$share_mobile = $item['merchant']['mobile'];
|
||||
} else {
|
||||
$share_name = '';
|
||||
$share_mobile = '';
|
||||
}
|
||||
$list[] = [
|
||||
'id'=>$value['id'],
|
||||
'trade_no' => $value['trade_no'],
|
||||
'name' => $value['name'],
|
||||
'mobile' => $value['mobile'],
|
||||
'price' => $value['price'],
|
||||
'merchant_price' => $value['can_withdraw_count'],
|
||||
'pay_status' => '完成支付',
|
||||
'created_at' => $value['created_at'],
|
||||
'channel' => $value['channel'],
|
||||
'goods' => $value['desc'],
|
||||
'share_name' => $share_name,
|
||||
'share_mobile' => (string)$share_mobile,
|
||||
'share_ratio' => $item['ratio'],
|
||||
'share_value' => $item['value'],
|
||||
'share_type' => $item['sharer'],
|
||||
'share_data' => $item['created_at'],
|
||||
'total' => $value['total'],
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$list[] = [
|
||||
'id'=>$value['id'],
|
||||
'trade_no' => $value['trade_no'],
|
||||
'name' => $value['name'],
|
||||
'mobile' => $value['mobile'],
|
||||
'price' => $value['price'],
|
||||
'merchant_price' =>'0.00',
|
||||
'pay_status' => '完成支付',
|
||||
'created_at' => $value['created_at'],
|
||||
'channel' => $value['channel'],
|
||||
'goods' => $value['desc'],
|
||||
'share_name' => '',
|
||||
'share_mobile' => '',
|
||||
'share_ratio' => '',
|
||||
'share_value' => '',
|
||||
'share_type' => '',
|
||||
'share_data' => '',
|
||||
'total' => $value['total'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//$this->column = count($list);
|
||||
//return collect($list);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
66
app/Exports/TouristOrdersExport.php
Normal file
66
app/Exports/TouristOrdersExport.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison; //为空时零填充
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //自动单元格尺寸
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;//设置单元格数据格式
|
||||
|
||||
class TouristOrdersExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'订单ID',
|
||||
'订单号',
|
||||
'订单类型',
|
||||
'类型ID',
|
||||
'支付状态',
|
||||
'品名',
|
||||
'规格',
|
||||
'份数',
|
||||
'订单姓名',
|
||||
'订单手机号',
|
||||
'下单日期',
|
||||
'实名认证',
|
||||
'真人认证',
|
||||
'头像认证',
|
||||
'学历认证',
|
||||
'昵称',
|
||||
'性别',
|
||||
'手机号',
|
||||
'行业',
|
||||
'二维码',
|
||||
'年龄',
|
||||
'信仰',
|
||||
'生日',
|
||||
'常居地',
|
||||
'成长地',
|
||||
'学历',
|
||||
'年收入'
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
129
app/Exports/UserApprovedExport.php
Normal file
129
app/Exports/UserApprovedExport.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use App\Models\ApproveHistory;
|
||||
class UserApprovedExport implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'序号',
|
||||
'部门',
|
||||
'姓名',
|
||||
'推广号码',
|
||||
'人数',
|
||||
];
|
||||
}
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$workers = $this->workers();
|
||||
$start_time = request()->input('start_time');
|
||||
$end_time = request()->input('end_time');
|
||||
$logs = ApproveHistory::with('fromUser')->where('type', 'body')->where('status', 1)->whereBetween('created_at', [$start_time, $end_time])->get();
|
||||
foreach ($logs as $log) {
|
||||
foreach ($workers as &$worker) {
|
||||
$type = 0;
|
||||
if ($log->from_user_id) {
|
||||
if ($worker['mobile'] == $log->fromUser->mobile) {
|
||||
$worker['num'] += 1;
|
||||
$type = 1;
|
||||
break;
|
||||
}
|
||||
if ($worker['mobile'] != $log->fromUser->mobile && $worker['id'] == 57) {
|
||||
$worker['num'] += 1;
|
||||
$type = 1;
|
||||
break;
|
||||
}
|
||||
}else{// no from_user_id
|
||||
if ($worker['name'] == '未记录') {
|
||||
$worker['num'] += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$workers[] = ['id'=>'总数', 'num'=>count($logs)];
|
||||
$data = collect($workers);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function workers()
|
||||
{
|
||||
$arr = [
|
||||
['id'=>1, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>13058071372, 'num'=>0],
|
||||
['id'=>2, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>18145852809, 'num'=>0],
|
||||
['id'=>3, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>13122565695, 'num'=>0],
|
||||
['id'=>4, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>15800001890, 'num'=>0],
|
||||
['id'=>5, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>13751693656, 'num'=>0],
|
||||
['id'=>6, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>13202316035, 'num'=>0],
|
||||
['id'=>7, 'branch'=>'客服部', 'name'=>'谭妙平', 'mobile'=>15818572612, 'num'=>0],
|
||||
['id'=>8, 'branch'=>'客服部', 'name'=>'阳平', 'mobile'=>15659761561, 'num'=>0],
|
||||
['id'=>9, 'branch'=>'客服部', 'name'=>'金虹燕', 'mobile'=>13600158195, 'num'=>0],
|
||||
['id'=>10, 'branch'=>'客服部', 'name'=>'杨乐恩', 'mobile'=>13249888386, 'num'=>0],
|
||||
['id'=>11, 'branch'=>'客服部', 'name'=>'杨乐恩', 'mobile'=>15018266605, 'num'=>0],
|
||||
['id'=>12, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>17666132809, 'num'=>0],
|
||||
['id'=>13, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>13671968879, 'num'=>0],
|
||||
['id'=>14, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>13265478879, 'num'=>0],
|
||||
['id'=>15, 'branch'=>'客服部', 'name'=>'张聿俊', 'mobile'=>15629390906, 'num'=>0],
|
||||
['id'=>16, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>13266890532, 'num'=>0],
|
||||
['id'=>17, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>13929563819, 'num'=>0],
|
||||
['id'=>18, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>18194066804, 'num'=>0],
|
||||
['id'=>19, 'branch'=>'商务部', 'name'=>'林文静', 'mobile'=>13428728141, 'num'=>0],
|
||||
['id'=>20, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>18922809346, 'num'=>0],
|
||||
['id'=>21, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>13670180767, 'num'=>0],
|
||||
['id'=>22, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>18818570521, 'num'=>0],
|
||||
['id'=>23, 'branch'=>'商务部', 'name'=>'王庆吉', 'mobile'=>15989575285, 'num'=>0],
|
||||
['id'=>24, 'branch'=>'商务部', 'name'=>'张艳彬', 'mobile'=>13377553550, 'num'=>0],
|
||||
['id'=>25, 'branch'=>'商务部', 'name'=>'李芳贤', 'mobile'=>18711720959, 'num'=>0],
|
||||
['id'=>26, 'branch'=>'商务部', 'name'=>'李芳贤', 'mobile'=>17688979885, 'num'=>0],
|
||||
['id'=>27, 'branch'=>'商务部', 'name'=>'熊怡凯', 'mobile'=>13809640078, 'num'=>0],
|
||||
['id'=>28, 'branch'=>'商务部', 'name'=>'赵艳敏', 'mobile'=>13266550216, 'num'=>0],
|
||||
['id'=>29, 'branch'=>'新媒体', 'name'=>'殷配环', 'mobile'=>15820768996, 'num'=>0],
|
||||
['id'=>30, 'branch'=>'新媒体', 'name'=>'李昆', 'mobile'=>18677369475, 'num'=>0],
|
||||
['id'=>31, 'branch'=>'新媒体', 'name'=>'黎美余', 'mobile'=>13420978248, 'num'=>0],
|
||||
['id'=>32, 'branch'=>'新媒体', 'name'=>'谭宏', 'mobile'=>18879165527, 'num'=>0],
|
||||
['id'=>33, 'branch'=>'新媒体', 'name'=>'周金辉', 'mobile'=>13178822477, 'num'=>0],
|
||||
['id'=>34, 'branch'=>'新媒体', 'name'=>'周金辉', 'mobile'=>18898888797, 'num'=>0],
|
||||
['id'=>35, 'branch'=>'新媒体', 'name'=>'赵淑美', 'mobile'=>13510197130, 'num'=>0],
|
||||
['id'=>36, 'branch'=>'客服部', 'name'=>'郭鳌', 'mobile'=>18402011334, 'num'=>0],
|
||||
['id'=>37, 'branch'=>'行政', 'name'=>'王美玲', 'mobile'=>15323715085, 'num'=>0],
|
||||
['id'=>38, 'branch'=>'行政', 'name'=>'王美玲', 'mobile'=>13829133831, 'num'=>0],
|
||||
['id'=>39, 'branch'=>'特别', 'name'=>'金文文', 'mobile'=>19925470983, 'num'=>0],
|
||||
['id'=>40, 'branch'=>'特别', 'name'=>'李雪花', 'mobile'=>18038040879, 'num'=>0],
|
||||
['id'=>41, 'branch'=>'特别', 'name'=>'李雪花', 'mobile'=>15914022467, 'num'=>0],
|
||||
['id'=>42, 'branch'=>'特别', 'name'=>'李恒飞', 'mobile'=>13138853376, 'num'=>0],
|
||||
['id'=>43, 'branch'=>'技术', 'name'=>'蓝志辉', 'mobile'=>15622316024, 'num'=>0],
|
||||
['id'=>44, 'branch'=>'技术', 'name'=>'黄济', 'mobile'=>15872844805, 'num'=>0],
|
||||
['id'=>45, 'branch'=>'技术', 'name'=>'廖世熙', 'mobile'=>15779459915, 'num'=>0],
|
||||
['id'=>46, 'branch'=>'技术', 'name'=>'曾斌', 'mobile'=>15112292112, 'num'=>0],
|
||||
['id'=>47, 'branch'=>'技术', 'name'=>'林兰', 'mobile'=>15012955320, 'num'=>0],
|
||||
['id'=>48, 'branch'=>'技术', 'name'=>'邓智锋', 'mobile'=>15707534403, 'num'=>0],
|
||||
['id'=>49, 'branch'=>'技术', 'name'=>'申维祯', 'mobile'=>18363129725, 'num'=>0],
|
||||
['id'=>50, 'branch'=>'技术', 'name'=>'曾荣耀', 'mobile'=>18922809435, 'num'=>0],
|
||||
['id'=>51, 'branch'=>'技术', 'name'=>'叶其焕', 'mobile'=>13682473213, 'num'=>0],
|
||||
['id'=>52, 'branch'=>'技术', 'name'=>'王立军', 'mobile'=>15211212467, 'num'=>0],
|
||||
['id'=>53, 'branch'=>'技术', 'name'=>'吕燕青', 'mobile'=>13536370059, 'num'=>0],
|
||||
['id'=>54, 'branch'=>'技术', 'name'=>'刘晋', 'mobile'=>18171893605, 'num'=>0],
|
||||
['id'=>55, 'branch'=>'技术', 'name'=>'秦磊', 'mobile'=>18667151881, 'num'=>0],
|
||||
['id'=>56, 'branch'=>'技术', 'name'=>'杨少锋', 'mobile'=>18778113153, 'num'=>0],
|
||||
['id'=>57, 'branch'=>'', 'name'=>'其他人', 'mobile'=>'', 'num'=>0],
|
||||
['id'=>58, 'branch'=>'', 'name'=>'未记录', 'mobile'=>'', 'num'=>0]
|
||||
];
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
40
app/Exports/UserCoinExport.php
Normal file
40
app/Exports/UserCoinExport.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class UserCoinExport implements FromCollection ,WithHeadings,WithStrictNullComparison,WithColumnFormatting,ShouldAutoSize
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'昵称',
|
||||
'福币',
|
||||
];
|
||||
}
|
||||
//设置列格式
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data);
|
||||
}
|
||||
|
||||
}
|
||||
44
app/Exports/UserDataExport.php
Normal file
44
app/Exports/UserDataExport.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat; //设置单元格数据格式
|
||||
|
||||
class UserDataExport implements FromCollection,WithHeadings
|
||||
{
|
||||
private $data;
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'昵称',
|
||||
'真实姓名',
|
||||
'性别',
|
||||
'电话',
|
||||
'角色',
|
||||
'微信',
|
||||
'生活省份',
|
||||
'生活城市',
|
||||
'出生省份',
|
||||
'出生城市',
|
||||
];
|
||||
}
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
public function collection()
|
||||
{
|
||||
$data = collect($this->data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
19
app/Facades/AlipayService.php
Normal file
19
app/Facades/AlipayService.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class AlipayService extends Facade
|
||||
|
||||
{
|
||||
|
||||
protected static function getFacadeAccessor()
|
||||
|
||||
{
|
||||
|
||||
return 'alipay';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
19
app/Facades/AliyunService.php
Normal file
19
app/Facades/AliyunService.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class AliyunService extends Facade
|
||||
|
||||
{
|
||||
|
||||
protected static function getFacadeAccessor()
|
||||
|
||||
{
|
||||
|
||||
return 'aliyunservice';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user