Index.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\admin\controller;
  13. use app\model\order\OrderCommon as OrderCommonModel;
  14. use app\model\system\Upgrade as UpgradeModel;
  15. use app\model\system\Web;
  16. use think\facade\Cache;
  17. use app\model\system\Config;
  18. use app\model\system\Stat as StatModel;
  19. use Carbon\Carbon;
  20. use app\model\system\User as UserModel;
  21. use app\model\shop\ShopApply;
  22. use app\model\shop\Shop as ShopModel;
  23. use app\model\goods\Goods as GoodsModel;
  24. use app\model\order\Order as OrderModel;
  25. /**
  26. * 首页 控制器
  27. */
  28. class Index extends BaseAdmin
  29. {
  30. /**
  31. * 首页
  32. */
  33. public function index()
  34. {
  35. $config_model = new Config();
  36. // $stat_model = new StatModel();
  37. $stat_model = new OrderCommonModel();
  38. $carbon = Carbon::now();
  39. $stat_info = $stat_model->getStatShop(0, 1);
  40. $this->assign('stat_info', $stat_info['data']);
  41. //订单总额
  42. $order_model = new OrderModel();
  43. $order_money = $order_model->getOrderMoneySum();
  44. $this->assign('order_money',$order_money['data']);
  45. //会员总数
  46. $user_model = new UserModel();
  47. $member_count = $user_model->getMemberTotalCount();
  48. $this->assign('member_count',$member_count['data']);
  49. //今日新增店铺数
  50. $shop_apply_model = new ShopApply();
  51. $condition = [
  52. ['create_time','between',[date_to_time(date('Y-m-d 00:00:00')),date_to_time(date('Y-m-d 23:59:59'))]]
  53. ];
  54. $shop_apply_count = $shop_apply_model->suppShopApplyCount($condition);
  55. $this->assign('shop_apply_count',$shop_apply_count['data']['shop_apply_count']);
  56. //今日申请店铺数
  57. $shop_model = new ShopModel();
  58. $shop_count = $shop_model->getShopCount($condition);
  59. $this->assign('shop_count',$shop_count['data']);
  60. //店铺总数
  61. $shop_model = new ShopModel();
  62. $shop_total_count = $shop_model->getShopCount();
  63. $this->assign('shop_total_count',$shop_total_count['data']);
  64. //商品总数
  65. $goods_model = new GoodsModel();
  66. $goods_count = $goods_model->getGoodsTotalCount();
  67. $this->assign('goods_count',$goods_count['data']);
  68. //获取最新版本
  69. $upgrade_model = new UpgradeModel();
  70. $last_version = $upgrade_model->getLatestVersion();
  71. $need_upgrade = 0;
  72. if (SYS_RELEASE < $last_version['data']['version_release']) {
  73. $need_upgrade = 1;
  74. }
  75. $system_config = $config_model->getSystemConfig();
  76. $this->assign('need_upgrade', $need_upgrade);
  77. $this->assign('sys_version_no', SYS_VERSION_NO);
  78. $this->assign('sys_version_name', SYS_VERSION_NAME);
  79. $this->assign('sys_version', SYS_VERSION);
  80. $this->assign('sys_release', SYS_RELEASE);
  81. $this->assign('system_config', $system_config['data']);
  82. //待处理的事物
  83. $this->todo();
  84. return $this->fetch('index/index');
  85. // }
  86. }
  87. /**
  88. * 待处理项
  89. */
  90. public function todo(){
  91. //待审核商品
  92. $goods_model = new \app\model\goods\Goods();
  93. $goods_count_result = $goods_model->getGoodsTotalCount([["verify_state", "=", 0], ["is_delete", "=", 0]]);
  94. $this->assign("verify_goods_count", $goods_count_result["data"]);
  95. //举报商品
  96. $inform_model = new \app\model\goods\Inform();
  97. $inform_count_result = $inform_model->getInformCount([["state", "=", 0]]);
  98. $this->assign("inform_count", $inform_count_result["data"]);
  99. //查询平台维权数量
  100. $complain_model = new \app\model\order\Complain();
  101. $complain_count_result =$complain_model->getComplainCount([["complain_status", "=", 1]]);
  102. $this->assign("complain_count_result", $complain_count_result["data"]);
  103. // //店铺入驻申请
  104. // $shop_apply_model = new \app\model\shop\ShopApply();
  105. // $shop_apply_count_result = $shop_apply_model->getShopApplyCount([["apply_state", "in", [1,2]]]);
  106. // $this->assign("shop_apply_count", $shop_apply_count_result["data"]);
  107. // //店铺续签申请
  108. //
  109. $shop_reopen_model = new \app\model\shop\ShopReopen();
  110. $shop_reopen_count_result = $shop_reopen_model->getApplyReopenCount([["apply_state", "=", 1]]);
  111. $this->assign("shop_reopen_count", $shop_reopen_count_result["data"]);
  112. }
  113. /**
  114. * 官网资讯
  115. */
  116. public function news(){
  117. $web_model = new Web();
  118. $result = $web_model->news();
  119. return $result;
  120. }
  121. /**
  122. * 账号及安全
  123. */
  124. // public function security()
  125. // {
  126. // $user_model = new UserModel();
  127. // $bind_mobile_info = $user_model->getUserBindMobileInfo(UID);
  128. // $this->assign('bind_mobile_info', $bind_mobile_info);
  129. // $this->assign('uid', UID);
  130. // $user_info = $user_model->getUserInfo([ 'uid' => UID ]);
  131. // $this->assign('user_info', $user_info['data']);
  132. // return $this->fetch('index/security');
  133. // }
  134. /**
  135. * 校验当前域名
  136. */
  137. // public function checkSiteDomain()
  138. // {
  139. // $site_model = new Site();
  140. // //查询所有站点绑定域名
  141. // $domains = cache('domains');
  142. // if (!$domains) {
  143. //
  144. // $domains = $site_model->getSiteDomains();
  145. // cache('domains', $domains['data']);
  146. // }
  147. // //获取当前域名用于检测当前域名是否是站点绑定域名
  148. // $domain = request()->domain();
  149. // //检测是否存在绑定站点域名
  150. // if (array_key_exists($domain, $domains)) {
  151. // request()->siteid($domains[ $domain ]);
  152. // $site_info = $site_model->getSiteInfo([ 'site_id' => $domains[ $domain ] ]);
  153. // if (!empty($site_info)) {
  154. // $this->error("当前站点域名已配置!", $domain . "/admin/index");
  155. // }
  156. // }
  157. // }
  158. /**
  159. * 用户绑定手机操作
  160. * @return mixed
  161. */
  162. // public function bindMobile()
  163. // {
  164. // if (IS_AJAX) {
  165. // $mobile = input('mobile', '');
  166. // $sms_code = input('sms_code', '');
  167. // if(empty($mobile)){
  168. // return error(-1, "手机号不可以为空");
  169. // }
  170. // $key = md5("bind_mobile_code_" . 0 . "_" . $mobile);
  171. // $code = Cache::get($key);
  172. // if (empty($code)) {
  173. // return error(-1, "短信动态码已失效");
  174. // }
  175. // if ($sms_code != $code) {
  176. // return error(-1, "短信动态码错误");
  177. // }
  178. //
  179. // $user_model = new UserModel();
  180. // $res = $user_model->bindMobile($mobile, UID);
  181. // return $res;
  182. // }
  183. // }
  184. /**
  185. * 更改绑定手机号
  186. * @return \multitype
  187. */
  188. // public function updateMobile(){
  189. // if (IS_AJAX) {
  190. // $mobile = input('mobile', '');
  191. // $sms_code = input('sms_code', '');
  192. // if(empty($mobile)){
  193. // return error(-1, "手机号不可以为空");
  194. // }
  195. // //验证当前手机号
  196. // $key = md5("bind_mobile_code_" . 0 . "_" . $mobile);
  197. // $code = Cache::get($key);
  198. // if (empty($code)) {
  199. // return error(-1, "短信动态码已失效");
  200. // }
  201. // if ($sms_code != $code) {
  202. // return error(-1, "短信动态码错误");
  203. // }
  204. //
  205. // $user_model = new UserModel();
  206. // $res = $user_model->bindMobile($mobile, UID);
  207. //// $user_model->refreshUserInfoSession(UID);
  208. // return $res;
  209. // }
  210. // }
  211. /**
  212. * 检测手机号是否存在
  213. */
  214. // public function checkMobileIsExist()
  215. // {
  216. // if (IS_AJAX) {
  217. // $mobile = input('mobile', '');
  218. // $user_model = new UserModel();
  219. // $res = $user_model->checkMobileIsExist($mobile, UID);
  220. // return $res;
  221. // }
  222. // }
  223. /**
  224. * 绑死手机发送验证码
  225. */
  226. // public function sendSmsCode(){
  227. // $mobile = input("mobile", '');
  228. // if (empty($mobile)) {
  229. // return error(-1, "手机号不可以为空!");
  230. // }
  231. //
  232. // $user_model = new User();
  233. // $exist_result = $user_model->checkMobileIsExist($mobile);
  234. // $exist_count = $exist_result["data"];
  235. // if($exist_count > 0){
  236. // return error(-1, "当前手机号已存在!");
  237. // }
  238. //
  239. // $code = rand(100000, 999999);
  240. // $data = [ "keyword" => "BIND_MOBILE", "site_id" => 0, 'code' => $code, 'support_type' => "Sms", 'mobile' => $mobile ];//仅支持短信发送
  241. // $res = hook("SendMessage", $data);
  242. // if($res[0]["code"] == 0){
  243. // $key = md5("bind_mobile_code_" . 0 . "_" . $mobile);
  244. // Cache::set($key, $code, 3600);
  245. // }
  246. // return $res[0];
  247. // }
  248. // public function test(){
  249. // $addon = new Addon();
  250. // $data = $addon->getAddons();
  251. // $event = include 'app/event.php';
  252. // foreach ($data['addon_path'] as $k => $v)
  253. // {
  254. // $addon_event = require_once $v.'config/event.php';
  255. // $event['bind'] = array_merge($event['bind'], $addon_event['bind']);
  256. // $event['listen'] = array_merge($event['listen'], $addon_event['listen']);
  257. //
  258. // }
  259. //
  260. // }
  261. }