Your Name 2 лет назад
Родитель
Сommit
c459aa3c20

+ 32 - 0
service/agent/database/member_goods.php

@@ -598,5 +598,37 @@ return array
             
             'col' => '*',
         ),
+        'getMingxi' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => 'yes-t_1.name',
+                'sku_id' => 'yes-t_1.sku_id',
+                'start' => array('yes-t_1.cdate','>='),
+                'end' => array('yes-t_1.cdate','<='),
+                // 'shop_name' => array('yes-t_2.name','like'),
+                // 'shop_num' =>'yes-t_2.sid',
+                'mobile' => 'yes-t_2.mobile',
+                // 'mid' => 'yes-t_1.mid',
+                'type' => array('yes-t_1.type','in'),
+                // 'type_id' => 'yes-t_1.type_id',
+                'state' => 'yes-t_1.state-1',
+            ),
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'agent/member',
+                    'type' => 'left join',
+                    'on' => array('mid', 'id'),
+                    'col' => 't_2.id as aid',
+                )
+                
+            ),
+            'type' => 'all',
+            // 'order' => array('cdate'=>'desc'),
+            'col' => '*',
+        ),
     ),
 );

+ 298 - 0
tool/stats/assets/pc/html/out.html

@@ -0,0 +1,298 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>财务数据统计</title>
+<meta name="renderer" content="webkit">
+<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+<meta name="apple-mobile-web-app-status-bar-style" content="black"> 
+<meta name="apple-mobile-web-app-capable" content="yes">
+<meta name="format-detection" content="telephone=no">
+<link rel="stylesheet" type="text/css" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" type="text/css" href="../script/lib/valid/validationEngine.jquery.css">
+<!-- <link rel="stylesheet" type="text/css" href="../script/lib/layui/admin/style/admin.css?v9" media="all"> -->
+<link rel="stylesheet" type="text/css" href="../script/lib/fancybox/jquery.fancybox.css">
+<link rel="stylesheet" type="text/css" href="../script/lib/datetime/jquery.datetimepicker.css">
+
+
+<link rel="stylesheet" type="text/css" href="../script/lib/color/colpick.css">
+<link rel="stylesheet" type="text/css" href="../script/lib/kindeditor/themes/default/default.css?v1" />
+<link rel="stylesheet" type="text/css" href="../script/lib/valid/validationEngine.jquery.css">
+<link rel="stylesheet" type="text/css" href="../script/lib/highlight/highlight.min.css">
+<link rel="stylesheet" type="text/css" href="../script/lib/ui/ui.min.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script src="../script/lib/echarts/echarts.common.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+<script type="text/javascript" src="../script/lib/valid/jquery.validationEngine.min.js?v3"></script>
+<script type="text/javascript" src="../script/lib/layui/upload.js?v226"></script>
+<script type="text/javascript" src="../script/lib/datetime/jquery.datetimepicker.min.js?v2"></script>
+<script type="text/javascript" src="../script/lib/clipboard/clipboard.js?v11"></script>
+<script type="text/javascript" src="../script/lib/highlight/highlight.min.js"></script>
+<script type="text/javascript" src="../script/lib/fancybox/jquery.fancybox.js"></script>
+<script src="../script/lib/manage/main.js?v82"></script>
+
+
+<script type="text/javascript" src="../script/lib/pic/webp.js"></script>
+
+
+<script type="text/javascript" src="../script/lib/color/colpick.js"></script>
+
+<script type="text/javascript" src="../script/lib/kindeditor/kindeditor-all-min.js?v9"></script>
+<script type="text/javascript" src="../script/lib/kindeditor/lang/zh-CN.js?v7"></script>
+
+<script type="text/javascript" src="../script/lib/ui/ui.min.js"></script>
+
+
+<script type="text/javascript" src="../script/lib/qiniu/upload/plupload.full.min.js"></script>
+
+<script type="text/javascript" src="../script/lib/qiniu/qiniu.upload.js"></script>
+<script type="text/javascript" src="../script/lib/oss/aliyun-oss-sdk-6.11.2.min.js"></script>
+<script type="text/javascript" src="../script/lib/tool/md5.js"></script>
+
+<script type="text/javascript" src="../script/lib/layui/upload.js?v226"></script>
+<script type="text/javascript" src="../script/lib/layui/layui.js"></script>
+
+<script type="text/javascript" src="../script/lib/clipboard/clipboard.js"></script>
+
+<script type="text/javascript" src="../script/lib/pic/holder.js"></script>
+
+<script type="text/javascript" src="../script/lib/excel/xlsx.min.js"></script>
+<script type="text/javascript" src="../script/lib/excel/excel.js?v16"></script>
+<style>
+
+body{
+    background:white;
+	/*padding-left: 10px;*/
+	height:100%;
+}
+.layout{
+    width: 100%;
+
+    height: 100%;
+
+    /*display: flex;*/
+    justify-content : space-around;
+    font-size:14px;
+
+}
+h3{
+	margin-top: 20px;
+	margin-bottom: 20px;
+	margin-left: 20px;
+}
+.layui-elem-quote{
+	margin-left:20px;
+}
+.cate{
+	height:38px;
+	border-width: 1px;
+	border-radius:2px;
+	line-height: 1.3;
+}
+.type{
+	height:38px;
+	border-width: 1px;
+	border-radius:2px;
+	line-height: 1.3;
+}
+input{
+	margin-top: 5px;
+	margin-bottom: 5px;
+}
+a{
+	margin-left: 10px;
+}
+</style>
+</head>
+<body>
+	<div class="layout">
+		<div class="layui-card">
+		<div><h3>厨人意料管理平台-商品销售相关数据</h3></div>
+	     <blockquote class="layui-elem-quote">
+	      <select class = 'cate'>
+	     	<option class = 'cate' value="-1">选择店铺类型</option>
+	        <option class = 'cate' value="1">体验店</option>
+	        <option  class = 'cate' value="2">平台商城</option>
+    	</select>
+    	<input type="text" value="" autocomplete="shop_name" id="shop_name" class="layui-input" style="width: auto;display: inline;" placeholder="门店名称">
+    	<input type="text" value="" autocomplete="goods_name" id="goods_name" class="layui-input" style="width: auto;display: inline;" placeholder="商品名称">
+    	<input type="text" value="" autocomplete="order_num" id="order_num" class="layui-input" style="width: auto;display: inline;" placeholder="订单号">
+	     <!-- <br/>下单时间: -->
+	     <input type="text" value="" autocomplete="order" id="date" class="layui-input" style="width: auto;display: inline;" placeholder="下单时间">
+	    <!--  发货时间: -->
+	     <input type="text" value="" autocomplete="fa" id="fa" class="layui-input" style="width: auto;display: inline;" placeholder="发货时间">
+	     <!-- 完成时间: -->
+	     <input type="text" value="" autocomplete="finish" id="fi" class="layui-input" style="width: auto;display: inline;" placeholder="完成时间">
+	    
+	     <!-- <br/> -->
+	     <a href="javascript:;" class="layui-btn" id="search">数据导出</a>
+	     </blockquote>
+	     <div><h3>厨人意料管理平台-代理商系统权益数据汇总</h3></div>
+	     <blockquote  class="layui-elem-quote">
+			<input type="text" value="" autocomplete="dh_name" id="dh_name" class="layui-input" style="width: auto;display: inline;" placeholder="权益名称">
+			<input type="text" value="" autocomplete="member_name" id="member_name" class="layui-input" style="width: auto;display: inline;" placeholder="姓名">
+    		<input type="text" value="" autocomplete="mobile" id="mobile" class="layui-input" style="width: auto;display: inline;" placeholder="手机号">
+    		<input type="text" value="" autocomplete="card_num" id="card_num" class="layui-input" style="width: auto;display: inline;" placeholder="卡号">
+    		<input type="text" value="" autocomplete="getday" id="getday" class="layui-input" style="width: auto;display: inline;" placeholder="获取时间">
+    		<input type="text" value="" autocomplete="regday" id="regday" class="layui-input" style="width: auto;display: inline;" placeholder="代理商注册时间">
+    		<input type="text" value="" autocomplete="cardday" id="cardday" class="layui-input" style="width: auto;display: inline;" placeholder="礼品卡有效期">
+    		<!-- <br/> -->
+    		<a href="javascript:;" class="layui-btn" id="out">数据导出</a>
+	     </blockquote>
+	     <div><h3>厨人意料管理平台-代理商系统权益数据明细</h3></div>
+	     <blockquote class="layui-elem-quote">
+	     <select class = 'type'>
+	     	<option class = 'type' value="-1">选择类型</option>
+	        <option class = 'type' value="1">发放权益</option>
+	        <option  class = 'type' value="2">兑换权益</option>
+	        <option  class = 'type' value="3">使用权益</option>
+    	</select>
+    	<input type="text" value="" autocomplete="dh_name" id="dh_names" class="layui-input" style="width: auto;display: inline;" placeholder="权益名称">
+    	<input type="text" value="" autocomplete="mobile" id="mobiles" class="layui-input" style="width: auto;display: inline;" placeholder="手机号">
+    	<input type="text" value="" autocomplete="card_num" id="card_nums" class="layui-input" style="width: auto;display: inline;" placeholder="卡号">
+    	<input type="text" value="" autocomplete="shop_num" id="shop_nums" class="layui-input" style="width: auto;display: inline;" placeholder="门店编号">
+    	<input type="text" value="" autocomplete="shop_name" id="shop_names" class="layui-input" style="width: auto;display: inline;" placeholder="门店名称">
+    	<!-- <br/> -->
+    	<input type="text" value="" autocomplete="order_num" id="order_nums" class="layui-input" style="width: auto;display: inline;" placeholder="关联平台商城订单号">
+
+	     <input type="text" value="" autocomplete="day" id="day" class="layui-input" style="width: auto;display: inline;" placeholder="日期">
+	     <!-- <br/> -->
+    		<a href="javascript:;" class="layui-btn" id="out_mingxi">数据导出</a>
+	     </blockquote>
+		</div>
+	</div>
+
+<script>
+layui.use(['form','element', 'layer', 'jquery', 'laydate'], function(){
+  var form = layui.form;
+  var laydate = layui.laydate;
+  laydate.render({
+    elem: '#date',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#fa',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#fi',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#getday',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#regday',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#cardday',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#day',
+    range: '~'
+  });
+});
+function search()
+{
+  var date = $('#date').val();
+  var fa = $('#fa').val();
+  var fi = $('#fi').val();
+  if (date) {
+    var s = date.split(' ~ ');
+  } else {
+    var s = [];
+    s[0] = '';
+    s[1] = '';
+  }
+  if (fa) {
+  	var a = fa.split(' ~ ');
+  } else {
+  	var a = [];
+  	a[0] = '';
+  	a[1] = '';
+  }
+  if (fi) {
+  	var f = fi.split(' ~ ');
+  } else {
+  	var f = [];
+  	f[0] = '';
+  	f[1] = '';
+  }
+  cate = $(".cate").val();
+  order_num = $('#order_num').val();
+  goods_name = $('#goods_name').val();
+  shop_name = $('#shop_name').val();
+  location.href = config.host + 'lib/manage.list&start=' + s[0] + '&end=' + s[1] + '&fastart=' + a[0] + '&faend=' + a[1] + '&fstart=' + f[0] + '&fend=' + f[1] + '&cate=' + cate + '&order_num=' + order_num + '&shop_name=' + shop_name + '&goods_name=' + goods_name ;
+}
+$('#search').click(function() {
+  search();
+})
+function out()
+{
+  var getday = $('#getday').val();
+  var regday = $('#regday').val();
+  var cardday = $('#cardday').val();
+  if (getday) {
+    var g = getday.split(' ~ ');
+  } else {
+    var g = [];
+    g[0] = '';
+    g[1] = '';
+  }
+  if (regday) {
+  	var r = regday.split(' ~ ');
+  } else {
+  	var r= [];
+  	r[0] = '';
+  	r[1] = '';
+  }
+  if (cardday) {
+  	var c = cardday.split(' ~ ');
+  } else {
+  	var c = [];
+  	c[0] = '';
+  	c[1] = '';
+  }
+  dh_name = $("#dh_name").val();
+  member_name = $("#member_name").val();
+  card_num = $('#card_num').val();
+  mobile = $('#mobile').val();
+  location.href = config.host + 'lib/manage.memberGoods&start=' + g[0] + '&end=' + g[1] + '&rstart=' + r[0] + '&rend=' + r[1] + '&cstart=' + c[0] + '&cend=' + c[1] + '&name=' + dh_name + '&card_num=' + card_num + '&mobile=' + mobile + '&member_name=' + member_name;
+}
+$('#out').click(function() {
+  out();
+})
+function out_mingxi()
+{
+	var day = $('#day').val();
+	if (day) {
+		var d = day.split(' ~ ');
+	} else {
+		var d = [];
+	  	d[0] = '';
+	  	d[1] = '';
+	}
+	dh_name = $("#dh_names").val();
+	shop_name = $("#shop_names").val();
+	card_num = $('#card_nums').val();
+	shop_num = $('#shop_nums').val();
+	order_num = $('#order_nums').val();
+	mobile = $('#mobiles').val();
+	type = $('.type').val();
+	location.href = config.host + 'lib/manage.mingxi&start=' + d[0] + '&end=' + d[1] + '&name=' + dh_name + '&card_num=' + card_num + '&mobile=' + mobile + '&shop_name=' + shop_name + '&shop_num=' + shop_num + '&order_num=' + order_num + '&type=' + type;
+}
+$('#out_mingxi').click(function() {
+  out_mingxi();
+})
+
+</script>
+</body>
+</html>

+ 10 - 0
tool/stats/index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'stats');
+define('DEVER_APP_LANG', '数据导出');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 20);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-website');
+define('DEVER_GROUP_ORDER', 1);
+define('DEVER_GROUP_NAME', '控制台');
+include(DEVER_APP_PATH . '../boot.php');

+ 655 - 0
tool/stats/lib/Manage.php

@@ -0,0 +1,655 @@
+<?php
+namespace Stats\Lib;
+use Dever;
+Class Manage
+{
+	public function index_api()
+	{
+		$data = array();
+		$start = Dever::input('start');
+		$end = Dever::input('end');
+		if (!$start && !$end) {
+			$start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
+            $end = strtotime(date('Y-m-d 23:59:59',
+                strtotime(date('Y-m-01')."+1 month - 1 day")));
+			$data['start'] = date('Y-m-d',$start);
+			$data['end'] = date('Y-m-d',$end);
+		} else {
+			$data['start'] = date('Y-m-d',$start);
+			$data['end'] = date('Y-m-d',$end);
+		}
+		$fastart = Dever::input('fastart');
+		$faend = Dever::input('faend');
+		if (!$fastart && !$faend) {
+			$fastart=Dever::maketime(date('Y-m-01') . ' 00:00:00');
+            $faend = strtotime(date('Y-m-d 23:59:59',
+                strtotime(date('Y-m-01')."+1 month - 1 day")));
+			$data['fastart'] = date('Y-m-d',$fastart);
+			$data['faend'] = date('Y-m-d',$faend);
+		} else {
+			$data['fastart'] = date('Y-m-d',$fastart);
+			$data['faend'] = date('Y-m-d',$faend);
+		}
+		$fstart = Dever::input('fstart');
+		$fend = Dever::input('fend');
+		if (!$fstart && !$fend) {
+			$fstart=Dever::maketime(date('Y-m-01') . ' 00:00:00');
+            $fend = strtotime(date('Y-m-d 23:59:59',
+                strtotime(date('Y-m-01')."+1 month - 1 day")));
+			$data['fstart'] = date('Y-m-d',$fstart);
+			$data['fend'] = date('Y-m-d',$fend);
+		} else {
+			$data['fstart'] = date('Y-m-d',$fstart);
+			$data['fend'] = date('Y-m-d',$fend);
+		}
+		$data['type'] = array(1 => '体验店',2 => '零售店',10 => '平台商城');
+		return Dever::render('out', $data);
+	}
+	public function list_api()
+	{
+		$header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额', '代理优惠金额', '商品实付金额', '礼品卡金额', '钱包金额','商品支付金额', '礼品卡名称', '礼品卡卡号', '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '礼品卡金额', '钱包金额', '优惠券金额', '代理优惠金额', '订单状态', '退款状态', '退款时间', '退款金额', '收件人', '收件人手机', '收件人地址');
+
+		$body = array();
+		$status = Dever::db('shop/sell_order')->config['status_manage'];
+		$start = Dever::input('start');
+		$end = Dever::input('end');
+		$fastart = Dever::input('fastart');
+		$faend = Dever::input('faend');
+		$fstart = Dever::input('fstart');
+		$fend = Dever::input('fend');
+		$cate = Dever::input('cate');
+		$name = Dever::input('goods_name');
+		$shop_name = Dever::input('shop_name');
+		if ($start) {
+			$where['start'] = strtotime($start);
+		}
+		if ($end) {
+			$where['end'] = strtotime($end);
+		}
+		if ($fastart) {
+			$where['fastart'] = strtotime($fastart);
+		}
+		if ($faend) {
+			$where['faend'] = strtotime($faend);
+		}
+		if ($fstart) {
+			$where['fstart'] = strtotime($fstart);
+		}
+		if ($fend) {
+			$where['fend'] = strtotime($fend);
+		}
+		if ($cate && $cate>0) {
+			$where['shop_type'] = $cate;
+		}
+		if ($name) {
+			$where['name'] = $name;
+		}
+		if ($shop_name) {
+			$shop = Dever::db('shop/info')->find(array('name'=>$name));
+			if ($shop) {
+				$where['shop_id'] = $shop['id'];
+			}
+		}
+		$where['state'] = 1;
+		$data = Dever::db('shop/sell_order')->getExcel($where);
+		if ($data) {
+			foreach ($data as $k => $v) {
+				$v['card'] = '';
+				$v['card_code'] = '';
+		        if ($v['card_code_id']) {
+		            $code = Dever::db('card/code')->find($v['card_code_id']);
+		            if ($code) {
+		                $card_info = Dever::db('card/info')->find($code['card_id']);
+		                if ($card_info) {
+		                    if (!$code['total_cash']) {
+		                        $code['total_cash'] = $card_info['value'];
+		                    }
+		                    $v['card'] = $card_info['name'];
+		                    $v['card_code'] = $code['card'];
+		                }
+		            }
+		        }
+				if ($v['shop_type'] == 1) {
+					$v['shop_type_name'] = '体验店';
+				} elseif ($v['shop_type'] == 2) {
+					$v['shop_type_name'] = '平台商城';
+				}
+				$shop = Dever::db('shop/info')->find(Array('id'=>$v['shop_id']));
+				if (isset($shop) && $shop) {
+					$data[$k]['shop_sid'] = $shop['sid'];
+					$data[$k]['shop_name'] = $shop['name'];
+				}
+				$zhuce = '';
+				$address_contact = '';
+				$address_mobile = '';
+				$address_info = '';
+				if ($v['address_id'] > 0) {
+        			$address = Dever::load('passport/address')->getOne($v['uid'], $v['address_id']);
+        			if($address) {
+        				$address_contact = $address['contact'];
+        				$address_mobile = $address['mobile'];
+        				$address_info = $address['address_info'];
+        				$member = Dever::db('agent/member')->find(array('mobile'=>$address['mobile']));
+        				if ($member) {
+        					$zhuce = date('Y-m-d H:i',$member['cdate']);
+        				}
+        			}
+        		}
+        		$ps = Dever::db('shop/sell_order_ps')->find(array('order_id' => $v['id']));
+	            $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']);
+	            $paydate = isset($v['paydate']) && $v['paydate'] ? date('Y-m-d H:i', $v['paydate']) : '-';
+	            $operdate = ($ps && $ps['cdate']) ? date('Y-m-d H:i', $ps['cdate']) : '-';
+				$goods = Dever::db('shop/sell_order_goods')->select(Array('order_id'=>$v['id']));
+				$fdate = '';
+				if ($v['fdate']) {
+					$fdate = date('Y-m-d H:i',$v['fdate']);
+				}
+				
+				
+				
+				foreach ($goods as $k1 => $v1) {
+					$goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
+					if (isset($goods_info['sku'])) {
+	                    $sku = $goods_info['sku']['string'];
+	                } else {
+	                    $sku = '';
+	                }
+	                $goods_price = $v1['price']*$v1['num'];
+	                #代理优惠金额
+	                $discount_cash = round($v['discount_cash']/$goods_price,2);
+	                #商品实付金额
+	                $price = round(($v['price']/$goods_price),2);
+	                #礼品卡金额
+	                $card_code_cash = round(($v['card_code_cash']/$goods_price),2);
+	                #钱包金额
+	                $wallet_cash = round(($v['wallet_cash']/$goods_price),2);
+	                #商品支付金额
+	                if ($k1 == 0) {
+	                	$total_cash = Dever::load("shop/lib/manage.getTotalCash", $v['id']);
+	                } else {
+	                	$total_cash = 0;
+	                }
+	                
+	                 if ($v['status'] == 8 || $v1['status'] == 3) {
+	                    $num = $v1['num'];
+	                    $v['refund_cash'] = $v1['price']*$v1['num'];
+	                    $refund_status = '已退款';
+	                    $refund_cdate = '';
+	                    if ($v['shop_type'] == 1) {
+	                    	$refund = Dever::db('shop/sell_order_refund')->find(array('order_id'=>$v['id']));
+							if ($refund) {
+								$refund_cdate = date('Y-m-d H:i',$refund['cdate']);
+							}
+	                    }
+	                    
+	                } else {
+	                	$refund_cdate = '';
+	                    $num = '0';
+	                    $v['refund_cash'] = '0';
+	                    $refund_status = '未退款';
+	                }
+	                if ($v['status'] >=7) {
+	                	$v['price'] = 0;
+	                }
+	                
+	                if ($k1 == 0) {
+	                    $v['num'] = $v['num'];
+	                    $v['card_code_cash'] = $v['card_code_cash'];
+	                    $v['price'] = $v['price'];
+	                    $v['wallet_cash'] = $v['wallet_cash'];
+	                    $v['coupon_cash'] = $v['coupon_cash'];
+	                    $v['discount_cash'] = $v['discount_cash'];
+	                } else {
+	                    $v['num'] = 0;
+	                    $v['card_code_cash'] = 0;
+	                    $v['price'] = 0;
+	                    $v['wallet_cash'] = 0;
+	                    $v['coupon_cash'] = 0;
+	                    $v['discount_cash'] = 0;
+	                }
+	                $d = array
+                    (
+                        $v['shop_type_name'],
+						$data[$k]['shop_sid'],
+						$data[$k]['shop_name'],
+						$v['order_num'],
+						$goods_info['code'] . "\t",
+						$goods_info['cunhuo_code'] . "\t",
+                    	$goods_info['name'],
+						$sku,
+						$goods_info['tax'],
+						round($v1['price'], 2),
+						round($v1['num'],2),
+						round($v1['price']*$v1['num'], 2),
+						$discount_cash,
+						$price,
+						$card_code_cash,
+						$wallet_cash,
+						$price,
+						$v['card'],
+						$v['card_code'],
+						$zhuce,
+						$cdate,
+						$paydate,
+						$operdate,
+						$fdate,
+						$v['num'],
+						round($total_cash, 2),
+	                    round($v['price'], 2),
+	                    round($v['card_code_cash'], 2),
+	                    round($v['wallet_cash'], 2),
+	                    round($v['coupon_cash'], 2),
+	                    round($v['discount_cash'], 2),
+	                    $status[$v['status']],
+	                    $refund_status,
+	                    $refund_cdate,
+	                    round($v['refund_cash'], 2),
+	                    $address_contact,
+	                    $address_mobile,
+	                    $address_info,
+                    );
+					
+					$body[] = $d;
+					if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) {
+                    
+	                    foreach ($goods_info['goods'] as $k2 => $v2) {
+	                        if ($v2['code']) {
+	                            //$v2['code'] = '-' . $v2['code'];
+	                        }
+	                        $p = $v2['price'];
+	                        if (is_numeric($v2['num']) && is_numeric($v2['price'])) {
+	                            $p = $v2['price']*$v2['num'];
+	                        }
+	                        $goods_price1 = 0;
+	                        
+	                        $d = array
+							(
+								$v['shop_type_name'],
+								$data[$k]['shop_sid'],
+								$data[$k]['shop_name'],
+								$v['order_num'],
+								$goods_info['code'] . "\t",
+								$goods_info['cunhuo_code'] . "\t",
+		                    	$goods_info['name'],
+								$sku,
+								$goods_info['tax'],
+								round($v1['price'], 2),
+								round($v1['num'],2),
+								round($v1['price']*$v1['num'], 2),
+								$discount_cash,
+								$price,
+								$card_code_cash,
+								$wallet_cash,
+								$price,
+								$v['card'],
+								$v['card_code'],
+								$zhuce,
+								$cdate,
+								$paydate,
+								$operdate,
+								$fdate,
+								'',
+								'',
+			                    '',
+			                    '',
+			                    '',
+			                    '',
+			                    '',
+			                    $status[$v['status']],
+			                    '',
+			                    '',
+			                    '',
+			                    $address_contact,
+			                    $address_mobile,
+			                    $address_info,
+							);
+
+	                        $body[] = $d;
+	                    }
+	                }
+				}
+			}
+		}
+		$file = '商品销售相关数据';
+    	return Dever::excelExport($body, $header, $file);
+	}
+	public function memberGoods_api()
+	{
+		$name = Dever::input('name');
+		$member_name = Dever::input('member_name');
+		$card_num = Dever::input('card_num');
+		$mobile = Dever::input('mobile');
+		$start = Dever::input('start');
+		$end = Dever::input('end');
+		$rstart = Dever::input('rstart');
+		$rend = Dever::input('end');
+		$cstart = Dever::input('cstart');
+		$cend = Dever::input('cend');
+		if ($card_num) {
+			$code = Dever::db('card/code')->find(array('card'=>$card_num));
+			if ($code){
+				$where['sku_id'] = "t_1.sku_id=".$code['id'];
+			}
+		}
+
+		if ($name) {
+			$where['name'] = "t_1.name like '%$name%'";
+		} 
+		if ($cstart) {
+			$where['cstart'] = 't_1.cdate+(360*86400)>='. strtotime($cstart);
+		} 
+		if ($cend) {
+			$where['cend'] = 't_1.cdate+(360*86400)<='.strtotime($cend);
+		} 
+		if ($start) {
+			$where['start'] = 't_1.cdate>='.strtotime($start);
+		}
+		if ($end) {
+			$where['end'] = 't_1.cdate<='.strtotime($end);
+		} 
+		
+		if ($member_name) {
+			$where['member_name'] = "t_2.name='%$member_name%'";
+		} 
+		if ($mobile) {
+			$where['mobile'] = 't_2.mobile='.$mobile;
+		} 
+		if ($rstart) {
+			$where['rstart'] = 't_2.cdate>='.strtotime($rstart);
+		} 
+		if ($rend) {
+			$where['rend'] = 't_2.cdate<='.strtotime($rend);
+		} 
+		$where['t_1.state'] = 't_1.state=1';
+		$header = array('权益名称','会员等级','姓名','手机号','卡号','类型','数量','单件价值','总价值','已兑换价值','已使用价值','未兑换价值','未使用价值','备注','获取方式','获取时间','代理商注册时间','礼品卡有效期');
+		if ($where) {
+			$where = implode(' and ', $where);
+			$data = Dever::db('agent/member_goods')->fetchAll("select t_1.*,t_2.id as aid from churen_agent_member_goods as t_1 left join churen_agent_member as t_2 on t_1.mid = t_2.id where " . $where);
+			// $data = Dever::db('agent/member_goods')->getJoinAll($where);
+			// echo Dever::sql();die;
+			if ($data) {
+				foreach ($data as $k => $v) {
+					$role_name = '';
+					$member_name = '';
+					$member_mobile = '';
+					$member = Dever::db('agent/member')->find($v['mid']);
+					if ($member) {
+						$member_cdate = '-';
+			            if($member['cdate']){
+			                $member_cdate = date('Y-m-d H:i',$member['cdate']);
+			            }
+						$member_name = $member['name'];
+						$member_mobile = $member['mobile'];
+						$role = Dever::db('setting/role')->find(array($member['role']));
+						if ($role) {
+							$role_name = $role['name'];
+						}
+					}
+					$wd = ($v['total_num'] - $v['sell_num'])*$v['price'];
+            		$yd = $v['sell_num']*$v['price'];
+					$card = '-';
+		            $mianzhi = '0';
+		            $money = '-';
+		            $youxiao = '';
+		            $leitype = '发放权益';
+		            if($v['type'] == 2){
+		                $code = Dever::db('card/code')->find($v['sku_id']);
+		                if($code){
+		                    $card_info = Dever::db('card/info')->find($code['card_id']);
+		                    if ($card_info && $card_info['end_dh_day']) {
+		                        $youxiao = date('Y-m-d H:i',strtotime(+ $card_info['end_dh_day'].'day',$code['bdate']));
+		                    }
+		                    $card = $code['card']."\t";
+		                    $mianzhi = $code['use_cash']; 
+		                }                  
+		            }
+		            $wy = $v['cash'] - $mianzhi;
+		            $desc = '';
+		            $member_goods_log = Dever::db('agent/member_goods_log')->getOne(array('type'=>$v['type'],'type_id'=>$v['type_id'],'sku_id'=>$v['sku_id'],'state'=>1));
+		            if($member_goods_log && $member_goods_log['desc']){
+		                $desc = $member_goods_log['desc'];
+		            }
+		            $d = array
+		            (
+		            	$v['name'],
+		            	$role_name,
+		            	$member_name,
+		            	$member_mobile,
+		            	$card,
+		            	$leitype,
+		            	$v['total_num'],
+		            	$v['price'],
+		            	$v['cash'],
+		            	$yd,
+		            	$mianzhi,
+		            	$wd,
+		            	$wy,
+		            	$desc,
+		            	'',
+		            	date('Y-m-d H:i',$v['cdate']),
+		                $member_cdate,
+		                $youxiao,
+		            );
+		            $body[] = $d;
+				}
+				$file = '代理商权益';
+        		return Dever::excelExport($body, $header, $file);
+			}
+		}
+	}
+	#代理商权益发放使用兑换明细
+	public function mingxi_api()
+	{
+		$name = Dever::input('name');
+		$mobile = Dever::input('mobile');
+		$card_num = Dever::input('card_num');
+		$shop_name = Dever::input('shop_name');
+		$shop_num = Dever::input('shop_num');
+		$order_num = Dever::input('order_num');
+		$start = Dever::input('start');
+		$end = Dever::input('end');
+		$type = Dever::input('type');
+		if ($name) {
+			$where['name'] = $name;
+		}
+		if ($mobile) {
+			$where['mobile'] = $mobile;
+		}
+		if ($card_num) {
+			$code = Dever::db('card/code')->find(array('card'=>$card_num));
+			if ($code){
+				$where['sku_id'] = $code['id'];
+			}
+		}
+		if ($shop_name) {
+			$shop = Dever::db('shop/info')->find(array('name'=>$shop_name));
+			$where['shop_id'] = $shop['id'];
+		}
+
+		if ($shop_num) {
+			$shop = Dever::db('shop/info')->fetch('select * from churen_shop_info where sid = '.$shop_num.' and state = 1');
+			$where['shop_id'] = $shop['id'];
+		}
+		// print_R($where['shop_id']);die;
+		if ($order_num) {
+			$sell_order = Dever::db('shop/sell_order')->find(array('order_num'=>$order_num));
+			$where['sku_id'] = $sell_order['card_code_id'];
+
+		}
+		if ($start) {
+			$where['start'] = strtotime($start);
+		}
+		if ($end) {
+			$where['end'] = strtotime($end);
+		}
+		if ($type) {
+			$where['types'] = $type;
+		}
+		$header = array('日期','权益名称','会员等级','姓名','手机号','卡号','类型','数量','单件价值','总价值','门店类型','门店编号','门店名称','关联平台商城订单号','备注','获取方式','获取时间','代理商注册时间','礼品卡有效期');
+		$body = array();
+		$where['type'] = '1,2';
+		$data = Dever::db('agent/member_goods')->getMingxi($where);
+		if ($data) {
+			foreach ($data as $k =>$v) {
+				$cdata = '';
+				if ($v['cdate']) {
+					$cdate = date('Y-m-d H:i',$v['cdate']);
+				}
+				$type = '发放权益';
+				$role_name = '';
+				$member_name = '';
+				$member_mobile = '';
+				$member_cdate = '-';
+				$member = Dever::db('agent/member')->find($v['mid']);
+				if ($member) {
+		            if($member['cdate']){
+		                $member_cdate = date('Y-m-d H:i',$member['cdate']);
+		            }
+					$member_name = $member['name'];
+					$member_mobile = $member['mobile'];
+					$role = Dever::db('setting/role')->find(array($member['role']));
+					if ($role) {
+						$role_name = $role['name'];
+					}
+				}
+				$card = '';
+				$youxiao = '';
+				if ($v['type'] == 2){
+	                $code = Dever::db('card/code')->find($v['sku_id']);
+	                if($code){
+	                    $card_info = Dever::db('card/info')->find($code['card_id']);
+	                    if ($card_info && $card_info['end_dh_day']) {
+	                        $youxiao = date('Y-m-d H:i',strtotime(+ $card_info['end_dh_day'].'day',$code['bdate']));
+	                    }
+	                    $card = $code['card']."\t";
+	                }                  
+	            }
+	            $desc = '';
+	            $member_goods_log = Dever::db('agent/member_goods_log')->getOne(array('type'=>$v['type'],'type_id'=>$v['type_id'],'sku_id'=>$v['sku_id'],'state'=>1));
+	            if($member_goods_log && $member_goods_log['desc']){
+	                $desc = $member_goods_log['desc'];
+	            }
+	            $dh_order_ps = Dever::db('agent/dh_order_ps')->getDui($v['mid']);
+	            if ($dh_order_ps) {
+	            	$type = '兑换权益';
+	            }
+	            if ($where['types'] == 2) {
+	            	if (!$dh_order_ps) {
+	            		$file = '代理商权益明细';
+        				return Dever::excelExport($body, $header, $file);
+	            	}
+	            }
+	            
+	           
+	            $shop_name = '';
+	            $shop_type = '';
+	            $shop_sid = '';
+	            $order_num = '';
+	            if (isset($where['shop_id']) && $where['shop_id']) {
+	            	// print_R($where['shop_id']);die;
+	            	$where['types'] = 3;
+	            	$sell_order = Dever::db('shop/sell_order')->find(array('shop_id'=>$where['shop_id']));
+	            	if ($sell_order) {
+	            		$w = $this->common($sell_order);
+	            		$type = '使用权益';
+	            		if ($w) {
+	            			$shop_name = $w['shop_name'];
+					        $shop_type = $w['shop_type'];
+					        $shop_sid = $w['shop_sid'];
+					        $order_num = $w['order_num'];
+	            			$d = array
+				                (
+				                	$cdate,
+				                	$v['name'],
+				                	$role_name,
+				                	$member_name,
+				                	$member_mobile,
+				                	$card,
+				                	$type,
+				                	$v['total_num'],
+				                	$v['price'],
+						            $v['cash'],
+						            $shop_type,
+						            $shop_sid,
+						            $shop_name,
+						            $order_num,
+						            $desc,
+					            	'',
+					            	date('Y-m-d H:i',$v['cdate']),
+					                $member_cdate,
+					                $youxiao,
+				                );
+				               	$body[] = $d;
+	            		}
+	            		$file = '代理商权益明细';
+	            		 return Dever::excelExport($body, $header, $file);
+	            	}
+	            	
+	            } else {
+	            	$sell_order = Dever::db('shop/sell_order')->find(array('card_code_id'=>$v['sku_id']));
+	            }
+                
+                if ($where['types'] == 3) {
+                	if (!$sell_order) {
+                		$file = '代理商权益明细';
+        				return Dever::excelExport($body, $header, $file);
+                	} 
+                } 
+                if ($sell_order) {
+                	$type = '使用权益';
+                	$w = $this->common($sell_order);
+                	if ($w) {
+                		$shop_name = $w['shop_name'];
+				        $shop_type = $w['shop_type'];
+				        $shop_sid = $w['shop_sid'];
+				        $order_num = $w['order_num'];
+                	}
+                }
+                $d = array
+                (
+                	$cdate,
+                	$v['name'],
+                	$role_name,
+                	$member_name,
+                	$member_mobile,
+                	$card,
+                	$type,
+                	$v['total_num'],
+                	$v['price'],
+		            $v['cash'],
+		            $shop_type,
+		            $shop_sid,
+		            $shop_name,
+		            $order_num,
+		            $desc,
+	            	'',
+	            	date('Y-m-d H:i',$v['cdate']),
+	                $member_cdate,
+	                $youxiao,
+                );
+               	$body[] = $d;
+			}
+			$file = '代理商权益明细';
+				// Dever::input('excel_name');
+        	return Dever::excelExport($body, $header, $file);
+		}
+	}
+	public function common($sell_order)
+	{
+		$w = array();
+		$w['order_num'] = $sell_order['order_num'];
+    	$shop = Dever::db('shop/info')->find($sell_order['shop_id']);
+    	if ($shop) {
+    		$w['shop_name'] = $shop['name'];
+    		$w['shop_sid'] = $shop['sid'];
+    		if ($shop['type'] = 1) {
+    			$w['shop_type'] = '体验店';
+    		} elseif ($shop['type'] = 2) {
+    			$w['shop_type'] = '零售店';
+    		} elseif ($shop['type'] = 10) {
+    			$w['shop_type'] = '平台商城';
+    		}
+    	}
+    	return $w;
+	}
+}