From e0537a730daee8ad22e3e92c30fbb01629ad43ed Mon Sep 17 00:00:00 2001 From: Tang Cheng Date: Sat, 13 Jul 2019 12:52:07 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E4=BA=86shoptype=E5=AE=9A?= =?utf8?q?=E4=B9=89=EF=BC=8C=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dlpay/api/annotation/ShopType.java | 6 +- .../dlpay/api/bean/OpenShopParam.java | 4 +- .../supwisdom/dlpay/api/util/ShopTypes.java | 34 +++++ .../api/validator/MobileNumberValidator.java | 3 +- .../api/validator/ShopTypeValidator.java | 23 +++- payapi/build.gradle | 4 +- .../dlpay/framework/domain/TShop.java | 13 +- .../dlpay/framework/util/Constants.java | 2 + .../dlpay/system/bean/ZTreeNode.java | 6 +- .../system/controller/ShopController.java | 12 +- .../service/impl/SettleReportServiceImpl.java | 16 ++- .../service/impl/ShopDataServiceImpl.java | 20 ++- .../supwisdom/dlpay/util/ConstantUtil.java | 3 - .../com/supwisdom/dlpay/util/EnumCheck.java | 12 ++ .../api/service/impl/shop_service_impl.kt | 15 ++- payapi/src/main/resources/data.sql | 2 +- .../templates/system/shop/config.html | 62 ++++++--- .../templates/system/shop/index.html | 125 ++++++++++-------- 18 files changed, 241 insertions(+), 121 deletions(-) create mode 100644 payapi-common/src/main/java/com/supwisdom/dlpay/api/util/ShopTypes.java create mode 100644 payapi/src/main/java/com/supwisdom/dlpay/util/EnumCheck.java diff --git a/payapi-common/src/main/java/com/supwisdom/dlpay/api/annotation/ShopType.java b/payapi-common/src/main/java/com/supwisdom/dlpay/api/annotation/ShopType.java index d869ffe2..4c16761b 100644 --- a/payapi-common/src/main/java/com/supwisdom/dlpay/api/annotation/ShopType.java +++ b/payapi-common/src/main/java/com/supwisdom/dlpay/api/annotation/ShopType.java @@ -1,5 +1,7 @@ package com.supwisdom.dlpay.api.annotation; +import com.supwisdom.dlpay.api.util.SexTypes; +import com.supwisdom.dlpay.api.util.ShopTypes; import com.supwisdom.dlpay.api.validator.ShopTypeValidator; import javax.validation.Constraint; @@ -12,9 +14,11 @@ import java.lang.annotation.*; @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface ShopType { - String message() default "不正确的状态 , 应该是 '1', '2' 其中之一"; + String message() default "不正确的商户类型 "; Class[] groups() default {}; Class[] payload() default {}; + + ShopTypes value() default ShopTypes.ALL; } \ No newline at end of file diff --git a/payapi-common/src/main/java/com/supwisdom/dlpay/api/bean/OpenShopParam.java b/payapi-common/src/main/java/com/supwisdom/dlpay/api/bean/OpenShopParam.java index 3be30ad3..df8ba1e4 100644 --- a/payapi-common/src/main/java/com/supwisdom/dlpay/api/bean/OpenShopParam.java +++ b/payapi-common/src/main/java/com/supwisdom/dlpay/api/bean/OpenShopParam.java @@ -22,9 +22,9 @@ public class OpenShopParam extends APIRequestParam { @NotEmpty(message = "商户唯一号不能为空") private String shopUniqueId; @Sign - @NotNull(message = "商户类型不能为空") @ShopType - private Integer shoptype; + @NotNull(message = "商户类型不能为空") + private String shoptype; @Sign private Integer fshopid; @Sign diff --git a/payapi-common/src/main/java/com/supwisdom/dlpay/api/util/ShopTypes.java b/payapi-common/src/main/java/com/supwisdom/dlpay/api/util/ShopTypes.java new file mode 100644 index 00000000..3503ab0b --- /dev/null +++ b/payapi-common/src/main/java/com/supwisdom/dlpay/api/util/ShopTypes.java @@ -0,0 +1,34 @@ +package com.supwisdom.dlpay.api.util; + +public enum ShopTypes { + GROUP("group", "商户组"), + ROOT("root", "根商户"), + NORMAL("normal", "结算商户"), + ALL("all", new ShopTypes[]{ROOT, GROUP, NORMAL}); + + ShopTypes(String t, Object data) { + this.id = t; + this.data = data; + } + + public String value() { + return this.id; + } + + public Object data() { + return this.data; + } + + public String desc() { + return this.data.toString(); + } + + + public String id; + public Object data; + + @Override + public String toString() { + return this.id; + } +} diff --git a/payapi-common/src/main/java/com/supwisdom/dlpay/api/validator/MobileNumberValidator.java b/payapi-common/src/main/java/com/supwisdom/dlpay/api/validator/MobileNumberValidator.java index 8fc1a26a..4ded93f4 100644 --- a/payapi-common/src/main/java/com/supwisdom/dlpay/api/validator/MobileNumberValidator.java +++ b/payapi-common/src/main/java/com/supwisdom/dlpay/api/validator/MobileNumberValidator.java @@ -2,6 +2,7 @@ package com.supwisdom.dlpay.api.validator; import com.supwisdom.dlpay.api.annotation.MobileNumber; import com.supwisdom.dlpay.api.util.MobileNumberCheck; +import org.apache.commons.lang3.StringUtils; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; @@ -10,7 +11,7 @@ public class MobileNumberValidator implements ConstraintValidator { - private final int[] ALL_TYPE = {1, 2}; +public class ShopTypeValidator implements ConstraintValidator { + private String[] allTypes; @Override - public boolean isValid(Integer value, ConstraintValidatorContext context) { - return Collections.singletonList(ALL_TYPE).contains(value); + public boolean isValid(String value, ConstraintValidatorContext context) { + if (value == null || value.isEmpty()) { + return true; + } + return Arrays.asList(allTypes).contains(value); } @Override public void initialize(ShopType constraintAnnotation) { + Object value = constraintAnnotation.value().data(); + if (value instanceof ShopTypes[]) { + allTypes = new String[((ShopTypes[]) value).length]; + for (int i = 0; i < ((ShopTypes[]) value).length; ++i) { + allTypes[i] = ((ShopTypes[]) value)[i].value(); + } + } else { + allTypes = new String[]{value.toString()}; + } } } \ No newline at end of file diff --git a/payapi/build.gradle b/payapi/build.gradle index 18f9d7f8..419a4703 100644 --- a/payapi/build.gradle +++ b/payapi/build.gradle @@ -68,7 +68,7 @@ dependencies { implementation 'org.postgresql:postgresql:42.2.5' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' implementation 'com.jcabi:jcabi-manifests:1.1' - implementation 'org.bitbucket.b_c:jose4j:0.6.3' + implementation 'org.bitbucket.b_c:jose4j:0.6.5' implementation 'io.github.microutils:kotlin-logging:1.6.26' implementation 'org.slf4j:slf4j-parent:1.7.26' implementation 'com.github.penggle:kaptcha:2.3.2' @@ -77,7 +77,7 @@ dependencies { implementation group: 'javax.servlet', name: 'jstl', version: '1.2' implementation group: 'taglibs', name: 'standard', version: '1.1.2' implementation group: 'commons-codec', name: 'commons-codec', version: '1.6' - implementation files('libs/ojdbc6.jar') +// implementation files('libs/ojdbc6.jar') implementation 'commons-dbcp:commons-dbcp:1.4' implementation project(':payapi-common') diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TShop.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TShop.java index 49b5df71..74c3ba62 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TShop.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TShop.java @@ -15,13 +15,16 @@ public class TShop { private Integer shopid; @Column(name = "FSHOPID", precision = 9) + @NotNull private Integer fshopid; @Column(name = "SHOPNAME", length = 200) + @NotNull private String shopname; - @Column(name = "SHOPTYPE", precision = 1) - private Integer shoptype; + @Column(name = "SHOPTYPE", length = 30) + @NotNull + private String shoptype; @Column(name = "STATUS", length = 20) @NotNull @@ -73,7 +76,7 @@ public class TShop { public TShop() { } - public TShop(Integer fshopid, String shopname, Integer shoptype, String status, String shopaccno, String contactman, String idtype, String idno, String tel, String mobile, String email, String addr, String zipcode, String opendate, String closedate, String thirdUniqueIdenty) { + public TShop(Integer fshopid, String shopname, String shoptype, String status, String shopaccno, String contactman, String idtype, String idno, String tel, String mobile, String email, String addr, String zipcode, String opendate, String closedate, String thirdUniqueIdenty) { this.fshopid = fshopid; this.shopname = shopname; this.shoptype = shoptype; @@ -124,11 +127,11 @@ public class TShop { this.shopname = shopname; } - public Integer getShoptype() { + public String getShoptype() { return shoptype; } - public void setShoptype(Integer shoptype) { + public void setShoptype(String shoptype) { this.shoptype = shoptype; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/Constants.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/Constants.java index 17dd6bc6..46af8bbb 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/Constants.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/Constants.java @@ -8,4 +8,6 @@ public class Constants { public static final String JWT_CLAIM_TENANTID = "tenantId"; public static final String JWT_CLAIM_UID = "uid"; public static final String JWT_CLAIM_AUTHORITIES = "authorities"; + // 根商户ID + public static final Integer ROOT_SHOP_FID = 1; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java index 61e122e0..8a4c964a 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/ZTreeNode.java @@ -8,7 +8,7 @@ public class ZTreeNode { private boolean checked; private boolean open; - private Integer shoptype; //商户类别,商户树用到 + private String shoptype; //商户类别,商户树用到 private String shopaccno; //商户账号 private String iconSkin; //自定义图标 @@ -52,11 +52,11 @@ public class ZTreeNode { this.checked = checked; } - public Integer getShoptype() { + public String getShoptype() { return shoptype; } - public void setShoptype(Integer shoptype) { + public void setShoptype(String shoptype) { this.shoptype = shoptype; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java index 9cc74c55..cb762831 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java @@ -4,6 +4,7 @@ import com.supwisdom.dlpay.api.bean.JsonResult; import com.supwisdom.dlpay.api.domain.TSourceType; import com.supwisdom.dlpay.api.domain.TShopSourceType; import com.supwisdom.dlpay.api.domain.TShopSourceTypeConfig; +import com.supwisdom.dlpay.api.util.ShopTypes; import com.supwisdom.dlpay.framework.domain.TShop; import com.supwisdom.dlpay.framework.domain.TShopacc; import com.supwisdom.dlpay.framework.service.SystemUtilService; @@ -13,6 +14,7 @@ import com.supwisdom.dlpay.system.service.DictionaryProxy; 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.EnumCheck; import com.supwisdom.dlpay.util.WebCheckException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -35,6 +37,8 @@ public class ShopController { @Autowired private DictionaryProxy dictionaryProxy; + private EnumCheck shopTypeCheck = new EnumCheck<>(); + @GetMapping("/shop/index") public String shopView() { return "system/shop/index"; @@ -84,7 +88,7 @@ public class ShopController { @PreAuthorize("hasPermission('/shop/saveorupdate','')") @ResponseBody public JsonResult saveOrUpdateShop(@RequestParam("shopid") Integer shopid, @RequestParam("shopname") String shopname, - @RequestParam("fshopid") Integer fshopid, @RequestParam("shoptype") Integer shoptype, + @RequestParam("fshopid") Integer fshopid, @RequestParam("shoptype") String shoptype, @RequestParam(value = "contactman", required = false) String contactman, @RequestParam(value = "idtype", required = false) String idtype, @RequestParam(value = "idno", required = false) String idno, @@ -93,7 +97,8 @@ public class ShopController { @RequestParam(value = "email", required = false) String email, @RequestParam(value = "addr", required = false) String addr, @RequestParam(value = "zipcode", required = false) String zipcode) { - if (null == shopid || StringUtil.isEmpty(shopname) || null == fshopid || (shoptype != 0 && shoptype != 1)) { + if (null == shopid || StringUtil.isEmpty(shopname) || null == fshopid + || !shopTypeCheck.isInEnums(shoptype, ShopTypes.NORMAL, ShopTypes.GROUP)) { return JsonResult.error("参数传递错误"); } @@ -115,7 +120,6 @@ public class ShopController { } shop.setFshopid(fshopid); shop.setShopname(shopname); -// shop.setShoptype(shoptype); //商户类型不能改 } shop.setContactman(contactman == null ? null : contactman.trim()); shop.setIdno(idno == null ? null : idno.trim()); @@ -125,7 +129,7 @@ public class ShopController { } else if (!StringUtil.isEmpty(shop.getIdno()) && "1".equals(shop.getIdtype()) && !StringUtil.isIdentity(shop.getIdno())) { return JsonResult.error("身份证格式错误!"); } - shop.setMobile(mobile == null ? null : mobile); + shop.setMobile(mobile); if (!StringUtil.isEmpty(shop.getMobile()) && !StringUtil.isMobile(shop.getMobile())) { return JsonResult.error("请正确填写手机号!"); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java index dc1128f6..9c0232b5 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java @@ -1,5 +1,6 @@ package com.supwisdom.dlpay.system.service.impl; +import com.supwisdom.dlpay.api.util.ShopTypes; import com.supwisdom.dlpay.framework.dao.*; import com.supwisdom.dlpay.framework.domain.TSettlectl; import com.supwisdom.dlpay.framework.domain.TShop; @@ -10,6 +11,7 @@ import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.StringUtil; import com.supwisdom.dlpay.system.bean.*; import com.supwisdom.dlpay.system.service.SettleReportService; +import com.supwisdom.dlpay.util.EnumCheck; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -32,10 +34,12 @@ public class SettleReportServiceImpl implements SettleReportService { @Autowired private ShopDao shopDao; + private EnumCheck shoptypeCheck = new EnumCheck<>(); + @Override public String getSystemSettledate() { TSettlectl settlectl = settleCtlDao.getOne(1); - if (null != settlectl && null != settlectl.getSettledate()) { + if (null != settlectl.getSettledate()) { return settlectl.getSettledate().toString(); } return DateUtil.getNow("yyyyMMdd"); @@ -143,7 +147,7 @@ public class SettleReportServiceImpl implements SettleReportService { TreeSelectNode node = new TreeSelectNode(); node.setId(shop.getShopid().toString()); node.setName(shop.getShopname()); - node.setOpen(shop.getShoptype() == 0); + node.setOpen(!shoptypeCheck.isInEnums(shop.getShoptype(), ShopTypes.NORMAL)); node.setChecked(false); node.setAccno(shop.getShopaccno() == null ? "" : shop.getShopaccno()); node.setpId(String.valueOf(fshopid)); @@ -203,11 +207,11 @@ public class SettleReportServiceImpl implements SettleReportService { //商户组,计算该组下所有的交易额 long transcnt = 0; double transamt = 0; - List childrenShops = getChildrenShopByShopid(shopAllList,shop.getShopid().intValue()); //子商户列表 + List childrenShops = getChildrenShopByShopid(shopAllList, shop.getShopid().intValue()); //子商户列表 for (TShop child : childrenShops) { - if(!StringUtil.isEmpty(child.getShopaccno())){ - for(ShopBusinessInfo info:businessInfos){ - if(child.getShopaccno().equals(info.getShopaccno())){ + if (!StringUtil.isEmpty(child.getShopaccno())) { + for (ShopBusinessInfo info : businessInfos) { + if (child.getShopaccno().equals(info.getShopaccno())) { transcnt += info.getTranscnt(); transamt += (info.getCramt() - info.getDramt()); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java index 24beb2bc..51981fd2 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java @@ -8,6 +8,7 @@ import com.supwisdom.dlpay.api.domain.TSourceType; import com.supwisdom.dlpay.api.domain.TSourceTypeConfig; import com.supwisdom.dlpay.api.domain.TShopSourceType; import com.supwisdom.dlpay.api.domain.TShopSourceTypeConfig; +import com.supwisdom.dlpay.api.util.ShopTypes; import com.supwisdom.dlpay.framework.dao.ShopDao; import com.supwisdom.dlpay.framework.dao.ShopaccDao; import com.supwisdom.dlpay.framework.data.SystemDateTime; @@ -15,13 +16,11 @@ 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.tenant.TenantContext; -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.framework.util.*; 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.EnumCheck; import com.supwisdom.dlpay.util.WebCheckException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -53,6 +52,8 @@ public class ShopDataServiceImpl implements ShopDataService { @Autowired private ShopSourceTypeConfigDao shopPaytypeConfigDao; + private EnumCheck enumUtil = new EnumCheck<>(); + @Override public List getAllShopNodes() { List result = new ArrayList<>(0); @@ -68,7 +69,8 @@ public class ShopDataServiceImpl implements ShopDataService { node.setOpen(true); node.setShoptype(shop.getShoptype()); node.setShopaccno(StringUtil.isEmpty(shop.getShopaccno()) ? "" : shop.getShopaccno()); - node.setIconSkin(shop.getShoptype() == 0 ? "pIcon01" : "pIcon02"); + node.setIconSkin(enumUtil.isInEnums(shop.getShoptype(), + ShopTypes.ROOT, ShopTypes.GROUP) ? "pIcon01" : "pIcon02"); result.add(node); } } @@ -86,6 +88,9 @@ public class ShopDataServiceImpl implements ShopDataService { @Override public boolean deleteShop(TShop shop) throws WebCheckException { if (null != shop) { + if (ShopTypes.ROOT.value().equals(shop.getShoptype())) { + throw new WebCheckException("不能删除根商户节点"); + } List childShops = shopDao.getChildShopsByShopid(shop.getShopid()); if (!StringUtil.isEmpty(childShops)) throw new WebCheckException("请先删除下级商户"); @@ -110,7 +115,8 @@ public class ShopDataServiceImpl implements ShopDataService { TShop fshop = shopDao.getTShopByShopid(shop.getFshopid()); if (null == fshop) { throw new WebCheckException("上级商户不存在!"); - } else if (fshop.getShoptype() == 1) { + } else if (!enumUtil.isInEnums(fshop.getShoptype(), + ShopTypes.ROOT, ShopTypes.GROUP)) { throw new WebCheckException("上级商户不是商户组!"); } } @@ -130,7 +136,7 @@ public class ShopDataServiceImpl implements ShopDataService { shop.setOpendate(dt.getHostdate()); shop.setTenantId(TenantContext.getTenantSchema()); shopDao.save(shop); - if (shop.getShoptype() == 1) { + if (enumUtil.isInEnums(shop.getShoptype(), ShopTypes.NORMAL)) { TShopacc shopacc = new TShopacc(); shopacc.setShopaccno(String.format("2%09d", shop.getShopid())); shopacc.setShopid(shop.getShopid()); diff --git a/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java b/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java index 4bd34fe7..ce13e1a0 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/util/ConstantUtil.java @@ -19,9 +19,6 @@ public class ConstantUtil { public static final String IDTYPE_OTHER = "9"; //其他 public static final String[] IDTYPE_DICTS = {"1", "2", "3", "4", "5", "9"}; //联动 - public static final int SHOPTYPE_GROUP = 0; //商户组 - public static final int SHOPTYPE_LEAF = 1; //末级商户,独立核算商户 - public static final String FEETYPE_DEFAULT = "none"; public static final String FEETYPE_MEALER = "mealer"; public static final String FEETYPE_DISCOUNT = "discount"; diff --git a/payapi/src/main/java/com/supwisdom/dlpay/util/EnumCheck.java b/payapi/src/main/java/com/supwisdom/dlpay/util/EnumCheck.java new file mode 100644 index 00000000..953aa5f2 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/util/EnumCheck.java @@ -0,0 +1,12 @@ +package com.supwisdom.dlpay.util; + +public class EnumCheck { + public boolean isInEnums(U value, T... expected) { + for (T item : expected) { + if (item.toString().equals(value)) { + return true; + } + } + return false; + } +} diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/shop_service_impl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/shop_service_impl.kt index 07c6c402..068cca72 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/shop_service_impl.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/shop_service_impl.kt @@ -1,18 +1,19 @@ package com.supwisdom.dlpay.api.service.impl import com.supwisdom.dlpay.api.bean.OpenShopParam +import com.supwisdom.dlpay.api.service.ShopService +import com.supwisdom.dlpay.api.util.ShopTypes +import com.supwisdom.dlpay.exception.TransactionProcessException import com.supwisdom.dlpay.framework.dao.ShopDao import com.supwisdom.dlpay.framework.dao.ShopaccDao 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.Subject -import com.supwisdom.dlpay.api.service.ShopService -import com.supwisdom.dlpay.exception.TransactionProcessException 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.framework.util.TradeErrorCode -import com.supwisdom.dlpay.util.ConstantUtil +import com.supwisdom.dlpay.util.EnumCheck import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @@ -28,8 +29,10 @@ class ShopServiceImpl : ShopService { @Autowired private lateinit var systemUtilService: SystemUtilService + private val shoptypeCheck = EnumCheck() + override fun findByThirdUniqueId(uniqueId: String): TShop? { - return shopDao.getByThirdUniqueIdenty(uniqueId) + return shopDao.getByThirdUniqueIdenty(uniqueId) } override fun registerShop(param: OpenShopParam): TShop { @@ -60,7 +63,7 @@ class ShopServiceImpl : ShopService { opendate = systemdatetime.hostdate thirdUniqueIdenty = param.shopUniqueId }) - if (ConstantUtil.SHOPTYPE_GROUP != shop.shoptype) { + if (shoptypeCheck.isInEnums(shop.shoptype, ShopTypes.NORMAL)) { //非商户组要创建账号 val shopaccno = String.format("2%09d", shop.shopid) shopaccDao.save(TShopacc().apply { diff --git a/payapi/src/main/resources/data.sql b/payapi/src/main/resources/data.sql index 83933b69..fdeebca8 100644 --- a/payapi/src/main/resources/data.sql +++ b/payapi/src/main/resources/data.sql @@ -498,7 +498,7 @@ INSERT INTO "tb_task_lock" ("taskcode", "remark", "taskstatus", "tasktime", "ten VALUES ('DAYENDSETTLETASK', '日终结算', '0', '20190619100600', '{tenantid}'); INSERT INTO "tb_shop" ("shopid", "shopname", "shoptype", "fshopid", "status", "opendate", "tenantid") -VALUES (1, '支付中心', 0, 0, 'normal', '20190517', '{tenantid}'); +VALUES (1, '支付中心', 'root', 0, 'normal', '20190517', '{tenantid}'); INSERT INTO "tb_transcode" ("transcode", "transname", "tenantid") VALUES (3010, '市民卡代扣', '{tenantid}'); diff --git a/payapi/src/main/resources/templates/system/shop/config.html b/payapi/src/main/resources/templates/system/shop/config.html index b8acc1d1..ed1b0276 100644 --- a/payapi/src/main/resources/templates/system/shop/config.html +++ b/payapi/src/main/resources/templates/system/shop/config.html @@ -14,7 +14,8 @@ 商户树(双击结算商户查询)
-
    +
      @@ -28,16 +29,20 @@   - - - -
      +
      @@ -47,22 +52,26 @@ @@ -110,18 +119,21 @@ $("#search-sourceType").val(""); form.render('select'); }); - $('#btn-search-shopsourcetype').click(function(){ + $('#btn-search-shopsourcetype').click(function () { var ptype = $("#search-sourceType").val(); - table.reload('shopPaytypeTable', {where: {sourceType: ptype, shopaccno:""}, page: {curr: 1}}); + table.reload('shopPaytypeTable', {where: {sourceType: ptype, shopaccno: ""}, page: {curr: 1}}); }); function ondblclick(event, treeId, treeNode) { - if (treeNode.shoptype !== 1 || ""===treeNode.shopaccno) { + if (treeNode.shoptype !== 'normal' || "" === treeNode.shopaccno) { layer.msg("请选择结算商户查询", {icon: 2, time: 1000}); return; } var ptype = $("#search-sourceType").val(); - table.reload('shopPaytypeTable', {where: {sourceType: ptype, shopaccno: treeNode.shopaccno}, page: {curr: 1}}); + table.reload('shopPaytypeTable', { + where: {sourceType: ptype, shopaccno: treeNode.shopaccno}, + page: {curr: 1} + }); } // 渲染表格 @@ -132,8 +144,15 @@ width: 1010, cols: [ [ - {field: 'shopaccno', title: '商户账号', width: 150, align: 'center', fixed: 'left', sort: true}, - {field: 'shopname', title: '商户名称', align: 'center', fixed: 'left', sort: true}, + { + field: 'shopaccno', + title: '商户账号', + width: 150, + align: 'center', + fixed: 'left', + sort: true + }, + {field: 'shopname', title: '商户名称', align: 'center', fixed: 'left', sort: true}, {field: 'paydesc', title: '支付方式', align: 'center', sort: true}, { field: 'consumeEnable', @@ -159,7 +178,8 @@ templet: '#shop-reverseenable-tpl-state', sort: true }, - {align: 'center', title: '操作', width: 90, fixed: 'right', templet: function (item) { + { + align: 'center', title: '操作', width: 90, fixed: 'right', templet: function (item) { if (item.sourceType !== 'balance') { return '配置'; } @@ -181,7 +201,7 @@ _csrf: token }, function (data) { if (data.code === 200) { - layer.msg(data.msg, {icon: 1, time:1000}); + 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 () { @@ -192,7 +212,7 @@ $(obj.elem).prop('checked', !obj.elem.checked); form.render('checkbox'); } - },function () { + }, function () { layer.msg('请求失败了,请稍后再试', {icon: 2}); $(obj.elem).prop('checked', !obj.elem.checked); form.render('checkbox'); @@ -243,13 +263,13 @@ return; } var shopNode = shopNodes[0]; //选中商户 - if(shopNode.shoptype!==1 || ""===shopNode.shopaccno){ + if (shopNode.shoptype !== 'normal' || "" === shopNode.shopaccno) { layer.msg("请选择结算商户!", {icon: 2, time: 1000}); return; } admin.putTempData('t_addshopsourcetype', { - shopaccno:shopNode.shopaccno, - shopname: shopNode.name.slice(shopNode.id.length+1) //23_第一食堂,截取商户名称 + shopaccno: shopNode.shopaccno, + shopname: shopNode.name.slice(shopNode.id.length + 1) //23_第一食堂,截取商户名称 }); admin.popupCenter({ title: "新增支付能力", diff --git a/payapi/src/main/resources/templates/system/shop/index.html b/payapi/src/main/resources/templates/system/shop/index.html index 0da8653a..32ab1dca 100644 --- a/payapi/src/main/resources/templates/system/shop/index.html +++ b/payapi/src/main/resources/templates/system/shop/index.html @@ -14,20 +14,24 @@ 商户树(双击商户进行修改)
      -
        +
          -