= 86400) { return $strtime = date('Y-m-d H:i', $time_s); } if ($time >= 3600) { $strtime .= intval($time / 3600) . '小时'; $time = $time % 3600; } else { $strtime .= ''; } if ($time >= 60) { $strtime .= intval($time / 60) . '分钟'; $time = $time % 60; } else { $strtime .= ''; } if ($time > 0) { $strtime .= intval($time) . '秒前'; } else { $strtime = '时间错误'; } return $strtime; } function getBlogList($limit = 6, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 6; } $arg_where = array_merge(['stat' => 1, 'country_code' => COUNTRY_CODE], $where); $arg_field = ['*']; $arg_order = ['id' => 'desc']; $result = Loader::model('Blog')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getFaqList($limit = 6, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 6; } $arg_where = array_merge(['stat' => 0,'is_home' => 1, 'country_code' => COUNTRY_CODE], $where); $arg_field = ['*']; $arg_order = ['sort' => 'asc', 'id' => 'desc']; $result = Loader::model('fq')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getArticleList($limit = 3, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 3; } $arg_where = array_merge( ['cid' => 1,'stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_field = ['*']; $arg_order = ['createtime' => 'desc']; $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); $arg_wheres = array_merge( ['cid' => 33,'stat' => 0, 'country_code' => COUNTRY_CODE], $where); $rest = Loader::model('Article')->getList($arg_wheres, array_merge($arg_order, $order), $arg_field, $limit); $array = array_merge($result, $rest); //echo Loader::model('Article')->getLastSQL();die; return $array; } /** * 计算剩余天时分。 * $unixEndTime string 终止日期的Unix时间 */ function getDHMtime($unixEndTime = 0) { if ($unixEndTime <= time()) { // 如果过了活动终止日期 return '0天0时0分'; } // 使用当前日期时间到活动截至日期时间的毫秒数来计算剩余天时分 $time = $unixEndTime - time(); $days = 0; if ($time >= 86400) { // 如果大于1天 $days = (int) ($time / 86400); $time = $time % 86400; // 计算天后剩余的毫秒数 } $xiaoshi = 0; if ($time >= 3600) { // 如果大于1小时 $xiaoshi = (int) ($time / 3600); $time = $time % 3600; // 计算小时后剩余的毫秒数 } $fen = (int) ($time / 60); // 剩下的毫秒数都算作分 return $days . '天' . $xiaoshi . '时' . $fen . '分'; } function getDifferentProduct($type, $limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0,'is_show' => 0, 'country_code' => COUNTRY_CODE], $where);//print_r($where);die; $arg_field = ['id', 'cid', 'name', 'shortname', 'sort', 'ishot', 'isnew', 'recommend', 'viewcount', 'tags', 'description', 'picture', 'picture_back', 'bk_img', 'bk_img_back','list_bk_img', 'createtime']; $bkinfo = ['id','product_id','image_url','image_bk_color','image_color','original_url']; switch ($type) { case 'recommend': // $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['recommend'] = 1; $result = Loader::model('Product')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); //print_r($result);die; break; case 'headline': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['headline'] = 1; $result = Loader::model('Product')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'ishot': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['ishot'] = 1; $result = Loader::model('Product')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'isnew': $arg_order['sort'] = 'asc'; $arg_order ['id'] = 'desc'; $arg_where['isnew'] = 1; $result = Loader::model('Product')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; default: if (!empty($order)) { $arg_order = $order; } $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $result = Loader::model('Product')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; } return $result; } function getDifferentArticle($type, $limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); //$arg_where['is_onsale'] = 1; $arg_field = ['id', 'cid', 'name', 'sort', 'headline','jump_link', 'ishot', 'recommend', 'zancount', 'viewcount', 'description', 'picture', 'createtime']; switch ($type) { case 'recommend': $arg_order['createtime'] = 'desc'; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['recommend'] = 1; $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'headline': $arg_order['createtime'] = 'desc'; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['headline'] = 1; $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'ishot': $arg_order['createtime'] = 'desc'; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['ishot'] = 1; $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; default: $arg_order['createtime'] = 'desc'; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; } return $result; } function getDifferentVideo($type, $limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); //$arg_where['is_onsale'] = 1; $arg_field = ['id', 'cid', 'name', 'sort', 'headline', 'ishot', 'recommend', 'viewcount', 'videopath', 'videourl', 'description', 'picture', 'createtime']; switch ($type) { case 'recommend': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['recommend'] = 1; $result = Loader::model('Video')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; $arg_where['headline'] = 1; if (Config ::get('news_headline')) { $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; } else { $arg_order['id'] = 'desc'; } case 'headline': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['headline'] = 1; $result = Loader::model('Video')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'ishot': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['ishot'] = 1; $result = Loader::model('Video')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; default: $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $result = Loader::model('Video')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; } return $result; } function getDifferentDownload($type, $limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); //$arg_where['is_onsale'] = 1; $arg_field = ['id', 'cid', 'name', 'sort', 'headline', 'ishot', 'recommend', 'app_model', 'support_os', 'format', 'viewcount', 'downloadcount', 'description', 'picture', 'tags', 'downloadpath', 'downloadpath64', 'createtime']; switch ($type) { case 'recommend': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['recommend'] = 1; $result = Loader::model('Download')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; $arg_where['headline'] = 1; if (Config ::get('news_headline')) { $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; } else { $arg_order['id'] = 'desc'; } case 'headline': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['headline'] = 1; $result = Loader::model('Download')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; case 'ishot': $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $arg_where['ishot'] = 1; $result = Loader::model('Download')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; default: $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $result = Loader::model('Download')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; } return $result; } function getProductChildCate($pid, $limit = 12, $where = array(), $order = array()) { $argc_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $argc_field = ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'createtime']; $argc_order['sort'] = 'asc'; $argc_order['id'] = 'desc'; $argc_where['pid'] = $pid; $result = Loader::model('ProductCategory')->getList($argc_where, array_merge($argc_order, $order), $argc_field, $limit); return $result; } function getArticleChildCate($pid, $limit = 12, $where = array(), $order = array()) { $argc_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $argc_field = ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'createtime']; $argc_order['sort'] = 'asc'; $argc_order['id'] = 'desc'; $argc_where['pid'] = $pid; $result = Loader::model('ArticleCategory')->getList($argc_where, array_merge($argc_order, $order), $argc_field, $limit); return $result; } function getCateProduct($cid, $limit = 12, $where = array(), $haschild = false, $order = array()) { $arg_where = array_merge(['p.stat' => 0, 'c.stat' => 0, 'p.country_code' => COUNTRY_CODE], $where); $arg_field = ['p.id', 'p.cid', 'p.name', 'p.shortname', 'p.sort', 'p.ishot', 'p.isnew', 'p.recommend', 'p.viewcount', 'p.tags', 'p.description', 'p.picture','p.list_bk_img', 'p.brand_id', 'p.picture_back', 'p.createtime', 'p.createtime', 'c.name' => 'categoryname', 'c.id' => 'categoryid']; $arg_order['p.sort'] = 'asc'; $arg_order['p.id'] = 'desc'; if ($haschild && $cid) { $cidarray = Loader::model('ProductCategory')->getChildIDArray($cid); $arg_where['p.cid'] = ['in', $cidarray]; } else { $arg_where['p.cid'] = $cid; } $result = Loader::model('Product')->getCateProductList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getCateoneProduct($cid, $limit = 12, $where = array(), $haschild = false, $order = array()) { $arg_where = array_merge(['p.stat' => 0, 'c.stat' => 0, 'p.is_show' => 0, 'p.country_code' => COUNTRY_CODE], $where); $arg_field = ['p.bk_img_back_color','p.bk_img_color','p.picture_back_color','p.picture_color','p.id', 'p.cid', 'p.name', 'p.shortname', 'p.sort', 'p.ishot', 'p.isnew','p.brand_id', 'p.recommend', 'p.viewcount', 'p.tags','p.list_bk_img', 'p.description', 'p.picture', 'p.picture_back', 'p.createtime', 'p.createtime', 'c.name' => 'categoryname', 'c.id' => 'categoryid']; $arg_order['p.sort'] = 'asc'; $arg_order['p.id'] = 'desc'; if ($haschild && $cid) { $cidarray = Loader::model('ProductCategory')->getChildIDArray($cid); $arg_where['p.cid'] = ['in', $cidarray]; } else { $arg_where['p.cid'] = $cid; } $result = Loader::model('Product')->getCateProductList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); //echo \think\Db::table('Product')->getLastSql(); // 获取二级图片 foreach ($result as $key => $value) { $res = model('ProductTwoImg')->field('image_url,image_bk_color,image_color,original_url,product_id,id,image_color')->where(['product_id' => $value['id'], 'stat' => 0])->select(); $result[$key]['product_two_img'] = $res; } return $result; } function getCateArticle($cid, $limit = 12, $where = array(), $haschild = false, $order = array()) { $arg_where = array_merge(['stat' => 0, 'p.country_code' => COUNTRY_CODE], $where); $arg_field = ['id', 'cid', 'name', 'sort', 'headline', 'ishot', 'recommend', 'viewcount', 'description', 'picture', 'createtime']; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; if ($haschild && $cid) { $cidarray = Loader::model('ArticleCategory')->getChildIDArray($cid); $arg_where['cid'] = ['in', $cidarray]; } else { $arg_where['cid'] = $cid; } $result = Loader::model('Article')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getCateVideo($cid, $limit = 12, $where = array(), $haschild = false, $order = array()) { $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_field = ['id', 'cid', 'name', 'product', 'sort', 'headline', 'ishot', 'recommend', 'tags', 'playcount', 'description', 'picture', 'videopath', 'createtime']; $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; if ($haschild && $cid) { $cidarray = Loader::model('VideoCategory')->getChildIDArray($cid); $arg_where['cid'] = ['in', $cidarray]; } else { $arg_where['cid'] = $cid; } $result = Loader::model('Video')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getVideoBannerList($tid = 0, $limit = 12, $where = array(), $field = array('*'), $order = array()) { $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_order = array_merge(['sort' => 'asc', 'id' => 'desc'], $order); $arg_field = $field; } function getBannerList($tid = 0, $limit = 12, $where = array(), $field = array('*'), $order = array()) { $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_order = ['sort' => 'asc', 'id' => 'desc']; $arg_field = $field; if ($tid) { $arg_where['typeid'] = $tid; } $result = Loader::model('Banner')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getBanner($id = 0) { $result = Loader::model('Banner')->getRow($id); return $result; } function getFlink($tid = 0, $limit = 12, $where = array(), $field = array('*'), $order = array()) { $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_order = ['sort' => 'asc', 'id' => 'desc']; $arg_field = $field; if ($tid) { $arg_where['typeid'] = $tid; } $result = Loader::model('Flink')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getQuestion($limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); $arg_field = ['*']; $arg_order = ['sort' => 'asc', 'id' => 'desc']; $result = Loader::model('Question')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); return $result; } function getProduct($id = 0) { $result = Loader::model('Product')->getRow(['id' => $id], ['id', 'name']); return $result; } function getProductCount($cid, $where = array(), $haschild = false) { $arg_where = array_merge(['stat' => 0, 'country_code' => COUNTRY_CODE], $where); if ($haschild && $cid) { $cidarray = Loader::model('ProductCategory')->getChildIDArray($cid); $arg_where['cid' ] = ['in', $cidarray]; } else { $arg_where['cid'] = $cid; } $result = Loader::model('Product')->where($arg_where)->count(); return $result; } function getArticleCategory($id = 0) { $result = Loader::model('ArticleCategory')->getRow(['id' => $id ], ['id', 'name']); return $result; } function getSinglepageChild($pid, $limit = 12, $where = array(), $order = array()) { $argc_where = array_merge(['stat' => 0], $where); $argc_field = ['id', 'pid', 'name', 'description', 'sort', 'isshow', 'recommend', 'picture', 'content', 'createtime']; $argc_order['sort'] = 'asc'; $argc_order['id'] = 'desc'; $argc_where['pid'] = $pid; $result = Loader:: model('Singlepage')->getList($argc_where, array_merge($argc_order, $order), $argc_field, $limit); return $result; } function getSinglepage($id = 0) { $result = Loader::model('Singlepag e')->getRow($id, ['id', 'pid', 'name', 'description', 'sort', 'isshow', 'recommend', 'picture', 'content', 'createtime']); return $result; } function getDifferentPinglun($type, $limit = 12, $where = array(), $order = array()) { if (empty($limit)) { $limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12; } $arg_where = array_merge(['stat' => 0, 'display' => 1], $where); $arg_field = ['id', 'pid', 'customer_id', 'cname', 'content_id', 'typeid', 'ishot', 'content', 'tx', 'createtime', 'ip', 'display']; switch ($type) { case 'ishot': $arg_order['id'] = 'desc'; $arg_where['ishot'] = 1; $result = Loader::model('Pinglun')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; default: if (!empty($order)) { $arg_order = $order; } $arg_order['sort'] = 'asc'; $arg_order['id'] = 'desc'; $result = Loader::model('Pinglun')->getList($arg_where, array_merge($arg_order, $order), $arg_field, $limit); break; } return $result; } function getBkImag($type, $limit = 12, $where = array(), $order = array()){ /*$result = \app\common\model\Product::where("recommend",1)->field('id,cid')->with("ProductImg")->limit($limit)->select();*/ //print_r($type);die; $where = ['recommend'=>1,'stat'=>0, 'country_code' => COUNTRY_CODE]; $result = \app\common\model\Product::where($where) ->field('id,cid,name,shortname') ->with(["ProductImg"=>function($query){ /** @var $query \think\db\Query */ $query->field('image_url,image_bk_color,image_color,original_url,product_id,id'); }]) // ->where('id', 130) ->order('id desc') ->select(); /** @var $result array */ $result = collection($result)->toArray(); return $result; } function getSonCategoryProduct($parent_id) { if (empty($parent_id)) { return "无父ID"; } $where = ['recommend'=>1,'stat'=>0, 'country_code' => COUNTRY_CODE]; $result = \app\common\model\Product::where('cid', 'in', function ($query) use ($parent_id) { /** @var $query \think\db\Query */ $query->table('cod_product_category')->where('pid', $parent_id)->field('id'); })->with(["ProductImg"=>function($query){ /** @var $query \think\db\Query */ $query->field('image_url,image_bk_color,image_color,original_url,product_id,id'); }])->where($where) ->field('id,cid,name,shortname') ->select(); if (!empty($result)) { $result = collection($result)->toArray(); } return $result; } function getCateColor($cid, $limit, $where = array(), $haschild = false, $order = array()) { $where = ['stat'=>0,'cid'=>$cid, 'country_code' => COUNTRY_CODE]; $result = \app\common\model\Product::where($where) ->field('id,cid,name,brand_id') ->with(["ProductTwoImg"=>function($query){ /** @var $query \think\db\Query */ $query->where('stat',0)->field('image_url,image_bk_color,image_color,original_url,product_id,id,image_color'); }]) ->limit($limit) ->order($order) ->select(); /** @var $result array */ $result = collection($result)->toArray();//print_r($result);die; return $result; } function getProductReated($id,$limit = 12, $where = array(), $haschild = false, $order = array()){ $where = ['product_id'=>$id,'stat'=>0, 'country_code' => COUNTRY_CODE]; $result = Loader::model('ProductTwoImg')->where($where)->field('image_url')->select(); $result = collection($result)->toArray(); return $result; } /*没有上级分类的爆款查询*/ function getCategoryProduct($parent_id) { if (empty($parent_id)) { return "无父ID"; } $where = ['recommend'=>1,'stat'=>0,'cid'=>$parent_id, 'country_code' => COUNTRY_CODE]; $result = \app\common\model\Product::where($where) ->field('id,cid,name,shortname') ->with(["ProductImg"=>function($query){ /** @var $query \think\db\Query */ $query->field('image_url,image_bk_color,image_color,original_url,product_id,id'); }]) // ->limit('sort') ->order('id desc') ->select(); /** @var $result array */ $result = collection($result)->toArray(); return $result; } /*没有上级的产品查询*/ function getProductColor($pid,$limit){ if(empty($pid)){ return "无父级ID"; } $where = ['stat'=>0,'cid'=>$pid, 'country_code' => COUNTRY_CODE]; $result = \app\common\model\Product::where($where) ->field('id,cid,name,shortname') ->with(["ProductTwoImg"=>function($query){ /** @var $query \think\db\Query */ $query->where('stat',0)->field('image_url,image_bk_color,image_color,original_url,product_id,id,image_color'); }]) ->limit($limit) ->order('id desc') ->select(); /** @var $result array */ $result = collection($result)->toArray();//print_r($result);die; return $result; } // 计算中文字符串长度 function utf8_strlen($string = null) { // 将字符串分解为单元 preg_match_all("/./us", $string, $match); // 返回单元个数 return count($match[0]); }