IndexController.class.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <?php
  2. namespace Seller\Controller;
  3. use Admin\Model\StatisticsModel;
  4. class IndexController extends CommonController {
  5. protected function _initialize(){
  6. parent::_initialize();
  7. }
  8. public function index(){
  9. //cookie('http_refer',$_SERVER['HTTP_REFERER']);
  10. //cookie('last_login_page');
  11. $is_new = I('get.is_new', 0 );
  12. if( $is_new == 1 )
  13. {
  14. //切换到新后台,
  15. cookie('is_new_backadmin',1);
  16. $data = array();
  17. $data['is_new_backadmin'] = 1;
  18. D('Seller/Config')->update($data);
  19. }else if( $is_new == 2 ){
  20. //切换到旧后台,
  21. cookie('is_new_backadmin',2);
  22. $data = array();
  23. $data['is_new_backadmin'] = 2;
  24. D('Seller/Config')->update($data);
  25. }
  26. $is_show_notice = true;
  27. $is_show_notice001 = D('Home/Front')->get_config_by_name('is_show_notice001');
  28. if( !isset($is_show_notice001) )
  29. {
  30. $data = array();
  31. $data['is_show_notice001'] = 1;
  32. D('Seller/Config')->update($data);
  33. }
  34. $this->is_show_notice001 = $is_show_notice001;
  35. $is_new_backadmin = D('Home/Front')->get_config_by_name('is_new_backadmin');
  36. $is_can_update = 1;
  37. if(SELLERUID != 1)
  38. {
  39. $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
  40. $perm_role = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  41. $perms_str = $perm_role['perms2'];
  42. if( strpos($perms_str, 'system') !== false)
  43. {
  44. $is_can_update = 1;
  45. }else{
  46. $is_can_update = 0;
  47. }
  48. $perms_arr = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  49. //goods,goods/goods/index,goods.goods.goodscategory,goods.goods.goodsspec,goods.goods.goodstag,goods.goods.config,goods.goods.settime,goods.goods.industrial
  50. $perms1 = str_replace('.','/',$perms_arr['perms2']);
  51. $perms2 = explode(",", $perms1);
  52. $perms = explode("/",$perms2[1]);
  53. $perm_url = $perms[1]."/".$perms[2];
  54. $this->perm_url = $perm_url;
  55. }
  56. $this->is_can_update = $is_can_update;
  57. if( empty($is_new_backadmin) || $is_new_backadmin == 2 )
  58. {
  59. $this->display();
  60. }else{
  61. $this->display('new_index');
  62. }
  63. //$this->display();
  64. //$this->display('new_index');
  65. }
  66. public function analys ()
  67. {
  68. //今天时间
  69. $today_time = strtotime( date('Y-m-d '.'00:00:00') );
  70. //支付成功订单数
  71. $today_success_where = " and order_status_id in (1,4,6,7,11,14) and pay_time > {$today_time} and type <> 'integral' ";
  72. $today_success_order_count = D('Seller/Order')->get_order_count($today_success_where);
  73. //支付取消订单数
  74. $today_cancel_where = " and order_status_id = 5 and date_added > {$today_time} and type <> 'integral' ";
  75. $today_cancel_order_count = D('Seller/Order')->get_order_count($today_cancel_where);
  76. $this->today_success_order_count = $today_success_order_count;
  77. $this->today_cancel_order_count = $today_cancel_order_count;
  78. //余额支付 yuer_pay_money_info
  79. $yuer_pay_where = " and payment_code ='yuer' and pay_time > {$today_time} and type <> 'integral' ";
  80. $yuer_pay_money_info = D('Seller/Order')->get_order_sum(' sum(total+shipping_fare-voucher_credit-fullreduction_money) as total ' , $yuer_pay_where);
  81. $yuer_pay_money = empty($yuer_pay_money_info['total']) ? 0:$yuer_pay_money_info['total'];
  82. $yuer_pay_money = sprintf("%.2f",$yuer_pay_money);
  83. $this->yuer_pay_money = $yuer_pay_money;
  84. //在线付款 payment_code支付方式 1.weixin 2.admin 3.yuer online_pay_money_info
  85. $online_pay_where = " and payment_code ='weixin' and pay_time > {$today_time} and type <> 'integral' ";
  86. $online_pay_money_info = D('Seller/Order')->get_order_sum(' sum(total+shipping_fare-voucher_credit-fullreduction_money) as total ' , $online_pay_where);
  87. $online_pay_money = empty($online_pay_money_info['total']) ? 0:$online_pay_money_info['total'];
  88. $online_pay_money = sprintf("%.2f",$online_pay_money);
  89. $this->online_pay_money = $online_pay_money;
  90. //积分抵现 score_for_money 积分抵现金额
  91. $score_for_money_where = " and score_for_money > 0 and pay_time > {$today_time} and type <> 'integral' ";
  92. $score_for_money_info = M('lionfish_comshop_order')->field(' sum(score_for_money) as score_for_money')->where("1 ".$score_for_money_where )->find();
  93. $score_for_money = empty($score_for_money_info['score_for_money']) ? 0:$score_for_money_info['score_for_money'];
  94. $score_for_money = sprintf("%.2f",$score_for_money);
  95. $this->score_for_money = $score_for_money;
  96. //使用积分
  97. $sum_score = 0;
  98. $sum_score = M('lionfish_comshop_member_integral_flow')->where(' addtime > '.$today_time.' and type = "orderbuy" and in_out = "out" ')->sum('score');
  99. if(empty($sum_score)){
  100. $sum_score = 0;
  101. }
  102. $this->sum_score = $sum_score;
  103. $this->display();
  104. }
  105. public function order_count()
  106. {
  107. //语音播报
  108. $voice_notice = D('Home/Front')->get_config_by_name('is_open_order_voice_notice');
  109. //供应商语音播报
  110. $is_open_supply_voice = D('Home/Front')->get_config_by_name('is_open_supply_voice');
  111. //获取有多少条的通知
  112. $day_time = strtotime( date('Y-m-d '.'00:00:00') );
  113. $day_key = 'new_ordernotice_'.$day_time;
  114. $day_arr = S( $day_key );
  115. $supply_arr = array();
  116. foreach( $day_arr as $key => $val )
  117. {
  118. $order_goods = M('lionfish_comshop_order_goods')->field('supply_id')->where( array('order_id' => $val ) )->find();
  119. $supply_arr[$val]['supply_id'] = $order_goods['supply_id'] ;
  120. }
  121. foreach( $supply_arr as $key1 => $val1 )
  122. {
  123. $a[$key1] = $val1['supply_id'];
  124. }
  125. //每个供应商对应订单数
  126. $supply_order_count = array_count_values($a);
  127. $order_count = 0;
  128. $info =array();
  129. if (!defined('ROLE') || ROLE != 'agenter' ){
  130. if( !empty($day_arr) )
  131. {
  132. //总订单数
  133. $order_count = count($day_arr);
  134. }
  135. $order_info = M('lionfish_comshop_order')->where( "order_status_id =1 and type != 'ignore'")->order('order_id desc')->find();
  136. //非供应商
  137. if(!empty($order_count)){
  138. $info =array(
  139. "resultCode"=>200,
  140. "message"=>"success",
  141. "data"=>$order_count,
  142. "voice_notice"=>$voice_notice,
  143. "order_type"=>$order_info['type']
  144. );
  145. }
  146. }else{
  147. //供应商
  148. if(!empty($is_open_supply_voice)){
  149. //获取供应商id
  150. $supply_id = $_SESSION["oscshop_seller_s"]["agent_auth"]["uid"];
  151. foreach($supply_order_count as $key2=>$value){
  152. if( $supply_id == $key2 ) {
  153. $order_count = $value;
  154. }
  155. }
  156. if(!empty($order_count)){
  157. $info =array(
  158. "resultCode"=>200,
  159. "message"=>"success",
  160. "data"=>$order_count,
  161. "voice_notice"=>$voice_notice
  162. );
  163. }
  164. }else{
  165. }
  166. }
  167. echo json_encode($info);
  168. die();
  169. }
  170. public function test()
  171. {
  172. $result = D('Seller/MpModifyTradeComponts')->uploadImg( ROOT_PATH.'Uploads/image/goods/2021-04-14/6076990200220.jpg' );
  173. var_dump( $result );
  174. die();
  175. }
  176. public function updatelog()
  177. {
  178. $auth_url ="http://pintuan.liofis.com/upgrade_dan.php";
  179. $version_info = M('lionfish_comshop_config')->where( array('name' => 'site_version') )->find();
  180. $version = $version_info['value'];
  181. $cur_release_info = M('lionfish_comshop_config')->where( array('name' => 'site_version') )->find();
  182. $cur_release = $cur_release_info['value'];
  183. $url = D('Home/Front')->get_config_by_name('shop_domain');
  184. $release = $cur_release;
  185. $modname = 'lionfish_comshop';
  186. $domain = trim(preg_replace('/http(s)?:\\/\\//', '', rtrim($url, '/')));
  187. $ip = gethostbyname($_SERVER['HTTP_HOST']);
  188. $resp = http_request($auth_url, array('action' => 'update_log','ip' => $ip,'release' => $release,'version' => $version, 'domain' => $domain) );
  189. $banben_list = @json_decode($resp, true);
  190. //version 版本号 release 时间 => 201901082100 desc 日志
  191. if($banben_list["result"]["version_desc"]){
  192. $banben_list['cur_version'] = $version;
  193. $banben_list['cur_release'] = $cur_release;
  194. $this->banben_list = $banben_list;
  195. include $this->display('Index/auth_updatelog');
  196. }else{
  197. $i =0 ;
  198. foreach( $banben_list as $key => $var){
  199. $data1[$i]['version'] = $var['version'];
  200. $year = substr($var['release'],2,2);
  201. $month =substr($var['release'],4,2);
  202. $day = substr($var['release'],6,2);
  203. $data1[$i]['release'] = "20".$year."-".$month."-".$day;
  204. $data1[$i]['desc'] = $var['desc'];
  205. $i++;
  206. }
  207. $data = array_reverse($data1);
  208. $this->data = $data;
  209. $this->display();
  210. }
  211. }
  212. /**
  213. * 配送消息发送
  214. */
  215. public function order_distribution(){
  216. $result = array();
  217. $result['no_send'] = D('Seller/Redisorder')->send_distribution_delivery_message();
  218. echo json_encode($result);
  219. die();
  220. }
  221. }