{js:my97date}
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="home-icon fa fa-home"></i>
			<a href="#">统计</a>
		</li>
		<li>
			<a href="#">商户数据统计</a>
		</li>
		<li class="active">待结算货款</li>
	</ul>
</div>

<div class="content">
	<table class="table list-table">
		<colgroup>
			<col width="30px" />
			<col  />
			<col width="80px" />
			<col width="120px" />
			<col width="120px" />
			<col width="120px" />
			{if:class_exists("commission")}
			<col width="120px" />
			{/if}
			<col width="120px" />
			<col width="80px" />
			<col width="100px" />
			<col width="80px" />
		</colgroup>

		<caption>
			<a class="btn btn-default" onclick="selectAll('seller_id[]')">
			    <i class="fa fa-check"></i>全选
			</a>

			 <div class="btn-group">
				<button type="button" class="btn btn-default"><i class="fa fa-jpy"></i>货款结算</button>
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                    <span class="caret"></span>
                    <span class="sr-only"></span>
                </button>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="javascript:confirm('直接转账给商家绑定的微信么？',function(){payCountFee('wechatBalance')});"><i class="fa fa-weixin"></i>微信转账</a></li>
                    <li><a href="javascript:confirm('已经通过人工线下结算货款么？',function(){payCountFee('offline')});"><i class="fa fa-money"></i>人工线下</a></li>
                </ul>
            </div>
		</caption>

		<thead>
			<tr>
				<th></th>
				<th>商户</th>
				<th>订单量</th>
				<th>订单完成额</th>
				<th>平台促销额</th>
				<th>平台手续费</th>
				{if:class_exists("commission")}
				<th>分销佣金额</th>
				{/if}
				<th>应结算金额</th>
				<th>微信绑定</th>
				<th>微信实名</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody>
			{foreach:items=$this->data key=$seller_id}
			{set:$sellerRow = Api::run('getSellerInfo',$seller_id)}
			<tr>
				<td><input name="seller_id[]" type="checkbox" value="{$seller_id}" /></td>
				<td>{$sellerRow['true_name']}</td>
				<td>{$item['orderNum']}单</td>
				<td>￥{echo:$item['orderAmountPrice'] - $item['refundFee']}</td>
				<td>￥{$item['platformFee']}</td>
				<td>￥{$item['commission']}</td>
				{if:class_exists("commission")}
				<td>￥{$item['commissionFee']}</td>
				{/if}
				<td>￥{$item['countFee']}</td>
				<td>{if:class_exists("wechat")}{echo:wechat::getOpenidBySeller($seller_id,'openid')?'已绑定':'未绑定'}{/if}</td>
				<td>{$sellerRow['account']}</td>
				<td>
					<a href="javascript:seeMore({$seller_id});" title="查看明细">
						<i class='operator fa fa-list'></i>
					</a>
				</td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>

<script>
//支付转账
function payCountFee(type)
{
	var seller_ids = [];
	$('[name="seller_id[]"]:checked').each(function()
	{
		seller_ids.push(this.value);
	});

	if(seller_ids.length == 0)
	{
		alert('请选择要结算的商家');
		return;
	}

	loadding('处理中...');

	$.get("{url:/market/pay_countfee}",{"seller_ids[]":seller_ids,"type":type},function(text)
	{
		unloadding();
		art.dialog.alert(text,function()
		{
			window.setTimeout(function(){window.location.reload();});
		});
	});
}

//跳转订单明细
function seeMore(seller_id)
{
	var searchUrl = "{url:/market/order_goods_list?search[seller_id]=@seller_id@&search[is_checkout]=0}";
	window.location.href=searchUrl.replace("@seller_id@",seller_id);
}
</script>