From: Xia Kaixiang Date: Wed, 22 May 2019 10:59:00 +0000 (+0800) Subject: 商户支付能力配置页面 X-Git-Tag: 1.0.0^2~201 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=6b6952e37a4dfefd8abea29d99d380f878da4dfe;p=epayment%2Ffood_payapi.git 商户支付能力配置页面 --- diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java index 0b0b998b..bd2c959b 100644 --- a/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java +++ b/src/main/java/com/supwisdom/dlpay/api/dao/PaytypeDao.java @@ -4,8 +4,11 @@ import com.supwisdom.dlpay.api.domain.TPaytype; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; + /** * Created by shuwei on 2019/4/9. */ @@ -14,4 +17,7 @@ public interface PaytypeDao extends JpaRepository { TPaytype getByPaytype(String paytype); Page findByPaytypeContaining(String paytype, Pageable pageable); + + @Query("select t from TPaytype t") + List getConsumePaytypes(); } diff --git a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java index 750f8acd..03196e1e 100644 --- a/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java +++ b/src/main/java/com/supwisdom/dlpay/api/dao/ShopPaytypeDao.java @@ -3,11 +3,13 @@ package com.supwisdom.dlpay.api.dao; import com.supwisdom.dlpay.api.domain.TShopPaytype; import com.supwisdom.dlpay.api.domain.TShopPaytypePK; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @Repository -public interface ShopPaytypeDao extends JpaRepository { +public interface ShopPaytypeDao extends JpaRepository, JpaSpecificationExecutor { @Query("select a from TShopPaytype a where a.paytype=?1 and a.shopaccno=?2 ") TShopPaytype getById(String paytype, String shopaccno); + } diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/ShopConfigBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/ShopConfigBean.java new file mode 100644 index 00000000..0bd5256d --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/bean/ShopConfigBean.java @@ -0,0 +1,80 @@ +package com.supwisdom.dlpay.system.bean; + +public class ShopConfigBean { + private String shopaccno; + private String shopname; + private String paytype; + private String paydesc; + private String consumeEnable; + private String anonymousEnable; + private String reverseEnable; + + public ShopConfigBean() { + } + + public ShopConfigBean(String shopaccno, String shopname, String paytype, String paydesc, String consumeEnable, String anonymousEnable, String reverseEnable) { + this.shopaccno = shopaccno; + this.shopname = shopname; + this.paytype = paytype; + this.paydesc = paydesc; + this.consumeEnable = consumeEnable; + this.anonymousEnable = anonymousEnable; + this.reverseEnable = reverseEnable; + } + + public String getShopaccno() { + return shopaccno; + } + + public void setShopaccno(String shopaccno) { + this.shopaccno = shopaccno; + } + + public String getShopname() { + return shopname; + } + + public void setShopname(String shopname) { + this.shopname = shopname; + } + + public String getPaytype() { + return paytype; + } + + public void setPaytype(String paytype) { + this.paytype = paytype; + } + + public String getPaydesc() { + return paydesc; + } + + public void setPaydesc(String paydesc) { + this.paydesc = paydesc; + } + + public String getConsumeEnable() { + return consumeEnable; + } + + public void setConsumeEnable(String consumeEnable) { + this.consumeEnable = consumeEnable; + } + + public String getAnonymousEnable() { + return anonymousEnable; + } + + public void setAnonymousEnable(String anonymousEnable) { + this.anonymousEnable = anonymousEnable; + } + + public String getReverseEnable() { + return reverseEnable; + } + + public void setReverseEnable(String reverseEnable) { + this.reverseEnable = reverseEnable; + } +} 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 a94f9068..5f09c4ee 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java @@ -1,14 +1,20 @@ 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.framework.domain.TShop; +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.ShopDataService; 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.*; @Controller @@ -131,5 +137,40 @@ public class ShopController { } } + /** + * ==================================================== + * 商户支付能力配置 + * ==================================================== + */ + @GetMapping("/shop/config") + public String shopConfigView(Model model) { + model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); + return "system/shop/config"; + } + + @GetMapping("/shop/shopacctree") + @PreAuthorize("hasPermission('/shop/config','')") + @ResponseBody + public JsonResult shopaccTreeData(){ + return JsonResult.ok("OK").put("data", shopDataService.getAllShopNodes()); + } + + @GetMapping("/shop/shoppaytypelist") + @PreAuthorize("hasPermission('/shop/shoppaytypelist','')") + @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); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } } 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 9a5dd9ab..fe9ce27d 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java @@ -1,6 +1,9 @@ package com.supwisdom.dlpay.system.service; +import com.supwisdom.dlpay.api.domain.TPaytype; import com.supwisdom.dlpay.framework.domain.TShop; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.system.bean.ShopConfigBean; import com.supwisdom.dlpay.system.bean.ZTreeNode; import com.supwisdom.dlpay.util.WebCheckException; import org.springframework.transaction.annotation.Propagation; @@ -20,4 +23,10 @@ public interface ShopDataService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) boolean saveOrUpdateShop(TShop shop) throws WebCheckException; + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) + List getConsumePaytypes(); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) + PageResult getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize); } 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 c8d3fe25..75722c75 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,6 +1,8 @@ package com.supwisdom.dlpay.system.service.impl; +import com.supwisdom.dlpay.api.dao.PaytypeDao; import com.supwisdom.dlpay.api.dao.ShopPaytypeDao; +import com.supwisdom.dlpay.api.domain.TPaytype; import com.supwisdom.dlpay.api.domain.TShopPaytype; import com.supwisdom.dlpay.framework.dao.ShopDao; import com.supwisdom.dlpay.framework.dao.ShopaccDao; @@ -8,16 +10,24 @@ import com.supwisdom.dlpay.framework.data.SystemDateTime; 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.Subject; import com.supwisdom.dlpay.framework.util.TradeDict; +import com.supwisdom.dlpay.system.bean.ShopConfigBean; import com.supwisdom.dlpay.system.bean.ZTreeNode; 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.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import org.springframework.data.jpa.domain.Specification; +import javax.persistence.criteria.*; import java.util.ArrayList; import java.util.List; @@ -31,6 +41,8 @@ public class ShopDataServiceImpl implements ShopDataService { private ShopPaytypeDao shopPaytypeDao; @Autowired private SystemUtilService systemUtilService; + @Autowired + private PaytypeDao paytypeDao; @Override public List getAllShopNodes() { @@ -131,5 +143,56 @@ public class ShopDataServiceImpl implements ShopDataService { } } + @Override + public List getConsumePaytypes() { + List list = paytypeDao.getConsumePaytypes(); + if (!StringUtil.isEmpty(list)) { + return list; + } + return new ArrayList(0); + } + + @Override + public PageResult getShopPaytypeInfos(String shopaccno, String paytype, Integer shopid, int pageNo, int pageSize) { + Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("shopaccno", "paytype")); + + Page page = shopPaytypeDao.findAll(new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + if (!StringUtil.isEmpty(shopaccno)) { + predicates.add(criteriaBuilder.equal(root.get("shopaccno").as(String.class), shopaccno.trim())); + } + 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); + + if (null == page || page.getTotalElements() == 0) { + return new PageResult<>(99, "无数据"); + } + List list = new ArrayList<>(0); + for (TShopPaytype pt : page.getContent()) { + ShopConfigBean bean = new ShopConfigBean(); + bean.setShopaccno(pt.getShopaccno()); + TShopacc shopacc = shopaccDao.getByShopaccno(pt.getShopaccno()); + bean.setShopname(shopacc == null ? "" : shopacc.getShopname()); + bean.setPaytype(pt.getPaytype()); + TPaytype tPaytype = paytypeDao.getByPaytype(pt.getPaytype()); + bean.setPaydesc(tPaytype == null ? "" : tPaytype.getPaydesc()); + bean.setConsumeEnable(pt.getConsumeEnable()); + bean.setAnonymousEnable(pt.getAnonymousEnable()); + bean.setReverseEnable(pt.getReverseEnable()); + list.add(bean); + } + return new PageResult<>(page.getTotalElements(), list); + } + } diff --git a/src/main/resources/templates/system/shop/config.html b/src/main/resources/templates/system/shop/config.html new file mode 100644 index 00000000..9765eb60 --- /dev/null +++ b/src/main/resources/templates/system/shop/config.html @@ -0,0 +1,175 @@ +
+
+

商户支付能力管理

+ + 商户中心 + 商户支付能力管理 + +
+
+
+
+
+
+ 商户树(双击末级商户查询) +
+
+
    +
    +
    +
    +
    +
    +
    +
    + 搜索: +   + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file