AuthApi.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. package com.caimei.controller.auth;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.po.CmBrandAuthPo;
  5. import com.caimei.model.vo.AuthFormVo;
  6. import com.caimei.model.vo.AuthVo;
  7. import com.caimei.model.vo.ProductTypeListVo;
  8. import com.caimei.service.auth.AuthService;
  9. import com.github.pagehelper.PageInfo;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. import lombok.RequiredArgsConstructor;
  15. import lombok.extern.slf4j.Slf4j;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.springframework.web.bind.annotation.*;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import javax.servlet.http.HttpServletResponse;
  20. import java.math.BigDecimal;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * 供应商API
  25. *
  26. * @author : Aslee
  27. * @date : 2021/5/11
  28. */
  29. @Api(tags = "认证机构API")
  30. @Slf4j
  31. @RestController
  32. @RequiredArgsConstructor
  33. @RequestMapping("/auth")
  34. public class AuthApi {
  35. private final AuthService authService;
  36. /**
  37. * 授权列表
  38. */
  39. @ApiOperation("授权列表")
  40. @ApiImplicitParams({
  41. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
  42. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  43. @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
  44. @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
  45. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  46. @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
  47. @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
  48. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  49. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  50. })
  51. @GetMapping("/list")
  52. public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
  53. Integer status, Integer auditStatus, Integer lowerAuditStatus,
  54. Integer shopAuditStatus,
  55. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  56. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  57. return authService.getAuthList(listType, authUserId, authParty, status, auditStatus, lowerAuditStatus, shopAuditStatus, pageNum, pageSize);
  58. }
  59. @ApiOperation("机构下拉框列表")
  60. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  61. @GetMapping("/select")
  62. public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
  63. if (null == authUserId) {
  64. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  65. }
  66. return authService.getAuthSelectList(authUserId);
  67. }
  68. /**
  69. * 更新授权状态
  70. */
  71. @ApiOperation("更新授权状态")
  72. @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
  73. @PostMapping("/update/status")
  74. public ResponseJson updateAuthStatus(@RequestBody Map<String,Integer> params) {
  75. Integer authId = params.get("authId");
  76. Integer status = params.get("status");
  77. return authService.updateAuthStatus(authId, status);
  78. }
  79. /**
  80. * 删除授权
  81. */
  82. @ApiOperation("删除授权")
  83. @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
  84. @PostMapping("/delete")
  85. public ResponseJson deleteAuth(@RequestBody Map<String,Integer> params) {
  86. Integer authId = params.get("authId");
  87. return authService.deleteAuth(authId);
  88. }
  89. /**
  90. * 授权机构回显数据
  91. */
  92. @ApiOperation("授权机构回显数据")
  93. @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
  94. @GetMapping("/form/data")
  95. public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
  96. return authService.getAuthFormData(authId);
  97. }
  98. /**
  99. * 添加/编辑授权
  100. */
  101. @ApiOperation("添加/编辑授权")
  102. @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
  103. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  104. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  105. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  106. "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
  107. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id", required = true)
  108. @PostMapping("/save")
  109. public ResponseJson saveAuth(@RequestBody String params) {
  110. JSONObject paramsMap = JSONObject.parseObject(params);
  111. Integer authId = paramsMap.getInteger("authId");
  112. Integer authUserId = paramsMap.getInteger("authUserId");
  113. Integer provinceId = paramsMap.getInteger("provinceId");
  114. Integer cityId = paramsMap.getInteger("cityId");
  115. Integer townId = paramsMap.getInteger("townId");
  116. String address = paramsMap.getString("address");
  117. String lngAndLat = paramsMap.getString("lngAndLat");
  118. String mobile = paramsMap.getString("mobile");
  119. String userMobile = paramsMap.getString("userMobile");
  120. Integer firstClubType = paramsMap.getInteger("firstClubType");
  121. Integer secondClubType = paramsMap.getInteger("secondClubType");
  122. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  123. Integer empNum = paramsMap.getInteger("empNum");
  124. String logo = paramsMap.getString("logo");
  125. Integer customFlag = paramsMap.getInteger("customFlag");
  126. String remarks = paramsMap.getString("remarks");
  127. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  128. String authParty = paramsMap.getString("authParty");
  129. Integer createBy = paramsMap.getInteger("createBy");
  130. /*
  131. 组装授权数据
  132. */
  133. CmBrandAuthPo auth = new CmBrandAuthPo();
  134. auth.setId(authId);
  135. auth.setAuthUserId(authUserId);
  136. auth.setAuthParty(authParty);
  137. auth.setProvinceId(provinceId);
  138. auth.setCityId(cityId);
  139. auth.setTownId(townId);
  140. auth.setAddress(address);
  141. auth.setCustomFlag(customFlag);
  142. auth.setRemarks(remarks);
  143. if (StringUtils.isEmpty(lngAndLat)) {
  144. return ResponseJson.error("参数异常,经纬度不能为空");
  145. }
  146. String[] split = lngAndLat.split(",");
  147. auth.setLng(new BigDecimal(split[0]));
  148. auth.setLat(new BigDecimal(split[1]));
  149. auth.setMobile(mobile);
  150. auth.setUserMobile(userMobile);
  151. auth.setFirstClubType(firstClubType);
  152. auth.setSecondClubType(secondClubType);
  153. auth.setMedicalLicenseImage(medicalLicenseImage);
  154. auth.setEmpNum(empNum);
  155. auth.setLogo(logo);
  156. auth.setCreateBy(createBy);
  157. return authService.saveAuth(auth, bannerList, false, 1);
  158. }
  159. /**
  160. * 审核品牌授权
  161. */
  162. @ApiOperation("审核品牌授权")
  163. @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
  164. "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
  165. @PostMapping("/audit")
  166. public ResponseJson auditAuth(@RequestBody String params) {
  167. JSONObject paramsMap = JSONObject.parseObject(params);
  168. Integer authId = paramsMap.getInteger("authId");
  169. Integer auditStatus = paramsMap.getInteger("auditStatus");
  170. String invalidReason = paramsMap.getString("invalidReason");
  171. Integer auditBy = paramsMap.getInteger("auditBy");
  172. Integer source = paramsMap.getInteger("source");
  173. return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
  174. }
  175. @ApiOperation("寄送授权牌")
  176. @ApiImplicitParam(name = "params", value = "authId:授权id;logisticsCompany:快递公司;logisticsNumber:快递单号;" +
  177. "image:图片备注;remarks:备注", required = true)
  178. @PostMapping("certificate/send")
  179. public ResponseJson send(@RequestBody String params) {
  180. JSONObject paramsMap = JSONObject.parseObject(params);
  181. Integer authId = paramsMap.getInteger("authId");
  182. String logisticsCompany = paramsMap.getString("logisticsCompany");
  183. String logisticsNumber = paramsMap.getString("logisticsNumber");
  184. String image = paramsMap.getString("image");
  185. String remarks = paramsMap.getString("remarks");
  186. return authService.sendCertificate(authId, logisticsCompany, logisticsNumber, image, remarks);
  187. }
  188. @ApiOperation("excel导入")
  189. @ApiImplicitParams({
  190. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  191. @ApiImplicitParam(name = "createBy", required = true, value = "创建人用户id"),
  192. @ApiImplicitParam(name = "file", required = true, value = "代理声明文件"),
  193. })
  194. @PostMapping("/import/excel")
  195. public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
  196. if (null == authUserId) {
  197. return ResponseJson.error("参数异常,请输入供应商id");
  198. }
  199. if (null == createBy) {
  200. return ResponseJson.error("参数异常,请输入创建人id");
  201. }
  202. if (null == file) {
  203. return ResponseJson.error("参数异常,请选择文件");
  204. }
  205. return authService.importDataByExcel(file, authUserId, createBy);
  206. }
  207. @ApiOperation("ldm导入")
  208. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  209. @PostMapping("/ldm/import")
  210. public ResponseJson importLdmData(Integer authUserId) {
  211. return authService.importLdmData(authUserId);
  212. }
  213. @ApiOperation("excel导出")
  214. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  215. @GetMapping("/export/excel")
  216. public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
  217. if (null == authUserId) {
  218. return ResponseJson.error("参数异常,请输入供应商id");
  219. }
  220. return authService.exportDataByExcel(authUserId, response);
  221. }
  222. }