Your Name пре 2 година
родитељ
комит
4f1ef707d7
3 измењених фајлова са 127 додато и 35 уклоњено
  1. 1 1
      app/shop/database/buy_order.php
  2. 20 8
      tool/stats/assets/pc/html/out.html
  3. 106 26
      tool/stats/lib/Manage.php

+ 1 - 1
app/shop/database/buy_order.php

@@ -1004,7 +1004,7 @@ $config = array
                 'name' => 'yes',
                 'order_num' => 'yes',
                 'state' => 1,
-                'parent_type' => 3,
+                'parent_type' => array('yes','in'),
             ),
             'type' => 'all',
             'page' => array(20,'list'),

+ 20 - 8
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,17 +144,22 @@ a{
 	     <br/>
 	     <a href="javascript:;" class="layui-btn" id="search">数据导出</a>
 	     </blockquote>
-       <div><h3>厨人意料管理平台-代理商兑换订单</h3></div>
+       <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="订单号">
+       <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/>下单时间: -->
-       <input type="text" value="" autocomplete="order" id="ddate" class="layui-input" style="width: auto;display: inline;" placeholder="下单时间">
+       <input type="text" value="" autocomplete="dorder" 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="dfa" 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="完成时间">
+       <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>
@@ -295,10 +306,11 @@ function duihuan()
     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 + '&list_excel=1';
+  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() {

+ 106 - 26
tool/stats/lib/Manage.php

@@ -240,7 +240,7 @@ 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,$v1['num']);
@@ -248,8 +248,9 @@ Class Manage
 						foreach ($goods_info['goods'] as $key => $val) {
 
 							$dnum = round($val['num']*$v1['num'],2);
-							// $bili = round($val['price']*$dnum /$heji,2);#比例
-							// $price_money = $val['price']*$dnum*$v['discount_cash'];#支付
+							$bili = round($val['price']*$dnum /$heji,2);#比例
+							// print_R($bili);die;
+							$price_money = $val['price']*$dnum*$v['discount_cash'];#支付
 							// if ($v['discount_id']>0) {
 							// 	$youhui = round($val['price']*$dnum-$price_money,2);
 							// } else {
@@ -263,19 +264,47 @@ Class Manage
 							
 							// // 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'];
-							}
+							// $youhui = 0;
+							// print_R($v1);die;
 							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) {
+							$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);
+								}
+								
+							} 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'];#订单总数量
@@ -316,7 +345,7 @@ Class Manage
 								$goodsfu,
 								$card_price,
 								$wallet_price,
-								$goodsfu,//$price,//$price_money,
+								$price,//$price,//$price_money,
 
 								$v['card'],
 								$v['card_code_card']."\t",
@@ -349,7 +378,7 @@ Class Manage
 							$body[] = $d;
 						}
 					} else {
-						if ($k1 == 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);
@@ -368,10 +397,7 @@ Class Manage
 							$oprice = 0;
 							$coupon_cash = 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;
@@ -400,7 +426,7 @@ Class Manage
 							$dgoodsfu,
 							$dcard_price,
 							$dwallet_price,
-							$dgoodsfu,//$zhifu,
+							$zhifu,//$dgoodsfu,//
 
 							$v['card'],
 							$v['card_code_card']."\t",
@@ -445,6 +471,7 @@ Class Manage
 		$file = '商品销售相关数据';
         return Dever::excelExport($body, $header, $file);
 	}
+	
 	public function total($goods,$num){
 		if ($goods) {
 			$price = 0;
@@ -465,6 +492,7 @@ Class Manage
 		$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);
 		}
@@ -483,6 +511,11 @@ Class Manage
 		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;
@@ -498,17 +531,14 @@ Class Manage
 			$where['order_num'] = $order_num;
 		}
 		$where['state'] = 1;
-		// print_R($where);die;
 		$data = Dever::db('shop/buy_order')->getDui($where);
-		$header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额',  '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '订单状态',  '收件人', '收件人手机', '收件人地址');
+		$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 = '平台商城';
 				}
@@ -516,8 +546,23 @@ Class Manage
 				$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']) {
+				$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) {
@@ -530,6 +575,10 @@ Class Manage
 	        				}
 	        			}
                 	}
+                } 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'];
@@ -552,7 +601,33 @@ Class Manage
 	                if ($v['fdate']) {
 	                	$fdate = date('Y-m-d H:i',$v['fdate']);
 	                }
-        			// print_R($v1);die;
+	                
+	                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['goods_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,
@@ -575,10 +650,15 @@ Class Manage
 						$fadate,
 						$fdate,
 
-						$v['num'],
-						round($v['price'],2),
-						0,
+						$num,
+						$order_price,
+						$shifu,
+						$record_cash,
 						$goods_status[$v1['status']],
+						$refund_status,
+						$refund_cdate,
+						$refund_cash,
+
 
 
 						$address_contact,