package com.caimei.controller.wechat; import com.alibaba.fastjson.JSONObject; import com.caimei.annotation.CurrentUser; import com.caimei.aop.IpSave; import com.caimei.model.ResponseJson; import com.caimei.model.dto.ProductSaveDto; import com.caimei.model.po.CmBrandAuthPo; import com.caimei.model.po.SysUser; import com.caimei.model.vo.*; import com.caimei.service.auth.*; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * @author Aslee */ @Api(tags = "微信认证数据API") @Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/wx/auth") public class WxAuthApi { private final AuthClubService authClubService; private final AuthService authService; private final AuthProductService authProductService; private final DoctorService doctorService; private final ShopService shopService; @ApiOperation("供应商信息") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId") }) @GetMapping("/shop/info") public ResponseJson getWxShopInfo(Integer authUserId, String appId) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authClubService.getWxShopInfo(authUserId, appId); } @ApiOperation("已认证机构列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "lngAndLat", required = false, value = "用户当前经纬度"), @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"), @ApiImplicitParam(name = "provinceId", required = false, value = "省id"), @ApiImplicitParam(name = "cityId", required = false, value = "市id"), @ApiImplicitParam(name = "townId", required = false, value = "区id"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @IpSave(saveName = "已认证机构列表",saveParams = true) @GetMapping("/club/list") public ResponseJson> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId, Integer cityId, Integer townId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authClubService.getWxClubList(authUserId, appId, lngAndLat, authParty, provinceId, cityId, townId, pageNum, pageSize); } @ApiOperation("明星机构列表") @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id") @GetMapping("/club/star/list") public ResponseJson> getStarClubList(Integer authUserId) { if (null == authUserId) { return ResponseJson.error("参数异常,供应商用户id不能为空", null); } return authClubService.getWxStarClubList(authUserId); } @ApiOperation("已认证机构详情") @ApiImplicitParam(required = false, name = "authId", value = "正品联盟机构Id") @IpSave(saveName = "已认证机构详情",saveParams = true) @GetMapping("/club/details") public ResponseJson getWxClubDetails(Integer authId) { return authClubService.getWxClubDetails(authId); } @ApiOperation("设备分类列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @GetMapping("/product/type/list") public ResponseJson> getWxProductTypeList(Integer authUserId, String appId, String name, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authProductService.getWxProductTypeList(authUserId, appId, name, pageNum, pageSize); } @ApiOperation("认证商品列表") @ApiImplicitParams({ @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1已上线设备列表 2设备认证记录列表"), @ApiImplicitParam(name = "authId", required = false, value = "机构id"), @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"), @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"), @ApiImplicitParam(name = "snCode", required = false, value = "sn码"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @IpSave(saveName = "认证商品列表",saveParams = true) @GetMapping("/product/list") public ResponseJson> getWxProductList(Integer listType, Integer authId, Integer productTypeId, String authParty, String snCode, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { return authProductService.getWxProductList(listType, authId, authParty, productTypeId, snCode, pageNum, pageSize); } /** * 获取授权商品回显数据 */ @ApiOperation("授权商品回显数据") @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id") @GetMapping("/product/form/data") public ResponseJson getProductFormData(Integer relationId) { return authProductService.getProductFormData(relationId); } /** * 品牌列表 * * @return AuthVo */ @ApiOperation("品牌列表") @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false) @GetMapping("/shop/info/list") public ResponseJson> getShopInfoList(Integer authUserId) { return shopService.getShopInfoList(authUserId); } /** * 添加/编辑授权商品 * @param productSaveDto { * productId 授权商品id * authId 授权id * infoId 品牌信息id * productTypeId 设备分类id * snCode 商品SN码 * productImage 商品图片 * purchaseWay 购买渠道 * invoiceImage 发票图片 * status 上线状态:0已下线,1已上线,2待上线 * createBy 创建人id * source 来源:1供应商保存,2机构保存 * paramList 商品参数列表 * } */ @ApiOperation("添加/编辑授权商品") @PostMapping("/product/save") public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException { return authProductService.saveProduct(productSaveDto); } /** * 授权机构回显数据 */ @ApiOperation("授权机构回显数据") @ApiImplicitParam(name = "authId", required = true, value = "机构用户id") @GetMapping("/form/data") public ResponseJson getAuthFormData(Integer authId) { return authService.getAuthFormData(authId); } @ApiOperation("添加/编辑授权") @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" + "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" + "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" + "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" + "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+ "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true) @PostMapping("/save") public ResponseJson saveAuth(@RequestBody String params) { JSONObject paramsMap = JSONObject.parseObject(params); Integer authId = paramsMap.getInteger("authId"); Integer authUserId = paramsMap.getInteger("authUserId"); Integer provinceId = paramsMap.getInteger("provinceId"); Integer cityId = paramsMap.getInteger("cityId"); Integer townId = paramsMap.getInteger("townId"); String address = paramsMap.getString("address"); String lngAndLat = paramsMap.getString("lngAndLat"); String mobile = paramsMap.getString("mobile"); String userMobile = paramsMap.getString("userMobile"); Integer firstClubType = paramsMap.getInteger("firstClubType"); Integer secondClubType = paramsMap.getInteger("secondClubType"); String medicalLicenseImage = paramsMap.getString("medicalLicenseImage"); Integer empNum = paramsMap.getInteger("empNum"); String logo = paramsMap.getString("logo"); Integer customFlag = paramsMap.getInteger("customFlag"); String remarks = paramsMap.getString("remarks"); List bannerList = (List) paramsMap.get("bannerList"); String authParty = paramsMap.getString("authParty"); Integer createBy = paramsMap.getInteger("createBy"); String linkMan = paramsMap.getString("linkMan"); String linkMobile = paramsMap.getString("linkMobile"); /* 组装授权数据 */ CmBrandAuthPo auth = new CmBrandAuthPo(); auth.setId(authId); auth.setAuthUserId(authUserId); auth.setAuthParty(authParty); auth.setProvinceId(provinceId); auth.setCityId(cityId); auth.setTownId(townId); auth.setAddress(address); auth.setCustomFlag(customFlag); auth.setRemarks(remarks); if (StringUtils.isEmpty(lngAndLat)) { return ResponseJson.error("参数异常,经纬度不能为空"); } String[] split = lngAndLat.split(","); auth.setLng(new BigDecimal(split[0])); auth.setLat(new BigDecimal(split[1])); auth.setMobile(mobile); auth.setUserMobile(userMobile); auth.setFirstClubType(firstClubType); auth.setSecondClubType(secondClubType); auth.setMedicalLicenseImage(medicalLicenseImage); auth.setEmpNum(empNum); auth.setLogo(logo); auth.setCreateBy(createBy); auth.setLinkMan(linkMan); auth.setLinkMobile(linkMobile); // 机构用户编辑授权 return authService.saveAuth(auth, bannerList, false, 2); } @ApiOperation("设备分类下拉框列表") @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id") @GetMapping("/product/type/select") public ResponseJson> getProductTypeSelectList(Integer authUserId) { if (null == authUserId) { return ResponseJson.error("参数异常,供应商用户id不能为空", null); } return authProductService.getProductTypeSelectList(authUserId); } @ApiOperation("已认证商品详情") @ApiImplicitParam(required = false, name = "productId", value = "正品联盟商品Id") @GetMapping("/product/details") public ResponseJson getAuthProductDetails(Integer productId) { return authProductService.getAuthProductDetails(productId); } @ApiOperation("关联设备获取设备信息") @ApiImplicitParams({ @ApiImplicitParam(name = "productId", required = false, value = "设备id"), @ApiImplicitParam(name = "snCode", required = false, value = "sn码") }) @GetMapping("/product/info") public ResponseJson getProductInfo(Integer productId, String snCode) { if (null == productId && null == snCode) { return ResponseJson.error("设备id和sn码不能同时为空", null); } return authProductService.getProductInfo(productId, snCode); } @ApiOperation("已认证医师列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"), @ApiImplicitParam(name = "doctorName", required = false, value = "医师名称"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @GetMapping("/doctor/list") public ResponseJson> getWxDoctorList(Integer authUserId, String appId, Integer doctorType, String doctorName, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return doctorService.getWxDoctorList(authUserId, appId, doctorType, doctorName, pageNum, pageSize); } @ApiOperation("已认证医师详情") @ApiImplicitParam(required = false, name = "doctorId", value = "正品联盟医师Id") @GetMapping("/doctor/details") public ResponseJson getAuthDoctorDetails(Integer doctorId) { return doctorService.getAuthDoctorDetails(doctorId); } @ApiOperation("获取机构下所有的设备信息") @GetMapping("/get/product/list") public ResponseJson> getPronductInfo(Integer authId,Integer authUserId){ if (null == authUserId) { return ResponseJson.error("用户信息异常", null); } return authProductService.getPronductInfo(authId,authUserId); } /** * 保存视频信息 * @return */ @PostMapping("/save/video/info") public ResponseJson saveVideoInfo(@RequestBody String params){ JSONObject jsonObject=JSONObject.parseObject(params); // //验证用户是否可以发布视频 // //是否为机构用户 Integer authId=jsonObject.getInteger("authId"); // boolean flagAtuhId= authService.getauthUserId(authId); // if(flagAtuhId){ // return ResponseJson.error("-1","由于您未认证机构,无法参与!"); // } // //用户是否已经发不过视频 String userName=jsonObject.getString("userName"); // Boolean flaguserName=authService.getuserName(userName); // if(!flaguserName){ // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!"); // } // //判断是否在活动时间内 // Date date=new Date(); // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // String releaseTime = sf.format(date).replace("T", ""); // boolean flagReleaseTime= authService.checkActivityTime(releaseTime); // if(flagReleaseTime){ // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!"); // } String title=jsonObject.getString("title"); String ossName=jsonObject.getString("ossName"); String cover=jsonObject.getString("cover"); String ossUrl=jsonObject.getString("ossUrl"); Integer authUserId=jsonObject.getInteger("authUserId"); ChallengeRoundVo cr=new ChallengeRoundVo(); cr.setUserName(userName); cr.setCover(cover); cr.setOssName(ossName); cr.setOssUrl(ossUrl); cr.setTitle(title); cr.setAuthId(authId); cr.setAuthUserId(authUserId); return authService.saveVideoInfo(cr); } /** * 获取已发布视频 * @param sysUser * @param status * @param clubUserName * @param cursor * @param count * @return */ @GetMapping("/get/published/video/list") public ResponseJson> getPublishedVideoList(@CurrentUser SysUser sysUser,Integer status,String clubUserName,Integer cursor,Integer count,@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,Integer authUserId){ // if (null == sysUser) { // return ResponseJson.error("用户信息异常", null); // } // // 获取供应商用户id // Integer userIdentity = sysUser.getUserIdentity(); // Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null; // if (null == authUserId) { // return ResponseJson.error("供应商用户id不能为空", null); // } if(count==null){ count=10; } if(cursor==null){ cursor=0; } return authService.getPublishedVideoList(clubUserName,status,cursor,count,pageNum,pageSize,authUserId); } /** * 验证视频是否符合发布条件 * @param params * @return */ @PostMapping("/check/video/info") public ResponseJson checkVideoInfo(@RequestBody String params){ JSONObject jsonObject=JSONObject.parseObject(params); //验证用户是否可以发布视频 //是否为机构用户 // Integer authId=jsonObject.getInteger("authId"); // boolean flagAtuhId= authService.getauthUserId(authId); // if(flagAtuhId){ // return ResponseJson.success("0",null); // return ResponseJson.error("-1","由于您未认证机构,无法参与!"); // } //用户是否已经发过视频 String userName=jsonObject.getString("userName"); Integer authUserId=jsonObject.getInteger("authUserId"); Boolean flaguserName=authService.getuserName(userName); ChallengeRoundVo challengeActivityVo=new ChallengeRoundVo(); ResponseJson activitty = authService.getActivitty(authUserId); ChallengeActivityVo challe = activitty.getData(); if(challe!=null){ challengeActivityVo.setActivityState(challe.getActivityState()); } String releaseTime = authService.getReleaseTime(userName); if(!flaguserName){ if(challe.getStartTime().compareTo(releaseTime)<0&&challe.getEndTime().compareTo(releaseTime)>0){ challengeActivityVo.setReleaseStatus(1); }else{ challengeActivityVo.setReleaseStatus(0); } return ResponseJson.success(challengeActivityVo); // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!"); }else{ challengeActivityVo.setReleaseStatus(0); return ResponseJson.success(challengeActivityVo); } //判断是否在活动时间内 // Date date=new Date(); // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // String releaseTime = sf.format(date).replace("T", ""); // boolean flagReleaseTime= authService.checkActivityTime(releaseTime); // if(flagReleaseTime){ // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!"); // } } /** * 判断活动开启状态 * @return */ @GetMapping("/get/activitty") public ResponseJson getActivitty(Integer authUserId){ return authService.getActivitty(authUserId); } //--------------------------------------------挑战赛1.7.7(ROSS)------------------------------------------------------------------------------------------------- /** * 新增参赛机构信息 * @return */ @PostMapping("save/ross/info") public ResponseJson saveRossInfo(@CurrentUser SysUser sysUser, @RequestBody String params) { // if (null == sysUser) { // return ResponseJson.error("用户信息异常", null); // } // // 获取供应商用户id // Integer userIdentity = sysUser.getUserIdentity(); // Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null; // if (null == authUserId) { // return ResponseJson.error("供应商用户id不能为空", null); // } JSONObject jsonObject = JSONObject.parseObject(params); String mobile=jsonObject.getString("mobile"); String licenseOssUrl=jsonObject.getString("licenseOssUrl"); String licenseOssName=jsonObject.getString("licenseOssName"); Integer authId=jsonObject.getInteger("authId"); Integer authuser=jsonObject.getInteger("authUserId"); // Integer clubUserId=jsonObject.getInteger("clubUserId"); //判断该账号是否已经参赛 List infoByUserName = authService.getInfoByUserName(mobile); if(null !=infoByUserName&&infoByUserName.size()>0){ return ResponseJson.success("您已报名",infoByUserName); } RossChallengeRoundVo rossChallengeRoundVo=new RossChallengeRoundVo(); // if(null!=authUserId){ // rossChallengeRoundVo.setAuthUserId(authUserId); // }else{ rossChallengeRoundVo.setAuthUserId(authuser); // } rossChallengeRoundVo.setAuthUserId(authuser); rossChallengeRoundVo.setUserName(mobile); rossChallengeRoundVo.setAuthId(authId); rossChallengeRoundVo.setLicenseOssUrl(licenseOssUrl); rossChallengeRoundVo.setLicenseOssName(licenseOssName); // rossChallengeRoundVo.setClubUserId(clubUserId); if(StringUtils.isEmpty(licenseOssUrl)&&StringUtils.isEmpty(licenseOssName)){ rossChallengeRoundVo.setAuthenticationStatus(1); }else{ rossChallengeRoundVo.setAuthenticationStatus(0); } rossChallengeRoundVo.setContestStatus(1); Date date=new Date(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // String format = sf.format(date); rossChallengeRoundVo.setContestTime(new java.sql.Timestamp(date.getTime())); return authService.saveRossInfo(rossChallengeRoundVo); } /** * 验证用户是否已经报名 * @param mobile * @return */ @GetMapping("/check/contest/info") public ResponseJson checkContestedInfo(String mobile){ return authService.checkContestedInfo(mobile); } /** * 获取已报名信息列表 * @return */ @GetMapping("/get/contested/info") public ResponseJson> getcontestedInfo(Integer authUserId){ return authService.getcontestedInfo(authUserId); } /** * 根据手机号码查询该机构视频列表 * @param mobile 登录账号 * @return */ @GetMapping("/get/video/username") public ResponseJson> getVideoByUsername(String mobile,Integer clubUserId){ return authService.getVideoByUsername(mobile,clubUserId); } /** * 查询视频列表 * @param mobileOrAuthpart 电话号码或者机构名称 * @return */ @GetMapping("/get/video/all") public ResponseJson> getVideoAll(String mobileOrAuthpart,Integer clubUserId,Integer authUserId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){ return authService.getVideoAll(mobileOrAuthpart,clubUserId,authUserId,pageNum,pageSize); } /** * 验证机构是否已经上传了3个视频(点击上传视频时验证) * @param mobile 登录账号 * @return */ @GetMapping("/check/video/username") public ResponseJson> checkVideoByUsername(String mobile){ return authService.checkVideoByUsername(mobile); } /** * 点赞与取消点赞 * @return */ @PostMapping("/up/video/diggcount") public ResponseJson upVideoDiggCount(@RequestBody String params){ JSONObject jsonObject=JSONObject.parseObject(params); Integer id=jsonObject.getInteger("id"); Integer diggStatus=jsonObject.getInteger("diggStatus"); String clubUserIds=jsonObject.getString("clubUserIds"); Integer clubUserId=jsonObject.getInteger("clubUserId"); return authService.upVideoDiggCount(id,diggStatus,clubUserId,clubUserIds); } /** * 1.7.7保存视频信息 * @return */ @PostMapping("/save/video") public ResponseJson saveVideo(@RequestBody String params){ JSONObject jsonObject=JSONObject.parseObject(params); Integer authId=jsonObject.getInteger("authId"); String userName=jsonObject.getString("userName"); String title=jsonObject.getString("title"); String ossName=jsonObject.getString("ossName"); String cover=jsonObject.getString("cover"); String ossUrl=jsonObject.getString("ossUrl"); String linked=jsonObject.getString("linked"); Integer authUserId=jsonObject.getInteger("authUserId"); RossChallengeVideo cr=new RossChallengeVideo(); cr.setUserName(userName); cr.setCover(cover); cr.setOssName(ossName); cr.setOssUrl(ossUrl); cr.setTitle(title); cr.setAuthId(authId); cr.setLinked(linked); cr.setAuthUserId(authUserId); return authService.saveVideo(cr); } }