WxAuthApi.java 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. package com.caimei.controller.wechat;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.annotation.CurrentUser;
  4. import com.caimei.annotation.Idempotent;
  5. import com.caimei.aop.IpSave;
  6. import com.caimei.model.ResponseJson;
  7. import com.caimei.model.dto.ProductSaveDto;
  8. import com.caimei.model.po.CmBrandAuthPo;
  9. import com.caimei.model.po.SysUser;
  10. import com.caimei.model.vo.*;
  11. import com.caimei.service.auth.*;
  12. import com.github.pagehelper.PageInfo;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiImplicitParam;
  15. import io.swagger.annotations.ApiImplicitParams;
  16. import io.swagger.annotations.ApiOperation;
  17. import lombok.RequiredArgsConstructor;
  18. import lombok.extern.slf4j.Slf4j;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.springframework.web.bind.annotation.*;
  21. import java.io.IOException;
  22. import java.math.BigDecimal;
  23. import java.text.ParseException;
  24. import java.text.SimpleDateFormat;
  25. import java.util.Date;
  26. import java.util.List;
  27. /**
  28. * @author Aslee
  29. */
  30. @Api(tags = "微信认证数据API")
  31. @Slf4j
  32. @RestController
  33. @RequiredArgsConstructor
  34. @RequestMapping("/wx/auth")
  35. public class WxAuthApi {
  36. private final AuthClubService authClubService;
  37. private final AuthService authService;
  38. private final AuthProductService authProductService;
  39. private final DoctorService doctorService;
  40. private final ShopService shopService;
  41. @ApiOperation("供应商信息")
  42. @ApiImplicitParams({
  43. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  44. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId")
  45. })
  46. @GetMapping("/shop/info")
  47. public ResponseJson<WxShopVo> getWxShopInfo(Integer authUserId, String appId) {
  48. if (null == authUserId && StringUtils.isEmpty(appId)) {
  49. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  50. }
  51. return authClubService.getWxShopInfo(authUserId, appId);
  52. }
  53. @ApiOperation("已认证机构列表")
  54. @ApiImplicitParams({
  55. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  56. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  57. @ApiImplicitParam(name = "lngAndLat", required = false, value = "用户当前经纬度"),
  58. @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
  59. @ApiImplicitParam(name = "provinceId", required = false, value = "省id"),
  60. @ApiImplicitParam(name = "cityId", required = false, value = "市id"),
  61. @ApiImplicitParam(name = "townId", required = false, value = "区id"),
  62. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  63. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  64. })
  65. @IpSave(saveName = "已认证机构列表",saveParams = true)
  66. @GetMapping("/club/list")
  67. public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
  68. Integer cityId, Integer townId,
  69. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  70. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  71. if (null == authUserId && StringUtils.isEmpty(appId)) {
  72. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  73. }
  74. return authClubService.getWxClubList(authUserId, appId, lngAndLat, authParty, provinceId, cityId, townId, pageNum, pageSize);
  75. }
  76. @ApiOperation("明星机构列表")
  77. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id")
  78. @GetMapping("/club/star/list")
  79. public ResponseJson<List<WxClubListVo>> getStarClubList(Integer authUserId) {
  80. if (null == authUserId) {
  81. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  82. }
  83. return authClubService.getWxStarClubList(authUserId);
  84. }
  85. @ApiOperation("已认证机构详情")
  86. @ApiImplicitParam(required = false, name = "authId", value = "正品联盟机构Id")
  87. @IpSave(saveName = "已认证机构详情",saveParams = true)
  88. @GetMapping("/club/details")
  89. public ResponseJson<WxClubDetailsVo> getWxClubDetails(Integer authId) {
  90. return authClubService.getWxClubDetails(authId);
  91. }
  92. @ApiOperation("设备分类列表")
  93. @ApiImplicitParams({
  94. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  95. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  96. @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"),
  97. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  98. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  99. })
  100. @GetMapping("/product/type/list")
  101. public ResponseJson<PageInfo<WxProductTypeListVo>> getWxProductTypeList(Integer authUserId, String appId, String name,
  102. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  103. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  104. if (null == authUserId && StringUtils.isEmpty(appId)) {
  105. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  106. }
  107. return authProductService.getWxProductTypeList(authUserId, appId, name, pageNum, pageSize);
  108. }
  109. @ApiOperation("认证商品列表")
  110. @ApiImplicitParams({
  111. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1已上线设备列表 2设备认证记录列表"),
  112. @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
  113. @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
  114. @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"),
  115. @ApiImplicitParam(name = "snCode", required = false, value = "sn码"),
  116. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  117. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  118. })
  119. @IpSave(saveName = "认证商品列表",saveParams = true)
  120. @GetMapping("/product/list")
  121. public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId,
  122. String authParty, String snCode,
  123. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  124. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  125. return authProductService.getWxProductList(listType, authId, authParty, productTypeId, snCode, pageNum, pageSize);
  126. }
  127. /**
  128. * 获取授权商品回显数据
  129. */
  130. @ApiOperation("授权商品回显数据")
  131. @ApiImplicitParam(name = "relationId", required = true, value = "机构设备关联id")
  132. @GetMapping("/product/form/data")
  133. public ResponseJson<ProductFormVo> getProductFormData(Integer relationId) {
  134. return authProductService.getProductFormData(relationId);
  135. }
  136. /**
  137. * 品牌列表
  138. *
  139. * @return AuthVo
  140. */
  141. @ApiOperation("品牌列表")
  142. @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
  143. @GetMapping("/shop/info/list")
  144. public ResponseJson<List<ShopInfoVo>> getShopInfoList(Integer authUserId) {
  145. return shopService.getShopInfoList(authUserId);
  146. }
  147. /**
  148. * 添加/编辑授权商品
  149. * @param productSaveDto {
  150. * productId 授权商品id
  151. * authId 授权id
  152. * infoId 品牌信息id
  153. * productTypeId 设备分类id
  154. * snCode 商品SN码
  155. * productImage 商品图片
  156. * purchaseWay 购买渠道
  157. * invoiceImage 发票图片
  158. * status 上线状态:0已下线,1已上线,2待上线
  159. * createBy 创建人id
  160. * source 来源:1供应商保存,2机构保存
  161. * paramList 商品参数列表
  162. * }
  163. */
  164. @ApiOperation("添加/编辑授权商品")
  165. @PostMapping("/product/save")
  166. public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
  167. return authProductService.saveProduct(productSaveDto);
  168. }
  169. /**
  170. * 授权机构回显数据
  171. */
  172. @ApiOperation("授权机构回显数据")
  173. @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
  174. @GetMapping("/form/data")
  175. public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
  176. return authService.getAuthFormData(authId);
  177. }
  178. @ApiOperation("添加/编辑授权")
  179. @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
  180. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  181. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  182. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  183. "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
  184. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true)
  185. @PostMapping("/save")
  186. public ResponseJson saveAuth(@RequestBody String params) {
  187. JSONObject paramsMap = JSONObject.parseObject(params);
  188. Integer authId = paramsMap.getInteger("authId");
  189. Integer authUserId = paramsMap.getInteger("authUserId");
  190. Integer provinceId = paramsMap.getInteger("provinceId");
  191. Integer cityId = paramsMap.getInteger("cityId");
  192. Integer townId = paramsMap.getInteger("townId");
  193. String address = paramsMap.getString("address");
  194. String lngAndLat = paramsMap.getString("lngAndLat");
  195. String mobile = paramsMap.getString("mobile");
  196. String userMobile = paramsMap.getString("userMobile");
  197. Integer firstClubType = paramsMap.getInteger("firstClubType");
  198. Integer secondClubType = paramsMap.getInteger("secondClubType");
  199. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  200. Integer empNum = paramsMap.getInteger("empNum");
  201. String logo = paramsMap.getString("logo");
  202. Integer customFlag = paramsMap.getInteger("customFlag");
  203. String remarks = paramsMap.getString("remarks");
  204. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  205. String authParty = paramsMap.getString("authParty");
  206. Integer createBy = paramsMap.getInteger("createBy");
  207. String linkMan = paramsMap.getString("linkMan");
  208. String linkMobile = paramsMap.getString("linkMobile");
  209. /*
  210. 组装授权数据
  211. */
  212. CmBrandAuthPo auth = new CmBrandAuthPo();
  213. auth.setId(authId);
  214. auth.setAuthUserId(authUserId);
  215. auth.setAuthParty(authParty);
  216. auth.setProvinceId(provinceId);
  217. auth.setCityId(cityId);
  218. auth.setTownId(townId);
  219. auth.setAddress(address);
  220. auth.setCustomFlag(customFlag);
  221. auth.setRemarks(remarks);
  222. if (StringUtils.isEmpty(lngAndLat)) {
  223. return ResponseJson.error("参数异常,经纬度不能为空");
  224. }
  225. String[] split = lngAndLat.split(",");
  226. auth.setLng(new BigDecimal(split[0]));
  227. auth.setLat(new BigDecimal(split[1]));
  228. auth.setMobile(mobile);
  229. auth.setUserMobile(userMobile);
  230. auth.setFirstClubType(firstClubType);
  231. auth.setSecondClubType(secondClubType);
  232. auth.setMedicalLicenseImage(medicalLicenseImage);
  233. auth.setEmpNum(empNum);
  234. auth.setLogo(logo);
  235. auth.setCreateBy(createBy);
  236. auth.setLinkMan(linkMan);
  237. auth.setLinkMobile(linkMobile);
  238. // 机构用户编辑授权
  239. return authService.saveAuth(auth, bannerList, false, 2);
  240. }
  241. /**
  242. * 添加/编辑授权
  243. */
  244. @ApiOperation("添加/编辑授权")
  245. @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
  246. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  247. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  248. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  249. "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
  250. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
  251. "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
  252. @PostMapping("/save1")
  253. @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
  254. public ResponseJson saveAuth1( @RequestBody String params) throws ParseException {
  255. JSONObject paramsMap = JSONObject.parseObject(params);
  256. Integer authId = paramsMap.getInteger("authId");
  257. Integer authUserId = paramsMap.getInteger("authUserId");
  258. Integer createBy = paramsMap.getInteger("createBy");
  259. Integer provinceId = paramsMap.getInteger("provinceId");
  260. Integer cityId = paramsMap.getInteger("cityId");
  261. Integer townId = paramsMap.getInteger("townId");
  262. String address = paramsMap.getString("address");
  263. String lngAndLat = paramsMap.getString("lngAndLat");
  264. String mobile = paramsMap.getString("mobile");
  265. String userMobile = paramsMap.getString("userMobile");
  266. String linkMan = paramsMap.getString("linkMan");
  267. String linkMobile = paramsMap.getString("linkMobile");
  268. Integer firstClubType = paramsMap.getInteger("firstClubType");
  269. Integer secondClubType = paramsMap.getInteger("secondClubType");
  270. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  271. Integer empNum = paramsMap.getInteger("empNum");
  272. String logo = paramsMap.getString("logo");
  273. String authCode = paramsMap.getString("authCode");
  274. String authDateStr = paramsMap.getString("authDate");
  275. SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
  276. Date authDate = null;
  277. if (StringUtils.isNotEmpty(authDateStr)) {
  278. authDate = format.parse(authDateStr);
  279. }
  280. Integer authImageType = paramsMap.getInteger("authImageType");
  281. String authImageLogo = paramsMap.getString("authImageLogo");
  282. String authImage = paramsMap.getString("authImage");
  283. Integer customFlag = paramsMap.getInteger("customFlag");
  284. String remarks = paramsMap.getString("remarks");
  285. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  286. String authParty = paramsMap.getString("authParty");
  287. Integer source = paramsMap.getInteger("source");
  288. String relationId = paramsMap.getString("relationId");
  289. String relationName = paramsMap.getString("relationName");
  290. if (null == source) {
  291. // 默认供应商保存
  292. source = 1;
  293. }
  294. /*
  295. 组装授权数据
  296. */
  297. CmBrandAuthPo auth = new CmBrandAuthPo();
  298. auth.setId(authId);
  299. auth.setAuthUserId(authUserId);
  300. auth.setAuthParty(authParty);
  301. auth.setProvinceId(provinceId);
  302. auth.setCityId(cityId);
  303. auth.setTownId(townId);
  304. auth.setAddress(address);
  305. auth.setCustomFlag(customFlag);
  306. auth.setRemarks(remarks);
  307. if (StringUtils.isEmpty(lngAndLat)) {
  308. return ResponseJson.error("参数异常,经纬度不能为空");
  309. }
  310. String[] split = lngAndLat.split(",");
  311. auth.setLng(new BigDecimal(split[0]));
  312. auth.setLat(new BigDecimal(split[1]));
  313. auth.setMobile(mobile);
  314. auth.setUserMobile(userMobile);
  315. auth.setLinkMan(linkMan);
  316. auth.setLinkMobile(linkMobile);
  317. auth.setFirstClubType(firstClubType);
  318. auth.setSecondClubType(secondClubType);
  319. auth.setMedicalLicenseImage(medicalLicenseImage);
  320. auth.setEmpNum(empNum);
  321. auth.setLogo(logo);
  322. auth.setAuthCode(authCode);
  323. auth.setAuthDate(authDate);
  324. auth.setAuthImageLogo(authImageLogo);
  325. auth.setAuthImage(authImage);
  326. auth.setAuthImageType(authImageType);
  327. auth.setCreateBy(createBy);
  328. auth.setCreateSource(2);
  329. auth.setRelationId(relationId);
  330. auth.setRelationName(relationName);
  331. return authService.saveAuth(auth, bannerList, false, source);
  332. }
  333. @ApiOperation("设备分类下拉框列表")
  334. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  335. @GetMapping("/product/type/select")
  336. public ResponseJson<List<ProductTypeListVo>> getProductTypeSelectList(Integer authUserId) {
  337. if (null == authUserId) {
  338. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  339. }
  340. return authProductService.getProductTypeSelectList(authUserId);
  341. }
  342. @ApiOperation("已认证商品详情")
  343. @ApiImplicitParam(required = false, name = "productId", value = "正品联盟商品Id")
  344. @GetMapping("/product/details")
  345. public ResponseJson<AuthProductVo> getAuthProductDetails(String productId) {
  346. return authProductService.getAuthProductDetails(productId);
  347. }
  348. @ApiOperation("关联设备获取设备信息")
  349. @ApiImplicitParams({
  350. @ApiImplicitParam(name = "productId", required = false, value = "设备id"),
  351. @ApiImplicitParam(name = "snCode", required = false, value = "sn码")
  352. })
  353. @GetMapping("/product/info")
  354. public ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode) {
  355. if (null == productId && null == snCode) {
  356. return ResponseJson.error("设备id和sn码不能同时为空", null);
  357. }
  358. return authProductService.getProductInfo(productId, snCode);
  359. }
  360. @ApiOperation("已认证医师列表")
  361. @ApiImplicitParams({
  362. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  363. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  364. @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"),
  365. @ApiImplicitParam(name = "doctorName", required = false, value = "医师名称"),
  366. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  367. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  368. })
  369. @GetMapping("/doctor/list")
  370. public ResponseJson<PageInfo<WxDoctorListVo>> getWxDoctorList(Integer authUserId, String appId, Integer doctorType, String doctorName,
  371. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  372. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  373. if (null == authUserId && StringUtils.isEmpty(appId)) {
  374. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  375. }
  376. return doctorService.getWxDoctorList(authUserId, appId, doctorType, doctorName, pageNum, pageSize);
  377. }
  378. @ApiOperation("已认证医师详情")
  379. @ApiImplicitParam(required = false, name = "doctorId", value = "正品联盟医师Id")
  380. @GetMapping("/doctor/details")
  381. public ResponseJson<DoctorFormVo> getAuthDoctorDetails(Integer doctorId) {
  382. return doctorService.getAuthDoctorDetails(doctorId);
  383. }
  384. @ApiOperation("获取机构下所有的设备信息")
  385. @GetMapping("/get/product/list")
  386. public ResponseJson<List<ProductListVo>> getPronductInfo(Integer authId,Integer authUserId){
  387. if (null == authUserId) {
  388. return ResponseJson.error("用户信息异常", null);
  389. }
  390. return authProductService.getPronductInfo(authId,authUserId);
  391. }
  392. /**
  393. * 保存视频信息
  394. * @return
  395. */
  396. @PostMapping("/save/video/info")
  397. public ResponseJson saveVideoInfo(@RequestBody String params){
  398. JSONObject jsonObject=JSONObject.parseObject(params);
  399. // //验证用户是否可以发布视频
  400. // //是否为机构用户
  401. Integer authId=jsonObject.getInteger("authId");
  402. // boolean flagAtuhId= authService.getauthUserId(authId);
  403. // if(flagAtuhId){
  404. // return ResponseJson.error("-1","由于您未认证机构,无法参与!");
  405. // }
  406. // //用户是否已经发不过视频
  407. String userName=jsonObject.getString("userName");
  408. // Boolean flaguserName=authService.getuserName(userName);
  409. // if(!flaguserName){
  410. // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
  411. // }
  412. // //判断是否在活动时间内
  413. // Date date=new Date();
  414. // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  415. // String releaseTime = sf.format(date).replace("T", "");
  416. // boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
  417. // if(flagReleaseTime){
  418. // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
  419. // }
  420. String title=jsonObject.getString("title");
  421. String ossName=jsonObject.getString("ossName");
  422. String cover=jsonObject.getString("cover");
  423. String ossUrl=jsonObject.getString("ossUrl");
  424. Integer authUserId=jsonObject.getInteger("authUserId");
  425. ChallengeRoundVo cr=new ChallengeRoundVo();
  426. cr.setUserName(userName);
  427. cr.setCover(cover);
  428. cr.setOssName(ossName);
  429. cr.setOssUrl(ossUrl);
  430. cr.setTitle(title);
  431. cr.setAuthId(authId);
  432. cr.setAuthUserId(authUserId);
  433. return authService.saveVideoInfo(cr);
  434. }
  435. /**
  436. * 获取已发布视频
  437. * @param sysUser
  438. * @param status
  439. * @param clubUserName
  440. * @param cursor
  441. * @param count
  442. * @return
  443. */
  444. @GetMapping("/get/published/video/list")
  445. public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser,Integer status,String clubUserName,Integer cursor,Integer count,@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  446. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,Integer authUserId){
  447. // if (null == sysUser) {
  448. // return ResponseJson.error("用户信息异常", null);
  449. // }
  450. // // 获取供应商用户id
  451. // Integer userIdentity = sysUser.getUserIdentity();
  452. // Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  453. // if (null == authUserId) {
  454. // return ResponseJson.error("供应商用户id不能为空", null);
  455. // }
  456. if(count==null){
  457. count=10;
  458. }
  459. if(cursor==null){
  460. cursor=0;
  461. }
  462. return authService.getPublishedVideoList(clubUserName,status,cursor,count,pageNum,pageSize,authUserId);
  463. }
  464. /**
  465. * 验证视频是否符合发布条件
  466. * @param params
  467. * @return
  468. */
  469. @PostMapping("/check/video/info")
  470. public ResponseJson<ChallengeRoundVo> checkVideoInfo(@RequestBody String params){
  471. JSONObject jsonObject=JSONObject.parseObject(params);
  472. //验证用户是否可以发布视频
  473. //是否为机构用户
  474. // Integer authId=jsonObject.getInteger("authId");
  475. // boolean flagAtuhId= authService.getauthUserId(authId);
  476. // if(flagAtuhId){
  477. // return ResponseJson.success("0",null);
  478. // return ResponseJson.error("-1","由于您未认证机构,无法参与!");
  479. // }
  480. //用户是否已经发过视频
  481. String userName=jsonObject.getString("userName");
  482. Integer authUserId=jsonObject.getInteger("authUserId");
  483. Boolean flaguserName=authService.getuserName(userName);
  484. ChallengeRoundVo challengeActivityVo=new ChallengeRoundVo();
  485. ResponseJson<ChallengeActivityVo> activitty = authService.getActivitty(authUserId);
  486. ChallengeActivityVo challe = activitty.getData();
  487. if(challe!=null){
  488. challengeActivityVo.setActivityState(challe.getActivityState());
  489. }
  490. String releaseTime = authService.getReleaseTime(userName);
  491. if(!flaguserName){
  492. if(challe.getStartTime().compareTo(releaseTime)<0&&challe.getEndTime().compareTo(releaseTime)>0){
  493. challengeActivityVo.setReleaseStatus(1);
  494. }else{
  495. challengeActivityVo.setReleaseStatus(0);
  496. }
  497. return ResponseJson.success(challengeActivityVo);
  498. // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
  499. }else{
  500. challengeActivityVo.setReleaseStatus(0);
  501. return ResponseJson.success(challengeActivityVo);
  502. }
  503. //判断是否在活动时间内
  504. // Date date=new Date();
  505. // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  506. // String releaseTime = sf.format(date).replace("T", "");
  507. // boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
  508. // if(flagReleaseTime){
  509. // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
  510. // }
  511. }
  512. /**
  513. * 判断活动开启状态
  514. * @return
  515. */
  516. @GetMapping("/get/activitty")
  517. public ResponseJson<ChallengeActivityVo> getActivitty(Integer authUserId){
  518. return authService.getActivitty(authUserId);
  519. }
  520. //--------------------------------------------挑战赛1.7.7(ROSS)-------------------------------------------------------------------------------------------------
  521. /**
  522. * 新增参赛机构信息
  523. * @return
  524. */
  525. @PostMapping("save/ross/info")
  526. public ResponseJson saveRossInfo(@CurrentUser SysUser sysUser, @RequestBody String params) {
  527. // if (null == sysUser) {
  528. // return ResponseJson.error("用户信息异常", null);
  529. // }
  530. // // 获取供应商用户id
  531. // Integer userIdentity = sysUser.getUserIdentity();
  532. // Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  533. // if (null == authUserId) {
  534. // return ResponseJson.error("供应商用户id不能为空", null);
  535. // }
  536. JSONObject jsonObject = JSONObject.parseObject(params);
  537. String mobile=jsonObject.getString("mobile");
  538. String licenseOssUrl=jsonObject.getString("licenseOssUrl");
  539. String licenseOssName=jsonObject.getString("licenseOssName");
  540. Integer authId=jsonObject.getInteger("authId");
  541. Integer authuser=jsonObject.getInteger("authUserId");
  542. // Integer clubUserId=jsonObject.getInteger("clubUserId");
  543. //判断该账号是否已经参赛
  544. RossChallengeRoundVo infoByUserName = authService.getInfoByUserName(mobile,authuser);
  545. if(null !=infoByUserName&&infoByUserName.getContestStatus()==1){
  546. return ResponseJson.success("您已报名",mobile);
  547. }
  548. RossChallengeRoundVo rossChallengeRoundVo=new RossChallengeRoundVo();
  549. // if(null!=authUserId){
  550. // rossChallengeRoundVo.setAuthUserId(authUserId);
  551. // }else{
  552. rossChallengeRoundVo.setAuthUserId(authuser);
  553. // }
  554. rossChallengeRoundVo.setAuthUserId(authuser);
  555. rossChallengeRoundVo.setUserName(mobile);
  556. rossChallengeRoundVo.setAuthId(authId);
  557. rossChallengeRoundVo.setLicenseOssUrl(licenseOssUrl);
  558. rossChallengeRoundVo.setLicenseOssName(licenseOssName);
  559. // rossChallengeRoundVo.setClubUserId(clubUserId);
  560. if(StringUtils.isEmpty(licenseOssUrl)&&StringUtils.isEmpty(licenseOssName)){
  561. rossChallengeRoundVo.setAuthenticationStatus(1);
  562. }else{
  563. rossChallengeRoundVo.setAuthenticationStatus(0);
  564. }
  565. rossChallengeRoundVo.setContestStatus(1);
  566. Date date=new Date();
  567. SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  568. // String format = sf.format(date);
  569. rossChallengeRoundVo.setContestTime(new java.sql.Timestamp(date.getTime()));
  570. return authService.saveRossInfo(rossChallengeRoundVo);
  571. }
  572. /**
  573. * 验证用户是否已经报名
  574. * @param mobile
  575. * @return
  576. */
  577. @GetMapping("/check/contest/info")
  578. public ResponseJson<RossChallengeRoundVo> checkContestedInfo(String mobile,Integer authUserId){
  579. return authService.checkContestedInfo(mobile,authUserId);
  580. }
  581. /**
  582. * 获取已报名信息列表
  583. * @return
  584. */
  585. @GetMapping("/get/contested/info")
  586. public ResponseJson<List<RossChallengeRoundVo>> getcontestedInfo(Integer authUserId){
  587. return authService.getcontestedInfo(authUserId);
  588. }
  589. /**
  590. * 根据手机号码查询该机构视频列表
  591. * @param mobile 登录账号
  592. * @return
  593. */
  594. @GetMapping("/get/video/username")
  595. public ResponseJson<List<RossChallengeVideo>> getVideoByUsername(@CurrentUser SysUser sysUser,String mobile,Integer clubUserId,Integer authUserId){
  596. Integer id=authUserId;
  597. // 获取供应商用户id
  598. if(null==authUserId){
  599. Integer userIdentity = sysUser.getUserIdentity();
  600. Integer UserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  601. if (null == authUserId) {
  602. id=UserId;
  603. }
  604. }
  605. return authService.getVideoByUsername(mobile,clubUserId,id);
  606. }
  607. /**
  608. * 查询视频列表
  609. * @param mobileOrAuthpart 电话号码或者机构名称
  610. * @return
  611. */
  612. @GetMapping("/get/video/all")
  613. public ResponseJson<PageInfo<RossChallengeVideo>> getVideoAll(String mobileOrAuthpart,Integer clubUserId,Integer authUserId,
  614. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  615. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
  616. return authService.getVideoAll(mobileOrAuthpart,clubUserId,authUserId,pageNum,pageSize);
  617. }
  618. /**
  619. * 验证机构是否已经上传了3个视频(点击上传视频时验证)
  620. * @param mobile 登录账号
  621. * @return
  622. */
  623. @GetMapping("/check/video/username")
  624. public ResponseJson<List<RossChallengeVideo>> checkVideoByUsername(String mobile,Integer authUserId){
  625. return authService.checkVideoByUsername(mobile,authUserId);
  626. }
  627. /**
  628. * 点赞与取消点赞
  629. * @return
  630. */
  631. @PostMapping("/up/video/diggcount")
  632. public ResponseJson upVideoDiggCount(@RequestBody String params){
  633. JSONObject jsonObject=JSONObject.parseObject(params);
  634. Integer id=jsonObject.getInteger("id");
  635. Integer diggStatus=jsonObject.getInteger("diggStatus");
  636. String clubUserIds=jsonObject.getString("clubUserIds");
  637. Integer clubUserId=jsonObject.getInteger("clubUserId");
  638. return authService.upVideoDiggCount(id,diggStatus,clubUserId,clubUserIds);
  639. }
  640. /**
  641. * 1.7.7保存视频信息
  642. * @return
  643. */
  644. @PostMapping("/save/video")
  645. public ResponseJson<RossChallengeVideo> saveVideo(@RequestBody String params){
  646. JSONObject jsonObject=JSONObject.parseObject(params);
  647. Integer authId=jsonObject.getInteger("authId");
  648. String userName=jsonObject.getString("userName");
  649. String title=jsonObject.getString("title");
  650. String ossName=jsonObject.getString("ossName");
  651. String cover=jsonObject.getString("cover");
  652. String ossUrl=jsonObject.getString("ossUrl");
  653. String linked=jsonObject.getString("linked");
  654. Integer authUserId=jsonObject.getInteger("authUserId");
  655. RossChallengeVideo cr=new RossChallengeVideo();
  656. cr.setUserName(userName);
  657. cr.setCover(cover);
  658. cr.setOssName(ossName);
  659. cr.setOssUrl(ossUrl);
  660. cr.setTitle(title);
  661. cr.setAuthId(authId);
  662. cr.setLinked(linked);
  663. cr.setAuthUserId(authUserId);
  664. return authService.saveVideo(cr);
  665. }
  666. }