提交代码

dev-discount
袁野 2 years ago
parent a04ed18fb7
commit 3ed726289c
  1. 158
      hai-bweb/src/main/java/com/bweb/controller/ApiIpAddressController.java
  2. 96
      hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java
  3. 5
      hai-bweb/src/main/java/com/bweb/controller/LoginController.java
  4. 4
      hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java
  5. 68
      hai-service/src/main/java/com/hai/service/ApiIpAddressService.java
  6. 21
      hai-service/src/main/java/com/hai/service/SecConfigService.java
  7. 53
      hai-service/src/main/java/com/hai/service/impl/ApiIpAddressServiceImpl.java
  8. 2
      hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java
  9. 35
      hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java
  10. 97
      v1/src/main/java/com/v1/controller/ApiMerchantsController.java
  11. 12
      v1/src/main/java/com/v1/controller/ApiOrderController.java
  12. 59
      v1/src/main/java/com/v1/controller/RechargeProductController.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<String , Object> 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);
}
}
}

@ -19,6 +19,7 @@ import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.ApiMerchantsService; import com.hai.service.ApiMerchantsService;
import com.hai.service.ApiProductService; import com.hai.service.ApiProductService;
import com.hai.service.OutRechargeOrderService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -50,6 +52,9 @@ public class ApiMerchantsController {
@Autowired @Autowired
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@ -275,19 +280,84 @@ public class ApiMerchantsController {
} }
} }
@RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET) // @RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET)
@ResponseBody // @ResponseBody
@ApiOperation(value = "查询商户产品") // @ApiOperation(value = "查询商户产品")
public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) { // public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) {
try { // try {
//
return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId)); // return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId));
//
} catch (Exception e) { // } catch (Exception e) {
log.error("ApiMerchantsController --> findById() error!", e); // log.error("ApiMerchantsController --> findById() error!", e);
return ResponseMsgUtil.exception(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<String, Object> 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);
// }
// }
} }

@ -74,6 +74,9 @@ public class LoginController {
@Resource @Resource
private ApiMerchantsService apiMerchantsService; private ApiMerchantsService apiMerchantsService;
@Resource
private ApiIpAddressService apiIpAddressService;
@RequestMapping(value="/userLogin",method = RequestMethod.POST) @RequestMapping(value="/userLogin",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "机构用户登录({'loginName':'','password':''})") @ApiOperation(value = "机构用户登录({'loginName':'','password':''})")
@ -246,6 +249,8 @@ public class LoginController {
log.error("login error!","账户状态异常,请联系管理员"); log.error("login error!","账户状态异常,请联系管理员");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户状态异常,请联系管理员"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户状态异常,请联系管理员");
} }
ApiIpAddress apiIpAddress = apiIpAddressService.findByMchId(apiMerchants.getMchId());
apiMerchants.setExt1(apiIpAddress.getIpAddress());
userInfoModel.setApiMerchants(apiMerchants); userInfoModel.setApiMerchants(apiMerchants);
} else { } else {

@ -85,7 +85,7 @@ public class OutRechargeOrder implements Serializable {
private String rechargeContent; private String rechargeContent;
/** /**
* 1支付宝 2微信 3汇联通工会卡 4银联 5银联分期 * 1支付宝 2微信 3汇联通工会卡 4银联 5银联分期 6: api商户余额
*/ */
private Integer payType; private Integer payType;
@ -743,4 +743,4 @@ public class OutRechargeOrder implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -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<com.hai.entity.ApiIpAddress>
*/
List<ApiIpAddress> getApiIpAddressByList(Map<String , Object> map);
}

@ -2,6 +2,7 @@ package com.hai.service;
import com.hai.entity.SecConfig; import com.hai.entity.SecConfig;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
@ -70,4 +71,24 @@ public interface SecConfigService {
*/ */
Boolean isSignVerify(Map<String, Object> map , String sign) throws Exception; Boolean isSignVerify(Map<String, Object> map , String sign) throws Exception;
/**
* @Author Sum1Dream
* @Name getSecConfigList
* @Description // 查询数据
* @Date 16:03 2022/12/7
* @Param [map]
* @Return java.util.List<com.hai.entity.SecConfig>
*/
List<SecConfig> getSecConfigList(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name configMerchant
* @Description // 配置商户
* @Date 16:09 2022/12/7
* @Param [mchId, configProduct]
* @Return void
*/
void configMerchant(String mchId , String configProduct);
} }

@ -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<ApiIpAddress> list = apiIpAddressMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public List<ApiIpAddress> getApiIpAddressByList(Map<String, Object> map) {
return null;
}
}

@ -60,14 +60,12 @@ public class ApiOpenServiceImpl implements ApiOpenService {
// 查询是否用重复订单 // 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
if (apiOrderRecord != null) { if (apiOrderRecord != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS); throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS);
} }
ApiProduct apiProduct = apiProductService.findById(productConfig.getProductId()); ApiProduct apiProduct = apiProductService.findById(productConfig.getProductId());
// 当前账号余额是否可以充值当前金额 // 当前账号余额是否可以充值当前金额
if (apiMerchants.getAmounts().compareTo(productConfig.getDiscountPrice()) < 0) { if (apiMerchants.getAmounts().compareTo(productConfig.getDiscountPrice()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE); throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);

@ -64,4 +64,39 @@ public class SecConfigServiceImpl implements SecConfigService {
return signPost.equals(sign); return signPost.equals(sign);
} }
@Override
public List<SecConfig> getSecConfigList(Map<String, Object> 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<SecConfig> 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);
}
}
} }

@ -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<String , Object> 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);
}
}
}

@ -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 {
}

@ -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<String , Object> 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) @RequestMapping(value = "/queryOrderResult", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询订单结果") @ApiOperation(value = "查询订单结果")
@ -245,7 +187,6 @@ public class RechargeProductController {
returnObject.put("payStatus" , rechargeOrder.getPayStatus()); returnObject.put("payStatus" , rechargeOrder.getPayStatus());
returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus()); returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus());
return ResponseMsgUtil.success(returnObject); return ResponseMsgUtil.success(returnObject);
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save