dev-discount
袁野 2 years ago
parent efd4d10627
commit 15e1d89441
  1. 5
      hai-bweb/src/main/java/com/BWebApplication.java
  2. 100
      hai-bweb/src/main/java/com/bweb/config/msg/MerStoreAccountChgHandler.java
  3. 96
      hai-bweb/src/main/java/com/bweb/controller/BsMsgController.java
  4. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  5. 28
      hai-bweb/src/main/resources/dev/application.yml
  6. 57
      hai-service/src/main/java/com/hai/service/BsMsgService.java
  7. 62
      hai-service/src/main/java/com/hai/service/impl/BsMsgServiceImpl.java

@ -1,5 +1,7 @@
package com;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import com.hai.common.utils.SpringContextUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
@ -14,8 +16,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
//@ComponentScan
@EnableTransactionManagement
@EnableScheduling
@EnableMethodCache(basePackages = "com.hai")
@EnableCreateCacheAnnotation
@ServletComponentScan
@EnableAspectJAutoProxy(proxyTargetClass = true)
@MapperScan("com.hai.dao")
public class BWebApplication
{

@ -33,55 +33,55 @@ public class MerStoreAccountChgHandler {
@PostConstruct
public void init() {
new Thread(() -> {
{
//消息处理
while (true){
try {
//构建的队列为左进右出
Object o = redisTemplate.opsForList().rightPop(MsgTopic.MerStoreAccount.getName());
if (o != null) {
//处理消息
logger.info("消息通道:"+o);
Map<String, Object> param = (Map<String, Object>) o;
if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type1.getType())) {
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
otherParam.put("opUserId", MapUtils.getLong(param, "opUserId"));
otherParam.put("opUserName", MapUtils.getString(param, "opUserName"));
merchantStoreAccountService.recharge(
MapUtils.getLong(param, "storeId"),
new BigDecimal(MapUtils.getString(param, "price")),
otherParam);
}
if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type2.getType())) {
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
otherParam.put("opUserId", MapUtils.getLong(param, "opUserId"));
otherParam.put("opUserName", MapUtils.getString(param, "opUserName"));
merchantStoreAccountService.consume(
MapUtils.getLong(param, "storeId"),
new BigDecimal(MapUtils.getString(param, "price")),
otherParam);
}
} else {
Thread.sleep(1000);
}
}catch (Exception e){
logger.error("监听订单状态变更错误",e);
}
}
}
}).start();
// new Thread(() -> {
// {
// //消息处理
// while (true){
// try {
// //构建的队列为左进右出
// Object o = redisTemplate.opsForList().rightPop(MsgTopic.MerStoreAccount.getName());
// if (o != null) {
// //处理消息
// logger.info("消息通道:"+o);
//
// Map<String, Object> param = (Map<String, Object>) o;
//
// if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type1.getType())) {
// Map<String, Object> otherParam = new HashMap<>();
// otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
// otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
// otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
// otherParam.put("opUserId", MapUtils.getLong(param, "opUserId"));
// otherParam.put("opUserName", MapUtils.getString(param, "opUserName"));
//
// merchantStoreAccountService.recharge(
// MapUtils.getLong(param, "storeId"),
// new BigDecimal(MapUtils.getString(param, "price")),
// otherParam);
// }
//
// if (MapUtils.getInteger(param, "businessType").equals(MerStoreAmountTypeEnum.type2.getType())) {
// Map<String, Object> otherParam = new HashMap<>();
// otherParam.put("sourceType", MapUtils.getString(param, "sourceType"));
// otherParam.put("sourceId", MapUtils.getString(param, "sourceId"));
// otherParam.put("sourceContent", MapUtils.getString(param, "sourceContent"));
// otherParam.put("opUserId", MapUtils.getLong(param, "opUserId"));
// otherParam.put("opUserName", MapUtils.getString(param, "opUserName"));
//
// merchantStoreAccountService.consume(
// MapUtils.getLong(param, "storeId"),
// new BigDecimal(MapUtils.getString(param, "price")),
// otherParam);
// }
//
// } else {
// Thread.sleep(1000);
// }
// }catch (Exception e){
// logger.error("监听订单状态变更错误",e);
// }
// }
// }
// }).start();
}
}

@ -0,0 +1,96 @@
package com.bweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.BsMsg;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.BsMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author sum1dream
*/
@Controller
@RequestMapping(value = "/bsMsg")
@Api(value = "站内信")
public class BsMsgController {
Logger log = LoggerFactory.getLogger(ApiProductController.class);
@Resource
private BsMsgService bsMsgService;
@Autowired
private UserCenter userCenter;
@RequestMapping(value = "/getMsgByList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询站内信列表")
public ResponseData getMsgByList(
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "jumpType", required = false) Integer jumpType,
@RequestParam(value = "msgType", required = false) Integer msgType,
@RequestParam(value = "title", required = false) String title,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request
) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
Map<String, Object> map = new HashMap<>(5);
map.put("type", type);
map.put("jumpType", jumpType);
map.put("msgType", msgType);
map.put("title", title);
map.put("companyId" , userInfoModel.getBsCompany().getId());
PageHelper.startPage(pageNum,pageSize);
List<BsMsg> list = bsMsgService.getMsgByList(map);
return ResponseMsgUtil.success(new PageInfo<>(list));
} catch (Exception e) {
log.error("BsMsgController --> getMsgByList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "insertMsg" , method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增站内信")
public ResponseData insertMsg(@RequestBody BsMsg bsMsg , HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
bsMsg.setCompanyId(userInfoModel.getBsCompany().getId());
bsMsg.setOpId(userInfoModel.getSecUser().getId());
bsMsg.setOpName(userInfoModel.getSecUser().getUserName());
bsMsgService.insertMsg(bsMsg);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("BsMsgController --> insertMsg() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

File diff suppressed because one or more lines are too long

@ -53,6 +53,12 @@ spring:
#MQTT默认的消息推送主题,实际可在调用接口是指定
# default:
# topic: topic
rocketmq:
name-server: 139.159.177.244:9876
producer:
#必须指定group
group: default-group
#配置日期返回至前台为时间戳
jackson:
serialization:
@ -63,6 +69,28 @@ mybatis:
type-aliases-package:
org.springboot.sample.entity
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
local:
default:
type: linkedhashmap
keyConvertor: fastjson
remote:
default:
type: redis
host: 139.159.177.244
port: 36379
password: HF123456.Redis
keyConvertor: fastjson
broadcastChannel: projectA
valueEncoder: java
valueDecoder: java
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
pagehelper:
helperDialect: mysql
reasonable: true

@ -0,0 +1,57 @@
package com.hai.service;
import com.hai.entity.BsMsg;
import java.util.List;
import java.util.Map;
/**
* @serviceName BsMsgService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 站内信接口
* @createTime 14:27 2022/9/20
**/
public interface BsMsgService {
/**
* @Author Sum1Dream
* @Name insertMsg
* @Description // 新增站内信
* @Date 14:30 2022/9/20
* @Param [bsMsg]
* @Return void
*/
void insertMsg(BsMsg bsMsg);
/**
* @Author Sum1Dream
* @Name updateMsg
* @Description //修改站内信
* @Date 14:30 2022/9/20
* @Param [bsMsg]
* @Return void
*/
void updateMsg(BsMsg bsMsg);
/**
* @Author Sum1Dream
* @Name findMsg
* @Description // 根据id查询站内信
* @Date 14:33 2022/9/20
* @Param [id]
* @Return com.hai.entity.BsMsg
*/
BsMsg findMsg(Long id);
/**
* @Author Sum1Dream
* @Name getMsgByList
* @Description // 查询站内信列表
* @Date 14:34 2022/9/20
* @Param [map]
* @Return java.util.List<com.hai.entity.BsMsg>
*/
List<BsMsg> getMsgByList(Map<String , Object> map);
}

@ -0,0 +1,62 @@
package com.hai.service.impl;
import com.hai.dao.BsMsgMapper;
import com.hai.entity.BsMsg;
import com.hai.entity.BsMsgExample;
import com.hai.service.BsMsgService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @author sum1dream
*/
@Service("bsMsgService")
public class BsMsgServiceImpl implements BsMsgService {
@Resource
private BsMsgMapper bsMsgMapper;
@Override
public void insertMsg(BsMsg bsMsg) {
bsMsgMapper.insert(bsMsg);
}
@Override
public void updateMsg(BsMsg bsMsg) {
bsMsgMapper.updateByPrimaryKey(bsMsg);
}
@Override
public BsMsg findMsg(Long id) {
return bsMsgMapper.selectByPrimaryKey(id);
}
@Override
public List<BsMsg> getMsgByList(Map<String, Object> map) {
BsMsgExample example = new BsMsgExample();
BsMsgExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type"));
}
if (MapUtils.getInteger(map , "jumpType") != null) {
criteria.andJumpTypeEqualTo(MapUtils.getInteger(map , "jumpType"));
}
if (MapUtils.getInteger(map , "msgType") != null) {
criteria.andMsgTypeEqualTo(MapUtils.getInteger(map , "msgType"));
}
if (MapUtils.getInteger(map , "title") != null) {
criteria.andTitleLike("%" + MapUtils.getString(map , "title") + "%" );
}
if (MapUtils.getLong(map , "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId"));
}
return bsMsgMapper.selectByExample(example);
}
}
Loading…
Cancel
Save