diff --git a/hai-bweb/src/main/java/com/bweb/config/RedisConfig.java b/hai-bweb/src/main/java/com/bweb/config/RedisConfig.java index 0c5f530e..9689c265 100644 --- a/hai-bweb/src/main/java/com/bweb/config/RedisConfig.java +++ b/hai-bweb/src/main/java/com/bweb/config/RedisConfig.java @@ -1,14 +1,19 @@ package com.bweb.config; +import com.bweb.config.msg.OilPriceTaskMsgListener; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; +import com.hai.msg.entity.MsgTopic; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.MessageListener; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.*; +import org.springframework.data.redis.listener.PatternTopic; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -17,6 +22,18 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; @EnableCaching //开启注解 public class RedisConfig extends CachingConfigurerSupport { + + @Bean + public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory factory) { + RedisMessageListenerContainer container = new RedisMessageListenerContainer(); + container.setConnectionFactory(factory); + + //可以添加多个 messageListener + container.addMessageListener(new OilPriceTaskMsgListener(), new PatternTopic(MsgTopic.oilPriceTask.getName())); + + return container; + } + /** * retemplate相关配置 * @param factory @@ -106,4 +123,4 @@ public class RedisConfig extends CachingConfigurerSupport { public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { return redisTemplate.opsForZSet(); } -} \ No newline at end of file +} diff --git a/hai-bweb/src/main/java/com/bweb/config/msg/OilPriceTaskMsgListener.java b/hai-bweb/src/main/java/com/bweb/config/msg/OilPriceTaskMsgListener.java new file mode 100644 index 00000000..8609c91a --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/config/msg/OilPriceTaskMsgListener.java @@ -0,0 +1,27 @@ +package com.bweb.config.msg; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; + +@Service(value = "driverLBSMsgListener") +public class OilPriceTaskMsgListener implements MessageListener { + + private static Logger logger = LoggerFactory.getLogger(OilPriceTaskMsgListener.class); + private RedisTemplate redisTemplate; + + @Override + public void onMessage(Message message, byte[] pattern) { + System.out.println(message); + } +} diff --git a/hai-bweb/src/main/java/com/bweb/config/msg/RedisKeyExpirationListener.java b/hai-bweb/src/main/java/com/bweb/config/msg/RedisKeyExpirationListener.java new file mode 100644 index 00000000..334b1058 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/config/msg/RedisKeyExpirationListener.java @@ -0,0 +1,59 @@ +package com.bweb.config.msg; + +import com.hai.entity.HighGasOilPriceTask; +import com.hai.msg.entity.MsgTopic; +import com.hai.service.HighGasOilPriceTaskService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author hurui + * @version 1.0 + * @ClassName RedisKeyExpirationListener + * @description: TODO + * @date 2021/8/19 10:00 + */ +@Component +public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener { + + private static Logger logger = LoggerFactory.getLogger(RedisKeyExpirationListener.class); + + @Resource + private HighGasOilPriceTaskService gasOilPriceTaskService; + + public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) { + super(listenerContainer); + } + + public void onMessage(Message message, byte[] pattern) { + try { + if (message != null && StringUtils.isNotBlank(message.toString())) { + // 加油站价格任务 + if (message.toString().contains(MsgTopic.oilPriceTask.getName())) { + // 截取任务id + Long taskId = Long.parseLong(StringUtils.substringAfterLast(message.toString(), MsgTopic.oilPriceTask.getName() + "-")); + if (taskId != null) { + // 查询任务 + HighGasOilPriceTask gasOilPriceTask = gasOilPriceTaskService.getDetailById(taskId); + if (gasOilPriceTask != null) { + // 任务处理 + gasOilPriceTaskService.businessHandle(gasOilPriceTask); + } + } + } + } + } catch (Exception e) { + logger.error("redis过期事件异常:", e); + } + } +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java index ae62e3a6..1224340e 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/CommonController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/CommonController.java @@ -38,6 +38,19 @@ public class CommonController { private SecConfigService secConfigService; + @RequestMapping(value="/getProvinceList",method= RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询省级列表") + public ResponseData getProvinceList(){ + try { + + return ResponseMsgUtil.success(commonService.getProvinceList()); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getRegionsByParentId",method= RequestMethod.GET) @ResponseBody @ApiOperation(value = "分级查询区域信息") diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java index ab501bdc..4aea9994 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.File; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -53,6 +54,9 @@ public class HighGasController { @Resource private HighMerchantStoreService merchantStoreService; + @Resource + private HighMerchantAccountService merchantAccountService; + @Resource private HighUserService highUserService; @@ -65,6 +69,35 @@ public class HighGasController { @Resource private RedisTemplate redisTemplate; + @RequestMapping(value="/getMerGasStatistical",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询商户油站统计") + public ResponseData getMerGasStatistical() { + try { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null || userInfoModel.getMerchant() == null) { + log.error("HighGasController -> getMerGasStatistical() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + + BigDecimal account = new BigDecimal("0"); + // 查询商户余额 + HighMerchantAccount merchantAccount = merchantAccountService.getStoreAccountDetail(userInfoModel.getMerchant().getId()); + if (merchantAccount != null) { + account = merchantAccount.getAmounts(); + } + Map param = new HashMap<>(); + param.put("amount", account.subtract(merchantAccountService.countMerGasOilAmount(userInfoModel.getMerchant().getId()))); + param.put("storeList", merchantAccountService.getStoreGasOilAmountByMer(userInfoModel.getMerchant().getId())); + + return ResponseMsgUtil.success(param); + + } catch (Exception e) { + log.error("HighGasController -> getMerGasStatistical() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getGasStatistical",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询油站统计") @@ -157,6 +190,38 @@ public class HighGasController { } } + @RequestMapping(value="/getGasSelectList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油站选择列表") + public ResponseData getGasSelectList() { + try { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + log.error("HighGasController -> disabledOil() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + + Map param = new HashMap<>(); + param.put("type", 1); + param.put("sourceType", 1); + param.put("status", 1); + + if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type0.getType())) { + + } else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type1.getType())) { + param.put("companyId", userInfoModel.getBsCompany().getId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + + return ResponseMsgUtil.success(merchantStoreService.getMerchantStoreList(param)); + + } catch (Exception e) { + log.error("HighGasController -> getGasSelectList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/exportGasOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "导出油站订单") diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java index f0c2a0e3..223d1f26 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasOilPriceTaskController.java @@ -6,9 +6,19 @@ import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighGasOilPriceTask; +import com.hai.entity.HighMerchantStore; +import com.hai.entity.SecDictionary; +import com.hai.entity.SecRegion; +import com.hai.enum_type.GasTaskPriceTypeEnum; +import com.hai.enum_type.UserObjectTypeEnum; import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.CommonService; import com.hai.service.HighGasOilPriceTaskService; +import com.hai.service.HighMerchantStoreService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -18,6 +28,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -30,19 +41,98 @@ public class HighGasOilPriceTaskController { @Resource private HighGasOilPriceTaskService gasOilPriceTaskService; - @RequestMapping(value="/addTask",method = RequestMethod.POST) + @Resource + private HighMerchantStoreService merchantStoreService; + + @Resource + private CommonService commonService; + + @Resource + private UserCenter userCenter; + + @RequestMapping(value="/batchAddTask",method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "增加任务") - public ResponseData addTask(@RequestBody JSONObject body) { + @ApiOperation(value = "批量增加任务") + public ResponseData batchAddTask(@RequestBody List taskList) { try { - if (body.getLong("regionId") == null - || body.getInteger("oilNo") == null - || body.getBigDecimal("price") == null - ) { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + if (taskList == null || taskList.size() == 0) { log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + for (HighGasOilPriceTask task : taskList) { + if (task.getPriceType() == null + || task.getPrice() == null + || task.getOilNo() == null + || task.getExecutionType() == null + ) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 执行方式 1. 立刻执行 2. 定时执行 + if (task.getExecutionType().equals(2) && task.getStartTime() == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置执行时间"); + } + + // 价格类型 1. 国标价 2. 油站价 3. 优惠幅度 + if (task.getPriceType().equals(GasTaskPriceTypeEnum.type1.getStatus())) { + if (task.getRegionId() == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置区域"); + } + // 加油站 + SecRegion region = commonService.getRegionsById(task.getRegionId()); + if (region == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到区域"); + } + task.setRegionId(region.getRegionId()); + task.setRegionName(region.getRegionName()); + } + + // 价格类型 1. 国标价 2. 油站价 3. 优惠幅度 + if (task.getPriceType().equals(GasTaskPriceTypeEnum.type2.getStatus()) + || task.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { + + if (task.getMerStoreId() == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置加油站"); + } + // 加油站 + HighMerchantStore store = merchantStoreService.getDetailById(task.getMerStoreId()); + if (store == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站"); + } + task.setRegionId(store.getRegionId()); + task.setRegionName(store.getRegionName()); + task.setMerStoreId(store.getId()); + task.setMerStoreKey(store.getStoreKey()); + task.setMerStoreName(store.getStoreName()); + task.setMerStoreAddress(store.getAddress()); + } + + // 查询油品 + SecDictionary oil = commonService.mappingSysCode("GAS_OIL_TYPE", task.getOilNo().toString()); + if (oil == null) { + log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + task.setOilType(Integer.parseInt(oil.getExt1())); + task.setOilTypeName(oil.getExt2()); + task.setOilNoName(oil.getCodeName()); + task.setOpUserId(userInfoModel.getSecUser().getId()); + task.setOpUserName(userInfoModel.getSecUser().getUserName()); + } + + gasOilPriceTaskService.batchAddTask(taskList); + return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { @@ -91,6 +181,7 @@ public class HighGasOilPriceTaskController { public ResponseData getTaskList(@RequestParam(name = "regionId", required = false) Integer regionId, @RequestParam(name = "regionName", required = false) String regionName, @RequestParam(name = "merStoreId", required = false) Integer merStoreId, + @RequestParam(name = "merStoreKey", required = false) String merStoreKey, @RequestParam(name = "merStoreName", required = false) String merStoreName, @RequestParam(name = "oilType", required = false) Integer oilType, @RequestParam(name = "oilNo", required = false) Integer oilNo, @@ -100,10 +191,31 @@ public class HighGasOilPriceTaskController { @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + log.error("HighGasController -> disabledOil() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + Map param = new HashMap<>(); param.put("regionId", regionId); param.put("regionName", regionName); - param.put("status", status); + param.put("merStoreId", merStoreId); + param.put("merStoreKey", merStoreKey); + param.put("merStoreName", merStoreName); + + if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type0.getType())) { + + } else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type1.getType())) { + param.put("regionId", userInfoModel.getBsCompany().getRegionId()); + + } else if (userInfoModel.getSecUser().getObjectType().equals(UserObjectTypeEnum.type3.getType())) { + param.put("merStoreId", userInfoModel.getMerchantStore().getId()); + } + param.put("oilType", oilType); + param.put("oilNo", oilNo); + param.put("priceType", priceType); + param.put("executionType", executionType); param.put("status", status); PageHelper.startPage(pageNum,pageSize); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerAmountController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerAmountController.java new file mode 100644 index 00000000..34a4231a --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerAmountController.java @@ -0,0 +1,82 @@ +package com.bweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighMerchantStoreAccount; +import com.hai.enum_type.MerStoreAmountSourceTypeEnum; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighCompanyTwoPwdService; +import com.hai.service.HighMerchantAccountService; +import com.hai.service.HighMerchantStoreAccountRecordService; +import com.hai.service.HighMerchantStoreAccountService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DeadlockLoserDataAccessException; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/merAccount") +@Api(value = "商户门店接口") +public class HighMerAmountController { + + private static Logger log = LoggerFactory.getLogger(HighMerAmountController.class); + + @Resource + private HighMerchantAccountService merchantAccountService; + + @Resource + private UserCenter userCenter; + + @RequestMapping(value = "/recharge", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "余额充值") + public synchronized ResponseData recharge(@RequestBody JSONObject body) { + try { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + if (userInfoModel.getBsCompany() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + if (body.getLong("merId") == null || body.getBigDecimal("amount") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + if (body.getBigDecimal("amount").compareTo(new BigDecimal("0")) == -1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "充值金额不能小于0"); + } + Map map = new HashMap<>(); + map.put("sourceType", MerStoreAmountSourceTypeEnum.type1.getType()); + map.put("sourceContent", "充值额度:" + body.getBigDecimal("amount") + " 元"); + map.put("opUserId", userInfoModel.getSecUser().getId()); + map.put("opUserName", userInfoModel.getSecUser().getUserName()); + merchantAccountService.recharge(body.getLong("merId"), body.getBigDecimal("amount"), map); + + return ResponseMsgUtil.success("操作成功"); + + } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { + log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); + return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null); + + } catch (Exception e) { + log.error("HighCompanyAmountController --> recharge() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java index aecbfd76..67565426 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java @@ -101,7 +101,6 @@ public class HighMerchantController { } } - @RequestMapping(value="/updateMerchant",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "修改商户") diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java index 5896070e..66b4ad97 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java @@ -208,14 +208,25 @@ public class HighMerchantStoreController { log.error("BsStudentController --> addStudent() error!", "未找到门店信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); } + BsCompany company = bsCompanyService.getCompanyById(store.getCompanyId()); + if (company == null) { + log.error("HighMerchantStoreController -> insertMerchantStore() error!","未找到分公司"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); + } + Map regionMap = commonService.getParentInfoByRegionId(highMerchantStore.getRegionId()); - // 如果是重庆市的区县,使用重庆市的区域代码 - if (regionMap.get("region").getRegionId().intValue() == 500100) { - store.setRegionId(regionMap.get("region").getParentId()); - store.setRegionName(regionMap.get("region").getRegionName()); + if (highMerchantStore.getType() != null && highMerchantStore.getType().equals(1)) { + highMerchantStore.setRegionId(Long.parseLong(company.getRegionId())); + highMerchantStore.setRegionName(commonService.getRegionName(Long.parseLong(company.getRegionId()))); } else { - store.setRegionId(regionMap.get("region").getRegionId()); - store.setRegionName(regionMap.get("region").getRegionName()); + // 如果是重庆市的区县,使用重庆市的区域代码 + if (regionMap.get("region").getRegionId().intValue() == 500100) { + highMerchantStore.setRegionId(regionMap.get("region").getParentId()); + highMerchantStore.setRegionName(regionMap.get("region").getRegionName()); + } else { + highMerchantStore.setRegionId(regionMap.get("region").getRegionId()); + highMerchantStore.setRegionName(regionMap.get("region").getRegionName()); + } } if (highMerchantStore.getBrandId() != null) { diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index 244d40bd..9eee8d96 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ -package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private SecSinopecConfigService secSinopecConfigService; @Resource private HighCouponCodeService highCouponCodeService; @Resource private HighOilCardService oilCardService; @Resource private GoodsOrderServiceImpl goodsOrderService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分账") public ResponseData wxProfitsharing(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); BigDecimal rake = new BigDecimal("0.01"); // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部 param.put("transaction_id" , order.getPaySerialNo()); param.put("out_order_no" , order.getOrderNo()); param.put("nonce_str" , WxUtils.makeNonStr()); // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.profitsharing(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(porofitSharingAmount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); return ResponseMsgUtil.success(e); } } public String profitsharing(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sys", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "同步") public ResponseData sys(@RequestParam(name = "appId", required = true) String appId, @RequestParam(name = "appSecret", required = true) String appSecret, @RequestParam(name = "code", required = true) String code, @RequestParam(name = "signKey", required = true) String signKey ) { try { Map tokenMap = new HashMap<>(); tokenMap.put("appId", appId); tokenMap.put("appSecret", appSecret); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); log.error(jsonObject.toJSONString()); if (jsonObject != null && jsonObject.getBoolean("success") == true) { JSONObject data = jsonObject.getJSONObject("data"); String token = data.getString("token"); Calendar instance = Calendar.getInstance(); instance.set(2021,3,1); Map bodyMap = new HashMap<>(); bodyMap.put("appId", appId); bodyMap.put("pageNo", 1); bodyMap.put("pageSize", 999999); bodyMap.put("startTime", instance.getTime()); bodyMap.put("endTime", new Date().getTime()); bodyMap.put("customerCode", code); Long date = new Date().getTime(); String sha256 = encodeBySHA256(signKey + JSON.toJSONString(bodyMap) + date); JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); File file = new File("/home/data/" + System.currentTimeMillis() + ".txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(object.toJSONString()); bw.close(); //JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}"); if(Objects.equals(object.get("success"), true)) { log.error(JSONObject.toJSONString(object.get("data"))); Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data"))); JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson)); JSONArray list = dataObject.getJSONArray("list"); for (Object dataJsonObject : list) { try { JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject)); String codeId = parseObject.getString("codeId"); String nodeName = parseObject.getString("nodeName"); Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss"); highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime, nodeName); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } } return ResponseMsgUtil.success("下载成功"); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String encodeBySHA256(String str) { try{ MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.reset(); messageDigest.update(str.getBytes("UTF-8")); return getFormattedText(messageDigest.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (Exception e) { throw new RuntimeException(e); } return ""; } private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; private String getFormattedText(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); // 把密文转换成十六进制的字符串形式 for (int j=0;j> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); } return buf.toString(); } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/zwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联退款") public ResponseData zwrefund( @RequestParam(name = "orderId", required = true) Long orderId , @RequestParam(name = "MER_ID", required = true) String MER_ID , @RequestParam(name = "TERM_ID", required = true) String TERM_ID , HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 订单退款 JSONObject refund = UnionPayConfig.zwrefund(MER_ID, TERM_ID, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (!refund.getString("resultcode").equals("W6")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } // order.setStatus(5); order.setRefundTime(new Date()); order.setOutRefundNo(refund.getString("oriwtorderid")); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(refund); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket( @RequestParam(name = "userId", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://139.159.177.244:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("请求成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getProductsList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取产品") public ResponseData getProductsList() { try { return ResponseMsgUtil.success(RechargeConfig.getProductsListByLy()); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.google.gson.JsonObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.security.KeyStore; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private SecSinopecConfigService secSinopecConfigService; @Resource private HighCouponCodeService highCouponCodeService; @Resource private HighOilCardService oilCardService; @Resource private GoodsOrderServiceImpl goodsOrderService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private HighGasOilPriceOfficialService gasOilPriceOfficialService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refreshGasPriceOfficial", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "刷新国标价") public ResponseData refreshGasPriceOfficial() { try { gasOilPriceOfficialService.refreshPriceOfficial(); gasOilPriceOfficialService.refreshGasPriceOfficial(null, null); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分账") public ResponseData wxProfitsharing(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); BigDecimal rake = new BigDecimal("0.01"); // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN); BigDecimal price = order.getPayPrice().subtract(wxHandlingFee); Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1624126902"); // 渝北区浩联物资经营部 param.put("transaction_id" , order.getPaySerialNo()); param.put("out_order_no" , order.getOrderNo()); param.put("nonce_str" , WxUtils.makeNonStr()); // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。 BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN); List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.profitsharing(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(porofitSharingAmount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); return ResponseMsgUtil.success(e); } } public String profitsharing(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sys", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "同步") public ResponseData sys(@RequestParam(name = "appId", required = true) String appId, @RequestParam(name = "appSecret", required = true) String appSecret, @RequestParam(name = "code", required = true) String code, @RequestParam(name = "signKey", required = true) String signKey ) { try { Map tokenMap = new HashMap<>(); tokenMap.put("appId", appId); tokenMap.put("appSecret", appSecret); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); log.error(jsonObject.toJSONString()); if (jsonObject != null && jsonObject.getBoolean("success") == true) { JSONObject data = jsonObject.getJSONObject("data"); String token = data.getString("token"); Calendar instance = Calendar.getInstance(); instance.set(2021,3,1); Map bodyMap = new HashMap<>(); bodyMap.put("appId", appId); bodyMap.put("pageNo", 1); bodyMap.put("pageSize", 999999); bodyMap.put("startTime", instance.getTime()); bodyMap.put("endTime", new Date().getTime()); bodyMap.put("customerCode", code); Long date = new Date().getTime(); String sha256 = encodeBySHA256(signKey + JSON.toJSONString(bodyMap) + date); JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); File file = new File("/home/data/" + System.currentTimeMillis() + ".txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(object.toJSONString()); bw.close(); //JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}"); if(Objects.equals(object.get("success"), true)) { log.error(JSONObject.toJSONString(object.get("data"))); Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data"))); JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson)); JSONArray list = dataObject.getJSONArray("list"); for (Object dataJsonObject : list) { try { JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject)); String codeId = parseObject.getString("codeId"); String nodeName = parseObject.getString("nodeName"); Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss"); highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime, nodeName); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } } return ResponseMsgUtil.success("下载成功"); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String encodeBySHA256(String str) { try{ MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.reset(); messageDigest.update(str.getBytes("UTF-8")); return getFormattedText(messageDigest.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (Exception e) { throw new RuntimeException(e); } return ""; } private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; private String getFormattedText(byte[] bytes) { int len = bytes.length; StringBuilder buf = new StringBuilder(len * 2); // 把密文转换成十六进制的字符串形式 for (int j=0;j> 4) & 0x0f]); buf.append(HEX_DIGITS[bytes[j] & 0x0f]); } return buf.toString(); } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getReadFile",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "存入用户信息") public ResponseData getReadFile() { try { highTestService.getReadFile(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/zwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联退款") public ResponseData zwrefund( @RequestParam(name = "orderId", required = true) Long orderId , @RequestParam(name = "MER_ID", required = true) String MER_ID , @RequestParam(name = "TERM_ID", required = true) String TERM_ID , HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 订单退款 JSONObject refund = UnionPayConfig.zwrefund(MER_ID, TERM_ID, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (!refund.getString("resultcode").equals("W6")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } order.setStatus(5); order.setRefundTime(new Date()); order.setOutRefundNo(refund.getString("oriwtorderid")); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(refund); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取定位信息") public ResponseData findByLatAndLng( @RequestParam(name = "lng", required = true) String lng, @RequestParam(name = "lat", required = true) String lat ) { try { return ResponseMsgUtil.success(highTestService.findByLatAndLng(lng , lat)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket( @RequestParam(name = "userId", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://139.159.177.244:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("请求成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index c2d28294..cdbceca9 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -112,32 +112,72 @@ public class HighGasController { PageInfo> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance)); for (Map map : mapPageInfo.getList()) { if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) { - // 查询是否配置了【油站的】优惠比例 - HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); - if (tyAgentPrice != null) { - // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); - } else { - // 查询是否配置了【油品】优惠比例 - HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no")); - if (gasDiscountOilPrice != null) { + + if (MapUtils.getInteger(map, "source_type").equals(1)) { + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); + if (tyAgentPrice != null) { // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin"))); + // (油枪价 - 优惠幅度) * 系统折扣 + map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no")); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin"))); + // (油枪价 - 优惠幅度) * 系统折扣 + map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } } - } - // 查询是否配置了【代理商】优惠比例 - if (isTyAgent != null && isTyAgent == true) { - HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); - if (agentPrice != null) { + // 查询是否配置了【代理商】优惠比例 + if (isTyAgent != null && isTyAgent == true) { + HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); + if (agentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = new BigDecimal(MapUtils.getString(map, "price_gun")).subtract(new BigDecimal(MapUtils.getString(map, "preferential_margin"))); + // (油枪价 - 优惠幅度) * 系统折扣 + map.put("price_vip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + + } else if (MapUtils.getInteger(map, "source_type").equals(2)) { + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); + if (tyAgentPrice != null) { // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); // 油品国标价 * 最终优惠比例 map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no")); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + + // 查询是否配置了【代理商】优惠比例 + if (isTyAgent != null && isTyAgent == true) { + HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); + if (agentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_gun")).multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } } } } @@ -271,6 +311,43 @@ public class HighGasController { oilPriceMap.put("priceVip", oilPrice.getPriceVip()); oilPriceMap.put("priceGun", oilPrice.getPriceGun()); oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial()); + + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), oilPrice.getOilNo().toString()); + if (tyAgentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(oilPrice.getOilNo().toString()); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + + // 查询是否配置了【代理商】优惠比例 + if (isTyAgent != null && isTyAgent == true) { + HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), oilPrice.getOilNo().toString()); + if (agentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + oilPriceMapList.add(oilPriceMap); } param.put("oilPriceList", oilPriceMapList); @@ -418,6 +495,43 @@ public class HighGasController { oilPriceMap.put("priceVip", oilPrice.getPriceVip()); oilPriceMap.put("priceGun", oilPrice.getPriceGun()); oilPriceMap.put("priceOfficial", oilPrice.getPriceOfficial()); + + // 查询是否配置了【油站的】优惠比例 + HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), oilPrice.getOilNo().toString()); + if (tyAgentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + + } else { + // 查询是否配置了【油品】优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(oilPrice.getOilNo().toString()); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + + // 查询是否配置了【代理商】优惠比例 + if (isTyAgent != null && isTyAgent == true) { + HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), oilPrice.getOilNo().toString()); + if (agentPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油枪价 - 优惠幅度 + BigDecimal price = oilPrice.getPriceGun().subtract(oilPrice.getPreferentialMargin()); + // (油枪价 - 优惠幅度) * 系统折扣 + oilPriceMap.put("priceVip", price.multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + oilPriceMapList.add(oilPriceMap); } param.put("oilPriceList", oilPriceMapList); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index e80f130c..2210cdb1 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -55,6 +55,9 @@ public class HighOrderController { @Autowired private UserCenter userCenter; + @Resource + private CommonService commonService; + @Resource private HighOrderService highOrderService; @@ -220,8 +223,18 @@ public class HighOrderController { log.error("HighOrderController --> addOrder() error!", "参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - if (childOrder.getGoodsPrice().compareTo(new BigDecimal("800")) == 1){ - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油金额不能超过800元"); + + // 加油限制 + if (childOrder.getGasOilType().equals(1)) { + SecDictionary refuelLimit = commonService.mappingSysName("REFUEL_LIMIT", "汽油"); + if (refuelLimit != null && childOrder.getGoodsPrice().compareTo(new BigDecimal(refuelLimit.getCodeValue())) == 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "汽油加油金额不能超过" + refuelLimit.getCodeValue()+"元"); + } + } else if (childOrder.getGasOilType().equals(2)){ + SecDictionary refuelLimit = commonService.mappingSysName("REFUEL_LIMIT", "柴油"); + if (refuelLimit != null && childOrder.getGoodsPrice().compareTo(new BigDecimal(refuelLimit.getCodeValue())) == 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "柴油加油金额不能超过" + refuelLimit.getCodeValue()+"元"); + } } if (highOrderService.getGasTheDayOrderNum(userInfoModel.getHighUser().getId()) >= 1) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java index 42e6a085..1de9a2aa 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java @@ -151,7 +151,7 @@ public class HighGasSchedule { } } - @Scheduled(cron = "0 1 7 * * ?") //每日7点1分执行一次 + @Scheduled(cron = "0 30 7 * * ?") //每日7点1分执行一次 public void refreshPriceOfficial() throws Exception { gasOilPriceOfficialService.refreshPriceOfficial(); diff --git a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java index 72f6bc61..09d9f1a4 100644 --- a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java +++ b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java @@ -34,6 +34,19 @@ public class DateUtil { public static final String Y_M = "yyyy-MM"; private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + //计算两个时间相差的秒数 + public static long getSecondDiff(Date startTime, Date endTime) { + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + long eTime = endTime.getTime(); + long sTime = startTime.getTime(); + long diff = (eTime - sTime) / 1000; + return diff; + } catch (Exception e) { + log.error("getSecondDiff error", e); + } + return 0; + } public static Integer getThisYear(){ Calendar calendar = Calendar.getInstance(); @@ -765,9 +778,11 @@ public class DateUtil { public static void main(String[] args) throws Exception { String a = "51130319931105651X"; - System.out.println(a.substring(6,10)); - System.out.println(a.substring(10,12)); - System.out.println(a.substring(12,14)); + + + Date date = new Date(); + date.setTime(1653979200000L); + System.out.println(getSecondDiff(new Date(), date)); } } diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java index e4cd226c..c1aa28b9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java @@ -22,6 +22,7 @@ public interface HighGasOilPriceMapperExt { " a.price_gun," + " a.price_vip," + " a.price_official," + + " a.preferential_margin," + " b.* " + " FROM" + " high_gas_oil_price a," + diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskMapper.java index 3db09123..d10678e9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskMapper.java @@ -40,25 +40,27 @@ public interface HighGasOilPriceTaskMapper extends HighGasOilPriceTaskMapperExt @Insert({ "insert into high_gas_oil_price_task (region_id, region_name, ", - "mer_store_id, mer_store_name, ", - "mer_store_address, oil_type, ", - "oil_type_name, oil_no, ", - "oil_no_name, price_type, ", - "price, execution_type, ", - "start_time, `status`, ", - "create_time, update_time, ", - "op_user_id, op_user_name, ", - "ext_1, ext_2, ext_3)", + "mer_store_key, mer_store_id, ", + "mer_store_name, mer_store_address, ", + "oil_type, oil_type_name, ", + "oil_no, oil_no_name, ", + "price_type, price, ", + "execution_type, start_time, ", + "`status`, create_time, ", + "update_time, op_user_id, ", + "op_user_name, ext_1, ", + "ext_2, ext_3)", "values (#{regionId,jdbcType=BIGINT}, #{regionName,jdbcType=VARCHAR}, ", - "#{merStoreId,jdbcType=BIGINT}, #{merStoreName,jdbcType=VARCHAR}, ", - "#{merStoreAddress,jdbcType=VARCHAR}, #{oilType,jdbcType=INTEGER}, ", - "#{oilTypeName,jdbcType=VARCHAR}, #{oilNo,jdbcType=INTEGER}, ", - "#{oilNoName,jdbcType=VARCHAR}, #{priceType,jdbcType=INTEGER}, ", - "#{price,jdbcType=DECIMAL}, #{executionType,jdbcType=INTEGER}, ", - "#{startTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{opUserId,jdbcType=BIGINT}, #{opUserName,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{merStoreKey,jdbcType=VARCHAR}, #{merStoreId,jdbcType=BIGINT}, ", + "#{merStoreName,jdbcType=VARCHAR}, #{merStoreAddress,jdbcType=VARCHAR}, ", + "#{oilType,jdbcType=INTEGER}, #{oilTypeName,jdbcType=VARCHAR}, ", + "#{oilNo,jdbcType=INTEGER}, #{oilNoName,jdbcType=VARCHAR}, ", + "#{priceType,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, ", + "#{executionType,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, ", + "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{opUserId,jdbcType=BIGINT}, ", + "#{opUserName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGasOilPriceTask record); @@ -72,6 +74,7 @@ public interface HighGasOilPriceTaskMapper extends HighGasOilPriceTaskMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="region_id", property="regionId", jdbcType=JdbcType.BIGINT), @Result(column="region_name", property="regionName", jdbcType=JdbcType.VARCHAR), + @Result(column="mer_store_key", property="merStoreKey", jdbcType=JdbcType.VARCHAR), @Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT), @Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR), @Result(column="mer_store_address", property="merStoreAddress", jdbcType=JdbcType.VARCHAR), @@ -96,7 +99,7 @@ public interface HighGasOilPriceTaskMapper extends HighGasOilPriceTaskMapperExt @Select({ "select", - "id, region_id, region_name, mer_store_id, mer_store_name, mer_store_address, ", + "id, region_id, region_name, mer_store_key, mer_store_id, mer_store_name, mer_store_address, ", "oil_type, oil_type_name, oil_no, oil_no_name, price_type, price, execution_type, ", "start_time, `status`, create_time, update_time, op_user_id, op_user_name, ext_1, ", "ext_2, ext_3", @@ -107,6 +110,7 @@ public interface HighGasOilPriceTaskMapper extends HighGasOilPriceTaskMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="region_id", property="regionId", jdbcType=JdbcType.BIGINT), @Result(column="region_name", property="regionName", jdbcType=JdbcType.VARCHAR), + @Result(column="mer_store_key", property="merStoreKey", jdbcType=JdbcType.VARCHAR), @Result(column="mer_store_id", property="merStoreId", jdbcType=JdbcType.BIGINT), @Result(column="mer_store_name", property="merStoreName", jdbcType=JdbcType.VARCHAR), @Result(column="mer_store_address", property="merStoreAddress", jdbcType=JdbcType.VARCHAR), @@ -142,6 +146,7 @@ public interface HighGasOilPriceTaskMapper extends HighGasOilPriceTaskMapperExt "update high_gas_oil_price_task", "set region_id = #{regionId,jdbcType=BIGINT},", "region_name = #{regionName,jdbcType=VARCHAR},", + "mer_store_key = #{merStoreKey,jdbcType=VARCHAR},", "mer_store_id = #{merStoreId,jdbcType=BIGINT},", "mer_store_name = #{merStoreName,jdbcType=VARCHAR},", "mer_store_address = #{merStoreAddress,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskSqlProvider.java index fa514857..81386790 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceTaskSqlProvider.java @@ -36,6 +36,10 @@ public class HighGasOilPriceTaskSqlProvider { sql.VALUES("region_name", "#{regionName,jdbcType=VARCHAR}"); } + if (record.getMerStoreKey() != null) { + sql.VALUES("mer_store_key", "#{merStoreKey,jdbcType=VARCHAR}"); + } + if (record.getMerStoreId() != null) { sql.VALUES("mer_store_id", "#{merStoreId,jdbcType=BIGINT}"); } @@ -124,6 +128,7 @@ public class HighGasOilPriceTaskSqlProvider { } sql.SELECT("region_id"); sql.SELECT("region_name"); + sql.SELECT("mer_store_key"); sql.SELECT("mer_store_id"); sql.SELECT("mer_store_name"); sql.SELECT("mer_store_address"); @@ -172,6 +177,10 @@ public class HighGasOilPriceTaskSqlProvider { sql.SET("region_name = #{record.regionName,jdbcType=VARCHAR}"); } + if (record.getMerStoreKey() != null) { + sql.SET("mer_store_key = #{record.merStoreKey,jdbcType=VARCHAR}"); + } + if (record.getMerStoreId() != null) { sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}"); } @@ -259,6 +268,7 @@ public class HighGasOilPriceTaskSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("region_id = #{record.regionId,jdbcType=BIGINT}"); sql.SET("region_name = #{record.regionName,jdbcType=VARCHAR}"); + sql.SET("mer_store_key = #{record.merStoreKey,jdbcType=VARCHAR}"); sql.SET("mer_store_id = #{record.merStoreId,jdbcType=BIGINT}"); sql.SET("mer_store_name = #{record.merStoreName,jdbcType=VARCHAR}"); sql.SET("mer_store_address = #{record.merStoreAddress,jdbcType=VARCHAR}"); @@ -296,6 +306,10 @@ public class HighGasOilPriceTaskSqlProvider { sql.SET("region_name = #{regionName,jdbcType=VARCHAR}"); } + if (record.getMerStoreKey() != null) { + sql.SET("mer_store_key = #{merStoreKey,jdbcType=VARCHAR}"); + } + if (record.getMerStoreId() != null) { sql.SET("mer_store_id = #{merStoreId,jdbcType=BIGINT}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapper.java b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapper.java new file mode 100644 index 00000000..4d2f0b68 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapper.java @@ -0,0 +1,122 @@ +package com.hai.dao; + +import com.hai.entity.HighMerchantAccount; +import com.hai.entity.HighMerchantAccountExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface HighMerchantAccountMapper extends HighMerchantAccountMapperExt { + @SelectProvider(type=HighMerchantAccountSqlProvider.class, method="countByExample") + long countByExample(HighMerchantAccountExample example); + + @DeleteProvider(type=HighMerchantAccountSqlProvider.class, method="deleteByExample") + int deleteByExample(HighMerchantAccountExample example); + + @Delete({ + "delete from high_merchant_account", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into high_merchant_account (mer_id, mer_name, ", + "account_no, amounts, ", + "`status`, create_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", + "values (#{merId,jdbcType=BIGINT}, #{merName,jdbcType=VARCHAR}, ", + "#{accountNo,jdbcType=VARCHAR}, #{amounts,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(HighMerchantAccount record); + + @InsertProvider(type=HighMerchantAccountSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(HighMerchantAccount record); + + @SelectProvider(type=HighMerchantAccountSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), + @Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), + @Result(column="account_no", property="accountNo", jdbcType=JdbcType.VARCHAR), + @Result(column="amounts", property="amounts", jdbcType=JdbcType.DECIMAL), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectByExample(HighMerchantAccountExample example); + + @Select({ + "select", + "id, mer_id, mer_name, account_no, amounts, `status`, create_time, update_time, ", + "ext_1, ext_2, ext_3", + "from high_merchant_account", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), + @Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), + @Result(column="account_no", property="accountNo", jdbcType=JdbcType.VARCHAR), + @Result(column="amounts", property="amounts", jdbcType=JdbcType.DECIMAL), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + HighMerchantAccount selectByPrimaryKey(Long id); + + @UpdateProvider(type=HighMerchantAccountSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") HighMerchantAccount record, @Param("example") HighMerchantAccountExample example); + + @UpdateProvider(type=HighMerchantAccountSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") HighMerchantAccount record, @Param("example") HighMerchantAccountExample example); + + @UpdateProvider(type=HighMerchantAccountSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighMerchantAccount record); + + @Update({ + "update high_merchant_account", + "set mer_id = #{merId,jdbcType=BIGINT},", + "mer_name = #{merName,jdbcType=VARCHAR},", + "account_no = #{accountNo,jdbcType=VARCHAR},", + "amounts = #{amounts,jdbcType=DECIMAL},", + "`status` = #{status,jdbcType=INTEGER},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "update_time = #{updateTime,jdbcType=TIMESTAMP},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(HighMerchantAccount record); +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java new file mode 100644 index 00000000..5eda9554 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java @@ -0,0 +1,38 @@ +package com.hai.dao; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * mapper扩展类 + */ +public interface HighMerchantAccountMapperExt { + + + @Select({"select " + + " case when sum(b.total_price) is not null then sum(b.total_price) ELSE 0 end " + + " from high_child_order a, high_order b" + + " where goods_type = 3 " + + " and a.order_id = b.id" + + " and goods_id in (SELECT id from high_merchant_store where merchant_id = #{merId}) " + + " and b.order_status in (2,3,6,7)"}) + BigDecimal countMerGasOilAmount(@Param("merId") Long merId); + + @Select({ + " SELECT ms.id, ms.store_name, ms.address," + + " (select " + + " case when sum(b.total_price) is not null then sum(b.total_price) else 0 end" + + " from high_child_order a, high_order b" + + " where a.order_id = b.id" + + " and goods_type = 3" + + " and goods_id = ms.id" + + " and b.order_status in (2,3,6,7)) countPrice" + + " from high_merchant_store ms where ms.merchant_id = #{merId}" + + " ORDER BY countPrice desc" + }) + List> selectStoreGasOilAmountByMer(@Param("merId") Long merId); +} diff --git a/hai-service/src/main/java/com/hai/dao/HighMerchantAccountSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountSqlProvider.java new file mode 100644 index 00000000..b847aea5 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountSqlProvider.java @@ -0,0 +1,318 @@ +package com.hai.dao; + +import com.hai.entity.HighMerchantAccount; +import com.hai.entity.HighMerchantAccountExample.Criteria; +import com.hai.entity.HighMerchantAccountExample.Criterion; +import com.hai.entity.HighMerchantAccountExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class HighMerchantAccountSqlProvider { + + public String countByExample(HighMerchantAccountExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("high_merchant_account"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(HighMerchantAccountExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("high_merchant_account"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(HighMerchantAccount record) { + SQL sql = new SQL(); + sql.INSERT_INTO("high_merchant_account"); + + if (record.getMerId() != null) { + sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}"); + } + + if (record.getMerName() != null) { + sql.VALUES("mer_name", "#{merName,jdbcType=VARCHAR}"); + } + + if (record.getAccountNo() != null) { + sql.VALUES("account_no", "#{accountNo,jdbcType=VARCHAR}"); + } + + if (record.getAmounts() != null) { + sql.VALUES("amounts", "#{amounts,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(HighMerchantAccountExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("mer_id"); + sql.SELECT("mer_name"); + sql.SELECT("account_no"); + sql.SELECT("amounts"); + sql.SELECT("`status`"); + sql.SELECT("create_time"); + sql.SELECT("update_time"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("high_merchant_account"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + HighMerchantAccount record = (HighMerchantAccount) parameter.get("record"); + HighMerchantAccountExample example = (HighMerchantAccountExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("high_merchant_account"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getMerId() != null) { + sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); + } + + if (record.getMerName() != null) { + sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); + } + + if (record.getAccountNo() != null) { + sql.SET("account_no = #{record.accountNo,jdbcType=VARCHAR}"); + } + + if (record.getAmounts() != null) { + sql.SET("amounts = #{record.amounts,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("high_merchant_account"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); + sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); + sql.SET("account_no = #{record.accountNo,jdbcType=VARCHAR}"); + sql.SET("amounts = #{record.amounts,jdbcType=DECIMAL}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + HighMerchantAccountExample example = (HighMerchantAccountExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(HighMerchantAccount record) { + SQL sql = new SQL(); + sql.UPDATE("high_merchant_account"); + + if (record.getMerId() != null) { + sql.SET("mer_id = #{merId,jdbcType=BIGINT}"); + } + + if (record.getMerName() != null) { + sql.SET("mer_name = #{merName,jdbcType=VARCHAR}"); + } + + if (record.getAccountNo() != null) { + sql.SET("account_no = #{accountNo,jdbcType=VARCHAR}"); + } + + if (record.getAmounts() != null) { + sql.SET("amounts = #{amounts,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, HighMerchantAccountExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTask.java b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTask.java index b4a50850..d1f65131 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTask.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTask.java @@ -29,6 +29,11 @@ public class HighGasOilPriceTask implements Serializable { */ private String regionName; + /** + * 加油站编号 + */ + private String merStoreKey; + /** * 加油站id */ @@ -75,7 +80,7 @@ public class HighGasOilPriceTask implements Serializable { private BigDecimal price; /** - * 执行类型 1. 立刻执行 2. 定时执行 + * 执行方式 1. 立刻执行 2. 定时执行 */ private Integer executionType; @@ -141,6 +146,14 @@ public class HighGasOilPriceTask implements Serializable { this.regionName = regionName; } + public String getMerStoreKey() { + return merStoreKey; + } + + public void setMerStoreKey(String merStoreKey) { + this.merStoreKey = merStoreKey; + } + public Long getMerStoreId() { return merStoreId; } @@ -308,6 +321,7 @@ public class HighGasOilPriceTask implements Serializable { return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getRegionId() == null ? other.getRegionId() == null : this.getRegionId().equals(other.getRegionId())) && (this.getRegionName() == null ? other.getRegionName() == null : this.getRegionName().equals(other.getRegionName())) + && (this.getMerStoreKey() == null ? other.getMerStoreKey() == null : this.getMerStoreKey().equals(other.getMerStoreKey())) && (this.getMerStoreId() == null ? other.getMerStoreId() == null : this.getMerStoreId().equals(other.getMerStoreId())) && (this.getMerStoreName() == null ? other.getMerStoreName() == null : this.getMerStoreName().equals(other.getMerStoreName())) && (this.getMerStoreAddress() == null ? other.getMerStoreAddress() == null : this.getMerStoreAddress().equals(other.getMerStoreAddress())) @@ -336,6 +350,7 @@ public class HighGasOilPriceTask implements Serializable { result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getRegionId() == null) ? 0 : getRegionId().hashCode()); result = prime * result + ((getRegionName() == null) ? 0 : getRegionName().hashCode()); + result = prime * result + ((getMerStoreKey() == null) ? 0 : getMerStoreKey().hashCode()); result = prime * result + ((getMerStoreId() == null) ? 0 : getMerStoreId().hashCode()); result = prime * result + ((getMerStoreName() == null) ? 0 : getMerStoreName().hashCode()); result = prime * result + ((getMerStoreAddress() == null) ? 0 : getMerStoreAddress().hashCode()); @@ -367,6 +382,7 @@ public class HighGasOilPriceTask implements Serializable { sb.append(", id=").append(id); sb.append(", regionId=").append(regionId); sb.append(", regionName=").append(regionName); + sb.append(", merStoreKey=").append(merStoreKey); sb.append(", merStoreId=").append(merStoreId); sb.append(", merStoreName=").append(merStoreName); sb.append(", merStoreAddress=").append(merStoreAddress); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTaskExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTaskExample.java index 601a1183..4527ab1a 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTaskExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOilPriceTaskExample.java @@ -316,6 +316,76 @@ public class HighGasOilPriceTaskExample { return (Criteria) this; } + public Criteria andMerStoreKeyIsNull() { + addCriterion("mer_store_key is null"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyIsNotNull() { + addCriterion("mer_store_key is not null"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyEqualTo(String value) { + addCriterion("mer_store_key =", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyNotEqualTo(String value) { + addCriterion("mer_store_key <>", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyGreaterThan(String value) { + addCriterion("mer_store_key >", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyGreaterThanOrEqualTo(String value) { + addCriterion("mer_store_key >=", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyLessThan(String value) { + addCriterion("mer_store_key <", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyLessThanOrEqualTo(String value) { + addCriterion("mer_store_key <=", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyLike(String value) { + addCriterion("mer_store_key like", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyNotLike(String value) { + addCriterion("mer_store_key not like", value, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyIn(List values) { + addCriterion("mer_store_key in", values, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyNotIn(List values) { + addCriterion("mer_store_key not in", values, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyBetween(String value1, String value2) { + addCriterion("mer_store_key between", value1, value2, "merStoreKey"); + return (Criteria) this; + } + + public Criteria andMerStoreKeyNotBetween(String value1, String value2) { + addCriterion("mer_store_key not between", value1, value2, "merStoreKey"); + return (Criteria) this; + } + public Criteria andMerStoreIdIsNull() { addCriterion("mer_store_id is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighMerchantAccount.java b/hai-service/src/main/java/com/hai/entity/HighMerchantAccount.java new file mode 100644 index 00000000..dc072b83 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighMerchantAccount.java @@ -0,0 +1,214 @@ +package com.hai.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * high_merchant_account + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class HighMerchantAccount implements Serializable { + private Long id; + + /** + * 商户id + */ + private Long merId; + + /** + * 商户名称 + */ + private String merName; + + /** + * 账户号码 + */ + private String accountNo; + + /** + * 账户余额 + */ + private BigDecimal amounts; + + /** + * 状态 0:删除 1:正常 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; + + private String ext1; + + private String ext2; + + private String ext3; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getMerId() { + return merId; + } + + public void setMerId(Long merId) { + this.merId = merId; + } + + public String getMerName() { + return merName; + } + + public void setMerName(String merName) { + this.merName = merName; + } + + public String getAccountNo() { + return accountNo; + } + + public void setAccountNo(String accountNo) { + this.accountNo = accountNo; + } + + public BigDecimal getAmounts() { + return amounts; + } + + public void setAmounts(BigDecimal amounts) { + this.amounts = amounts; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + HighMerchantAccount other = (HighMerchantAccount) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId())) + && (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName())) + && (this.getAccountNo() == null ? other.getAccountNo() == null : this.getAccountNo().equals(other.getAccountNo())) + && (this.getAmounts() == null ? other.getAmounts() == null : this.getAmounts().equals(other.getAmounts())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode()); + result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode()); + result = prime * result + ((getAccountNo() == null) ? 0 : getAccountNo().hashCode()); + result = prime * result + ((getAmounts() == null) ? 0 : getAmounts().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", merId=").append(merId); + sb.append(", merName=").append(merName); + sb.append(", accountNo=").append(accountNo); + sb.append(", amounts=").append(amounts); + sb.append(", status=").append(status); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighMerchantAccountExample.java b/hai-service/src/main/java/com/hai/entity/HighMerchantAccountExample.java new file mode 100644 index 00000000..2a1d4b4a --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighMerchantAccountExample.java @@ -0,0 +1,934 @@ +package com.hai.entity; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class HighMerchantAccountExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public HighMerchantAccountExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andMerIdIsNull() { + addCriterion("mer_id is null"); + return (Criteria) this; + } + + public Criteria andMerIdIsNotNull() { + addCriterion("mer_id is not null"); + return (Criteria) this; + } + + public Criteria andMerIdEqualTo(Long value) { + addCriterion("mer_id =", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdNotEqualTo(Long value) { + addCriterion("mer_id <>", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdGreaterThan(Long value) { + addCriterion("mer_id >", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdGreaterThanOrEqualTo(Long value) { + addCriterion("mer_id >=", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdLessThan(Long value) { + addCriterion("mer_id <", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdLessThanOrEqualTo(Long value) { + addCriterion("mer_id <=", value, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdIn(List values) { + addCriterion("mer_id in", values, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdNotIn(List values) { + addCriterion("mer_id not in", values, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdBetween(Long value1, Long value2) { + addCriterion("mer_id between", value1, value2, "merId"); + return (Criteria) this; + } + + public Criteria andMerIdNotBetween(Long value1, Long value2) { + addCriterion("mer_id not between", value1, value2, "merId"); + return (Criteria) this; + } + + public Criteria andMerNameIsNull() { + addCriterion("mer_name is null"); + return (Criteria) this; + } + + public Criteria andMerNameIsNotNull() { + addCriterion("mer_name is not null"); + return (Criteria) this; + } + + public Criteria andMerNameEqualTo(String value) { + addCriterion("mer_name =", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameNotEqualTo(String value) { + addCriterion("mer_name <>", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameGreaterThan(String value) { + addCriterion("mer_name >", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameGreaterThanOrEqualTo(String value) { + addCriterion("mer_name >=", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameLessThan(String value) { + addCriterion("mer_name <", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameLessThanOrEqualTo(String value) { + addCriterion("mer_name <=", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameLike(String value) { + addCriterion("mer_name like", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameNotLike(String value) { + addCriterion("mer_name not like", value, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameIn(List values) { + addCriterion("mer_name in", values, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameNotIn(List values) { + addCriterion("mer_name not in", values, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameBetween(String value1, String value2) { + addCriterion("mer_name between", value1, value2, "merName"); + return (Criteria) this; + } + + public Criteria andMerNameNotBetween(String value1, String value2) { + addCriterion("mer_name not between", value1, value2, "merName"); + return (Criteria) this; + } + + public Criteria andAccountNoIsNull() { + addCriterion("account_no is null"); + return (Criteria) this; + } + + public Criteria andAccountNoIsNotNull() { + addCriterion("account_no is not null"); + return (Criteria) this; + } + + public Criteria andAccountNoEqualTo(String value) { + addCriterion("account_no =", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoNotEqualTo(String value) { + addCriterion("account_no <>", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoGreaterThan(String value) { + addCriterion("account_no >", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoGreaterThanOrEqualTo(String value) { + addCriterion("account_no >=", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoLessThan(String value) { + addCriterion("account_no <", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoLessThanOrEqualTo(String value) { + addCriterion("account_no <=", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoLike(String value) { + addCriterion("account_no like", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoNotLike(String value) { + addCriterion("account_no not like", value, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoIn(List values) { + addCriterion("account_no in", values, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoNotIn(List values) { + addCriterion("account_no not in", values, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoBetween(String value1, String value2) { + addCriterion("account_no between", value1, value2, "accountNo"); + return (Criteria) this; + } + + public Criteria andAccountNoNotBetween(String value1, String value2) { + addCriterion("account_no not between", value1, value2, "accountNo"); + return (Criteria) this; + } + + public Criteria andAmountsIsNull() { + addCriterion("amounts is null"); + return (Criteria) this; + } + + public Criteria andAmountsIsNotNull() { + addCriterion("amounts is not null"); + return (Criteria) this; + } + + public Criteria andAmountsEqualTo(BigDecimal value) { + addCriterion("amounts =", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsNotEqualTo(BigDecimal value) { + addCriterion("amounts <>", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsGreaterThan(BigDecimal value) { + addCriterion("amounts >", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("amounts >=", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsLessThan(BigDecimal value) { + addCriterion("amounts <", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsLessThanOrEqualTo(BigDecimal value) { + addCriterion("amounts <=", value, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsIn(List values) { + addCriterion("amounts in", values, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsNotIn(List values) { + addCriterion("amounts not in", values, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("amounts between", value1, value2, "amounts"); + return (Criteria) this; + } + + public Criteria andAmountsNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("amounts not between", value1, value2, "amounts"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Date value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Date value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Date value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Date value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Date value1, Date value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/msg/entity/MsgTopic.java b/hai-service/src/main/java/com/hai/msg/entity/MsgTopic.java index a2ebb3dd..65af6191 100644 --- a/hai-service/src/main/java/com/hai/msg/entity/MsgTopic.java +++ b/hai-service/src/main/java/com/hai/msg/entity/MsgTopic.java @@ -3,7 +3,8 @@ package com.hai.msg.entity; public enum MsgTopic { // 门店账户业务员 - MerStoreAccount("mer-store-account"); + MerStoreAccount("mer-store-account"), + oilPriceTask("OIL-PRICE-TASK"); private String name; diff --git a/hai-service/src/main/java/com/hai/service/CommonService.java b/hai-service/src/main/java/com/hai/service/CommonService.java index ee8bbe23..21926282 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -147,6 +147,12 @@ public interface CommonService { */ SecRegion getRegionsById(Long regionId); + /** + * 查询省级列表 + * @return + */ + List getProvinceList(); + /** * 根据地区名称模糊查询 * @param regionName diff --git a/hai-service/src/main/java/com/hai/service/HighGasOilPriceTaskService.java b/hai-service/src/main/java/com/hai/service/HighGasOilPriceTaskService.java index dd528cb1..3d6e7a69 100644 --- a/hai-service/src/main/java/com/hai/service/HighGasOilPriceTaskService.java +++ b/hai-service/src/main/java/com/hai/service/HighGasOilPriceTaskService.java @@ -17,6 +17,12 @@ public interface HighGasOilPriceTaskService { */ void editData(HighGasOilPriceTask gasOilPriceTask); + /** + * 批量增加价格任务 + * @param taskList + */ + void batchAddTask(List taskList); + /** * 增加价格任务 * @param gasOilPriceTask diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantAccountService.java b/hai-service/src/main/java/com/hai/service/HighMerchantAccountService.java new file mode 100644 index 00000000..00a5af15 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighMerchantAccountService.java @@ -0,0 +1,45 @@ +package com.hai.service; + +import com.hai.entity.HighMerchantAccount; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +public interface HighMerchantAccountService { + + /** + * 编辑商户账户 + * @param merchantAccount + */ + void editMerchantAccount(HighMerchantAccount merchantAccount); + + /** + * 充值 + * @param merId + * @param amount + * @param otherParam + */ + void recharge(Long merId, BigDecimal amount, Map otherParam); + + /** + * 查询商户账户 + * @param merId + * @return + */ + HighMerchantAccount getStoreAccountDetail(Long merId); + + /** + * 统计商户加油金额 + * @param merId + * @return + */ + BigDecimal countMerGasOilAmount(Long merId); + + /** + * 查询门店加油金额 + * @param merId + * @return + */ + List> getStoreGasOilAmountByMer(Long merId); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java index 6a2ed729..f95b0a58 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java @@ -89,7 +89,10 @@ public class BsCompanyServiceImpl implements BsCompanyService { public BsCompany getCompanyById(Long id) { BsCompany company =bsCompanyMapper.selectByPrimaryKey(id); if (company.getRegionId() != null) { - // company.setRegionName(commonService.getRegionName(Long.valueOf(company.getRegionId()))); + SecRegion region = commonService.getRegionsById(Long.parseLong(company.getRegionId())); + if (region != null) { + company.setRegionName(region.getRegionName()); + } } return company; } diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index e83619a0..d864c0fe 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -410,6 +410,13 @@ public class CommonServiceImpl implements CommonService { return regionMapper.selectByPrimaryKey(regionId); } + @Override + public List getProvinceList() { + SecRegionExample example = new SecRegionExample(); + example.createCriteria().andParentIdIsNull().andStatusEqualTo(1); + return regionMapper.selectByExample(example); + } + @Override public SecRegion getRegionsByName(String regionName) { SecRegionExample example = new SecRegionExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java index 549c908e..5de5044a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.BigInteger; import java.util.List; import java.util.Map; @@ -134,12 +135,74 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri } discount = discount.divide(new BigDecimal("100")); // 枪价 - BigDecimal priceGun = null; + BigDecimal priceGun; // 优惠价 - BigDecimal priceVip = null; + BigDecimal priceVip; + // 优惠幅度 + BigDecimal preferentialMargin = new BigDecimal("0"); - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(2)) { + // 查询油站价格 + HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(goodsId, Integer.parseInt(oilNo)); + if (gasOilPrice == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); + } + priceGun = gasOilPrice.getPriceGun(); + priceVip = gasOilPrice.getPriceVip(); + preferentialMargin = gasOilPrice.getPreferentialMargin(); + + // 国标价 + BigDecimal priceOfficial = gasOilPrice.getPriceOfficial(); + + GasPayPriceModel payPriceModel = new GasPayPriceModel(); + + if (store.getSourceType().equals(1)) { + + // 嗨森逛平台价 国标价 * 折扣 + BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); + + // 加油金额 + payPriceModel.setOilingPrice(oilingPrice); + + // 加油站枪价 + payPriceModel.setPriceGun(priceGun); + + // 加油站优惠价 + payPriceModel.setPriceVip(priceVip); + + // 加油站国标价 + payPriceModel.setPriceOfficial(priceOfficial); + + // 平台价 + payPriceModel.setPricePlatform(pricePlatform); + + // 加油升数,计算方式:加油金额 / 枪价 + payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); + + // 平台折扣,我们平台或者代理商设置的折扣 + payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount); + + // 加油补贴, 计算方式:加油站枪价 - 加油站VIP价 + payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); + + // 折扣,1 -平台折扣 + BigDecimal decimal1 = new BigDecimal("1").subtract(discount); + + // 油枪价 - 优惠幅度 + BigDecimal price = payPriceModel.getPriceGun().subtract(preferentialMargin); + + // 优惠价格 (油枪价 - 优惠幅度) * 系统折扣 + payPriceModel.setPricePreferences(price.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); + + // 每升优惠 枪价 - 优惠价格 + payPriceModel.setLitersPreferences(priceGun.subtract(payPriceModel.getPricePreferences())); + + // 本次优惠 加油升数 * 每升优惠 + payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); + + // 支付价格 加油金额 - 本次优惠 + payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); + + } else if (store.getSourceType().equals(2)) { // 查询油站油品价格 JSONObject oilPriceObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), oilNo); if (oilPriceObject == null) { @@ -154,66 +217,52 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri priceGun = priceDetail.getBigDecimal("priceGun"); // 团油优惠价 priceVip = priceDetail.getBigDecimal("priceVip"); - } - HighGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPriceByStoreAndOilNo(goodsId, Integer.parseInt(oilNo)); - if (gasOilPrice == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); - } - if (priceGun == null) { - priceGun = gasOilPrice.getPriceGun(); - } - if (priceVip == null) { - priceVip = gasOilPrice.getPriceVip(); - } - // 团油国标价 - BigDecimal priceOfficial = gasOilPrice.getPriceOfficial(); - // 嗨森逛平台价 国标价 * 折扣 - BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); + // 嗨森逛平台价 国标价 * 折扣 + BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); - GasPayPriceModel payPriceModel = new GasPayPriceModel(); - // 加油金额 - payPriceModel.setOilingPrice(oilingPrice); + // 加油金额 + payPriceModel.setOilingPrice(oilingPrice); - // 团油枪价 - payPriceModel.setPriceGun(priceGun); - - // 团油优惠价 - payPriceModel.setPriceVip(priceVip); + // 团油枪价 + payPriceModel.setPriceGun(priceGun); - // 团油国标价 - payPriceModel.setPriceOfficial(priceOfficial); + // 团油优惠价 + payPriceModel.setPriceVip(priceVip); - // 平台价 - payPriceModel.setPricePlatform(pricePlatform); + // 团油国标价 + payPriceModel.setPriceOfficial(priceOfficial); - // 加油升数,计算方式:加油金额 / 枪价 - payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); + // 平台价 + payPriceModel.setPricePlatform(pricePlatform); - // 平台折扣,我们平台或者代理商设置的折扣 - payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("0") : discount); + // 加油升数,计算方式:加油金额 / 枪价 + payPriceModel.setOilLiters(oilingPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); - // 加油补贴, 计算方式:团油枪价 - 团油VIP价 - payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); + // 平台折扣,我们平台或者代理商设置的折扣 + payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("100") : discount); - // 折扣,1 -平台折扣 - BigDecimal decimal1 = new BigDecimal("1").subtract(discount); + // 加油补贴, 计算方式:团油枪价 - 团油VIP价 + payPriceModel.setOilSubsidy(priceGun.subtract(priceVip)); - // 价格差价 团油枪价 - 团油VIP价 - BigDecimal oilPriceDifferences = priceGun.subtract(priceVip); + // 折扣,1 -平台折扣 + BigDecimal decimal1 = new BigDecimal("1").subtract(discount); - // 每升优惠 团油枪价 *(1-平台折扣)+(国标价-团油VIP价 ) - payPriceModel.setLitersPreferences(priceGun.multiply(decimal1).setScale(2, BigDecimal.ROUND_HALF_UP).add(oilPriceDifferences)); + // 价格差价 团油枪价 - 团油VIP价 + BigDecimal oilPriceDifferences = priceGun.subtract(priceVip); - // 优惠价格 团油枪价 * 平台折扣 -(国标价-团油VIP价 ) - payPriceModel.setPricePreferences(pricePlatform.subtract(oilPriceDifferences)); + // 每升优惠 团油枪价 *(1-平台折扣)+(国标价-团油VIP价 ) + payPriceModel.setLitersPreferences(priceGun.multiply(decimal1).setScale(2, BigDecimal.ROUND_HALF_UP).add(oilPriceDifferences)); - // 本次优惠 - payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); + // 优惠价格 团油枪价 * 平台折扣 -(国标价-团油VIP价 ) + payPriceModel.setPricePreferences(pricePlatform.subtract(oilPriceDifferences)); - // 支付价格 - payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); + // 本次优惠 + payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_DOWN)); + // 支付价格 + payPriceModel.setPayPrice(oilingPrice.subtract(payPriceModel.getTotalPreferences())); + } return payPriceModel; } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java index e01f6f1b..69e845bf 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceTaskServiceImpl.java @@ -3,6 +3,8 @@ package com.hai.service.impl; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.RedisUtil; import com.hai.dao.HighGasOilPriceTaskMapper; import com.hai.entity.HighGasOilPrice; import com.hai.entity.HighGasOilPriceOfficial; @@ -11,12 +13,15 @@ import com.hai.entity.HighGasOilPriceTaskExample; import com.hai.enum_type.GasTaskExecutionTypeEnum; import com.hai.enum_type.GasTaskPriceTypeEnum; import com.hai.enum_type.GasTaskStatusEnum; +import com.hai.msg.entity.MsgTopic; import com.hai.service.HighGasOilPriceOfficialService; import com.hai.service.HighGasOilPriceService; import com.hai.service.HighGasOilPriceTaskService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; @@ -26,6 +31,9 @@ import java.util.Map; @Service("gasOilPriceTaskService") public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskService { + @Resource + private RedisUtil redisUtil; + @Resource private HighGasOilPriceTaskMapper gasOilPriceTaskMapper; @@ -48,63 +56,77 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic } @Override + @Transactional(propagation= Propagation.REQUIRED) + public void batchAddTask(List taskList) { + for (HighGasOilPriceTask task : taskList) { + addTask(task); + } + } + + @Override + @Transactional(propagation= Propagation.REQUIRED) public void addTask(HighGasOilPriceTask gasOilPriceTask) { editData(gasOilPriceTask); - // 立刻执行 if (gasOilPriceTask.getExecutionType().equals(GasTaskExecutionTypeEnum.type1.getStatus())) { businessHandle(gasOilPriceTask); - } + } else if (gasOilPriceTask.getExecutionType().equals(GasTaskExecutionTypeEnum.type2.getStatus())) { + long time = DateUtil.getSecondDiff(new Date(), gasOilPriceTask.getStartTime()); + if (time >= 1) { + redisUtil.set(MsgTopic.oilPriceTask.getName() + "-" + gasOilPriceTask.getId(), "", time); + } else { + businessHandle(gasOilPriceTask); + } + } } @Override + @Transactional(propagation= Propagation.REQUIRED) public void businessHandle(HighGasOilPriceTask gasOilPriceTask) { // 立刻执行 - if (gasOilPriceTask.getExecutionType().equals(GasTaskExecutionTypeEnum.type1.getStatus())) { - gasOilPriceTask.setStartTime(new Date()); - gasOilPriceTask.setStatus(GasTaskStatusEnum.status2.getStatus()); - editData(gasOilPriceTask); - - // 国标价 - if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type1.getStatus())) { - // 查询国标价油品价格 - HighGasOilPriceOfficial price = gasOilPriceOfficialService.getPrice(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo()); - if (price == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); - } - gasOilPriceOfficialService.editPrice(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo(), gasOilPriceTask.getPrice()); - - new Thread(() -> { - gasOilPriceOfficialService.refreshGasPriceOfficial(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo()); - }).start(); - } + gasOilPriceTask.setStartTime(new Date()); + gasOilPriceTask.setStatus(GasTaskStatusEnum.status2.getStatus()); + editData(gasOilPriceTask); - // 油站价 - if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type2.getStatus())) { - // 查询油品价格 - HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); - if (price == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); - } - price.setPriceGun(gasOilPriceTask.getPrice()); - price.setPriceVip(gasOilPriceTask.getPrice().subtract(price.getPreferentialMargin())); - gasOilPriceService.editGasOilPrice(price); + // 国标价 + if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type1.getStatus())) { + // 查询国标价油品价格 + HighGasOilPriceOfficial price = gasOilPriceOfficialService.getPrice(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo()); + if (price == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); } + gasOilPriceOfficialService.editPrice(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo(), gasOilPriceTask.getPrice()); - // 优惠幅度 - if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { - // 查询油品价格 - HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); - if (price == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); - } - price.setPreferentialMargin(gasOilPriceTask.getPrice()); - price.setPriceVip(price.getPriceGun().subtract(price.getPreferentialMargin())); - gasOilPriceService.editGasOilPrice(price); + new Thread(() -> { + gasOilPriceOfficialService.refreshGasPriceOfficial(gasOilPriceTask.getRegionId(), gasOilPriceTask.getOilNo()); + }).start(); + } + + // 油站价 + if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type2.getStatus())) { + // 查询油品价格 + HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); + if (price == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); } + price.setPriceGun(gasOilPriceTask.getPrice()); + price.setPriceVip(gasOilPriceTask.getPrice().subtract(price.getPreferentialMargin())); + gasOilPriceService.editGasOilPrice(price); + } + // 优惠幅度 + if (gasOilPriceTask.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { + // 查询油品价格 + HighGasOilPrice price = gasOilPriceService.getGasOilPriceByStoreAndOilNo(gasOilPriceTask.getMerStoreId(), gasOilPriceTask.getOilNo()); + if (price == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油品价格"); + } + price.setPreferentialMargin(gasOilPriceTask.getPrice()); + price.setPriceVip(price.getPriceGun().subtract(price.getPreferentialMargin())); + gasOilPriceService.editGasOilPrice(price); } + } @Override @@ -121,6 +143,9 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic } detail.setStatus(GasTaskStatusEnum.status0.getStatus()); editData(detail); + + // 从redis中删除任务 + redisUtil.del(MsgTopic.oilPriceTask.getName() + "-" + taskId); } @Override @@ -145,6 +170,10 @@ public class HighGasOilPriceTaskServiceImpl implements HighGasOilPriceTaskServic criteria.andMerStoreNameLike("%" + MapUtils.getString(param, "merStoreName") + "%"); } + if (StringUtils.isNotBlank(MapUtils.getString(param, "merStoreKey"))) { + criteria.andMerStoreKeyLike("%" + MapUtils.getString(param, "merStoreKey") + "%"); + } + if (MapUtils.getInteger(param, "oilType") != null) { criteria.andOilTypeEqualTo(MapUtils.getInteger(param, "oilType")); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java new file mode 100644 index 00000000..0e05a400 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantAccountServiceImpl.java @@ -0,0 +1,93 @@ +package com.hai.service.impl; + +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.BankNumberUtil; +import com.hai.dao.HighMerchantAccountMapper; +import com.hai.entity.HighMerchant; +import com.hai.entity.HighMerchantAccount; +import com.hai.entity.HighMerchantAccountExample; +import com.hai.entity.HighMerchantStoreAccount; +import com.hai.model.HighMerchantModel; +import com.hai.model.HighMerchantStoreModel; +import com.hai.service.HighMerchantAccountService; +import com.hai.service.HighMerchantService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service("merchantAccountService") +public class HighMerchantAccountServiceImpl implements HighMerchantAccountService { + + @Resource + private HighMerchantAccountMapper merchantAccountMapper; + + @Resource + private HighMerchantService merchantService; + + @Override + public void editMerchantAccount(HighMerchantAccount merchantAccount) { + if (merchantAccount.getId() == null) { + merchantAccount.setAccountNo(BankNumberUtil.getBrankNumber("6")); + merchantAccount.setCreateTime(new Date()); + merchantAccount.setUpdateTime(new Date()); + merchantAccount.setStatus(1); + merchantAccountMapper.insert(merchantAccount); + } else { + merchantAccount.setUpdateTime(new Date()); + merchantAccountMapper.updateByPrimaryKey(merchantAccount); + } + } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void recharge(Long merId, BigDecimal amount, Map otherParam) { + // 查询商户 + HighMerchant merchant = merchantService.getDetailById(merId); + if (merchant == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); + } + // 是否开通了账户 + HighMerchantAccount account = getStoreAccountDetail(merId); + if (account == null) { + account = new HighMerchantAccount(); + account.setMerId(merId); + account.setAmounts(new BigDecimal("0")); + } + // 变更前金额 + BigDecimal beforeAmount = account.getAmounts(); + // 计算金额 + account.setAmounts(account.getAmounts().add(amount)); + // 变更后金额 + BigDecimal afterAmount = account.getAmounts(); + editMerchantAccount(account); + } + + @Override + public HighMerchantAccount getStoreAccountDetail(Long merId) { + HighMerchantAccountExample example = new HighMerchantAccountExample(); + example.createCriteria().andStatusEqualTo(1).andMerIdEqualTo(merId); + List list = merchantAccountMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + public BigDecimal countMerGasOilAmount(Long merId) { + return merchantAccountMapper.countMerGasOilAmount(merId); + } + + @Override + public List> getStoreGasOilAmountByMer(Long merId) { + return merchantAccountMapper.selectStoreGasOilAmountByMer(merId); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java index 268d69ef..6f9b0166 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -178,6 +178,14 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { HighMerchantStoreExample example = new HighMerchantStoreExample(); HighMerchantStoreExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + + if (MapUtils.getInteger(map, "sourceType") != null) { + criteria.andSourceTypeEqualTo(MapUtils.getInteger(map, "sourceType")); + } + if (MapUtils.getLong(map, "companyId") != null) { criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java index 5c0d2a3c..04311f2a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java @@ -36,7 +36,7 @@ public class HighOilCardRecordServiceImpl implements HighOilCardRecordService { oilCardRecord.setOpUserName(userInfoModel.getSecUser().getUserName()); } HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); - if (userModel == null) { + if (userModel != null) { oilCardRecord.setOpUserId(userModel.getHighUser().getId()); oilCardRecord.setOpUserName(userModel.getHighUser().getName()); }