| | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.tcm.training.admin.agent.entity.ProvincialAgent; |
| | | import com.tcm.training.admin.agent.mapper.ProvincialAgentMapper; |
| | | import com.tcm.training.admin.app.auth.service.AppAuthSessionService; |
| | | import com.tcm.training.admin.app.home.vo.AppVzanLiveEntryVO; |
| | | import com.tcm.training.admin.app.user.service.AppUserCenterService; |
| | | import com.tcm.training.admin.app.user.vo.AppUserCenterVO; |
| | |
| | | @Service |
| | | public class AppVzanLiveEntryService { |
| | | private static final String VZAN_AUTH_SECRET = "2b4fefe91d8cba50"; |
| | | private static final String VZAN_WEB_PAY_UA = "webchatPay/wx074c1f0cf5a0ecf4 InAppPay"; |
| | | private static final int USER_STATUS_ENABLED = 1; |
| | | |
| | | private final LiveRoomSettingService liveRoomSettingService; |
| | | private final UserMapper userMapper; |
| | | private final ClinicMapper clinicMapper; |
| | | private final ProvincialAgentMapper provincialAgentMapper; |
| | | private final AppAuthSessionService appAuthSessionService; |
| | | |
| | | public AppVzanLiveEntryService(LiveRoomSettingService liveRoomSettingService, |
| | | UserMapper userMapper, |
| | | ClinicMapper clinicMapper, |
| | | ProvincialAgentMapper provincialAgentMapper) { |
| | | ProvincialAgentMapper provincialAgentMapper, |
| | | AppAuthSessionService appAuthSessionService) { |
| | | this.liveRoomSettingService = liveRoomSettingService; |
| | | this.userMapper = userMapper; |
| | | this.clinicMapper = clinicMapper; |
| | | this.provincialAgentMapper = provincialAgentMapper; |
| | | this.appAuthSessionService = appAuthSessionService; |
| | | } |
| | | |
| | | public AppVzanLiveEntryVO createEntry(Long userId) { |
| | | Long sessionUserId = appAuthSessionService.getLoginUserId(); |
| | | log.info("微赞直播入口userId对比,请求体userId={},会话userId={},是否一致={}", |
| | | userId, sessionUserId, java.util.Objects.equals(userId, sessionUserId)); |
| | | LiveRoomSettingVO setting = liveRoomSettingService.current(); |
| | | String liveRoomUrl = setting == null ? null : StrUtil.trim(setting.getLiveRoomUrl()); |
| | | validateLiveRoomUrl(liveRoomUrl); |
| | |
| | | JSONObject payload = new JSONObject(); |
| | | payload.set("tuid", user.getId()); |
| | | payload.set("followPhone", followPhone); |
| | | payload.set("third_ts", System.currentTimeMillis()); |
| | | payload.set("third_ts", System.currentTimeMillis() + 5000); |
| | | payload.set("avatar", StrUtil.trim(avatar)); |
| | | log.info("微赞入口参数已生成,{}", JSONUtil.toJsonStr(payload)); |
| | | |
| | |
| | | .encode(StandardCharsets.UTF_8) |
| | | .toUriString(); |
| | | log.info("微赞直播生成URL: {}", entryUrl); |
| | | return new AppVzanLiveEntryVO(entryUrl); |
| | | return new AppVzanLiveEntryVO(entryUrl, VZAN_WEB_PAY_UA); |
| | | } |
| | | |
| | | private String resolveFollowPhone(Long clinicId) { |
| | |
| | | String wechatAvatar = user == null ? null : StrUtil.trim(user.getWechatAvatar()); |
| | | return StrUtil.isNotBlank(wechatAvatar) ? wechatAvatar : ""; |
| | | } |
| | | } |
| | | } |