From 42c30dd66e4fe7309d293de68de3fa1244f941e3 Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Thu, 23 May 2019 17:12:33 +0800 Subject: [PATCH] =?utf8?q?=E5=95=86=E6=88=B7=E6=94=AF=E4=BB=98=E8=83=BD?= =?utf8?q?=E5=8A=9B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dlpay/api/dao/ShopPaytypeConfigDao.java | 3 + .../dlpay/api/domain/TShopPaytypeConfig.java | 6 +- .../dlpay/system/bean/ZTreeNode.java | 9 + .../system/controller/ShopController.java | 183 ++++++++++++++++-- .../dlpay/system/service/ShopDataService.java | 23 ++- .../service/impl/ShopDataServiceImpl.java | 108 +++++++++-- .../templates/system/param/businesspara.html | 18 +- .../templates/system/param/paytype.html | 6 +- .../templates/system/param/paytypeconfig.html | 2 +- .../templates/system/param/syspara.html | 12 +- .../templates/system/shop/config.html | 140 ++++++++++++-- .../templates/system/shop/configform.html | 101 ++++++++++ .../templates/system/shop/configpara.html | 79 ++++++++ 13 files changed, 620 insertions(+), 70 deletions(-) create mode 100644 src/main/resources/templates/system/shop/configform.html create mode 100644 src/main/resources/templates/system/shop/configpara.html 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 036161a8..a7164c84 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 @@ import java.util.List; public interface ShopPaytypeConfigDao extends JpaRepository { @Query("select a from TShopPaytypeConfig a where a.paytype=?1 and a.shopaccno=?2 ") List 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 4d9fd722..acea2098 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 @@ public class TShopPaytypeConfig { @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 @@ public class TShopPaytypeConfig { 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 cd18d0a3..61e122e0 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 @@ public class ZTreeNode { private boolean open; private Integer shoptype; //商户类别,商户树用到 + private String shopaccno; //商户账号 private String iconSkin; //自定义图标 public boolean isOpen() { @@ -59,6 +60,14 @@ public class ZTreeNode { 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 5f09c4ee..2aba10b3 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 @@ package com.supwisdom.dlpay.system.controller; 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.stereotype.Controller; 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 @@ public class ShopController { @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 @@ public class ShopController { @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 @@ public class ShopController { 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 @@ public class ShopController { @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 @@ public class ShopController { @ResponseBody public PageResult 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 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 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 fe9ce27d..63b9f274 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.Propagation; 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 @@ public interface ShopDataService { List getConsumePaytypes(); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) - PageResult getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize); + PageResult 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 getShopPaytypeConfigs(String shopaccno, String paytype); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + boolean saveOrUpdateShopPaytypeConfig(String shopaccno, String paytype, Map 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 75722c75..37101ad0 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 org.springframework.data.jpa.domain.Specification; 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 @@ public class ShopDataServiceImpl implements ShopDataService { private SystemUtilService systemUtilService; @Autowired private PaytypeDao paytypeDao; + @Autowired + private PaytypeConfigDao paytypeConfigDao; + @Autowired + private ShopPaytypeConfigDao shopPaytypeConfigDao; @Override public List getAllShopNodes() { @@ -53,12 +62,13 @@ public class ShopDataServiceImpl implements ShopDataService { 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 @@ public class ShopDataServiceImpl implements ShopDataService { } @Override - public boolean deleteShop(TShop shop) throws WebCheckException{ - if(null!=shop){ + public boolean deleteShop(TShop shop) throws WebCheckException { + if (null != shop) { List 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 @@ public class ShopDataServiceImpl implements ShopDataService { 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 @@ public class ShopDataServiceImpl implements ShopDataService { 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 @@ public class ShopDataServiceImpl implements ShopDataService { } @Override - public PageResult getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize) { + public PageResult getShopPaytypeInfos(String shopaccno, String paytype, int pageNo, int pageSize) { Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("shopaccno", "paytype")); Page page = shopPaytypeDao.findAll(new Specification() { @@ -166,10 +179,6 @@ public class ShopDataServiceImpl implements ShopDataService { if (!StringUtil.isEmpty(paytype)) { predicates.add(criteriaBuilder.equal(root.get("paytype").as(String.class), paytype.trim())); } - if (null != shopid) { - Join 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 @@ public class ShopDataServiceImpl implements ShopDataService { 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 getShopPaytypeConfigs(String shopaccno, String paytype) { + List result = new ArrayList<>(0); + if (!StringUtil.isEmpty(paytype)) { + List 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 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 80ddac40..0caaab01 100644 --- a/src/main/resources/templates/system/param/businesspara.html +++ b/src/main/resources/templates/system/param/businesspara.html @@ -9,12 +9,12 @@
搜索: -   - - - + +
@@ -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 f7909f49..a235ff97 100644 --- a/src/main/resources/templates/system/param/paytype.html +++ b/src/main/resources/templates/system/param/paytype.html @@ -9,7 +9,7 @@
搜索: - @@ -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 c087c949..5f81755a 100644 --- a/src/main/resources/templates/system/param/paytypeconfig.html +++ b/src/main/resources/templates/system/param/paytypeconfig.html @@ -12,7 +12,7 @@
- +
diff --git a/src/main/resources/templates/system/param/syspara.html b/src/main/resources/templates/system/param/syspara.html index 79d94ec8..56f7755a 100644 --- a/src/main/resources/templates/system/param/syspara.html +++ b/src/main/resources/templates/system/param/syspara.html @@ -9,8 +9,8 @@
搜索: -   -   +   + @@ -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 9765eb60..070295a0 100644 --- a/src/main/resources/templates/system/shop/config.html +++ b/src/main/resources/templates/system/shop/config.html @@ -11,7 +11,7 @@
- 商户树(双击末级商户查询) + 商户树(双击结算商户查询)
@@ -23,18 +23,18 @@
- 搜索: + 支付方式:   - - -
@@ -48,22 +48,22 @@ @@ -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'); + } + }); + } + }); }); \ 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 00000000..9f60ecff --- /dev/null +++ b/src/main/resources/templates/system/shop/configform.html @@ -0,0 +1,101 @@ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+   +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ + + \ 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 00000000..231b6ae1 --- /dev/null +++ b/src/main/resources/templates/system/shop/configpara.html @@ -0,0 +1,79 @@ +
+ + +
+ 无配置项 +
+ +
+
+ +
+
+ +
+
+ + +
+ + + \ No newline at end of file -- 2.17.1