Your Name 2 years ago
parent
commit
0c5946d169
1 changed files with 28 additions and 9 deletions
  1. 28 9
      tool/stats/lib/Manage.php

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

@@ -47,7 +47,7 @@ Class Manage
 	}
 	public function list_api()
 	{
-		$header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额', '代理优惠金额', '商品实付金额', '礼品卡金额', '钱包金额','商品支付金额', '礼品卡名称', '礼品卡卡号', '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '礼品卡金额', '钱包金额', '优惠券金额', '代理优惠金额', '订单状态', '退款状态', '退款时间', '退款金额', '收件人', '收件人手机', '收件人地址');
+		$header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额', '代理优惠金额', '商品实付金额', '礼品卡金额', '钱包金额','商品支付金额', '礼品卡名称', '礼品卡卡号', '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '礼品卡金额', '钱包金额', '优惠券金额', '代理优惠金额', '订单状态', '退款状态', '退款时间', '退款金额','退卡金额','退现金金额', '收件人', '收件人手机', '收件人地址');
 
 		$body = array();
 		$status = Dever::db('shop/sell_order')->config['status_manage'];
@@ -169,10 +169,21 @@ Class Manage
 	                } else {
 	                	$total_cash = 0;
 	                }
-
+	                $ka = 0;
+	                $money = 0;
 	                 if ($v['status'] == 8 || $v1['status'] == 3) {
 	                    $num = $v1['num'];
-	                    $v['refund_cash'] = $v1['price']*$v1['num'];
+	                    $refund_cash = $v1['price']*$v1['num'];
+	                    if ($v['card_code_cash'] >0) {
+	                    	if ($v['refund_cash'] <= $v['card_code_cash']) {
+	                    		$ka = $v['refund_cash'];
+	                    	} else {
+	                    		$ka = $v['card_code_cash'];
+	                    		$money = $v['refund_cash'] - $v['card_code_cash'];
+	                    	}
+	                    }
+	                    // $refund = Dever::db('shop/sell_order_refund')->find(array('order_id'=>$v['id']));
+	                    // if ($refund)
 	                    $refund_status = '已退款';
 	                    $refund_cdate = '';
 	                    if ($v['shop_type'] == 1) {
@@ -185,7 +196,7 @@ Class Manage
 	                } else {
 	                	$refund_cdate = '';
 	                    $num = '0';
-	                    $v['refund_cash'] = '0';
+	                    $refund_cash = '0';
 	                    $refund_status = '未退款';
 	                }
 	                if ($v['status'] >=7) {
@@ -199,6 +210,8 @@ Class Manage
 	                    $v['wallet_cash'] = $v['wallet_cash'];
 	                    $v['coupon_cash'] = $v['coupon_cash'];
 	                    $v['discount_cash'] = $v['discount_cash'];
+	                    $ka = $ka;
+	                    $money = $money;
 	                } else {
 	                    $v['num'] = 0;
 	                    $v['card_code_cash'] = 0;
@@ -206,6 +219,8 @@ Class Manage
 	                    $v['wallet_cash'] = 0;
 	                    $v['coupon_cash'] = 0;
 	                    $v['discount_cash'] = 0;
+	                    $ka = 0;
+	                    $money = 0;
 	                }
 	                // print_R($total_cash);die;
 	                $d = array
@@ -228,7 +243,7 @@ Class Manage
 						$wallet_cash,
 						$price,
 						$v['card'],
-						$v['card_code'],
+						$v['card_code']."\t",
 						$zhuce,
 						$cdate,
 						$paydate,
@@ -244,13 +259,15 @@ Class Manage
 	                    $status[$v['status']],
 	                    $refund_status,
 	                    $refund_cdate,
-	                    round($v['refund_cash'], 2),
+	                    round($refund_cash, 2),
+	                    round($ka,2),
+	                    round($money,2),
 	                    $address_contact,
 	                    $address_mobile,
 	                    $address_info,
                     );
 					
-					$body[] = $d;
+					// $body[] = $d;
 					if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) {
                     
 	                    foreach ($goods_info['goods'] as $k2 => $v2) {
@@ -283,7 +300,7 @@ Class Manage
 								$wallet_cash,
 								$price,
 								$v['card'],
-								$v['card_code'],
+								$v['card_code']."\t",
 								$zhuce,
 								$cdate,
 								$paydate,
@@ -305,11 +322,13 @@ Class Manage
 			                    $address_info,
 							);
 
-	                        $body[] = $d;
+	                        
 	                    }
 	                }
 				}
+				$body[] = $d;
 			}
+			
 		}
 		$file = '商品销售相关数据';
     	return Dever::excelExport($body, $header, $file);