package com.supwisdom.dlpay.system.controller; import com.supwisdom.dlpay.api.annotation.ShopType; 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.types.IDTypes; import com.supwisdom.dlpay.api.types.ShopTypes; import com.supwisdom.dlpay.framework.domain.*; import com.supwisdom.dlpay.framework.service.SystemUtilService; import com.supwisdom.dlpay.framework.util.*; import com.supwisdom.dlpay.system.bean.ShopCheckBean; import com.supwisdom.dlpay.system.bean.ShopConfigBean; import com.supwisdom.dlpay.system.bean.TreeSelectNode; 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.apache.commons.lang.math.NumberUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.userdetails.UserDetails; 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; @Autowired private DictionaryProxy dictionaryProxy; private EnumCheck shopTypeCheck = new EnumCheck<>(); @GetMapping("/shop/index") public String shopView(Model model) { model.addAttribute("shopNeedCheck", systemUtilService.getSysparaValueAsBoolean(SysparaUtil.SHOP_NEEDCHECK_SWITCH)); return "system/shop/index"; } @GetMapping("/shop/shoptree") @PreAuthorize("hasPermission('/shop/index','')") @ResponseBody public JsonResult shopTreeData(@AuthenticationPrincipal UserDetails operUser) { try { TOperator oper = (TOperator) operUser; return JsonResult.ok("OK").put("data", shopDataService.getShopManageLayerShopTree(oper.getOperid())); } catch (Exception e) { return JsonResult.error("查询商户树失败!").put("exception", e); } } @GetMapping("/shop/shoplist") @PreAuthorize("hasPermission('/shop/index','')") @ResponseBody public PageResult getShopBySearch(@RequestParam("page") Integer pageNo, @RequestParam("limit") Integer pageSize, @RequestParam(value = "status", required = false) String status, @RequestParam(value = "shopname", required = false) String shopname, @RequestParam(value = "shopid", required = false) Integer shopid) { try { if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; return shopDataService.getShopListBySearch(status, shopname, shopid, pageNo, pageSize); } catch (Exception e) { e.printStackTrace(); return new PageResult<>(99, "系统查询错误"); } } @PostMapping("/shop/deleteshop") @PreAuthorize("hasPermission('/shop/deleteshop','')") @ResponseBody public JsonResult deleteShop(@RequestParam("shopid") Integer shopid, @AuthenticationPrincipal UserDetails operUser) { TShop shop = shopDataService.getShopByShopid(shopid); if (null == shop) { return JsonResult.error("商户不存在,请重新查询"); //商户不存在,请重新查询 } try { TOperator oper = (TOperator) operUser; boolean needCheck = systemUtilService.getSysparaValueAsBoolean(SysparaUtil.SHOP_NEEDCHECK_SWITCH); int ret = shopDataService.deleteShop(shop, needCheck, oper); if (0 == ret) { return JsonResult.ok("删除成功"); } else if (ret > 0) { return JsonResult.ok("删除申请成功"); } return JsonResult.error(needCheck ? "删除申请失败" : "删除失败"); } catch (WebCheckException ex) { return JsonResult.error(ex.getMessage()); } catch (Exception e) { return JsonResult.error("系统处理异常").put("exception", e); } } @GetMapping("/shop/load4addshop") @PreAuthorize("hasPermission('/shop/load4addshop','')") public String load4AddShop(Model model) { model.addAttribute(Dictionary.IDTYPE, dictionaryProxy.getDictionaryAsList(Dictionary.IDTYPE)); return "system/shop/addshop"; } @GetMapping("/shop/selectshopgroup") @PreAuthorize("hasPermission('/shop/index','')") @ResponseBody public List searchShopTree() { return shopDataService.getChooseShopGroup(); } @PostMapping("/shop/addshop") @PreAuthorize("hasPermission('/shop/addshop','')") @ResponseBody public JsonResult addShop(@RequestParam("shoptype") String shoptype, @RequestParam("fshopid") Integer fshopid, @RequestParam("shopname") String shopname, @RequestParam("businessLicenseNo") String businessLicenseNo, @RequestParam("taxRegistrationNo") String taxRegistrationNo, @RequestParam("addr") String addr, @RequestParam("legalPersonName") String legalPersonName, @RequestParam("legalPersonIdtype") String legalPersonIdtype, @RequestParam("legalPersonIdno") String legalPersonIdno, @RequestParam("contactman") String contactman, @RequestParam("mobile") String mobile, @RequestParam("email") String email, @RequestParam("tel") String tel, @AuthenticationPrincipal UserDetails operUser) { if (StringUtil.isEmpty(shopname) || null == fshopid || !shopTypeCheck.isInEnums(shoptype, ShopTypes.NORMAL, ShopTypes.GROUP, ShopTypes.ROOT)) { return JsonResult.error("参数传递错误"); } else if (ShopTypes.NORMAL.toString().equals(shoptype) && (StringUtil.isEmpty(businessLicenseNo) || StringUtil.isEmpty(taxRegistrationNo) || StringUtil.isEmpty(addr) || StringUtil.isEmpty(legalPersonName) || StringUtil.isEmpty(legalPersonIdtype) || StringUtil.isEmpty(legalPersonIdno))) { return JsonResult.error("参数传递错误,结算商户必须填写商户营业信息!"); }else if(!StringUtil.isEmpty(businessLicenseNo) && !StringUtil.checkBusinessLicenseNo(businessLicenseNo.trim())){ return JsonResult.error("参数错误,请正确填写营业执照编号!"); } TShop shop = new TShop(); shop.setFshopid(fshopid); shop.setShopname(shopname); shop.setShoptype(shoptype); shop.setBusinessLicenseNo(null == businessLicenseNo ? null : businessLicenseNo.trim()); shop.setTaxRegistrationNo(null == taxRegistrationNo ? null : taxRegistrationNo.trim()); shop.setAddr(null == addr ? null : addr.trim()); shop.setLegalPersonName(null == legalPersonName ? null : legalPersonName.trim()); shop.setLegalPersonIdtype(null == legalPersonIdtype ? null : legalPersonIdtype.trim()); shop.setLegalPersonIdno(null == legalPersonIdno ? null : legalPersonIdno); if (!StringUtil.isEmpty(shop.getLegalPersonIdno()) && StringUtil.isEmpty(shop.getLegalPersonIdtype())) { return JsonResult.error("填写法人证件号时必须指定证件类型!"); } else if (!StringUtil.isEmpty(shop.getLegalPersonIdno()) && IDTypes.IDCARD.value().equals(shop.getLegalPersonIdtype()) && !StringUtil.isIdentity(shop.getLegalPersonIdno())) { return JsonResult.error("身份证格式错误!"); } shop.setContactman(contactman == null ? null : contactman.trim()); shop.setMobile(mobile); if (!StringUtil.isEmpty(shop.getMobile()) && !StringUtil.isMobile(shop.getMobile())) { return JsonResult.error("请正确填写联系人手机号!"); } shop.setTel(tel == null ? null : tel.trim()); shop.setEmail(email == null ? null : email.trim()); if (!StringUtil.isEmpty(shop.getEmail()) && !StringUtil.isEmail(shop.getEmail())) { return JsonResult.error("请正确填写联系人邮箱!"); } try { TOperator oper = (TOperator) operUser; boolean needCheck = systemUtilService.getSysparaValueAsBoolean(SysparaUtil.SHOP_NEEDCHECK_SWITCH); int ret = shopDataService.saveNewShop(shop, needCheck, oper); if (ret == 0) { return JsonResult.ok("新增成功!"); } else if (ret > 0) { return JsonResult.ok("新增申请成功!"); } return JsonResult.error(needCheck ? "新增申请失败" : "新增失败"); } catch (WebCheckException ex) { return JsonResult.error(ex.getMessage()); } catch (Exception e) { e.printStackTrace(); return JsonResult.error("系统处理异常").put("exception", e); } } @GetMapping("/shop/load4updateshop") @PreAuthorize("hasPermission('/shop/load4updateshop','')") public String load4UpdateShop(@RequestParam("shopid") Integer shopid, Model model) { TShop shop = shopDataService.getShopByShopid(shopid); model.addAttribute("shop", shop != null ? shop : new TShop()); model.addAttribute(Dictionary.IDTYPE, dictionaryProxy.getDictionaryAsList(Dictionary.IDTYPE)); return "system/shop/updateshop"; } @PostMapping("/shop/updateshop") @PreAuthorize("hasPermission('/shop/updateshop','')") @ResponseBody public JsonResult updateShop(@RequestParam("shopid") Integer shopid, @RequestParam("fshopid") Integer fshopid, @RequestParam("shopname") String shopname, @RequestParam("businessLicenseNo") String businessLicenseNo, @RequestParam("taxRegistrationNo") String taxRegistrationNo, @RequestParam("addr") String addr, @RequestParam("legalPersonName") String legalPersonName, @RequestParam("legalPersonIdtype") String legalPersonIdtype, @RequestParam("legalPersonIdno") String legalPersonIdno, @RequestParam("contactman") String contactman, @RequestParam("mobile") String mobile, @RequestParam("email") String email, @RequestParam("tel") String tel, @AuthenticationPrincipal UserDetails operUser) { if (null == shopid || StringUtil.isEmpty(shopname) || null == fshopid) { return JsonResult.error("参数传递错误"); } TShop oldShop = shopDataService.getShopByShopid(shopid); if (null == oldShop) { return JsonResult.error("商户不存在,修改失败!请重新查询"); } if (ShopTypes.NORMAL.toString().equals(oldShop.getShoptype()) && (StringUtil.isEmpty(businessLicenseNo) || StringUtil.isEmpty(taxRegistrationNo) || StringUtil.isEmpty(addr) || StringUtil.isEmpty(legalPersonName) || StringUtil.isEmpty(legalPersonIdtype) || StringUtil.isEmpty(legalPersonIdno))) { return JsonResult.error("参数传递错误,结算商户必须填写商户营业信息!"); }else if(!StringUtil.isEmpty(businessLicenseNo) && !StringUtil.checkBusinessLicenseNo(businessLicenseNo.trim())){ return JsonResult.error("参数错误,请正确填写营业执照编号!"); } TShop shop=new TShop(); BeanUtils.copyProperties(oldShop, shop); //TODO:避免JPA的set方法会提交数据库 shop.setFshopid(fshopid); shop.setShopname(shopname); shop.setBusinessLicenseNo(null == businessLicenseNo ? null : businessLicenseNo.trim()); shop.setTaxRegistrationNo(null == taxRegistrationNo ? null : taxRegistrationNo.trim()); shop.setAddr(null == addr ? null : addr.trim()); shop.setLegalPersonName(null == legalPersonName ? null : legalPersonName.trim()); shop.setLegalPersonIdtype(null == legalPersonIdtype ? null : legalPersonIdtype.trim()); shop.setLegalPersonIdno(null == legalPersonIdno ? null : legalPersonIdno); if (!StringUtil.isEmpty(shop.getLegalPersonIdno()) && StringUtil.isEmpty(shop.getLegalPersonIdtype())) { return JsonResult.error("填写法人证件号时必须指定证件类型!"); } else if (!StringUtil.isEmpty(shop.getLegalPersonIdno()) && IDTypes.IDCARD.value().equals(shop.getLegalPersonIdtype()) && !StringUtil.isIdentity(shop.getLegalPersonIdno())) { return JsonResult.error("身份证格式错误!"); } shop.setContactman(contactman == null ? null : contactman.trim()); shop.setMobile(mobile); if (!StringUtil.isEmpty(shop.getMobile()) && !StringUtil.isMobile(shop.getMobile())) { return JsonResult.error("请正确填写联系人手机号!"); } shop.setTel(tel == null ? null : tel.trim()); shop.setEmail(email == null ? null : email.trim()); if (!StringUtil.isEmpty(shop.getEmail()) && !StringUtil.isEmail(shop.getEmail())) { return JsonResult.error("请正确填写联系人邮箱!"); } try { TOperator oper = (TOperator) operUser; boolean needCheck = systemUtilService.getSysparaValueAsBoolean(SysparaUtil.SHOP_NEEDCHECK_SWITCH); int ret = shopDataService.updateShop(shop, needCheck, oper); if (ret == 0) { return JsonResult.ok("修改成功!"); } else if (ret > 0) { return JsonResult.ok("修改申请成功!"); } return JsonResult.error(needCheck ? "修改申请失败" : "修改失败"); } catch (WebCheckException ex) { return JsonResult.error(ex.getMessage()); } catch (Exception e) { e.printStackTrace(); return JsonResult.error("系统处理异常").put("exception", e); } } @GetMapping("/shop/getshopinfo") @PreAuthorize("hasPermission('/shop/getshopinfo','')") public String getShopInfo(@RequestParam("shopid") Integer shopid,Model model) { TShop shop = shopDataService.getShopByShopid(shopid); model.addAttribute("shop", shop != null ? shop : new TShop()); model.addAttribute(Dictionary.IDTYPE, dictionaryProxy.getDictionaryAsList(Dictionary.IDTYPE)); return "system/shop/shopdetail"; } @GetMapping("/shop/getshopchk") @PreAuthorize("hasPermission('/shop/getshopchk','')") public String getShopChkdtl(@RequestParam("shopid") Integer shopid,Model model) { model.addAttribute("selectShopid", shopid); return "system/shop/shopchk"; } @GetMapping("/shop/getshopchklist") @PreAuthorize("hasPermission('/shop/getshopchk','')") @ResponseBody public PageResult getShopBySearch(@RequestParam("page") Integer pageNo, @RequestParam("limit") Integer pageSize, @RequestParam(value = "shopid", required = false) String shopid, @RequestParam(value = "status", required = false) String status, @RequestParam(value = "searchkey", required = false) String searchkey) { try { if (StringUtil.isEmpty(shopid)) return new PageResult<>(99, "无数据"); if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; return shopDataService.getShopChkdtlDetails(shopid, status, searchkey, pageNo, pageSize); } catch (Exception e) { e.printStackTrace(); return new PageResult<>(99, "系统查询错误"); } } /** * ==================================================== * 商户审批 * ==================================================== */ @GetMapping("/shop/shopcheck") @PreAuthorize("hasPermission('/shop/shopcheck','')") public String shopCheckIndex(){ return "system/shop/shopcheck"; } @GetMapping("/shop/shopchecklist") @PreAuthorize("hasPermission('/shop/shopcheck','')") @ResponseBody public PageResult shopCheckIndex(@RequestParam("page") Integer pageNo, @RequestParam("limit") Integer pageSize, @RequestParam(value = "shopid", required = false) String shopid, @RequestParam(value = "status", required = false) String status, @RequestParam(value = "searchkey", required = false) String searchkey) { try { if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; return shopDataService.getShopChkdtlDetails(shopid, status, searchkey, pageNo, pageSize); } catch (Exception e) { e.printStackTrace(); return new PageResult<>(99, "系统查询错误"); } } @GetMapping("/shop/opercheck") @PreAuthorize("hasPermission('/shop/opercheck','')") public String shopOperCheck(@RequestParam("chkno") Long chkno, Model map) { TOperChkdtl chkdtl = shopDataService.getOperChkdtlByChkno(chkno); ShopCheckBean shop = shopDataService.getOperChkShopInfo(chkdtl); map.addAttribute("operChkdtl", chkdtl); map.addAttribute("shop", shop); return "system/shop/opercheck"; } @PostMapping("/shop/docheckshop") @PreAuthorize("hasPermission('/shop/docheckshop','')") @ResponseBody public JsonResult doCheckShop(@RequestParam("chkno") String chkno, @RequestParam("chkresult") String chkresult, @RequestParam("chkmsg") String chkmsg, @AuthenticationPrincipal UserDetails operUser) { if(!NumberUtils.isDigits(chkno) || (!TradeDict.STATUS_NORMAL.equals(chkresult) && !TradeDict.STATUS_REJECT.equals(chkresult))){ return JsonResult.error("参数传递错误"); }else if(!TradeDict.STATUS_NORMAL.equals(chkresult) && StringUtil.isEmpty(chkmsg)){ return JsonResult.error("驳回必须填写审核意见!"); } try { TOperator oper = (TOperator) operUser; TOperChkdtl chkdtl = shopDataService.doCheckShopChkdtl(Long.valueOf(chkno), TradeDict.STATUS_NORMAL.equals(chkresult), chkmsg, oper); if (chkresult.equals(chkdtl.getChkResult())) { return JsonResult.ok(TradeDict.STATUS_NORMAL.equals(chkresult) ? "审核成功!" : "驳回成功!"); } else { return JsonResult.ok(299, chkdtl.getChkMsg()); } } catch (WebCheckException ex) { return JsonResult.error(ex.getMessage()); } catch (Exception e) { e.printStackTrace(); return JsonResult.error("系统处理异常").put("exception", e); } } // @PostMapping("/shop/saveorupdate") // @PreAuthorize("hasPermission('/shop/saveorupdate','')") // @ResponseBody // public JsonResult saveOrUpdateShop(@RequestParam("shopid") Integer shopid, @RequestParam("shopname") String shopname, // @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, // @RequestParam(value = "mobile", required = false) String mobile, // @RequestParam(value = "tel", required = false) String tel, // @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 // || !shopTypeCheck.isInEnums(shoptype, ShopTypes.NORMAL, ShopTypes.GROUP, ShopTypes.ROOT)) { // return JsonResult.error("参数传递错误"); // } // // TShop shop; // boolean addflag = false; // if (shopid == 0) { // //新增 // addflag = true; // shop = new TShop(); // shop.setFshopid(fshopid); // shop.setShopname(shopname); // shop.setShoptype(shoptype); // shop.setStatus(TradeDict.STATUS_NORMAL); // } else { // //修改 // shop = shopDataService.getShopByShopid(shopid); // if (null == shop) { // return JsonResult.error("商户不存在,修改失败!请重新查询"); // } // shop.setFshopid(fshopid); // shop.setShopname(shopname); // } // shop.setContactman(contactman == null ? null : contactman.trim()); // shop.setIdno(idno == null ? null : idno.trim()); // shop.setIdtype(idtype == null ? null : idtype.trim()); // if (!StringUtil.isEmpty(shop.getIdno()) && StringUtil.isEmpty(shop.getIdtype())) { // return JsonResult.error("填写证件号时必须制定证件类型!"); // } else if (!StringUtil.isEmpty(shop.getIdno()) && IDTypes.IDCARD.value().equals(shop.getIdtype()) && !StringUtil.isIdentity(shop.getIdno())) { // return JsonResult.error("身份证格式错误!"); // } // shop.setMobile(mobile); // if (!StringUtil.isEmpty(shop.getMobile()) && !StringUtil.isMobile(shop.getMobile())) { // return JsonResult.error("请正确填写手机号!"); // } // shop.setTel(tel == null ? null : tel.trim()); // shop.setEmail(email == null ? null : email.trim()); // if (!StringUtil.isEmpty(shop.getEmail()) && !StringUtil.isEmail(shop.getEmail())) { // return JsonResult.error("请正确填写邮箱地址!"); // } // 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 ? "新增失败" : "修改失败"); // } // } catch (WebCheckException ex) { // return JsonResult.error(ex.getMessage()); // } catch (Exception e) { // e.printStackTrace(); // return JsonResult.error("系统处理异常").put("exception", e); // } // } /** * ==================================================== * 商户支付能力配置 * ==================================================== */ @GetMapping("/shop/config") public String shopConfigView(Model model) { model.addAttribute(Dictionary.PAY_TYPE, dictionaryProxy.getDictionaryAsList(Dictionary.SOURCE_TYPE)); return "system/shop/config"; } @GetMapping("/shop/shopacctree") @PreAuthorize("hasPermission('/shop/config','')") @ResponseBody public JsonResult shopaccTreeData() { return JsonResult.ok("OK").put("data", shopDataService.getLayerShopTree()); } @GetMapping("/shop/shopsourcetypelist") @PreAuthorize("hasPermission('/shop/shopsourcetypelist','')") @ResponseBody public PageResult getShopPaytypeList(@RequestParam("page") Integer pageNo, @RequestParam("limit") Integer pageSize, @RequestParam(value = "sourcetype", required = false) String sourcetype, @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, sourcetype, pageNo, pageSize); } catch (Exception e) { e.printStackTrace(); return new PageResult<>(99, "系统查询错误"); } } @PostMapping("/shop/updatesourcetypestat") @PreAuthorize("hasPermission('/shop/updatesourcetypestat','')") @ResponseBody public JsonResult updateShopPaytypeStat(@RequestParam("shopaccno") String shopaccno, @RequestParam("sourceType") String sourcetype, @RequestParam("state") String state, @RequestParam("optype") String optype) { if (StringUtil.isEmpty(shopaccno) || StringUtil.isEmpty(sourcetype) || (!ConstantUtil.ENABLE_NO.equals(state) && !ConstantUtil.ENABLE_YES.equals(state)) || (!"consume".equals(optype) && !"anonymous".equals(optype) && !"reverse".equals(optype))) { return JsonResult.error("参数传递错误"); } try { TShopSourceType shopPaytype = shopDataService.getShopPaytype(shopaccno.trim(), sourcetype.trim()); if (null == shopPaytype) { return JsonResult.error("商户支付能力不存在!"); } if ("consume".equals(optype)) { if (state.equals(shopPaytype.getConsumeEnable())) { return JsonResult.error("状态错误,请重新查询后操作"); } shopPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES.equals(state)); } else if ("anonymous".equals(optype)) { if (state.equals(shopPaytype.getAnonymousEnable())) { return JsonResult.error("状态错误,请重新查询后操作"); } shopPaytype.setAnonymousEnable(ConstantUtil.ENABLE_YES.equals(state)); } else if ("refund".equals(optype)) { if (state.equals(shopPaytype.getReverseEnable())) { return JsonResult.error("状态错误,请重新查询后操作"); } shopPaytype.setReverseEnable(ConstantUtil.ENABLE_YES.equals(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/load4addsourcetype") @PreAuthorize("hasPermission('/shop/load4addsourcetype','')") public String load4AddShopPaytype(Model model) { model.addAttribute(Dictionary.PAY_TYPE, dictionaryProxy.getDictionaryAsList(Dictionary.SOURCE_TYPE)); return "system/shop/configform"; } @PostMapping("/shop/addshopsourcetype") @PreAuthorize("hasPermission('/shop/addshopsourcetype','')") @ResponseBody public JsonResult addShopsourcetype(@RequestParam("shopaccno") String shopaccno, @RequestParam("sourcetype") String sourcetype, @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(sourcetype)) { return JsonResult.error("参数传递错误"); } try { TShopacc shopacc = shopDataService.getShopaccByAccno(shopaccno.trim()); TSourceType tPaytype = paramService.getSourceType(sourcetype.trim()); if (null == shopacc) { return JsonResult.error("商户账户不存在!"); } if (null == tPaytype) { return JsonResult.error("支付方式在系统中不存在!"); } TShopSourceType shopPaytype = shopDataService.getShopPaytype(shopaccno.trim(), sourcetype.trim()); if (null != shopPaytype) { return JsonResult.error("商户该支付能力已经存在!"); } shopPaytype = new TShopSourceType(); shopPaytype.setShopaccno(shopacc.getShopaccno()); shopPaytype.setSourceType(tPaytype.getSourceType()); shopPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(consumeEnable)); shopPaytype.setAnonymousEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(anonymousEnable)); shopPaytype.setReverseEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(reverseEnable)); 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/load4sourcetypepara") @PreAuthorize("hasPermission('/shop/load4sourcetypepara','')") public String load4AddShopPaytypePara(@RequestParam("shopaccno") String shopaccno, @RequestParam("sourceType") String sourcetype, Model model) { List configList = shopDataService.getShopPaytypeConfigs(shopaccno, sourcetype); model.addAttribute("configlist", configList); model.addAttribute("shopaccno", shopaccno); model.addAttribute("sourcetype", sourcetype); return "system/shop/configpara"; } @PostMapping("/shop/addsourcetypepara") @PreAuthorize("hasPermission('/shop/addsourcetypepara','')") @ResponseBody public JsonResult addShopPaytypePara(@RequestBody Map param) { String shopaccnoHtmlKey = "hid_shopaccno"; //页面上传来shopaccno的KEY String sourcetypeHtmlKey = "hid_sourcetype"; //页面上传来sourcetype的KEY if (null == param || StringUtil.isEmpty(param.get(sourcetypeHtmlKey)) || StringUtil.isEmpty(param.get(shopaccnoHtmlKey))) { return JsonResult.error("参数传递错误"); } try { String shopaccno = param.get(shopaccnoHtmlKey).trim(); String sourcetype = param.get(sourcetypeHtmlKey).trim(); param.remove(shopaccnoHtmlKey); param.remove(sourcetypeHtmlKey); if (shopDataService.saveOrUpdateShopPaytypeConfig(shopaccno, sourcetype, 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); } } }