소스 검색

for card key stat

stanley-king 4 년 전
부모
커밋
3c693c88ec
2개의 변경된 파일38개의 추가작업 그리고 14개의 파일을 삭제
  1. 21 2
      data/config/dev/base.ini.php
  2. 17 12
      shop/control/card_keylist.php

+ 21 - 2
data/config/dev/base.ini.php

@@ -45,7 +45,9 @@ $config['gip'] 		= 0;
 $config['dbdriver'] = 'mysqli';
 $config['tablepre']	= 'lrlz_';
 
-define('SSH_TUNEL_PROD',true);
+//define('SSH_TUNEL_PROD',true);
+//define('SSH_TUNEL_PROD','xyz');
+define('SSH_TUNEL_PROD','lingzh');
 
 if(SSH_TUNEL_PROD === false) {
     $config['db'][1]['dbhost']       = MASTER_DBHOST;
@@ -62,7 +64,7 @@ if(SSH_TUNEL_PROD === false) {
     $config['db']['slave'][0]['dbname']     = 'xyzshop';
     $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
 }
-else {
+elseif(SSH_TUNEL_PROD === 'xyz') {
     //调试是先执行这行命令
     //shell_exec("ssh -NCPf root@121.89.223.81 -L 3307:127.0.0.1:3306");
     $config['db'][1]['dbhost']       = MASTER_DBHOST;
@@ -79,6 +81,23 @@ else {
     $config['db']['slave'][0]['dbname']     = 'xyzshop';
     $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
 }
+elseif(SSH_TUNEL_PROD === 'lingzh') {
+    //调试是先执行这行命令
+    //shell_exec("ssh -NCPf root@121.89.212.167 -L 3307:127.0.0.1:3306");
+    $config['db'][1]['dbhost']       = MASTER_DBHOST;
+    $config['db'][1]['dbport']       = '3307';
+    $config['db'][1]['dbuser']       = 'root';
+    $config['db'][1]['dbpwd']        = 'Linzhuhmnbmhhah#2021';
+    $config['db'][1]['dbname']       = 'xyzshop';
+    $config['db'][1]['dbcharset']    = 'UTF-8';
+
+    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
+    $config['db']['slave'][0]['dbport']     = '3307';
+    $config['db']['slave'][0]['dbuser']     = 'root';
+    $config['db']['slave'][0]['dbpwd']      = 'Linzhuhmnbmhhah#2021';
+    $config['db']['slave'][0]['dbname']     = 'xyzshop';
+    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
+}
 
 $config['session_expire'] 	= 3600;
 $config['lang_type'] 		= 'zh_cn';

+ 17 - 12
shop/control/card_keylist.php

@@ -41,27 +41,32 @@ class card_keylistcontrol extends BaseSellerControl
 
     public function statsOp()
     {
-        $condition = [];
+        $condition = ['card_id' => ['gt', 0]];
         if (in_array($_GET['card_state'], ['0', '1', '2', '3'])) {
             $condition['card_state'] = $_GET['card_state'];
         }
-        $counts = Model('')->table('card_key')
-            ->field('count(*) as card_count, card_type, amount, card_state')
+
+        $items = Model('')->table('card_key')
+            ->field('card_type, amount, card_state, count(*) as card_count, sum(amount) as card_amounts')
             ->where($condition)
             ->group('card_type,amount,card_state')
             ->select();
+
         $card_count = 0;
         $card_type_texts = [1 => '中石油', 2 => '中石化', 4 => '中国移动', 5 => '中国联通', 6 => '中国电信'];
         $data = $stats = [];
-        foreach ($counts as $key => $count) {
-            $card_count += $count['card_count'];
-            $count['card_type_text'] = $card_type_texts[$count['card_type']];
-            $count['amount'] = intval($count['amount']);
-            $key = "{$count['card_type_text']}-{$count['amount']}元";
-            $stats[$key][] = $count;
-        }
-        foreach ($stats as $key => $value) {
-            foreach ($value as $stat) {
+        foreach ($items as $item) {
+            $card_count += $item['card_count'];
+            $item['card_type_text'] = $card_type_texts[$item['card_type']];
+            $item['amount'] = intval($item['amount']);
+            $key = "{$item['card_type_text']}-{$item['amount']}元";
+            $stats[$key][] = $item;
+        }
+
+        foreach ($stats as $key => $value)
+        {
+            foreach ($value as $stat)
+            {
                 if(empty($data[$key]['UnusedCardCount'])) {
                     $data[$key]['UnusedCardCount'] = $stat['card_state'] == mtopcard\UnusedCard ? $stat['card_count'] : 0;
                 }