支付能力配置
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
index 65f8e1a..021d398 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeConfigDao.java
@@ -13,4 +13,6 @@
@Repository
public interface PaytypeConfigDao extends JpaRepository<TPaytypeConfig, TPaytypeConfigPK> {
List<TPaytypeConfig> getByPaytype(String paytype);
+
+ TPaytypeConfig getByPaytypeAndAndConfigid(String paytype, String configid);
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java
index 0313df1..eb9f3f4 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java
@@ -2,22 +2,23 @@
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.api.domain.TPaytype;
+import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
import com.supwisdom.dlpay.framework.domain.TApiClient;
import com.supwisdom.dlpay.framework.domain.TBusinesspara;
import com.supwisdom.dlpay.framework.domain.TSyspara;
import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.*;
import com.supwisdom.dlpay.system.service.ParamService;
+import com.supwisdom.dlpay.util.ConstantUtil;
+import com.supwisdom.dlpay.util.WebCheckException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@Controller
@@ -95,8 +96,8 @@
@PreAuthorize("hasPermission('/param/businesspara','')")
@ResponseBody
public PageResult<TBusinesspara> getBusinessDataList(@RequestParam("page") Integer pageNo,
- @RequestParam("limit") Integer pageSize,
- @RequestParam(value = "paraname", required = false) String paraname) {
+ @RequestParam("limit") Integer pageSize,
+ @RequestParam(value = "paraname", required = false) String paraname) {
try {
if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;
if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;
@@ -200,7 +201,7 @@
/**
* ====================================================
- * APPID应用权限参数管理
+ * APPID应用权限参数管理
* ====================================================
*/
@GetMapping("/param/apiclientpara")
@@ -291,8 +292,8 @@
@PreAuthorize("hasPermission('/param/updateapiclientpara','')")
@ResponseBody
public JsonResult updateApiclientSecret(@RequestParam("appid") String appid,
- @RequestParam(value = "secret", required = false) String secret,
- @RequestParam(value = "roles", required = false) String roles) {
+ @RequestParam(value = "secret", required = false) String secret,
+ @RequestParam(value = "roles", required = false) String roles) {
if (StringUtil.isEmpty(appid) || (StringUtil.isEmpty(secret) && StringUtil.isEmpty(roles))) {
return JsonResult.error("参数传递错误");
}
@@ -322,7 +323,7 @@
@PreAuthorize("hasPermission('/param/addapiclientpara','')")
@ResponseBody
public JsonResult addApiclientPara(@RequestParam("appid") String appid,
- @RequestParam("roles") String roles) {
+ @RequestParam("roles") String roles) {
if (StringUtil.isEmpty(appid) || StringUtil.isEmpty(roles)) {
return JsonResult.error("参数传递错误");
}
@@ -349,7 +350,7 @@
/**
* ====================================================
- * 支付能力配置
+ * 支付能力配置
* ====================================================
*/
@GetMapping("/param/paytype")
@@ -373,4 +374,181 @@
}
}
+ @GetMapping("/param/load4addpaytype")
+ @PreAuthorize("hasPermission('/param/load4addpaytype','')")
+ public String load4AddPaytype(Model model) {
+ return "system/param/paytypeform";
+ }
+
+ @PostMapping("/param/updatepaytypestate")
+ @PreAuthorize("hasPermission('/param/updatepaytypestate','')")
+ @ResponseBody
+ public JsonResult updatePaytypeState(@RequestParam("paytype") String paytype,
+ @RequestParam("state") String state,
+ @RequestParam(value = "optype", required = false) String optype) {
+ if (StringUtil.isEmpty(paytype) || (!ConstantUtil.ENABLE_YES.equals(state) && !ConstantUtil.ENABLE_NO.equals(state)) || (!StringUtil.isEmpty(optype) && !"charge".equals(optype) && !"consume".equals(optype) && !"anonymous".equals(optype))) {
+ return JsonResult.error("参数传递错误");
+ }
+ try {
+ TPaytype tPaytype = paramService.getPaytype(paytype);
+ if (null == tPaytype) {
+ return JsonResult.error("支付方式不存在!");
+ }
+ if ("charge".equals(optype)) {
+ if (state.equals(tPaytype.getChargeEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ tPaytype.setChargeEnable(state);
+ } else if ("consume".equals(optype)) {
+ if (state.equals(tPaytype.getConsumeEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ tPaytype.setConsumeEnable(state);
+ } else if ("anonymous".equals(optype)) {
+ if (state.equals(tPaytype.getAnonymousEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ tPaytype.setAnonymousEnable(state);
+ } else {
+ if (state.equals(tPaytype.getEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ tPaytype.setEnable(state); //默认切换主状态
+ }
+
+ if (paramService.saveOrUpdatePaytype(tPaytype)) {
+ return JsonResult.ok(ConstantUtil.ENABLE_YES.equals(state) ? "启用成功" : "关闭成功");
+ } else {
+ return JsonResult.error(ConstantUtil.ENABLE_YES.equals(state) ? "启用失败" : "关闭失败");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+ @PostMapping("/param/updatepaytypename")
+ @PreAuthorize("hasPermission('/param/updatepaytypename','')")
+ @ResponseBody
+ public JsonResult updatePaytypeName(@RequestParam("paytype") String paytype,
+ @RequestParam("paydesc") String paydesc) {
+ if (StringUtil.isEmpty(paytype) || StringUtil.isEmpty(paydesc)) {
+ return JsonResult.error("参数传递错误");
+ }
+ try {
+ TPaytype tPaytype = paramService.getPaytype(paytype);
+ if (null == tPaytype) {
+ return JsonResult.error("支付方式不存在!");
+ }
+ tPaytype.setPaydesc(paydesc.trim());
+ if (paramService.saveOrUpdatePaytype(tPaytype)) {
+ return JsonResult.ok("修改成功");
+ } else {
+ return JsonResult.error("修改失败");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+ @PostMapping("/param/deletepaytype")
+ @PreAuthorize("hasPermission('/param/deletepaytype','')")
+ @ResponseBody
+ public JsonResult deletePaytype(@RequestParam("paytype") String paytype) {
+ try {
+ TPaytype tPaytype = paramService.getPaytype(paytype);
+ if (null == tPaytype) {
+ return JsonResult.error("支付方式不存在!");
+ }
+ if (paramService.deletePaytype(tPaytype)) {
+ return JsonResult.ok("删除成功");
+ } else {
+ return JsonResult.error("删除失败");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+ @PostMapping("/param/addpaytype")
+ @PreAuthorize("hasPermission('/param/addpaytype','')")
+ @ResponseBody
+ public JsonResult addPaytype(@RequestParam("paytype") String paytype,
+ @RequestParam(value = "enable",required = false,defaultValue = "no") String enable,
+ @RequestParam(value = "chargeEnable",required = false,defaultValue = "no") String chargeEnable,
+ @RequestParam(value = "consumeEnable",required = false,defaultValue = "no") String consumeEnable,
+ @RequestParam(value = "anonymousEnable",required = false,defaultValue = "no") String anonymousEnable,
+ @RequestParam("paydesc") String paydesc) {
+ try {
+ TPaytype tPaytype = paramService.getPaytype(paytype);
+ if (null != tPaytype) {
+ return JsonResult.error("支付方式已经存在");
+ }
+ tPaytype = new TPaytype();
+ tPaytype.setPaytype(paytype.trim());
+ if (StringUtil.isEmpty(paydesc)) return JsonResult.error("支付名称不能为空!");
+ tPaytype.setPaydesc(paydesc.trim());
+ tPaytype.setEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(enable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ tPaytype.setChargeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(chargeEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ tPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(consumeEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ tPaytype.setAnonymousEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(anonymousEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ if (paramService.saveOrUpdatePaytype(tPaytype)) {
+ return JsonResult.ok("新增成功");
+ } else {
+ return JsonResult.error("新增失败");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+ @GetMapping("/param/checkpaytype")
+ @ResponseBody
+ public JsonResult checkPaytype(@RequestParam("paytype") String paytype) {
+ TPaytype tPaytype = paramService.getPaytype(paytype);
+ if (null != tPaytype) {
+ return JsonResult.error("支付方式已经存在");
+ } else {
+ return JsonResult.ok("可以使用");
+ }
+ }
+
+ @GetMapping("/param/load4paytypeconfig")
+ @PreAuthorize("hasPermission('/param/load4paytypeconfig','')")
+ public String load4PaytypeConfig(@RequestParam("paytype") String paytype, Model model) {
+ List<TPaytypeConfig> configList = paramService.getPaytypeConfigList(paytype);
+ model.addAttribute("configlist", configList);
+ model.addAttribute("paytype", paytype);
+ return "system/param/paytypeconfig";
+ }
+
+ @PostMapping("/param/addpaytypeconfig")
+ @PreAuthorize("hasPermission('/param/addpaytypeconfig','')")
+ @ResponseBody
+ public JsonResult addPaytypeConfig(@RequestBody Map<String,String> param){
+ String paytypeHtmlKey = "hid_paytype"; //页面上传来paytype的KEY
+ if(null==param || StringUtil.isEmpty(param.get(paytypeHtmlKey))){
+ return JsonResult.error("参数传递错误");
+ }
+
+ try {
+ String paytype = param.get(paytypeHtmlKey).trim();
+ param.remove(paytypeHtmlKey);
+ if (paramService.savePaytypeConfig(paytype, param)) {
+ return JsonResult.ok("配置成功");
+ } else {
+ return JsonResult.error("配置失败");
+ }
+ } catch (WebCheckException ex) {
+ return JsonResult.error(ex.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java b/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java
index aa5f7ea..4dedc44 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java
@@ -1,13 +1,18 @@
package com.supwisdom.dlpay.system.service;
import com.supwisdom.dlpay.api.domain.TPaytype;
+import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
import com.supwisdom.dlpay.framework.domain.TApiClient;
import com.supwisdom.dlpay.framework.domain.TBusinesspara;
import com.supwisdom.dlpay.framework.domain.TSyspara;
import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.util.WebCheckException;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+import java.util.Map;
+
public interface ParamService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
@@ -46,4 +51,21 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
PageResult<TPaytype> getPaytypePage(String paytype, int pageNo, int pageSize);
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
+ TPaytype getPaytype(String paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean saveOrUpdatePaytype(TPaytype paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean deletePaytype(TPaytype paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
+ List<TPaytypeConfig> getPaytypeConfigList(String paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean savePaytypeConfig(String paytype, Map<String, String> param) throws WebCheckException;
+
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java
index 5ed8ca9..4fff8ce 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java
@@ -1,7 +1,9 @@
package com.supwisdom.dlpay.system.service.impl;
+import com.supwisdom.dlpay.api.dao.PaytypeConfigDao;
import com.supwisdom.dlpay.api.dao.PaytypeDao;
import com.supwisdom.dlpay.api.domain.TPaytype;
+import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
import com.supwisdom.dlpay.framework.dao.ApiClientDao;
import com.supwisdom.dlpay.framework.dao.BusinessparaDao;
import com.supwisdom.dlpay.framework.dao.SysparaDao;
@@ -12,6 +14,7 @@
import com.supwisdom.dlpay.framework.util.StringUtil;
import com.supwisdom.dlpay.system.service.ParamService;
import com.supwisdom.dlpay.util.ConstantUtil;
+import com.supwisdom.dlpay.util.WebCheckException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -26,6 +29,7 @@
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
@Service
@@ -38,6 +42,8 @@
private ApiClientDao apiClientDao;
@Autowired
private PaytypeDao paytypeDao;
+ @Autowired
+ private PaytypeConfigDao paytypeConfigDao;
@Override
public PageResult<TSyspara> getSysparaPage(Integer paraid, String paraname, int pageNo, int pageSize) {
@@ -152,4 +158,56 @@
return new PageResult<>(paytypeDao.findAll(pageable));
}
+ @Override
+ public TPaytype getPaytype(String paytype) {
+ if (!StringUtil.isEmpty(paytype)) {
+ return paytypeDao.getByPaytype(paytype.trim());
+ }
+ return null;
+ }
+
+ @Override
+ public boolean saveOrUpdatePaytype(TPaytype paytype){
+ if(null!=paytype){
+ paytypeDao.save(paytype);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean deletePaytype(TPaytype paytype){
+ if(null!=paytype){
+ paytypeDao.delete(paytype);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<TPaytypeConfig> getPaytypeConfigList(String paytype) {
+ if (!StringUtil.isEmpty(paytype)) {
+ List<TPaytypeConfig> list = paytypeConfigDao.getByPaytype(paytype.trim());
+ if (!StringUtil.isEmpty(list))
+ return list;
+ }
+ return new ArrayList<>(0);
+ }
+
+ @Override
+ public boolean savePaytypeConfig(String paytype, Map<String, String> param) throws WebCheckException {
+ TPaytype tPaytype = getPaytype(paytype);
+ if (null == tPaytype) throw new WebCheckException("支付能力[" + paytype + "]不存在");
+ for (String key : param.keySet()) {
+ String value = param.get(key);
+ TPaytypeConfig config = paytypeConfigDao.getByPaytypeAndAndConfigid(tPaytype.getPaytype(), key);
+ if (null == config) throw new WebCheckException("支付能力[" + tPaytype.getPaytype() + "]不存在配置项[" + key + "],请重新查询");
+ config.setConfigValue(StringUtil.isEmpty(value) ? null : value.trim());
+ paytypeConfigDao.save(config);
+ }
+ return true;
+ }
+
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/util/WebCheckException.java b/src/main/java/com/supwisdom/dlpay/util/WebCheckException.java
new file mode 100644
index 0000000..42e72d4
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/util/WebCheckException.java
@@ -0,0 +1,7 @@
+package com.supwisdom.dlpay.util;
+
+public class WebCheckException extends Exception {
+ public WebCheckException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/resources/templates/system/param/paytype.html b/src/main/resources/templates/system/param/paytype.html
index 8f9883a..63a0cee 100644
--- a/src/main/resources/templates/system/param/paytype.html
+++ b/src/main/resources/templates/system/param/paytype.html
@@ -13,38 +13,48 @@
placeholder="输入支付方式查询"/>
<button id="btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
</button>
- <button id="btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>新 增</button>
- <button id="btn-reset" class="layui-btn layui-btn-primary" data-type="reset"><i class="layui-icon"></i>清 空</button>
+ <button id="btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>新 增
+ </button>
+ <button id="btn-reset" class="layui-btn layui-btn-primary" data-type="reset"><i class="layui-icon"></i>清 空
+ </button>
</div>
<table class="layui-table" id="paytypeTable" lay-filter="paytypeTable-filter"></table>
</div>
</div>
-<!-- 表格操作列 -->
-<script type="text/html" id="paytype-table-bar">
- {{# if(d.paytype == 'balance') { }}
- <span></span>
- {{# }else{ }}
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
- {{# } }}
-</script>
-
<!-- 表格状态列 -->
<script type="text/html" id="enable-tpl-state">
<input type="checkbox" lay-filter="enable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
- {{d.enable=='yes'?'checked':''}} />
+ {{d.enable=='yes'?'checked':''}}/>
</script>
<script type="text/html" id="chargeenable-tpl-state">
+ {{# if(d.enable =='yes'){ }}
<input type="checkbox" lay-filter="chargeenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
- {{(d.enable=='yes' && d.chargeEnable=='yes')?'checked':''}} />
+ {{(d.enable=='yes' && d.chargeEnable=='yes')?'checked':''}}/>
+ {{# }else{ }}
+ <input type="checkbox" lay-filter="chargeenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
+ {{(d.enable=='yes' && d.chargeEnable=='yes')?'checked':''}} disabled/>
+ {{# } }}
</script>
<script type="text/html" id="consumeenable-tpl-state">
+ {{# if(d.enable =='yes'){ }}
<input type="checkbox" lay-filter="consumeenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
- {{(d.enable=='yes' && d.consumeEnable=='yes')?'checked':''}} />
+ {{(d.enable=='yes' && d.consumeEnable=='yes')?'checked':''}}/>
+ {{# }else{ }}
+ <input type="checkbox" lay-filter="consumeenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
+ {{(d.enable=='yes' && d.consumeEnable=='yes')?'checked':''}} disabled/>
+ {{# } }}
</script>
<script type="text/html" id="anonymousenable-tpl-state">
- <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
- {{(d.enable=='yes' && d.anonymousEnable=='yes')?'checked':''}} />
+ {{# if(d.enable =='yes' ){ }}
+ <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.paytype}}" lay-skin="switch"
+ lay-text="启用|关闭"
+ {{(d.enable=='yes' && d.anonymousEnable=='yes')?'checked':''}}/>
+ {{# }else{ }}
+ <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.paytype}}" lay-skin="switch"
+ lay-text="启用|关闭"
+ {{(d.enable=='yes' && d.anonymousEnable=='yes')?'checked':''}} disabled/>
+ {{# } }}
</script>
<script>
@@ -60,18 +70,37 @@
cols: [
[
{field: 'paytype', title: '支付方式', width: 200, align: 'center', fixed: 'left', sort: true},
- {field: 'paydesc', title: '名称', align: 'center', sort: true},
- {field: 'enable', title: '状态', align: 'center', templet: '#enable-tpl-state',sort: true},
- {field: 'chargeEnable', title: '能否充值', align: 'center', templet: '#chargeenable-tpl-state',sort: true},
- {field: 'consumeEnable', title: '能否消费', align: 'center', templet: '#consumeenable-tpl-state',sort: true},
- {field: 'anonymousEnable', title: '匿名消费', align: 'center', templet: '#anonymousenable-tpl-state',sort: true},
- {align: 'center', title: '操作', width: 100, fixed: 'right', templet: function(item){
- if(item.paytype!='balance') {
- return '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
- }else{
+ {field: 'paydesc', title: '名称', align: 'center', sort: true, edit:'text'},
+ {field: 'enable', title: '状态', align: 'center', templet: '#enable-tpl-state', sort: true},
+ {
+ field: 'chargeEnable',
+ title: '能否充值',
+ align: 'center',
+ templet: '#chargeenable-tpl-state',
+ sort: true
+ },
+ {
+ field: 'consumeEnable',
+ title: '能否消费',
+ align: 'center',
+ templet: '#consumeenable-tpl-state',
+ sort: true
+ },
+ {
+ field: 'anonymousEnable',
+ title: '匿名消费',
+ align: 'center',
+ templet: '#anonymousenable-tpl-state',
+ sort: true
+ },
+ {
+ align: 'center', title: '操作', width: 150, fixed: 'right', templet: function (item) {
+ if (item.paytype != 'balance') {
+ return '<a class="layui-btn layui-btn-xs" lay-event="config">配置</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
+ }
return '';
}
- }}
+ }
]
]
});
@@ -82,110 +111,153 @@
});
$('#btn-add').click(function () {
- showEditModel();
+ admin.popupCenter({
+ title: "新增支付能力",
+ path: '/param/load4addpaytype',
+ finish: function () {
+ table.reload('paytypeTable');
+ }
+ });
});
$('#btn-reset').click(function () {
$("#search-paytypeTable").val("");
});
- // function showEditModel(data) {
- // var title = data ? '修改角色' : '新增应用';
- // admin.putTempData('t_appclient', data);
- // admin.popupCenter({
- // title: title,
- // path: '/param/load4addapiclient',
- // finish: function () {
- // table.reload('apiClientTable');
- // }
- // });
- // }
- //
- // // 修改user状态
- // form.on('switch(api-tpl-state)', function (obj) {
- // var token = $("meta[name='_csrf_token']").attr("value");
- // admin.go('/param/updateapiclientstate', {
- // appid: obj.elem.value,
- // state: obj.elem.checked ? 'normal' : 'closed',
- // _csrf: token
- // }, function (data) {
- // if (data.code == 200) {
- // layer.msg(data.msg, {icon: 1});
- // } else if (data.code == 401) {
- // layer.msg(data.msg, {icon: 2, time: 1500}, function () {
- // location.replace('/login');
- // }, 1000);
- // return;
- // } else {
- // layer.msg(data.msg, {icon: 2});
- // $(obj.elem).prop('checked', !obj.elem.checked);
- // form.render('checkbox');
- // }
- // },function () {
- // layer.msg('请求失败了,请稍后再试', {icon: 2});
- // $(obj.elem).prop('checked', !obj.elem.checked);
- // form.render('checkbox');
- // });
- // });
- //
- // //监听单元格
- // table.on('tool(apiClientTable-filter)', function (obj) {
- // var data = obj.data;
- // if('del' == obj.event){
- // if(confirm("确定要删除应用参数["+data.appid+"]吗?")){
- // layer.load(2);
- // admin.go('/param/deleteapiclient', {
- // appid: data.appid,
- // _csrf: $("meta[name='_csrf_token']").attr("value")
- // }, function (data) {
- // console.log(data.code);
- // layer.closeAll('loading');
- // if (data.code == 200) {
- // layer.msg(data.msg, {icon: 1});
- // } else if (data.code == 401) {
- // layer.msg(data.msg, {icon: 2, time: 1500}, function () {
- // location.replace('/login');
- // }, 1000);
- // return;
- // } else {
- // layer.msg(data.msg, {icon: 2});
- // }
- // table.reload('apiClientTable');
- // }, function (ret) {
- // console.log(ret);
- // layer.closeAll('loading');
- // layer.msg('请求失败了,请稍后再试', {icon: 2});
- // });
- // }
- // }else if('editRole' ==obj.event){
- // showEditModel(data);
- // }
- // });
- //
- // table.on('edit(apiClientTable-filter)', function (obj) {
- // var row = obj.data; //得到所在行所有键值
- // var newval = obj.value; //得到修改后的值
- // admin.go('/param/updateapiclientpara', {
- // appid: row.appid,
- // secret: newval,
- // _csrf: $("meta[name='_csrf_token']").attr("value"),
- // }, function (data) {
- // if (data.code == 200) {
- // layer.msg("修改成功", {icon: 1});
- // } else if (data.code == 401) {
- // layer.msg(data.msg, {icon: 2, time: 1500}, function () {
- // location.replace('/login');
- // }, 1000);
- // return;
- // } else {
- // layer.msg(data.msg, {icon: 2});
- // table.reload('apiClientTable');
- // }
- // },function () {
- // layer.msg('修改失败了,请稍后再试', {icon: 2});
- // table.reload('apiClientTable');
- // });
- // })
+ // 修改总状态
+ form.on('switch(enable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ admin.go('/param/updatepaytypestate', {
+ paytype: obj.elem.value,
+ state: obj.elem.checked ? 'yes' : 'no',
+ _csrf: token
+ }, function (data) {
+ if (data.code == 200) {
+ layer.msg(data.msg, {icon: 1, time:1000});
+ table.reload('paytypeTable');
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ $(obj.elem).prop('checked', !obj.elem.checked);
+ form.render('checkbox');
+ }
+ },function () {
+ layer.msg('请求失败了,请稍后再试', {icon: 2});
+ $(obj.elem).prop('checked', !obj.elem.checked);
+ form.render('checkbox');
+ });
+ });
+ form.on('switch(chargeenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ updatePaytypeState(obj, "charge", token);
+ });
+
+ form.on('switch(consumeenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ updatePaytypeState(obj, "consume", token);
+ });
+
+ form.on('switch(anonymousenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ updatePaytypeState(obj, "anonymous", token);
+ });
+
+
+ function updatePaytypeState(obj, optype, token) {
+ admin.go('/param/updatepaytypestate', {
+ paytype: obj.elem.value,
+ state: obj.elem.checked ? 'yes' : 'no',
+ optype: optype,
+ _csrf: token
+ }, function (data) {
+ if (data.code == 200) {
+ layer.msg(data.msg, {icon: 1, time: 1000});
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ $(obj.elem).prop('checked', !obj.elem.checked);
+ form.render('checkbox');
+ }
+ }, function () {
+ layer.msg('请求失败了,请稍后再试', {icon: 2});
+ $(obj.elem).prop('checked', !obj.elem.checked);
+ form.render('checkbox');
+ });
+ }
+
+ table.on('edit(paytypeTable-filter)', function (obj) {
+ var row = obj.data; //得到所在行所有键值
+ var newval = obj.value; //得到修改后的值
+ admin.go('/param/updatepaytypename', {
+ paytype: row.paytype,
+ paydesc: newval,
+ _csrf: $("meta[name='_csrf_token']").attr("value"),
+ }, function (data) {
+ if (data.code == 200) {
+ layer.msg("修改成功", {icon: 1, time: 1000});
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ table.reload('paytypeTable');
+ }
+ },function () {
+ layer.msg('修改失败了,请稍后再试', {icon: 2});
+ table.reload('paytypeTable');
+ });
+ })
+
+ //监听单元格
+ table.on('tool(paytypeTable-filter)', function (obj) {
+ var data = obj.data;
+ if('del' == obj.event){
+ if (confirm("确定要删除支付方式[" + data.paytype + "_" + data.paydesc + "]吗?")) {
+ layer.load(2);
+ admin.go('/param/deletepaytype', {
+ paytype: data.paytype,
+ _csrf: $("meta[name='_csrf_token']").attr("value")
+ }, function (data) {
+ console.log(data.code);
+ layer.closeAll('loading');
+ if (data.code == 200) {
+ layer.msg(data.msg, {icon: 1, time: 1000});
+ } else if (data.code == 401) {
+ layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ layer.msg(data.msg, {icon: 2});
+ }
+ table.reload('paytypeTable');
+ }, function (ret) {
+ console.log(ret);
+ layer.closeAll('loading');
+ layer.msg('请求失败了,请稍后再试', {icon: 2});
+ });
+ }
+ }else if('config' ==obj.event){
+ admin.popupCenter({
+ title: "配置参数【" + data.paytype + "_" + data.paydesc + "】",
+ path: '/param/load4paytypeconfig?paytype='+data.paytype,
+ area: '800px',
+ finish: function () {
+ table.reload('paytypeTable');
+ }
+ });
+ }
+ });
});
</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/system/param/paytypeconfig.html b/src/main/resources/templates/system/param/paytypeconfig.html
new file mode 100644
index 0000000..180e578
--- /dev/null
+++ b/src/main/resources/templates/system/param/paytypeconfig.html
@@ -0,0 +1,73 @@
+<form id="paytype-config-form" lay-filter="paytype-config-form" class="layui-form model-form">
+ <div class="layui-form-item" style="display: none;">
+ <input type="hidden" class="layui-input" id="hid_paytype" th:value="${paytype}"/>
+ </div>
+
+ <div class="layui-form-item" style="text-align: center;" th:if="${configlist.size()} le 0">
+ 无配置项
+ </div>
+
+ <div class="layui-form-item" th:if="${configlist.size()} gt 0" th:each="config:${configlist}">
+ <label class="layui-form-label" th:text="${config.configid}">参数名</label>
+ <div class="layui-input-block">
+ <input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}"/>
+ </div>
+ </div>
+
+ <div class="layui-form-item model-form-footer">
+ <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
+ <button class="layui-btn" lay-filter="form-submit" lay-submit id="submitbtn">保存</button>
+ </div>
+</form>
+
+
+<script>
+ layui.use(['layer', 'admin', 'form'], function () {
+ var layer = layui.layer;
+ var admin = layui.admin;
+ var form = layui.form;
+ // 表单提交事件
+ form.on('submit(form-submit)', function (data) {
+ layer.load(2);
+ var vdata = data.field;
+ if(vdata.length <=0){
+ admin.finishPopupCenter();
+ return; //无配置项,直接关闭
+ }
+ var token=$("meta[name='_csrf_token']").attr("value");
+ vdata["hid_paytype"] = $("#hid_paytype").val();
+ debugger
+ $.ajax({
+ type : "POST",
+ dataType : "json",
+ url : '/param/addpaytypeconfig',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ 'X-CSRF-TOKEN':token,
+ },
+ data : JSON.stringify(vdata),
+ success : function(result) {
+ layer.closeAll('loading');
+ if (result.code == 200) {
+ layer.msg(result.msg, {icon: 1});
+ admin.finishPopupCenter();
+ } else if (result.code == 401) {
+ layer.msg(result.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ console.log('err:' + result.code);
+ layer.msg(result.msg, {icon: 2});
+ }
+ },
+ error : function() {
+ layer.closeAll('loading');
+ layer.msg("请求服务器失败!", {icon: 2});
+ }
+ });
+ return false;
+ });
+ });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/system/param/paytypeform.html b/src/main/resources/templates/system/param/paytypeform.html
new file mode 100644
index 0000000..705c9b2
--- /dev/null
+++ b/src/main/resources/templates/system/param/paytypeform.html
@@ -0,0 +1,115 @@
+<form id="paytype-form" lay-filter="form" class="layui-form model-form">
+ <div class="layui-form-item">
+ <label class="layui-form-label">支付方式</label>
+ <div class="layui-input-block">
+ <input name="paytype" placeholder="请输入支付方式代码" type="text" class="layui-input" maxlength="20"
+ lay-verify="required|paytype" required/>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">名称</label>
+ <div class="layui-input-block">
+ <input name="paydesc" placeholder="请输入支付方式名称" type="text" class="layui-input" maxlength="30"
+ lay-verify="required" required/>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">状态</label>
+ <div class="layui-input-block">
+ <input name="enable" type="checkbox" lay-skin="switch" lay-text="启用|关闭" value="yes" lay-verify="required" checked/>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <label class="layui-form-label">能否充值</label>
+ <div class="layui-input-block">
+ <input name="chargeEnable" type="checkbox" lay-skin="switch" lay-text="启用|关闭" value="yes" lay-verify="required" checked/>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <label class="layui-form-label">能否消费</label>
+ <div class="layui-input-block">
+ <input name="consumeEnable" type="checkbox" lay-skin="switch" lay-text="启用|关闭" value="yes" lay-verify="required" checked/>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
+ <label class="layui-form-label">匿名消费</label>
+ <div class="layui-input-block">
+ <input name="anonymousEnable" type="checkbox" lay-skin="switch" lay-text="启用|关闭" value="yes" lay-verify="required" checked/>
+ </div>
+ </div>
+
+ <div class="layui-form-item model-form-footer">
+ <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
+ <button class="layui-btn" lay-filter="form-submit" lay-submit id="submitbtn">保存</button>
+ </div>
+</form>
+
+
+<script>
+ layui.use(['layer', 'admin', 'form'], function () {
+ var layer = layui.layer;
+ var admin = layui.admin;
+ var form = layui.form;
+ form.render('checkbox');
+ form.verify({
+ "paytype": function (e) {
+ var msg = "";
+ $.ajax({
+ type: "GET",
+ url: '/param/checkpaytype',
+ async: false,
+ data: {
+ paytype: e
+ },
+ success: function (result) {
+ if (result.code != 200) {
+ msg = result.msg;
+ }
+ },
+ error: function (error) {
+ msg = "请求服务器校验支付方式失败";
+ }
+ });
+ if (msg != "") {
+ return msg;
+ }
+ }
+ });
+
+ // 表单提交事件
+ form.on('submit(form-submit)', function (data) {
+ layer.load(2);
+ var vdata = data.field;
+ vdata["_csrf"] = $("meta[name='_csrf_token']").attr("value");
+ $.ajax({
+ type : "POST",
+ dataType : "json",
+ url : '/param/addpaytype',
+ data : vdata,
+ success : function(result) {
+ layer.closeAll('loading');
+ if (result.code == 200) {
+ layer.msg(result.msg, {icon: 1});
+ admin.finishPopupCenter();
+ } else if (result.code == 401) {
+ layer.msg(result.msg, {icon: 2, time: 1500}, function () {
+ location.replace('/login');
+ }, 1000);
+ return;
+ } else {
+ console.log('err:' + result.code);
+ layer.msg(result.msg, {icon: 2});
+ }
+ },
+ error : function() {
+ layer.closeAll('loading');
+ layer.msg("请求服务器失败!", {icon: 2});
+ }
+ });
+ return false;
+ });
+ });
+</script>
\ No newline at end of file