|
|
|
@ -10,16 +10,18 @@ import com.hfkj.common.utils.PageUtil; |
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hfkj.entity.BsAgentApiLogWithBLOBs; |
|
|
|
|
import com.hfkj.entity.BsAgentApiParam; |
|
|
|
|
import com.hfkj.entity.BsAgentMer; |
|
|
|
|
import com.hfkj.entity.BsDiscountUser; |
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
|
import com.hfkj.openapi.model.request.*; |
|
|
|
|
import com.hfkj.openapi.model.response.*; |
|
|
|
|
import com.hfkj.openapi.service.ApiGasService; |
|
|
|
|
import com.hfkj.openapi.model.request.RequestPushDiscountModel; |
|
|
|
|
import com.hfkj.openapi.model.request.RequestPushPkDiscountModel; |
|
|
|
|
import com.hfkj.openapi.model.request.RequestQueryCodeModel; |
|
|
|
|
import com.hfkj.openapi.model.request.RequestQueryGasListModel; |
|
|
|
|
import com.hfkj.openapi.model.response.ResponsePushDiscountModel; |
|
|
|
|
import com.hfkj.openapi.model.response.ResponsePushDiscountPkModel; |
|
|
|
|
import com.hfkj.openapi.model.response.ResponseQueryCodeModel; |
|
|
|
|
import com.hfkj.service.agent.BsAgentApiLogService; |
|
|
|
|
import com.hfkj.service.agent.BsAgentApiParamService; |
|
|
|
|
import com.hfkj.service.agent.BsAgentDiscountService; |
|
|
|
|
import com.hfkj.service.agent.BsAgentMerService; |
|
|
|
|
import com.hfkj.service.discount.BsDiscountUserService; |
|
|
|
|
import com.hfkj.service.gas.BsGasService; |
|
|
|
|
import com.hfkj.service.merchant.BsMerchantService; |
|
|
|
@ -49,12 +51,11 @@ public class BsGasController { |
|
|
|
|
@Resource |
|
|
|
|
private BsAgentApiParamService agentApiParamService; |
|
|
|
|
@Resource |
|
|
|
|
private BsAgentMerService agentMerService; |
|
|
|
|
@Resource |
|
|
|
|
private ApiGasService apiGasService; |
|
|
|
|
private BsGasService gasService; |
|
|
|
|
@Resource |
|
|
|
|
private BsAgentApiLogService agentApiLogService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryList",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "分页获取(全量)油站信息") |
|
|
|
@ -79,9 +80,21 @@ public class BsGasController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResponseQueryGasListModel response = new ResponseQueryGasListModel(); |
|
|
|
|
List<Map<String,Object>> codeMapList = new ArrayList<>(); |
|
|
|
|
/*for (BsDiscountUser discountUser : codeDataList) { |
|
|
|
|
Map<String,Object> codeMap = new HashMap<>(); |
|
|
|
|
codeMap.put("discountNo", discountUser.getDiscountNo()); |
|
|
|
|
codeMap.put("phone", discountUser.getUserPhone()); |
|
|
|
|
codeMap.put("code", discountUser.getDiscountStockCode()); |
|
|
|
|
codeMap.put("status", discountUser.getStatus()); |
|
|
|
|
codeMap.put("createTime", DateUtil.date2String(discountUser.getCreateTime(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMap.put("expirationDate", DateUtil.date2String(discountUser.getExpirationDate(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
codeMapList.add(codeMap); |
|
|
|
|
}*/ |
|
|
|
|
ResponsePushDiscountModel response = new ResponsePushDiscountModel(); |
|
|
|
|
response.setReqId(body.getReqId()); |
|
|
|
|
response.setAppId(body.getAppId()); |
|
|
|
|
response.setCodeList(codeMapList); |
|
|
|
|
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); |
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(response)); |
|
|
|
|
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
|
|
|
@ -103,54 +116,4 @@ public class BsGasController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryGasInfoByGasNo",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取油站信息") |
|
|
|
|
public ResponseData queryGasInfoByGasNo(@Validated @RequestBody RequestQueryGasInfoModel body) { |
|
|
|
|
log.info("========= Start 获取油站信息 Start ==========="); |
|
|
|
|
log.info("请求参数:" + JSONObject.toJSONString(body)); |
|
|
|
|
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
|
|
|
|
try { |
|
|
|
|
// 验证签名
|
|
|
|
|
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
|
|
|
|
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
|
|
|
|
} |
|
|
|
|
// 验证请求id
|
|
|
|
|
if (agentApiLogService.isExist(body.getAppId(), body.getReqId())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_REQ_ID_ERR, ""); |
|
|
|
|
} |
|
|
|
|
apiLog.setAppId(body.getAppId()); |
|
|
|
|
apiLog.setRequestId(body.getReqId()); |
|
|
|
|
apiLog.setRequestUrl("gas/queryGasInfoByGasNo"); |
|
|
|
|
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
|
|
|
|
|
|
|
|
|
// 查询油站
|
|
|
|
|
BsAgentMer agentMer = agentMerService.getDetailByAgent(apiParam.getAgentId(), body.getGasNo()); |
|
|
|
|
if (agentMer == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未查到加油站信息"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ResponseQueryGasInfoModel response = apiGasService.queryGasInfo(apiParam.getAgentId(), body.getGasNo()); |
|
|
|
|
log.info("返回参数:" + JSONObject.toJSONString(response)); |
|
|
|
|
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(response); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("出现异常:", e); |
|
|
|
|
// 异常内容
|
|
|
|
|
ResponseData exception = ResponseMsgUtil.exception(e); |
|
|
|
|
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
|
|
|
|
return exception; |
|
|
|
|
} finally { |
|
|
|
|
// 记录日志
|
|
|
|
|
if (apiLog.getAppId() != null) { |
|
|
|
|
agentApiLogService.edit(apiLog); |
|
|
|
|
} |
|
|
|
|
log.info("========= END 获取油站信息 END ==========="); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|