Browse Source

Merge branch 'master' of ssh://git.dever.cc:10022/dever-product/churen

rabin 2 years ago
parent
commit
1ce38b363d

+ 2 - 2
app/card/lib/Manage.php

@@ -118,8 +118,8 @@ class Manage
             $info['use_cash'] = 0;
         }
         $table['总面值'] = $info['total_cash'];
-        $table['已用面值'] = $info['use_cash'];
-        $table['剩余面值'] = $info['total_cash'] - $info['use_cash'];
+        $table['已用面值'] = round($info['use_cash'],2);
+        $table['剩余面值'] = round(($info['total_cash'] - $info['use_cash']),2);
 
         if ($table) {
             return Dever::table($table);

+ 23 - 0
app/shop/database/buy_order.php

@@ -987,6 +987,29 @@ $config = array
             'type' => 'all',
             'col' => '*',
         ),
+        'getDui' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'fstart' => array('yes-fdate', '>='),
+                'fend' => array('yes-fdate', '<='),
+                'fastart' => array('yes-cdate', '>='),
+                'faend' => array('yes-cdate', '<='),
+                'type' => 1,
+                'type_id' => array('yes', 'in'),
+                'status' => array('yes', 'in'),
+                'name' => 'yes',
+                'order_num' => 'yes',
+                'state' => 1,
+                'parent_type' => array('yes','in'),
+            ),
+            'type' => 'all',
+            'page' => array(20,'list'),
+            'col' => '*',
+        ),
     ),
 );
 

+ 3 - 2
app/shop/database/info.php

@@ -74,7 +74,8 @@ $method = array
 $stat_type = Dever::db('cash/shop')->config['config_type'];
 $add = false;
 //$add = array('银联签约','"sign&search_option_shop_id={id}&oper_table=info&where_id={id}"', '"{mid}" == ""');
-
+$excel = false;
+$excel[] = array('导出数据', '导出门店列表', 'shop/excel.shop_info');
 return array
 (
     # 表名
@@ -711,7 +712,7 @@ return array
     (
         //'mul' => true,
         //'insert' => false,
-        'excel' => true,
+        'excel' => $excel,
         'list_button' => array
         (
             'delete' => '删除',

+ 50 - 0
app/shop/src/Excel.php

@@ -1009,4 +1009,54 @@ class Excel
 
         return Dever::excelExport($body, $header, $file);
     }
+    #门店列表数据导出
+    public function shop_info ($data)
+    {
+        $header = array('店铺id', '店铺编号-一般为5位数字,不能重复', '门店名称', '联系人姓名', '联系人电话', '营业状态', '门店类型-自营为平台店,当没有找到加盟店时,将自动获取平台店', '合作状态', '所属代理商名称', '所属代理商手机号', '分账商户号','录入时间');
+        $body = array();
+        if ($data) {
+            $type = Dever::db('shop/info')->config['config_type'];
+            foreach ($data as $k => $v) {
+                if ($v['open'] == 1) {
+                    $open = '开启';
+                } else {
+                    $open = '关闭';
+                }
+                if ($v['status'] == 1) {
+                    $status = '合作中';
+                } else {
+                    $status = '已终止合作';
+                }
+                $member_name = '';
+                $member_mobile = '';
+                if ($v['agent_mid'] && $v['agent_mid']>0) {
+                    $member = Dever::db('agent/member')->find($v['agent_mid']);
+                    if ($member) {
+                         $member_name = $member['name'];
+                         $member_mobile = $member['mobile'];
+                    }
+                }
+                $d = array
+                (
+                    $v['id'],
+                    $v['sid'],
+                    $v['name'],
+                    $v['truename'],
+                    $v['mobile'],
+                    $open,
+                    $type[$v['type']],
+                    $status,
+                    $member_name,
+                    $member_mobile,
+                    $v['mid'],
+                    date('Y-m-d H:i',$v['cdate']),
+                );
+                $body[] = $d;
+            }
+        } else {
+            Dever::alert('无导出数据');
+        }
+        $file = Dever::input('excel_name');
+        return Dever::excelExport($body, $header, $file);
+    }
 }

+ 7 - 7
service/agent/lib/Agreement.php

@@ -439,7 +439,7 @@ class Agreement
             $temp = explode('?', $info['sign']);
             $info['sign'] = $temp[0];
         	if (strstr($info['sign'], 'http')) {
-        		$pdf->Image($info['sign'], $x, $y, 20, 20);
+        		$pdf->Image($info['sign'], $x, $y, 50, 50);
         	}
         }
 
@@ -742,7 +742,7 @@ class Agreement
         $x = $cx + 50;
         $y = $cy - 25;
 
-        $pdf->Image($pic, $x, $y, 15, 15);
+        $pdf->Image($pic, $x, $y, 50, 50);
 
         $x += 100;
 
@@ -751,7 +751,7 @@ class Agreement
             $temp = explode('?', $info['sign']);
             $info['sign'] = $temp[0];
         	if (strstr($info['sign'], 'http')) {
-        		$pdf->Image($info['sign'], $x, $y, 15, 15);
+        		$pdf->Image($info['sign'], $x, $y, 50, 50);
         	}
         }
 
@@ -1219,7 +1219,7 @@ class Agreement
         $x = $cx + 48;
         $y = $cy - 42;
 
-        $pdf->Image($pic, $x, $y, 30, 30);
+        $pdf->Image($pic, $x, $y, 50, 50);
 
         $x += 100;
 
@@ -1228,7 +1228,7 @@ class Agreement
             $temp = explode('?', $info['sign']);
             $info['sign'] = $temp[0];
         	if (strstr($info['sign'], 'http')) {
-        		$pdf->Image($info['sign'], $x, $y, 30, 30);
+        		$pdf->Image($info['sign'], $x, $y, 50, 50);
         	}
         }
 
@@ -1660,7 +1660,7 @@ class Agreement
         $x = $cx + 50;
         $y = $cy - 50;
 
-        $pdf->Image($pic, $x, $y, 30, 30);
+        $pdf->Image($pic, $x, $y, 50, 50);
 
         $x += 20;
         $y -= 48;
@@ -1670,7 +1670,7 @@ class Agreement
             $temp = explode('?', $info['sign']);
             $info['sign'] = $temp[0];
             if (strstr($info['sign'], 'http')) {
-                $pdf->Image($info['sign'], $x, $y, 30, 30);
+                $pdf->Image($info['sign'], $x, $y, 50, 50);
             }
         }
 

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

@@ -94,6 +94,12 @@ h3{
 	border-radius:2px;
 	line-height: 1.3;
 }
+.dcate{
+  height:38px;
+  border-width: 1px;
+  border-radius:2px;
+  line-height: 1.3;
+}
 .type{
 	height:38px;
 	border-width: 1px;
@@ -138,12 +144,34 @@ a{
 	     <br/>
 	     <a href="javascript:;" class="layui-btn" id="search">数据导出</a>
 	     </blockquote>
+       <div><h3>厨人意料管理平台-代理商采购订单</h3></div>
+       <blockquote class="layui-elem-quote">
+       <select class = 'dcate'>
+        <option class = 'dcate' value="-1">选择类型</option>
+          <option class = 'dcate' value="1">采购单</option>
+          <option  class = 'dcate' value="2">商品兑换</option>
+      </select>
+      <input type="text" value="" autocomplete="dshop_name" id="dshop_name" class="layui-input" style="width: auto;display: inline;" placeholder="门店名称">
+      <input type="text" value="" autocomplete="dgoods_name" id="dgoods_name" class="layui-input" style="width: auto;display: inline;" placeholder="商品名称">
+      <input type="text" value="" autocomplete="dorder_num" id="dorder_num" class="layui-input" style="width: auto;display: inline;" placeholder="订单号">
+      <br/>
+       <!-- <br/>下单时间: -->
+       <input type="text" value="" autocomplete="dorder" id="ddate" class="layui-input" style="width: auto;display: inline;" placeholder="下单时间">
+      <!--  发货时间: -->
+       <input type="text" value="" autocomplete="dfa" id="dfa" class="layui-input" style="width: auto;display: inline;" placeholder="发货时间">
+       <!-- 完成时间: -->
+       <input type="text" value="" autocomplete="dfinish" id="dfi" class="layui-input" style="width: auto;display: inline;" placeholder="完成时间">
+      
+       <br/>
+       <a href="javascript:;" class="layui-btn" id="duihuan">数据导出</a>
+       </blockquote>
 	     <div  class="biaoti"><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="卡号">
+        <br/>
     		<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="礼品卡有效期">
@@ -189,6 +217,18 @@ layui.use(['form','element', 'layer', 'jquery', 'laydate'], function(){
     elem: '#fi',
     range: '~'
   });
+  laydate.render({
+    elem: '#ddate',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#dfa',
+    range: '~'
+  });
+  laydate.render({
+    elem: '#dfi',
+    range: '~'
+  });
   laydate.render({
     elem: '#getday',
     range: '~'
@@ -242,6 +282,42 @@ function search()
 $('#search').click(function() {
   search();
 })
+function duihuan()
+{
+  var date = $('#ddate').val();
+  var fa = $('#dfa').val();
+  var fi = $('#dfi').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] = '';
+  }
+  dcate = $('.dcate').val();
+  dorder_num = $('#dorder_num').val();
+  dgoods_name = $('#dgoods_name').val();
+  dshop_name = $('#dshop_name').val();
+  var link = config.host + 'lib/manage.duihuan&start=' + s[0] + '&end=' + s[1] + '&fastart=' + a[0] + '&faend=' + a[1] + '&fstart=' + f[0] + '&fend=' + f[1] + '&order_num=' + dorder_num + '&shop_name=' + dshop_name + '&goods_name=' + dgoods_name + '&cate=' + dcate + '&list_excel=1';
+  jump(link);
+}
+$('#duihuan').click(function() {
+  duihuan();
+})
 function out()
 {
   var getday = $('#getday').val();

+ 286 - 28
tool/stats/lib/Manage.php

@@ -240,26 +240,72 @@ Class Manage
 		            	}
 		            }
 		            // print_R($goods);die;
-		            // print_R($goods_info);
+		            // print_R($goods_info);die;
 	                if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) {
 	                	$heji = 0;
-	                	$heji = $this->total($goods);
-	                	// print_R($heji);die;
+	                	$heji = $this->total($goods,$v1['num']);
+	                	// print_R($v);die;
 						foreach ($goods_info['goods'] as $key => $val) {
-							// $val['price']-($val['price']*)
-							$youhui = ($val['price']*($val['num']+$v1['num'])-($val['price']*($val['num']+$v1['num'])/$heji)*$v['price'])*$v1['num'];
-							$card_price = ($v['card_code_cash']/$heji*($val['price']*($val['num']+$v1['num'])))*$v1['num'];
-							$wallet_price = ($v['wallet_cash']/$heji*($val['price']*($val['num']+$v1['num'])))*$v1['num'];
-							$goodsfu = $val['price']*($val['num']+$v1['num'])-$youhui-$card_price-$wallet_price;
-							if ($key == 0) {
-								$price = round($v1['price']*$v1['num']-$v1['discount_cash'],2);
+
+							$dnum = round($val['num']*$v1['num'],2);
+							$bili = round($val['price']*$dnum /$heji,2);#比例
+							// print_R($bili);die;
+							$price_money = $val['price']*$dnum*$v['discount_cash'];#支付
+							
+							if ($v['card_code_cash'] && $v['card_code_cash']>0){
+								$card_price = round(($v['card_code_cash']/$v['oprice']*($val['price']*$dnum)),2);
+							} else {
+								$card_price = 0;
+							}
+							$wallet_price = round(($v['wallet_cash']/$v['oprice']*($val['price']*$dnum)),2);
+							$goodsfu = 0;
+							if ($v1['discount_id']<=0) {
+								$youhui = 0;
+								if ($card_price + $wallet_price >=$val['price']*$dnum){
+									$goodsfu = 0;
+								} elseif ($card_price + $wallet_price ==0) {
+									$goodsfu = round($val['price']*$dnum,2);
+								} else {
+									$goodsfu = round($val['price']*$dnum-($card_price + $wallet_price),2);
+								}
+								// print_R($card_price);die;
+								
+							} else {
+								$act = Dever::db('act/discount')->find($v['discount_id']);
+								if ($act && $act['num']) {
+									$act_num = $act['num']/10;
+								}
+								if ($card_price + $wallet_price == 0) {
+									$goodsfu = round($val['price']*$dnum*$act_num,2);
+									$youhui = round($val['price']*$dnum-$goodsfu);
+								} elseif ($card_price + $wallet_price >=$val['price']*$dnum) {
+									$goodsfu = 0;
+									$youhui = round($val['price']*$dnum-$goodsfu-($card_price + $wallet_price),2);
+								} else {
+									$goodsfu = round($val['price']*$dnum-($card_price + $wallet_price),2);
+									$youhui = round($val['price']*$dnum-$goodsfu,2);
+								}
+								
+
+								// $youhui = ($val['price']*$dnum-($val['price']*$dnum/$heji)*$v1['price'])*$v1['num'];
+							}
+							
+							// $goodsfu = $val['price']*$dnum-$youhui-$card_price-$wallet_price;
+							if ($key == 0 && $k1 ==0) {
+								$price = $v['price'];//round($v1['price']*$v1['num']-$v1['discount_cash'],2);
 								$shifu = round($v['price'],2);//实付金额
 								$order_num = $v1['num'];#订单总数量
-								$oprice = round($v1['price']*$v1['num'],2);#订单总金额
+								$oprice = $v['oprice'];//round($v1['price']*$v1['num'],2);#订单总金额
 								$coupon_cash = round($v1['coupon_cash'],2);
 								$discount_cash = round($v1['discount_cash'],2);
 								$card_code_cash = round($v['card_code_cash'],2);
 								$wallet_cash = round($v['wallet_cash'],2);
+								if ($v['status'] == 8) {
+									$refund_cash = $refund_cash;
+									$ka = $ka;
+									$money = 0;
+								}
+
 							} else {
 								$price = 0;
 								$shifu = 0;
@@ -269,12 +315,13 @@ Class Manage
 								$discount_cash = 0;
 								$card_code_cash = 0;
 								$wallet_cash = 0;
+								if ($v['status'] == 8) {
+									$refund_cash = 0;
+									$ka = 0;
+									$money = 0;
+								}
 							}
-							if($v1['num']>1)  {
-								$dnum = round($val['num']+$v1['num'],2);
-							} else {
-								$dnum = round($val['num'],2);
-							}
+							
 
 							$d = array
 							(
@@ -290,12 +337,12 @@ Class Manage
 
 								round($val['price'],2),
 								$dnum,
-								round(($val['price']*($val['num']+$v1['num'])),2),
+								round(($val['price']*$dnum),2),
 								round($youhui,2),
 								$goodsfu,
 								$card_price,
 								$wallet_price,
-								$price,
+								$price,//$price,//$price_money,
 
 								$v['card'],
 								$v['card_code_card']."\t",
@@ -328,7 +375,17 @@ Class Manage
 							$body[] = $d;
 						}
 					} else {
-						if ($k1 == 0) {
+						if ($ka > 0 || $money > 0) {
+							$st = Dever::db('shop/sell_order_goods')->find(Array('order_id'=>$v['id'],'status'=>3));
+							if ($v1['goods_id'] == $st['goods_id']) {
+								$ka = round($ka,2);
+								$money = round($money,2);
+							} else {
+								$ka = 0;
+								$money = 0;
+							}
+						} 
+						if ($k1 == 0 ) {
 							$discount_cash = round($v['discount_cash'],2);
 							$card_code_cash = round($v['card_code_cash'],2);
 							$wallet_cash = round($v['wallet_cash'],2);
@@ -337,6 +394,8 @@ Class Manage
 							$order_num = $v['num'];//订单总数量
 							$oprice = round($v['oprice'],2);#订单总金额
 							$coupon_cash = round($v['coupon_cash'],2);
+							// $ka = round($ka,2);
+							// $money = round($money,2);
 						} else {
 							$discount_cash = 0;
 							$card_code_cash = 0;
@@ -346,17 +405,19 @@ Class Manage
 							$order_num = 0;
 							$oprice = 0;
 							$coupon_cash = 0;
+							// $ka = 0;
+							// $money = 0;
 						}
-						// print_R($v1['price']*$v1['num']/$v['oprice']*$v['price']);die;
 						$dyouhui = round($v1['discount_cash'],2);
-						// ($v1['price']*$v1['num']/$v['oprice']*$v['price']);
-						// print_R($dyouhui);die;
 						$dcard_price = $v['card_code_cash']/$v['oprice']*($v1['price']*$v1['num']);
 						$dwallet_price = $v['wallet_cash']/$v['oprice']*($v1['price']*$v1['num']);
 						$dgoodsfu = $v1['price']*$v1['num']-$dyouhui-$dcard_price-$dwallet_price;
+						// print_R($v1);die;
+						// $dpaymoney = round($v1['price']/$v['oprice']*$v1['price']*$v1['num'],2);
 						if ($dgoodsfu<0){
 							$dgoodsfu = 0;
 						}
+						// print_R($ka);
 						$d = array
 						(
 							$shop_type,
@@ -372,11 +433,12 @@ Class Manage
 							round($v1['price'],2),
 							round($v1['num'],2),
 							round(($v1['price']*$v1['num']),2),
+
 							round($dyouhui,2),
 							$dgoodsfu,
 							$dcard_price,
 							$dwallet_price,
-							$zhifu,
+							$zhifu,//$dgoodsfu,//
 
 							$v['card'],
 							$v['card_code_card']."\t",
@@ -399,8 +461,8 @@ Class Manage
 		                    $refund_cdate,
 
 		                    round($refund_cash, 2),
-		                    round($ka,2),
-		                    round($money,2),
+		                    $ka,
+		                    $money,
 
 		                    $address_contact,
 		                    $address_mobile,
@@ -421,16 +483,212 @@ Class Manage
 		$file = '商品销售相关数据';
         return Dever::excelExport($body, $header, $file);
 	}
-	public function total($goods){
-		// print_R($goods);die;
+	
+	public function total($goods,$num){
 		if ($goods) {
 			$price = 0;
 			foreach ($goods as $k => $v) {
-				$price += $v['price'] * $v['num'];
+				$price += $v['price'] * $v['num']*$num;
 			}
 			return $price;
 		}
 	}
+	public function duihuan_api()
+	{
+		$start = Dever::input('start');
+		$end = Dever::input('end');
+		$fastart = Dever::input('fastart');
+		$faend = Dever::input('faend');
+		$fstart = Dever::input('fstart');
+		$fend = Dever::input('fend');
+		$name = Dever::input('goods_name');
+		$shop_name = Dever::input('shop_name');
+		$order_num = Dever::input('order_num');
+		$parent_type = Dever::input('cate');
+		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 ($parent_type && $parent_type>0) {
+			$where['parent_type'] = $parent_type;
+		} else {
+			$where['parent_type'] = '1,3';
+		}
+		
+		if ($name) {
+			$where['name'] = $name;
+		}
+		if ($shop_name) {
+			$where['type'] = 1;
+			$shop = Dever::db('shop/info')->find(array('name'=>$name));
+			if ($shop) {
+				$where['type_id'] = $shop['id'];
+			}
+		}
+		if ($order_num) {
+			$where['order_num'] = $order_num;
+		}
+		$where['state'] = 1;
+		$data = Dever::db('shop/buy_order')->getDui($where);
+		$header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额',  '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '资金账户抵扣金额', '订单状态',  '退款状态', '退款时间', '退款金额',  '收件人', '收件人手机', '收件人地址');
+		$body = array();
+		if ($data) {
+			foreach($data as $k => $v){
+				$shop = Dever::db('shop/info')->find($v['type_id']);
+				if ($shop['type'] ==1) {
+					$shop_type = '体验店';
+				} elseif ($shop['type'] ==10) {
+					$shop_type = '平台商城';
+				}
+				$zhuce = '';
+				$address_contact = '';
+				$address_mobile = '';
+				$address_info = '';
+				$shifu = 0;
+				if ($v['parent_type'] == 3) {
+					$parent_order = Dever::db('agent/dh_order')->find($v['parent_order_id']);
+					$shifu = 0;
+					$record_cash = 0;
+				} else {
+					$shifu = round($v['price'],2);
+					$record_cash = round($v['record_cash'],2);
+				}
+				if ($v['type'] == 1) {
+		            $type_info = Dever::db('shop/info')->find($v['type_id']);
+		        } elseif ($info['type'] == 2) {
+		            $type_info = Dever::db('store/info')->find($v['type_id']);
+		        } elseif ($info['type'] == 3) {
+		            $type_info = Dever::db('store/info')->find($v['type_id']);
+		        }
+				if (isset($parent_order) && $parent_order && isset($parent_order['uid']) && $parent_order['uid']) {
+            		if ($parent_order['address_id']) {
+                		$address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['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']);
+	        				}
+	        			}
+                	}
+                } elseif (isset($type_info) && $type_info) {
+                	$address_contact = $type_info['truename'];
+                	$address_mobile = $type_info['mobile'];
+	        		$address_info = $type_info['address'];
+                }
+				$goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
+        		$goods_status = Dever::db('shop/buy_order_goods')->config['status'];
+        		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 = '';
+	                }
+	                if ($v['cdate']) {
+	                	$cdate = date('Y-m-d H:i',$v['cdate']);
+						
+	                }
+	                $fadate = '';
+	                if ($v['fadate']) {
+	                	$fadate = date('Y-m-d H:i',$v['fadate']);
+	                }
+	                $fdate = '';
+	                if ($v['fdate']) {
+	                	$fdate = date('Y-m-d H:i',$v['fdate']);
+	                }
+	                
+	                if ($v1['status'] == 1) {
+	                	$refund_status = '正常';
+	                } elseif ($v1['status'] == 2) {
+	                	$refund_status = '已申报';
+	                } elseif ($v1['status'] == 3) {
+	                	$refund_status = '已退款';
+	                }
+	                $tk = Dever::db('shop/buy_order_refund')->find(array('order_id'=>$v['id'],'order_goods_id'=>$v1['id']));
+	                $refund_cdate = '-';
+	                if ($tk) {
+	                	$refund_cdate = date('Y-m-d H:i',$tk['cdate']);
+	                }
+	                if ($k1 == 0) {
+	                	$num = $v['num'];
+	                	$order_price = round($v['price'],2);
+	                	$shifu = $shifu;
+	                	$record_cash = $record_cash;
+	                	$refund_cash = round($v['refund_cash'],2);
+	                } else {
+	                	$num = 0;
+	                	$order_price = 0;
+	                	$shifu = 0;
+	                	$record_cash = 0;
+	                	$refund_cash = 0;
+	                }
+
+        			$d = array
+					(
+						$shop_type,
+						$shop['sid'],
+						$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),
+
+						$zhuce,
+						$cdate,
+						$cdate,
+						$fadate,
+						$fdate,
+
+						$num,
+						$order_price,
+						$shifu,
+						$record_cash,
+						$goods_status[$v1['status']],
+						$refund_status,
+						$refund_cdate,
+						$refund_cash,
+
+
+
+						$address_contact,
+						$address_mobile,
+						$address_info,
+					);
+					$body[] = $d;
+        		}
+				
+			}
+		}
+		// print_R($body);die;
+		if (!$body) {
+			Dever::alert('此时段没有数据,请重新选择条件');
+		}
+		$file = '代理商兑换订单';
+        return Dever::excelExport($body, $header, $file);
+	}
 	public function memberGoods_api()
 	{
 		$name = Dever::input('name');