new-dev
袁野 1 year ago
parent 3a55528375
commit 3c2a156991
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 4
      hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java
  3. 14
      hai-service/src/main/java/com/hai/entity/HighUserCoupon.java
  4. 183
      hai-service/src/main/java/com/hai/openApi/config/BlxConfig.java
  5. 3
      hai-service/src/main/java/com/hai/service/HighUserCardService.java
  6. 11
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  7. 1
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  8. 96
      hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java
  9. 19
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java
  10. 2
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java
  11. 304
      v1/src/main/java/com/v1/controller/business/BlxCouponController.java
  12. 26
      v1/src/main/java/com/v1/controller/orderController.java

File diff suppressed because one or more lines are too long

@ -19,7 +19,7 @@ public class HighCouponCodeOther implements Serializable {
private Long id; private Long id;
/** /**
* 类型 1 贵州中石化 2 重庆中石油 3 优惠券 * 类型 1 贵州中石化 2 重庆中石油 3 优惠券 4:黔印象停车券
*/ */
private Integer type; private Integer type;
@ -341,4 +341,4 @@ public class HighCouponCodeOther implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -1,5 +1,7 @@
package com.hai.entity; package com.hai.entity;
import com.hai.model.HighCouponModel;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -101,6 +103,16 @@ public class HighUserCoupon implements Serializable {
private String ext4; private String ext4;
private HighCouponModel highCouponModel;
public HighCouponModel getHighCouponModel() {
return highCouponModel;
}
public void setHighCouponModel(HighCouponModel highCouponModel) {
this.highCouponModel = highCouponModel;
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Long getId() { public Long getId() {
@ -354,4 +366,4 @@ public class HighUserCoupon implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -1,15 +1,12 @@
package com.hai.openApi.config; package com.hai.openApi.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.RedisUtil; import com.hai.common.utils.RedisUtil;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongUnionCardConfig;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -38,16 +35,19 @@ public class BlxConfig {
Map<String , Object > map = new HashMap<>(); Map<String , Object > map = new HashMap<>();
map.put("organizeCode" , "dhy"); map.put("organizeCode" , "dhy");
log.info("============ 比邻星停车券业务-获取TOKEN-START ============="); log.info("============ 比邻星停车券业务-获取TOKEN-START =============");
JSONObject object = HttpsUtils.doGet("https://vertical-formats-gateway.blx.bodata.cn:18443/admin/api/generateJwt" , map); JSONObject object = HttpsUtils.doGet(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/generateJwt" , map);
log.info("请求参数: " + map); log.info("请求参数: " + map);
log.info("响应参数: " + object); log.info("响应参数: " + object);
log.info("============ 比邻星停车券业务-获取TOKEN-END =============="); log.info("============ 比邻星停车券业务-获取TOKEN-END ==============");
redisUtil.set("BlxToken" , object.getString("data") , 2000);
return object.getString("data"); return object.getString("data");
} }
return token.toString(); return token.toString();
} }
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Name queryCouponPage * @Name queryCouponPage
@ -132,4 +132,179 @@ public class BlxConfig {
} }
/**
* @Author Sum1Dream
* @Name getUserBindCarNo
* @Description // 获取用户绑定车辆信息
* @Date 10:11 2023/8/25
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject getUserBindCarNo(JSONObject object) {
Map<String , Object > map = new HashMap<>();
map.put("userMobile" , object.getString("userMobile"));
map.put("organizeCode" , object.getString("organizeCode"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/getUserBindCarNo" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-END =============");
return data;
}
/**
* @Author Sum1Dream
* @Name addUserBindCarNo
* @Description // 用户绑定车辆
* @Date 10:11 2023/8/25
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject addUserBindCarNo(JSONObject object) {
Map<String , Object > map = new HashMap<>();
map.put("userMobile" , object.getString("userMobile"));
map.put("organizeCode" , object.getString("organizeCode"));
map.put("plateNumber" , object.getString("plateNumber"));
// 车牌颜色- 0:未知,1:蓝色,2:黄色,3:黑色,4:白色,5:绿色
map.put("plateColor" , object.getString("plateColor"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-用户绑定车辆-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/addUserBindCarNo" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-用户绑定车辆-END =============");
return data;
}
/**
* @Author Sum1Dream
* @Name delUserBindCarNo
* @Description // 删除用户绑定车辆
* @Date 10:20 2023/8/25
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject delUserBindCarNo(JSONObject object) {
Map<String , Object > map = new HashMap<>();
map.put("userMobile" , object.getString("userMobile"));
map.put("organizeCode" , object.getString("organizeCode"));
map.put("plateNumber" , object.getString("plateNumber"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-删除用户绑定车辆-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/delUserBindCarNo" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-删除用户绑定车辆-END =============");
return data;
}
/**
* @Author Sum1Dream
* @Name queryJsParking
* @Description // 获取附近停车场-捷顺
* @Date 10:26 2023/8/25
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject queryJsParking(JSONObject object) {
Map<String , Object > map = new HashMap<>();
map.put("gps" , object.getString("gps"));
map.put("range" , object.getString("range"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsParking" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-END =============");
return data;
}
/**
* @Author Sum1Dream
* @Name queryJsOrderList
* @Description // 查询车牌订单列表信息
* @Date 11:42 2023/8/28
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject queryJsOrderList(JSONObject object) {
Map<String , Object > map = new HashMap<>();
map.put("carNo" , object.getString("carNo"));
map.put("orderStatus" , object.getString("orderStatus"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsOrderList" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END =============");
return data;
}
/**
* @Author Sum1Dream
* @Name creatOrder
* @Description // 停车添加订单
* @Date 10:12 2023/8/30
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
public JSONObject creatOrder(JSONObject object) {
Map<String , Object > map = new HashMap<>();
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"));
Map<String , Object> header = new HashMap<>();
header.put("token" , generateJw());
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START =============");
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/creatOrder" , map , header);
log.info("头部参数: " + header);
log.info("请求参数: " + map);
log.info("响应参数: " + data);
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END =============");
return data;
}
} }

@ -1,5 +1,6 @@
package com.hai.service; package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighUser; import com.hai.entity.HighUser;
import com.hai.entity.HighUserCard; import com.hai.entity.HighUserCard;
@ -73,6 +74,6 @@ public interface HighUserCardService {
**/ **/
HighUserCard getUserHtlCardNo(Long userId); HighUserCard getUserHtlCardNo(Long userId);
Integer getBlxCouponBalance(String phone); JSONObject getBlxCouponBalance(String phone);
} }

@ -94,5 +94,16 @@ public interface HighUserCouponService {
**/ **/
void expiredCoupon(Long userCouponId); void expiredCoupon(Long userCouponId);
/**
* @Author Sum1Dream
* @Name findUserCouponByCode
* @Description // 第三方code查询
* @Date 15:30 2023/8/24
* @Param [code]
* @Return com.hai.entity.HighUserCoupon
*/
HighUserCoupon findUserCouponByCode(String code);
} }

@ -524,6 +524,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
highUserCoupon.setOrderId(order.getId()); highUserCoupon.setOrderId(order.getId());
highUserCoupon.setChildOrderId(childOrder.getId()); highUserCoupon.setChildOrderId(childOrder.getId());
highUserCoupon.setUserId(order.getMemId()); highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setUserPhone(order.getMemPhone());
highUserCoupon.setCreateTime(new Date()); highUserCoupon.setCreateTime(new Date());
highUserCoupon.setUseEndTime(apiBlxCoupon.getUseEndTime()); highUserCoupon.setUseEndTime(apiBlxCoupon.getUseEndTime());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用

@ -1,29 +1,28 @@
package com.hai.service.impl; package com.hai.service.impl;
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.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.dao.HighUserCardMapper; import com.hai.dao.HighUserCardMapper;
import com.hai.entity.HighFleetOilCard; import com.hai.entity.*;
import com.hai.entity.HighOilCard;
import com.hai.entity.HighUserCard;
import com.hai.entity.HighUserCardExample;
import com.hai.enum_type.OilCardStatusEnum; import com.hai.enum_type.OilCardStatusEnum;
import com.hai.enum_type.UserCardType; import com.hai.enum_type.UserCardType;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.openApi.config.BlxConfig; import com.hai.openApi.config.BlxConfig;
import com.hai.service.HighFleetOilCardService; import com.hai.service.*;
import com.hai.service.HighOilCardService; import org.apache.commons.lang3.StringUtils;
import com.hai.service.HighUserCardService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service("highUserCardService") @Service("highUserCardService")
public class HighUserCardServiceImpl implements HighUserCardService { public class HighUserCardServiceImpl implements HighUserCardService {
@ -32,8 +31,10 @@ public class HighUserCardServiceImpl implements HighUserCardService {
private HighUserCardMapper highUserCardMapper; private HighUserCardMapper highUserCardMapper;
@Resource @Resource
private UserCenter userCenter; private HighUserCouponService highUserCouponService;
@Resource
private HighCouponCodeOtherService couponCodeOtherService;
@Resource @Resource
private BlxConfig blxConfig; private BlxConfig blxConfig;
@ -44,6 +45,12 @@ public class HighUserCardServiceImpl implements HighUserCardService {
@Resource @Resource
private HighFleetOilCardService fleetOilCardService; private HighFleetOilCardService fleetOilCardService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighUserService highUserService;
@Override @Override
public void editCard(HighUserCard highUserCard) { public void editCard(HighUserCard highUserCard) {
if(highUserCard.getId() == null){ if(highUserCard.getId() == null){
@ -172,27 +179,92 @@ public class HighUserCardServiceImpl implements HighUserCardService {
} }
@Override @Override
public Integer getBlxCouponBalance(String phone) { public JSONObject getBlxCouponBalance(String phone) {
try { try {
if (phone == null) { if (phone == null) {
return 0; return null;
} }
JSONObject data = new JSONObject();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("userMobile" , phone); jsonObject.put("userMobile" , phone);
HighUser user = highUserService.findByPhone(phone);
// 获取比邻星接口查询用户停车券内容
JSONObject object = blxConfig.getUserCouponPage(jsonObject); JSONObject object = blxConfig.getUserCouponPage(jsonObject);
int num = 0; int num = 0;
if (object.getInteger("code") == 1) { if (object.getInteger("code") == 1) {
num = object.getJSONObject("data").getInteger("total"); num = object.getJSONObject("data").getInteger("total");
if (num > 0) {
// 获取停车券内容
JSONArray blcArray = object.getJSONObject("data").getJSONArray("records");
data.put("data" , blcArray);
// 更新停车券状态
for (Object o : blcArray) {
JSONObject blxData = (JSONObject) o;
// 查询是否存在
HighUserCoupon userCoupon = highUserCouponService.findUserCouponByCode(blxData.getString("userCouponCode"));
HighCouponCodeOther couponCodeOther = couponCodeOtherService.getDetailByCouNo(blxData.getString("userCouponCode"));
// 查询卡券
HighCoupon coupon = highCouponService.getCouponDetail(blxData.getString("couponCode"));
if (userCoupon != null) {
userCoupon.setStatus(blxData.getInteger("userCouponStatus"));
highUserCouponService.updateUserCoupon(userCoupon);
} else {
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setStatus(blxData.getInteger("userCouponStatus"));
highUserCoupon.setUserPhone(phone);
if (coupon != null ) {
highUserCoupon.setCouponId(coupon.getId());
}
if (user != null) {
highUserCoupon.setUserId(user.getId());
}
highUserCoupon.setCreateTime(new Date());
highUserCoupon.setQrCodeImg(blxData.getString("userCouponCode"));
highUserCoupon.setUseEndTime(blxData.getDate("expiresTime"));
highUserCoupon.setSource(3);
highUserCouponService.insertUserCoupon(highUserCoupon);
}
if (couponCodeOther != null) {
couponCodeOther.setStatus(blxData.getInteger("userCouponStatus") == 1 ? 20:40);
couponCodeOtherService.update(couponCodeOther);
} else {
HighCouponCodeOther codeOther = new HighCouponCodeOther();
codeOther.setStatus(blxData.getInteger("userCouponStatus") == 1 ? 20:40);
codeOther.setType(4);
codeOther.setActiveTime(blxData.getDate("useStartTime"));
codeOther.setCouNo(blxData.getString("userCouponCode"));
codeOther.setCouTypeCode(blxData.getString("couponCode"));
codeOther.setCreateTime(new Date());
codeOther.setValidStartDate(blxData.getDate("useStartTime"));
codeOther.setValidEndDate(blxData.getDate("expiresTime"));
couponCodeOtherService.insertCouponCodeOther(codeOther);
}
}
}
} }
return num; data.put("num" , num);
return data;
} catch (Exception e) { } catch (Exception e) {
return 0; return null;
} }
} }

@ -109,6 +109,10 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
} }
if (MapUtils.getString(map, "userPhone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone"));
}
if (MapUtils.getLong(map, "merchantId") != null) { if (MapUtils.getLong(map, "merchantId") != null) {
criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId")); criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId"));
} }
@ -253,4 +257,19 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
couponCode.setReceiveTime(null); couponCode.setReceiveTime(null);
highCouponCodeService.updateCouponCode(couponCode); highCouponCodeService.updateCouponCode(couponCode);
} }
@Override
public HighUserCoupon findUserCouponByCode(String code) {
HighUserCouponExample example = new HighUserCouponExample();
example.createCriteria().andQrCodeImgEqualTo(code);
example.setOrderByClause("create_time desc");
List<HighUserCoupon> userCoupons = highUserCouponMapper.selectByExample(example);
if (userCoupons.size() > 0) {
return userCoupons.get(0);
}
return null;
}
} }

@ -215,7 +215,7 @@ public class HighUserServiceImpl implements HighUserService {
user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId)); user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId));
user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId)); user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId));
user.setHltCardNo(highUserCardService.getUserHtlCardNo(userId)); user.setHltCardNo(highUserCardService.getUserHtlCardNo(userId));
user.setBlxCouponBalance(highUserCardService.getBlxCouponBalance(user.getPhone())); user.setBlxCouponBalance(highUserCardService.getBlxCouponBalance(user.getPhone()).getInteger("num"));
// 查询油卡 // 查询油卡
List<HighUserCard> oilCardList = highUserCardService.getListByUser(userId, UserCardType.type2.getType()); List<HighUserCard> oilCardList = highUserCardService.getListByUser(userId, UserCardType.type2.getType());

@ -8,11 +8,13 @@ import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.ApiMerchants; import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.openApi.config.BlxConfig;
import com.hai.openApi.service.ApiBlxCouponService; import com.hai.openApi.service.ApiBlxCouponService;
import com.hai.openApi.service.ApiMobileRechargeProductService; import com.hai.openApi.service.ApiMobileRechargeProductService;
import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderProductType;
import com.hai.service.ApiIpAddressService; import com.hai.service.ApiIpAddressService;
import com.hai.service.ApiMerchantsService; import com.hai.service.ApiMerchantsService;
import com.hai.service.HighUserCardService;
import com.hai.service.SecConfigService; import com.hai.service.SecConfigService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -23,6 +25,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.sql.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -46,6 +49,12 @@ public class BlxCouponController {
@Resource @Resource
private ApiIpAddressService apiIpAddressService; private ApiIpAddressService apiIpAddressService;
@Resource
private HighUserCardService highUserCardService;
@Resource
private BlxConfig blxConfig;
@RequestMapping(value = "/getCouponList", method = RequestMethod.POST) @RequestMapping(value = "/getCouponList", method = RequestMethod.POST)
@ResponseBody @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);
}
}
} }

@ -73,7 +73,7 @@ public class orderController {
public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) { public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) {
try { try {
String ip = ""; String ip;
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) { if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
@ -192,7 +192,7 @@ public class orderController {
public ResponseData orderPay(@RequestBody JSONObject object , HttpServletRequest request) { public ResponseData orderPay(@RequestBody JSONObject object , HttpServletRequest request) {
try { try {
String ip = ""; String ip;
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) { if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
@ -259,7 +259,7 @@ public class orderController {
public ResponseData queryOrderDetail(@RequestBody JSONObject object , HttpServletRequest request) { public ResponseData queryOrderDetail(@RequestBody JSONObject object , HttpServletRequest request) {
try { try {
String ip = ""; String ip;
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) { if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
@ -312,7 +312,7 @@ public class orderController {
public ResponseData refund(@RequestBody JSONObject object , HttpServletRequest request) { public ResponseData refund(@RequestBody JSONObject object , HttpServletRequest request) {
try { try {
String ip = ""; String ip;
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for // 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) { if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
@ -433,23 +433,5 @@ public class orderController {
} }
} }
@RequestMapping(value = "/test", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "对外订单退款接口")
public ResponseData test() {
try {
System.out.println("话费请求订单=================================");
Thread.currentThread().sleep(30000);
return ResponseMsgUtil.success("请求成功!");
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

Loading…
Cancel
Save