ソースを参照

Merge branch 'rmaster' of 39.97.239.116:gyfl/xyzshop into rmaster

stanley-king 4 年 前
コミット
6c8e61acad

+ 2 - 2
admin/control/merchant.php

@@ -942,7 +942,7 @@ class merchantControl extends SystemControl
         }else{
             QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => true]);
         }
-        showMessage('操作成功', 'index.php?act=merchant&op=refill_order');
+        showMessage('操作成功', '');
     }
 
     public function notify_manual_merchantOp()
@@ -965,7 +965,7 @@ class merchantControl extends SystemControl
             showMessage('手动操作类型错误', 'index.php?act=merchant&op=refill_order');
         }
 
-        showMessage('操作成功', 'index.php?act=merchant&op=refill_order');
+        showMessage('操作成功', '');
     }
 
     public function providerStatsOp()

+ 41 - 23
shop/control/card_keylist.php

@@ -42,48 +42,66 @@ class card_keylistcontrol extends BaseSellerControl
     public function statsOp()
     {
         $condition = ['card_id' => ['gt', 0]];
-        if (in_array($_GET['card_state'], ['0', '1', '2', '3'])) {
-            $condition['card_state'] = $_GET['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')
+            ->order('card_type asc, amount asc, card_state asc')
             ->select();
 
         $card_count = 0;
         $card_type_texts = [1 => '中石油', 2 => '中石化', 4 => '中国移动', 5 => '中国联通', 6 => '中国电信'];
-        $data = $stats = [];
+        $stats = [];
         foreach ($items as $item) {
             $card_count += $item['card_count'];
-            $item['card_type_text'] = $card_type_texts[$item['card_type']];
+            $card_type = $item['card_type'];
             $item['amount'] = intval($item['amount']);
-            $key = "{$item['card_type_text']}-{$item['amount']}元";
+            $item['card_amounts'] = intval($item['card_amounts']);
+            $key = "{$card_type_texts[$card_type]}-{$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;
-                }
-                if(empty($data[$key]['ReserveCardCount'])) {
-                    $data[$key]['ReserveCardCount'] = $stat['card_state'] == mtopcard\ReserveCard ? $stat['card_count'] : 0;
-                }
-                if(empty($data[$key]['AssignedCardCount'])) {
-                    $data[$key]['AssignedCardCount'] = $stat['card_state'] == mtopcard\AssignedCard ? $stat['card_count'] : 0;
+        $card_state_stats = function($stats) {
+            $data = [];
+            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;
+                        $data[$key]['UnusedCardAmounts'] = $stat['card_state'] == mtopcard\UnusedCard ? $stat['card_amounts'] : 0;
+                    }
+                    if (empty($data[$key]['ReserveCardCount'])) {
+                        $data[$key]['ReserveCardCount'] = $stat['card_state'] == mtopcard\ReserveCard ? $stat['card_count'] : 0;
+                        $data[$key]['ReserveCardAmounts'] = $stat['card_state'] == mtopcard\ReserveCard ? $stat['card_amounts'] : 0;
+                    }
+                    if (empty($data[$key]['AssignedCardCount'])) {
+                        $data[$key]['AssignedCardCount'] = $stat['card_state'] == mtopcard\AssignedCard ? $stat['card_count'] : 0;
+                        $data[$key]['AssignedCardAmounts'] = $stat['card_state'] == mtopcard\AssignedCard ? $stat['card_amounts'] : 0;
+                    }
+                    if (empty($data[$key]['FreezedCardCount'])) {
+                        $data[$key]['FreezedCardCount'] = $stat['card_state'] == mtopcard\FreezedCard ? $stat['card_count'] : 0;
+                        $data[$key]['FreezedCardAmounts'] = $stat['card_state'] == mtopcard\FreezedCard ? $stat['card_amounts'] : 0;
+                    }
                 }
-                if(empty($data[$key]['FreezedCardCount'])) {
-                    $data[$key]['FreezedCardCount'] = $stat['card_state'] == mtopcard\FreezedCard ? $stat['card_count'] : 0;
-                }
-                $data[$key]['amount'] = $stat['amount'];
             }
+            return $data;
+        };
+        $data = $card_state_stats($stats);
+        $totals = [];
+        $items = Model('')->table('card_key')
+            ->field('card_type, card_state, count(*) as card_count, sum(amount) as card_amounts')
+            ->where($condition)
+            ->group('card_type,card_state')
+            ->order('card_type asc, card_state asc')
+            ->select();
+        foreach ($items as $item) {
+            $card_type = $item['card_type'];
+            $key = "{$card_type_texts[$card_type]}-总计:";
+            $totals[$key][] = $item;
         }
+        $total = $card_state_stats($totals);
         Tpl::output('card_count', $card_count);
         Tpl::output('stats', $data);
+        Tpl::output('totals', $total);
         Tpl::showpage('card_key.stats');
     }
 

+ 29 - 5
shop/templates/default/seller/card_key.stats.php

@@ -32,7 +32,7 @@
         </tr>
     </table>
 </form>
-<table class="ncsc-default-table">
+<table class="ncsc-default-table" id="card_stats">
     <thead>
     <tr>
         <th class="w150">卡密</th>
@@ -52,13 +52,37 @@
             <tr>
                 <td class="w150"><?php echo $key;?></td>
                 <td class="w100"><?php echo $stats['UnusedCardCount'];?></td>
-                <td class="w100"><?php echo $stats['UnusedCardCount'] * $stats['amount'];?></td>
+                <td class="w100"><?php echo $stats['UnusedCardAmounts'];?></td>
                 <td class="w100"><?php echo $stats['ReserveCardCount'];?></td>
-                <td class="w100"><?php echo $stats['ReserveCardCount'] * $stats['amount'];?></td>
+                <td class="w100"><?php echo $stats['ReserveCardAmounts'];?></td>
                 <td class="w100"><?php echo $stats['AssignedCardCount'];?></td>
-                <td class="w100"><?php echo $stats['AssignedCardCount'] * $stats['amount'];?></td>
+                <td class="w100"><?php echo $stats['AssignedCardAmounts'];?></td>
                 <td class="w100"><?php echo $stats['FreezedCardCount'];?></td>
-                <td class="w100"><?php echo $stats['FreezedCardCount'] * $stats['amount'];?></td>
+                <td class="w100"><?php echo $stats['FreezedCardAmounts'];?></td>
+            </tr>
+        <?php } ?>
+        <tr>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+            <td><hr/></td>
+        </tr>
+        <?php foreach ($output['totals'] as $key => $total) { ?>
+            <tr>
+                <td class="w150"><?php echo $key;?></td>
+                <td class="w100"><?php echo $total['UnusedCardCount'];?></td>
+                <td class="w100"><?php echo $total['UnusedCardAmounts'];?></td>
+                <td class="w100"><?php echo $total['ReserveCardCount'];?></td>
+                <td class="w100"><?php echo $total['ReserveCardAmounts'];?></td>
+                <td class="w100"><?php echo $total['AssignedCardCount'];?></td>
+                <td class="w100"><?php echo $total['AssignedCardAmounts'];?></td>
+                <td class="w100"><?php echo $total['FreezedCardCount'];?></td>
+                <td class="w100"><?php echo $total['FreezedCardAmounts'];?></td>
             </tr>
         <?php } ?>
     <?php } else { ?>