Eric 2 лет назад
Родитель
Сommit
07cb181291

+ 31 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/CustomerServiceBatchSendingController.java

@@ -145,4 +145,35 @@ public class CustomerServiceBatchSendingController extends BaseController {
     
 		return HttpResponseResult.succeed(customerServiceBatchSendingService.removeById(id));
 	}
+
+	@ApiOperation(value = "更新消息状态", notes = "客服群发- 传入id")
+	@ApiImplicitParams({
+			@ApiImplicitParam(name = "id", value = "主键Id", dataType = "long"),
+			@ApiImplicitParam(name = "sendStatus", value = "发送状态", dataType = "String"),
+	})
+	@PostMapping("/status/{id}")
+	public HttpResponseResult<Boolean> status(@PathVariable("id") Long id, EImSendStatus sendStatus) {
+
+		if (Objects.isNull(sendStatus)) {
+			throw new BizException("发送状态不能为空");
+		}
+
+		// 更新群发消息状态
+		customerServiceBatchSendingService.status(id, sendStatus);
+
+		return HttpResponseResult.succeed(true);
+	}
+
+	@ApiOperation(value = "立即发送", notes = "客服群发- 传入id")
+	@ApiImplicitParams({
+			@ApiImplicitParam(name = "id", value = "主键Id", dataType = "long"),
+	})
+	@PostMapping("/send/{id}")
+	public HttpResponseResult<Boolean> send(@PathVariable("id") Long id) {
+
+		// 更新群发消息状态
+		//customerServiceBatchSendingService.status(id, sendStatus);
+
+		return HttpResponseResult.succeed(true);
+	}
 }

+ 8 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CustomerServiceBatchSendingService.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.entity.CustomerServiceBatchSending;
+import com.yonge.cooleshow.biz.dal.enums.im.EImSendStatus;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceBatchSendingWrapper;
 
 /**
@@ -39,5 +40,11 @@ public interface CustomerServiceBatchSendingService extends IService<CustomerSer
      * @return Boolean
      */
      Boolean update(CustomerServiceBatchSendingWrapper.CustomerServiceBatchSending customerServiceBatchSending);
-     
+
+    /**
+     * 更新消息状态
+     * @param id 消息Id
+     * @param sendStatus EImSendStatus
+     */
+    void status(Long id, EImSendStatus sendStatus);
 }

+ 32 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceBatchSendingServiceImpl.java

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.biz.dal.entity.CustomerServiceBatchSending;
 import com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.im.EImSendStatus;
 import com.yonge.cooleshow.biz.dal.mapper.CustomerServiceBatchSendingMapper;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceBatchSendingService;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceReceiveService;
@@ -180,4 +181,35 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
 
         return true;
     }
+
+    /**
+     * 更新消息状态
+     *
+     * @param id         消息Id
+     * @param sendStatus EImSendStatus
+     */
+    @Override
+    public void status(Long id, EImSendStatus sendStatus) {
+
+        CustomerServiceBatchSending record = getById(id);
+        if (Objects.isNull(record)) {
+            throw new BizException("无效的请求Id");
+        }
+
+        // 校验消息发送状态
+        if (EImSendStatus.SEND == record.getSendStatus()) {
+            throw new BizException("当前消息已发送");
+        }
+
+        // 当前群发消息状态一致
+        if (record.getSendStatus() == sendStatus) {
+            throw new BizException("群发消息状态一致");
+        }
+
+        // 更新群发消息状态
+        lambdaUpdate()
+                .eq(CustomerServiceBatchSending::getId, id)
+                .set(CustomerServiceBatchSending::getSendStatus, sendStatus)
+                .update();
+    }
 }