暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

EyouCmsLogic.php 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海口快推科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\logic;
  14. use think\Model;
  15. use think\Db;
  16. use think\Page;
  17. use think\Request;
  18. /**
  19. * 逻辑定义
  20. * Class CatsLogic
  21. * @package admin\Logic
  22. */
  23. load_trait('controller/Jump');
  24. class EyouCmsLogic extends Model
  25. {
  26. use \traits\controller\Jump;
  27. public $request = null; // 当前Request对象实例
  28. public $main_lang = 'cn'; // 后台多语言标识
  29. public $admin_lang = 'cn'; // 后台多语言标识
  30. public $root_dir = ROOT_DIR;
  31. /**
  32. * 析构函数
  33. */
  34. function __construct() {
  35. null === $this->request && $this->request = Request::instance();
  36. $this->main_lang = get_main_lang();
  37. $this->admin_lang = get_admin_lang();
  38. }
  39. public function welcome_default(&$assign_data = [], $globalConfig = [], $usersConfig = [])
  40. {
  41. // 同步导航与内容统计的状态
  42. $this->syn_open_quickmenu($globalConfig, $usersConfig);
  43. // 快捷导航
  44. $quickMenu = Db::name('quickentry')->where([
  45. 'type' => 1,
  46. 'checked' => 1,
  47. 'status' => 1,
  48. ])->order('sort_order asc, id asc')->select();
  49. $web_recycle_switch = tpCache('web.web_recycle_switch');
  50. foreach ($quickMenu as $key => $val) {
  51. if ($globalConfig['php_servicemeal'] <= 1 && $val['controller'] == 'Shop' && $val['action'] == 'index') {
  52. unset($quickMenu[$key]);
  53. continue;
  54. }
  55. if (!empty($web_recycle_switch) && $val['controller'] == 'RecycleBin' && $val['action'] == 'archives_index'){
  56. unset($quickMenu[$key]);
  57. continue;
  58. }
  59. if (is_language() && $this->main_lang != $this->admin_lang) {
  60. $controllerArr = ['Weapp','Filemanager','Sitemap','Admin','Member','Seo','Channeltype','Tools'];
  61. if (empty($globalConfig['language_split'])) {
  62. $controllerArr[] = 'RecycleBin';
  63. }
  64. $ctlActArr = ['System@water','System@thumb','System@api_conf'];
  65. if (in_array($val['controller'], $controllerArr) || in_array($val['controller'].'@'.$val['action'], $ctlActArr)) {
  66. unset($quickMenu[$key]);
  67. continue;
  68. }
  69. }
  70. $quickMenu[$key]['vars'] = !empty($val['vars']) ? $val['vars']."&lang=".$this->admin_lang : "lang=".$this->admin_lang;
  71. }
  72. $assign_data['quickMenu'] = $quickMenu;
  73. // 内容统计
  74. $assign_data['contentTotal'] = $this->contentTotalList();
  75. // 服务器信息
  76. $assign_data['sys_info'] = $this->get_sys_info($globalConfig);
  77. }
  78. /**
  79. * 同步受开关控制的导航和内容统计
  80. */
  81. private function syn_open_quickmenu($globalConfig = [], $usersConfig = [])
  82. {
  83. /*商城中心 - 受本身开关和会员中心开关控制*/
  84. if (!empty($globalConfig['web_users_switch']) && !empty($usersConfig['shop_open'])) {
  85. $shop_open = 1;
  86. } else {
  87. $shop_open = 0;
  88. }
  89. /*end*/
  90. $saveData = [
  91. [
  92. 'id' => 31,
  93. 'status' => !empty($globalConfig['web_users_switch']) ? 1 : 0,
  94. 'update_time' => getTime(),
  95. ],
  96. [
  97. 'id' => 32,
  98. 'status' => (1 == $globalConfig['web_weapp_switch']) ? 1 : 0,
  99. 'update_time' => getTime(),
  100. ],
  101. [
  102. 'id' => 33,
  103. 'status' => !empty($globalConfig['web_users_switch']) ? 1 : 0,
  104. 'update_time' => getTime(),
  105. ],
  106. [
  107. 'id' => 34,
  108. 'status' => $shop_open,
  109. 'update_time' => getTime(),
  110. ],
  111. [
  112. 'id' => 35,
  113. 'status' => $shop_open,
  114. 'update_time' => getTime(),
  115. ],
  116. ];
  117. model('Quickentry')->saveAll($saveData);
  118. /*处理模型导航和统计*/
  119. $channeltypeRow = Db::name('channeltype')->cache(true,EYOUCMS_CACHE_TIME,"channeltype")->select();
  120. foreach ($channeltypeRow as $key => $val) {
  121. $updateData = [
  122. 'groups' => 1,
  123. 'vars' => 'channel='.$val['id'],
  124. 'status' => $val['status'],
  125. 'update_time' => getTime(),
  126. ];
  127. Db::name('quickentry')->where([
  128. 'vars' => 'channel='.$val['id']
  129. ])->update($updateData);
  130. }
  131. /*end*/
  132. }
  133. /**
  134. * 内容统计 - 数量处理
  135. */
  136. private function contentTotalList()
  137. {
  138. $shop_open = getUsersConfigData('shop.shop_open');
  139. $archivesTotalRow = null;
  140. $quickentryList = Db::name('quickentry')->where([
  141. 'type' => 2,
  142. 'checked' => 1,
  143. 'status' => 1,
  144. ])->order('sort_order asc, id asc')->select();
  145. foreach ($quickentryList as $key => $val) {
  146. $code = $val['controller'].'@'.$val['action'].'@'.$val['vars'];
  147. $quickentryList[$key]['vars'] = !empty($val['vars']) ? $val['vars']."&lang=".$this->admin_lang : "lang=".$this->admin_lang;
  148. if ($code == 'Form@index@') // 留言列表
  149. {
  150. $map = [
  151. 'lang' => $this->admin_lang,
  152. ];
  153. $quickentryList[$key]['total'] = Db::name('guestbook')->where($map)->count();
  154. }
  155. else if (1 == $val['groups']) // 模型内容统计
  156. {
  157. if ('Product' == $val['controller']) {
  158. if (1 == $shop_open) {
  159. $val['controller'] = 'ShopProduct';
  160. }
  161. }
  162. parse_str($val['vars'], $vars);
  163. $admin_info = session('admin_info');
  164. $auth_role_info = !empty($admin_info['auth_role_info']) ? $admin_info['auth_role_info'] : [];
  165. if (!empty($auth_role_info['permission']['arctype'])) {
  166. /*权限控制 by 小虎哥*/
  167. if (0 < intval($admin_info['role_id'])) {
  168. $arctype_channels = Db::name('arctype')->field('current_channel')->where([
  169. 'id' => ['IN', $auth_role_info['permission']['arctype']],
  170. ])->group('current_channel')->column('current_channel');
  171. if (!in_array($vars['channel'], $arctype_channels)) { // 移除该模型没有分配栏目权限的模块
  172. if (isset($quickentryList[$key])) {
  173. unset($quickentryList[$key]);
  174. continue;
  175. }
  176. }
  177. }
  178. /*--end*/
  179. } else {
  180. /*权限控制 by 小虎哥*/
  181. if (0 < intval($admin_info['role_id'])) {
  182. if (isset($quickentryList[$key])) {
  183. unset($quickentryList[$key]);
  184. continue;
  185. }
  186. }
  187. /*--end*/
  188. }
  189. if (null === $archivesTotalRow) {
  190. $map = [
  191. 'lang' => $this->admin_lang,
  192. 'status' => 1,
  193. 'is_del' => 0,
  194. ];
  195. $mapNew = "(users_id = 0 OR (users_id > 0 AND arcrank >= 0))";
  196. /*权限控制 by 小虎哥*/
  197. if (0 < intval($admin_info['role_id'])) {
  198. if(! empty($auth_role_info)){
  199. if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
  200. $map['admin_id'] = $admin_info['admin_id'];
  201. }
  202. }
  203. }
  204. /*--end*/
  205. $SqlQuery = Db::name('archives')->field('channel, count(aid) as total')->where($map)->where($mapNew)->group('channel')->select(false);
  206. $SqlResult = Db::name('sql_cache_table')->where(['sql_md5'=>md5($SqlQuery)])->getField('sql_result');
  207. if (!empty($SqlResult)) {
  208. $archivesTotalRow = json_decode($SqlResult, true);
  209. } else {
  210. $archivesTotalRow = Db::name('archives')->field('channel, count(aid) as total')->where($map)->where($mapNew)->group('channel')->getAllWithIndex('channel');
  211. /*添加查询执行语句到mysql缓存表*/
  212. $SqlCacheTable = [
  213. 'sql_name' => '|model|all|count|',
  214. 'sql_result' => json_encode($archivesTotalRow),
  215. 'sql_md5' => md5($SqlQuery),
  216. 'sql_query' => $SqlQuery,
  217. 'add_time' => getTime(),
  218. 'update_time' => getTime(),
  219. ];
  220. Db::name('sql_cache_table')->insertGetId($SqlCacheTable);
  221. /*END*/
  222. }
  223. }
  224. $val['total'] = !empty($archivesTotalRow[$vars['channel']]['total']) ? intval($archivesTotalRow[$vars['channel']]['total']) : 0;
  225. $quickentryList[$key] = $val;
  226. }
  227. else if ($code == 'AdPosition@index@') // 广告
  228. {
  229. $map = [
  230. 'lang' => $this->admin_lang,
  231. 'is_del' => 0,
  232. ];
  233. $quickentryList[$key]['total'] = Db::name('ad_position')->where($map)->count();
  234. }
  235. else if ($code == 'Links@index@') // 友情链接
  236. {
  237. $map = [
  238. 'lang' => $this->admin_lang,
  239. ];
  240. $quickentryList[$key]['total'] = Db::name('links')->where($map)->count();
  241. }
  242. else if ($code == 'Tags@index@') // Tags标签
  243. {
  244. $map = [
  245. 'lang' => $this->admin_lang,
  246. ];
  247. $quickentryList[$key]['total'] = Db::name('tagindex')->where($map)->count();
  248. }
  249. else if ($code == 'Member@users_index@') // 会员
  250. {
  251. $map = [
  252. 'lang' => $this->admin_lang,
  253. 'is_del' => 0,
  254. ];
  255. $quickentryList[$key]['total'] = Db::name('users')->where($map)->count();
  256. }
  257. else if ($code == 'Shop@index@') // 订单
  258. {
  259. $map = [
  260. 'lang' => $this->admin_lang,
  261. ];
  262. $quickentryList[$key]['total'] = Db::name('shop_order')->where($map)->count();
  263. }
  264. }
  265. return $quickentryList;
  266. }
  267. /**
  268. * 服务器信息
  269. */
  270. private function get_sys_info($globalConfig = [])
  271. {
  272. $sys_info['os'] = PHP_OS;
  273. $sys_info['zlib'] = function_exists('gzclose') ? 'YES' : '<font color="red">NO(请开启 php.ini 中的php-zlib扩展)</font>';//zlib
  274. $sys_info['safe_mode'] = (boolean) ini_get('safe_mode') ? 'YES' : 'NO';//safe_mode = Off
  275. $sys_info['timezone'] = function_exists("date_default_timezone_get") ? date_default_timezone_get() : "no_timezone";
  276. $sys_info['curl'] = function_exists('curl_init') ? 'YES' : '<font color="red">NO(请开启 php.ini 中的php-curl扩展)</font>';
  277. $web_server = $_SERVER['SERVER_SOFTWARE'];
  278. if (stristr($web_server, 'apache')) {
  279. $web_server = 'apache';
  280. } else if (stristr($web_server, 'nginx')) {
  281. $web_server = 'nginx';
  282. } else if (stristr($web_server, 'iis')) {
  283. $web_server = 'iis';
  284. }
  285. $sys_info['web_server'] = $web_server;
  286. $sys_info['phpv'] = phpversion();
  287. $sys_info['ip'] = serverIP();
  288. $sys_info['postsize'] = @ini_get('file_uploads') ? ini_get('post_max_size') :'未知';
  289. $sys_info['fileupload'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') :'未开启';
  290. $sys_info['max_ex_time'] = @ini_get("max_execution_time").'s'; //脚本最大执行时间
  291. $sys_info['set_time_limit'] = function_exists("set_time_limit") ? true : false;
  292. $sys_info['domain'] = request()->host();
  293. $sys_info['memory_limit'] = ini_get('memory_limit');
  294. $sys_info['version'] = file_get_contents(DATA_PATH.'conf/version.txt');
  295. $mysqlinfo = Db::query("SELECT VERSION() as version");
  296. $sys_info['mysql_version'] = $mysqlinfo[0]['version'];
  297. if(function_exists("gd_info")){
  298. $gd = gd_info();
  299. $sys_info['gdinfo'] = $gd['GD Version'];
  300. }else {
  301. $sys_info['gdinfo'] = "未知";
  302. }
  303. if (extension_loaded('zip')) {
  304. $sys_info['zip'] = "YES";
  305. } else {
  306. $sys_info['zip'] = '<font color="red">NO(请开启 php.ini 中的php-zip扩展)</font>';
  307. }
  308. $sys_info['curent_version'] = getCmsVersion(); //当前程序版本
  309. $sys_info['web_name'] = empty($globalConfig['web_name']) ? '' : $globalConfig['web_name'];
  310. return $sys_info;
  311. }
  312. /**
  313. * 内置商城欢迎页主题
  314. * @return [type] [description]
  315. */
  316. public function welcome_shop(&$assign_data = [], $globalConfig = [], $usersConfig = [])
  317. {
  318. // 快捷导航
  319. $quickMenu = Db::name('quickentry')->where([
  320. 'type' => 11,
  321. 'checked' => 1,
  322. 'status' => 1,
  323. ])->order('sort_order asc, id asc')->select();
  324. foreach ($quickMenu as $key => $val) {
  325. if (empty($val['litpic'])) {
  326. unset($quickMenu[$key]);
  327. continue;
  328. }
  329. $quickMenu[$key]['vars'] = !empty($val['vars']) ? $val['vars'] : '';
  330. $quickMenu[$key]['litpic'] = get_default_pic($val['litpic']);
  331. }
  332. $assign_data['quickMenu'] = $quickMenu;
  333. //插件快捷导航
  334. $weappMenuList = Db::name('weapp')->where([
  335. 'status' => 1,
  336. 'checked' => 1,
  337. ])->order('quick_sort asc, id asc')->select();
  338. foreach ($weappMenuList as $key => $val) {
  339. if (!empty($val['config'])){
  340. $val['config'] = json_decode($val['config'],true);
  341. if (0 == $val['is_system']){
  342. $val['config']['litpic'] = get_default_pic($val['config']['litpic']);
  343. }
  344. if (empty($val['config']['management']['href'])) {
  345. if (!empty($val['config']['management']['controller']) && !empty($val['config']['management']['action'])) {
  346. $val['config']['management']['href'] = url($val['config']['management']['controller'].'/'.$val['config']['management']['action'], $val['config']['management']['param']);
  347. } else {
  348. $val['config']['management']['href'] = url('Weapp/execute',array('sm'=>$val['config']['code'],'sc'=>$val['config']['code'],'sa'=>'index'));
  349. }
  350. }
  351. $weappMenuList[$key] = $val;
  352. }
  353. }
  354. $assign_data['weappMenuList'] = $weappMenuList;
  355. //实时概况
  356. $surveyQuickMenu = Db::name('quickentry')->where([
  357. 'type' => 21,
  358. 'checked' => 1,
  359. 'status' => 1,
  360. ])->order('sort_order asc, id asc')->select();
  361. $statistics_type = get_arr_column($surveyQuickMenu,'statistics_type');
  362. $now_date = date('Y-m-d');
  363. $now_time = strtotime($now_date);
  364. $yesterday = $now_time - 86400;
  365. //统计 今日/昨日
  366. $statistics_where = $today_statistics_data = $yesterday_statistics_data = [];
  367. $statistics_where['type'] = ['in',$statistics_type];
  368. $statistics_where['date'] = ['egt', $yesterday];
  369. $statistics_where['lang'] = $this->admin_lang;
  370. $statistics_data = Db::name('statistics_data')->where($statistics_where)->select();
  371. foreach ($statistics_data as $key => $val) {
  372. if ($val['date'] < $now_time) { // 昨天统计
  373. $yesterday_statistics_data[$val['type']] = $val;
  374. } else if ($val['date'] >= $now_time) { // 今天统计
  375. $today_statistics_data[$val['type']] = $val;
  376. }
  377. }
  378. $total_statistics_data = [];
  379. $archives_data = [];
  380. if (in_array(1,$statistics_type) || in_array(6,$statistics_type)) {
  381. $archives_data = Db::name('archives')->field('sum(click) as click, count(aid) as total')->where(['is_del'=>0,'lang'=>$this->admin_lang])->find();
  382. }
  383. if (in_array(1,$statistics_type)){
  384. $total_statistics_data[1] = empty($archives_data['click']) ? 0 : $archives_data['click'];
  385. }
  386. if (in_array(6,$statistics_type)){
  387. $total_statistics_data[6] = empty($archives_data['total']) ? 0 : $archives_data['total'];
  388. }
  389. $shop_order_data = [];
  390. if (in_array(2,$statistics_type) || in_array(3,$statistics_type)) {
  391. $shop_order_data = Db::name('shop_order')->field('sum(order_amount) as order_amount, count(order_id) as total')->where(['order_status' => ['IN', [1, 2, 3]],'lang'=>$this->admin_lang])->find();
  392. }
  393. if (in_array(2,$statistics_type)){
  394. $total_statistics_data[2] = empty($shop_order_data['total']) ? 0 : $shop_order_data['total'];
  395. }
  396. if (in_array(3,$statistics_type)){
  397. $total_statistics_data[3] = empty($shop_order_data['order_amount']) ? 0 : $shop_order_data['order_amount'];
  398. }
  399. if (in_array(4,$statistics_type)){
  400. $total_statistics_data[4] = Db::name('users')->where(['is_del'=>0,'lang'=>$this->admin_lang])->count('users_id');
  401. }
  402. if (in_array(5,$statistics_type)){
  403. $total_statistics_data[5] = Db::name('users_money')->where(['cause_type'=>1,'status' => ['IN', [2, 3]],'lang'=>$this->admin_lang])->sum('money');
  404. }
  405. foreach ($surveyQuickMenu as $k => $v) {
  406. $v['data'] = [
  407. 'today' => empty($today_statistics_data[$v['statistics_type']]) ? [] : $today_statistics_data[$v['statistics_type']],
  408. 'yesterday' => empty($yesterday_statistics_data[$v['statistics_type']]) ? [] : $yesterday_statistics_data[$v['statistics_type']],
  409. 'total' => empty($total_statistics_data[$v['statistics_type']]) ? 0 : $total_statistics_data[$v['statistics_type']],
  410. ];
  411. $surveyQuickMenu[$k] = $v;
  412. }
  413. $assign_data['surveyQuickMenu'] = $surveyQuickMenu;
  414. $assign_data['current_time'] = date('Y-m-d H:i:s');
  415. $lineChartData = $this->GetLineChartData();
  416. $assign_data['DealNum'] = $lineChartData['num'];
  417. $assign_data['DealAmount'] = $lineChartData['amount'];
  418. //待办事项统计
  419. $toDoList = [];
  420. $toDoList['undelivery'] = Db::name('shop_order')->where(['order_status'=>1,'lang'=>$this->admin_lang])->count('order_id');
  421. $toDoList['service'] = Db::name('shop_order_service')->where(['status'=>1,'lang'=>$this->admin_lang])->count('service_id');
  422. $where = [
  423. 'a.is_del' => 0,
  424. 'a.channel' => 2,
  425. 'a.stock_count|b.spec_stock' => ['elt', $usersConfig['goods_stock_warning']],
  426. 'a.lang' => $this->admin_lang,
  427. ];
  428. $toDoList['warning'] = Db::name('archives')->alias('a')->join('product_spec_value b', 'a.aid = b.aid', 'LEFT')->where($where)->group('a.aid')->count('a.aid');
  429. $assign_data['toDoList'] = $toDoList;
  430. //pc端前台入口链接
  431. $assign_data['home_url'] = $this->shouye($globalConfig);
  432. //小程序码
  433. $weixin_data = tpSetting("OpenMinicode.conf_weixin");
  434. $weixin_data = json_decode($weixin_data, true);
  435. $weixin_qrcodeurl = "";
  436. if (!empty($weixin_data['appid'])) {
  437. $filepath = UPLOAD_PATH."allimg/20230505/weixin-".md5($weixin_data['appid']).".png";
  438. tp_mkdir(dirname($filepath));
  439. if (file_exists($filepath)) {
  440. $weixin_qrcodeurl = "{$this->root_dir}/".$filepath;
  441. }
  442. }
  443. $assign_data['weixin_data'] = $weixin_data;
  444. $assign_data['weixin_qrcodeurl'] = $weixin_qrcodeurl;
  445. // h5二维码
  446. vendor('wechatpay.phpqrcode.phpqrcode');
  447. $pngurl = $this->request->domain().ROOT_DIR;
  448. $h5_qrcodeurl = "";
  449. $filepath = UPLOAD_PATH."allimg/20230505/h5-".md5($pngurl).".png";
  450. tp_mkdir(dirname($filepath));
  451. if (file_exists($filepath)) {
  452. $h5_qrcodeurl = "{$this->root_dir}/".$filepath;
  453. } else {
  454. $qrcode = new \QRcode;
  455. $qrcode->png($pngurl, $filepath, 0, 3, 1);
  456. $h5_qrcodeurl = "{$this->root_dir}/".$filepath;
  457. }
  458. $assign_data['h5_qrcodeurl'] = $h5_qrcodeurl;
  459. }
  460. // 近七日成交量成交额折线图数据
  461. private function GetLineChartData()
  462. {
  463. $now_day = strtotime(date("Y-m-d"));
  464. $min_time = $now_day - (6*86400);
  465. $dataNum = $dataAmount = [];
  466. $statistics_data = Db::name('statistics_data')->field('date,num,total')->where([
  467. 'type'=>2,
  468. 'date'=>['egt', $min_time],
  469. 'lang'=>$this->admin_lang,
  470. ])->order('date desc')->getAllWithIndex('date');
  471. for ($i = 0;$i<7;$i++){
  472. $time = $now_day - $i*86400;
  473. //成交量
  474. $dataNum[$i] = empty($statistics_data[$time]) ? 0 : $statistics_data[$time]['num'];
  475. //成交额
  476. $dataAmount[$i] = empty($statistics_data[$time]) ? 0 : $statistics_data[$time]['total'];
  477. }
  478. $dataNum = array_reverse($dataNum);
  479. $dataAmount = array_reverse($dataAmount);
  480. return ['num'=>$dataNum,'amount'=>$dataAmount];
  481. }
  482. /**
  483. * 301跳转首页
  484. */
  485. public function shouye($globalConfig = [])
  486. {
  487. $inletStr = '/index.php';
  488. $seo_inlet = config('ey_config.seo_inlet');
  489. 1 == intval($seo_inlet) && $inletStr = '';
  490. // --end
  491. $home_default_lang = config('ey_config.system_home_default_lang');
  492. $home_url = $this->request->domain().ROOT_DIR.'/index.php'; // 支持子目录
  493. //默认前台语言,链接中不需要带语言参数;非默认前台语言,链接中需要带语言参数
  494. if ($home_default_lang != $this->admin_lang) {
  495. $home_url = Db::name('language')->where(['mark'=>$this->admin_lang])->getField('url');
  496. if (empty($home_url)) {
  497. $seo_pseudo = !empty($globalConfig['seo_pseudo']) ? $globalConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
  498. if (1 == $seo_pseudo) {
  499. $home_url = $this->request->domain().ROOT_DIR.$inletStr; // 支持子目录
  500. if (!empty($inletStr)) {
  501. $home_url .= '?';
  502. } else {
  503. $home_url .= '/?';
  504. }
  505. $home_url .= http_build_query(['lang'=>$this->admin_lang]);
  506. } else {
  507. $home_url = $this->request->domain().ROOT_DIR.$inletStr.'/'.$this->admin_lang; // 支持子目录
  508. }
  509. }
  510. }
  511. if (stristr($home_url, '?')) {
  512. $home_url .= '&clear=1';
  513. } else {
  514. $home_url .= '?clear=1';
  515. }
  516. return $home_url;
  517. }
  518. /**
  519. * 任务流版欢迎页主题
  520. * @param array &$assign_data [description]
  521. * @param array $globalConfig [description]
  522. * @param array $usersConfig [description]
  523. * @return [type] [description]
  524. */
  525. public function welcome_taskflow(&$assign_data = [], $globalConfig = [], $usersConfig = [])
  526. {
  527. // 服务器信息
  528. $assign_data['sys_info'] = $this->get_sys_info($globalConfig);
  529. $weappList = model('weapp')->getWeappList();
  530. $assign_data['weappList'] = $weappList;
  531. // 安装【工作任务流】插件才可用
  532. if (!empty($weappList['TaskFlow']) && 1 == $weappList['TaskFlow']['status']) {
  533. $Prefix = config('database.prefix');
  534. $taskflowTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}weapp_task_flow");
  535. $taskflowTableInfo = get_arr_column($taskflowTableInfo, 'Field');
  536. if (!empty($taskflowTableInfo) && !in_array('helper_id', $taskflowTableInfo)){
  537. $sql = "ALTER TABLE `{$Prefix}weapp_task_flow` ADD COLUMN `helper_id` int(11) NOT NULL DEFAULT 0 COMMENT '协助问题的负责人ID' AFTER `auditors_id`;";
  538. $r = @Db::execute($sql);
  539. if ($r !== false) {
  540. schemaTable('weapp_task_flow');
  541. }
  542. }
  543. // 当前管理员
  544. $admin_info = getAdminInfo(session('admin_id'));
  545. $assign_data['admin_info'] = $admin_info;
  546. // 指定查看的管理员id
  547. $admin_id = input('admin_id/d', $admin_info['admin_id']);
  548. $assign_data['admin_id'] = $admin_id;
  549. // 小组成员列表
  550. $admin_list = Db::name('admin')
  551. ->alias('a')
  552. ->field('a.*, b.name as role_name')
  553. ->join('auth_role b','a.role_id = b.id','LEFT')
  554. ->where([
  555. 'a.status' => 1,
  556. ])
  557. ->select();
  558. $NewAdmin = [];
  559. foreach ($admin_list as $k =>$v) {
  560. if (0 >= intval($v['role_id'])) {
  561. $v['role_name'] = !empty($v['parent_id']) ? '超级管理员' : '创始人';
  562. }
  563. $v['pen_name'] = !empty($v['true_name']) ? $v['true_name'] : $v['pen_name'];
  564. $v['pen_name'] = !empty($v['pen_name']) ? $v['pen_name'] : $v['user_name'];
  565. $admin_list[$k] = $v;
  566. $NewAdmin[$k]['name'] = $v['pen_name'];
  567. $NewAdmin[$k]['value'] = $v['admin_id'];
  568. }
  569. $assign_data['admin_list'] = $admin_list;
  570. $assign_data['NewAdmin'] = $NewAdmin;
  571. $taskFlowData = $this->taskFlowData();
  572. $assign_data['taskFlowData'] = $taskFlowData;
  573. //任务流统计
  574. $row = Db::name('weapp_task_flow')->field('initiator_id,handler_id,auditors_id,helper_id,task_status,is_draft')->where([
  575. 'initiator_id|handler_id|auditors_id|helper_id' => $admin_id,
  576. ])->order('task_status asc, task_id desc')->select();
  577. $countRow = ['all'=>0, 'my'=>0, 'test'=>0, 'done'=>0, 'draft'=>0];
  578. foreach ($row as $key => $val) {
  579. if (1 == $val['is_draft']) {
  580. if (in_array($admin_id, [$val['initiator_id']])) {
  581. $countRow['draft']++;
  582. }
  583. } else {
  584. if ($admin_id == $val['initiator_id']) { //发起任务
  585. $countRow['my']++;
  586. }
  587. // if (4 == $val['task_status'] && in_array($admin_id, [$val['initiator_id'], $val['handler_id'], $val['auditors_id']])) { //待测试
  588. // $countRow['test']++;
  589. // }
  590. if (5 == $val['task_status']) { //已完成
  591. if (in_array($admin_id, [$val['handler_id'], $val['auditors_id']])) {
  592. $countRow['done']++;
  593. }
  594. } else { //我的任务
  595. if ( in_array($admin_id, [$val['handler_id']]) || (4 == $val['task_status'] && in_array($admin_id, [$val['auditors_id']])) || (2 == $val['task_status'] && in_array($admin_id, [$val['helper_id']])) ) {
  596. $countRow['all']++; //我的任务
  597. }
  598. }
  599. }
  600. }
  601. $assign_data['countRow'] = $countRow;
  602. //任务流 默认是当前管理员的处理人任务
  603. $task_where = [
  604. 'a.is_draft' => 0,
  605. 'a.task_status' => ['NOTIN', [5]],
  606. ];
  607. $task_where[] = Db::raw(" (a.handler_id = '{$admin_id}' OR (a.auditors_id = '{$admin_id}' AND a.task_status = 4) OR (a.helper_id = '{$admin_id}' AND a.task_status = 2)) ");
  608. $task_list = Db::name('weapp_task_flow')
  609. ->field('a.*')
  610. ->alias('a')
  611. ->where($task_where)
  612. ->orderRaw("FIND_IN_SET(a.task_status, '2,6,1,3,4,5') ASC, a.helper_id desc, a.task_id desc")
  613. ->limit(8)->select();
  614. $task_admin_ids = [];
  615. foreach ($task_list as $key => $val) {
  616. array_push($task_admin_ids, $val['initiator_id']);
  617. array_push($task_admin_ids, $val['handler_id']);
  618. array_push($task_admin_ids, $val['auditors_id']);
  619. array_push($task_admin_ids, $val['helper_id']);
  620. }
  621. $week_time = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
  622. $task_admin_list = Db::name('admin')->field('admin_id,user_name,pen_name,true_name,head_pic')->where(['admin_id'=>['IN',$task_admin_ids]])->getAllWithIndex('admin_id');
  623. foreach ($task_list as $key => $val) {
  624. if (!empty($val['project_id']) && !empty($taskFlowData['project_list'][$val['project_id']]['name'])) {
  625. $val['task_title'] = '【'.$taskFlowData['project_list'][$val['project_id']]['name'].'】'.$val['task_title'];
  626. }else {
  627. $val['task_title'] = '【其他】' . $val['task_title'];
  628. }
  629. $val['status_name'] = $this->taskFlowStatus($val['task_status'], 'text', $val['helper_id']);
  630. $val['status_bg'] = $this->taskFlowStatus($val['task_status'], 'bg', $val['helper_id']);
  631. $val['level_name'] = $this->taskFlowLevel($val['task_level']);
  632. $val['level_bg'] = $this->taskFlowLevel($val['task_level'], 'bg');
  633. if ($val['task_status'] == 3) {
  634. $new_time = $val['update_time'];
  635. } else if ($val['task_status'] == 4) {
  636. $new_time = $val['update_time'];
  637. } else if ($val['task_status'] == 5) {
  638. $new_time = $val['update_time'];
  639. } else {
  640. $new_time = $val['add_time'];
  641. }
  642. if ($new_time > $week_time) {
  643. $new_time = '本周';
  644. } else {
  645. $new_time = MyDate('Y-m-d', $new_time);
  646. }
  647. $val['new_time'] = $new_time;
  648. if (!empty($val['initiator_id'])) {
  649. $val['initiator_info'] = !empty($task_admin_list[$val['initiator_id']]) ? $task_admin_list[$val['initiator_id']] : $task_admin_list[1];
  650. }
  651. if (!empty($val['handler_id'])) {
  652. $val['handler_info'] = !empty($task_admin_list[$val['handler_id']]) ? $task_admin_list[$val['handler_id']] : $task_admin_list[1];
  653. }
  654. if (!empty($val['auditors_id'])) {
  655. $val['auditors_info'] = !empty($task_admin_list[$val['auditors_id']]) ? $task_admin_list[$val['auditors_id']] : $task_admin_list[1];
  656. }
  657. if (!empty($val['helper_id'])) {
  658. $val['helper_info'] = !empty($task_admin_list[$val['helper_id']]) ? $task_admin_list[$val['helper_id']] : $task_admin_list[1];
  659. if (2 == $val['task_status']) {
  660. $val['handler_info'] = $val['helper_info'];
  661. }
  662. }
  663. $task_list[$key] = $val;
  664. }
  665. $assign_data['task_list'] = $task_list;
  666. }
  667. /*----------------业务统计 start-------------*/
  668. $surveyQuickMenu = Db::name('quickentry')->where([
  669. 'type' => 31,
  670. 'checked' => 1,
  671. 'status' => 1,
  672. ])->order('sort_order asc, id asc')->select();
  673. $statistics_type = get_arr_column($surveyQuickMenu,'statistics_type');
  674. $now_date = date('Y-m-d');
  675. $now_time = strtotime($now_date);
  676. $yesterday = $now_time - 86400;
  677. //统计 今日/昨日
  678. $statistics_where = $today_statistics_data = $yesterday_statistics_data = [];
  679. $statistics_where['type'] = ['in',$statistics_type];
  680. $statistics_where['date'] = ['egt', $yesterday];
  681. $statistics_where['lang'] = $this->admin_lang;
  682. $statistics_data = Db::name('statistics_data')->where($statistics_where)->select();
  683. foreach ($statistics_data as $key => $val) {
  684. if ($val['date'] < $now_time) { // 昨天统计
  685. $yesterday_statistics_data[$val['type']] = $val;
  686. } else if ($val['date'] >= $now_time) { // 今天统计
  687. $today_statistics_data[$val['type']] = $val;
  688. }
  689. }
  690. $total_statistics_data = [];
  691. $archives_data = [];
  692. if (in_array(1,$statistics_type) || in_array(6,$statistics_type)) {
  693. $archives_data = Db::name('archives')->field('sum(click) as click, count(aid) as total')->where(['is_del'=>0,'lang'=>$this->admin_lang])->find();
  694. }
  695. if (in_array(1,$statistics_type)){
  696. $total_statistics_data[1] = empty($archives_data['click']) ? 0 : $archives_data['click'];
  697. }
  698. if (in_array(6,$statistics_type)){
  699. $total_statistics_data[6] = empty($archives_data['total']) ? 0 : $archives_data['total'];
  700. }
  701. $shop_order_data = [];
  702. if (in_array(2,$statistics_type) || in_array(3,$statistics_type)) {
  703. $shop_order_data = Db::name('shop_order')->field('sum(order_amount) as order_amount, count(order_id) as total')->where(['order_status' => ['IN', [1, 2, 3]],'lang'=>$this->admin_lang])->find();
  704. }
  705. if (in_array(2,$statistics_type)){
  706. $total_statistics_data[2] = empty($shop_order_data['total']) ? 0 : $shop_order_data['total'];
  707. }
  708. if (in_array(3,$statistics_type)){
  709. $total_statistics_data[3] = empty($shop_order_data['order_amount']) ? 0 : $shop_order_data['order_amount'];
  710. }
  711. if (in_array(4,$statistics_type)){
  712. $total_statistics_data[4] = Db::name('users')->where(['is_del'=>0,'lang'=>$this->admin_lang])->count('users_id');
  713. }
  714. if (in_array(5,$statistics_type)){
  715. $total_statistics_data[5] = Db::name('users_money')->where(['cause_type'=>1,'status' => ['IN', [2, 3]],'lang'=>$this->admin_lang])->sum('money');
  716. }
  717. if (in_array(7,$statistics_type)){ // 发布文章总数
  718. $total_statistics_data[7] = Db::name('archives')->where(['arcrank'=>['egt', 0],'status' => 1,'is_del' => 0,'lang'=>$this->admin_lang])->count();
  719. }
  720. if (in_array(8,$statistics_type)){ // tag总数 / 今日数
  721. $total_statistics_data[8] = Db::name('tagindex')->where(['id'=>['gt',0],'lang'=>$this->admin_lang])->count();
  722. $today_statistics_data[8]['total'] = Db::name('tagindex')->whereTime('add_time', 'today')->where(['lang'=>$this->admin_lang])->count();
  723. }
  724. if (in_array(9,$statistics_type)){ // 待审文档总数
  725. $total_statistics_data[9] = Db::name('archives')->where(['arcrank'=>['eq', -1],'status' => 1,'is_del' => 0,'lang'=>$this->admin_lang])->count();
  726. $today_statistics_data[9]['total'] = Db::name('archives')->whereTime('add_time', 'today')->where(['arcrank'=>['eq', -1],'status' => 1,'is_del' => 0,'lang'=>$this->admin_lang])->count();
  727. }
  728. foreach ($surveyQuickMenu as $k => $v) {
  729. $v['data'] = [
  730. 'today' => empty($today_statistics_data[$v['statistics_type']]) ? [] : $today_statistics_data[$v['statistics_type']],
  731. 'yesterday' => empty($yesterday_statistics_data[$v['statistics_type']]) ? [] : $yesterday_statistics_data[$v['statistics_type']],
  732. 'total' => empty($total_statistics_data[$v['statistics_type']]) ? [] : $total_statistics_data[$v['statistics_type']],
  733. ];
  734. $v['url'] = empty($v['url']) ? url($v['controller'].'/'.$v['action'], [$v['vars']]) : $v['url'];
  735. $surveyQuickMenu[$k] = $v;
  736. }
  737. $assign_data['surveyQuickMenu'] = $surveyQuickMenu;
  738. $assign_data['current_time'] = date('Y-m-d H:i:s');
  739. /*----------------业务统计 end-------------*/
  740. }
  741. //ajax获取任务流数据
  742. public function get_task_list()
  743. {
  744. if (IS_AJAX_POST){
  745. $admin_id = input('post.admin_id/d', session('admin_id'));
  746. $task_status = input('post.task_status/s');
  747. //任务流统计
  748. $row = Db::name('weapp_task_flow')->field('initiator_id,handler_id,auditors_id,helper_id,task_status,is_draft')->where([
  749. 'initiator_id|handler_id|auditors_id|helper_id' => $admin_id,
  750. ])->order('task_status asc, task_id desc')->select();
  751. $countRow = ['all'=>0, 'my'=>0, 'test'=>0, 'done'=>0, 'draft'=>0];
  752. foreach ($row as $key => $val) {
  753. if (1 == $val['is_draft']) {
  754. if (in_array($admin_id, [$val['initiator_id']])) {
  755. $countRow['draft']++;
  756. }
  757. } else {
  758. if ($admin_id == $val['initiator_id']) { //发起任务
  759. $countRow['my']++;
  760. }
  761. // if (4 == $val['task_status'] && in_array($admin_id, [$val['initiator_id'], $val['handler_id'], $val['auditors_id']])) { //待测试
  762. // $countRow['test']++;
  763. // }
  764. if (5 == $val['task_status']) { //已完成
  765. if (in_array($admin_id, [$val['handler_id'], $val['auditors_id']])) {
  766. $countRow['done']++;
  767. }
  768. } else { //我的任务
  769. if ( in_array($admin_id, [$val['handler_id']]) || (4 == $val['task_status'] && in_array($admin_id, [$val['auditors_id']])) || (2 == $val['task_status'] && in_array($admin_id, [$val['helper_id']])) ) {
  770. $countRow['all']++; //我的任务
  771. }
  772. }
  773. }
  774. }
  775. //任务流列表
  776. $task_where = [];
  777. $task_where['a.is_draft'] = 0;
  778. if ('my' == $task_status) {
  779. $task_where['a.initiator_id'] = $admin_id;
  780. $orderby = "FIND_IN_SET(a.task_status, '2,6,1,3,4,5') ASC, a.helper_id desc, a.task_id desc";
  781. }elseif ('test' == $task_status) {
  782. $task_where['a.auditors_id'] = $admin_id;
  783. $task_where['a.task_status'] = 4;
  784. $orderby = "a.task_id desc";
  785. }elseif ('done' == $task_status) {
  786. $task_where['a.handler_id|a.auditors_id'] = $admin_id;
  787. $task_where['a.task_status'] = 5;
  788. $orderby = "a.update_time desc";
  789. }elseif ('draft' == $task_status) {
  790. $task_where['a.initiator_id'] = $admin_id;
  791. $task_where['a.is_draft'] = 1;
  792. $orderby = "a.task_id desc";
  793. }else{
  794. $task_where['a.handler_id|a.auditors_id|a.helper_id'] = $admin_id;
  795. $task_where['a.task_status'] = ['NOTIN', [5]];
  796. $task_where[] = Db::raw(" (a.handler_id = '{$admin_id}' OR (a.auditors_id = '{$admin_id}' AND a.task_status = 4) OR (a.helper_id = '{$admin_id}' AND a.task_status = 2)) ");
  797. $orderby = "FIND_IN_SET(a.task_status, '2,6,1,3,4,5') ASC, a.helper_id desc, a.task_id desc";
  798. }
  799. $count = Db::name('weapp_task_flow')->alias('a')->where($task_where)->count('a.task_id');
  800. $pager = new Page($count, 8);// 实例化分页类 传入总记录数和每页显示的记录数
  801. $task_list = Db::name('weapp_task_flow')
  802. ->field('a.*')
  803. ->alias('a')
  804. ->where($task_where)
  805. ->orderRaw($orderby)
  806. ->limit($pager->firstRow.','.$pager->listRows)
  807. ->select();
  808. $task_admin_ids = [];
  809. foreach ($task_list as $key => $val) {
  810. array_push($task_admin_ids, $val['initiator_id']);
  811. array_push($task_admin_ids, $val['handler_id']);
  812. array_push($task_admin_ids, $val['auditors_id']);
  813. array_push($task_admin_ids, $val['helper_id']);
  814. }
  815. $task_admin_list = Db::name('admin')->field('admin_id,user_name,pen_name,true_name,head_pic')->where(['admin_id'=>['IN',$task_admin_ids]])->getAllWithIndex('admin_id');
  816. $taskFlowData = $this->taskFlowData();
  817. foreach ($task_list as $key => $val) {
  818. if (!empty($val['project_id']) && !empty($taskFlowData['project_list'][$val['project_id']]['name'])) {
  819. $val['task_title'] = '【'.$taskFlowData['project_list'][$val['project_id']]['name'].'】'.$val['task_title'];
  820. }else {
  821. $val['task_title'] = '【其他】' . $val['task_title'];
  822. }
  823. $val['status_name'] = $this->taskFlowStatus($val['task_status'], 'text', $val['helper_id']);
  824. $val['status_bg'] = $this->taskFlowStatus($val['task_status'], 'bg', $val['helper_id']);
  825. $val['level_name'] = $this->taskFlowLevel($val['task_level']);
  826. $val['level_bg'] = $this->taskFlowLevel($val['task_level'], 'bg');
  827. if (!empty($val['initiator_id'])) {
  828. $val['initiator_info'] = !empty($task_admin_list[$val['initiator_id']]) ? $task_admin_list[$val['initiator_id']] : $task_admin_list[1];
  829. $val['initiator_info']['head_pic'] = get_head_pic($val['initiator_info']['head_pic'], true);
  830. $val['initiator_info']['pen_name'] = !empty($val['initiator_info']['true_name']) ? $val['initiator_info']['true_name'] : $val['initiator_info']['pen_name'];
  831. empty($val['initiator_info']['pen_name']) && $val['initiator_info']['pen_name'] = $val['initiator_info']['user_name'];
  832. }
  833. if (!empty($val['handler_id'])) {
  834. $val['handler_info'] = !empty($task_admin_list[$val['handler_id']]) ? $task_admin_list[$val['handler_id']] : $task_admin_list[1];
  835. $val['handler_info']['head_pic'] = get_head_pic($val['handler_info']['head_pic'], true);
  836. $val['handler_info']['pen_name'] = !empty($val['handler_info']['true_name']) ? $val['handler_info']['true_name'] : $val['handler_info']['pen_name'];
  837. empty($val['handler_info']['pen_name']) && $val['handler_info']['pen_name'] = $val['handler_info']['user_name'];
  838. }
  839. if (!empty($val['auditors_id'])) {
  840. $val['auditors_info'] = !empty($task_admin_list[$val['auditors_id']]) ? $task_admin_list[$val['auditors_id']] : $task_admin_list[1];
  841. $val['auditors_info']['head_pic'] = get_head_pic($val['auditors_info']['head_pic'], true);
  842. $val['auditors_info']['pen_name'] = !empty($val['auditors_info']['true_name']) ? $val['auditors_info']['true_name'] : $val['auditors_info']['pen_name'];
  843. empty($val['auditors_info']['pen_name']) && $val['auditors_info']['pen_name'] = $val['auditors_info']['user_name'];
  844. }
  845. if (!empty($val['helper_id'])) {
  846. $val['helper_info'] = !empty($task_admin_list[$val['helper_id']]) ? $task_admin_list[$val['helper_id']] : $task_admin_list[1];
  847. $val['helper_info']['head_pic'] = get_head_pic($val['helper_info']['head_pic'], true);
  848. $val['helper_info']['pen_name'] = !empty($val['helper_info']['true_name']) ? $val['helper_info']['true_name'] : $val['helper_info']['pen_name'];
  849. empty($val['helper_info']['pen_name']) && $val['helper_info']['pen_name'] = $val['helper_info']['user_name'];
  850. if (2 == $val['task_status']) {
  851. $val['handler_info'] = $val['helper_info'];
  852. }
  853. }
  854. $task_list[$key] = $val;
  855. }
  856. $html = '';
  857. $week_time = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
  858. foreach ($task_list as $key => $val) {
  859. if ($val['task_status'] == 3) {
  860. $new_time = $val['update_time'];
  861. } else if ($val['task_status'] == 4) {
  862. $new_time = $val['update_time'];
  863. } else if ($val['task_status'] == 5) {
  864. $new_time = $val['update_time'];
  865. } else {
  866. $new_time = $val['add_time'];
  867. }
  868. if ($new_time > $week_time) {
  869. $new_time = '本周';
  870. } else {
  871. $new_time = MyDate('Y-m-d', $new_time);
  872. }
  873. $html .=<<<EOF
  874. <div class="flex-dir-row flex-a-center">
  875. <div style="width: 100px; padding-left: 10px;">
  876. <div class="table-center-one task_status_{$val['task_id']}">
  877. <div class="{$val['status_bg']}-bg">{$val['status_name']}</div>
  878. </div>
  879. </div>
  880. <div class="table-center-ellipsis" style="width: 59%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">
  881. <div class="table-center-two">
  882. <span class="task_title curpoin task_title_{$val['task_id']}" onclick="GetTaskDetails({$val['task_id']});">{$val['task_title']}</span>
  883. <span class="task_level_{$val['task_id']}">
  884. <label class="{$val['level_bg']}-bt">{$val['level_name']}</label>
  885. </span>
  886. </div>
  887. </div>
  888. <div style="width: 10%; margin-left: 38.5px;">
  889. <div class="flex-dir-row flex-a-center" style="margin-top: -5px;">
  890. <img class="table-center-image" src="{$val['initiator_info']['head_pic']}">{$val['initiator_info']['pen_name']}
  891. </div>
  892. </div>
  893. <div style="width: 10%;">
  894. <div class="flex-dir-row flex-a-center" style="margin-top: -5px;">
  895. <img class="table-center-image" src="{$val['handler_info']['head_pic']}">{$val['handler_info']['pen_name']}
  896. </div>
  897. </div>
  898. <div style="width: 10%;">
  899. <div class="flex-dir-row flex-a-center" style="margin-top: -5px;">
  900. <img class="table-center-image" src="{$val['auditors_info']['head_pic']}">{$val['auditors_info']['pen_name']}
  901. </div>
  902. </div>
  903. <div style="width: 6%; margin-right: 30.2px">
  904. <div class="flex-dir-row flex-a-center" style="margin-top: -5px;">
  905. {$new_time}
  906. </div>
  907. </div>
  908. </div>
  909. EOF;
  910. }
  911. $hasMorePage = $pager->nowPage >= $pager->totalPages ? 0 : 1; // 是否有下一页
  912. $nextpage = $pager->nowPage + 1;
  913. if ($nextpage > $pager->totalPages) {
  914. $nextpage = $pager->totalPages;
  915. }
  916. $this->success('success', null, ['countRow'=>$countRow,'html'=>$html,'nextpage'=>$nextpage,'hasMorePage'=>$hasMorePage]);
  917. }
  918. $this->error('请求错误!');
  919. }
  920. // 任务流配置
  921. private function taskFlowData(){
  922. $data = Db::name('weapp')->where('code', 'TaskFlow')->getField('data');
  923. $data = json_decode($data, true);
  924. return $data;
  925. }
  926. //任务流任务状态
  927. private function taskFlowStatus($value = 1, $type = 'text', $helper_id = 0){
  928. if ('text' == $type) {
  929. $arr = [
  930. '1' => '待处理',
  931. '2' => '处理中',
  932. '3' => '驳回处理',
  933. '4' => '验收中',
  934. '5' => '已完成',
  935. '6' => '暂停中',
  936. ];
  937. $str = $arr[$value];
  938. if (2 == $value && !empty($helper_id)) {
  939. $str = '协助中';
  940. }
  941. } else if ('bg' == $type) {
  942. $arr = [
  943. '1' => 'blue',
  944. '2' => 'orange',
  945. '3' => 'red',
  946. '4' => 'yellow',
  947. '5' => 'green',
  948. '6' => 'suspend',
  949. ];
  950. $str = $arr[$value];
  951. if (2 == $value && !empty($helper_id)) {
  952. $str = 'helper';
  953. }
  954. }
  955. return $str;
  956. }
  957. //任务流任务等级
  958. private function taskFlowLevel($value= 1, $type = 'text'){
  959. if ('text' == $type) {
  960. $arr = [
  961. '1' => '不重要',
  962. '2' => '严重',
  963. '3' => '主要',
  964. '4' => '次要',
  965. '5' => '不重要',
  966. ];
  967. } else if ('bg' == $type) {
  968. $arr = [
  969. '1' => 'green',
  970. '2' => 'red',
  971. '3' => 'blue',
  972. '4' => 'teal',
  973. '5' => 'green',
  974. ];
  975. }
  976. return $arr[$value];
  977. }
  978. }