1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
<?php
/**
* fishow共通
* $Id: CompassHandler.inc,v 1.1 2015/10/08 13:34:45 g_wang Exp $
* @author $Author: g_wang $
* @access public
* @package jp.fishow.handler
*/
class CompassHandler{
/**
* API请求时发生错误
*/
public static function responseApiNg($error_code = 0, $error_message = null) {
$arr = ["status"=>"NG", "error_code"=>$error_code, "error_message"=>$error_message];
echo json_encode($arr);
exit;
}
/**
* API请求时返回正常结果
*/
public static function responseApiOk($result = []) {
$arr = ["status"=>"OK", "data"=>$result];
echo json_encode($arr);
exit;
}
/**
* 图片显示URL取得
* child_path(不包含"/")
*/
public static function getImageUrl($file_name, $type, $child_path) {
$file_path = IMAGES_PATH;
if ($type == "theme") {
$file_path = THEME_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "article") {
$file_path = ARTICLE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "category") {
$file_path = ARTICLE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "course") {
$file_path = COURSE_IMAGES_PATH;
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else if ($type == "video") {
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
} else {
if(!empty($child_path)) {
$file_path .= "/" . $child_path;
}
$file_path .= "/" . $file_name;
}
$url = "display_image.php?type={type}&child_path={child_path}&file_name={file_name}";
$url = str_replace("{child_path}", $child_path, $url);
$url = str_replace("{file_name}", $file_name, $url);
$url = str_replace("{type}", $type, $url);
return $url;
}
/**
* 获取图集的目录下文件列表
*/
public static function getArticleImages($articleDat) {
$resultArray = array();
if(empty($articleDat) || empty($articleDat->image_path)) {
return $resultArray;
}
$image_full_path = IMAGES_PATH . "/" . $articleDat->image_path;
if(!is_dir($image_full_path)) {
return $resultArray;
}
//遍历读取列表
if($dh = @opendir($image_full_path)){
//读取
while(($file = readdir($dh)) !== false){
if($file != '.' && $file != '..'){
$resultArray[] = $file;
}
}
//关闭
closedir($dh);
}
return $resultArray;
}
/**
* 获取图集的目录下文件列表图片数量
*/
public static function getArticleImagesCount($articleDat) {
$resultCount = 0;
if(empty($articleDat) || empty($articleDat->image_path)) {
return $resultCount;
}
$image_full_path = IMAGES_PATH . "/" . $articleDat->image_path;
if(!is_dir($image_full_path)) {
return $resultCount;
}
//遍历读取列表
if($dh = @opendir($image_full_path)){
//读取
while(($file = readdir($dh)) !== false){
if($file != '.' && $file != '..'){
$resultCount++;
}
}
//关闭
closedir($dh);
}
return $resultCount;
}
/**
* 获取网络图片并保存
*/
public static function grabImage($url, $filename = "") {
//如果$url地址为空,直接退出
if(empty($url)){
return false;
}
//如果没有指定新的文件名
if(empty($filename)){
return false;
}
ob_start();//打开输出
//输出图片文件
if(!readfile($url)) {
return false;
}
$img = ob_get_contents();//得到浏览器输出
ob_end_clean();//清除输出并关闭
$size = strlen($img);//得到图片大小
$fp2 = @fopen($filename, "a");
fwrite($fp2, $img);//向当前目录写入图片文件,并重新命名
fclose($fp2);
return true;
}
/**
* 获取去重后的解梦关键词列表
*/
public static function getUniqueDreamListByCategoryId($categoty_id, $offset, $limit) {
$db = &CompassDBManager::getInstance();
$sql = "select distinct category_id, dream_id, title from dream_dat where delete_flg=false";
if(isset($categoty_id)) {
$sql .= " and category_id=".$categoty_id;
}
if(isset($limit)) {
$sql .= " limit ".$limit;
}
if(isset($offset)) {
$sql .= " offset ".$offset;
}
$result = $db->executeQuery($sql);
if(count($result) > 0){
return $result;
}
return array();
}
/**
* 获取单个广告合计后的去重点击数
*/
public static function getSumUniqueAdClickCount($adid, $object_date) {
$db = &CompassDBManager::getInstance();
$sql = "select sum(unique_click_count) as count from miniplay_ad_click_dat where delete_flg=false and channel_id<>'0' and adid='" . $adid . "' and object_date='" . $object_date . "'";
$result = $db->executeQuery($sql);
if(count($result) > 0){
return $result[0]["count"];
}
return 0;
}
/**
* 插入用户点数获得数据【openid】
*/
public static function insertPointLog($openid, $action_type, $point, $status) {
if(empty($openid) || $openid=="undefined") return;
$db = &CompassDBManager::getInstance();
$insert_sql = "insert into miniplay_user_point_log (openid, action_type, point, status) VALUES ('{$openid}', '{$action_type}','{$point}','{$status}')";
$db->executeQuery($insert_sql);
//更新该用户的累计点数
if($status=="SUCCESS") {
$point_val = (int)$point;
if($point_val > 0) {
$update_sql = "update user_mst set point=point+{$point_val}, sum_point=sum_point+{$point} where openid='{$openid}' and delete_flg=false";
} else {
$point_val2 = abs($point_val);
$update_sql = "update user_mst set point=point-{$point_val2} where openid='{$openid}' and delete_flg=false";
}
$db->executeQuery($update_sql);
}
return;
}
/**
* 插入用户点数获得数据【openid】
*/
public static function insertPointLogByUID($uid, $action_type, $point, $status) {
if(empty($uid) || $uid=="undefined") return;
$db = &CompassDBManager::getInstance();
$insert_sql = "insert into miniplay_user_point_log (openid, action_type, point, status) VALUES ('{$uid}', '{$action_type}','{$point}','{$status}')";
$db->executeQuery($insert_sql);
//更新该用户的累计点数
if($status=="SUCCESS") {
//判断记录是否存在
$param = array();
$param["union_id"] = $uid;
$param["delete_flg"] = false;
$tmp_list = UnionUserDat::getList($param, "id", "desc", 0 , 1);
if(empty($tmp_list)) {
$union_user_dat = new UnionUserDat();
$union_user_dat->union_id = $uid;
$union_user_dat->point = 0;
$union_user_dat->sum_point = 0;
} else {
$union_user_dat = $tmp_list[0];
}
$point_val = (int)$point;
if($point_val > 0) {
$union_user_dat->point += $point_val;
$union_user_dat->sum_point += $point_val;
} else {
$point_val2 = abs($point_val);
$union_user_dat->point -= $point_val;
}
$union_user_dat->save();
}
return;
}
/**
* 插入用户点数获得数据
*/
public static function insertOctopusPointLog($openid, $action_type, $group_id, $point) {
if(empty($openid) || $openid=="undefined") return;
$db = &CompassDBManager::getInstance();
$insert_sql = "insert into octopus_user_point_log (openid, action_type, group_id, point) VALUES ('{$openid}', '{$action_type}','{$group_id}','{$point}')";
$db->executeQuery($insert_sql);
//更新该用户的累计点数
$point_val = (int)$point;
if($point_val > 0) {
$update_sql = "update user_mst set point=point+{$point_val}, sum_point=sum_point+{$point} where openid='{$openid}' and delete_flg=false";
} else {
$point_val2 = abs($point_val);
$update_sql = "update user_mst set point=point-{$point_val2} where openid='{$openid}' and delete_flg=false";
}
$db->executeQuery($update_sql);
return;
}
/**
* 渠道广告点击记录
*/
public static function insertTrafficLog($channel_id, $openid, $adid) {
if(empty($openid) || $openid=="undefined") return;
$db = &CompassDBManager::getInstance();
$insert_sql = "insert into miniplay_traffic_click_log (channel_id, openid, adid) VALUES ('{$channel_id}', '{$openid}','{$adid}')";
$db->executeQuery($insert_sql);
return;
}
/**
* 下线广告处理
*/
public static function offlineAd($adDat) {
if(empty($adDat)) return;
//该广告对应的ad_plan下线处理
$param = array();
$param["delete_flg"] = false;
$param["adid"] = $adDat->id;
$param["is_finish"] = false;
$ad_plan_list = MiniplayAdPlan::getList($param);
if(!empty($ad_plan_list)) {
foreach($ad_plan_list as $ad_plan) {
$ad_plan->is_finish = true;
$ad_plan->save();
}
}
//渠道广告配置下线
$param = array();
$param["delete_flg"] = false;
$param["adid"] = $adDat->id;
$promotion_dat_list = MiniplayPromotionDat::getList($param);
if(!empty($promotion_dat_list)) {
foreach($promotion_dat_list as $promotion_dat) {
$promotion_dat->delete_flg = true;
$promotion_dat->save();
}
}
//广告下线
$adDat->is_top = false;
if($adDat->status == "OK") {
$adDat->status = "NG";
$adDat->save();
}
//渠道配置广告下线处理
return;
}
/**
* Cookies设定
* @param string $name
* @param string $value
* @param int $expire
* @return empty
*/
public static function setCookies($name, $value, $expire = 0) {
setcookie($name, $value, $expire, "/");
}
/**
* Cookies取得
* @param string $name
* @return string
*/
public static function getCookies($name) {
$cookies_value = null;
if (isset($_COOKIE[$name]) && $_COOKIE[$name] != null) {
$cookies_value = $_COOKIE[$name];
}
return $cookies_value;
}
/**
* Cookies清除
* @param string $name
* @return null
*/
public static function clearCookies($name) {
if (isset($_COOKIE[$name]) && $_COOKIE[$name] != null) {
setcookie($name, "", time() - 3600, "/");
}
return null;
}
/**
* CURLでHttp請求
* @param unknown $url
*/
public static function getCurl($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
/**
* 对象转数组
*/
public static function object2array($object) {
if (is_object($object)) {
foreach ($object as $key => $value) {
$array[$key] = $value;
}
}
else {
$array = $object;
}
return $array;
}
/**
* 排序专用callback
*/
public static function callbackCmpPriority($a, $b) {
return $a["idx"] < $b["idx"] ? true : false;
}
/**
* 新增account时使用的学校list
*/
public static function getSchoolListForAccount() {
$sql = "select id,title from school_mst where delete_flg = false order by id asc";
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($sql);
return $result;
}
/**
* 新增account时使用的领过机构list
*/
public static function getGovernmentlListForAccount() {
$sql = "select id,title from government_mst where delete_flg = false order by id asc";
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($sql);
return $result;
}
/**
* 根据条件查询account list
*/
public static function getAccountlList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from account_mst";
$sql_where =" where delete_flg=false";
if (isset($param["user_id"]) && !empty($param["user_id"])) {
$sql_where .= " and user_id = ".$param["user_id"];
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new AccountMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询government list
*/
public static function getGovernmentlList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from government_mst";
$sql_where =" where delete_flg=false";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new GovernmentMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询school list count
*/
public static function getSchoollListCount($param) {
$from = "select count(*) count from school_mst";
$sql_where =" where delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and title like '%".$param["title"] . "%'";
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询school list
*/
public static function getSchoollList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from school_mst";
$sql_where =" where delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and title like '%".$param["title"] . "%'";
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new SchoolMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询班级 list
*/
public static function getClassList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select cm.*,gm.title as grade_title from class_mst cm left join grade_mst gm on cm.grade_id=gm.id";
$sql_where =" where cm.delete_flg=false";
if (isset($param["school_id"]) && !empty($param["school_id"])) {
$sql_where .= " and cm.school_id=".$param["school_id"];
}
$sql_where.=" order by ".$order_key.' '.$sort;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询合集视频 list
*/
public static function getCourseListCount($param) {
$from = "select count(*) count from course_mst cm left join";
$from .= " (select course_id,max(registration_date) registration_date,sum(view_count) view_count from course_media_dat where delete_flg = false and course_id <> 0 group by course_id) cmd on cm.id=cmd.course_id";
$sql_where =" where cm.delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and cm.title like '%" . $param["title"] . "%'";
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询合集视频 list
*/
public static function getCourseList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select cm.*,cmd.registration_date as upload_date,cmd.view_count as view_count from course_mst cm left join ";
$from .= " (select course_id,max(registration_date) registration_date,sum(view_count) view_count from course_media_dat where delete_flg = false and course_id <> 0 group by course_id) cmd on cm.id=cmd.course_id";
$sql_where =" where cm.delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and cm.title like '%" . $param["title"] . "%'";
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询视频详细 count
*/
public static function getCourseMediaListCount($param) {
$from = "select count(*) count from course_media_dat";
$sql_where =" where delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and title like '%" . $param["title"] . "%'";
}
if (isset($param["course_id"]) && !empty($param["course_id"])) {
$sql_where .= " and course_id=" . $param["course_id"];
}
if (isset($param["media_type"])) {
if($param["media_type"] == "1"){
$sql_where .= " and course_id = 0";
}else if($param["media_type"] == "2"){
$sql_where .= " and course_id <> 0";
}
}
if (isset($param["media_kind"])) {
if($param["media_kind"] == "1"){
$sql_where .= " and is_free = true";
}else if($param["media_kind"] == "2"){
$sql_where .= " and is_free = false";
}
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询视频详细 list
*/
public static function getCourseMediaList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from course_media_dat";
$sql_where =" where delete_flg=false";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and title like '%" . $param["title"] . "%'";
}
if (isset($param["course_id"]) && !empty($param["course_id"])) {
$sql_where .= " and course_id=" . $param["course_id"];
}
if (isset($param["media_type"])) {
if($param["media_type"] == "1"){
$sql_where .= " and course_id = 0";
}else if($param["media_type"] == "2"){
$sql_where .= " and course_id <> 0";
}
}
if (isset($param["media_kind"])) {
if($param["media_kind"] == "1"){
$sql_where .= " and is_free = true";
}else if($param["media_kind"] == "2"){
$sql_where .= " and is_free = false";
}
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new CourseMediaDat($tmp));
}
}
return $return;
}
/**
* 根据条件查询certificate list
*/
public static function getCertificatelList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from certificate_mst";
$sql_where =" where delete_flg=false";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new CertificateMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询user_certificate list count
*/
public static function getUserCertificateListCount($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select ucm.* from user_certificate_dat ucm left join user_mst um on ucm.user_id=um.id left join certificate_mst cm on ucm.certificate_id=um.id";
$sql_where =" where ucm.delete_flg=false";
if (isset($param["user_name"]) && !empty($param["user_name"])) {
$sql_where .= " and um.name like '%" . $param["user_name"] . "%'";
}
if (isset($param["certificate_title"]) && !empty($param["certificate_title"])) {
$sql_where .= " and cm.title like '%" . $param["certificate_title"] . "%'";
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and ucm.name like '%" . $param["name"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and ucm.status='" . $param["status"] . "'";
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return count($result);
}
/**
* 根据条件查询user_certificate list
*/
public static function getUserCertificateList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select ucm.*,um.name user_name,cm.title certificate_title from user_certificate_dat ucm left join user_mst um on ucm.user_id=um.id left join certificate_mst cm on ucm.certificate_id=um.id";
$sql_where =" where ucm.delete_flg=false";
if (isset($param["user_name"]) && !empty($param["user_name"])) {
$sql_where .= " and um.name like '%" . $param["user_name"] . "%'";
}
if (isset($param["certificate_title"]) && !empty($param["certificate_title"])) {
$sql_where .= " and cm.title like '%" . $param["certificate_title"] . "%'";
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and ucm.name like '%" . $param["name"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and ucm.status='" . $param["status"] . "'";
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据id查询user_certificate_dat
*/
public static function getUserCertificateById($id) {
$from = "select ucm.*,um.name user_name,cm.title certificate_title from user_certificate_dat ucm left join user_mst um on ucm.user_id=um.id left join certificate_mst cm on ucm.certificate_id=um.id";
$sql_where =" where ucm.delete_flg=false and ucm.id=".$id;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0];
}
/**
* 获取收费视频收益
*/
public static function getProceedsMedia() {
$from = "select count(id) as total,sum(view_count) as view_total from course_media_dat ";
$sql_where =" where delete_flg=false and is_free=false";
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0];
}
/**
* 获取收费视频收益
*/
public static function getProceeds() {
$from = "select sum(money) as money_total from user_media_dat ";
$sql_where =" where delete_flg=false and is_free=false and status='SUCCESS'";
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0];
}
/**
* 获取收费视频一览
*/
public static function getProceedsMediaList($param = null, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select umd.id,umd.money,umd.registration_date,cmd.title,um.name from user_media_dat umd left join course_media_dat cmd on umd.media_id = cmd.id left join user_mst um on umd.user_id = um.id";
$sql_where =" where umd.delete_flg=false and umd.is_free=false and umd.status='SUCCESS'";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 获取收费视频一览
*/
public static function getProceedsMediaListCount() {
$from = "select count(*) as count from user_media_dat umd left join course_media_dat cmd on umd.media_id = cmd.id left join user_mst um on umd.user_id = um.id";
$sql_where =" where umd.delete_flg=false and umd.is_free=false and umd.status='SUCCESS'";
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询机构认证 count
*/
public static function getOrgAccreditedListCount($param) {
$from = "select count(*) count from user_mst";
$sql_where =" where delete_flg=false and organization_no is not null";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and organization_title like '%" . $param["title"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and organization_status='" . $param["status"] . "'";
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询机构认证list
*/
public static function getOrgAccreditedList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from user_mst";
$sql_where =" where delete_flg=false and role=6";
if (isset($param["title"]) && !empty($param["title"])) {
$sql_where .= " and organization_title like '%" . $param["title"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and organization_status='" . $param["status"] . "'";
}
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new UserMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询志愿者活动list
*/
public static function getEventList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select ved.*,vemd.involved_count,vemd.finish_count from volunteer_event_dat ved left join ";
$from .= "(select volunteer_event_id,count(volunteer_event_id) as involved_count,sum(CASE WHEN status='FINISH' THEN 1 else 0 END) as finish_count from volunteer_event_member_dat where delete_flg=false group by volunteer_event_id) vemd on ved.id=vemd.volunteer_event_id";
$sql_where =" where ved.delete_flg=false";
$sql_where .=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询活动列表-数据详情list count
*/
public static function getEventMemberListCount($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select count(*) count from volunteer_event_member_dat vemd";
$from .= " join user_mst um on um.id=vemd.user_id and um.delete_flg=false";
$from .= " left join circle_dat cd on cd.id=vemd.circle_id and cd.delete_flg=false";
$sql_where =" where vemd.delete_flg=false";
if (isset($param["id"]) && !empty($param["id"])) {
$sql_where .= " and vemd.volunteer_event_id=" . $param["id"];
}
if (isset($param["mobile"]) && !empty($param["mobile"])) {
$sql_where .= " and vemd.mobile='" . $param["mobile"] . "'";
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and um.name like '%" . $param["name"] . "%'";
}
if (isset($param["is_circle"]) && !empty($param["is_circle"])) {
if($param["is_circle"] == 1){
$sql_where .= " and vemd.circle_id != 0";
}else if($param["is_circle"] == 2){
$sql_where .= " and vemd.circle_id = 0";
}
}
if (isset($param["is_finish"]) && !empty($param["is_finish"])) {
if($param["is_finish"] == 1){
$sql_where .= " and vemd.finish_time is not null";
}elseif($param["is_finish"] == 2){
$sql_where .= " and vemd.finish_time is null";
}
}
if (isset($param["circle_id"]) && !empty($param["circle_id"])) {
$sql_where .= " and vemd.circle_id=" . $param["circle_id"];
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询活动列表-数据详情list
*/
public static function getEventMemberList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select vemd.*,um.name as user_name,cd.title as circle_title from volunteer_event_member_dat vemd";
$from .= " join user_mst um on um.id=vemd.user_id and um.delete_flg=false";
$from .= " left join circle_dat cd on cd.id=vemd.circle_id and cd.delete_flg=false";
$sql_where =" where vemd.delete_flg=false";
if (isset($param["id"]) && !empty($param["id"])) {
$sql_where .= " and vemd.volunteer_event_id=" . $param["id"];
}
if (isset($param["member_id"]) && !empty($param["member_id"])) {
$sql_where .= " and vemd.id=" . $param["member_id"];
}
if (isset($param["mobile"]) && !empty($param["mobile"])) {
$sql_where .= " and vemd.mobile='" . $param["mobile"] . "'";
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and um.name like '%" . $param["name"] . "%'";
}
if (isset($param["is_circle"]) && !empty($param["is_circle"])) {
if($param["is_circle"] == 1){
$sql_where .= " and vemd.circle_id != 0";
}else if($param["is_circle"] == 2){
$sql_where .= " and vemd.circle_id = 0";
}
}
if (isset($param["is_finish"]) && !empty($param["is_finish"])) {
if($param["is_finish"] == 1){
$sql_where .= " and vemd.finish_time is not null";
}elseif($param["is_finish"] == 2){
$sql_where .= " and vemd.finish_time is null";
}
}
if (isset($param["circle_id"]) && !empty($param["circle_id"])) {
$sql_where .= " and vemd.circle_id=" . $param["circle_id"];
}
$sql_where.=" order by ".$order_key.' '.$sort;
if(isset($limit)){
$sql_where.= ' limit '.$limit;
}
if(isset($offset)){
$sql_where.= ' OFFSET '.$offset;
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询募捐活动列表-数据详情list count
*/
public static function getUserDonationListCount($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select count(*) count from user_donation_dat udd";
$from .= " left join user_mst um on um.id=udd.user_id and um.delete_flg=false";
$sql_where =" where udd.delete_flg=false";
if (isset($param["id"]) && !empty($param["id"])) {
$sql_where .= " and udd.donation_id=" . $param["id"];
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and um.name like '%" . $param["name"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and udd.status in('" . implode("','", explode(",", $param["status"])). "')";
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result[0]["count"];
}
/**
* 根据条件查询活动列表-数据详情list
*/
public static function getUserDonationList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select udd.*,um.name as user_name from user_donation_dat udd";
$from .= " left join user_mst um on um.id=udd.user_id and um.delete_flg=false";
$sql_where =" where udd.delete_flg=false";
if (isset($param["id"]) && !empty($param["id"])) {
$sql_where .= " and udd.donation_id=" . $param["id"];
}
if (isset($param["name"]) && !empty($param["name"])) {
$sql_where .= " and um.name like '%" . $param["name"] . "%'";
}
if (isset($param["status"]) && !empty($param["status"])) {
$sql_where .= " and udd.status in('" . implode("','", explode(",", $param["status"])). "')";
}
$sql_where.=" order by ".$order_key.' '.$sort;
if(isset($limit)){
$sql_where.= ' limit '.$limit;
}
if(isset($offset)){
$sql_where.= ' OFFSET '.$offset;
}
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
}
?>