<style>
	.line_p{line-height:26px;font-size:13px;margin-top:5px;}
</style>
<form class="form-horizontal form-validate" action="{:U('order/oprefund_do')}" method="post" enctype="multipart/form-data">
	<input type='hidden' name='id' value='{$id}' />

	<div class="modal-dialog">
           <div class="modal-content">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">退款金额</h4>
				 
            </div>
            <div class="modal-body" style = "padding: 10px;" >
					<!--
						if($is_has_refund_deliveryfree == 1)
						  {
							$total += $item['shipping_fare'];
						  }
					-->
			        <?php 
						  $total = $item['total']-$item['voucher_credit']-$item['fullreduction_money']-$has_refud_money;
						  $score_for_money = $item['score_for_money'];
						  $free_tongji = $total - $score_for_money;

						  if( !empty($presale_info) )
						  {
						    $free_tongji = $free_tongji - $presale_info['presale_for_ordermoney'];
						  }

						  $free_tongji = round($free_tongji - $hx_used_total,2);
						  if($free_tongji < 0){
							$free_tongji = 0;
						  }

					?>
					<?php if( !empty( $score_for_money ) && $score_for_money > 0 ){ ?>
					<p style="line-height:26px;font-size:13px;">积分抵扣：￥{$score_for_money}</p>
					<?php } ?>
					<p style="line-height:26px;font-size:13px;">最多退款：￥{$free_tongji}
						<?php if( !empty($presale_info) ){ ?>
						<span style="color:red;">&nbsp;&nbsp;&nbsp;&nbsp;预售定金：{$presale_info['presale_for_ordermoney']}元不退款，仅退尾款</span>
						<?php } ?>
					</p>
                    <div style="height:8px;"></div>
					<input type="text" name="refund_money" id="refund_money" placeholder="退款金额" value="{:round($free_tongji ,2)}" class="form-control" />
					<div style="height:8px;"></div>
					<?php if($item['payment_code'] == 'cashon_delivery'){ ?>
						<div style="color:red;line-height: 16px;font-size: 12px;">该订单为“货到付款”订单，订单退款金额只保留记录到订单操作中不作实际退款（不退至用户余额或微信账户），实际退款金额请线下和用户协商解决</div>
					<?php } ?>
					<?php  if($is_has_refund_deliveryfree == 1){ ?>
					<p class="line_p">
						<label>配送费：&nbsp;&nbsp;&nbsp;&nbsp;
							<?php if($shipping_fare <= 0){ ?>
							&nbsp;0
							<?php }else{ ?>
							<input type="checkbox" id="is_refund_shippingfare" name="is_refund_shippingfare" checked value ="1" />&nbsp;
							<?php if( $delivery == 'express' ){ ?>
							退“快递配送费” ¥<?php echo round($shipping_fare,2); ?>
							<?php }else if( $delivery == 'localtown_delivery' ){ ?>
							退“同城配送费” ¥<?php echo round($shipping_fare,2); ?>
							<?php }else if( $delivery == 'tuanz_send' ){ ?>
							退“团长配送费” ¥<?php echo round($shipping_fare,2); ?>
							<?php } ?>

							<?php } ?>
						</label>
					</p>
					<?php }else{ ?>
					<p class="line_p">
						<label>配送费：&nbsp;&nbsp;&nbsp;&nbsp;后台设置不退配送费</label>
					</p>
					<?php } ?>


					
					<p class="line_p">
						<label>其他操作：&nbsp;&nbsp;&nbsp;<input type="checkbox" id="is_back_sellcount" checked name="is_back_sellcount" value ="1"  />&nbsp;退库存以及减销量{$total_quantity}个</label>
					
						<?php if( !empty( $score_for_money ) && $score_for_money > 0 ){ ?>
						
						<label>
						<input type="checkbox" id="is_back_buyscore"  name="is_back_buyscore" value ="1"  />&nbsp;
						退{$buy_score_total}积分</label>
						<?php } ?>	
						
					</p>
					
					<p style="line-height:26px;font-size:13px;">佣金：<span class="label label-success">{$commiss_state}</span></p>
					<p style="margin-top:10px;line-height:16px;font-size:12px;color:#9e9696;">
					   备注：1.佣金指社区团购团长提成，团长分销提成，会员分销提成。<br/>
					   2.当佣金“未结算”，本页面操作会重新计算佣金金额，计算公式:商品退款金额占商品可退总金额比重*原来应结佣金<br/>
					   3.所退配送费计算公式=均摊，退款金额/全部商品金额*运费<br/>
				       <span style="color:red;">4.当佣金“已结算”，本页面操作不会影响已经结算的所有佣金。<br/></span>
					   <span style="color:red;">5.已结算后再发生任何退款，所有积分、社区团购团长提成、会员分销提成、团长分销提成、拼团佣金团提成、独立供应商可提现，不会再扣除，不发生任何变化。<br/></span>
					</p>
		   </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="submit">提交</button>
                <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
            </div>
        </div>
</form>

<script>
var free_tongji = {$free_tongji};
var shipping_fare = {$item['shipping_fare']};

$(function(){
	$('#is_refund_shippingfare').click(function(){
		
		var refund_money_str = $('#refund_money').val();
		
		var refund_money = parseFloat(refund_money_str);
		
		/*if($(this).is(':checked')) {
			// do something
			refund_money = refund_money + shipping_fare;
			
		}else{
			refund_money = refund_money - shipping_fare;
		}*/
		
		refund_money = Math.floor( refund_money * 100) / 100;
		$('#refund_money').val(refund_money);
	
	})
})
</script>