Commit 5d83c89c by Java-聂换换

结算管理

parent dc75efe4
......@@ -629,6 +629,18 @@
<artifactId>socket.io-client</artifactId>
<version>0.8.3</version>
</dependency>
<!-- fastjson json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
......
package com.thinkgem.jeesite.modules.youka.entity;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.List;
......@@ -25,6 +27,8 @@ public class YoukaRate extends DataEntity<YoukaRate> {
private List<YoukaRate> list;
private JSONObject jsonObject;
public YoukaRate() {
}
......@@ -136,4 +140,12 @@ public class YoukaRate extends DataEntity<YoukaRate> {
public void setSiglePrice(String siglePrice) {
this.siglePrice = siglePrice;
}
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
}
package com.thinkgem.jeesite.modules.youka.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.youka.entity.UserLevel;
import com.thinkgem.jeesite.modules.youka.entity.YoukaRate;
import com.thinkgem.jeesite.modules.youka.service.YoukaRateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @author niehh
* @Description:
* @date 2018年03月09日 14:24
*/
@RestController
@RequestMapping(value = "${adminPath}/youka/rateBody")
public class YoukaRateBodyController{
@Autowired
private YoukaRateService youkaRateService;
@RequiresPermissions("youka:rate:save")
@ResponseBody
@RequestMapping(value = "saveAll")
public String save(HttpServletRequest request,Model model, RedirectAttributes redirectAttributes){
String listStr = request.getParameter("lists");
List<YoukaRate> list = JSONArray.parseArray(listStr,YoukaRate.class);
if(list!=null && list.size()>0){
for(YoukaRate youkaRate:list){
if(youkaRate ==null || StringUtils.isBlank(youkaRate.getUserLevel()) ){
return "false";
}
try{
youkaRateService.saveRate(youkaRate);
}catch (Exception e){
e.printStackTrace();
return "false";
}
}
}else{
return "false";
}
return "true";
}
}
......@@ -11,11 +11,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @author niehh
......@@ -97,4 +97,50 @@ public class YoukaRateController extends BaseController {
return list(youkaRate, model);
}
@RequiresPermissions("youka:rate:save")
@ResponseBody
@RequestMapping(value = "saveAll")
public String save(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes){
Map map=request.getParameterMap();
Set keSet=map.entrySet();
for(Iterator itr = keSet.iterator(); itr.hasNext();){
Map.Entry me=(Map.Entry)itr.next();
Object ok=me.getKey(); //获取参数名
Object ov=me.getValue(); //获取参数值
String[] value=new String[1];
if(ov instanceof String[]){
value=(String[])ov;
}else{
value[0]=ov.toString();
}
for(int k=0;k <value.length;k++){
System.out.println(ok+"="+value[k]);
}
}
List<YoukaRate> list = new ArrayList<>();
if(list!=null && list.size()>0){
for(YoukaRate youkaRate:list){
if(youkaRate ==null || StringUtils.isBlank(youkaRate.getUserLevel()) ){
addMessage(model, "信息为空");
return "false";
}
try{
youkaRateService.saveRate(youkaRate);
}catch (Exception e){
addMessage(model, "保存失败");
e.printStackTrace();
return "false";
}
}
}else{
addMessage(model, "信息为空");
return "false";
}
return "true";
}
}
......@@ -40,6 +40,48 @@
return false;
}
function saveAll(n,s){
var datas = [];
var trs = $("#contentTable tr");
console.log(trs);
var len = trs.size() - 1;
console.log(len);
for(var i=0 ;i<len;i++){
var data = new Object();
data.userLevel = $("#userLevel"+i).val();
data.payMethod = $("#payMethod"+i).val();
data.payChannel = $("#payChannel"+i).val();
data.rate = $("#rate"+i).val();
data.balance = $("#balance"+i).val();
data.singleLimit = $("#singleLimit"+i).val();
data.dayLimit = $("#dayLimit"+i).val();
data.code = $("#code"+i).val();
data.rateType = $("#rateType"+i).val();
data.siglePrice = $("#siglePrice"+i).val();
datas.push(data);
}
console.log(datas);
console.log(JSON.stringify(datas));
$.ajax({
url:"${ctx}/youka/rateBody/saveAll",
type: "POST",
dataType : 'json',
data:
{
lists:JSON.stringify(datas)
}
,
async:false,
success: function(data){
alert("保存成功");
}
})
return false;
}
</script>
</head>
......@@ -92,64 +134,69 @@
<%--<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>--%>
<%--<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>--%>
</li>
<li class="btns"><input id="saveSubmit" class="btn btn-primary" type="submit" value="一键保存" onclick="return saveAll();"/>
</li>
<li class="clearfix"></li>
</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead><tr><th>序号</th><th class="sort-column login_name">用户类型</th><th class="sort-column name">汇率</th><th>汇率类型</th><th>单笔价格</th><td>结算</td><td>单笔限额</td><td>当天额度</td><shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission></tr></thead>
<tbody>
<c:forEach items="${userLevels}" var="userLevel" varStatus="indexs">
<tr>
<form action="${ctx}/youka/rate/save" id="form-save${indexs.index}" method="post" class="breadcrumb form-save">
<c:set var="rateEntity" value="${map[userLevel.level]}"></c:set>
<td>${indexs.index}</td>
<td>
<input name="payMethod" value="${youkaRate.payMethod}" style="display: none"/>
<input name="code" value="${rateEntity.code}" style="display: none"/>
<input name="payChannel" value="${youkaRate.payChannel}" style="display: none"/>
<input name="userLevel" value="${userLevel.level}" style="display: none"/>
<span>${userLevel.name}</span>
</td>
<td><input class="input_border input_m" name="rate" value="${rateEntity.rate}"></td>
<td>
<select name="rateType" style="width: 120px;">
<c:forEach items="${HL3rates}" var="HL3rate">
<c:if test="${HL3rate.value eq rateEntity.rateType}">
<option selected="selected" value="${HL3rate.value}">${HL3rate.label}</option>
</c:if>
<c:if test="${HL3rate.value ne rateEntity.rateType}">
<option value="${HL3rate.value}">${HL3rate.label}</option>
</c:if>
</c:forEach>
</select>
<%--<input class="input_border input_m" name="rateType" value="${rateEntity.rateType}">--%>
</td>
<td>
<input class="input_border input_m" name="siglePrice" value="${rateEntity.siglePrice}">
</td>
<td><input class="input_border input_m" name="balance" value="${rateEntity.balance}"></td>
<td>
<input class="input_border input_m" name="singleLimit" value="${rateEntity.singleLimit}">
</td>
<td>
<input class="input_border input_m" name="dayLimit" value="${rateEntity.dayLimit}">
</td>
<%--
<td>${user.roleNames}</td> --%>
<td>
<shiro:hasPermission name="youka:rate:save">
<input id="${indexs.index}" type="button" class="save btn" value="保存">
</shiro:hasPermission>
</td>
</form>
</tr>
</c:forEach>
</tbody>
</table>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead><tr><th>序号</th><th class="sort-column login_name">用户类型</th><th class="sort-column name">汇率</th><th>汇率类型</th><th>单笔价格</th><td>结算</td><td>单笔限额</td><td>当天额度</td><shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission></tr></thead>
<tbody>
<c:forEach items="${userLevels}" var="userLevel" varStatus="indexs">
<tr>
<form action="${ctx}/youka/rate/save" id="form-save${indexs.index}" method="post" class="breadcrumb form-save">
<c:set var="rateEntity" value="${map[userLevel.level]}"></c:set>
<td>${indexs.index}</td>
<td>
<input id="payMethod${indexs.index}" name="payMethod" value="${youkaRate.payMethod}" style="display: none"/>
<input id="code${indexs.index}" name="code" value="${rateEntity.code}" style="display: none"/>
<input id="payChannel${indexs.index}" name="payChannel" value="${youkaRate.payChannel}" style="display: none"/>
<input id="userLevel${indexs.index}" name="userLevel" value="${userLevel.level}" style="display: none"/>
<span>${userLevel.name}</span>
</td>
<td><input class="input_border input_m" id="rate${indexs.index}" name="rate" value="${rateEntity.rate}"></td>
<td>
<select id="rateType${indexs.index}" name="rateType" style="width: 120px;">
<c:forEach items="${HL3rates}" var="HL3rate">
<c:if test="${HL3rate.value eq rateEntity.rateType}">
<option selected="selected" value="${HL3rate.value}">${HL3rate.label}</option>
</c:if>
<c:if test="${HL3rate.value ne rateEntity.rateType}">
<option value="${HL3rate.value}">${HL3rate.label}</option>
</c:if>
</c:forEach>
</select>
<%--<input class="input_border input_m" name="rateType" value="${rateEntity.rateType}">--%>
</td>
<td>
<input id="siglePrice${indexs.index}" class="input_border input_m" name="siglePrice" value="${rateEntity.siglePrice}">
</td>
<td><input id="balance${indexs.index}" class="input_border input_m" name="balance" value="${rateEntity.balance}"></td>
<td>
<input id="singleLimit${indexs.index}" class="input_border input_m" name="singleLimit" value="${rateEntity.singleLimit}">
</td>
<td>
<input id="dayLimit${indexs.index}" class="input_border input_m" name="dayLimit" value="${rateEntity.dayLimit}">
</td>
<%--
<td>${user.roleNames}</td> --%>
<td>
<shiro:hasPermission name="youka:rate:save">
<input id="${indexs.index}" type="button" class="save btn" value="保存">
</shiro:hasPermission>
</td>
</form>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment