| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.vo.XpTaskVO; |
| | | import com.xiaopeng.api.vo.pushMessage.SendCouponMessageVo; |
| | | import com.xiaopeng.api.vo.pushMessage.UpdateEndAddStatusVo; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.controller.BaseController; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 推送优惠券消息 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/websocket/coupon/sendCouponMessage") |
| | | public R<?> sendCouponMessage(@RequestBody SendCouponMessageVo vo){ |
| | | String message = vo.getMessage(); |
| | | if (message.trim().isEmpty()) { |
| | | return R.fail("消息内容不能为空"); |
| | | } |
| | | String appUserId = vo.getAppUserId().toString(); |
| | | if (appUserId.trim().isEmpty()) { |
| | | return R.fail("用户id不能为空"); |
| | | } |
| | | int deviceCount = webSocketUserService.sendMessageToUser(appUserId, message); |
| | | if (deviceCount > 0) { |
| | | return R.ok("消息发送成功,发送到 " + deviceCount + " 个设备"); |
| | | } else { |
| | | return R.fail("用户不在线或发送失败"); |
| | | } |
| | | } |
| | | } |