From 3ed726289c9bf558d8be6eef2aaa20f7f5b0ed67 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 12 Dec 2022 15:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiIpAddressController.java | 158 ++++++++++++++++++ .../controller/ApiMerchantsController.java | 96 +++++++++-- .../com/bweb/controller/LoginController.java | 5 + .../java/com/hai/entity/OutRechargeOrder.java | 4 +- .../com/hai/service/ApiIpAddressService.java | 68 ++++++++ .../com/hai/service/SecConfigService.java | 21 +++ .../service/impl/ApiIpAddressServiceImpl.java | 53 ++++++ .../hai/service/impl/ApiOpenServiceImpl.java | 2 - .../service/impl/SecConfigServiceImpl.java | 35 ++++ .../v1/controller/ApiMerchantsController.java | 97 +++++++++++ .../com/v1/controller/ApiOrderController.java | 12 ++ .../controller/RechargeProductController.java | 59 ------- 12 files changed, 534 insertions(+), 76 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/ApiIpAddressController.java create mode 100644 hai-service/src/main/java/com/hai/service/ApiIpAddressService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/ApiIpAddressServiceImpl.java create mode 100644 v1/src/main/java/com/v1/controller/ApiMerchantsController.java create mode 100644 v1/src/main/java/com/v1/controller/ApiOrderController.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiIpAddressController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiIpAddressController.java new file mode 100644 index 00000000..bf395a74 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiIpAddressController.java @@ -0,0 +1,158 @@ +package com.bweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.RedisUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.ApiIpAddress; +import com.hai.entity.ApiMerchants; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.ApiIpAddressService; +import com.hai.service.ApiMerchantsService; +import com.hai.service.CommonService; +import com.hai.service.SecConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/apiIpAddress") +@Api(value = "Ip地址管理") +public class ApiIpAddressController { + + Logger log = LoggerFactory.getLogger(ApiMemberProductController.class); + + @Resource + private ApiIpAddressService apiIpAddressService; + + @Autowired + private UserCenter userCenter; + + @Resource + private SecConfigService secConfigService; + + @Resource + private ApiMerchantsService apiMerchantsService; + + + @RequestMapping(value="/editApiIpAddress",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "编辑ip地址") + public ResponseData editApiIpAddress(@RequestBody ApiIpAddress apiIpAddress, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getBsCompany() == null) { + log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + if (apiIpAddress.getMchId() == null) { + log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + ApiIpAddress apiIpAddressEdit = apiIpAddressService.findByMchId(apiIpAddress.getMchId()); + + // 判断是否存在ip地址内容 + if (apiIpAddressEdit == null ) { + apiIpAddress.setCreateTime(new Date()); + apiIpAddress.setUpdateTime(new Date()); + apiIpAddressService.insertApiIpAddress(apiIpAddress); + } else { + apiIpAddressEdit.setUpdateTime(new Date()); + apiIpAddressEdit.setIpAddress(apiIpAddress.getIpAddress()); + apiIpAddressService.updateApiIpAddress(apiIpAddressEdit); + } + + + + return ResponseMsgUtil.success("新增成功"); + } catch (Exception e) { + log.error("ApiMerchantsController -> insertMerchant() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/findByMchId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据商户号查询详情") + public ResponseData findByMchId(@RequestParam(value = "mchId", required = true) String mchId) { + try { + + return ResponseMsgUtil.success(apiIpAddressService.findByMchId(mchId)); + + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getSecConfigList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据商户号查询已配置接口") + public ResponseData getSecConfigList(@RequestParam(value = "mchId", required = true) String mchId) { + try { + + Map map = new HashMap<>(); + map.put("codeValue", mchId); + + return ResponseMsgUtil.success(secConfigService.getSecConfigList(map)); + + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/configMerchant",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "配置门店可用接口") + public ResponseData configMerchant(@RequestBody JSONObject object, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getBsCompany() == null) { + log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + if (object.getString("mchId") == null || object.getString("configProduct") == null) { + log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + ApiMerchants merchants = apiMerchantsService.findByMchId(object.getString("mchId")); + + if (merchants == null) { + log.error("ApiMemberProductController -> insertMemberProduct() error!","商户状态错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户状态错误"); + } + + secConfigService.configMerchant(object.getString("mchId") , object.getString("configProduct")); + + return ResponseMsgUtil.success("配置成功"); + } catch (Exception e) { + log.error("ApiMerchantsController -> insertMerchant() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java index 616cb572..a9cf9858 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java @@ -19,6 +19,7 @@ import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.ApiMerchantsService; import com.hai.service.ApiProductService; +import com.hai.service.OutRechargeOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -50,6 +52,9 @@ public class ApiMerchantsController { @Autowired private UserCenter userCenter; + @Resource + private OutRechargeOrderService outRechargeOrderService; + @Resource private RedisUtil redisUtil; @@ -275,19 +280,84 @@ public class ApiMerchantsController { } } - @RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "查询商户产品") - public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) { - try { - - return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId)); - - } catch (Exception e) { - log.error("ApiMerchantsController --> findById() error!", e); - return ResponseMsgUtil.exception(e); - } - } +// @RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET) +// @ResponseBody +// @ApiOperation(value = "查询商户产品") +// public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) { +// try { +// +// return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId)); +// +// } catch (Exception e) { +// log.error("ApiMerchantsController --> findById() error!", e); +// return ResponseMsgUtil.exception(e); +// } +// } +// +// @RequestMapping(value = "/getPhoneOrderList", method = RequestMethod.GET) +// @ResponseBody +// @ApiOperation(value = "获取订单") +// public ResponseData getPhoneOrderList( +// @RequestParam(name = "rechargeStatus", required = false) String rechargeStatus, +// @RequestParam(name = "orderNo", required = false) String orderNo, +// @RequestParam(name = "operatorType", required = false) String operatorType, +// @RequestParam(name = "laborUnionCard", required = false) String laborUnionCard, +// @RequestParam(name = "rechargeContent", required = false) String rechargeContent, +// @RequestParam(name = "userPhone", required = false) String userPhone, +// @RequestParam(name = "rechargeType", required = false) String rechargeType, +// @RequestParam(name = "payType", required = false) Integer payType, +// @RequestParam(name = "payTimeS", required = false) Long payTimeS, +// @RequestParam(name = "payTimeE", required = false) Long payTimeE, +// @RequestParam(name = "whetherTimeOut", required = false) Boolean whetherTimeOut, +// @RequestParam(name = "createTimeS", required = false) Long createTimeS, +// @RequestParam(name = "createTimeE", required = false) Long createTimeE, +// @RequestParam(name = "pageNum", required = true) Integer pageNum, +// @RequestParam(name = "pageSize", required = true) Integer pageSize, +// HttpServletRequest request) { +// try { +// +// SessionObject sessionObject = userCenter.getSessionObject(request); +// UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); +// +// Map map = new HashMap<>(); +// +// if (companyId != null) { +// map.put("companyId", companyId); +// } else if (userInfoModel.getSecRole().getRoleType() != 1){ +// if (userInfoModel.getSecRole().getRoleType() == 7) { +// map.put("companyId", 23); +// } else { +// map.put("companyId", userInfoModel.getBsCompany().getId()); +// } +// } +// +// map.put("rechargeStatus", rechargeStatus); +// map.put("payStatus", payStatus); +// map.put("orderNo", orderNo); +// map.put("whetherTimeOut", whetherTimeOut); +// map.put("operatorType", operatorType); +// map.put("laborUnionCard", laborUnionCard); +// map.put("rechargeContent", rechargeContent); +// map.put("userPhone", userPhone); +// map.put("rechargeType", rechargeType); +// map.put("payType", payType); +// if (payTimeS != null && payTimeE != null ) { +// map.put("payTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeS)); +// map.put("payTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeE)); +// } +// if (createTimeS != null && createTimeE != null) { +// map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); +// map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); +// } +// +// PageHelper.startPage(pageNum, pageSize); +// return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map))); +// +// } catch (Exception e) { +// log.error("HighOrderController --> getUserOrderList() error!", e); +// return ResponseMsgUtil.exception(e); +// } +// } } diff --git a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java index 571c006d..3482ab11 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java @@ -74,6 +74,9 @@ public class LoginController { @Resource private ApiMerchantsService apiMerchantsService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value="/userLogin",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "机构用户登录({'loginName':'','password':''})") @@ -246,6 +249,8 @@ public class LoginController { log.error("login error!","账户状态异常,请联系管理员"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户状态异常,请联系管理员"); } + ApiIpAddress apiIpAddress = apiIpAddressService.findByMchId(apiMerchants.getMchId()); + apiMerchants.setExt1(apiIpAddress.getIpAddress()); userInfoModel.setApiMerchants(apiMerchants); } else { diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java b/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java index 6bc226e1..f7f1f4fe 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java @@ -85,7 +85,7 @@ public class OutRechargeOrder implements Serializable { private String rechargeContent; /** - * 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期 + * 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期 6: api商户余额 */ private Integer payType; @@ -743,4 +743,4 @@ public class OutRechargeOrder implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/service/ApiIpAddressService.java b/hai-service/src/main/java/com/hai/service/ApiIpAddressService.java new file mode 100644 index 00000000..ffb2022a --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/ApiIpAddressService.java @@ -0,0 +1,68 @@ +package com.hai.service; + +import com.hai.entity.ApiAmountRecord; +import com.hai.entity.ApiIpAddress; + +import java.util.List; +import java.util.Map; + +/** + * @serviceName ApiIpAddressService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // Api商户IP地址管理 + * @createTime 14:18 2022/12/6 + **/ +public interface ApiIpAddressService { + + /** + * @Author Sum1Dream + * @Name insertApiIpAddress + * @Description // 新增ip地址内容 + * @Date 14:21 2022/12/6 + * @Param [apiIpAddress] + * @Return void + */ + void insertApiIpAddress(ApiIpAddress apiIpAddress); + + /** + * @Author Sum1Dream + * @Name updateApiIpAddress + * @Description // 修改IP地址内容 + * @Date 15:29 2022/12/6 + * @Param [apiIpAddress] + * @Return void + */ + void updateApiIpAddress(ApiIpAddress apiIpAddress); + + /** + * @Author Sum1Dream + * @Name findById + * @Description // 查询ip地址详情 + * @Date 14:19 2022/12/6 + * @Param [id] + * @Return com.hai.entity.ApiIpAddress + */ + ApiIpAddress findById(Long id); + + /** + * @Author Sum1Dream + * @Name findByMchId + * @Description // 根据商户号查询IP地址内容 + * @Date 14:23 2022/12/6 + * @Param [mchId] + * @Return com.hai.entity.ApiIpAddress + */ + ApiIpAddress findByMchId(String mchId); + + /** + * @Author Sum1Dream + * @Name getApiIpAddressByList + * @Description // 查询IP地址列表 + * @Date 14:19 2022/12/6 + * @Param [map] + * @Return java.util.List + */ + List getApiIpAddressByList(Map map); + +} diff --git a/hai-service/src/main/java/com/hai/service/SecConfigService.java b/hai-service/src/main/java/com/hai/service/SecConfigService.java index 278508de..dd132051 100644 --- a/hai-service/src/main/java/com/hai/service/SecConfigService.java +++ b/hai-service/src/main/java/com/hai/service/SecConfigService.java @@ -2,6 +2,7 @@ package com.hai.service; import com.hai.entity.SecConfig; +import java.util.List; import java.util.Map; import java.util.SortedMap; @@ -70,4 +71,24 @@ public interface SecConfigService { */ Boolean isSignVerify(Map map , String sign) throws Exception; + /** + * @Author Sum1Dream + * @Name getSecConfigList + * @Description // 查询数据 + * @Date 16:03 2022/12/7 + * @Param [map] + * @Return java.util.List + */ + List getSecConfigList(Map map); + + /** + * @Author Sum1Dream + * @Name configMerchant + * @Description // 配置商户 + * @Date 16:09 2022/12/7 + * @Param [mchId, configProduct] + * @Return void + */ + void configMerchant(String mchId , String configProduct); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiIpAddressServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiIpAddressServiceImpl.java new file mode 100644 index 00000000..5922a90d --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/ApiIpAddressServiceImpl.java @@ -0,0 +1,53 @@ +package com.hai.service.impl; + +import com.hai.dao.ApiIpAddressMapper; +import com.hai.entity.ApiIpAddress; +import com.hai.entity.ApiIpAddressExample; +import com.hai.service.ApiIpAddressService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("apiIpAddressService") +public class ApiIpAddressServiceImpl implements ApiIpAddressService { + + @Resource + private ApiIpAddressMapper apiIpAddressMapper; + + @Override + public void insertApiIpAddress(ApiIpAddress apiIpAddress) { + apiIpAddressMapper.insert(apiIpAddress); + } + + @Override + public void updateApiIpAddress(ApiIpAddress apiIpAddress) { + apiIpAddressMapper.updateByPrimaryKey(apiIpAddress); + } + + @Override + public ApiIpAddress findById(Long id) { + return apiIpAddressMapper.selectByPrimaryKey(id); + } + + @Override + public ApiIpAddress findByMchId(String mchId) { + ApiIpAddressExample example = new ApiIpAddressExample(); + ApiIpAddressExample.Criteria criteria = example.createCriteria(); + criteria.andMchIdEqualTo(mchId); + + List list = apiIpAddressMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } + + @Override + public List getApiIpAddressByList(Map map) { + return null; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java index f0957a77..5597abe8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java @@ -60,14 +60,12 @@ public class ApiOpenServiceImpl implements ApiOpenService { // 查询是否用重复订单 ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); - if (apiOrderRecord != null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS); } ApiProduct apiProduct = apiProductService.findById(productConfig.getProductId()); - // 当前账号余额是否可以充值当前金额 if (apiMerchants.getAmounts().compareTo(productConfig.getDiscountPrice()) < 0) { throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE); diff --git a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java index 9a732714..7a1f10a3 100644 --- a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java @@ -64,4 +64,39 @@ public class SecConfigServiceImpl implements SecConfigService { return signPost.equals(sign); } + @Override + public List getSecConfigList(Map map) { + SecConfigExample example = new SecConfigExample(); + SecConfigExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map , "codeValue") != null) { + criteria.andCodeValueEqualTo(MapUtils.getString(map , "codeValue")); + } + + return secConfigMapper.selectByExample(example); + } + + @Override + public void configMerchant(String mchId, String configProduct) { + SecConfigExample example = new SecConfigExample(); + + example.createCriteria().andCodeValueEqualTo(mchId); + + List list = secConfigMapper.selectByExample(example); + + // 删除当前所有配置 + for (SecConfig secConfig : list) { + secConfigMapper.deleteByPrimaryKey(secConfig.getId()); + } + + String [] configProductArray = configProduct.split(","); + + for (String s : configProductArray) { + SecConfig secConfig = new SecConfig(); + secConfig.setCodeType(s); + secConfig.setCodeValue(mchId); + secConfigMapper.insert(secConfig); + } + + } } diff --git a/v1/src/main/java/com/v1/controller/ApiMerchantsController.java b/v1/src/main/java/com/v1/controller/ApiMerchantsController.java new file mode 100644 index 00000000..bf70a102 --- /dev/null +++ b/v1/src/main/java/com/v1/controller/ApiMerchantsController.java @@ -0,0 +1,97 @@ +package com.v1.controller; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.ApiMerchants; +import com.hai.model.ResponseData; +import com.hai.service.*; +import com.v1.config.ToolConfig; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/apiMerchants") +@Api(value = "API商户接口") +public class ApiMerchantsController { + private static Logger log = LoggerFactory.getLogger(RechargeProductController.class); + + @Resource + private ApiMerchantsService apiMerchantsService; + + @Resource + private SecConfigService secConfigService; + + @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询帐户余额") + public ResponseData checkAccountBalance(@RequestBody JSONObject object , HttpServletRequest request ) { + try { + + String ip = ""; + // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for + if (request.getHeader("x-forwarded-for") == null) { + ip = request.getRemoteAddr(); + } else { + ip = request.getHeader("x-forwarded-for"); + } + + if (!secConfigService.isConfig("IP_WHITE" , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + + if (StringUtils.isBlank(object.getString("apiKey")) || + StringUtils.isBlank(object.getString("merchId")) || + StringUtils.isBlank(object.getString("timetable")) || + StringUtils.isBlank(object.getString("sign")) + ) { + log.error("getRechargeProduct error!", "请求参数校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + } + + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); + + if (apiMerchants == null) { + log.error("getRechargeProduct error!", "商户号错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("timetable" , object.getString("timetable")); + map.put("merchId" , object.getString("merchId")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) { + log.error("getRechargeProduct error!", "请求时间超过15分钟!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT); + } + + return ResponseMsgUtil.success(apiMerchants.getAmounts()); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/v1/src/main/java/com/v1/controller/ApiOrderController.java b/v1/src/main/java/com/v1/controller/ApiOrderController.java new file mode 100644 index 00000000..29cbc87f --- /dev/null +++ b/v1/src/main/java/com/v1/controller/ApiOrderController.java @@ -0,0 +1,12 @@ +package com.v1.controller; + +import io.swagger.annotations.Api; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping(value = "/apiOrder") +@Api(value = "API订单接口") +public class ApiOrderController { + +} diff --git a/v1/src/main/java/com/v1/controller/RechargeProductController.java b/v1/src/main/java/com/v1/controller/RechargeProductController.java index fc06573b..cb10fab6 100644 --- a/v1/src/main/java/com/v1/controller/RechargeProductController.java +++ b/v1/src/main/java/com/v1/controller/RechargeProductController.java @@ -117,64 +117,6 @@ public class RechargeProductController { } } - @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "查询帐户余额") - public ResponseData checkAccountBalance(@RequestBody JSONObject object , HttpServletRequest request ) { - try { - - String ip = ""; - // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for - if (request.getHeader("x-forwarded-for") == null) { - ip = request.getRemoteAddr(); - } else { - ip = request.getHeader("x-forwarded-for"); - } - - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); - } - - if (StringUtils.isBlank(object.getString("apiKey")) || - StringUtils.isBlank(object.getString("merchId")) || - StringUtils.isBlank(object.getString("timetable")) || - StringUtils.isBlank(object.getString("sign")) - ) { - log.error("getRechargeProduct error!", "请求参数校验失败!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); - } - - ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); - - if (apiMerchants == null) { - log.error("getRechargeProduct error!", "商户号错误!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); - } - - Map map = new HashMap<>(); - map.put("apiKey" , object.getString("apiKey")); - map.put("timetable" , object.getString("timetable")); - map.put("merchId" , object.getString("merchId")); - - if (!secConfigService.isSignVerify(map , object.getString("sign"))) { - log.error("getRechargeProduct error!", "签名校验失败!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); - } - - if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) { - log.error("getRechargeProduct error!", "请求时间超过15分钟!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT); - } - - return ResponseMsgUtil.success(apiMerchants.getAmounts()); - - } catch (Exception e) { - log.error("HighOpenApiController --> getRechargeProduct() error!", e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value = "/queryOrderResult", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询订单结果") @@ -245,7 +187,6 @@ public class RechargeProductController { returnObject.put("payStatus" , rechargeOrder.getPayStatus()); returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus()); - return ResponseMsgUtil.success(returnObject); } catch (Exception e) {