rabin 3 năm trước cách đây
mục cha
commit
a66712b508
1 tập tin đã thay đổi với 45 bổ sung0 xóa
  1. 45 0
      service/agent/lib/Tool.php

+ 45 - 0
service/agent/lib/Tool.php

@@ -765,4 +765,49 @@ class Tool
         }
         return 'ok';
     }
+
+    # 根据身份证号获取购买次数
+    public function buy_api()
+    {
+        $data = Dever::db('agent/order')->fetchAll('select mobile, name, idcard, count(*) as num,sum(price) as price from churen_agent_order where status = 4 and state = 1 and idcard is not null group by idcard order by num desc');
+
+        $head = array('姓名', '手机号', '身份证号', '购买数量', '购买总金额');
+        $body = array();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                if ($v['num'] > 1) {
+                    $body[] = array
+                    (
+                        $v['name'],
+                        $v['mobile'],
+                        $v['idcard'],
+                        $v['num'],
+                        $v['price'],
+                    );
+                }
+            }
+        }
+
+        $file = '复购数据';
+        $xls = Dever::excelExport($body, $head, $file, 0, '复购明细', true);
+
+        $data = Dever::db('agent/order')->fetchAll('select mobile, name, idcard, count(*) as num,sum(price) as price,role from churen_agent_order where status = 4 and state = 1 group by role order by num desc');
+
+        $head = array('角色名称', '购买数量', '购买总金额');
+        $body = array();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $role = Dever::db('setting/role')->find($v['role']);
+                if ($v['num'] > 1) {
+                    $body[] = array
+                    (
+                        $role['name'],
+                        $v['num'],
+                        $v['price'],
+                    );
+                }
+            }
+        }
+        return Dever::excelExport($body, $head, $file, 1, '角色复购数据', false, $xls);
+    }
 }