rabin 2 years ago
parent
commit
3355245b37
1 changed files with 22 additions and 18 deletions
  1. 22 18
      service/agent/lib/Order.php

+ 22 - 18
service/agent/lib/Order.php

@@ -1757,11 +1757,21 @@ class Order
                 }
             }
             $cash = 0;
-            $info = Dever::db('bill/cash')->getCash(array('mid' => $v['mid'], 'type' => 1));
-            if ($info) {
-                $cash = $info['total'];
-            }
+
             $month_cash = array();
+            $month = array();
+
+            $bill = Dever::db('bill/cash')->select(array('mid' => $v['mid'], 'type' => 1));
+            if ($bill) {
+                foreach ($bill as $k1 => $v1) {
+                    $time = date('Y年m月', $v1['cdate']);
+                    if (!isset($month[$time])) {
+                        $month[$time] = 0;
+                    }
+                    $month[$time] += $v1['cash'];
+                    $cash += $v1['cash'];
+                }
+            }
 
             if ($v['mid'] < 50000) {
                 $member = $db->fetch('select * from ims_ewei_shop_member where id = ' . $v['mid'] . '');
@@ -1772,30 +1782,24 @@ class Order
                         $record = $db->fetchAll('select * from `ims_ewei_shop_member_credit_record` where `remark` LIKE "%推荐%" and `remark` LIKE "%'.$member['openid'].'%" and credittype = "credit2"');
                     }
                     if (isset($record) && $record) {
-                        $month = array();
-                        $total = 0;
                         foreach ($record as $k1 => $v1) {
-                            $time = date('Ym', $v1['createtime']);
+                            $time = date('Y年m月', $v1['createtime']);
                             if (!isset($month[$time])) {
                                 $month[$time] = 0;
                             }
                             $month[$time] += $v1['num'];
-                            $total += $total;
-                        }
-
-                        if ($total > 0) {
-                            $cash += $total;
-                        }
-
-                        if (isset($month) && $month) {
-                            foreach ($month as $k2 => $v2) {
-                                $month_cash[] = $k2 . ':' . $v2;
-                            }
+                            $cash += $v1['num'];
                         }
                     }
                 }
             }
 
+            if (isset($month) && $month) {
+                foreach ($month as $k2 => $v2) {
+                    $month_cash[] = $k2 . ':' . $v2;
+                }
+            }
+
             if (!$cash) {
                 $cash = 0;
             }