|
|
|
|
@ -137,6 +137,7 @@ public class BsAgentPriceController { |
|
|
|
|
agentPrice.setMerName(merchant.getMerName()); |
|
|
|
|
agentPrice.setOilNo(oilNo.getCode().toString()); |
|
|
|
|
agentPrice.setOilNoName(oilNo.getName()); |
|
|
|
|
agentPrice.setAgentId(agentMer!=null?agentMer.getAgentId():null); |
|
|
|
|
agentPrice.setAgentMerId(agentMer!=null?agentMer.getId():null); |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
@ -155,24 +156,172 @@ public class BsAgentPriceController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/editApiPrice", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "编辑API价格") |
|
|
|
|
public ResponseData editApiPrice(@RequestBody JSONArray bodyArray) { |
|
|
|
|
try { |
|
|
|
|
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
|
|
|
|
if (!userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (bodyArray == null || bodyArray.isEmpty()) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer accountObjectType = userSession.getAccount().getObjectType(); |
|
|
|
|
for (Object obj : bodyArray) { |
|
|
|
|
JSONObject body = (JSONObject)JSONObject.toJSON(obj); |
|
|
|
|
if (body.getLong("agentId") == null |
|
|
|
|
|| StringUtils.isBlank(body.getString("merNo")) |
|
|
|
|
|| StringUtils.isBlank(body.getString("oilNo")) |
|
|
|
|
|| body.getBigDecimal("priceRate") == null |
|
|
|
|
|| body.getBigDecimal("serviceFeeRate") == null |
|
|
|
|
) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询商户
|
|
|
|
|
BsMerchant merchant = merchantService.getMerchant(body.getString("merNo")); |
|
|
|
|
if (merchant == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BsAgentPrice agentPrice = null; |
|
|
|
|
BsAgentMer agentMer = null; |
|
|
|
|
if (accountObjectType.equals(SecUserObjectTypeEnum.type1.getCode())) { |
|
|
|
|
agentMer = agentMerService.getDetailByAgent(body.getLong("agentId"), body.getString("merNo")); |
|
|
|
|
if (agentMer != null) { |
|
|
|
|
agentPrice = agentPriceService.getDetail(agentMer.getId(), body.getString("oilNo")); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的角色"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询油号
|
|
|
|
|
GasOilNoEnum oilNo = GasOilNoEnum.getNameByType(body.getInteger("oilNo")); |
|
|
|
|
if (oilNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油号"); |
|
|
|
|
} |
|
|
|
|
// 查询油站
|
|
|
|
|
if (agentPrice == null) { |
|
|
|
|
agentPrice = new BsAgentPrice(); |
|
|
|
|
agentPrice.setType(AgentPriceTypeEnum.type2.getCode()); |
|
|
|
|
agentPrice.setMerId(merchant.getId()); |
|
|
|
|
agentPrice.setMerNo(merchant.getMerNo()); |
|
|
|
|
agentPrice.setMerName(merchant.getMerName()); |
|
|
|
|
agentPrice.setOilNo(oilNo.getCode().toString()); |
|
|
|
|
agentPrice.setOilNoName(oilNo.getName()); |
|
|
|
|
agentPrice.setAgentId(agentMer!=null?agentMer.getAgentId():null); |
|
|
|
|
agentPrice.setAgentMerId(agentMer!=null?agentMer.getId():null); |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
} else { |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
} |
|
|
|
|
agentPriceService.editData(agentPrice); |
|
|
|
|
|
|
|
|
|
// 通知代理
|
|
|
|
|
agentMerService.agentNotify(agentPrice.getAgentId(), merchant.getMerNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("BsAgentPriceController --> editPrice() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/batchConfigApiPrice", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "批量配置API价格") |
|
|
|
|
public ResponseData batchConfigApiPrice(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
|
|
|
|
if (!userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
|
|
|
|
} |
|
|
|
|
if (body.getLong("agentId") == null |
|
|
|
|
|| body.getString("oilNo") == null |
|
|
|
|
|| body.getBigDecimal("priceRate") == null |
|
|
|
|
|| body.getBigDecimal("serviceFeeRate") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询油号
|
|
|
|
|
GasOilNoEnum oilNo = GasOilNoEnum.getNameByType(body.getInteger("oilNo")); |
|
|
|
|
if (oilNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油号"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("agentId", body.getLong("agentId")); |
|
|
|
|
param.put("provinceCode", body.getLong("provinceCode")); |
|
|
|
|
param.put("merSourceType", body.getInteger("sourceType")); |
|
|
|
|
List<BsAgentMer> list = agentMerService.getList(param); |
|
|
|
|
for (BsAgentMer agentMer : list) { |
|
|
|
|
// 查询价格
|
|
|
|
|
BsAgentPrice agentPrice = agentPriceService.getDetail(agentMer.getId(), body.getString("oilNo")); |
|
|
|
|
// 查询油站
|
|
|
|
|
if (agentPrice == null) { |
|
|
|
|
// 查询商户
|
|
|
|
|
BsMerchant merchant = merchantService.getMerchant(agentMer.getMerNo()); |
|
|
|
|
if (merchant == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); |
|
|
|
|
} |
|
|
|
|
agentPrice = new BsAgentPrice(); |
|
|
|
|
agentPrice.setType(AgentPriceTypeEnum.type2.getCode()); |
|
|
|
|
agentPrice.setMerId(merchant.getId()); |
|
|
|
|
agentPrice.setMerNo(merchant.getMerNo()); |
|
|
|
|
agentPrice.setMerName(merchant.getMerName()); |
|
|
|
|
agentPrice.setOilNo(oilNo.getCode().toString()); |
|
|
|
|
agentPrice.setOilNoName(oilNo.getName()); |
|
|
|
|
agentPrice.setAgentId(agentMer!=null?agentMer.getAgentId():null); |
|
|
|
|
agentPrice.setAgentMerId(agentMer!=null?agentMer.getId():null); |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
} else { |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
} |
|
|
|
|
agentPriceService.editData(agentPrice); |
|
|
|
|
|
|
|
|
|
// 通知代理
|
|
|
|
|
agentMerService.agentNotify(agentPrice.getAgentId(), agentPrice.getMerNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("BsAgentPriceController --> editPrice() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/batchConfigPrice", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "批量配置价格") |
|
|
|
|
public ResponseData batchConfigPrice(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
SecUserSessionObject userSession = userCenter.getSessionModel(SecUserSessionObject.class); |
|
|
|
|
if (!userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode()) |
|
|
|
|
&& !userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type4.getCode()) |
|
|
|
|
&& !userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type5.getCode())) { |
|
|
|
|
if (!userSession.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (body.getJSONArray("merNoList") == null |
|
|
|
|
|| StringUtils.isBlank(body.getString("oilNo")) |
|
|
|
|
if (body.getLong("agentId") == null |
|
|
|
|
|| body.getLong("provinceCode") == null |
|
|
|
|
|| body.getInteger("sourceType") == null |
|
|
|
|
|| body.getString("oilNo") == null |
|
|
|
|
|| body.getBigDecimal("priceRate") == null |
|
|
|
|
|| body.getBigDecimal("serviceFeeRate") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer accountObjectType = userSession.getAccount().getObjectType(); |
|
|
|
|
Integer type = null; |
|
|
|
|
for (Object obj : body.getJSONArray("merNoList")) { |
|
|
|
|
@ -235,6 +384,7 @@ public class BsAgentPriceController { |
|
|
|
|
agentPrice.setMerName(merchant.getMerName()); |
|
|
|
|
agentPrice.setOilNo(oilNo.getCode().toString()); |
|
|
|
|
agentPrice.setOilNoName(oilNo.getName()); |
|
|
|
|
agentPrice.setAgentId(agentMer!=null?agentMer.getAgentId():null); |
|
|
|
|
agentPrice.setAgentMerId(agentMer!=null?agentMer.getId():null); |
|
|
|
|
agentPrice.setPriceRate(body.getBigDecimal("priceRate")); |
|
|
|
|
agentPrice.setServiceFeeRate(body.getBigDecimal("serviceFeeRate")); |
|
|
|
|
@ -356,4 +506,33 @@ public class BsAgentPriceController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getApiDiscountList", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取APi代理优惠价格列表") |
|
|
|
|
public ResponseData getApiDiscountList(@RequestParam(name = "agentId", required = true) Long agentId, |
|
|
|
|
@RequestParam(name = "provinceCode", required = false) String provinceCode, |
|
|
|
|
@RequestParam(name = "merNo", required = false) String merNo, |
|
|
|
|
@RequestParam(name = "merName", required = false) String merName, |
|
|
|
|
@RequestParam(name = "oilNo", required = false) String oilNo, |
|
|
|
|
@RequestParam(name = "sourceType", required = false) Integer sourceType, |
|
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize |
|
|
|
|
) { |
|
|
|
|
try { |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("agentId", agentId); |
|
|
|
|
param.put("provinceCode", provinceCode); |
|
|
|
|
param.put("merNo", merNo); |
|
|
|
|
param.put("merName", merName); |
|
|
|
|
param.put("sourceType", sourceType); |
|
|
|
|
param.put("oilNo", oilNo); |
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(agentPriceService.getApiAgentDiscountList(param))); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|