Browse Source

一二级市场消息模块

李书文 1 year ago
parent
commit
56a9310e8c

+ 31 - 18
sp-core/sp-api/src/main/java/com/pj/api/dto/MessageDto.java

@@ -15,9 +15,9 @@ public class MessageDto {
     private Integer types;
 
     /**
-     * 消息类型
+     * 跳转页面路径
      */
-    private Integer module;
+    private String url;
 
     /**
      * 消息内容
@@ -30,15 +30,20 @@ public class MessageDto {
     private Long userId;
 
     /**
-     * 创建时间
+     * 状态(0=禁用,1=启用)
      */
-    private Date createTime;
+    private Integer enable;
 
+    /**
+     * 是否已读(0=未读,1=已读)
+     */
+    private Integer isRead;
 
     /**
-     * 状态(0=禁用,1=启用)
+     * 创建时间
      */
-    private String enable;
+    private Date createTime;
+
 
     public Integer getTypes() {
         return types;
@@ -48,12 +53,12 @@ public class MessageDto {
         this.types = types;
     }
 
-    public Integer getModule() {
-        return module;
+    public String getUrl() {
+        return url;
     }
 
-    public void setModule(Integer module) {
-        this.module = module;
+    public void setUrl(String url) {
+        this.url = url;
     }
 
     public String getContents() {
@@ -72,19 +77,27 @@ public class MessageDto {
         this.userId = userId;
     }
 
-    public Date getCreateTime() {
-        return createTime;
+    public Integer getEnable() {
+        return enable;
     }
 
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
+    public void setEnable(Integer enable) {
+        this.enable = enable;
     }
 
-    public String getEnable() {
-        return enable;
+    public Integer getIsRead() {
+        return isRead;
     }
 
-    public void setEnable(String enable) {
-        this.enable = enable;
+    public void setIsRead(Integer isRead) {
+        this.isRead = isRead;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
     }
 }

+ 16 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java

@@ -10,7 +10,9 @@ import java.util.List;
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.dto.GoodsTransitDto;
+import com.pj.api.dto.MessageDto;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
@@ -84,6 +86,12 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 	@Autowired
 	TbOrderService orderService;
 
+	/**
+	 * 远程调用
+	 */
+	@Autowired
+	private AdminInterface adminInterface;
+
 	/** 增 */
 	void add(TbGoodsTransit t){
 		//获取当前登录人
@@ -304,6 +312,14 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 				//获取商家信息
 				TbEnterprise tbEnterprise = tbEnterpriseMapper.selectById(tbGoodsTransit.getMerchantId());
 				if(tbEnterprise == null)throw new RuntimeException("商家不存在!");
+
+				//todo:给商家发一条接单消息
+				MessageDto dto = new MessageDto();
+				dto.setUrl("/pages/market/one/merchant/order/list");
+				dto.setUserId(tbEnterprise.getId());
+				dto.setContents("你的发布的《" + tbGoodsTransit.getGoodsName() + "》已有人接单,请及时确认。");
+				adminInterface.messageSave(dto);
+
 				//todo:通知短信
 //				return smsRetryService.sendSmsMsg(tbEnterprise.getContact());
 				return true;

+ 17 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java

@@ -7,6 +7,8 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.pj.api.client.admin.AdminInterface;
+import com.pj.api.dto.MessageDto;
 import com.pj.api.dto.OrderDto;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.current.dto.APPLoginUserInfo;
@@ -49,6 +51,12 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 	@Autowired
 	private TbGoodsTransitService tbGoodsTransitService;
 
+	/**
+	 * 远程调用
+	 */
+	@Autowired
+	private AdminInterface adminInterface;
+
 	/**  app端: 生成一级市场订单 */
 	void appAdd(TbOrder t){
 		//获取当前登陆人
@@ -232,6 +240,15 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 
 		}
 
+		TbOrder tbOrder=tbOrderMapper.selectById(order.getId());
+		//todo:给组长发一条商家消息
+		String message = order.getEnterpriseConfirm() == 1 ? "商户已确认,请及时发货。" : "已被商户拒绝,请重新接单或换一家商品。";
+		MessageDto dto = new MessageDto();
+		dto.setUrl("/pages/market/one/leader/order");
+		dto.setUserId(tbOrder.getBuyUserId());
+		dto.setContents("你接单的《" + tbOrder.getGoodsNames() + "》" + message);
+		adminInterface.messageSave(dto);
+
 		// 修改订单表的商家确认状态
 		order.setGoodsId(null);
 		boolean flag = updateById(order);

+ 8 - 9
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/TbDemandQuotationService.java

@@ -1,8 +1,7 @@
 package com.pj.tb_demand_quotation;
 
-import java.util.Date;
-import java.util.List;
-
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
 import com.pj.api.dto.MessageDto;
@@ -20,10 +19,11 @@ import com.pj.tb_purchaser.TbPurchaserMapper;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * Service: tb_demand_quotation -- 一级市场组长需求抢购表
  *
@@ -147,11 +147,10 @@ public class TbDemandQuotationService extends ServiceImpl<TbDemandQuotationMappe
             TbPurchaser tbPurchaser = tbPurchaserMapper.selectById(tbGoodsDemand.getPurchaserId());
             if (tbPurchaser == null) throw new RuntimeException("二级商户信息异常!~");
             //todo:给收购商发一条接单消息
-            MessageDto dto=new MessageDto();
-            dto.setEnable("1");
-            dto.setModule(2);
+            MessageDto dto = new MessageDto();
+            dto.setUrl("/pages/market/two/purchaser/buy/list");
             dto.setUserId(tbGoodsDemand.getPurchaserId());
-            dto.setContents("你的发布的"+tbGoodsDemand.getGoodsName()+"已有人接单,请及时确认。");
+            dto.setContents("你的发布的" + tbGoodsDemand.getGoodsName() + "已有人接单,请及时确认。");
             adminInterface.messageSave(dto);
             //todo:发送短信
 //			smsRetryService.sendSmsMsg(tbPurchaser.getContact());

+ 170 - 129
sp-service/level-two-server/src/main/java/com/pj/tb_goods_demand/TbGoodsDemandService.java

@@ -1,9 +1,11 @@
 package com.pj.tb_goods_demand;
 
-import java.util.Date;
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.pj.api.client.admin.AdminInterface;
+import com.pj.api.dto.MessageDto;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
@@ -11,143 +13,182 @@ import com.pj.enummj.DeleteStatus;
 import com.pj.enummj.OrderStatus;
 import com.pj.enummj.ReleaseStatus;
 import com.pj.tb_demand_quotation.TbDemandQuotation;
+import com.pj.tb_demand_quotation.TbDemandQuotationMapper;
 import com.pj.tb_demand_quotation.TbDemandQuotationService;
 import com.pj.tb_goods_demand.vo.GoodsDemandVo;
 import com.pj.utils.so.SoMap;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
-import com.pj.utils.sg.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Service: tb_goods_demand -- 二级收购商需求发布表
+ *
  * @author yzs
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbGoodsDemandService extends ServiceImpl<TbGoodsDemandMapper, TbGoodsDemand> implements IService<TbGoodsDemand>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbGoodsDemandMapper tbGoodsDemandMapper;
-	@Autowired
-	private TbDemandQuotationService demandQuotationService;
-
-	@Autowired
-	private MethodGoodsDemandService methodGoodsDemandService;
-
-	/** 二级市场收购商发布需求 */
-	void add(TbGoodsDemand t){
-		//获取并判断当前登陆人
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
-			throw new ServiceException("当前登录账号信息已失效!");
-		//设置基本状态
-		t.setIsOrders(0); // 0= 未被下单
-		t.setIsConfirm(0);// 收购商未确认
-		t.setPurchaserId(appLoginInfo.getFk());
-		t.setCreateBy(appLoginInfo.getLoginId());
-		t.setCreateName(appLoginInfo.getLoginName());
-		t.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-		t.setCreateTime(new Date());
-		save(t);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(TbGoodsDemand t){
-		//获取并判断当前登陆人
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
-			throw new ServiceException("当前登录账号信息已失效!");
-		//执行修改
-		t.setIsOrders(0); // 0= 未被下单
-		t.setIsConfirm(0);// 收购商未确认
-		t.setUpdateBy(appLoginInfo.getLoginId());
-		t.setUpdateName(appLoginInfo.getLoginName());
-		t.setUpdateTime(new Date());
-		updateById(t);
-
-	}
-
-	/** 查 */
-	TbGoodsDemand getById(Long id){
-		return super.getById(id);
-	}
-
-	/** pc端:专供给一级市场查看的需求列表 */
-	List<TbGoodsDemand> getList(SoMap so) {
-		return tbGoodsDemandMapper.getList(so);
-	}
-
-	/** app端:专供给二级市场查看的需求列表 */
-	List<TbGoodsDemand> getAppList(SoMap so) {
-		//获取并判断当前登陆人
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
-			throw new ServiceException("当前登录账号信息已失效!");
-		//获取当前收购商发布的需求
-		so.put("purchaserId",appLoginInfo.getFk());
-		so.put("sortType",10); //根据创建日期降序
-		so.put("deleteStatus", DeleteStatus.DELETE_STATUS_ON.getCode()); // 状态可用
-		return tbGoodsDemandMapper.getList(so);
-	}
-
-	/**
-	 * 二级收购商查看需求发布需求详情
-	 * @return
-	 */
-	public GoodsDemandVo goodsDemandList(SoMap so){
-		so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
-		List<TbGoodsDemand> goodsDemandMapperList = tbGoodsDemandMapper.getList(so);
-
-		//匹配已被报价的列表
-		if(goodsDemandMapperList.size() > 0){
-			List<GoodsDemandVo> goodsDemandVos = methodGoodsDemandService.setGoodsDemandVo(goodsDemandMapperList,so);
-			if(goodsDemandVos.size() > 0) return goodsDemandVos.get(0);
-		}
-		return null;
-	}
-
-	/**
-	 * 二级市场收购商处理需求订单
-	 * @param disposeStatus 处理状态[0=待处理,1=通过,2=拒绝]
-	 * @param goodsDemandId  需求表主键
-	 * @param demandQuotationId 报价表主键
-	 */
-	public boolean disposeOrders(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId,String purchaserRemark)  {
-		//获取并判断当前登陆人
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		if(appLoginInfo == null || appLoginInfo.getLoginId() == null) throw new ServiceException("当前登录账号信息已失效!");
-
-		//同意则开始创建订单,不同意则修改报价表和需求表状态
-		if(disposeStatus == 1){
-			return methodGoodsDemandService.agreeQuotation(appLoginInfo,goodsDemandId,demandQuotationId,purchaserRemark);
-		}else if(disposeStatus == 2){
-			return methodGoodsDemandService.refuseQuotation(appLoginInfo,goodsDemandId,demandQuotationId,purchaserRemark);
-		}
-		throw new RuntimeException("服务器繁忙~");
-	}
-
-	boolean refuse(TbGoodsDemand t) {
-		t.setIsOrders(OrderStatus.ORDER_STATUS_ZERO.getCode());//未被接单
-		t.setIsRelease(ReleaseStatus.RELEASE_STATUS_PUBLISH.getCode());//已发布
-		t.setIsConfirm(0);//收购商未确认
-		update(t);
-
-		LambdaUpdateWrapper<TbDemandQuotation> wrapper = new LambdaUpdateWrapper<>();
-		//报价结果[0=待确认,1=确认,2=拒绝]
-		wrapper.set(TbDemandQuotation::getQuotationResult, 2);
-		wrapper.eq(TbDemandQuotation::getDemandId, t.getId());
-		boolean update = demandQuotationService.update(wrapper);
-
-		return update;
-	}
+public class TbGoodsDemandService extends ServiceImpl<TbGoodsDemandMapper, TbGoodsDemand> implements IService<TbGoodsDemand> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGoodsDemandMapper tbGoodsDemandMapper;
+    @Autowired
+    private TbDemandQuotationService demandQuotationService;
+
+    @Autowired
+    private MethodGoodsDemandService methodGoodsDemandService;
+
+    @Autowired
+    TbDemandQuotationMapper tbDemandQuotationMapper;
+
+    /**
+     * 远程调用
+     */
+    @Autowired
+    private AdminInterface adminInterface;
+
+    /**
+     * 二级市场收购商发布需求
+     */
+    void add(TbGoodsDemand t) {
+        //获取并判断当前登陆人
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        if (appLoginInfo == null || appLoginInfo.getLoginId() == null)
+            throw new ServiceException("当前登录账号信息已失效!");
+        //设置基本状态
+        t.setIsOrders(0); // 0= 未被下单
+        t.setIsConfirm(0);// 收购商未确认
+        t.setPurchaserId(appLoginInfo.getFk());
+        t.setCreateBy(appLoginInfo.getLoginId());
+        t.setCreateName(appLoginInfo.getLoginName());
+        t.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+        t.setCreateTime(new Date());
+        save(t);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(TbGoodsDemand t) {
+        //获取并判断当前登陆人
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        if (appLoginInfo == null || appLoginInfo.getLoginId() == null)
+            throw new ServiceException("当前登录账号信息已失效!");
+        //执行修改
+        t.setIsOrders(0); // 0= 未被下单
+        t.setIsConfirm(0);// 收购商未确认
+        t.setUpdateBy(appLoginInfo.getLoginId());
+        t.setUpdateName(appLoginInfo.getLoginName());
+        t.setUpdateTime(new Date());
+        updateById(t);
+
+    }
+
+    /**
+     * 查
+     */
+    TbGoodsDemand getById(Long id) {
+        return super.getById(id);
+    }
+
+    /**
+     * pc端:专供给一级市场查看的需求列表
+     */
+    List<TbGoodsDemand> getList(SoMap so) {
+        return tbGoodsDemandMapper.getList(so);
+    }
+
+    /**
+     * app端:专供给二级市场查看的需求列表
+     */
+    List<TbGoodsDemand> getAppList(SoMap so) {
+        //获取并判断当前登陆人
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        if (appLoginInfo == null || appLoginInfo.getLoginId() == null)
+            throw new ServiceException("当前登录账号信息已失效!");
+        //获取当前收购商发布的需求
+        so.put("purchaserId", appLoginInfo.getFk());
+        so.put("sortType", 10); //根据创建日期降序
+        so.put("deleteStatus", DeleteStatus.DELETE_STATUS_ON.getCode()); // 状态可用
+        return tbGoodsDemandMapper.getList(so);
+    }
+
+    /**
+     * 二级收购商查看需求发布需求详情
+     *
+     * @return
+     */
+    public GoodsDemandVo goodsDemandList(SoMap so) {
+        so.put("deleteStatus", DeleteStatus.DELETE_STATUS_ON.getCode());
+        List<TbGoodsDemand> goodsDemandMapperList = tbGoodsDemandMapper.getList(so);
+
+        //匹配已被报价的列表
+        if (goodsDemandMapperList.size() > 0) {
+            List<GoodsDemandVo> goodsDemandVos = methodGoodsDemandService.setGoodsDemandVo(goodsDemandMapperList, so);
+            if (goodsDemandVos.size() > 0) return goodsDemandVos.get(0);
+        }
+        return null;
+    }
+
+    /**
+     * 二级市场收购商处理需求订单
+     *
+     * @param disposeStatus     处理状态[0=待处理,1=通过,2=拒绝]
+     * @param goodsDemandId     需求表主键
+     * @param demandQuotationId 报价表主键
+     */
+    public boolean disposeOrders(Integer disposeStatus, Long goodsDemandId, Long demandQuotationId, String purchaserRemark) {
+        //获取并判断当前登陆人
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        if (appLoginInfo == null || appLoginInfo.getLoginId() == null)
+            throw new ServiceException("当前登录账号信息已失效!");
+
+        //同意则开始创建订单,不同意则修改报价表和需求表状态
+        if (disposeStatus == 1) {
+            return methodGoodsDemandService.agreeQuotation(appLoginInfo, goodsDemandId, demandQuotationId, purchaserRemark);
+        } else if (disposeStatus == 2) {
+            return methodGoodsDemandService.refuseQuotation(appLoginInfo, goodsDemandId, demandQuotationId, purchaserRemark);
+        }
+        throw new RuntimeException("服务器繁忙~");
+    }
+
+    boolean refuse(TbGoodsDemand t) {
+        t.setIsOrders(OrderStatus.ORDER_STATUS_ZERO.getCode());//未被接单
+        t.setIsRelease(ReleaseStatus.RELEASE_STATUS_PUBLISH.getCode());//已发布
+        t.setIsConfirm(0);//收购商未确认
+        update(t);
+
+        LambdaUpdateWrapper<TbDemandQuotation> wrapper = new LambdaUpdateWrapper<>();
+        //报价结果[0=待确认,1=确认,2=拒绝]
+        wrapper.set(TbDemandQuotation::getQuotationResult, 2);
+        wrapper.eq(TbDemandQuotation::getDemandId, t.getId());
+        boolean update = demandQuotationService.update(wrapper);
+
+        LambdaQueryWrapper<TbDemandQuotation> wra = new LambdaQueryWrapper<>();
+        wra.eq(TbDemandQuotation::getDemandId, t.getId());
+        wra.orderByDesc(TbDemandQuotation::getCreateTime);
+        List<TbDemandQuotation> quotationList=tbDemandQuotationMapper.selectList(wra);
+
+        //todo:给组长发一条拒绝的接单消息
+        MessageDto dto = new MessageDto();
+        dto.setUserId(quotationList.get(0).getLeaderId());
+        dto.setContents("抱歉! 你接单的《" + t.getGoodsName()+ "》已被商户拒绝,请重新接单或换一家商品。");
+        adminInterface.messageSave(dto);
+
+        return update;
+    }
 }

+ 14 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -6,8 +6,10 @@ import java.util.List;
 
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
 import com.pj.api.dto.GoodsDto;
+import com.pj.api.dto.MessageDto;
 import com.pj.current.config.SystemObject;
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
@@ -51,6 +53,12 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 	@Autowired
 	private MethodOrdersService methodOrdersService;
 
+	/**
+	 * 远程调用
+	 */
+	@Autowired
+	private AdminInterface adminInterface;
+
 	/** 增 */
 	void add(TbOrders t){
 		save(t);
@@ -194,6 +202,12 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 		wrapper2.eq(TbDemandQuotation::getDemandId, goodsDemandVo.getGoodsDemandId());
 		boolean update2 = demandQuotationService.update(wrapper2);
 
+		//todo:给组长发一条已确认接单消息
+		MessageDto dto = new MessageDto();
+		dto.setUrl("/pages/market/two/leader/order");
+		dto.setUserId(goodsDemandVo.getLeaderId());
+		dto.setContents("你接单的《" + goodsDemandVo.getGoodsName() + "》商户已确认,请及时发货。");
+		adminInterface.messageSave(dto);
 
 		return true;
 	}

+ 19 - 8
sp-service/sp-admin/src/main/java/com/pj/project/tb_message/TbMessage.java

@@ -45,7 +45,7 @@ public class TbMessage extends Model<TbMessage> implements Serializable {
 	 *  
 	 */
 	@TableId(type = IdType.AUTO)
-	private Integer id;	
+	private Long id;	
 
 	/**
 	 * 消息类型 
@@ -53,9 +53,9 @@ public class TbMessage extends Model<TbMessage> implements Serializable {
 	private Integer types;	
 
 	/**
-	 * 消息类型 
+	 * 跳转页面路径 
 	 */
-	private Integer module;	
+	private String url;
 
 	/**
 	 * 消息内容 
@@ -65,17 +65,28 @@ public class TbMessage extends Model<TbMessage> implements Serializable {
 	/**
 	 * 关联用户 
 	 */
-	private Long userId;
+	private Long userId;	
 
 	/**
-	 * 创建时间 
+	 * 状态(0=禁用,1=启用) 
 	 */
-	private Date createTime;
+	private Integer enable;	
 
+	/**
+	 * 是否已读(0=未读,1=已读) 
+	 */
+	private Integer isRead;	
 
 	/**
-	 * 状态(0=禁用,1=启用)
+	 * 创建时间 
 	 */
-	private String enable;
+	private Date createTime;
+
+
+
+
+
+	
+
 
 }

+ 8 - 3
sp-service/sp-admin/src/main/java/com/pj/project/tb_message/TbMessageAppController.java

@@ -6,6 +6,7 @@ import com.pj.project4sp.SP;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -30,16 +31,20 @@ public class TbMessageAppController {
     /**
      * 消息中心
      */
-    @RequestMapping("getList")
+    @GetMapping("getList")
     public AjaxJson getList() {
         SoMap so = SoMap.getRequestSoMap();
         so.put("enable", 1);
         if (so.get("types").toString().equals("2")) {
-            so.put("userId", StpAPPUserUtil.getAPPLoginInfo().getLoginId());
+            so.put("userId", StpAPPUserUtil.getAPPLoginInfo().getFk());
+            tbMessageService.clearRead(StpAPPUserUtil.getAPPLoginInfo().getFk());
         }
         List<TbMessage> list = tbMessageService.getList(so.startPage());
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
 
-
+    @GetMapping("getRead")
+    public AjaxJson getRead() {
+        return AjaxJson.getSuccessData(tbMessageService.getRead(StpAPPUserUtil.getAPPLoginInfo().getFk()));
+    }
 }

+ 4 - 7
sp-service/sp-admin/src/main/java/com/pj/project/tb_message/TbMessageController.java

@@ -7,6 +7,7 @@ import com.pj.project4sp.SP;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.apache.xmlbeans.impl.xb.xsdschema.Public;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -97,17 +98,13 @@ public class TbMessageController {
 
     @RequestMapping(value = "rpc/save")
     public AjaxJson save(@RequestBody MessageDto dto) {
-        System.out.println("远程调用:" + dto.getUserId());
         TbMessage message = new TbMessage();
-        message.setEnable("1");
-        message.setContents(dto.getContents());
+        BeanUtils.copyProperties(dto, message);
+        message.setEnable(1);
+        message.setIsRead(0);
         message.setTypes(2);
-        message.setUserId(dto.getUserId());
         message.setCreateTime(new Date());
         tbMessageService.save(message);
-/*        System.out.println("远程调用:"+t.toString());
-        t.setTypes(2);
-        tbMessageService.add(t);*/
         return AjaxJson.getSuccess();
     }
 

+ 23 - 8
sp-service/sp-admin/src/main/java/com/pj/project/tb_message/TbMessageMapper.java

@@ -1,30 +1,45 @@
 package com.pj.project.tb_message;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.ibatis.annotations.Mapper;
 
 import com.pj.utils.so.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.stereotype.Repository;
 
 /**
  * Mapper: tb_message -- 通知消息
- * @author lsw 
+ *
+ * @author lsw
  */
 
 @Mapper
 @Repository
-public interface TbMessageMapper extends BaseMapper <TbMessage> {
+public interface TbMessageMapper extends BaseMapper<TbMessage> {
 
 
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     *
+     * @param so 参数集合
+     * @return 数据列表
+     */
+    List<TbMessage> getList(SoMap so);
 
-	/**
-	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
-	 * @param so 参数集合 
-	 * @return 数据列表 
-	 */
-	List<TbMessage> getList(SoMap so);
 
+    /**
+     * 设置消息已读
+     *
+     * @return
+     */
+    @Update("UPDATE tb_message SET is_read=1 WHERE user_id=#{userId}")
+    boolean clearRead(@Param("userId") Long userId);
 
+    @Select("SELECT count(id)AS count FROM tb_message WHERE is_read=0 AND user_id=#{userId}")
+    Map<Object, String> getRead(@Param("userId") Long userId);
 }

+ 9 - 0
sp-service/sp-admin/src/main/java/com/pj/project/tb_message/TbMessageService.java

@@ -2,6 +2,7 @@ package com.pj.project.tb_message;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import com.pj.current.satoken.StpAPPUserUtil;
 import com.pj.utils.so.SoMap;
@@ -52,6 +53,14 @@ public class TbMessageService extends ServiceImpl<TbMessageMapper, TbMessage> im
 
     }
 
+    boolean clearRead(Long userId) {
+        return tbMessageMapper.clearRead(userId);
+    }
+
+    Map<Object, String> getRead(Long userId) {
+        return tbMessageMapper.getRead(userId);
+    }
+
     /**
      * 查
      */