| | |
| | | package com.ks.daylucky; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.app.util.AlipayAppUtil; |
| | | import com.ks.daylucky.exception.UserMsgException; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.service.UserMsgService; |
| | | import com.ks.daylucky.service.impl.AppManager; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import com.ks.daylucky.util.factory.LuckyMsgContentFactory; |
| | | import com.ks.daylucky.util.factory.UserMsgFactory; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.remote.service.LuckyActivityService; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.yeshi.utils.alipay.AlipayXcxUtil; |
| | | import org.yeshi.utils.exception.AlipayXcxException; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | @SpringBootTest |
| | | public class MsgTest { |
| | | @Resource |
| | | private UserMsgService userMsgService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private AppManager appManager; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Test |
| | | public void addMsg() { |
| | | try { |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(4L, LuckyMsgContentFactory.createJoinSuccess(7L))); |
| | | userMsgService.addMsg(UserMsgFactory.createLuckyMsg(4L, LuckyMsgContentFactory.createJoinSuccess(7L, new Date()))); |
| | | } catch (UserMsgException e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void sendTemplateMsg() { |
| | | //如果是中奖消息要发送模板消息 |
| | | UserInfo userInfo = userInfoService.getUserDetail(4L); |
| | | AppInfo appInfo = appManager.getAppDetail(userInfo.getAppId()); |
| | | LuckyActivity activity = luckyActivityService.getActivity(10029L); |
| | | try { |
| | | AlipayXcxUtil.sendTemplateMsg(AlipayAppUtil.getAlipayAppInfo(appInfo.getAlipayInfo()), "677118be3b914b98be8cc58d4addc0db", "pages/activity-detail/activity-detail", userInfo.getAlipayUid(), "123", "中奖啦,快去看看你中了什么大奖", ActivityUtil.getActivityDateNumber(activity.getId(), activity.getCreateTime())); |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } catch (AlipayXcxException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |