|
|
@ -1,14 +1,16 @@ |
|
|
|
package com.v1.controller; |
|
|
|
package com.v1.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.config.QianZhuConfig; |
|
|
|
import com.hai.config.QianZhuConfig; |
|
|
|
import com.hai.entity.ApiMerchants; |
|
|
|
import com.hai.entity.*; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.service.*; |
|
|
|
import com.hai.service.*; |
|
|
|
|
|
|
|
import com.v1.config.ToolConfig; |
|
|
|
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; |
|
|
@ -22,7 +24,10 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
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.RoundingMode; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -48,6 +53,15 @@ public class ThirdPartyController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private ApiIpAddressService apiIpAddressService; |
|
|
|
private ApiIpAddressService apiIpAddressService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private ApiProductService apiProductService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private ApiOpenService apiOpenService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private ApiMemberProductService apiMemberProductService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getAllCities", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/getAllCities", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "查询可用城市") |
|
|
|
@ApiOperation(value = "查询可用城市") |
|
|
@ -62,7 +76,6 @@ public class ThirdPartyController { |
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
if (StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) |
|
|
|
StringUtils.isBlank(object.getString("sign")) |
|
|
@ -144,7 +157,7 @@ public class ThirdPartyController { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("KFC_CONFIG" , object.getString("merchId"))) { |
|
|
|
if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) { |
|
|
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
|
|
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -196,8 +209,81 @@ public class ThirdPartyController { |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
if (StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
StringUtils.isBlank(object.getString("pageIndex")) || |
|
|
|
StringUtils.isBlank(object.getString("sign")) |
|
|
|
StringUtils.isBlank(object.getString("pageSize")) || |
|
|
|
) { |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) { |
|
|
|
|
|
|
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapProduct = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(mapProduct); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ApiStarbucksProducts starbucksProducts : list) { |
|
|
|
|
|
|
|
if (starbucksProducts.getMarketGrandePrice().compareTo(new BigDecimal(1000)) > 0) { |
|
|
|
|
|
|
|
starbucksProducts.setMarketGrandePrice(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (starbucksProducts.getMarketTallPrice().compareTo(new BigDecimal(1000)) > 0) { |
|
|
|
|
|
|
|
starbucksProducts.setMarketTallPrice(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (starbucksProducts.getMarketVentiPrice().compareTo(new BigDecimal(1000)) > 0) { |
|
|
|
|
|
|
|
starbucksProducts.setMarketVentiPrice(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
starbucksProducts.setSalesTallPrice(starbucksProducts.getMarketTallPrice()); |
|
|
|
|
|
|
|
starbucksProducts.setSalesVentiPrice(starbucksProducts.getMarketVentiPrice()); |
|
|
|
|
|
|
|
starbucksProducts.setSalesGrandePrice(starbucksProducts.getMarketGrandePrice()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(list); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getKfcStoresList", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "查询肯德基门店") |
|
|
|
|
|
|
|
public ResponseData getKfcStoresList(@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("sign")) |
|
|
|
StringUtils.isBlank(object.getString("sign")) |
|
|
|
) { |
|
|
|
) { |
|
|
|
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
|
|
|
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
|
|
@ -220,23 +306,244 @@ public class ThirdPartyController { |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(object.getInteger("pageIndex") , object.getInteger("pageSize")); |
|
|
|
Map<String, Object> mapStores = new HashMap<>(); |
|
|
|
|
|
|
|
List<ApiKfcStores> list = apiProductService.getKfcStoresList(mapStores); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject.getBoolean("success")) { |
|
|
|
return ResponseMsgUtil.success(list); |
|
|
|
return ResponseMsgUtil.success(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "根据门店编码查询KFC产品") |
|
|
|
|
|
|
|
public ResponseData kfcProductByStoreCode(@RequestBody JSONObject object , HttpServletRequest request ) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ip = ""; |
|
|
|
|
|
|
|
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
|
|
|
|
|
|
|
|
if (request.getHeader("x-forwarded-for") == null) { |
|
|
|
|
|
|
|
ip = request.getRemoteAddr(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.error("getRechargeProduct error!", "查询失败!"); |
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("storeCode")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("KFC_CONFIG" , object.getString("merchId"))) { |
|
|
|
|
|
|
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
map.put("storeCode" , object.getString("storeCode")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = QianZhuConfig.listByStoreCode(object.getString("storeCode")); |
|
|
|
|
|
|
|
JSONArray array = jsonObject.getJSONArray("data"); |
|
|
|
|
|
|
|
if (array == null) { |
|
|
|
|
|
|
|
log.error("kfcProductByStoreCode error!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询到商品"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Object data : array) { |
|
|
|
|
|
|
|
JSONObject dataObject = (JSONObject) data; |
|
|
|
|
|
|
|
if (dataObject.getJSONArray("products") != null) { |
|
|
|
|
|
|
|
for (Object products : dataObject.getJSONArray("products")) { |
|
|
|
|
|
|
|
JSONObject productsObject = (JSONObject) products; |
|
|
|
|
|
|
|
productsObject.put("taxOriginalPrice" , null); |
|
|
|
|
|
|
|
productsObject.put("taxOriginalTotalPrice" , null); |
|
|
|
|
|
|
|
productsObject.put("price" , null); |
|
|
|
|
|
|
|
productsObject.put("taxPrice" , null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (productsObject.getJSONArray("specGroups") != null) { |
|
|
|
|
|
|
|
for (Object specGroups : productsObject.getJSONArray("specGroups")) { |
|
|
|
|
|
|
|
JSONObject specGroupsObject = (JSONObject) specGroups; |
|
|
|
|
|
|
|
specGroupsObject.put("taxOriginalPrice" , null); |
|
|
|
|
|
|
|
specGroupsObject.put("taxOriginalTotalPrice" , null); |
|
|
|
|
|
|
|
specGroupsObject.put("price" , null); |
|
|
|
|
|
|
|
specGroupsObject.put("taxPrice" , null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(array); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getMemberProducts", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "查询会员产品") |
|
|
|
|
|
|
|
public ResponseData getMemberProducts(@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("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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("MEMBER_RECHARGE_CONFIG" , object.getString("merchId"))) { |
|
|
|
|
|
|
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapProduct = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ApiMemberProduct> list = apiMemberProductService.getListApiMemberProduct(mapProduct); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ApiMemberProduct apiMemberProduct : list) { |
|
|
|
|
|
|
|
apiMemberProduct.setCostPrice(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(list); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/createOrder", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "充值预下单") |
|
|
|
|
|
|
|
public ResponseData createOrder(@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("createOrder error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("customerMobile")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("productType")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("apiKey")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("timetable")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("orderNo")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("notifyUrl")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("sign")) || |
|
|
|
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("createOrder error!", "请求参数校验失败!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (apiMerchants == null) { |
|
|
|
|
|
|
|
log.error("createOrder error!", "商户错误!"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> productMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("customerMobile" , object.getString("customerMobile")); |
|
|
|
|
|
|
|
map.put("productType" , object.getString("productType")); |
|
|
|
|
|
|
|
map.put("timetable" , object.getString("timetable")); |
|
|
|
|
|
|
|
map.put("orderNo" , object.getString("orderNo")); |
|
|
|
|
|
|
|
map.put("notifyUrl" , object.getString("notifyUrl")); |
|
|
|
|
|
|
|
map.put("apiKey" , object.getString("apiKey")); |
|
|
|
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map, object.getString("sign"))) { |
|
|
|
|
|
|
|
log.error("createOrder 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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apiOpenService.createOrder(object , apiMerchants); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success("下单成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighOpenApiController --> createOrder() error!", e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|