<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 220px;
	}
	.date_width{
	     width: 150px;
	}
	
	.tablelist th,td{
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	#signServiceAdd .zwfb_shop_table {
		margin-top: 10px
	}
	#signServiceAdd tbody {
	    display: table-row-group;
	    vertical-align: middle;
    	border-color: inherit;
	}
	#signServiceAdd .fwmc_xxk {
	    overflow: hidden;
	    margin-left: 20px;
	}
	#signServiceAdd .fwmc_xxk li {
	    float: left;
	    width: 150px;
	    height: 52px;
	    border: 1px solid #ddd;
	    font-size: 18px;
	    color: #666;
	    margin-right: 30px;
	    text-align: center;
	    margin-bottom: 10px;
	    overflow: hidden;
	    cursor: pointer;
	}
	#signServiceAdd .fwmc_xxk li p {
	    line-height: 18px;
	    font-size: 12px;
	    color: #999;
	    margin-top: 5px;
	}
	#signServiceAdd .zwsl_num {
	    margin-left: 20px;
	    font-size: 16px;
	    color: #333;
	}
	#signServiceAdd .zwsl_num span {
	    color: #999;
	    font-size: 12px;
	    padding-left: 10px;
	}
	#signServiceAdd .nmb_jj {
	    overflow: hidden;
	    margin-left: 20px;
	}
	#signServiceAdd .nmb_jj li.jian {
	    border-right: none;
	    cursor: pointer;
	    color: #999;
	    width: 30px;
	    padding: 0;
	}
	#signServiceAdd .nmb_jj li {
	    float: left;
	    text-align: center;
	    line-height: 30px;
	    border: 1px solid #ddd;
	    font-size: 20px;
	    padding: 0 8px;
	}
	#signServiceAdd .nmb_jj li .srkk {
	    width: 30px;
	    font-size: 16px;
	    border: none;
	    line-height: 30px;
	    text-align: center;
	    outline: 0;
	    background: #FFF;
	}
	#signServiceAdd .nmb_jj li.jia {
	    border-left: none;
	    cursor: pointer;
	    color: #999;
	    width: 30px;
	    padding: 0;
	}
	#signServiceAdd a.ty_but {
	    width: 130px;
	    height: 40px;
	    line-height: 40px;
	    text-align: center;
	    display: block;
	    font-size: 16px;
	    color: #fff;
	    border-radius: 3px;
	    background: #169ed8;
	}
	#signServiceAdd a.ty_but:hover {
	    background: #1187ba;
	}
	#signServiceAdd .fwmc_xxk li.sign_type_select_on {
	    background: url(/static/sys/images/fwkk.jpg) no-repeat center;
	    color: #169ed8;
	    border: 1px solid #169ed8;
	}
	
	
	
	
	
	
	#libServiceAdd .zwfb_shop_table {
		margin-top: 10px
	}
	#libServiceAdd tbody {
	    display: table-row-group;
	    vertical-align: middle;
    	border-color: inherit;
	}
	#libServiceAdd .fwmc_xxk {
	    overflow: hidden;
	    margin-left: 20px;
	}
	#libServiceAdd .fwmc_xxk li {
	    float: left;
	    width: 150px;
	    height: 52px;
	    border: 1px solid #ddd;
	    font-size: 18px;
	    color: #666;
	    margin-right: 30px;
	    text-align: center;
	    margin-bottom: 25px;
	    overflow: hidden;
	    cursor: pointer;
	}
	#libServiceAdd .fwmc_xxk li p {
	    line-height: 18px;
	    font-size: 12px;
	    color: #999;
	    margin-top: 5px;
	}
	#libServiceAdd .zwsl_num {
	    margin-left: 20px;
	    font-size: 16px;
	    color: #333;
	}
	#libServiceAdd .zwsl_num span {
	    color: #999;
	    font-size: 12px;
	    padding-left: 10px;
	}
	#libServiceAdd .nmb_jj {
	    overflow: hidden;
	    margin-left: 20px;
	}
	#libServiceAdd .nmb_jj li.jian {
	    border-right: none;
	    cursor: pointer;
	    color: #999;
	    width: 30px;
	    padding: 0;
	}
	#libServiceAdd .nmb_jj li {
	    float: left;
	    text-align: center;
	    line-height: 30px;
	    border: 1px solid #ddd;
	    font-size: 20px;
	    padding: 0 8px;
	}
	#libServiceAdd .nmb_jj li .srkk {
	    width: 30px;
	    font-size: 16px;
	    border: none;
	    line-height: 30px;
	    text-align: center;
	    outline: 0;
	    background: #FFF;
	}
	#libServiceAdd .nmb_jj li.jia {
	    border-left: none;
	    cursor: pointer;
	    color: #999;
	    width: 30px;
	    padding: 0;
	}
	#libServiceAdd a.ty_but {
	    width: 130px;
	    height: 40px;
	    line-height: 40px;
	    text-align: center;
	    display: block;
	    font-size: 16px;
	    color: #fff;
	    border-radius: 3px;
	    background: #169ed8;
	}
	#libServiceAdd a.ty_but:hover {
	    background: #1187ba;
	}
	#libServiceAdd .fwmc_xxk li.sign_type_select_on {
	    background: url(/static/sys/images/fwkk.jpg) no-repeat center;
	    color: #169ed8;
	    border: 1px solid #169ed8;
	}
	
	
	
</style>
<body>

<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/fx/merchantAllList.html}" method="post">
	<input type="hidden" name="reportType" id="reportType" />
	<input type="hidden" name="pageSize" id="pageSize" value="10" />
	<ul class="seachform">
		<li>
		 <label>商户名称</label>
		  <input name=LIKE_orgCode type="hidden" class="scinput" th:value="${search.get('LIKE_orgCode')}"/>
		  <input name="LIKE_unitName" type="text" class="scinput" th:value="${search.get('LIKE_unitName')}"/>
	    </li>
		    
	    <li>
		 <label>商户账号</label>
		  <input name="LIKE_posCode" type="text" class="scinput" th:value="${search.get('LIKE_posCode')}"/>
	    </li>
		    
	    <li>
		 <label>商户模式</label>
		 	<select class="scinput select_width" name="signType" id="signType"   style="width: 150px;" >
		 	 	<option value="" >全部</option>
				<option value="0"  th:selected="${search.get('signType') eq '0' ? true : false}" >旧模式</option>
				<option value="1"  th:selected="${search.get('signType') eq '1' ? true : false}">新模式</option>
			</select>
	    </li>
	    
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
<!-- 		<li> -->
		
<!-- 			<ul class="toolbar" th:if=" -->
<!-- 			${ #httpSession.getAttribute('admin') !=null &&  -->
<!-- 			( -->
<!-- 				#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员')  || -->
<!-- 				#lists.contains(#httpSession.getAttribute('admin').authorities,'分销管理员')   || -->
<!-- 				#lists.contains(#httpSession.getAttribute('admin').authorities,'超级管理员角色')   -->
<!-- 			)  }"> -->
<!-- 				<a href="javascript:;" onclick="savemerchant('')"> -->
<!-- 					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>机构商户</li> -->
<!-- 				</a> -->
				
<!-- 				<a href="javascript:;" onclick="savemerchantsc('')"> -->
<!-- 					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>学校商户</li> -->
<!-- 				</a> -->
<!-- 			</ul> -->
			
<!-- 		</li> -->
	</ul>
	</form>
	<ul style="margin-bottom: 10px" >
	  <li>
		<input type="button" id="button" class="scbtn" value="导出商户" />
      </li>
	</ul>
	 
	

	<table class="tablelist">
		<thead>
		    <tr>

		    	<th >商户账号</th>
		    	<th >单位名称 </th>
		    	<th >关联机构 </th>
		    	<th >商户类型 </th>
		    	<th >商户套餐 </th>
		    	<th >商户模式 </th>
		    	<th >平台管理费 </th>
		    	<th style="width: 60px;">签约端口数量</th>
		    	<th style="width: 60px;">服务人数/塾币</th>
		    	<th style="width: 60px;">平台塾币</th>
		    	<th style="max-width: 160px;" >合同日期</th>
		    	<th style="width: 60px;" >激活开始日期</th>
		    	<th style="width: 60px;" >激活结束日期</th>
		    	<th style="width: 60px;" >计费开始日期</th>
		    	<th style="width: 60px;" >服务结束日期</th>
		    	<th  >状态</th> 
		        <th  >操作</th> 
		    </tr> 
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
		
					<td th:title="${item.posCode}" th:text="${item.posCode}"></td>
					<td th:title="${item.unitName}" th:text="${item.unitName}"></td>
					<td  th:title="${item.libJoin!=null ? item.libJoin.leagueName : '' }" >
						<a href="javascript:;" th:onclick="'openNew(\''+${item.libId}+'\')'" th:if="${item.libId!='' && item.libId!=null}"	class="tablelink">[[${item.libJoin.leagueName}]]</a>
					</td>
					
					<td  th:switch="${item.posType}">
					   <span th:case="1" >塾币商户</span>
					   <span th:case="2" >端口商户</span>
					   <span th:case="3" >学校商户</span>
					   <span th:case="*" >--</span>
					</td>
					
					<td  th:switch="${item.mealType}">
					   <span th:case="0" >塾币模式</span>
					   <span th:case="1" >优选套餐</span>
					   <span th:case="2" >VIP套餐</span>
					   <span th:case="3" >尊享套餐</span>
					   <span th:case="4" >校园服务</span>
					   <span th:case="*" >--</span>
					</td>
					
					<td  th:switch="${item.signType}">
					   <span th:case="0" >塾币模式</span>
					   <span th:case="1" >服务包1</span>
					   <span th:case="2" >服务包2</span>
					   <span th:case="3" >服务包3</span>
					   <span th:case="4" >服务包4</span>
					   <span th:case="5" >服务包5</span>
					   <span th:case="*" >--</span>
					</td>
					
					<td  th:text="${item.posType>1 ? item.outPrice: '--' }"></td>
					<td  th:text="${item.portNum}"></td>
					<td  th:text="${item.libService}"></td>
					<td  th:text="${item.platformService}"></td>
					
					
					<td th:title="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '--' }"  th:text="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '--' }"></td>
					<td  th:text="${item.posType>1 ? #calendars.format(item.startActiveTime,'yyyy-MM-dd'): '--'}" ></td> 
					<td  th:text="${item.posType>1 ? #calendars.format(item.activeTime,'yyyy-MM-dd'): '--'}" ></td> 
					<td  th:text="${item.posType>1 ? #calendars.format(item.computeTime,'yyyy-MM-dd'): '--'}" ></td> 
					<td  th:text="${item.posType>1 ? #calendars.format(item.endActiveTime,'yyyy-MM-dd'): '--'}" ></td> 
					<td  th:switch="${item.status}">
					   <span th:case="1" >正常&nbsp;</span>
					   <span th:case="2" >正常&nbsp;</span>
					   <span th:case="3" >正常&nbsp;</span>
					   <span th:case="4" >冻结&nbsp;</span>
					</td>
					<td  >   
						<di th:if="
						${ #httpSession.getAttribute('admin') !=null && 
						(
							#lists.contains(#httpSession.getAttribute('admin').authorities,'财务管理员')  ||
							#lists.contains(#httpSession.getAttribute('admin').authorities,'超级管理员角色')  
						)  }
						">
							<a href="javascript:;" th:if="${item.posType==1 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'joinServiceEdit(\''+${item.id}+'\')'" class="tablelink">塾&nbsp;&nbsp;&nbsp;币</a>
							<a href="javascript:;" th:if="${item.posType==2 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'libServiceAdd(\''+${item.id}+'\')'" class="tablelink">服务包</a>
							<a href="javascript:;" th:if="${item.posType==3 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'libServiceScAdd(\''+${item.id}+'\')'" class="tablelink">服务包</a>
							
							<a href="javascript:;" th:if="${item.signType!=0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'signServiceAdd(\''+${item.id}+'\')'" class="tablelink">加油包</a>
							
							<a href="javascript:;" th:if="${item.signType!=0 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'platServiceAdd(\''+${item.id}+'\')'" class="tablelink">管理费</a>
						
							<a href="javascript:;" th:if="${item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'updatemerchant(\''+${item.id}+'\',\'4\')'"   class="tablelink">冻结</a>
							
							<a href="javascript:;" th:if="${item.posType==1 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'savemerchantold(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
							<a href="javascript:;" th:if="${item.posType==2 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'savemerchant(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
							<a href="javascript:;" th:if="${item.posType==3 && item.status!=4 && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'savemerchantsc(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
						
						</di>
						<a href="javascript:;" th:if="${item.status!=4 && item.libId!='' && item.libId!=null && (curMerchant.orgCode eq 'SSJ-FX' || #strings.contains(item.orgCode,curMerchant.orgCode) ) }"  th:onclick="'untyingmerchant(\''+${item.id}+'\')'"  	class="tablelink">解绑</a>
					 </td>  
					
					
			</tr>
		</tbody>
	</table> 
	
	
<div class="formbody" id="joinServiceEdit" style="display: none">
	<input type="hidden" id="merchant_id" value="" >
	<ul class="forminfo">
		<li>
			<label style="width: 100%;line-height: 30px;color: #ea2020;font-size: 15px">温馨提醒：1个塾币=1个月服务</label>
		</li>
		<li></li>
		<li>
			<label>机构端口：</label>
			<label><b id="port_num">0</b> 个</label>
			<input  onclick="joinServiceAdd(2);" type="button" style="width: 70px;height: 30px;border-radius: 50px;"  class="scbtn isportnum" value=" 添加 " />
		</li>
		
		<li>
			<label>机构塾币：</label>
			<label><b id="lib_service_num">0</b> 个</label>
			<input  onclick="joinServiceAdd(1);" type="button" style="width: 70px;height: 30px;border-radius: 50px;margin-right: 10px;"  class="scbtn" value=" 添加 " />&nbsp;
			<input onclick="merchantallot(1);" type="button" style="width: 70px;height: 30px;border-radius: 50px;background: #ffb752!important;"  class="scbtn" value=" 分配 " />
		</li>
		
		<li>
			<label>平台塾币：</label>
			<label><b id="platform_service_num">0</b> 个</label>
			<input  onclick="joinServiceAdd(3);" type="button" style="width: 70px;height: 30px;border-radius: 50px;margin-right: 10px;"  class="scbtn" value=" 添加 " />&nbsp;
			<input onclick="merchantallot(2);" type="button" style="width: 70px;height: 30px;border-radius: 50px;background: #ffb752!important;"  class="scbtn" value=" 分配 " />
		</li>
		
	</ul>
</div>


<div class="formbody" id="libServiceAdd" style="display: none;">
	<input type="hidden" id="lib_merchant_id" value="" >
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="zwfb_shop_table">
	      <tbody>
	      	<tr valign="top">
		        <td align="right" width="70" style="line-height: 50px;font-weight: 700">续费服务包：</td>
		        <td>
		        	<ul class="fwmc_xxk">
		           	<li class="sign_type_select sign_type_select_on"  data-type="5">
		              <p>服务包1</p>
		              30人<i>/1月/1000元</i>
		           	</li>
		          </ul>
		        </td>
	      </tr>
	      
	      <tr valign="top">
  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">总服务月数量：</td>
  	        <td>
	        	<ul class="nmb_jj">
		            <li><i>6月</i></li>
	          </ul>
	        </td>
	      </tr>
	      <tr>
	        <td height="10"></td>
	        <td></td>
	      </tr>
	      <tr valign="top">
  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">已赠送月数量：</td>
  	        <td>
	        	<ul class="nmb_jj">
		            <li><i>1月</i></li>
	          </ul>
	        </td>
	      </tr>
	       <tr>
	        <td height="10"></td>
	        <td></td>
	      </tr>
	      
	      <tr>
	        <td height="10"></td>
	        <td></td>
	      </tr>
	      <tr valign="top">
  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">已购买月数量：</td>
  	        <td>
	        	<ul class="nmb_jj">
		            <li><i>5月</i></li>
	          </ul>
	        </td>
	      </tr>
	       <tr>
	        <td height="10"></td>
	        <td></td>
	      </tr>
	      
	      <tr valign="top">
  			<td align="right" width="70" style="line-height: 30px;font-weight: 700">续费月数量：</td>
  	        <td>
	        	<ul class="nmb_jj">
		            <li class="jian" id="lib_reduce_num">-</li>
		            <li>
		              <input name="" id="lib_add_service_num" type="text" value="1" class="srkk">
		            </li>
		            <li class="jia" id="lib_add_num">+</li>  
	          </ul>
	        </td>
	      </tr>
	      
	      <tr>
	        <td height="20"></td>
	        <td></td>
	      </tr>
	   	 <tr>
	        <td height="20"></td>
	        <td></td>
	      </tr>
	      <tr>
	        <td></td>
	        <td><a class="ty_but ml20" href="javascript:#" onclick="saveLib();">添 加</a></td>
	      </tr>
	    </tbody>
   	</table>
    
</div>



<div class="formbody" id="signServiceAdd" style="display: none;">
	<input type="hidden" id="meal_merchant_id" value="" >
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="zwfb_shop_table">
	      <tbody>
	      	<tr valign="top">
		        <td align="right" width="70" style="line-height: 50px;font-weight: 700">加油包类型：</td>
		        <td>
		        	<ul class="fwmc_xxk">
		            <li class="sign_type_select sign_type_select_on" data-type="4">
		              <p>加油包-月包</p>
		              1个月<i>/5人/1000元</i>
		           	</li>
		           	<li class="sign_type_select"  data-type="5">
		              <p>加油包-数量包</p>
		              5人<i>/1月/1000元</i>
		           	</li>
		          </ul>
		        </td>
	      	</tr>
	      <tr>
	        <td height="20"></td>
	        <td></td>
	      </tr>
	      <tr>
	        <td align="right" style="font-weight: 700">添加数量：</td>
	        <td>
	        	<ul class="nmb_jj">
		            <li class="jian" id="meal_reduce_num">-</li>
		            <li>
		              <input name="" id="meal_add_service_num" type="text" value="1" class="srkk">
		            </li>
		            <li class="jia" id="meal_add_num">+</li>  
	          </ul>
	        </td>
	      </tr>
	      <tr>
	        <td height="20"></td>
	        <td></td>
	      </tr>
	   	 <tr>
	        <td height="20"></td>
	        <td></td>
	      </tr>
	      <tr>
	        <td></td>
	        <td><a class="ty_but ml20" href="javascript:#" onclick="saveMeal();">添 加</a></td>
	      </tr>
	    </tbody>
   	</table>
    
</div>



<div class="formbody" id="joinServiceAdd" style="display: none;">
	<input type="hidden" id="service_type" value="" >
	<ul class="seachform" style="margin-top: 40px;margin-left:38%">
	    <li>
		  <input type="button" id="reduce_num" style="width: 30px;height: 30px;border-radius: 50px;"  class="scbtn" value=" - " />
	    </li>
	    <li>
		  <input type="text" id="add_service_num" value="1"  style="width: 50px;height: 30px;text-align: center;"   />
	    </li>
	    <li>
		  <input type="button" id="add_num" style="width: 30px;height: 30px;border-radius: 50px;"  class="scbtn" value=" + " />
	    </li>
	</ul>
	<button style="margin-top: 30px;margin-left: 38%" type="submit" onclick="save();" class="btn">提交</button>
</div>
	


	<!-- 分页 -->
	<div class="pagin">
    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
   	</div>
</div>




<ul style="margin-bottom: 100px;margin-left: 20px;">
		<li style="line-height: 25px;">
			<span style="font-size: 14px;">操作名词解释</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">关联机构：商户关联的机构名称，可通过操作解绑，修改重新绑定新机构。</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">商户套餐：商户开通的服务套餐。</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">商户模式：商户开通的服务包，服务包决定机构服务的人数。</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">服务人数/塾币：现在可以服务的人数。</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">旧转新余币	：当商户发生旧转新模式时，会保存旧模式最后一时刻的余币数量。</span>
		</li>
		<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">充值/已结算(月份)：充值=充值的几个月，已结算=现已正常结算的次数。如0/0时，表示此商户服务包已过期。</span>
		</li>
			<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">激活开始日期：商户可以使用服务包的开始日期。</span>
		</li>
		</li>
			<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">激活结束日期：商户真正开始进入结算的日期。</span>
		</li>
		</li>
			<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">计费开始日	：免费期之后，商户真正开始进入结算的日期。</span>
		</li>
		</li>
			<li style="line-height: 25px;color: red;">
			<span style="font-size: 14px;">下个结算日：商户下一个发生结算的日期。</span>
		</li>

	</ul>

</body>


<script type="text/javascript">


$(function () {
	
	$("#reduce_num").click(function (){
		if($("#add_service_num").val()<=1){
			parent.layer.msg("塾币不能小于1。",{icon:11});
			return;
		}
		$("#add_service_num").val(parseInt($("#add_service_num").val())-1);
	});
	
	$("#add_num").click(function (){
		$("#add_service_num").val(parseInt($("#add_service_num").val())+1);
	});
	
	$("#meal_reduce_num").click(function (){
		if($("#meal_add_service_num").val()<=1){
			parent.layer.msg("添加加油包数量不能小于1",{icon:11});
			return;
		}
		$("#meal_add_service_num").val(parseInt($("#meal_add_service_num").val())-1);
	});
	
	$("#meal_add_num").click(function (){
		$("#meal_add_service_num").val(parseInt($("#meal_add_service_num").val())+1);
	});
	
	$(".sign_type_select").click(function (){
		$(".sign_type_select").removeClass("sign_type_select_on");
		$(this).addClass("sign_type_select_on");
	});
	

})


function save(){
	var type= $("#service_type").val();
	var num=$("#add_service_num").val();
	var merchantId=$("#merchant_id").val();
	
	var url="[[${sysUrl}]]/sys/fx/merchant/update/"+merchantId;
	var params ={
        'type' : type,
        'num':num
    };
	$.post(url,params,function(data){
		if(data.meta.success){
			parent.layer.msg("设置成功",{icon:1});
			parent.location.reload();
			parent.layer.close(parent.layer.getFrameIndex(window.name));
		}else{
			parent.layer.msg(data.meta.message,{icon:11});
		}
	});
}


function joinServiceAdd(type){
	var title='';
	if(type==1){
		title="添加机构塾币";
	}else if(type==3){
		title="添加平台塾币";
	}else{
		title="添加机构端口";
	}
	$("#add_service_num").val(1)
	 $.ajax({
		  url: "[[${sysUrl}]]/sys/fx/getMerchant/"+$("#merchant_id").val(),
	      type: 'POST',
	      data: {},
	      processData: false,
	      contentType: false, 
	      beforeSend: function () {
	      },
	      success: function (responseStr) {
	    	  if(responseStr.meta.success){
	    		  $("#service_type").val(type);
	    		  layer.open({
	    			    type: 1,
	    			    title: title,
	    			    closeBtn: 1, //不显示关闭按钮
	    			    shift: 0.8,
	    			    offset: '150px',
	    			    area: ['40%', '40%'],
	    			    content: $("#joinServiceAdd")
	    			});
	    		  
	    	  }else{
	    		  parent.layer.msg(responseStr.meta.message,{icon:11});
	    	  }
	      }
	      ,
	      error : function (responseStr) {
	    	  parent.layer.msg("查询失败,请刷新后重试！",{icon:11});
	      }
	  });
	

}



function libServiceAdd(id){
	var title="购买端口服务包";
	parent.layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    offset: '10%',
	    area: ['905px', '60%'],
	    content: '[[${sysUrl}]]/sys/fx/merchantMealAdd.html?id='+id
	});
}

function libServiceScAdd(id){
	var title="购买学校服务包";
	parent.layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    offset: '10%',
	    area: ['905px', '60%'],
	    content: '[[${sysUrl}]]/sys/fx/merchantMealScAdd.html?id='+id
	});
}

function signServiceAdd(id){
	var title="购买加油包";
	parent.layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    offset: '10%',
	    area: ['905px', '60%'],
	    content: '[[${sysUrl}]]/sys/fx/merchantSignAdd.html?id='+id
	});
}


function platServiceAdd(id){
	var title="购买管理费";
	parent.layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    offset: '10%',
	    area: ['905px', '60%'],
	    content: '[[${sysUrl}]]/sys/fx/merchantPlatAdd.html?id='+id
	});
}



function saveMeal(){
	parent.layer.confirm("确定为此商户添加加油包？", {
		icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
	}, function(){
		var type=$(".sign_type_select_on").data("type");
		var num=$("#meal_add_service_num").val();
		var merchantId=$("#meal_merchant_id").val();
		var url="[[${sysUrl}]]/sys/fx/merchant/updateMeal/"+merchantId;
		var params ={
	        'num':num,
	        'type':type
	    };
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("添加成功",{icon:1});
				parent.location.reload();
				parent.layer.close(parent.layer.getFrameIndex(window.name));
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
			}
		});
	});
}




function joinServiceEdit(id){
	  $.ajax({
		  url: "[[${sysUrl}]]/sys/fx/getMerchant/"+id,
	      type: 'POST',
	      data: {},
	      processData: false,
	      contentType: false, 
	      beforeSend: function () {
	      },
	      success: function (responseStr) {
	    	  if(responseStr.meta.success){
	    		  
	    		  $("#merchant_id").val(id);
	    		  $("#lib_service_num").html(responseStr.data.merchant.libService);
	    		  $("#platform_service_num").html(responseStr.data.merchant.platformService);
	    		  $("#port_num").html(responseStr.data.merchant.portNum);
	    		  
	    		  if(responseStr.data.isPortNum){
	    			  $(".isportnum").show();
	    		  }else{
	    			  $(".isportnum").hide();
	    		  }
	    		  
	    		  layer.open({
    			    type: 1,
    			    title: '管理塾币',
    			    closeBtn: 1, //不显示关闭按钮
    			    shift: 0.8,
    			    offset: '150px',
    			    area: ['40%', '40%'],
    			    content: $("#joinServiceEdit")
	    		 });
	    		  
	    	  }else{
	    		  parent.layer.msg(responseStr.meta.message,{icon:11});
	    	  }
	      }
	      ,
	      error : function (responseStr) {
	    	  parent.layer.msg("查询失败,请刷新后重试！",{icon:11});
	      }
	  });
}
</script>

<script type="text/javascript">

	function  openNew(libId) {
		//@{/sys/admin/curator/index.html(libId=${item.libId})}
		window.open('[[${sysUrl}]]/sys/admin/curator/index.html?libId='+libId);
	}
		function merchantallot(type){
			var id=$("#merchant_id").val();
			var title="";
			if(type==1){
				title="分配机构塾币";
			}else{
				title="分配平台塾币";
			}
			layer.open({
			    type: 2,
			    title: title,
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '150px',
			    area: ['40%', '40%'],
			    content: '[[${sysUrl}]]/sys/fx/merchantAllot.html?id='+id+'&type='+type
			});
		}

		
		
		
		function infomerchant(id){
			var title="查看商户";
			
			parent.layer.open({
			    type: 2,
			    title: title,
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '10px',
			    area: ['90%', '95%'],
			    content: '[[${sysUrl}]]/sys/fx/merchantInfo.html?id='+id
			});
		}


		function savemerchant(id){
			var title="端口商户建立";
			if(id!=null && id!='' && id!=undefined){
				title="修改端口商户";
			}
			parent.layer.open({
			    type: 2,
			    title: title,
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '10px',
			    area: ['90%', '95%'],
			    content: '[[${sysUrl}]]/sys/fx/merchantAdd.html?id='+id
			});
		}
		
		function savemerchantsc(id){
			var title="学校商户建立";
			if(id!=null && id!='' && id!=undefined){
				title="修改商户";
			}
			parent.layer.open({
			    type: 2,
			    title: title,
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '10px',
			    area: ['90%', '95%'],
			    content: '[[${sysUrl}]]/sys/fx/merchantScAdd.html?id='+id
			});
		}
		
		
		function savemerchantold(id){
			var title="塾币商户建立";
			if(id!=null && id!='' && id!=undefined){
				title="修改塾币商户";
			}
			parent.layer.open({
			    type: 2,
			    title: title,
			    closeBtn: 1, //不显示关闭按钮
			    shift: 0.8,
			    offset: '10px',
			    area: ['90%', '95%'],
			    content: '[[${sysUrl}]]/sys/fx/merchantOldAdd.html?id='+id
			});
		}
		
		
		
		function untyingmerchant(id){
			
			parent.layer.confirm("确定解绑机构？<br/>此动作会清空机构下塾币<br/>但此商户下的塾币会保留", {
				icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
			}, function(){
				$.ajax({
					url : "[[${sysUrl}]]/sys/fx/merchant/untying",
					type : "post",
					data : {id:id},
					dataType : "json",
					success : function(data) {
						if(data.meta.success){
							parent.layer.msg("操作成功",{icon:1});
					    	setTimeout(function(){
					    		location.reload();
							},1000);
						}else{
							alert("操作异常，请刷新后重试...")
						}
					}
				});
			});
			
		}


		function updatemerchant(id,status){  
			
			if(status==4){
				parent.layer.confirm("确定操作冻结此商户？", {
					icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
				}, function(){
					$.ajax({
						url : "[[${sysUrl}]]/sys/fx/updateMerchant",
						type : "post",
						data : {id:id,status:status},
						dataType : "json",
						success : function(data) {
							if(data.meta.success){
								parent.layer.msg("操作成功",{icon:1});
						    	setTimeout(function(){
						    		location.reload();
								},1000);
							}else{
								alert("操作异常，请刷新后重试...")
							}
						}
					});
				});
			}else{
				
				$.ajax({
					url : "[[${sysUrl}]]/sys/fx/updateMerchant",
					type : "post",
					data : {id:id,status:status},
					dataType : "json",
					success : function(data) {
						if(data.meta.success){
							parent.layer.msg("操作成功",{icon:1});
					    	setTimeout(function(){
					    		location.reload();
							},1000);
						}else{
							alert("操作异常，请刷新后重试...")
						}
					}
				});
			}
		}
	
	
</script>

<script type="text/javascript">
$("#button").on('click',function(){
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/exportMerchant";
	$("#seachform").submit();
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/merchantAllList.html";
});
</script>




</html>