临时提交

dev
胡锐 2 weeks ago
parent 70df18c2d0
commit 9af14ec6dd
  1. 81
      openapi/src/main/java/com/openapi/controller/BsGasController.java
  2. 40
      service/src/main/java/com/hfkj/openapi/model/request/RequestQueryGasInfoModel.java
  3. 21
      service/src/main/java/com/hfkj/openapi/model/response/QueryGasGun.java
  4. 42
      service/src/main/java/com/hfkj/openapi/model/response/QueryGasOilPriceDetail.java
  5. 83
      service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryGasInfoModel.java
  6. 47
      service/src/main/java/com/hfkj/openapi/model/response/ResponseQueryGasListModel.java
  7. 50
      service/src/main/java/com/hfkj/openapi/service/ApiGasService.java

@ -10,18 +10,16 @@ import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsAgentApiLogWithBLOBs; import com.hfkj.entity.BsAgentApiLogWithBLOBs;
import com.hfkj.entity.BsAgentApiParam; import com.hfkj.entity.BsAgentApiParam;
import com.hfkj.entity.BsAgentMer;
import com.hfkj.entity.BsDiscountUser; import com.hfkj.entity.BsDiscountUser;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.openapi.model.request.RequestPushDiscountModel; import com.hfkj.openapi.model.request.*;
import com.hfkj.openapi.model.request.RequestPushPkDiscountModel; import com.hfkj.openapi.model.response.*;
import com.hfkj.openapi.model.request.RequestQueryCodeModel; import com.hfkj.openapi.service.ApiGasService;
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.BsAgentApiLogService;
import com.hfkj.service.agent.BsAgentApiParamService; import com.hfkj.service.agent.BsAgentApiParamService;
import com.hfkj.service.agent.BsAgentDiscountService; import com.hfkj.service.agent.BsAgentDiscountService;
import com.hfkj.service.agent.BsAgentMerService;
import com.hfkj.service.discount.BsDiscountUserService; import com.hfkj.service.discount.BsDiscountUserService;
import com.hfkj.service.gas.BsGasService; import com.hfkj.service.gas.BsGasService;
import com.hfkj.service.merchant.BsMerchantService; import com.hfkj.service.merchant.BsMerchantService;
@ -51,11 +49,12 @@ public class BsGasController {
@Resource @Resource
private BsAgentApiParamService agentApiParamService; private BsAgentApiParamService agentApiParamService;
@Resource @Resource
private BsGasService gasService; private BsAgentMerService agentMerService;
@Resource
private ApiGasService apiGasService;
@Resource @Resource
private BsAgentApiLogService agentApiLogService; private BsAgentApiLogService agentApiLogService;
@RequestMapping(value="/queryList",method = RequestMethod.POST) @RequestMapping(value="/queryList",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "分页获取(全量)油站信息") @ApiOperation(value = "分页获取(全量)油站信息")
@ -80,21 +79,9 @@ public class BsGasController {
List<Map<String,Object>> codeMapList = new ArrayList<>(); ResponseQueryGasListModel response = new ResponseQueryGasListModel();
/*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.setReqId(body.getReqId());
response.setAppId(body.getAppId()); response.setAppId(body.getAppId());
response.setCodeList(codeMapList);
response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret())); response.setSign(SignatureUtil.createSign(response, agentApiParamService.getParamByAppId(body.getAppId()).getAppSecret()));
log.info("返回参数:" + JSONObject.toJSONString(response)); log.info("返回参数:" + JSONObject.toJSONString(response));
apiLog.setResponseParam(JSONObject.toJSONString(response)); apiLog.setResponseParam(JSONObject.toJSONString(response));
@ -116,4 +103,54 @@ 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 ===========");
}
}
} }

@ -0,0 +1,40 @@
package com.hfkj.openapi.model.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class RequestQueryGasInfoModel {
/**
* appid
*/
@NotBlank(message = "请求id必填项")
private String reqId;
/**
* appid
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 油站编号
*/
@NotNull(message = "油站编号必填项")
private String gasNo;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,21 @@
package com.hfkj.openapi.model.response;
import lombok.Data;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class QueryGasGun {
/**
* 油站编号
*/
private String gasNo;
/**
* 油站名称
*/
private String gasName;
}

@ -0,0 +1,42 @@
package com.hfkj.openapi.model.response;
import lombok.Data;
import java.math.BigDecimal;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class QueryGasOilPriceDetail {
/**
* 油站编号
*/
private String gasNo;
/**
* 油站名称
*/
private String gasName;
/**
* 油品类型
*/
private Integer oilType;
/**
* 油品类型名称
*/
private Integer oilTypeName;
/**
* 国标价
*/
private BigDecimal priceOfficial;
/**
* 油枪价
*/
private BigDecimal priceGun;
/**
* 优惠价
*/
private BigDecimal priceVip;
}

@ -0,0 +1,83 @@
package com.hfkj.openapi.model.response;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class ResponseQueryGasInfoModel {
/**
* 油站编号
*/
private String gasNo;
/**
* 油站名称
*/
private String gasName;
/**
* 省份编码
*/
private String provinceCode;
/**
* 油站所在省份
*/
private String provinceName;
/**
* 城市编码
*/
private String cityCode;
/**
* 油站所在城市
*/
private String cityName;
/**
* 区县码
*/
private String countyCode;
/**
* 油站所在区/
*/
private String countyName;
/**
* 油站详细地址
*/
private String gasAddress;
/**
* 油站经度
*/
private String gasAddressLongitude;
/**
* 油站维度
*/
private String gasAddressLatitude;
/**
* 油站状态
*/
private Integer gasStatus;
/**
* 油站logo
*/
private String gasLogo;
/**
* 油站图片
*/
private String gasImg;
/**
* 油品信息
*/
private List<QueryGasOilPriceDetail> oilPriceList;
/**
* 油枪信息
*/
private List<QueryGasGun> gasGunList;
}

@ -0,0 +1,47 @@
package com.hfkj.openapi.model.response;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @className: RequestQueryGasListModel
* @author: HuRui
* @date: 2024/9/18
**/
@Data
public class ResponseQueryGasListModel {
/**
* appid
*/
private String reqId;
/**
* appid
*/
@NotBlank(message = "appId必填项")
private String appId;
/**
* 分页页数
*/
@NotNull(message = "页数必填项")
private Integer pageNum;
/**
* 每页数量
*/
@Range(min = 1, max = 50,message = "数量必须设置在1至100之内")
@NotNull(message = "每页数量必填项")
private Integer pageSize;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -0,0 +1,50 @@
package com.hfkj.openapi.service;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.entity.BsMerchant;
import com.hfkj.model.GasModel;
import com.hfkj.openapi.model.response.ResponseQueryGasInfoModel;
import com.hfkj.service.agent.BsAgentMerService;
import com.hfkj.service.agent.BsAgentPriceService;
import com.hfkj.service.gas.BsGasOilGunNoService;
import com.hfkj.service.gas.BsGasService;
import com.hfkj.service.merchant.BsMerchantService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @className: GasService
* @author: HuRui
* @date: 2024/11/12
**/
@Component("apiGasService")
public class ApiGasService {
@Resource
private BsAgentMerService agentMerService;
@Resource
private BsAgentPriceService agentPriceService;
@Resource
private BsMerchantService merchantService;
@Resource
private BsGasService gasService;
/**
* 查询油站详情
* @param agentId
* @param gasNo
*/
public ResponseQueryGasInfoModel queryGasInfo(Long agentId, String gasNo) {
// 油站详情
GasModel gasDetail = gasService.getGasDetail(gasNo);
if (gasDetail == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未查到加油站信息");
}
return null;
}
}
Loading…
Cancel
Save