123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- package com.zhongzheng.controller.cmmon;
- import cn.hutool.core.lang.Validator;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.zhongzheng.common.core.controller.BaseController;
- import com.zhongzheng.common.core.domain.AjaxResult;
- import com.zhongzheng.common.core.page.TableDataInfo;
- import com.zhongzheng.common.core.redis.RedisCache;
- import com.zhongzheng.common.utils.DateUtils;
- import com.zhongzheng.common.utils.ServletUtils;
- import com.zhongzheng.common.utils.ToolsUtils;
- import com.zhongzheng.framework.web.service.WxLoginService;
- import com.zhongzheng.modules.activity.vo.ActivityGoodsPriceVo;
- import com.zhongzheng.modules.base.bo.ConfigQueryBo;
- import com.zhongzheng.modules.course.bo.CourseQueryBo;
- import com.zhongzheng.modules.course.bo.CourseTopicGoodsQueryBo;
- import com.zhongzheng.modules.course.service.ICourseService;
- import com.zhongzheng.modules.course.service.ICourseTopicService;
- import com.zhongzheng.modules.course.vo.CourseTopicGoodsVo;
- import com.zhongzheng.modules.course.vo.CourseTopicVo;
- import com.zhongzheng.modules.course.vo.CourseUserVo;
- import com.zhongzheng.modules.data.domain.DataWxTpClick;
- import com.zhongzheng.modules.data.service.IDataWxTpClickService;
- import com.zhongzheng.modules.distribution.bo.DistributionActivityGoodsQueryBo;
- import com.zhongzheng.modules.distribution.service.IDistributionActivityGoodsService;
- import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
- import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
- import com.zhongzheng.modules.goods.bo.DistributionGoodsBo;
- import com.zhongzheng.modules.goods.service.IGoodsSpecTemplateService;
- import com.zhongzheng.modules.goods.vo.GoodsSpecTemplateVo;
- import com.zhongzheng.modules.goods.vo.GoodsUserVo;
- import com.zhongzheng.modules.goods.vo.GoodsVo;
- import com.zhongzheng.modules.order.domain.Printer;
- import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
- import com.zhongzheng.modules.system.service.ISysConfigService;
- import com.zhongzheng.modules.system.service.ISysTenantService;
- import com.zhongzheng.modules.wx.bo.WxInfoBo;
- import com.zhongzheng.modules.wx.bo.WxInfoQuery;
- import com.zhongzheng.modules.wx.bo.WxServerBody;
- import com.zhongzheng.modules.wx.domain.*;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.text.ParseException;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 课程Controller
- *
- * @author hjl
- * @date 2021-10-09
- */
- @Api(value = "游客访问接口", tags = {"游客访问接口"})
- @RequiredArgsConstructor(onConstructor_ = @Autowired)
- @RestController
- @RequestMapping("/app/common/")
- public class CommonController extends BaseController {
- private final ICourseService iCourseService;
- private final WxLoginService wxLoginService;
- private final ISysConfigService configService;
- private final IDistributionSellerService iDistributionSellerService;
- @Autowired
- private RedisCache redisCache;
- private final ICourseTopicService iCourseTopicService;
- private final IGoodsSpecTemplateService iGoodsSpecTemplateService;
- private final ISysTenantService iSysTenantService;
- private final IDataWxTpClickService iDataWxTpClickService;
- private final IDistributionActivityGoodsService iDistributionActivityGoodsService;
- /**
- * 获取微信小程序信息(网页跳转小程序)
- */
- @ApiOperation("获取微信小程序信息(网页跳转小程序)")
- @GetMapping("/get/wx/info")
- public AjaxResult<WxInfoBo> getWxInfo(WxInfoQuery query) {
- return AjaxResult.success(wxLoginService.getWxInfo(query));
- }
- /**
- * 获取小程序首页链接
- */
- @ApiOperation("获取小程序首页链接")
- @GetMapping("/get/small/link")
- public AjaxResult<Void> getWxSmallLink() {
- return AjaxResult.success(wxLoginService.getWxSmallLink());
- }
- /**
- * 获取商品专题页指定商品信息
- */
- @ApiOperation("获取商品专题页指定商品信息")
- @GetMapping("/get/goodsInfo/{topicId}")
- public AjaxResult<CourseTopicVo> getGoodsInfo(@PathVariable("topicId") Integer topicId) {
- return AjaxResult.success(iCourseTopicService.getGoodsInfo(topicId));
- }
- /**
- * 获取商品规格模板信息
- */
- @ApiOperation("获取商品规格模板信息")
- @GetMapping("/spec/{specTemplateId}")
- public AjaxResult<GoodsSpecTemplateVo> getSpecTemplate(@PathVariable("specTemplateId")Long specTemplateId) {
- return AjaxResult.success(iGoodsSpecTemplateService.queryById(specTemplateId));
- }
- /**
- * 获取商品规格模板信息
- */
- @ApiOperation("获取商品规格模板信息")
- @GetMapping("/distribution/spec")
- public AjaxResult<GoodsSpecTemplateVo> getDistributionSpec(DistributionGoodsBo bo) {
- return AjaxResult.success(iGoodsSpecTemplateService.getDistributionSpec(bo));
- }
- /**
- * 获取规格属性值对应的商品信息
- */
- @ApiOperation("获取规格属性值对应的商品信息")
- @GetMapping("/attr/goods")
- public AjaxResult<GoodsVo> getSpecTemplate(@RequestParam("specTemplateId")Long specTemplateId,@RequestParam("specAttrIds")String specAttrIds) {
- GoodsVo vo = iGoodsSpecTemplateService.getSpecTemplate(specTemplateId,specAttrIds);
- return AjaxResult.success(vo);
- }
- /**
- * 获取专题页组合班级商品
- */
- @ApiOperation("获取专题页组合班级商品")
- @GetMapping("/get/goodsList")
- public AjaxResult<List<CourseTopicGoodsVo>> getGoodsList(CourseTopicGoodsQueryBo bo) {
- return AjaxResult.success(iCourseTopicService.getGoodsList(bo));
- }
- /**
- * 查询课程列表
- */
- @ApiOperation("查询商品下的课程列表")
- @GetMapping("/courseList")
- public TableDataInfo<CourseUserVo> courseList(CourseQueryBo bo) {
- startPage();
- List<CourseUserVo> list = iCourseService.courseList(bo);
- return getDataTable(list);
- }
- /**
- * 查询课程列表
- */
- @ApiOperation("查询用户拥有的商品")
- @GetMapping("/goodsList")
- public TableDataInfo<GoodsUserVo> goodsList(CourseQueryBo bo) {
- startPage();
- List<GoodsUserVo> list = iCourseService.goodsList(bo);
- return getDataTable(list);
- }
- @ApiOperation("查询用户拥有的商品")
- @GetMapping("/test")
- public AjaxResult<Integer> test(CourseQueryBo bo) throws InterruptedException, ParseException {
- return AjaxResult.success(Printer.num);
- }
- @ApiOperation("小程序配置")
- @GetMapping("/config")
- public AjaxResult<Map<String,Object>> config(ConfigQueryBo bo) {
- Map<String,Object> map = new HashMap<>();
- map.put("hide",false);
- if(Validator.isNotEmpty(bo.getVersion())){
- String hideVersion = configService.selectConfigByKey("version.hide");
- if(bo.getVersion().equals(hideVersion)){
- map.put("hide",true);
- }
- }
- return AjaxResult.success(map);
- }
- @ApiOperation("获取微信参数")
- @GetMapping("/wx/config")
- public AjaxResult<Map<String,Object>> wxConfig() {
- Map<String,Object> map = new HashMap<>();
- String smallAppId = configService.selectConfigByKey("wx.small.appid");
- String gzhAppId = configService.selectConfigByKey("wx.gzh.appid");
- map.put("smallAppId",smallAppId);
- map.put("gzhAppId",gzhAppId);
- return AjaxResult.success(map);
- }
- @ApiOperation("登录双重验证")
- @GetMapping("/dual_auth")
- public AjaxResult<String> dual_auth() {
- String dualAuth = configService.selectConfigByKey("login.dual.auth");
- return AjaxResult.success("成功",dualAuth);
- }
- /**
- * 公众号服务接口
- */
- @ApiOperation("公众号服务接口")
- @GetMapping("/wxGzhServer")
- public String wxGzhServer(WxServerBody bo) {
- try {
- String token = "511A23101c826G90T1";
- String EncodingAESKey = "ybzse4DNAMj9oGzZ9kQqOX0F7nKjebGZ3xNesVFInPP";
- String echostr = bo.getEchostr();
- if (ToolsUtils.checkGzhServerSignature(token,bo.getSignature(), bo.getTimestamp(), bo.getNonce())) {
- return echostr;
- }
- } catch (Exception e) {
- //验证公众号token失败
- }
- return null;
- }
- @ApiOperation("公众号服务接口")
- @PostMapping("/wxGzhServer")
- public String wxGzhServer(@RequestBody String xmlData) {
- // 将xml格式的数据,转换为 AllMessage 对象
- AllMessage allMessage = MessageUtil.xmlToAllMessage(xmlData);
- String TenantId = "867735392558919680";
- ServletUtils.getRequestAttributes().getResponse().setHeader("TenantId", TenantId);
- // 是否是文本消息类型
- if (allMessage.getMsgType().equals(MessageTypeEnum.MSG_TEXT.getMsgType())) {
- // 自动回复用户所发送的文本消息
- // return MessageUtil.autoReply(allMessage, ContentEnum.CONTENT_PREFIX.getContent() + allMessage.getContent());
- return "";
- }
- // 是否是事件推送类型
- else if (allMessage.getMsgType().equals(MessageTypeEnum.MSG_EVENT.getMsgType())) {
- // 是否为订阅事件,即公众号被关注时所触发的事件
- if (EventType.EVENT_SUBSCRIBE.getEventType().equals(allMessage.getEvent())) {
- // System.out.println("关注");
- String openId = allMessage.getFromUserName();
- wxLoginService.subGzh(openId);
- // 自动回复欢迎语
- return MessageUtil.autoReply(allMessage, ContentEnum.CONTENT_SUBSCRIBE.getContent());
- }
- else if (EventType.EVENT_UNSUBSCRIBE.getEventType().equals(allMessage.getEvent())) {
- String openId = allMessage.getFromUserName();
- wxLoginService.unsubGzh(openId);
- // System.out.println("取消关注");
- }
- } else {
- // 暂不支持文本以外的消息回复
- return MessageUtil.autoReply(allMessage, ContentEnum.CONTENT_NONSUPPORT.getContent());
- }
- return MessageUtil.autoReply(allMessage, ContentEnum.CONTENT_NONSUPPORT.getContent());
- }
- /**
- * 获取企业ID
- */
- @ApiOperation("获取企业ID")
- @GetMapping("/findTenantId")
- public AjaxResult<String> findTenantId(SysTenantQueryBo bo) {
- Long tenantId = iSysTenantService.findTenantId(bo);
- if(Validator.isNotEmpty(tenantId)){
- return AjaxResult.success("成功",tenantId.toString());
- }else{
- if(Validator.isNotEmpty(bo.getHostH5())&&bo.getHostH5().equals("120.79.166.78:19012")){
- return AjaxResult.success("成功","867735392558919680");
- }
- if(Validator.isNotEmpty(bo.getHostLive())&&bo.getHostLive().equals("120.79.166.78:19012")){
- return AjaxResult.success("成功","867735392558919680");
- }
- if(Validator.isNotEmpty(bo.getHostPc())&&bo.getHostPc().equals("120.79.166.78:19012")){
- return AjaxResult.success("成功","867735392558919680");
- }
- if(Validator.isNotEmpty(bo.getHostH5Seller())&&bo.getHostH5Seller().equals("120.79.166.78:19012")){
- return AjaxResult.success("成功","867735392558919680");
- }
- return AjaxResult.error("失败",null);
- }
- }
- @ApiOperation("移动端配置参数")
- @GetMapping("/mobileConfig")
- public AjaxResult<Map<String,Object>> mobileConfig(ConfigQueryBo bo) {
- Map<String,Object> map = new HashMap<>();
- String json = configService.selectConfigByKey("home.mobile");
- map.put("mobileConfig",json);
- return AjaxResult.success(map);
- }
- /**
- * 领取题库活动校验
- */
- @ApiOperation("领取题库活动校验")
- @GetMapping("/check")
- public AjaxResult<Void> checkTime() {
- return toAjax(iCourseService.checkTime()? 1 : 0);
- }
- /**
- * 领取题库活动记录
- */
- @ApiOperation("领取题库活动记录")
- @GetMapping("/save/activity/record/{crowdType}")
- public AjaxResult<Void> saveActivityRecord(@PathVariable("crowdType") Integer crowdType) {
- DataWxTpClick dataWxTpClick = new DataWxTpClick();
- dataWxTpClick.setCrowdType(crowdType);
- dataWxTpClick.setCreateTime(DateUtils.getNowTime());
- dataWxTpClick.setType(2);
- dataWxTpClick.setStatus(1);
- dataWxTpClick.setInformId(0L);
- dataWxTpClick.setUpdateTime(DateUtils.getNowTime());
- return toAjax(iDataWxTpClickService.save(dataWxTpClick)? 1 : 0);
- }
- @ApiOperation("通过分享code查询业务员用户信息")
- @GetMapping("/distribution/getInfoByShareCode")
- public AjaxResult<DistributionSellerVo> getInfoByShareCode(String shareCode)
- {
- DistributionSellerVo vo = iDistributionSellerService.queryByShareCode(shareCode);
- vo.setNull();
- String jsonStr = configService.selectConfigByKey("home.header");
- JSONObject objectJson = JSON.parseObject(jsonStr);
- vo.setTenantName(String.valueOf(objectJson.get("companyName")));
- return AjaxResult.success(vo);
- }
- @ApiOperation("获取分销活动商品列表")
- @GetMapping("/distribution/getGoodsList")
- public TableDataInfo<ActivityGoodsPriceVo> distributionGoodsList(DistributionActivityGoodsQueryBo bo)
- {
- startPage();
- List<ActivityGoodsPriceVo> list = iDistributionActivityGoodsService.getGoodsList(bo);
- return getDataTable(list);
- }
- }
|