|
|
|
@ -8,11 +8,13 @@ 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.openApi.config.BlxConfig; |
|
|
|
|
import com.hai.openApi.service.ApiBlxCouponService; |
|
|
|
|
import com.hai.openApi.service.ApiMobileRechargeProductService; |
|
|
|
|
import com.hai.order.type.OrderProductType; |
|
|
|
|
import com.hai.service.ApiIpAddressService; |
|
|
|
|
import com.hai.service.ApiMerchantsService; |
|
|
|
|
import com.hai.service.HighUserCardService; |
|
|
|
|
import com.hai.service.SecConfigService; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.sql.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -46,6 +49,12 @@ public class BlxCouponController { |
|
|
|
|
@Resource |
|
|
|
|
private ApiIpAddressService apiIpAddressService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighUserCardService highUserCardService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BlxConfig blxConfig; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getCouponList", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
@ -103,4 +112,299 @@ public class BlxCouponController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getUserCouponPage", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取用户停车券") |
|
|
|
|
public ResponseData getUserCouponPage(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("phone")) || |
|
|
|
|
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(OrderProductType.PRODUCT_TYPE13.getApiCode(), 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" , apiMerchants.getApiKey()); |
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
map.put("phone" , object.getString("phone")); |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("userMobile" , object.getString("phone")); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highUserCardService.getBlxCouponBalance(object.getString("phone")).getJSONArray("data")); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/queryJsParking", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取附近停车场") |
|
|
|
|
public ResponseData queryJsParking(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("gps")) || |
|
|
|
|
StringUtils.isBlank(object.getString("range")) || |
|
|
|
|
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(OrderProductType.PRODUCT_TYPE13.getApiCode(), 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" , apiMerchants.getApiKey()); |
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
map.put("gps" , object.getString("gps")); |
|
|
|
|
map.put("range" , object.getString("range")); |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("range" , object.getString("range")); |
|
|
|
|
jsonObject.put("gps" , object.getString("gps")); |
|
|
|
|
|
|
|
|
|
JSONObject data = blxConfig.queryJsParking(jsonObject); |
|
|
|
|
|
|
|
|
|
if (data.getInteger("code") == 1) { |
|
|
|
|
return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("parkList")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(null); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/queryJsOrderList", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询车牌订单列表信息") |
|
|
|
|
public ResponseData queryJsOrderList(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("carNo")) || |
|
|
|
|
StringUtils.isBlank(object.getString("orderStatus")) || |
|
|
|
|
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(OrderProductType.PRODUCT_TYPE13.getApiCode(), 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" , apiMerchants.getApiKey()); |
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
map.put("carNo" , object.getString("carNo")); |
|
|
|
|
map.put("orderStatus" , object.getString("orderStatus")); |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("carNo" , object.getString("carNo")); |
|
|
|
|
jsonObject.put("orderStatus" , object.getString("orderStatus")); |
|
|
|
|
|
|
|
|
|
JSONObject data = blxConfig.queryJsOrderList(jsonObject); |
|
|
|
|
|
|
|
|
|
if (data.getInteger("code") == 1) { |
|
|
|
|
return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("ordlist")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(null); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/creatOrder", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "停车添加订单") |
|
|
|
|
public ResponseData creatOrder(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { |
|
|
|
|
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
StringUtils.isBlank(object.getString("merchId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("organizeCode")) || |
|
|
|
|
StringUtils.isBlank(object.getString("userMobile")) || |
|
|
|
|
StringUtils.isBlank(object.getString("userCouponCode")) || |
|
|
|
|
StringUtils.isBlank(object.getString("parkOrderId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("orderType")) || |
|
|
|
|
StringUtils.isBlank(object.getString("prePrice")) || |
|
|
|
|
StringUtils.isBlank(object.getString("parkId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("parkName")) || |
|
|
|
|
StringUtils.isBlank(object.getString("parkTime")) || |
|
|
|
|
StringUtils.isBlank(object.getString("carSeatId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("inTime")) || |
|
|
|
|
StringUtils.isBlank(object.getString("outTime")) || |
|
|
|
|
StringUtils.isBlank(object.getString("carNo")) || |
|
|
|
|
StringUtils.isBlank(object.getString("parkType")) || |
|
|
|
|
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(OrderProductType.PRODUCT_TYPE13.getApiCode(), 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" , apiMerchants.getApiKey()); |
|
|
|
|
map.put("merchId" , object.getString("merchId")); |
|
|
|
|
map.put("organizeCode" , object.getString("organizeCode")); |
|
|
|
|
map.put("userMobile" , object.getString("userMobile")); |
|
|
|
|
map.put("userCouponCode" , object.getString("userCouponCode")); |
|
|
|
|
map.put("parkOrderId" , object.getString("parkOrderId")); |
|
|
|
|
map.put("orderType" , object.getString("orderType")); |
|
|
|
|
map.put("prePrice" , object.getString("prePrice")); |
|
|
|
|
map.put("parkId" , object.getString("parkId")); |
|
|
|
|
map.put("parkName" , object.getString("parkName")); |
|
|
|
|
map.put("parkTime" , object.getString("parkTime")); |
|
|
|
|
map.put("carSeatId" , object.getString("carSeatId")); |
|
|
|
|
map.put("inTime" , object.getString("inTime")); |
|
|
|
|
map.put("outTime" , object.getString("outTime")); |
|
|
|
|
map.put("carNo" , object.getString("carNo")); |
|
|
|
|
map.put("parkType" , object.getString("parkType")); |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
|
|
|
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("carNo" , object.getString("carNo")); |
|
|
|
|
jsonObject.put("orderStatus" , object.getString("orderStatus")); |
|
|
|
|
|
|
|
|
|
JSONObject data = blxConfig.queryJsOrderList(jsonObject); |
|
|
|
|
|
|
|
|
|
if (data.getInteger("code") == 1) { |
|
|
|
|
return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("ordlist")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(null); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|