Your Name 2 роки тому
батько
коміт
2e32cffcfb

+ 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' => 3,
+            ),
+            'type' => 'all',
+            'page' => array(20,'list'),
+            'col' => '*',
+        ),
     ),
 );
 

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

@@ -138,6 +138,21 @@ a{
 	     <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="shop_name" id="dshop_name" class="layui-input" style="width: auto;display: inline;" placeholder="门店名称">
+      <input type="text" value="" autocomplete="goods_name" id="dgoods_name" class="layui-input" style="width: auto;display: inline;" placeholder="商品名称">
+      <input type="text" value="" autocomplete="order_num" id="dorder_num" class="layui-input" style="width: auto;display: inline;" placeholder="订单号">
+       <!-- <br/>下单时间: -->
+       <input type="text" value="" autocomplete="order" id="ddate" class="layui-input" style="width: auto;display: inline;" placeholder="下单时间">
+      <!--  发货时间: -->
+       <input type="text" value="" autocomplete="fa" id="dfa" class="layui-input" style="width: auto;display: inline;" placeholder="发货时间">
+       <!-- 完成时间: -->
+       <input type="text" value="" autocomplete="finish" 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="权益名称">
@@ -189,6 +204,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 +269,41 @@ 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] = '';
+  }
+  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 + '&list_excel=1';
+  jump(link);
+}
+$('#duihuan').click(function() {
+  duihuan();
+})
 function out()
 {
   var getday = $('#getday').val();

+ 186 - 20
tool/stats/lib/Manage.php

@@ -243,23 +243,48 @@ Class Manage
 		            // print_R($goods_info);
 	                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;
+
+							$dnum = round($val['num']*$v1['num'],2);
+							// $bili = round($val['price']*$dnum /$heji,2);#比例
+							// $price_money = $val['price']*$dnum*$v['discount_cash'];#支付
+							// if ($v['discount_id']>0) {
+							// 	$youhui = round($val['price']*$dnum-$price_money,2);
+							// } else {
+							// 	$youhui = 0;
+							// }
+							
+							
+							// $card_price = round(($v['card_code_cash']/$v['oprice']*($val['price']*$dnum *$bili)),2);
+							// // print_R($card_price);die;
+							// $wallet_price = round(($v['wallet_cash']/$heji*($val['price']*$dnum*$bili)),2);
+							
+							// // print_R($price_money);die;
+							// $goodsfu = $val['price']*$dnum-$youhui-$card_price-$wallet_price;
+							if ($v['discount_id']<=0) {
+								$youhui = 0;
+							} else {
+								$youhui = ($val['price']*$dnum-($val['price']*$dnum/$heji)*$v['price'])*$v1['num'];
+							}
+							if ($v['card_code_cash'] && $v['card_code_cash']>0){
+								$card_price = ($v['card_code_cash']/$v['oprice']*($val['price']*$dnum))*$v1['num'];
+							} else {
+								$card_price = 0;
+							}
+							$wallet_price = ($v['wallet_cash']/$v['oprice']*($val['price']*$dnum))*$v1['num'];
+							$goodsfu = $val['price']*$dnum-$youhui-$card_price-$wallet_price;
 							if ($key == 0) {
-								$price = round($v1['price']*$v1['num']-$v1['discount_cash'],2);
+								$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);
+
 							} else {
 								$price = 0;
 								$shifu = 0;
@@ -270,11 +295,7 @@ Class Manage
 								$card_code_cash = 0;
 								$wallet_cash = 0;
 							}
-							if($v1['num']>1)  {
-								$dnum = round($val['num']+$v1['num'],2);
-							} else {
-								$dnum = round($val['num'],2);
-							}
+							
 
 							$d = array
 							(
@@ -290,12 +311,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,
+								$goodsfu,//$price,//$price_money,
 
 								$v['card'],
 								$v['card_code_card']."\t",
@@ -354,6 +375,8 @@ Class Manage
 						$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;
 						}
@@ -372,11 +395,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,
+							$dgoodsfu,//$zhifu,
 
 							$v['card'],
 							$v['card_code_card']."\t",
@@ -421,16 +445,158 @@ 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');
+		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 ($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;
+		// print_R($where);die;
+		$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'] ==2) {
+					$shop_type = '零售店';
+				} elseif ($shop['type'] ==10) {
+					$shop_type = '平台商城';
+				}
+				$zhuce = '';
+				$address_contact = '';
+				$address_mobile = '';
+				$address_info = '';
+				$parent_order = Dever::db('agent/dh_order')->find($v['parent_order_id']);
+				if ($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']);
+	        				}
+	        			}
+                	}
+                }
+				$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']);
+	                }
+        			// print_R($v1);die;
+        			$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,
+
+						$v['num'],
+						round($v['price'],2),
+						0,
+						$goods_status[$v1['status']],
+
+
+						$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');