AuthApi.java 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. package com.caimei.controller.admin.auth;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.annotation.CurrentUser;
  4. import com.caimei.annotation.Idempotent;
  5. import com.caimei.annotation.WebHooks;
  6. import com.caimei.components.RedisService;
  7. import com.caimei.model.ResponseJson;
  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.AuthService;
  12. import com.caimei.utils.OSSUtils;
  13. import com.caimei.utils.SmsUtils;
  14. import com.github.pagehelper.PageInfo;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiImplicitParam;
  17. import io.swagger.annotations.ApiImplicitParams;
  18. import io.swagger.annotations.ApiOperation;
  19. import lombok.RequiredArgsConstructor;
  20. import lombok.extern.slf4j.Slf4j;
  21. import org.apache.commons.lang3.StringUtils;
  22. import org.apache.http.Consts;
  23. import org.apache.http.HttpEntity;
  24. import org.apache.http.NameValuePair;
  25. import org.apache.http.client.entity.UrlEncodedFormEntity;
  26. import org.apache.http.client.methods.CloseableHttpResponse;
  27. import org.apache.http.client.methods.HttpPost;
  28. import org.apache.http.entity.ContentType;
  29. import org.apache.http.impl.client.CloseableHttpClient;
  30. import org.apache.http.impl.client.HttpClients;
  31. import org.apache.http.message.BasicNameValuePair;
  32. import org.apache.http.util.EntityUtils;
  33. import org.springframework.beans.factory.annotation.Autowired;
  34. import org.springframework.web.bind.annotation.*;
  35. import org.springframework.web.multipart.MultipartFile;
  36. import javax.annotation.Resource;
  37. import javax.servlet.http.HttpServletResponse;
  38. import java.io.IOException;
  39. import java.math.BigDecimal;
  40. import java.nio.charset.StandardCharsets;
  41. import java.text.ParseException;
  42. import java.text.SimpleDateFormat;
  43. import java.util.*;
  44. /**
  45. * 供应商API
  46. *
  47. * @author : Aslee
  48. * @date : 2021/5/11
  49. */
  50. @Api(tags = "认证机构API")
  51. @Slf4j
  52. @RestController
  53. @RequiredArgsConstructor
  54. @RequestMapping("/auth")
  55. public class AuthApi {
  56. private final AuthService authService;
  57. @Resource
  58. private RedisService redisService;
  59. /**
  60. * 授权列表
  61. */
  62. @ApiOperation("授权列表")
  63. @ApiImplicitParams({
  64. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  65. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
  66. @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
  67. @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
  68. @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
  69. @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
  70. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  71. @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
  72. @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
  73. @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
  74. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  75. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  76. })
  77. @GetMapping("/list")
  78. public ResponseJson<PageInfo<AuthVo>> getAuthList(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
  79. Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
  80. Integer shopAuditStatus, Integer sendStatus, String authCode,
  81. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  82. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  83. // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
  84. if (null != sysUser && 1 != sysUser.getId()) {
  85. // 获取供应商用户id
  86. Integer userIdentity = sysUser.getUserIdentity();
  87. authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  88. if (null == authUserId) {
  89. return ResponseJson.error("供应商用户id不能为空", null);
  90. }
  91. } else if (null == authUserId) {
  92. return ResponseJson.error("供应商用户id不能为空", null);
  93. }
  94. return authService.getAuthList(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, authCode, pageNum, pageSize);
  95. }
  96. /**
  97. * 授权列表
  98. * 1.7.4版本
  99. * 新加两个查询条件
  100. * <p>
  101. * name 商品名称
  102. * snCode 商品sn码
  103. **/
  104. @ApiOperation("授权列表")
  105. @ApiImplicitParams({
  106. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  107. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
  108. @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
  109. @ApiImplicitParam(name = "mobile", required = false, value = "机构用户手机号"),
  110. @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
  111. @ApiImplicitParam(name = "starFlag", required = false, value = "明星机构标识:0不是,1是"),
  112. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  113. @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
  114. @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
  115. @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
  116. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  117. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  118. })
  119. @GetMapping("/listAll")
  120. public ResponseJson<PageInfo<AuthVo>> getAuthListAll(@CurrentUser SysUser sysUser, Integer authUserId, Integer listType, String authParty, String mobile,
  121. Integer status, Integer starFlag, Integer auditStatus, Integer lowerAuditStatus,
  122. Integer shopAuditStatus, Integer sendStatus, String name, String snCode,
  123. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  124. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  125. // 管理员/供应商公用接口,管理员调用时传authUserId,供应商调用不传
  126. if (null != sysUser && 1 != sysUser.getId()) {
  127. // 获取供应商用户id
  128. Integer userIdentity = sysUser.getUserIdentity();
  129. authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  130. if (null == authUserId) {
  131. return ResponseJson.error("供应商用户id不能为空", null);
  132. }
  133. } else if (null == authUserId) {
  134. return ResponseJson.error("供应商用户id不能为空", null);
  135. }
  136. return authService.getAuthListAll(listType, authUserId, authParty, mobile, status, starFlag, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, name, snCode, pageNum, pageSize);
  137. }
  138. @ApiOperation("机构下拉框列表")
  139. @GetMapping("/select")
  140. public ResponseJson<List<AuthVo>> getAuthSelectList(@CurrentUser SysUser sysUser) {
  141. if (null == sysUser) {
  142. return ResponseJson.error("用户信息异常", null);
  143. }
  144. // 获取供应商用户id
  145. Integer userIdentity = sysUser.getUserIdentity();
  146. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  147. if (null == authUserId) {
  148. return ResponseJson.error("供应商用户id不能为空", null);
  149. }
  150. return authService.getAuthSelectList(authUserId);
  151. }
  152. /**
  153. * 更新授权状态
  154. */
  155. @ApiOperation("更新授权状态")
  156. @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
  157. @PostMapping("/update/status")
  158. public ResponseJson updateAuthStatus(@RequestBody Map<String, Integer> params) {
  159. Integer authId = params.get("authId");
  160. Integer status = params.get("status");
  161. return authService.updateAuthStatus(authId, status);
  162. }
  163. /**
  164. * 删除授权
  165. */
  166. @ApiOperation("删除授权")
  167. @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
  168. @PostMapping("/delete")
  169. public ResponseJson deleteAuth(@RequestBody Map<String, Integer> params) {
  170. Integer authId = params.get("authId");
  171. return authService.deleteAuth(authId);
  172. }
  173. /**
  174. * 授权机构回显数据
  175. */
  176. @ApiOperation("授权机构回显数据")
  177. @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
  178. @GetMapping("/form/data")
  179. public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
  180. return authService.getAuthFormData(authId);
  181. }
  182. /**
  183. * 添加/编辑授权
  184. */
  185. @ApiOperation("添加/编辑授权")
  186. @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
  187. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  188. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  189. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  190. "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
  191. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
  192. "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
  193. @PostMapping("/save")
  194. @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
  195. public ResponseJson saveAuth(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
  196. if (null == sysUser) {
  197. return ResponseJson.error("用户信息异常", null);
  198. }
  199. // 获取供应商用户id
  200. Integer userIdentity = sysUser.getUserIdentity();
  201. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  202. Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
  203. if (null == authUserId) {
  204. return ResponseJson.error("供应商用户id不能为空", null);
  205. }
  206. JSONObject paramsMap = JSONObject.parseObject(params);
  207. Integer authId = paramsMap.getInteger("authId");
  208. Integer provinceId = paramsMap.getInteger("provinceId");
  209. Integer cityId = paramsMap.getInteger("cityId");
  210. Integer townId = paramsMap.getInteger("townId");
  211. String address = paramsMap.getString("address");
  212. String lngAndLat = paramsMap.getString("lngAndLat");
  213. String mobile = paramsMap.getString("mobile");
  214. String userMobile = paramsMap.getString("userMobile");
  215. String linkMan = paramsMap.getString("linkMan");
  216. String linkMobile = paramsMap.getString("linkMobile");
  217. Integer firstClubType = paramsMap.getInteger("firstClubType");
  218. Integer secondClubType = paramsMap.getInteger("secondClubType");
  219. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  220. Integer empNum = paramsMap.getInteger("empNum");
  221. String logo = paramsMap.getString("logo");
  222. String authCode = paramsMap.getString("authCode");
  223. String authDateStr = paramsMap.getString("authDate");
  224. SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
  225. Date authDate = null;
  226. if (StringUtils.isNotEmpty(authDateStr)) {
  227. authDate = format.parse(authDateStr);
  228. }
  229. Integer authImageType = paramsMap.getInteger("authImageType");
  230. String authImageLogo = paramsMap.getString("authImageLogo");
  231. String authImage = paramsMap.getString("authImage");
  232. Integer customFlag = paramsMap.getInteger("customFlag");
  233. String remarks = paramsMap.getString("remarks");
  234. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  235. String authParty = paramsMap.getString("authParty");
  236. Integer source = paramsMap.getInteger("source");
  237. String relationId = paramsMap.getString("relationId");
  238. String relationName = paramsMap.getString("relationName");
  239. if (null == source) {
  240. // 默认供应商保存
  241. source = 1;
  242. }
  243. /*
  244. 组装授权数据
  245. */
  246. CmBrandAuthPo auth = new CmBrandAuthPo();
  247. auth.setId(authId);
  248. auth.setAuthUserId(authUserId);
  249. auth.setAuthParty(authParty);
  250. auth.setProvinceId(provinceId);
  251. auth.setCityId(cityId);
  252. auth.setTownId(townId);
  253. auth.setAddress(address);
  254. auth.setCustomFlag(customFlag);
  255. auth.setRemarks(remarks);
  256. if (StringUtils.isEmpty(lngAndLat)) {
  257. return ResponseJson.error("参数异常,经纬度不能为空");
  258. }
  259. String[] split = lngAndLat.split(",");
  260. auth.setLng(new BigDecimal(split[0]));
  261. auth.setLat(new BigDecimal(split[1]));
  262. auth.setMobile(mobile);
  263. auth.setUserMobile(userMobile);
  264. auth.setLinkMan(linkMan);
  265. auth.setLinkMobile(linkMobile);
  266. auth.setFirstClubType(firstClubType);
  267. auth.setSecondClubType(secondClubType);
  268. auth.setMedicalLicenseImage(medicalLicenseImage);
  269. auth.setEmpNum(empNum);
  270. auth.setLogo(logo);
  271. auth.setAuthCode(authCode);
  272. auth.setAuthDate(authDate);
  273. auth.setAuthImageLogo(authImageLogo);
  274. auth.setAuthImage(authImage);
  275. auth.setAuthImageType(authImageType);
  276. auth.setCreateBy(createBy);
  277. auth.setCreateSource(1);
  278. auth.setRelationId(relationId);
  279. auth.setRelationName(relationName);
  280. return authService.saveAuth(auth, bannerList, false, source);
  281. }
  282. /**
  283. * 添加/编辑授权
  284. * 1.7.4版本:编辑时新加关联机构操作
  285. */
  286. @ApiOperation("添加/编辑授权")
  287. @ApiImplicitParam(name = "params", value = "authId:授权id;authParty:授权机构;provinceId;cityId;" +
  288. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  289. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  290. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  291. "medicalLicenseImage:医疗许可证图;empNum:员工人数;" +
  292. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存" +
  293. "linkMan:运营联系人;linkMobile:运营联系人手机号", required = true)
  294. @PostMapping("/saverelationg")
  295. @Idempotent(prefix = "idempotent_auth_save", keys = {"#params"}, expire = 5)
  296. public ResponseJson savesaverelationg(@CurrentUser SysUser sysUser, @RequestBody String params) throws ParseException {
  297. if (null == sysUser) {
  298. return ResponseJson.error("用户信息异常", null);
  299. }
  300. // 获取供应商用户id
  301. Integer userIdentity = sysUser.getUserIdentity();
  302. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  303. Integer createBy = (2 == userIdentity || 3 == userIdentity) ? sysUser.getId() : null;
  304. if (null == authUserId) {
  305. return ResponseJson.error("供应商用户id不能为空", null);
  306. }
  307. JSONObject paramsMap = JSONObject.parseObject(params);
  308. // Integer authUserId = paramsMap.getInteger("authUserId");
  309. // Integer createBy = paramsMap.getInteger("createBy");
  310. Integer authId = paramsMap.getInteger("authId");
  311. Integer provinceId = paramsMap.getInteger("provinceId");
  312. Integer cityId = paramsMap.getInteger("cityId");
  313. Integer townId = paramsMap.getInteger("townId");
  314. String address = paramsMap.getString("address");
  315. String lngAndLat = paramsMap.getString("lngAndLat");
  316. String mobile = paramsMap.getString("mobile");
  317. String userMobile = paramsMap.getString("userMobile");
  318. String linkMan = paramsMap.getString("linkMan");
  319. String linkMobile = paramsMap.getString("linkMobile");
  320. Integer firstClubType = paramsMap.getInteger("firstClubType");
  321. Integer secondClubType = paramsMap.getInteger("secondClubType");
  322. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  323. Integer empNum = paramsMap.getInteger("empNum");
  324. String logo = paramsMap.getString("logo");
  325. String authCode = paramsMap.getString("authCode");
  326. String authDateStr = paramsMap.getString("authDate");
  327. SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
  328. String relationId = paramsMap.getString("relationId");
  329. String relationName = paramsMap.getString("relationName");
  330. Date authDate = null;
  331. if (StringUtils.isNotEmpty(authDateStr)) {
  332. authDate = format.parse(authDateStr);
  333. }
  334. Integer authImageType = paramsMap.getInteger("authImageType");
  335. String authImageLogo = paramsMap.getString("authImageLogo");
  336. String authImage = paramsMap.getString("authImage");
  337. Integer customFlag = paramsMap.getInteger("customFlag");
  338. String remarks = paramsMap.getString("remarks");
  339. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  340. String authParty = paramsMap.getString("authParty");
  341. Integer source = paramsMap.getInteger("source");
  342. if (null == source) {
  343. // 默认供应商保存
  344. source = 1;
  345. }
  346. /*
  347. 组装授权数据
  348. */
  349. CmBrandAuthPo auth = new CmBrandAuthPo();
  350. auth.setId(authId);
  351. auth.setAuthUserId(authUserId);
  352. auth.setAuthParty(authParty);
  353. auth.setProvinceId(provinceId);
  354. auth.setCityId(cityId);
  355. auth.setTownId(townId);
  356. auth.setAddress(address);
  357. auth.setCustomFlag(customFlag);
  358. auth.setRemarks(remarks);
  359. if (StringUtils.isEmpty(lngAndLat)) {
  360. return ResponseJson.error("参数异常,经纬度不能为空");
  361. }
  362. String[] split = lngAndLat.split(",");
  363. auth.setLng(new BigDecimal(split[0]));
  364. auth.setLat(new BigDecimal(split[1]));
  365. auth.setMobile(mobile);
  366. auth.setUserMobile(userMobile);
  367. auth.setLinkMan(linkMan);
  368. auth.setLinkMobile(linkMobile);
  369. auth.setFirstClubType(firstClubType);
  370. auth.setSecondClubType(secondClubType);
  371. auth.setMedicalLicenseImage(medicalLicenseImage);
  372. auth.setEmpNum(empNum);
  373. auth.setLogo(logo);
  374. auth.setAuthCode(authCode);
  375. auth.setAuthDate(authDate);
  376. auth.setAuthImageLogo(authImageLogo);
  377. auth.setAuthImage(authImage);
  378. auth.setAuthImageType(authImageType);
  379. auth.setCreateBy(createBy);
  380. auth.setCreateSource(1);
  381. auth.setRelationId(relationId);
  382. auth.setRelationName(relationName);
  383. return authService.saveAuth(auth, bannerList, false, source);
  384. }
  385. /**
  386. * 审核品牌授权
  387. */
  388. @ApiOperation("审核品牌授权")
  389. @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
  390. "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
  391. @PostMapping("/audit")
  392. public ResponseJson auditAuth(@CurrentUser SysUser sysUser, @RequestBody String params) {
  393. if (null == sysUser) {
  394. return ResponseJson.error("用户信息异常", null);
  395. }
  396. // 获取审核人用户id
  397. Integer auditBy = sysUser.getId();
  398. if (null == auditBy) {
  399. return ResponseJson.error("审核人用户id不能为空", null);
  400. }
  401. JSONObject paramsMap = JSONObject.parseObject(params);
  402. Integer authId = paramsMap.getInteger("authId");
  403. Integer auditStatus = paramsMap.getInteger("auditStatus");
  404. String invalidReason = paramsMap.getString("invalidReason");
  405. Integer source = paramsMap.getInteger("source");
  406. return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
  407. }
  408. @ApiOperation("excel导入")
  409. @ApiImplicitParam(name = "file", required = true, value = "机构excel表格")
  410. @PostMapping("/import/excel")
  411. public ResponseJson importDataByExcel(@CurrentUser SysUser sysUser, MultipartFile file) {
  412. if (null == sysUser) {
  413. return ResponseJson.error("用户信息异常", null);
  414. }
  415. // 获取供应商用户id
  416. Integer userIdentity = sysUser.getUserIdentity();
  417. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  418. Integer createBy = sysUser.getId();
  419. if (null == authUserId) {
  420. return ResponseJson.error("供应商用户id不能为空", null);
  421. }
  422. if (null == createBy) {
  423. return ResponseJson.error("参数异常,请输入创建人id");
  424. }
  425. if (null == file) {
  426. return ResponseJson.error("参数异常,请选择文件");
  427. }
  428. return authService.importDataByExcel(file, authUserId, createBy);
  429. }
  430. @ApiOperation("ldm门店图/备注导入")
  431. @GetMapping("/ldm/image/import")
  432. public ResponseJson importLdmImage(@CurrentUser SysUser sysUser) {
  433. if (null == sysUser) {
  434. return ResponseJson.error("用户信息异常", null);
  435. }
  436. // 获取供应商用户id
  437. Integer userIdentity = sysUser.getUserIdentity();
  438. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  439. if (null == authUserId) {
  440. return ResponseJson.error("供应商用户id不能为空", null);
  441. }
  442. return authService.importLdmImage(authUserId);
  443. }
  444. @ApiOperation("更改查看标记")
  445. @PostMapping("/check/{id}")
  446. public ResponseJson checkAuth(@PathVariable("id") Integer authId) {
  447. return authService.checkAuth(authId);
  448. }
  449. @ApiOperation("勾选明星机构")
  450. @ApiImplicitParam(name = "params", required = true, value = "authId:机构id;starFlag:明星机构标识:1明星机构,0不是;starNum明星机构数值(用于排序,数值越大排名越前)")
  451. @PostMapping("/star")
  452. public ResponseJson starAuth(@RequestBody String params) {
  453. JSONObject paramsMap = JSONObject.parseObject(params);
  454. Integer authId = paramsMap.getInteger("authId");
  455. Integer starFlag = paramsMap.getInteger("starFlag");
  456. String starNum = paramsMap.getString("starNum");
  457. if (null == authId) {
  458. return ResponseJson.error("机构id不能为空");
  459. }
  460. if (null == starFlag) {
  461. return ResponseJson.error("明星机构标识不能为空");
  462. }
  463. return authService.starAuth(authId, starFlag, starNum);
  464. }
  465. /**
  466. * 获取机构关联的机构信息
  467. * 1.7.4版本:编辑时新加关联机构操作
  468. */
  469. @PostMapping("/product/relation/list")
  470. public ResponseJson<List<AuthFormVo>> getRelationgInfo(@CurrentUser SysUser sysUser, @RequestBody String params) {
  471. JSONObject paramsMap = JSONObject.parseObject(params);
  472. String snCode = paramsMap.getString("snCode");
  473. if (null == sysUser) {
  474. return ResponseJson.error("用户信息异常", null);
  475. }
  476. // 获取供应商用户id
  477. Integer userIdentity = sysUser.getUserIdentity();
  478. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  479. if (null == authUserId) {
  480. return ResponseJson.error("供应商用户id不能为空", null);
  481. }
  482. return authService.getRelationgInfo(snCode, authUserId);
  483. }
  484. /**
  485. * 获取可绑定机构机构信息
  486. * 1.7.4版本:编辑时新加关联机构操作
  487. */
  488. @GetMapping("/club/bind/list")
  489. public ResponseJson<List<AuthFormVo>> getClubBindAuth(@CurrentUser SysUser sysUser) {
  490. if (null == sysUser) {
  491. return ResponseJson.error("用户信息异常", null);
  492. }
  493. // 获取供应商用户id
  494. Integer userIdentity = sysUser.getUserIdentity();
  495. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  496. if (null == authUserId) {
  497. return ResponseJson.error("供应商用户id不能为空", null);
  498. }
  499. return authService.getClubBindAuth(authUserId);
  500. }
  501. //-----------------------------------------------------上传视频至抖音-----------------------------------------------------------------------------------
  502. /**
  503. * 用户扫码授权,获取code值
  504. *
  505. * @param response
  506. * @throws IOException
  507. */
  508. @GetMapping("/check/accesstoken")
  509. public ResponseJson getDouYingCode(HttpServletResponse response) throws IOException {
  510. return authService.getDouYingCode(response);
  511. }
  512. /**
  513. * 清除抖音授权token缓存
  514. * @return
  515. */
  516. @GetMapping("/clean/douyin/redis")
  517. public ResponseJson cleanDYRedis(){
  518. redisService.remove("DYaccessToken");
  519. redisService.remove("DyrefreshToken");
  520. redisService.remove("DyopenId");
  521. return ResponseJson.success();
  522. }
  523. /**
  524. * 根据用户的code值获取AcessToken
  525. * ccode 用户授权登录code
  526. **/
  527. @GetMapping("/get/douying/acesstoken")
  528. public ResponseJson getDouYingAcessToken(String code) throws IOException {
  529. return authService.getDouYingAcessToken(code);
  530. }
  531. /**
  532. * h5的方式上传视频
  533. *
  534. * @return
  535. * @throws IOException
  536. */
  537. @PostMapping("/upload/video/to/douyin")
  538. public ResponseJson getclientToken(@RequestBody String params) throws IOException {
  539. JSONObject paramsMap = JSONObject.parseObject(params);
  540. String title = paramsMap.getString("title");
  541. String videoPath = paramsMap.getString("videoPath");
  542. Integer authId = paramsMap.getInteger("authId");
  543. return authService.getclientToken(title, videoPath, authId);
  544. }
  545. /**
  546. * 发布视频后通过webhook获取回调数据
  547. *
  548. * @param params
  549. * @return
  550. */
  551. @PostMapping("/webhook")
  552. @ResponseBody
  553. @WebHooks
  554. public Object webhook(@RequestBody String params) {
  555. JSONObject paramsMap = JSONObject.parseObject(params);
  556. System.out.println(paramsMap.getString("item_id"));
  557. String content = paramsMap.getString("content");
  558. JSONObject contentList = JSONObject.parseObject(content);
  559. System.out.println(content);
  560. String challenge = contentList.getString("challenge");
  561. System.out.println(challenge);
  562. String itemId = contentList.getString("item_id");
  563. System.out.println(itemId);
  564. String shareId = contentList.getString("share_id");
  565. //根据回调的shareId保存itemId
  566. if (StringUtils.isNotEmpty(shareId) && StringUtils.isNotEmpty(itemId)) {
  567. if (authService.getShareId(shareId)) {
  568. //根据shareId保存itemId
  569. authService.savaItemIdByShareId(shareId, itemId);
  570. }
  571. }
  572. System.out.println(shareId);
  573. Map<String, String> map = new HashMap<>();
  574. map.put("challenge", challenge);
  575. map.put("item_id", itemId);
  576. map.put("share_id", shareId);
  577. return map;
  578. }
  579. /**
  580. * 把抖音分享视频口令以短信推送给机构
  581. *
  582. * @return
  583. */
  584. @PostMapping("/sms/send/douyin")
  585. public ResponseJson sms(@RequestBody String params) {//String mobile,String content
  586. JSONObject jsonObject = JSONObject.parseObject(params);
  587. //根据authId获取手机号
  588. Integer authId = jsonObject.getInteger("authId");
  589. String mobile = authService.getMobileByAuthId(authId);
  590. //根据authId获取供应商名称
  591. String authUserName = authService.getAuthUserName(authId);
  592. String content = jsonObject.getString("content");
  593. // String authParty=jsonObject.getString("authParty");
  594. // 短信类型:1通知短信,2验证码短信,3营销短信
  595. String con = content.substring(0, content.indexOf("/") + 1);
  596. String cs = content.substring(content.indexOf("com") + 3);
  597. Integer type = 1;
  598. String kouLin = "[" + authUserName + "]您在认证通抖音视频挑战赛发布的视频已成功上传至抖音平台,抖音分享口令为:" + con + " https://v.douyin.com" + cs + ",您可复制该口令后去抖音平台打开";
  599. Boolean flag = SmsUtils.sendSms(type, mobile, kouLin);
  600. if (flag) {
  601. //短信发送成功后,保存口令
  602. authService.savaDyCommand(authId, content);
  603. return ResponseJson.success();
  604. } else {
  605. return ResponseJson.error("短信发送失败-----" + mobile);
  606. }
  607. }
  608. // /**
  609. // * 保存视频信息
  610. // * @return
  611. // */
  612. // @PostMapping("/save/video/info")
  613. // public ResponseJson saveVideoInfo(@RequestBody String params){
  614. // JSONObject jsonObject=JSONObject.parseObject(params);
  615. //// //验证用户是否可以发布视频
  616. //// //是否为机构用户
  617. // Integer authId=jsonObject.getInteger("authId");
  618. //// boolean flagAtuhId= authService.getauthUserId(authId);
  619. //// if(flagAtuhId){
  620. //// return ResponseJson.error("-1","由于您未认证机构,无法参与!");
  621. //// }
  622. //// //用户是否已经发不过视频
  623. // String userName=jsonObject.getString("userName");
  624. //// Boolean flaguserName=authService.getuserName(userName);
  625. //// if(!flaguserName){
  626. //// return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
  627. //// }
  628. //// //判断是否在活动时间内
  629. //// Date date=new Date();
  630. //// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  631. //// String releaseTime = sf.format(date).replace("T", "");
  632. //// boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
  633. //// if(flagReleaseTime){
  634. //// return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
  635. //// }
  636. // String title=jsonObject.getString("title");
  637. // String ossName=jsonObject.getString("ossName");
  638. // String cover=jsonObject.getString("cover");
  639. // String ossUrl=jsonObject.getString("ossUrl");
  640. // ChallengeRoundVo cr=new ChallengeRoundVo();
  641. // cr.setUserName(userName);
  642. // cr.setCover(cover);
  643. // cr.setOssName(ossName);
  644. // cr.setOssUrl(ossUrl);
  645. // cr.setTitle(title);
  646. // cr.setAuthId(authId);
  647. // return authService.saveVideoInfo(cr);
  648. // }
  649. // @PostMapping("/get/published/video/list")
  650. // public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(@RequestBody String params){
  651. // JSONObject jsonObject=JSONObject.parseObject(params);
  652. // Integer status=jsonObject.getInteger("status");//1:未上传至抖音(前端使用) 否则不传(后端使用)
  653. // String clubUserName=jsonObject.getString("clubUserName");
  654. // Integer count=jsonObject.getInteger("count");
  655. // Integer cursor =jsonObject.getInteger("cursor");
  656. // if(count==null){
  657. // count=10;
  658. // }
  659. // if(cursor==null){
  660. // cursor=0;
  661. // }
  662. // return authService.getPublishedVideoList(clubUserName,status,cursor,count);
  663. // }
  664. //
  665. // /**
  666. // * 验证视频是否符合发布条件
  667. // * @param params
  668. // * @return
  669. // */
  670. // @PostMapping("/check/video/info")
  671. // public ResponseJson checkVideoInfo(@RequestBody String params){
  672. // JSONObject jsonObject=JSONObject.parseObject(params);
  673. // //验证用户是否可以发布视频
  674. // //是否为机构用户
  675. // Integer authId=jsonObject.getInteger("authId");
  676. // boolean flagAtuhId= authService.getauthUserId(authId);
  677. // if(flagAtuhId){
  678. // return ResponseJson.error("-1","由于您未认证机构,无法参与!");
  679. // }
  680. // //用户是否已经发不过视频
  681. // String userName=jsonObject.getString("userName");
  682. // Boolean flaguserName=authService.getuserName(userName);
  683. // if(!flaguserName){
  684. // return ResponseJson.error("-1","抱歉,活动规定每个用户只能发布一个视频,您已发布过视频,请勿再次发布!");
  685. // }
  686. // //判断是否在活动时间内
  687. // Date date=new Date();
  688. // SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  689. // String releaseTime = sf.format(date).replace("T", "");
  690. // boolean flagReleaseTime= authService.checkActivityTime(releaseTime);
  691. // if(flagReleaseTime){
  692. // return ResponseJson.error("-1","抱歉,活动已结束,暂无法发布视频!");
  693. // }
  694. // return ResponseJson.success();
  695. // }
  696. /**
  697. * 保存活动信息
  698. *
  699. * @param params
  700. * @return
  701. */
  702. @PostMapping("/save/activity/time")
  703. public ResponseJson saveActivityTime(@CurrentUser SysUser sysUser, @RequestBody String params) {
  704. if (null == sysUser) {
  705. return ResponseJson.error("用户信息异常", null);
  706. }
  707. // 获取供应商用户id
  708. Integer userIdentity = sysUser.getUserIdentity();
  709. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  710. if (null == authUserId) {
  711. return ResponseJson.error("供应商用户id不能为空", null);
  712. }
  713. JSONObject jsonObject = JSONObject.parseObject(params);
  714. String startTime = jsonObject.getString("startTime");
  715. String endTime = jsonObject.getString("endTime");
  716. Integer status = jsonObject.getInteger("status");
  717. authService.saveActivityTime(startTime, endTime, status, authUserId);
  718. return ResponseJson.success();
  719. }
  720. /**
  721. * 获取活动信息
  722. *
  723. * @return
  724. */
  725. @GetMapping("/get/activity/time")
  726. public ResponseJson<ChallengeActivityVo> getActivityTime(@CurrentUser SysUser sysUser) {
  727. if (null == sysUser) {
  728. return ResponseJson.error("用户信息异常", null);
  729. }
  730. // 获取供应商用户id
  731. Integer userIdentity = sysUser.getUserIdentity();
  732. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  733. if (null == authUserId) {
  734. return ResponseJson.error("供应商用户id不能为空", null);
  735. }
  736. return authService.getActivityTime(authUserId);
  737. }
  738. /**
  739. * 获取已发布视频
  740. *
  741. * @param sysUser
  742. * @param status
  743. * @param cursor
  744. * @param count
  745. * @return
  746. */
  747. @GetMapping("/get/published/video/list")
  748. public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(@CurrentUser SysUser sysUser, Integer status, String userName, String authParty, Integer cursor, Integer count, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  749. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,String startTIme,String endTime) {
  750. if (null == sysUser) {
  751. return ResponseJson.error("用户信息异常", null);
  752. }
  753. // 获取供应商用户id
  754. Integer userIdentity = sysUser.getUserIdentity();
  755. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  756. if (null == authUserId) {
  757. return ResponseJson.error("供应商用户id不能为空", null);
  758. }
  759. if (count == null) {
  760. count = 10;
  761. }
  762. if (cursor == null) {
  763. cursor = 0;
  764. }
  765. return authService.getPublishedVideo(userName, authParty, status, cursor, count, authUserId, pageNum, pageSize,startTIme,endTime);
  766. }
  767. /**
  768. * 获取机构已发布视频的机构下拉列表
  769. *
  770. * @return
  771. */
  772. @GetMapping("/get/auth/party/list")
  773. public ResponseJson<List<ChallengeRoundVo>> getAuthPartylist(@CurrentUser SysUser sysUser) {
  774. if (null == sysUser) {
  775. return ResponseJson.error("用户信息异常", null);
  776. }
  777. // 获取供应商用户id
  778. Integer userIdentity = sysUser.getUserIdentity();
  779. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  780. if (null == authUserId) {
  781. return ResponseJson.error("供应商用户id不能为空", null);
  782. }
  783. return authService.getAuthPartylist(authUserId);
  784. }
  785. /**
  786. * 删除视频
  787. *
  788. * @param videoId
  789. * @return
  790. */
  791. @GetMapping("/del/video")
  792. public ResponseJson delVideo(Integer videoId) {
  793. //删除阿里云存储视频
  794. String ossName = authService.getOssNameAuthId(videoId);
  795. OSSUtils.deleteSingleFile(ossName);
  796. //删除视频信息
  797. authService.deleteVideoByAuthId(videoId);
  798. return ResponseJson.success();
  799. }
  800. /**
  801. * 下载视频
  802. *
  803. * @param fileId
  804. * @param response
  805. * @return
  806. */
  807. @GetMapping("/downLoad/chose/zip")
  808. public ResponseJson downLoadChoseZip(String fileId, HttpServletResponse response) {
  809. return authService.downLoadChoseZip(fileId, response);
  810. }
  811. /**
  812. * 根据id获取信息
  813. */
  814. @GetMapping("/get/info/by/id")
  815. public ResponseJson<ChallengeRoundVo> getInfoById(Integer videoId) {
  816. return authService.getInfoById(videoId);
  817. }
  818. @GetMapping("/getDyVidoInfo")
  819. public ResponseJson getDyVidoInfo(@CurrentUser SysUser sysUser){
  820. Integer userIdentity = sysUser.getUserIdentity();
  821. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  822. return authService.getDyVidoInfo(authUserId);
  823. }
  824. //------------------------------------------抖音挑战赛1.7.7版本----------------------------------------------------------------------------------------------------------------
  825. /**
  826. * 查询机构信息(后端)
  827. * @param mobile
  828. * @return
  829. */
  830. @GetMapping("/get/auth/info")
  831. public ResponseJson<PageInfo<RossChallengeRoundVo>> getAuthInfo(String mobile,
  832. @CurrentUser SysUser sysUser,
  833. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  834. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
  835. if (null == sysUser) {
  836. return ResponseJson.error("用户信息异常", null);
  837. }
  838. // 获取供应商用户id
  839. Integer userIdentity = sysUser.getUserIdentity();
  840. Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
  841. if (null == authUserId) {
  842. return ResponseJson.error("供应商用户id不能为空", null);
  843. }
  844. return authService.getAuthInfo(mobile,pageNum,pageSize,authUserId);
  845. }
  846. /**
  847. * 根据id删除机构信息
  848. * @param id
  849. * @return
  850. */
  851. @GetMapping("/del/auth/info")
  852. public ResponseJson delAuthInfoById(Integer id){
  853. //删除机构信息
  854. return authService.delAuthInfoById(id);
  855. }
  856. /**
  857. * 根据id删除视频信息
  858. * @param id
  859. * @return
  860. */
  861. @GetMapping("/del/video/info")
  862. public ResponseJson delVideoInfoById(Integer id){
  863. return authService.delVideoInfoById(id);
  864. }
  865. }