提交代码

dev
胡锐 2 weeks ago
parent f64a202350
commit c66cee02e5
  1. 189
      bweb/src/main/java/com/bweb/controller/BsAgentPriceController.java
  2. 4
      bweb/src/main/java/com/bweb/controller/BsGasOrderController.java
  3. 6
      bweb/src/main/java/com/bweb/controller/BsMerchantController.java
  4. 15
      bweb/src/main/java/com/bweb/controller/TestController.java
  5. 2
      bweb/src/main/resources/dev/application.yml
  6. 4
      openapi/src/main/java/com/openapi/controller/BsGasController.java
  7. 56
      schedule/src/main/java/com/hfkj/schedule/GasOrderSchedule.java
  8. 4
      service/src/main/java/com/hfkj/channel/gas/newlink/NewLinkGasService.java
  9. 2
      service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumGasService.java
  10. 15
      service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java
  11. 23
      service/src/main/java/com/hfkj/dao/BsAgentMerMapper.java
  12. 38
      service/src/main/java/com/hfkj/dao/BsAgentMerMapperExt.java
  13. 42
      service/src/main/java/com/hfkj/dao/BsAgentMerSqlProvider.java
  14. 30
      service/src/main/java/com/hfkj/dao/BsAgentPriceMapper.java
  15. 32
      service/src/main/java/com/hfkj/dao/BsAgentPriceMapperExt.java
  16. 14
      service/src/main/java/com/hfkj/dao/BsAgentPriceSqlProvider.java
  17. 48
      service/src/main/java/com/hfkj/entity/BsAgentMer.java
  18. 190
      service/src/main/java/com/hfkj/entity/BsAgentMerExample.java
  19. 16
      service/src/main/java/com/hfkj/entity/BsAgentPrice.java
  20. 60
      service/src/main/java/com/hfkj/entity/BsAgentPriceExample.java
  21. 4
      service/src/main/java/com/hfkj/openapi/model/GasOilPriceDetail.java
  22. 32
      service/src/main/java/com/hfkj/openapi/service/ApiGasOrderService.java
  23. 12
      service/src/main/java/com/hfkj/openapi/service/ApiGasService.java
  24. 2
      service/src/main/java/com/hfkj/service/agent/BsAgentMerService.java
  25. 16
      service/src/main/java/com/hfkj/service/agent/BsAgentPriceService.java
  26. 82
      service/src/main/java/com/hfkj/service/agent/impl/BsAgentMerServiceImpl.java
  27. 16
      service/src/main/java/com/hfkj/service/agent/impl/BsAgentPriceServiceImpl.java

@ -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);
}
}
}

@ -324,8 +324,8 @@ public class BsGasOrderController {
model.setGasDiscount(gasOrder.getGasDiscount().compareTo(new BigDecimal("1")) != 0?gasOrder.getGasDiscount().multiply(new BigDecimal("100")).setScale(2).toString():"无");
model.setGasOilNo(gasOrder.getGasOilNo() + "#");
model.setGasGunNo(gasOrder.getGasGunNo() + "号枪");
model.setGasPricePlatform(gasOrder.getCreateType().equals(GasOrderCreateType.TYPE1.getNumber())?gasOrder.getGasPricePlatform().toString():"无");
model.setGasPriceVip(gasOrder.getCreateType().equals(GasOrderCreateType.TYPE1.getNumber())?gasOrder.getGasPriceVip().toString():"无");
model.setGasPricePlatform(gasOrder.getGasPricePlatform().toString());
model.setGasPriceVip(gasOrder.getGasPriceVip().toString());
model.setGasPriceGun(gasOrder.getGasPriceGun());
model.setGasPriceOfficial(gasOrder.getGasPriceOfficial());
model.setGasSettlePrice(gasOrder.getGasSettlePrice());

@ -147,7 +147,7 @@ public class BsMerchantController {
} else {
merchantService.updateMerchant(merchant);
// 通知代理
agentMerService.agentNotify(merchant.getMerNo());
agentMerService.agentNotify(null, merchant.getMerNo());
}
return ResponseMsgUtil.success("操作成功");
@ -170,7 +170,7 @@ public class BsMerchantController {
merchantService.updateMerStatus(body.getString("merNo"), MerchantStatusEnum.status1);
// 通知代理
agentMerService.agentNotify(body.getString("merNo"));
agentMerService.agentNotify(null, body.getString("merNo"));
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
@ -215,7 +215,7 @@ public class BsMerchantController {
merchantService.updateMerStatus(body.getString("merNo"), MerchantStatusEnum.status2);
// 通知代理
agentMerService.agentNotify(body.getString("merNo"));
agentMerService.agentNotify(null,body.getString("merNo"));
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {

@ -78,6 +78,21 @@ public class TestController {
@Resource
private CommonService commonService;
@RequestMapping(value="testAgentNotify",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "测试api推送")
public ResponseData testAgentNotify(@RequestBody JSONObject body) {
try {
System.out.println("收到参数:" + body.toJSONString());
return ResponseMsgUtil.success("");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="testApiPush",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试api推送")

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://139.9.154.68:3306/hai_oil_prod?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://139.9.154.68:3306/hai_oil?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource

@ -66,7 +66,7 @@ public class BsGasController {
PageHelper.startPage(body.getPageNum(), body.getPageSize());
PageInfo<ResponseQueryGasInfoModel> pageInfo = new PageInfo<>(agentMerService.getMerNoList(apiParam.getAgentId()));
for (int i = 0; i < pageInfo.getList().size();i++) {
pageInfo.getList().set(i, apiGasService.queryGasInfo(pageInfo.getList().get(i).getGasNo()));
pageInfo.getList().set(i, apiGasService.queryGasInfo(apiParam.getAgentId(),pageInfo.getList().get(i).getGasNo()));
}
Map<String,Object> response = new LinkedHashMap<>();
response.put("totalCount", pageInfo.getTotal());
@ -103,7 +103,7 @@ public class BsGasController {
if (agentMer == null) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未查到加油站信息");
}
ResponseQueryGasInfoModel response = apiGasService.queryGasInfo(body.getGasNo());
ResponseQueryGasInfoModel response = apiGasService.queryGasInfo(apiParam.getAgentId(), body.getGasNo());
log.info("返回参数:" + JSONObject.toJSONString(response));
return ResponseMsgUtil.success(response);

@ -0,0 +1,56 @@
package com.hfkj.schedule;
import com.hfkj.channel.gas.newlink.NewLinkGasService;
import com.hfkj.channel.gas.shell.CqShellPetroleumGasService;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.entity.BsGasOrder;
import com.hfkj.service.gas.BsGasOrderService;
import com.hfkj.sysenum.gas.OrderOilStatus;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
/**
* @className: GasOrderSchedule
* @author: HuRui
* @date: 2025/11/13
**/
@Component
public class GasOrderSchedule {
@Resource
private BsGasOrderService gasOrderService;
/**
* 补推异常订单补推已支付的异常30秒执行查询一次
*/
@Scheduled(fixedDelay = 30000)
public void repairOrder() {
try {
Map<String,Object> param = new HashMap<>();
param.put("abnormal", true);
param.put("status", OrderOilStatus.STATUS2.getNumber());
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.SECOND, -60); // 60秒前的数据
param.put("payTimeS", calendar.getTimeInMillis());
List<BsGasOrder> orderList = gasOrderService.getGasOrderList(param);
for (BsGasOrder gasOrder : orderList) {
// 补推
gasOrderService.repairOrder(gasOrder.getOrderNo());
}
} catch (Exception e) {
System.out.println("能链【团油】油站获取失败!!!");
}
}
}

@ -344,7 +344,7 @@ public class NewLinkGasService {
// 清除油站缓存
gasService.clean(merchant.getMerNo());
// 通知代理
agentMerService.agentNotify(merNo);
agentMerService.agentNotify(null, merNo);
}
else if ("120000".equals(response.getString("code"))) {
/*** 油站下线 ***/
@ -356,7 +356,7 @@ public class NewLinkGasService {
merchantService.updateMerchant(merchant);
}
// 通知代理
agentMerService.agentNotify(merNo);
agentMerService.agentNotify(null, merNo);
}
}

@ -215,7 +215,7 @@ public class CqShellPetroleumGasService {
// 清除油站缓存
gasService.clean(merchant.getMerNo());
// 通知代理
agentMerService.agentNotify(merchant.getMerNo());
agentMerService.agentNotify(null, merchant.getMerNo());
} catch (Exception e) {
System.out.println("更新油站失败");
}

@ -86,12 +86,21 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception {
JSONObject obj = new JSONObject();
obj.put("appId", "hfa52e9d683e7056");
obj.put("appId", "hffeab7fdb44d4f1");
obj.put("pageNum", "1");
obj.put("pageSize", "100");
String sign = createSign(JSONObject.parseObject(obj.toJSONString()), "251529f314cc2a8679280d88626b1ef2");
System.out.println(sign);
//obj.put("appId","hffeab7fdb44d4f1");
//obj.put("gasNo","10021");
//obj.put("oilNo","92");
//obj.put("gunNo","3");
//obj.put("orderNo",System.currentTimeMillis()+"");
//obj.put("refuelingAmount","100");
//obj.put("userPhone","17726395120");
String sign = createSign(JSONObject.parseObject(obj.toJSONString()), "3a9b2772b9a2d319a9b18e55fa30246d");
obj.put("sign", sign);
System.out.println(JSONObject.toJSONString(obj));
}
}

@ -41,13 +41,17 @@ public interface BsAgentMerMapper extends BsAgentMerMapperExt {
@Insert({
"insert into bs_agent_mer (agent_id, agent_name, ",
"agent_staff_id, agent_staff_name, ",
"mer_id, mer_no, mer_name, ",
"mer_source_type, province_code, ",
"province_name, mer_id, ",
"mer_no, mer_name, ",
"qr_code_img_url, `status`, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"values (#{agentId,jdbcType=BIGINT}, #{agentName,jdbcType=VARCHAR}, ",
"#{agentStaffId,jdbcType=BIGINT}, #{agentStaffName,jdbcType=VARCHAR}, ",
"#{merId,jdbcType=BIGINT}, #{merNo,jdbcType=VARCHAR}, #{merName,jdbcType=VARCHAR}, ",
"#{merSourceType,jdbcType=INTEGER}, #{provinceCode,jdbcType=BIGINT}, ",
"#{provinceName,jdbcType=VARCHAR}, #{merId,jdbcType=BIGINT}, ",
"#{merNo,jdbcType=VARCHAR}, #{merName,jdbcType=VARCHAR}, ",
"#{qrCodeImgUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
@ -66,6 +70,9 @@ public interface BsAgentMerMapper extends BsAgentMerMapperExt {
@Result(column="agent_name", property="agentName", jdbcType=JdbcType.VARCHAR),
@Result(column="agent_staff_id", property="agentStaffId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_staff_name", property="agentStaffName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_source_type", property="merSourceType", jdbcType=JdbcType.INTEGER),
@Result(column="province_code", property="provinceCode", jdbcType=JdbcType.BIGINT),
@Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@ -81,9 +88,9 @@ public interface BsAgentMerMapper extends BsAgentMerMapperExt {
@Select({
"select",
"id, agent_id, agent_name, agent_staff_id, agent_staff_name, mer_id, mer_no, ",
"mer_name, qr_code_img_url, `status`, create_time, update_time, ext_1, ext_2, ",
"ext_3",
"id, agent_id, agent_name, agent_staff_id, agent_staff_name, mer_source_type, ",
"province_code, province_name, mer_id, mer_no, mer_name, qr_code_img_url, `status`, ",
"create_time, update_time, ext_1, ext_2, ext_3",
"from bs_agent_mer",
"where id = #{id,jdbcType=BIGINT}"
})
@ -93,6 +100,9 @@ public interface BsAgentMerMapper extends BsAgentMerMapperExt {
@Result(column="agent_name", property="agentName", jdbcType=JdbcType.VARCHAR),
@Result(column="agent_staff_id", property="agentStaffId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_staff_name", property="agentStaffName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_source_type", property="merSourceType", jdbcType=JdbcType.INTEGER),
@Result(column="province_code", property="provinceCode", jdbcType=JdbcType.BIGINT),
@Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@ -121,6 +131,9 @@ public interface BsAgentMerMapper extends BsAgentMerMapperExt {
"agent_name = #{agentName,jdbcType=VARCHAR},",
"agent_staff_id = #{agentStaffId,jdbcType=BIGINT},",
"agent_staff_name = #{agentStaffName,jdbcType=VARCHAR},",
"mer_source_type = #{merSourceType,jdbcType=INTEGER},",
"province_code = #{provinceCode,jdbcType=BIGINT},",
"province_name = #{provinceName,jdbcType=VARCHAR},",
"mer_id = #{merId,jdbcType=BIGINT},",
"mer_no = #{merNo,jdbcType=VARCHAR},",
"mer_name = #{merName,jdbcType=VARCHAR},",

@ -16,22 +16,26 @@ import java.util.Map;
public interface BsAgentMerMapperExt {
@Insert(value = {
"<script>",
"insert into bs_agent_mer (agent_id, agent_name, ",
"agent_staff_id, agent_staff_name, ",
"mer_id, mer_no, mer_name, ",
"qr_code_img_url, `status`, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"values " +
"<foreach collection=\"dataList\" item=\"item\" index=\"idx\" open=\"(\" separator=\"),(\" close=\")\">",
"#{item.agentId,jdbcType=BIGINT}, #{item.agentName,jdbcType=VARCHAR}, ",
"#{item.agentStaffId,jdbcType=BIGINT}, #{item.agentStaffName,jdbcType=VARCHAR}, ",
"#{item.merId,jdbcType=BIGINT}, #{item.merNo,jdbcType=VARCHAR}, #{item.merName,jdbcType=VARCHAR}, ",
"#{item.qrCodeImgUrl,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER}, ",
"#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, ",
"#{item.ext1,jdbcType=VARCHAR}, #{item.ext2,jdbcType=VARCHAR}, #{item.ext3,jdbcType=VARCHAR}",
"</foreach>",
"<script>" +
" insert into bs_agent_mer (agent_id, agent_name, ",
" agent_staff_id, agent_staff_name, ",
" mer_source_type, province_code, ",
" province_name, mer_id, ",
" mer_no, mer_name, ",
" qr_code_img_url, `status`, ",
" create_time, update_time, ",
" ext_1, ext_2, ext_3)",
" values" +
" <foreach collection=\"dataList\" item=\"item\" index=\"idx\" open=\"(\" separator=\"),(\" close=\")\">",
" #{item.agentId,jdbcType=BIGINT}, #{item.agentName,jdbcType=VARCHAR}, ",
" #{item.agentStaffId,jdbcType=BIGINT}, #{item.agentStaffName,jdbcType=VARCHAR}, ",
" #{item.merSourceType,jdbcType=INTEGER}, #{item.provinceCode,jdbcType=BIGINT}, ",
" #{item.provinceName,jdbcType=VARCHAR}, #{item.merId,jdbcType=BIGINT}, ",
" #{item.merNo,jdbcType=VARCHAR}, #{item.merName,jdbcType=VARCHAR}, ",
" #{item.qrCodeImgUrl,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER}, ",
" #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, ",
" #{item.ext1,jdbcType=VARCHAR}, #{item.ext2,jdbcType=VARCHAR}, #{item.ext3,jdbcType=VARCHAR}",
" </foreach>",
"</script>"
})
void addPatch(@Param(value = "dataList") List<BsAgentMer> dataList);
@ -46,6 +50,7 @@ public interface BsAgentMerMapperExt {
" a.merName," +
" a.merAddress," +
" a.agentName," +
" a.status," +
" a.createTime," +
" GROUP_CONCAT(a.agentStaffName) agentStaff" +
" FROM " +
@ -57,6 +62,7 @@ public interface BsAgentMerMapperExt {
" a.mer_no merNo," +
" a.mer_name merName," +
" a.address merAddress," +
" a.status status," +
" b.id agentMerId," +
" b.agent_id agentId," +
" b.agent_name agentName," +

@ -44,6 +44,18 @@ public class BsAgentMerSqlProvider {
sql.VALUES("agent_staff_name", "#{agentStaffName,jdbcType=VARCHAR}");
}
if (record.getMerSourceType() != null) {
sql.VALUES("mer_source_type", "#{merSourceType,jdbcType=INTEGER}");
}
if (record.getProvinceCode() != null) {
sql.VALUES("province_code", "#{provinceCode,jdbcType=BIGINT}");
}
if (record.getProvinceName() != null) {
sql.VALUES("province_name", "#{provinceName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}");
}
@ -98,6 +110,9 @@ public class BsAgentMerSqlProvider {
sql.SELECT("agent_name");
sql.SELECT("agent_staff_id");
sql.SELECT("agent_staff_name");
sql.SELECT("mer_source_type");
sql.SELECT("province_code");
sql.SELECT("province_name");
sql.SELECT("mer_id");
sql.SELECT("mer_no");
sql.SELECT("mer_name");
@ -145,6 +160,18 @@ public class BsAgentMerSqlProvider {
sql.SET("agent_staff_name = #{record.agentStaffName,jdbcType=VARCHAR}");
}
if (record.getMerSourceType() != null) {
sql.SET("mer_source_type = #{record.merSourceType,jdbcType=INTEGER}");
}
if (record.getProvinceCode() != null) {
sql.SET("province_code = #{record.provinceCode,jdbcType=BIGINT}");
}
if (record.getProvinceName() != null) {
sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
}
@ -198,6 +225,9 @@ public class BsAgentMerSqlProvider {
sql.SET("agent_name = #{record.agentName,jdbcType=VARCHAR}");
sql.SET("agent_staff_id = #{record.agentStaffId,jdbcType=BIGINT}");
sql.SET("agent_staff_name = #{record.agentStaffName,jdbcType=VARCHAR}");
sql.SET("mer_source_type = #{record.merSourceType,jdbcType=INTEGER}");
sql.SET("province_code = #{record.provinceCode,jdbcType=BIGINT}");
sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}");
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}");
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}");
@ -234,6 +264,18 @@ public class BsAgentMerSqlProvider {
sql.SET("agent_staff_name = #{agentStaffName,jdbcType=VARCHAR}");
}
if (record.getMerSourceType() != null) {
sql.SET("mer_source_type = #{merSourceType,jdbcType=INTEGER}");
}
if (record.getProvinceCode() != null) {
sql.SET("province_code = #{provinceCode,jdbcType=BIGINT}");
}
if (record.getProvinceName() != null) {
sql.SET("province_name = #{provinceName,jdbcType=VARCHAR}");
}
if (record.getMerId() != null) {
sql.SET("mer_id = #{merId,jdbcType=BIGINT}");
}

@ -41,18 +41,20 @@ public interface BsAgentPriceMapper extends BsAgentPriceMapperExt {
@Insert({
"insert into bs_agent_price (`type`, mer_id, ",
"mer_no, mer_name, ",
"agent_mer_id, oil_no_name, ",
"oil_no, price_rate, ",
"service_fee_rate, `status`, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"agent_id, agent_mer_id, ",
"oil_no_name, oil_no, ",
"price_rate, service_fee_rate, ",
"`status`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{type,jdbcType=INTEGER}, #{merId,jdbcType=BIGINT}, ",
"#{merNo,jdbcType=VARCHAR}, #{merName,jdbcType=VARCHAR}, ",
"#{agentMerId,jdbcType=BIGINT}, #{oilNoName,jdbcType=VARCHAR}, ",
"#{oilNo,jdbcType=VARCHAR}, #{priceRate,jdbcType=DECIMAL}, ",
"#{serviceFeeRate,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"#{agentId,jdbcType=BIGINT}, #{agentMerId,jdbcType=BIGINT}, ",
"#{oilNoName,jdbcType=VARCHAR}, #{oilNo,jdbcType=VARCHAR}, ",
"#{priceRate,jdbcType=DECIMAL}, #{serviceFeeRate,jdbcType=DECIMAL}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsAgentPrice record);
@ -68,6 +70,7 @@ public interface BsAgentPriceMapper extends BsAgentPriceMapperExt {
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_mer_id", property="agentMerId", jdbcType=JdbcType.BIGINT),
@Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR),
@Result(column="oil_no", property="oilNo", jdbcType=JdbcType.VARCHAR),
@ -84,8 +87,9 @@ public interface BsAgentPriceMapper extends BsAgentPriceMapperExt {
@Select({
"select",
"id, `type`, mer_id, mer_no, mer_name, agent_mer_id, oil_no_name, oil_no, price_rate, ",
"service_fee_rate, `status`, create_time, update_time, ext_1, ext_2, ext_3",
"id, `type`, mer_id, mer_no, mer_name, agent_id, agent_mer_id, oil_no_name, oil_no, ",
"price_rate, service_fee_rate, `status`, create_time, update_time, ext_1, ext_2, ",
"ext_3",
"from bs_agent_price",
"where id = #{id,jdbcType=BIGINT}"
})
@ -95,6 +99,7 @@ public interface BsAgentPriceMapper extends BsAgentPriceMapperExt {
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="agent_mer_id", property="agentMerId", jdbcType=JdbcType.BIGINT),
@Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR),
@Result(column="oil_no", property="oilNo", jdbcType=JdbcType.VARCHAR),
@ -124,6 +129,7 @@ public interface BsAgentPriceMapper extends BsAgentPriceMapperExt {
"mer_id = #{merId,jdbcType=BIGINT},",
"mer_no = #{merNo,jdbcType=VARCHAR},",
"mer_name = #{merName,jdbcType=VARCHAR},",
"agent_id = #{agentId,jdbcType=BIGINT},",
"agent_mer_id = #{agentMerId,jdbcType=BIGINT},",
"oil_no_name = #{oilNoName,jdbcType=VARCHAR},",
"oil_no = #{oilNo,jdbcType=VARCHAR},",

@ -44,4 +44,36 @@ public interface BsAgentPriceMapperExt {
"</script>")
List<Map<String,Object>> queryAgentPriceList(@Param("param") Map<String,Object> param);
@Select("<script>" +
" select a.*," +
" case when b.price_rate is not null then b.price_rate else 100 end priceRate," +
" ROUND(a.priceGun * ((case when b.price_rate is not null then b.price_rate else 100 end) / 100),2) terminalPrice" +
" from " +
" (select " +
" c.agent_name agentName," +
" b.province_name provinceName," +
" b.source_type sourceType, " +
" b.mer_no merNo," +
" b.mer_name merName," +
" a.oil_no oilNo," +
" a.price_official priceOfficial," +
" a.price_gun priceGun," +
" a.price_vip priceVip," +
" c.id agentMerId" +
" from bs_gas_oil_price a" +
" LEFT JOIN bs_merchant b on b.id = a.mer_id" +
" LEFT JOIN bs_agent_mer c on c.mer_id = a.mer_id and c.`status` = 1" +
" where a.`status` = 1 and c.`status` = 1 and c.agent_staff_id is null" +
" <if test='param.agentId != null'> and c.agent_id = #{param.agentId} </if>" +
" <if test='param.provinceCode != null'> and b.province_code = #{param.provinceCode} </if>" +
" <if test='param.merNo != null'> and b.mer_no like concat('%',#{param.merNo},'%') </if>" +
" <if test='param.merName != null'> and b.mer_name like concat('%',#{param.merName},'%') </if>" +
" <if test='param.sourceType != null'> and b.source_type = #{param.sourceType} </if>" +
" <if test='param.oilNo != null'> and a.oil_no = #{param.oilNo} </if>" +
" ORDER BY b.mer_no,oil_no) a" +
" LEFT JOIN bs_agent_price b on b.agent_mer_id = a.agentMerId and b.oil_no = a.oilNo and b.status = 1 " +
" ORDER BY a.merNo" +
"</script>")
List<Map<String,Object>> queryApiAgentDiscountList(@Param("param") Map<String,Object> param);
}

@ -44,6 +44,10 @@ public class BsAgentPriceSqlProvider {
sql.VALUES("mer_name", "#{merName,jdbcType=VARCHAR}");
}
if (record.getAgentId() != null) {
sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}");
}
if (record.getAgentMerId() != null) {
sql.VALUES("agent_mer_id", "#{agentMerId,jdbcType=BIGINT}");
}
@ -102,6 +106,7 @@ public class BsAgentPriceSqlProvider {
sql.SELECT("mer_id");
sql.SELECT("mer_no");
sql.SELECT("mer_name");
sql.SELECT("agent_id");
sql.SELECT("agent_mer_id");
sql.SELECT("oil_no_name");
sql.SELECT("oil_no");
@ -150,6 +155,10 @@ public class BsAgentPriceSqlProvider {
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}");
}
if (record.getAgentId() != null) {
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
}
if (record.getAgentMerId() != null) {
sql.SET("agent_mer_id = #{record.agentMerId,jdbcType=BIGINT}");
}
@ -207,6 +216,7 @@ public class BsAgentPriceSqlProvider {
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}");
sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}");
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}");
sql.SET("agent_mer_id = #{record.agentMerId,jdbcType=BIGINT}");
sql.SET("oil_no_name = #{record.oilNoName,jdbcType=VARCHAR}");
sql.SET("oil_no = #{record.oilNo,jdbcType=VARCHAR}");
@ -244,6 +254,10 @@ public class BsAgentPriceSqlProvider {
sql.SET("mer_name = #{merName,jdbcType=VARCHAR}");
}
if (record.getAgentId() != null) {
sql.SET("agent_id = #{agentId,jdbcType=BIGINT}");
}
if (record.getAgentMerId() != null) {
sql.SET("agent_mer_id = #{agentMerId,jdbcType=BIGINT}");
}

@ -35,6 +35,21 @@ public class BsAgentMer implements Serializable {
*/
private String agentStaffName;
/**
* 来源类型
*/
private Integer merSourceType;
/**
* 省地区代码
*/
private Long provinceCode;
/**
* 省地区名称
*/
private String provinceName;
/**
* 加油站id
*/
@ -118,6 +133,30 @@ public class BsAgentMer implements Serializable {
this.agentStaffName = agentStaffName;
}
public Integer getMerSourceType() {
return merSourceType;
}
public void setMerSourceType(Integer merSourceType) {
this.merSourceType = merSourceType;
}
public Long getProvinceCode() {
return provinceCode;
}
public void setProvinceCode(Long provinceCode) {
this.provinceCode = provinceCode;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName;
}
public Long getMerId() {
return merId;
}
@ -215,6 +254,9 @@ public class BsAgentMer implements Serializable {
&& (this.getAgentName() == null ? other.getAgentName() == null : this.getAgentName().equals(other.getAgentName()))
&& (this.getAgentStaffId() == null ? other.getAgentStaffId() == null : this.getAgentStaffId().equals(other.getAgentStaffId()))
&& (this.getAgentStaffName() == null ? other.getAgentStaffName() == null : this.getAgentStaffName().equals(other.getAgentStaffName()))
&& (this.getMerSourceType() == null ? other.getMerSourceType() == null : this.getMerSourceType().equals(other.getMerSourceType()))
&& (this.getProvinceCode() == null ? other.getProvinceCode() == null : this.getProvinceCode().equals(other.getProvinceCode()))
&& (this.getProvinceName() == null ? other.getProvinceName() == null : this.getProvinceName().equals(other.getProvinceName()))
&& (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId()))
&& (this.getMerNo() == null ? other.getMerNo() == null : this.getMerNo().equals(other.getMerNo()))
&& (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName()))
@ -236,6 +278,9 @@ public class BsAgentMer implements Serializable {
result = prime * result + ((getAgentName() == null) ? 0 : getAgentName().hashCode());
result = prime * result + ((getAgentStaffId() == null) ? 0 : getAgentStaffId().hashCode());
result = prime * result + ((getAgentStaffName() == null) ? 0 : getAgentStaffName().hashCode());
result = prime * result + ((getMerSourceType() == null) ? 0 : getMerSourceType().hashCode());
result = prime * result + ((getProvinceCode() == null) ? 0 : getProvinceCode().hashCode());
result = prime * result + ((getProvinceName() == null) ? 0 : getProvinceName().hashCode());
result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode());
result = prime * result + ((getMerNo() == null) ? 0 : getMerNo().hashCode());
result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode());
@ -260,6 +305,9 @@ public class BsAgentMer implements Serializable {
sb.append(", agentName=").append(agentName);
sb.append(", agentStaffId=").append(agentStaffId);
sb.append(", agentStaffName=").append(agentStaffName);
sb.append(", merSourceType=").append(merSourceType);
sb.append(", provinceCode=").append(provinceCode);
sb.append(", provinceName=").append(provinceName);
sb.append(", merId=").append(merId);
sb.append(", merNo=").append(merNo);
sb.append(", merName=").append(merName);

@ -445,6 +445,196 @@ public class BsAgentMerExample {
return (Criteria) this;
}
public Criteria andMerSourceTypeIsNull() {
addCriterion("mer_source_type is null");
return (Criteria) this;
}
public Criteria andMerSourceTypeIsNotNull() {
addCriterion("mer_source_type is not null");
return (Criteria) this;
}
public Criteria andMerSourceTypeEqualTo(Integer value) {
addCriterion("mer_source_type =", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeNotEqualTo(Integer value) {
addCriterion("mer_source_type <>", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeGreaterThan(Integer value) {
addCriterion("mer_source_type >", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("mer_source_type >=", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeLessThan(Integer value) {
addCriterion("mer_source_type <", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeLessThanOrEqualTo(Integer value) {
addCriterion("mer_source_type <=", value, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeIn(List<Integer> values) {
addCriterion("mer_source_type in", values, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeNotIn(List<Integer> values) {
addCriterion("mer_source_type not in", values, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeBetween(Integer value1, Integer value2) {
addCriterion("mer_source_type between", value1, value2, "merSourceType");
return (Criteria) this;
}
public Criteria andMerSourceTypeNotBetween(Integer value1, Integer value2) {
addCriterion("mer_source_type not between", value1, value2, "merSourceType");
return (Criteria) this;
}
public Criteria andProvinceCodeIsNull() {
addCriterion("province_code is null");
return (Criteria) this;
}
public Criteria andProvinceCodeIsNotNull() {
addCriterion("province_code is not null");
return (Criteria) this;
}
public Criteria andProvinceCodeEqualTo(Long value) {
addCriterion("province_code =", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeNotEqualTo(Long value) {
addCriterion("province_code <>", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeGreaterThan(Long value) {
addCriterion("province_code >", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeGreaterThanOrEqualTo(Long value) {
addCriterion("province_code >=", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeLessThan(Long value) {
addCriterion("province_code <", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeLessThanOrEqualTo(Long value) {
addCriterion("province_code <=", value, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeIn(List<Long> values) {
addCriterion("province_code in", values, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeNotIn(List<Long> values) {
addCriterion("province_code not in", values, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeBetween(Long value1, Long value2) {
addCriterion("province_code between", value1, value2, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceCodeNotBetween(Long value1, Long value2) {
addCriterion("province_code not between", value1, value2, "provinceCode");
return (Criteria) this;
}
public Criteria andProvinceNameIsNull() {
addCriterion("province_name is null");
return (Criteria) this;
}
public Criteria andProvinceNameIsNotNull() {
addCriterion("province_name is not null");
return (Criteria) this;
}
public Criteria andProvinceNameEqualTo(String value) {
addCriterion("province_name =", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotEqualTo(String value) {
addCriterion("province_name <>", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThan(String value) {
addCriterion("province_name >", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameGreaterThanOrEqualTo(String value) {
addCriterion("province_name >=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThan(String value) {
addCriterion("province_name <", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLessThanOrEqualTo(String value) {
addCriterion("province_name <=", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameLike(String value) {
addCriterion("province_name like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotLike(String value) {
addCriterion("province_name not like", value, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameIn(List<String> values) {
addCriterion("province_name in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotIn(List<String> values) {
addCriterion("province_name not in", values, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameBetween(String value1, String value2) {
addCriterion("province_name between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andProvinceNameNotBetween(String value1, String value2) {
addCriterion("province_name not between", value1, value2, "provinceName");
return (Criteria) this;
}
public Criteria andMerIdIsNull() {
addCriterion("mer_id is null");
return (Criteria) this;

@ -36,6 +36,11 @@ public class BsAgentPrice implements Serializable {
*/
private String merName;
/**
* 代理商id
*/
private Long agentId;
/**
* 代理油站数据id
*/
@ -124,6 +129,14 @@ public class BsAgentPrice implements Serializable {
this.merName = merName;
}
public Long getAgentId() {
return agentId;
}
public void setAgentId(Long agentId) {
this.agentId = agentId;
}
public Long getAgentMerId() {
return agentMerId;
}
@ -229,6 +242,7 @@ public class BsAgentPrice implements Serializable {
&& (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId()))
&& (this.getMerNo() == null ? other.getMerNo() == null : this.getMerNo().equals(other.getMerNo()))
&& (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName()))
&& (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId()))
&& (this.getAgentMerId() == null ? other.getAgentMerId() == null : this.getAgentMerId().equals(other.getAgentMerId()))
&& (this.getOilNoName() == null ? other.getOilNoName() == null : this.getOilNoName().equals(other.getOilNoName()))
&& (this.getOilNo() == null ? other.getOilNo() == null : this.getOilNo().equals(other.getOilNo()))
@ -251,6 +265,7 @@ public class BsAgentPrice implements Serializable {
result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode());
result = prime * result + ((getMerNo() == null) ? 0 : getMerNo().hashCode());
result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode());
result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode());
result = prime * result + ((getAgentMerId() == null) ? 0 : getAgentMerId().hashCode());
result = prime * result + ((getOilNoName() == null) ? 0 : getOilNoName().hashCode());
result = prime * result + ((getOilNo() == null) ? 0 : getOilNo().hashCode());
@ -276,6 +291,7 @@ public class BsAgentPrice implements Serializable {
sb.append(", merId=").append(merId);
sb.append(", merNo=").append(merNo);
sb.append(", merName=").append(merName);
sb.append(", agentId=").append(agentId);
sb.append(", agentMerId=").append(agentMerId);
sb.append(", oilNoName=").append(oilNoName);
sb.append(", oilNo=").append(oilNo);

@ -446,6 +446,66 @@ public class BsAgentPriceExample {
return (Criteria) this;
}
public Criteria andAgentIdIsNull() {
addCriterion("agent_id is null");
return (Criteria) this;
}
public Criteria andAgentIdIsNotNull() {
addCriterion("agent_id is not null");
return (Criteria) this;
}
public Criteria andAgentIdEqualTo(Long value) {
addCriterion("agent_id =", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdNotEqualTo(Long value) {
addCriterion("agent_id <>", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdGreaterThan(Long value) {
addCriterion("agent_id >", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdGreaterThanOrEqualTo(Long value) {
addCriterion("agent_id >=", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdLessThan(Long value) {
addCriterion("agent_id <", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdLessThanOrEqualTo(Long value) {
addCriterion("agent_id <=", value, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdIn(List<Long> values) {
addCriterion("agent_id in", values, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdNotIn(List<Long> values) {
addCriterion("agent_id not in", values, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdBetween(Long value1, Long value2) {
addCriterion("agent_id between", value1, value2, "agentId");
return (Criteria) this;
}
public Criteria andAgentIdNotBetween(Long value1, Long value2) {
addCriterion("agent_id not between", value1, value2, "agentId");
return (Criteria) this;
}
public Criteria andAgentMerIdIsNull() {
addCriterion("agent_mer_id is null");
return (Criteria) this;

@ -38,4 +38,8 @@ public class GasOilPriceDetail {
* 油枪价
*/
private BigDecimal priceGun;
/**
* 优惠价
*/
private BigDecimal priceVip;
}

@ -21,10 +21,7 @@ import com.hfkj.openapi.model.response.OrderRefundNotifyModel;
import com.hfkj.openapi.model.response.ResponseOrderDetailModel;
import com.hfkj.openapi.model.response.ResponseOrderPushModel;
import com.hfkj.service.BsDeviceService;
import com.hfkj.service.agent.BsAgentApiAccountService;
import com.hfkj.service.agent.BsAgentApiParamService;
import com.hfkj.service.agent.BsAgentMerService;
import com.hfkj.service.agent.BsAgentService;
import com.hfkj.service.agent.*;
import com.hfkj.service.gas.BsGasClassGroupTaskService;
import com.hfkj.service.gas.BsGasOilPriceService;
import com.hfkj.service.gas.BsGasOrderService;
@ -95,6 +92,8 @@ public class ApiGasOrderService {
@Resource
private BsGasOilPriceService gasOilPriceService;
@Resource
private BsAgentPriceService agentPriceService;
@Resource
private RedisTemplate<String, Object> redisTemplate;
private final String LOCK_KEY = "AGENT_API_PUSH_ORDER_LOCK_";
/**
@ -177,11 +176,17 @@ public class ApiGasOrderService {
gasOrder.setGasGunNo(request.getGunNo());
gasOrder.setGasOilType(oilPrice.getOilType());
gasOrder.setGasPriceGun(oilPrice.getPriceGun());
gasOrder.setGasPriceVip(oilPrice.getPriceVip());
// 代理商价格
BigDecimal priceRate = new BigDecimal("100");
BsAgentPrice agentPrice = agentPriceService.getPrice(gasOrder.getAgentId(), gasDetail.getId(), oilPrice.getOilNo());
if (agentPrice != null) {
priceRate = agentPrice.getPriceRate();
}
gasOrder.setGasPriceVip(oilPrice.getPriceGun().multiply(priceRate.divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_UP));
gasOrder.setGasPriceCost(oilPrice.getPriceGun());
gasOrder.setGasPriceOfficial(oilPrice.getPriceOfficial());
gasOrder.setGasPricePlatform(oilPrice.getPriceGun());
gasOrder.setGasDiscount(new BigDecimal("0"));
gasOrder.setGasPricePlatform(gasOrder.getGasPriceVip());
gasOrder.setGasDiscount(agentPrice!=null?agentPrice.getPriceRate().divide(new BigDecimal("100")):new BigDecimal("0"));
gasOrder.setGasOilSubsidy(new BigDecimal("0"));
gasOrder.setGasLitersPreferences(new BigDecimal("0"));
gasOrder.setGasPricePreferences(new BigDecimal("0"));
@ -205,7 +210,14 @@ public class ApiGasOrderService {
} else {
gasOrder.setGasSettlePrice(gasOrder.getGasRefuelPrice());
}
gasOrder.setGasAgentSettlePrice(gasOrder.getGasRefuelPrice());
// 代理商结算
// 代理结算金额=加油金额-(加油金额/挂牌价(升数) *(挂牌价-优惠价))
BigDecimal agentSettlePrice = gasOrder.getGasRefuelPrice()
.subtract(gasOrder.getGasOilLiters()
.multiply((gasOrder.getGasPriceGun().subtract(gasOrder.getGasPriceVip()).setScale(2, BigDecimal.ROUND_HALF_DOWN))));
gasOrder.setGasAgentSettlePrice(agentSettlePrice);
// 油站是否开启班组
BsGasClassGroupTask groupTask = gasClassGroupTaskService.getCurrentTaskByMerId(gasDetail.getId());
if (groupTask != null) {
@ -219,7 +231,7 @@ public class ApiGasOrderService {
Map<String,Object> consumeParam = new HashMap<>();
consumeParam.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType());
consumeParam.put("sourceOrderNo", gasOrder.getOrderNo());
consumeParam.put("sourceOrderContent", "加油单:"+gasOrder.getOrderNo());
consumeParam.put("sourceOrderContent", "加油单:"+gasOrder.getOrderNo()+",加油金额:"+ gasOrder.getGasRefuelPrice());
agentApiAccountService.consume(agent.getId(), gasOrder.getGasAgentSettlePrice(), consumeParam);
// 处理支付后的加油业务
@ -611,4 +623,6 @@ public class ApiGasOrderService {
return gasOrder;
}
}

@ -48,12 +48,13 @@ import java.util.stream.Collectors;
public class ApiGasService {
@Resource
private BsGasService gasService;
@Resource
private BsAgentPriceService agentPriceService;
/**
* 查询油站详情
* @param gasNo
*/
public ResponseQueryGasInfoModel queryGasInfo(String gasNo) {
public ResponseQueryGasInfoModel queryGasInfo(Long agentId,String gasNo) {
// 油站详情
GasModel gasDetail = gasService.getGasDetail(gasNo);
if (gasDetail == null) {
@ -85,6 +86,13 @@ public class ApiGasService {
gasOilPriceDetail.setOilTypeName(oilPrice.getOilTypeName());
gasOilPriceDetail.setPriceOfficial(oilPrice.getPriceOfficial());
gasOilPriceDetail.setPriceGun(oilPrice.getPriceGun());
// 代理商价格
BigDecimal priceRate = new BigDecimal("100");
BsAgentPrice agentPrice = agentPriceService.getPrice(agentId, gasDetail.getId(), oilPrice.getOilNo());
if (agentPrice != null) {
priceRate = agentPrice.getPriceRate();
}
gasOilPriceDetail.setPriceVip(oilPrice.getPriceGun().multiply(priceRate.divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_UP));
gasOilPriceDetail.setGunNoList(oilPrice.getGasOilGunNo().stream().map(BsGasOilGunNo::getGunNo).collect(Collectors.toList()));
response.getOilPriceList().add(gasOilPriceDetail);
}

@ -102,6 +102,6 @@ public interface BsAgentMerService {
* 通知代理
* @param merNo
*/
void agentNotify(String merNo);
void agentNotify(Long agentId,String merNo);
}

@ -36,6 +36,15 @@ public interface BsAgentPriceService {
*/
BsAgentPrice getDetail(Long agentMerId,String oilNo);
/**
* 查询价格
* @param agentId
* @param merId
* @param oilNo
* @return
*/
BsAgentPrice getPrice(Long agentId,Long merId,String oilNo);
/**
* 查询列表
* @param type
@ -51,4 +60,11 @@ public interface BsAgentPriceService {
*/
List<Map<String,Object>> getAgentPriceList(Map<String,Object> param);
/**
* 查询API代理优惠
* @param param
* @return
*/
List<Map<String,Object>> getApiAgentDiscountList(Map<String,Object> param);
}

@ -84,7 +84,6 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
if (agent == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的代理商");
}
// 查询代理商的油站
Map<String,Object> param = new HashMap<>();
param.put("agentId", agent.getId());
@ -104,6 +103,9 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
agentMer.setAgentId(agent.getId());
agentMer.setAgentName(agent.getName());
agentMer.setAgentName(agent.getName());
agentMer.setMerSourceType(merchant.getSourceType());
agentMer.setProvinceCode(merchant.getProvinceCode());
agentMer.setProvinceName(merchant.getProvinceName());
agentMer.setMerId(merchant.getId());
agentMer.setMerNo(merchant.getMerNo());
agentMer.setMerName(merchant.getMerName());
@ -121,10 +123,24 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
account.setAmountConsume(new BigDecimal("0"));
account.setStatus(1);
agentMerAccountService.editData(account);
}
}
}
agentMerService.addData(dataList);
// 通知代理商
if (agent.getType().equals(AgentTypeEnum.type2.getCode())) {
// 代理参数
BsAgentApiParam apiParam = agentApiParamService.getParam(agentId);
if (apiParam != null && StringUtils.isNotBlank(apiParam.getMerInfoNotify())) {
for (BsAgentMer data : dataList) {
// 通知代理
agentMerService.agentNotify(apiParam.getAgentId(), data.getMerNo());
}
}
}
}
@Override
@ -182,7 +198,7 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
for (String merNo : merNoArray) {
try {
// 查询油站
ResponseQueryGasInfoModel gasInfo = apiGasService.queryGasInfo(merNo);
ResponseQueryGasInfoModel gasInfo = apiGasService.queryGasInfo(agentId,merNo);
gasInfo.setGasStatus(MerchantStatusEnum.status2.getNumber());
JSONObject notifyParam = JSONObject.parseObject(JSONObject.toJSONString(gasInfo), JSONObject.class);
notifyParam.put("sign", SignatureUtil.createSign(notifyParam, apiParam.getAppSecret()));
@ -215,6 +231,18 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
criteria.andAgentIdEqualTo(MapUtils.getLong(param, "agentId"));
}
if (MapUtils.getInteger(param, "merSourceType") != null) {
criteria.andMerSourceTypeEqualTo(MapUtils.getInteger(param, "merSourceType"));
}
if (MapUtils.getLong(param, "provinceCode") != null) {
criteria.andProvinceCodeEqualTo(MapUtils.getLong(param, "provinceCode"));
}
if (MapUtils.getLong(param, "agentId") != null) {
criteria.andAgentIdEqualTo(MapUtils.getLong(param, "agentId"));
}
if (MapUtils.getLong(param, "agentStaffId") != null) {
criteria.andAgentStaffIdEqualTo(MapUtils.getLong(param, "agentStaffId"));
}
@ -288,6 +316,9 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
agentMer.setAgentName(agent.getName());
agentMer.setAgentStaffId(staff.getId());
agentMer.setAgentStaffName(staff.getName());
agentMer.setMerSourceType(merchant.getSourceType());
agentMer.setProvinceCode(merchant.getProvinceCode());
agentMer.setProvinceName(merchant.getProvinceName());
agentMer.setMerId(merchant.getId());
agentMer.setMerNo(merchant.getMerNo());
agentMer.setMerName(merchant.getMerName());
@ -311,30 +342,31 @@ public class BsAgentMerServiceImpl implements BsAgentMerService {
}
@Override
public void agentNotify(String merNo) {
// 查询油站
ResponseQueryGasInfoModel gasInfo = apiGasService.queryGasInfo(merNo);
if (gasInfo != null) {
List<BsAgentApiParam> list = agentApiParamService.getParamListByGasNo(gasInfo.getGasNo());
for (BsAgentApiParam apiParam : list) {
if (StringUtils.isNotBlank(apiParam.getMerInfoNotify())) {
// 创建一个单线程的线程池
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
// 异步记录登录信息
singleThreadExecutor.submit(new Runnable() {
@Override
public void run() {
try {
// 通知代理
JSONObject notifyParam = JSONObject.parseObject(JSONObject.toJSONString(gasInfo), JSONObject.class);
notifyParam.put("sign", SignatureUtil.createSign(notifyParam, apiParam.getAppSecret()));
HttpsUtils.doApiPost(apiParam.getMerInfoNotify(), notifyParam);
} catch (Exception e) {
System.out.println("通知代理商:"+apiParam.getAgentId()+"失败"+e.getMessage());
}
public void agentNotify(Long agentId, String merNo) {
List<BsAgentApiParam> list = agentApiParamService.getParamListByGasNo(merNo);
if (agentId != null) {
list = list.stream().filter(o-> o.getAgentId().equals(agentId)).collect(Collectors.toList());
}
for (BsAgentApiParam apiParam : list) {
if (StringUtils.isNotBlank(apiParam.getMerInfoNotify())) {
// 查询油站
ResponseQueryGasInfoModel gasInfo = apiGasService.queryGasInfo(apiParam.getAgentId(),merNo);
// 创建一个单线程的线程池
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
// 异步记录登录信息
singleThreadExecutor.submit(new Runnable() {
@Override
public void run() {
try {
// 通知代理
JSONObject notifyParam = JSONObject.parseObject(JSONObject.toJSONString(gasInfo), JSONObject.class);
notifyParam.put("sign", SignatureUtil.createSign(notifyParam, apiParam.getAppSecret()));
HttpsUtils.doApiPost(apiParam.getMerInfoNotify(), notifyParam);
} catch (Exception e) {
System.out.println("通知代理商:"+apiParam.getAgentId()+"失败"+e.getMessage());
}
});
}
}
});
}
}
}

@ -57,6 +57,17 @@ public class BsAgentPriceServiceImpl implements BsAgentPriceService {
return null;
}
@Override
public BsAgentPrice getPrice(Long agentId, Long merId, String oilNo) {
BsAgentPriceExample example = new BsAgentPriceExample();
example.createCriteria().andAgentIdEqualTo(agentId).andMerIdEqualTo(merId).andOilNoEqualTo(oilNo).andStatusEqualTo(1);
List<BsAgentPrice> list = agentPriceMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<BsAgentPrice> getPriceList(AgentPriceTypeEnum type, String merNo) {
BsAgentPriceExample example = new BsAgentPriceExample();
@ -68,5 +79,10 @@ public class BsAgentPriceServiceImpl implements BsAgentPriceService {
public List<Map<String, Object>> getAgentPriceList(Map<String, Object> param) {
return agentPriceMapper.queryAgentPriceList(param);
}
@Override
public List<Map<String, Object>> getApiAgentDiscountList(Map<String, Object> param) {
return agentPriceMapper.queryApiAgentDiscountList(param);
}
}

Loading…
Cancel
Save