商户支付能力配置
diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java
index 036161a..a7164c8 100644
--- a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java
+++ b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeConfigDao.java
@@ -11,4 +11,7 @@
public interface ShopPaytypeConfigDao extends JpaRepository<TShopPaytypeConfig, String> {
@Query("select a from TShopPaytypeConfig a where a.paytype=?1 and a.shopaccno=?2 ")
List<TShopPaytypeConfig> getShopPaytypeConfigs(String paytype, String shopaccno);
+
+ @Query("select a from TShopPaytypeConfig a where a.shopaccno=?1 and a.paytype=?2 and a.configid=?3 ")
+ TShopPaytypeConfig getShopPaytypeConfigById(String shopaccno,String paytype, String configid);
}
diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java
index 4d9fd72..acea209 100644
--- a/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java
+++ b/src/main/java/com/supwisdom/dlpay/api/domain/TShopPaytypeConfig.java
@@ -11,7 +11,7 @@
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
@Column(name = "CFGID", nullable = false, length = 32)
- private Integer cfgid;
+ private String cfgid;
@Column(name = "SHOPACCNO", nullable = false, length = 10)
private String shopaccno;
@@ -39,11 +39,11 @@
this.configName = configName;
}
- public Integer getCfgid() {
+ public String getCfgid() {
return cfgid;
}
- public void setCfgid(Integer cfgid) {
+ public void setCfgid(String cfgid) {
this.cfgid = cfgid;
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java b/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
index cd18d0a..61e122e 100644
--- a/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
+++ b/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java
@@ -9,6 +9,7 @@
private boolean open;
private Integer shoptype; //商户类别,商户树用到
+ private String shopaccno; //商户账号
private String iconSkin; //自定义图标
public boolean isOpen() {
@@ -59,6 +60,14 @@
this.shoptype = shoptype;
}
+ public String getShopaccno() {
+ return shopaccno;
+ }
+
+ public void setShopaccno(String shopaccno) {
+ this.shopaccno = shopaccno;
+ }
+
public String getIconSkin() {
return iconSkin;
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
index 5f09c4e..2aba10b 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java
@@ -3,13 +3,18 @@
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.api.domain.TPaytype;
import com.supwisdom.dlpay.api.domain.TShopPaytype;
+import com.supwisdom.dlpay.api.domain.TShopPaytypeConfig;
import com.supwisdom.dlpay.framework.domain.TShop;
+import com.supwisdom.dlpay.framework.domain.TShopacc;
+import com.supwisdom.dlpay.framework.service.SystemUtilService;
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.framework.util.StringUtil;
import com.supwisdom.dlpay.framework.util.TradeDict;
import com.supwisdom.dlpay.framework.util.WebConstant;
import com.supwisdom.dlpay.system.bean.ShopConfigBean;
+import com.supwisdom.dlpay.system.service.ParamService;
import com.supwisdom.dlpay.system.service.ShopDataService;
+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;
@@ -17,10 +22,17 @@
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
+import java.util.Map;
+
@Controller
public class ShopController {
@Autowired
private ShopDataService shopDataService;
+ @Autowired
+ private ParamService paramService;
+ @Autowired
+ private SystemUtilService systemUtilService;
@GetMapping("/shop/index")
public String shopView() {
@@ -30,7 +42,7 @@
@GetMapping("/shop/shoptree")
@PreAuthorize("hasPermission('/shop/index','')")
@ResponseBody
- public JsonResult shopTreeData(){
+ public JsonResult shopTreeData() {
return JsonResult.ok("OK").put("data", shopDataService.getAllShopNodes());
}
@@ -39,19 +51,19 @@
@ResponseBody
public JsonResult deleteShop(@RequestParam("shopid") Integer shopid) {
TShop shop = shopDataService.getShopByShopid(shopid);
- if(null==shop){
+ if (null == shop) {
return JsonResult.error("商户不存在,请重新查询"); //商户不存在,请重新查询
}
- try{
- if(shopDataService.deleteShop(shop)){
+ try {
+ if (shopDataService.deleteShop(shop)) {
return JsonResult.ok("删除成功");
- }else{
+ } else {
return JsonResult.error("删除失败");
}
- }catch (WebCheckException ex){
+ } catch (WebCheckException ex) {
return JsonResult.error(ex.getMessage());
- }catch (Exception e){
+ } catch (Exception e) {
return JsonResult.error("系统处理异常").put("exception", e);
}
}
@@ -124,22 +136,23 @@
shop.setAddr(addr == null ? null : addr.trim());
shop.setZipcode(zipcode == null ? null : zipcode.trim());
- try{
- if(shopDataService.saveOrUpdateShop(shop)){
- return JsonResult.ok(addflag?"新增成功":"修改成功").put("shop",shop);
- }else{
- return JsonResult.error(addflag?"新增失败":"修改失败");
+ try {
+ if (shopDataService.saveOrUpdateShop(shop)) {
+ return JsonResult.ok(addflag ? "新增成功" : "修改成功").put("shop", shop);
+ } else {
+ return JsonResult.error(addflag ? "新增失败" : "修改失败");
}
- }catch (WebCheckException ex){
+ } catch (WebCheckException ex) {
return JsonResult.error(ex.getMessage());
- }catch (Exception e){
+ } catch (Exception e) {
+ e.printStackTrace();
return JsonResult.error("系统处理异常").put("exception", e);
}
}
/**
* ====================================================
- * 商户支付能力配置
+ * 商户支付能力配置
* ====================================================
*/
@GetMapping("/shop/config")
@@ -151,7 +164,7 @@
@GetMapping("/shop/shopacctree")
@PreAuthorize("hasPermission('/shop/config','')")
@ResponseBody
- public JsonResult shopaccTreeData(){
+ public JsonResult shopaccTreeData() {
return JsonResult.ok("OK").put("data", shopDataService.getAllShopNodes());
}
@@ -160,17 +173,151 @@
@ResponseBody
public PageResult<ShopConfigBean> getShopPaytypeList(@RequestParam("page") Integer pageNo,
@RequestParam("limit") Integer pageSize,
- @RequestParam(value = "shopid", required = false) Integer shopid,
@RequestParam(value = "paytype", required = false) String paytype,
@RequestParam(value = "shopaccno", required = false) String shopaccno) {
try {
if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;
if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;
- return shopDataService.getShopPaytypeInfos(shopaccno, paytype, shopid, pageNo, pageSize);
+ return shopDataService.getShopPaytypeInfos(shopaccno, paytype, pageNo, pageSize);
} catch (Exception e) {
e.printStackTrace();
return new PageResult<>(99, "系统查询错误");
}
}
+ @PostMapping("/shop/updatepaytypestat")
+ @PreAuthorize("hasPermission('/shop/updatepaytypestat','')")
+ @ResponseBody
+ public JsonResult updateShopPaytypeStat(@RequestParam("shopaccno") String shopaccno, @RequestParam("paytype") String paytype,
+ @RequestParam("state") String state, @RequestParam("optype") String optype) {
+ if (StringUtil.isEmpty(shopaccno) || StringUtil.isEmpty(paytype)
+ || (!ConstantUtil.ENABLE_NO.equals(state) && !ConstantUtil.ENABLE_YES.equals(state))
+ || (!"consume".equals(optype) && !"anonymous".equals(optype) && !"reverse".equals(optype))) {
+ return JsonResult.error("参数传递错误");
+ }
+
+ try {
+ TShopPaytype shopPaytype = shopDataService.getShopPaytype(shopaccno.trim(), paytype.trim());
+ if (null == shopPaytype) {
+ return JsonResult.error("商户支付能力不存在!");
+ }
+
+ if ("consume".equals(optype)) {
+ if (state.equals(shopPaytype.getConsumeEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ shopPaytype.setConsumeEnable(state);
+ } else if ("anonymous".equals(optype)) {
+ if (state.equals(shopPaytype.getAnonymousEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ shopPaytype.setAnonymousEnable(state);
+ } else if ("reverse".equals(optype)) {
+ if (state.equals(shopPaytype.getReverseEnable())) {
+ return JsonResult.error("状态错误,请重新查询后操作");
+ }
+ shopPaytype.setReverseEnable(state);
+ }
+
+ if (shopDataService.saveOrUpdateShopPaytype(shopPaytype)) {
+ 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);
+ }
+ }
+
+ @GetMapping("/shop/load4addpaytype")
+ @PreAuthorize("hasPermission('/shop/load4addpaytype','')")
+ public String load4AddShopPaytype(Model model){
+ model.addAttribute("paytypelist", shopDataService.getConsumePaytypes());
+ return "system/shop/configform";
+ }
+
+ @PostMapping("/shop/addshoppaytype")
+ @PreAuthorize("hasPermission('/shop/addshoppaytype','')")
+ @ResponseBody
+ public JsonResult addShoppaytype(@RequestParam("shopaccno") String shopaccno,
+ @RequestParam("paytype") String paytype,
+ @RequestParam(value = "consumeEnable", required = false, defaultValue = "no") String consumeEnable,
+ @RequestParam(value = "anonymousEnable", required = false, defaultValue = "no") String anonymousEnable,
+ @RequestParam(value = "reverseEnable", required = false, defaultValue = "no") String reverseEnable) {
+ if(StringUtil.isEmpty(shopaccno) || StringUtil.isEmpty(paytype)){
+ return JsonResult.error("参数传递错误");
+ }
+ try {
+ TShopacc shopacc = shopDataService.getShopaccByAccno(shopaccno.trim());
+ TPaytype tPaytype = paramService.getPaytype(paytype.trim());
+ if (null == shopacc) {
+ return JsonResult.error("商户账户不存在!");
+ }
+ if (null == tPaytype) {
+ return JsonResult.error("支付方式在系统中不存在!");
+ }
+ TShopPaytype shopPaytype = shopDataService.getShopPaytype(shopaccno.trim(), paytype.trim());
+ if (null != shopPaytype) {
+ return JsonResult.error("商户该支付能力已经存在!");
+ }
+ shopPaytype = new TShopPaytype();
+ shopPaytype.setShopaccno(shopacc.getShopaccno());
+ shopPaytype.setPaytype(tPaytype.getPaytype());
+ shopPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(consumeEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ shopPaytype.setAnonymousEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(anonymousEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ shopPaytype.setReverseEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(reverseEnable) ? ConstantUtil.ENABLE_YES : ConstantUtil.ENABLE_NO);
+ shopPaytype.setCreatetime(systemUtilService.getSysdatetime().getHostdatetime());
+ if (shopDataService.saveOrUpdateShopPaytype(shopPaytype)) {
+ return JsonResult.ok("新增成功");
+ } else {
+ return JsonResult.error("新增失败");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return JsonResult.error("系统处理异常").put("exception", e);
+ }
+ }
+
+ @GetMapping("/shop/load4paytypepara")
+ @PreAuthorize("hasPermission('/shop/load4paytypepara','')")
+ public String load4AddShopPaytypePara(@RequestParam("shopaccno") String shopaccno,
+ @RequestParam("paytype") String paytype,
+ Model model) {
+ List<TShopPaytypeConfig> configList = shopDataService.getShopPaytypeConfigs(shopaccno, paytype);
+ model.addAttribute("configlist", configList);
+ model.addAttribute("shopaccno", shopaccno);
+ model.addAttribute("paytype", paytype);
+ return "system/shop/configpara";
+ }
+
+ @PostMapping("/shop/addpaytypepara")
+ @PreAuthorize("hasPermission('/shop/addpaytypepara','')")
+ @ResponseBody
+ public JsonResult addShopPaytypePara(@RequestBody Map<String, String> param) {
+ String shopaccnoHtmlKey = "hid_shopaccno"; //页面上传来shopaccno的KEY
+ String paytypeHtmlKey = "hid_paytype"; //页面上传来paytype的KEY
+ if (null == param || StringUtil.isEmpty(param.get(paytypeHtmlKey)) || StringUtil.isEmpty(param.get(shopaccnoHtmlKey))) {
+ return JsonResult.error("参数传递错误");
+ }
+ try {
+ String shopaccno = param.get(shopaccnoHtmlKey).trim();
+ String paytype = param.get(paytypeHtmlKey).trim();
+ param.remove(shopaccnoHtmlKey);
+ param.remove(paytypeHtmlKey);
+ if (shopDataService.saveOrUpdateShopPaytypeConfig(shopaccno, 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/ShopDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
index fe9ce27..63b9f27 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java
@@ -1,7 +1,10 @@
package com.supwisdom.dlpay.system.service;
import com.supwisdom.dlpay.api.domain.TPaytype;
+import com.supwisdom.dlpay.api.domain.TShopPaytype;
+import com.supwisdom.dlpay.api.domain.TShopPaytypeConfig;
import com.supwisdom.dlpay.framework.domain.TShop;
+import com.supwisdom.dlpay.framework.domain.TShopacc;
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.system.bean.ShopConfigBean;
import com.supwisdom.dlpay.system.bean.ZTreeNode;
@@ -10,6 +13,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
+import java.util.Map;
public interface ShopDataService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
@@ -28,5 +32,22 @@
List<TPaytype> getConsumePaytypes();
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
- PageResult<ShopConfigBean> getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize);
+ PageResult<ShopConfigBean> getShopPaytypeInfos(String shopaccno, String paytype, int pageNo, int pageSize);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ TShopPaytype getShopPaytype(String shopaccno, String paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ TShopacc getShopaccByAccno(String shopaccno);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean saveOrUpdateShopPaytype(TShopPaytype shopPaytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
+ List<TShopPaytypeConfig> getShopPaytypeConfigs(String shopaccno, String paytype);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ boolean saveOrUpdateShopPaytypeConfig(String shopaccno, String paytype, Map<String, String> param) throws WebCheckException;
+
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
index 75722c7..37101ad 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java
@@ -1,9 +1,13 @@
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.dao.ShopPaytypeConfigDao;
import com.supwisdom.dlpay.api.dao.ShopPaytypeDao;
import com.supwisdom.dlpay.api.domain.TPaytype;
+import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
import com.supwisdom.dlpay.api.domain.TShopPaytype;
+import com.supwisdom.dlpay.api.domain.TShopPaytypeConfig;
import com.supwisdom.dlpay.framework.dao.ShopDao;
import com.supwisdom.dlpay.framework.dao.ShopaccDao;
import com.supwisdom.dlpay.framework.data.SystemDateTime;
@@ -30,6 +34,7 @@
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
@Service
public class ShopDataServiceImpl implements ShopDataService {
@@ -43,6 +48,10 @@
private SystemUtilService systemUtilService;
@Autowired
private PaytypeDao paytypeDao;
+ @Autowired
+ private PaytypeConfigDao paytypeConfigDao;
+ @Autowired
+ private ShopPaytypeConfigDao shopPaytypeConfigDao;
@Override
public List<ZTreeNode> getAllShopNodes() {
@@ -53,12 +62,13 @@
if (null == shop || !TradeDict.STATUS_NORMAL.equals(shop.getStatus())) continue; //跳过注销商户
ZTreeNode node = new ZTreeNode();
node.setId(shop.getShopid().toString());
- node.setName(shop.getShopid()+"_"+shop.getShopname());
+ node.setName(shop.getShopid() + "_" + shop.getShopname());
node.setpId(shop.getFshopid() == null ? "" : shop.getFshopid().toString());
node.setChecked(false);
node.setOpen(true);
node.setShoptype(shop.getShoptype());
- node.setIconSkin(shop.getShoptype()==0?"pIcon01":"pIcon02");
+ node.setShopaccno(StringUtil.isEmpty(shop.getShopaccno()) ? "" : shop.getShopaccno());
+ node.setIconSkin(shop.getShoptype() == 0 ? "pIcon01" : "pIcon02");
result.add(node);
}
}
@@ -74,17 +84,17 @@
}
@Override
- public boolean deleteShop(TShop shop) throws WebCheckException{
- if(null!=shop){
+ public boolean deleteShop(TShop shop) throws WebCheckException {
+ if (null != shop) {
List<TShop> childShops = shopDao.getChildShopsByShopid(shop.getShopid());
- if(!StringUtil.isEmpty(childShops))
+ if (!StringUtil.isEmpty(childShops))
throw new WebCheckException("请先删除下级商户");
shop.setStatus(TradeDict.STATUS_CLOSED);
shop.setClosedate(systemUtilService.getSysdatetime().getHostdate());
shopDao.save(shop);
- if(!StringUtil.isEmpty(shop.getShopaccno())){
- TShopacc shopacc=shopaccDao.getByShopaccno(shop.getShopaccno());
- if(null==shopacc) throw new WebCheckException("数据异常!对应的商户账户不存在!");
+ if (!StringUtil.isEmpty(shop.getShopaccno())) {
+ TShopacc shopacc = shopaccDao.getByShopaccno(shop.getShopaccno());
+ if (null == shopacc) throw new WebCheckException("数据异常!对应的商户账户不存在!");
shopacc.setStatus(TradeDict.STATUS_CLOSED);
shopacc.setClosedate(shop.getClosedate());
shopaccDao.save(shopacc);
@@ -100,7 +110,7 @@
TShop fshop = shopDao.getTShopByShopid(shop.getFshopid());
if (null == fshop) {
throw new WebCheckException("上级商户不存在!");
- }else if(fshop.getShoptype()==1){
+ } else if (fshop.getShoptype() == 1) {
throw new WebCheckException("上级商户不是商户组!");
}
}
@@ -130,6 +140,9 @@
shopacc.setBalance(0D);
shopaccDao.save(shopacc);
+ shop.setShopaccno(shopacc.getShopaccno());
+ shopDao.save(shop);
+
TShopPaytype shopPaytype = new TShopPaytype();
shopPaytype.setShopaccno(shopacc.getShopaccno());
shopPaytype.setPaytype(TradeDict.PAYTYPE_BALANCE);
@@ -153,7 +166,7 @@
}
@Override
- public PageResult<ShopConfigBean> getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize) {
+ public PageResult<ShopConfigBean> getShopPaytypeInfos(String shopaccno, String paytype, int pageNo, int pageSize) {
Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("shopaccno", "paytype"));
Page<TShopPaytype> page = shopPaytypeDao.findAll(new Specification<TShopPaytype>() {
@@ -166,10 +179,6 @@
if (!StringUtil.isEmpty(paytype)) {
predicates.add(criteriaBuilder.equal(root.get("paytype").as(String.class), paytype.trim()));
}
- if (null != shopid) {
- Join<TShopPaytype, TShopacc> joinShopacc = root.join("shopaccno", JoinType.LEFT);
- predicates.add(criteriaBuilder.equal(joinShopacc.get("shopid").as(Integer.class), shopid));
- }
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
}
}, pageable);
@@ -194,5 +203,76 @@
return new PageResult<>(page.getTotalElements(), list);
}
+ @Override
+ public TShopPaytype getShopPaytype(String shopaccno, String paytype) {
+ return shopPaytypeDao.getById(paytype, shopaccno);
+ }
+
+ @Override
+ public TShopacc getShopaccByAccno(String shopaccno) {
+ if(!StringUtil.isEmpty(shopaccno)){
+ return shopaccDao.getByShopaccno(shopaccno.trim());
+ }
+ return null;
+ }
+
+ @Override
+ public boolean saveOrUpdateShopPaytype(TShopPaytype shopPaytype) {
+ if (null != shopPaytype) {
+ shopPaytypeDao.save(shopPaytype);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<TShopPaytypeConfig> getShopPaytypeConfigs(String shopaccno, String paytype) {
+ List<TShopPaytypeConfig> result = new ArrayList<>(0);
+ if (!StringUtil.isEmpty(paytype)) {
+ List<TPaytypeConfig> list = paytypeConfigDao.getByPaytypeOrderByConfigid(paytype.trim());
+ if (!StringUtil.isEmpty(list)) {
+ for (TPaytypeConfig pt : list) {
+ TShopPaytypeConfig spc = shopPaytypeConfigDao.getShopPaytypeConfigById(shopaccno, pt.getPaytype(), pt.getConfigid());
+ if (null == spc) {
+ spc = new TShopPaytypeConfig();
+ spc.setShopaccno(shopaccno);
+ spc.setPaytype(pt.getPaytype());
+ spc.setConfigid(pt.getConfigid());
+ spc.setConfigName(pt.getConfigName());
+ spc.setConfigValue(null);
+ }
+ result.add(spc);
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean saveOrUpdateShopPaytypeConfig(String shopaccno, String paytype, Map<String, String> param) throws WebCheckException {
+ TShopPaytype shopPaytype = getShopPaytype(shopaccno, paytype);
+ if (null == shopPaytype) {
+ throw new WebCheckException("此商户[" + shopaccno + "]还不具有该支付能力[" + paytype + "]");
+ }
+ for (String key : param.keySet()) {
+ String value = param.get(key);
+ TShopPaytypeConfig spc = shopPaytypeConfigDao.getShopPaytypeConfigById(shopPaytype.getShopaccno(), shopPaytype.getPaytype(), key);
+ if (null != spc) {
+ spc.setConfigValue(StringUtil.isEmpty(value) ? null : value.trim());
+ } else {
+ spc = new TShopPaytypeConfig();
+ spc.setShopaccno(shopPaytype.getShopaccno());
+ spc.setPaytype(shopPaytype.getPaytype());
+ spc.setConfigid(key);
+ spc.setConfigValue(StringUtil.isEmpty(value) ? null : value.trim());
+ TPaytypeConfig paytypeConfig = paytypeConfigDao.getByPaytypeAndAndConfigid(shopPaytype.getPaytype(), key);
+ if (null != paytypeConfig) {
+ spc.setConfigName(paytypeConfig.getConfigName());
+ }
+ }
+ shopPaytypeConfigDao.save(spc);
+ }
+ return true;
+ }
}
diff --git a/src/main/resources/templates/system/param/businesspara.html b/src/main/resources/templates/system/param/businesspara.html
index 80ddac4..0caaab0 100644
--- a/src/main/resources/templates/system/param/businesspara.html
+++ b/src/main/resources/templates/system/param/businesspara.html
@@ -9,12 +9,12 @@
<div class="layui-card-body">
<div class="layui-form toolbar">
搜索:
- <input id="search-paraname" class="layui-input search-input" type="text" maxlength="40" style="width: 300px;"
+ <input id="search-business-paraname" class="layui-input search-input" type="text" maxlength="40" style="width: 300px;"
placeholder="输入参数名查询"/> 
- <button id="btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
+ <button id="search-business-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="search-business-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>新 增</button>
+ <button id="search-business-reset" class="layui-btn layui-btn-primary" data-type="reset"><i class="layui-icon"></i>清 空</button>
</div>
<table class="layui-table" id="businessparaTable" lay-filter="businessparaTable-filter"></table>
</div>
@@ -44,12 +44,12 @@
]
});
// 搜索按钮点击事件
- $('#btn-search').click(function () {
- var paraname = $("#search-paraname").val();
+ $('#search-business-search').click(function () {
+ var paraname = $("#search-business-paraname").val();
table.reload('businessparaTable', {where: {paraname: paraname}, page: {curr: 1}});
});
- $('#btn-add').click(function () {
+ $('#search-business-add').click(function () {
admin.popupCenter({
title: "新增业务参数",
area:["600px","300px"],
@@ -60,8 +60,8 @@
});
});
- $('#btn-reset').click(function () {
- $("#search-paraname").val("");
+ $('#search-business-reset').click(function () {
+ $("#search-business-paraname").val("");
});
//监听单元格
diff --git a/src/main/resources/templates/system/param/paytype.html b/src/main/resources/templates/system/param/paytype.html
index f7909f4..a235ff9 100644
--- a/src/main/resources/templates/system/param/paytype.html
+++ b/src/main/resources/templates/system/param/paytype.html
@@ -9,7 +9,7 @@
<div class="layui-card-body">
<div class="layui-form toolbar">
搜索:
- <input id="search-paytype" class="layui-input search-input" type="text" maxlength="40" style="width: 300px;"
+ <input id="search-global-paytype" class="layui-input search-input" type="text" maxlength="40" style="width: 300px;"
placeholder="输入支付方式查询"/>
<button id="btn-search-param" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
</button>
@@ -106,7 +106,7 @@
});
// 搜索按钮点击事件
$('#btn-search-param').click(function () {
- var paytype = $("#search-paytype").val();
+ var paytype = $("#search-global-paytype").val();
table.reload('paytypeTable', {where: {paytype: paytype}, page: {curr: 1}});
});
@@ -121,7 +121,7 @@
});
$('#btn-reset-param').click(function () {
- $("#search-paytypeTable").val("");
+ $("#search-global-paytype").val("");
});
// 修改总状态
diff --git a/src/main/resources/templates/system/param/paytypeconfig.html b/src/main/resources/templates/system/param/paytypeconfig.html
index c087c94..5f81755 100644
--- a/src/main/resources/templates/system/param/paytypeconfig.html
+++ b/src/main/resources/templates/system/param/paytypeconfig.html
@@ -12,7 +12,7 @@
<label class="layui-form-label" style="float: right;width: 100%;" th:text="${config.configid}">参数名</label>
</div>
<div class="layui-input-block" style="margin:0;display: inline;float: right;width: 80%;">
- <input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}"/>
+ <input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}" autocomplete="off"/>
</div>
</div>
diff --git a/src/main/resources/templates/system/param/syspara.html b/src/main/resources/templates/system/param/syspara.html
index 79d94ec..56f7755 100644
--- a/src/main/resources/templates/system/param/syspara.html
+++ b/src/main/resources/templates/system/param/syspara.html
@@ -9,8 +9,8 @@
<div class="layui-card-body">
<div class="layui-form toolbar">
搜索:
- <input id="search-paraid" class="layui-input search-input" maxlength="9" type="text" placeholder="输入参数ID"/> 
- <input id="search-paraname" class="layui-input search-input" type="text" maxlength="30" placeholder="输入参数名称"/> 
+ <input id="search-syspara-paraid" class="layui-input search-input" maxlength="9" type="text" placeholder="输入参数ID"/> 
+ <input id="search-syspara-paraname" class="layui-input search-input" type="text" maxlength="30" placeholder="输入参数名称"/> 
<button id="btn-search-sysparam" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
</button>
<button id="btn-reset-sysparam" class="layui-btn layui-btn-primary" data-type="reset"><i class="layui-icon"></i>清 空</button>
@@ -51,8 +51,8 @@
});
// 搜索按钮点击事件
$('#btn-search-sysparam').click(function () {
- var paraid = $("#search-paraid").val();
- var paraname = $("#search-paraname").val();
+ var paraid = $("#search-syspara-paraid").val();
+ var paraname = $("#search-syspara-paraname").val();
if (null != paraid && paraid.length > 0 && !(/^\d+$/.test(paraid))) {
layer.msg("参数ID请输入数字", {icon: 2});
}else{
@@ -61,8 +61,8 @@
});
$('#btn-reset-sysparam').click(function () {
- $("#search-paraid").val("");
- $("#search-paraname").val("");
+ $("#search-syspara-paraid").val("");
+ $("#search-syspara-paraname").val("");
});
diff --git a/src/main/resources/templates/system/shop/config.html b/src/main/resources/templates/system/shop/config.html
index 9765eb6..070295a 100644
--- a/src/main/resources/templates/system/shop/config.html
+++ b/src/main/resources/templates/system/shop/config.html
@@ -11,7 +11,7 @@
<div class="layui-col-xs5 layui-col-md3">
<div class="layui-card">
<div class="layui-card-header">
- 商户树<span style="font-size: 12px;">(双击末级商户查询)</span>
+ 商户树<span style="font-size: 12px;">(双击结算商户查询)</span>
</div>
<div class="layui-card-body layui-show"
style="background-color: #D7F9F7;max-height: 560px;overflow:auto;">
@@ -23,18 +23,18 @@
<div class="layui-card" style="min-height: 600px;">
<div class="layui-card-body">
<div class="layui-form toolbar">
- 搜索:
+ 支付方式:
<select id="search-paytype">
<option value=""> 全部</option>
<option th:each="pt:${paytypelist}" th:value="${pt.paytype}"
th:text="${pt.paydesc}"></option>
</select> 
- <button id="btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索
+ <button id="btn-search-shoppaytype" 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 id="btn-add-shoppaytype" 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
+ <button id="btn-reset-shoppaytype" class="layui-btn layui-btn-primary" data-type="reset"><i
class="layui-icon"></i>清 空
</button>
</div>
@@ -48,22 +48,22 @@
<!-- 表格状态列 -->
<script type="text/html" id="consumeenable-tpl-state">
- <input type="checkbox" lay-filter="consumeenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
+ <input type="checkbox" lay-filter="consumeenable-tpl-state" value="{{d.shopaccno}}" def-paytype="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
{{d.consumeEnable=='yes'?'checked':''}}/>
</script>
<script type="text/html" id="anonymousenable-tpl-state">
{{# if(d.consumeEnable =='yes' ){ }}
- <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.paytype}}" lay-skin="switch"
+ <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.shopaccno}}" def-paytype="{{d.paytype}}" lay-skin="switch"
lay-text="启用|关闭"
{{(d.consumeEnable=='yes' && d.anonymousEnable=='yes')?'checked':''}}/>
{{# }else{ }}
- <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.paytype}}" lay-skin="switch"
+ <input type="checkbox" lay-filter="anonymousenable-tpl-state" value="{{d.shopaccno}}" def-paytype="{{d.paytype}}" lay-skin="switch"
lay-text="启用|关闭"
{{(d.consumeEnable=='yes' && d.anonymousEnable=='yes')?'checked':''}} disabled/>
{{# } }}
</script>
<script type="text/html" id="reverseenable-tpl-state">
- <input type="checkbox" lay-filter="reverseenable-tpl-state" value="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
+ <input type="checkbox" lay-filter="reverseenable-tpl-state" value="{{d.shopaccno}}" def-paytype="{{d.paytype}}" lay-skin="switch" lay-text="启用|关闭"
{{d.reverseEnable=='yes'?'checked':''}}/>
</script>
@@ -108,22 +108,22 @@
layer.msg('查询商户树失败了,请稍后再试', {icon: 2});
});
- $('#btn-reset').click(function () {
+ $('#btn-reset-shoppaytype').click(function () {
$("#search-paytype").val("");
form.render('select');
});
- $('#btn-search').click(function(){
+ $('#btn-search-shoppaytype').click(function(){
var ptype = $("#search-paytype").val();
- table.reload('shopPaytypeTable', {where: {paytype: ptype, shopid:""}, page: {curr: 1}});
+ table.reload('shopPaytypeTable', {where: {paytype: ptype, shopaccno:""}, page: {curr: 1}});
});
function ondblclick(event, treeId, treeNode) {
- if (treeNode.shoptype != 1) {
- layer.msg("请选择末级商户", {icon: 2, time: 1000});
+ if (treeNode.shoptype != 1 || ""==treeNode.shopaccno) {
+ layer.msg("请选择结算商户查询", {icon: 2, time: 1000});
return;
}
var ptype = $("#search-paytype").val();
- table.reload('shopPaytypeTable', {where: {paytype: ptype, shopid: treeNode.id}, page: {curr: 1}});
+ table.reload('shopPaytypeTable', {where: {paytype: ptype, shopaccno: treeNode.shopaccno}, page: {curr: 1}});
}
// 渲染表格
@@ -171,5 +171,115 @@
]
]
});
+
+ // 修改总状态
+ form.on('switch(consumeenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ admin.go('/shop/updatepaytypestat', {
+ shopaccno: obj.elem.value,
+ paytype: $(obj.elem).attr("def-paytype"),
+ optype: "consume",
+ state: obj.elem.checked ? 'yes' : 'no',
+ _csrf: token
+ }, function (data) {
+ if (data.code == 200) {
+ layer.msg(data.msg, {icon: 1, time:1000});
+ table.reload('shopPaytypeTable');
+ } 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(anonymousenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ updateShopPaytypeState(obj, "anonymous", token);
+ });
+
+ form.on('switch(reverseenable-tpl-state)', function (obj) {
+ var token = $("meta[name='_csrf_token']").attr("value");
+ updateShopPaytypeState(obj, "reverse", token);
+ });
+
+ function updateShopPaytypeState(obj, optype, token) {
+ admin.go('/shop/updatepaytypestat', {
+ shopaccno: obj.elem.value,
+ paytype: $(obj.elem).attr("def-paytype"),
+ 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');
+ });
+ }
+
+ $('#btn-add-shoppaytype').click(function () {
+ var ztree = $.fn.zTree.getZTreeObj("shopacctree");
+ var shopNodes = ztree.getSelectedNodes();
+ if (undefined == shopNodes || null == shopNodes || shopNodes.length < 1) {
+ layer.msg("请先选中左侧的一个结算商户", {icon: 2, time: 1000});
+ return;
+ }
+ var shopNode = shopNodes[0]; //选中商户
+ if(shopNode.shoptype!=1 || ""==shopNode.shopaccno){
+ layer.msg("请选择结算商户!", {icon: 2, time: 1000});
+ return;
+ }
+ admin.putTempData('t_addshoppaytype', {
+ shopaccno:shopNode.shopaccno,
+ shopname: shopNode.name.slice(shopNode.id.length+1) //23_第一食堂,截取商户名称
+ });
+ admin.popupCenter({
+ title: "新增支付能力",
+ path: '/shop/load4addpaytype',
+ finish: function () {
+ table.reload('shopPaytypeTable', {
+ where: {paytype: "", shopaccno: shopNode.shopaccno},
+ page: {curr: 1}
+ });
+ }
+ });
+ });
+
+ //监听单元格
+ table.on('tool(shopPaytypeTable-filter)', function (obj) {
+ var data = obj.data;
+ if ('config' == obj.event) {
+ admin.popupCenter({
+ title: "配置参数【" + data.shopname + "_" + data.paydesc + "】",
+ path: '/shop/load4paytypepara?shopaccno=' + data.shopaccno + '&paytype=' + data.paytype,
+ area: '800px',
+ finish: function () {
+ table.reload('shopPaytypeTable');
+ }
+ });
+ }
+ });
});
</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/system/shop/configform.html b/src/main/resources/templates/system/shop/configform.html
new file mode 100644
index 0000000..9f60ecf
--- /dev/null
+++ b/src/main/resources/templates/system/shop/configform.html
@@ -0,0 +1,101 @@
+<form id="shop-paytype-form" lay-filter="shop-paytype-form" class="layui-form model-form">
+ <div class="layui-form-item">
+ <label class="layui-form-label">商户账号</label>
+ <div class="layui-input-block">
+ <input name="shopaccno" class="layui-input" readonly="readonly" lay-verify="required"/>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">商户名称</label>
+ <div class="layui-input-block">
+ <input name="shopname" class="layui-input" readonly="readonly"/>
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">支付方式</label>
+ <div class="layui-input-block">
+ <select name="paytype" lay-verify="required">
+ <option th:each="pt:${paytypelist}" th:value="${pt.paytype}"
+ th:text="${pt.paydesc}"></option>
+ </select> 
+ </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">
+ <label class="layui-form-label">能否冲正</label>
+ <div class="layui-input-block">
+ <input name="reverseEnable" 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.render('select');
+ // 回显数据
+ var shop = admin.getTempData('t_addshoppaytype');
+ if (shop) {
+ form.val('shop-paytype-form', {
+ shopaccno: shop.shopaccno,
+ shopname: shop.shopname
+ });
+ }
+
+ // 表单提交事件
+ 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 : '/shop/addshoppaytype',
+ 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);
+ 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/shop/configpara.html b/src/main/resources/templates/system/shop/configpara.html
new file mode 100644
index 0000000..231b6ae
--- /dev/null
+++ b/src/main/resources/templates/system/shop/configpara.html
@@ -0,0 +1,79 @@
+<form id="shop-paytype-config-form" lay-filter="shop-paytype-config-form" class="layui-form model-form">
+ <div class="layui-form-item" style="display: none;">
+ <input type="hidden" class="layui-input" id="hid_shopaccno" th:value="${shopaccno}"/>
+ <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}">
+ <div class="layui-input-block" style="margin:0;display: inline;float: left;width: 20%;">
+ <label class="layui-form-label" style="float: right;width: 100%;" th:text="${config.configid}">参数名</label>
+ </div>
+ <div class="layui-input-block" style="margin:0;display: inline;float: right;width: 80%;">
+ <input type="text" th:name="${config.configid}" class="layui-input" th:value="${config.configValue}" autocomplete="off"/>
+ </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(JSON.stringify(vdata)=="{}"){
+ layer.closeAll('loading');
+ admin.closePopupCenter();
+ return; //无配置项,直接关闭
+ }
+ var token = $("meta[name='_csrf_token']").attr("value");
+ vdata["hid_paytype"] = $("#hid_paytype").val();
+ vdata["hid_shopaccno"] = $("#hid_shopaccno").val();
+ console.log('addShopPaytype:', vdata);
+ debugger
+ $.ajax({
+ type : "POST",
+ dataType : "json",
+ url : '/shop/addpaytypepara',
+ 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