<%
  @confirm = params[:confirm].to_i || 0
  @confirm_diaplay = params[:c] || "block"
  @success_display = params[:s] || "none"
  if @confirm == 1
    if @object.pay_state == 0
      #回退提现金额到账户余额中, 确保账户表中之前没有拒绝的记录
      cbalance = CashBalance.where("wx_uid = ? and source = ? and relate_id = ?", 
        @object.wx_uid, 'extract_reject', @object.order_id).first
      if cbalance.blank?
        cbalance = CashBalance.new
        cbalance.wx_uid = @object.wx_uid
        cbalance.relate_id = @object.order_id
        cbalance.source = "extract_reject"
        cbalance.count = @object.count
        cbalance.remark = "提现被拒绝"
        cbalance.save

        update_sql = "update take_cash_orders set audit_state = 2 where id = '#{@object.id}'"
        TakeCashOrder.connection.execute(update_sql)                    
      end
    end
  end
%>
<!DOCTYPE html>
<html>
<head>
  <title>拒绝提现</title>
  <script type="text/javascript">
    function confirm(){
     <% go_url = "#{CONFIG_FILE["admin_host"]}/admin/take_cash_order/#{@object.id}/refuse_takecash?confirm=1&c=none&s=block" %> 
      window.open("<%= go_url %>","_self");
    }
    function not_confirm(){
      <% go_url2 = "#{CONFIG_FILE["admin_host"]}/admin/take_cash_order" %>
      window.open("<%= go_url2 %>","_self");
    }
  </script>
</head>
<body>
  <div id="confirm" style="display: <%=@confirm_diaplay%>">
    <input type="button" value="是的，我确定" id="yes" onclick="confirm()" >
    <input type="button" value="取 消" id="no" onclick="not_confirm()" >
  </div>
  <div id="success" style="display:<%=@success_display%>;">
    <h3>已拒绝, 提现款项已回到资金账户中。</h3>
  </div>
</body>
</html>