|
|
|
@ -6,7 +6,10 @@ import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.config.HuiLianTongConfig; |
|
|
|
|
import com.hai.dao.HighGasOrderPushMapper; |
|
|
|
|
import com.hai.entity.HighGasOrderPush; |
|
|
|
|
import com.hai.entity.HighUser; |
|
|
|
|
import com.hai.enum_type.OrderPushType; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
import com.hai.service.HighOpenApiService; |
|
|
|
|
import com.hai.service.HighUserService; |
|
|
|
@ -20,6 +23,7 @@ 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; |
|
|
|
|
|
|
|
|
@ -36,6 +40,9 @@ public class GzSinopecController { |
|
|
|
|
@Resource |
|
|
|
|
private HighUserService highUserService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighGasOrderPushMapper highGasOrderPushMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private SecConfigService secConfigService; |
|
|
|
|
|
|
|
|
@ -57,7 +64,7 @@ public class GzSinopecController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前手机号暂无用户"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("userId", highUser.getId()); |
|
|
|
|
map.put("useScope", useScope); |
|
|
|
|
if (year != null) { |
|
|
|
@ -73,7 +80,7 @@ public class GzSinopecController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getGuizhouSinopecList",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取贵州中石化电子卡券") |
|
|
|
|
public ResponseData getGuizhouSinopecList(HttpServletRequest request) { |
|
|
|
@ -87,7 +94,7 @@ public class GzSinopecController { |
|
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE" , ip)) { |
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE", ip)) { |
|
|
|
|
log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
@ -99,18 +106,18 @@ public class GzSinopecController { |
|
|
|
|
JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token); |
|
|
|
|
System.out.println(corpCouTypes.toJSONString()); |
|
|
|
|
if (!corpCouTypes.getString("result").equals("success")) { |
|
|
|
|
log.error("HighOpenApiController -> getGuizhouSinopecList() error!","获取电子卡券列表失败"); |
|
|
|
|
log.error("HighOpenApiController -> getGuizhouSinopecList() error!", "获取电子卡券列表失败"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取电子卡券列表失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(corpCouTypes.getJSONArray("data")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!",e); |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/checkCouponStatus",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/checkCouponStatus", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询电子券状态") |
|
|
|
|
public ResponseData checkCouponStatus(@RequestBody JSONObject object, HttpServletRequest request) { |
|
|
|
@ -124,7 +131,7 @@ public class GzSinopecController { |
|
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE" , ip)) { |
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE", ip)) { |
|
|
|
|
log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
@ -135,18 +142,18 @@ public class GzSinopecController { |
|
|
|
|
// 查询电子卡券类型
|
|
|
|
|
JSONObject data = HuiLianTongConfig.getCouState(token, object.getString("couNo")); |
|
|
|
|
if (!data.getString("result").equals("success")) { |
|
|
|
|
log.error("HighOpenApiController -> insertCoupon() error!","查询电子券状态失败"); |
|
|
|
|
log.error("HighOpenApiController -> insertCoupon() error!", "查询电子券状态失败"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询电子券状态失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(data.getJSONObject("data")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!",e); |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/couJointDist",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/couJointDist", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "商户派发电子券") |
|
|
|
|
public ResponseData couJointDist(@RequestBody JSONObject object, HttpServletRequest request) { |
|
|
|
@ -160,7 +167,7 @@ public class GzSinopecController { |
|
|
|
|
ip = request.getHeader("x-forwarded-for"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE" , ip)) { |
|
|
|
|
if (!secConfigService.isConfig("IP_WHITE", ip)) { |
|
|
|
|
log.error("couJointDist error!", "非法ip地址,请联系管理人员!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
|
|
|
|
} |
|
|
|
@ -170,20 +177,29 @@ public class GzSinopecController { |
|
|
|
|
|
|
|
|
|
// 商户派发电子券
|
|
|
|
|
JSONObject returnParam = HuiLianTongConfig.couJointDist(token, object.getString("orderNo"), object.getString("couTypeCode"), object.getInteger("distCouCount"), object.getString("phone"), object.getString("thirdUserId")); |
|
|
|
|
if (returnParam == null || !returnParam.getString("result").equals("success")) { |
|
|
|
|
log.error("HighOpenApiController -> couJointDist() error!","商户派发电子券失败"); |
|
|
|
|
// 推送记录
|
|
|
|
|
HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); |
|
|
|
|
highGasOrderPush.setType(OrderPushType.type6.getType()); |
|
|
|
|
highGasOrderPush.setOrderNo(object.getString("orderNo")); |
|
|
|
|
highGasOrderPush.setCreateTime(new Date()); |
|
|
|
|
highGasOrderPush.setCode(returnParam.getString("result")); |
|
|
|
|
highGasOrderPush.setRequestContent(JSONObject.toJSONString(object)); |
|
|
|
|
highGasOrderPush.setReturnContent(returnParam.toJSONString()); |
|
|
|
|
highGasOrderPushMapper.insert(highGasOrderPush); |
|
|
|
|
if (!returnParam.getString("result").equals("success")) { |
|
|
|
|
log.error("HighOpenApiController -> couJointDist() error!", "商户派发电子券失败"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(returnParam.getJSONArray("data")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighOpenApiController -> couJointDist() error!",e); |
|
|
|
|
log.error("HighOpenApiController -> couJointDist() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/test",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value = "/test", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "测试") |
|
|
|
|
public ResponseData test(HttpServletRequest request) { |
|
|
|
@ -198,7 +214,7 @@ public class GzSinopecController { |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(ip); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!",e); |
|
|
|
|
log.error("HighCouponController -> getGuizhouSinopec() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|