Commit 5d83c89c by Java-聂换换

结算管理

parent dc75efe4
...@@ -629,6 +629,18 @@ ...@@ -629,6 +629,18 @@
<artifactId>socket.io-client</artifactId> <artifactId>socket.io-client</artifactId>
<version>0.8.3</version> <version>0.8.3</version>
</dependency> </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> </dependencies>
<build> <build>
......
package com.thinkgem.jeesite.modules.youka.entity; package com.thinkgem.jeesite.modules.youka.entity;
import com.thinkgem.jeesite.common.persistence.DataEntity; import com.thinkgem.jeesite.common.persistence.DataEntity;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -25,6 +27,8 @@ public class YoukaRate extends DataEntity<YoukaRate> { ...@@ -25,6 +27,8 @@ public class YoukaRate extends DataEntity<YoukaRate> {
private List<YoukaRate> list; private List<YoukaRate> list;
private JSONObject jsonObject;
public YoukaRate() { public YoukaRate() {
} }
...@@ -136,4 +140,12 @@ public class YoukaRate extends DataEntity<YoukaRate> { ...@@ -136,4 +140,12 @@ public class YoukaRate extends DataEntity<YoukaRate> {
public void setSiglePrice(String siglePrice) { public void setSiglePrice(String siglePrice) {
this.siglePrice = 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; ...@@ -11,11 +11,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* @author niehh * @author niehh
...@@ -97,4 +97,50 @@ public class YoukaRateController extends BaseController { ...@@ -97,4 +97,50 @@ public class YoukaRateController extends BaseController {
return list(youkaRate, model); 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 @@ ...@@ -40,6 +40,48 @@
return false; 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> </script>
</head> </head>
...@@ -92,6 +134,9 @@ ...@@ -92,6 +134,9 @@
<%--<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>--%> <%--<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>--%>
<%--<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>--%> <%--<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>--%>
</li> </li>
<li class="btns"><input id="saveSubmit" class="btn btn-primary" type="submit" value="一键保存" onclick="return saveAll();"/>
</li>
<li class="clearfix"></li> <li class="clearfix"></li>
</ul> </ul>
</form:form> </form:form>
...@@ -105,15 +150,15 @@ ...@@ -105,15 +150,15 @@
<c:set var="rateEntity" value="${map[userLevel.level]}"></c:set> <c:set var="rateEntity" value="${map[userLevel.level]}"></c:set>
<td>${indexs.index}</td> <td>${indexs.index}</td>
<td> <td>
<input name="payMethod" value="${youkaRate.payMethod}" style="display: none"/> <input id="payMethod${indexs.index}" name="payMethod" value="${youkaRate.payMethod}" style="display: none"/>
<input name="code" value="${rateEntity.code}" style="display: none"/> <input id="code${indexs.index}" name="code" value="${rateEntity.code}" style="display: none"/>
<input name="payChannel" value="${youkaRate.payChannel}" style="display: none"/> <input id="payChannel${indexs.index}" name="payChannel" value="${youkaRate.payChannel}" style="display: none"/>
<input name="userLevel" value="${userLevel.level}" style="display: none"/> <input id="userLevel${indexs.index}" name="userLevel" value="${userLevel.level}" style="display: none"/>
<span>${userLevel.name}</span> <span>${userLevel.name}</span>
</td> </td>
<td><input class="input_border input_m" name="rate" value="${rateEntity.rate}"></td> <td><input class="input_border input_m" id="rate${indexs.index}" name="rate" value="${rateEntity.rate}"></td>
<td> <td>
<select name="rateType" style="width: 120px;"> <select id="rateType${indexs.index}" name="rateType" style="width: 120px;">
<c:forEach items="${HL3rates}" var="HL3rate"> <c:forEach items="${HL3rates}" var="HL3rate">
<c:if test="${HL3rate.value eq rateEntity.rateType}"> <c:if test="${HL3rate.value eq rateEntity.rateType}">
<option selected="selected" value="${HL3rate.value}">${HL3rate.label}</option> <option selected="selected" value="${HL3rate.value}">${HL3rate.label}</option>
...@@ -126,14 +171,14 @@ ...@@ -126,14 +171,14 @@
<%--<input class="input_border input_m" name="rateType" value="${rateEntity.rateType}">--%> <%--<input class="input_border input_m" name="rateType" value="${rateEntity.rateType}">--%>
</td> </td>
<td> <td>
<input class="input_border input_m" name="siglePrice" value="${rateEntity.siglePrice}"> <input id="siglePrice${indexs.index}" class="input_border input_m" name="siglePrice" value="${rateEntity.siglePrice}">
</td> </td>
<td><input class="input_border input_m" name="balance" value="${rateEntity.balance}"></td> <td><input id="balance${indexs.index}" class="input_border input_m" name="balance" value="${rateEntity.balance}"></td>
<td> <td>
<input class="input_border input_m" name="singleLimit" value="${rateEntity.singleLimit}"> <input id="singleLimit${indexs.index}" class="input_border input_m" name="singleLimit" value="${rateEntity.singleLimit}">
</td> </td>
<td> <td>
<input class="input_border input_m" name="dayLimit" value="${rateEntity.dayLimit}"> <input id="dayLimit${indexs.index}" class="input_border input_m" name="dayLimit" value="${rateEntity.dayLimit}">
</td> </td>
<%-- <%--
<td>${user.roleNames}</td> --%> <td>${user.roleNames}</td> --%>
...@@ -151,5 +196,7 @@ ...@@ -151,5 +196,7 @@
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </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