WxAuthApi.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. package com.caimei.controller.wechat;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.aop.IpSave;
  4. import com.caimei.model.ResponseJson;
  5. import com.caimei.model.dto.ProductSaveDto;
  6. import com.caimei.model.po.CmBrandAuthPo;
  7. import com.caimei.model.vo.*;
  8. import com.caimei.service.auth.*;
  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 java.io.IOException;
  19. import java.math.BigDecimal;
  20. import java.util.List;
  21. /**
  22. * @author Aslee
  23. */
  24. @Api(tags = "微信认证数据API")
  25. @Slf4j
  26. @RestController
  27. @RequiredArgsConstructor
  28. @RequestMapping("/wx/auth")
  29. public class WxAuthApi {
  30. private final AuthClubService authClubService;
  31. private final AuthService authService;
  32. private final AuthProductService authProductService;
  33. private final DoctorService doctorService;
  34. private final ShopService shopService;
  35. @ApiOperation("供应商信息")
  36. @ApiImplicitParams({
  37. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  38. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId")
  39. })
  40. @GetMapping("/shop/info")
  41. public ResponseJson<WxShopVo> getWxShopInfo(Integer authUserId, String appId) {
  42. if (null == authUserId && StringUtils.isEmpty(appId)) {
  43. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  44. }
  45. return authClubService.getWxShopInfo(authUserId, appId);
  46. }
  47. @ApiOperation("已认证机构列表")
  48. @ApiImplicitParams({
  49. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  50. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  51. @ApiImplicitParam(name = "lngAndLat", required = false, value = "用户当前经纬度"),
  52. @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
  53. @ApiImplicitParam(name = "provinceId", required = false, value = "省id"),
  54. @ApiImplicitParam(name = "cityId", required = false, value = "市id"),
  55. @ApiImplicitParam(name = "townId", required = false, value = "区id"),
  56. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  57. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  58. })
  59. @IpSave(saveName = "已认证机构列表",saveParams = true)
  60. @GetMapping("/club/list")
  61. public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
  62. Integer cityId, Integer townId,
  63. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  64. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  65. if (null == authUserId && StringUtils.isEmpty(appId)) {
  66. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  67. }
  68. return authClubService.getWxClubList(authUserId, appId, lngAndLat, authParty, provinceId, cityId, townId, pageNum, pageSize);
  69. }
  70. @ApiOperation("明星机构列表")
  71. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id")
  72. @GetMapping("/club/start/list")
  73. public ResponseJson<List<WxClubListVo>> getStarClubList(Integer authUserId) {
  74. if (null == authUserId) {
  75. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  76. }
  77. return authClubService.getWxStarClubList(authUserId);
  78. }
  79. @ApiOperation("已认证机构详情")
  80. @ApiImplicitParam(required = false, name = "authId", value = "正品联盟机构Id")
  81. @IpSave(saveName = "已认证机构详情",saveParams = true)
  82. @GetMapping("/club/details")
  83. public ResponseJson<WxClubDetailsVo> getWxClubDetails(Integer authId) {
  84. return authClubService.getWxClubDetails(authId);
  85. }
  86. @ApiOperation("设备分类列表")
  87. @ApiImplicitParams({
  88. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  89. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  90. @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"),
  91. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  92. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  93. })
  94. @GetMapping("/product/type/list")
  95. public ResponseJson<PageInfo<WxProductTypeListVo>> getWxProductTypeList(Integer authUserId, String appId, String name,
  96. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  97. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  98. if (null == authUserId && StringUtils.isEmpty(appId)) {
  99. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  100. }
  101. return authProductService.getWxProductTypeList(authUserId, appId, name, pageNum, pageSize);
  102. }
  103. @ApiOperation("认证商品列表")
  104. @ApiImplicitParams({
  105. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1已上线设备列表 2设备认证记录列表"),
  106. @ApiImplicitParam(name = "authId", required = false, value = "机构id"),
  107. @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"),
  108. @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"),
  109. @ApiImplicitParam(name = "snCode", required = false, value = "sn码"),
  110. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  111. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  112. })
  113. @IpSave(saveName = "认证商品列表",saveParams = true)
  114. @GetMapping("/product/list")
  115. public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId,
  116. String authParty, String snCode,
  117. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  118. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  119. return authProductService.getWxProductList(listType, authId, authParty, productTypeId, snCode, pageNum, pageSize);
  120. }
  121. /**
  122. * 获取授权商品回显数据
  123. */
  124. @ApiOperation("授权商品回显数据")
  125. @ApiImplicitParam(name = "productId", required = true, value = "授权商品id")
  126. @GetMapping("/product/form/data")
  127. public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
  128. return authProductService.getProductFormData(productId);
  129. }
  130. /**
  131. * 品牌列表
  132. *
  133. * @return AuthVo
  134. */
  135. @ApiOperation("品牌列表")
  136. @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
  137. @GetMapping("/shop/info/list")
  138. public ResponseJson<List<ShopInfoVo>> getShopInfoList(Integer authUserId) {
  139. return shopService.getShopInfoList(authUserId);
  140. }
  141. /**
  142. * 添加/编辑授权商品
  143. * @param productSaveDto {
  144. * productId 授权商品id
  145. * authId 授权id
  146. * info 品牌信息id
  147. * productTypeId 设备分类id
  148. * snCode 商品SN码
  149. * productImage 商品图片
  150. * purchaseWay 购买渠道
  151. * invoiceImage 发票图片
  152. * status 上线状态:0已下线,1已上线,2待上线
  153. * createBy 创建人id
  154. * source 来源:1供应商保存,2机构保存
  155. * paramList 商品参数列表
  156. * }
  157. */
  158. @ApiOperation("添加/编辑授权商品")
  159. @PostMapping("/product/save")
  160. public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException {
  161. return authProductService.saveProduct(productSaveDto);
  162. }
  163. /**
  164. * 授权机构回显数据
  165. */
  166. @ApiOperation("授权机构回显数据")
  167. @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
  168. @GetMapping("/form/data")
  169. public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
  170. return authService.getAuthFormData(authId);
  171. }
  172. @ApiOperation("添加/编辑授权")
  173. @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
  174. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  175. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  176. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  177. "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
  178. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true)
  179. @PostMapping("/save")
  180. public ResponseJson saveAuth(@RequestBody String params) {
  181. JSONObject paramsMap = JSONObject.parseObject(params);
  182. Integer authId = paramsMap.getInteger("authId");
  183. Integer authUserId = paramsMap.getInteger("authUserId");
  184. Integer provinceId = paramsMap.getInteger("provinceId");
  185. Integer cityId = paramsMap.getInteger("cityId");
  186. Integer townId = paramsMap.getInteger("townId");
  187. String address = paramsMap.getString("address");
  188. String lngAndLat = paramsMap.getString("lngAndLat");
  189. String mobile = paramsMap.getString("mobile");
  190. String userMobile = paramsMap.getString("userMobile");
  191. Integer firstClubType = paramsMap.getInteger("firstClubType");
  192. Integer secondClubType = paramsMap.getInteger("secondClubType");
  193. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  194. Integer empNum = paramsMap.getInteger("empNum");
  195. String logo = paramsMap.getString("logo");
  196. Integer customFlag = paramsMap.getInteger("customFlag");
  197. String remarks = paramsMap.getString("remarks");
  198. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  199. String authParty = paramsMap.getString("authParty");
  200. Integer createBy = paramsMap.getInteger("createBy");
  201. /*
  202. 组装授权数据
  203. */
  204. CmBrandAuthPo auth = new CmBrandAuthPo();
  205. auth.setId(authId);
  206. auth.setAuthUserId(authUserId);
  207. auth.setAuthParty(authParty);
  208. auth.setProvinceId(provinceId);
  209. auth.setCityId(cityId);
  210. auth.setTownId(townId);
  211. auth.setAddress(address);
  212. auth.setCustomFlag(customFlag);
  213. auth.setRemarks(remarks);
  214. if (StringUtils.isEmpty(lngAndLat)) {
  215. return ResponseJson.error("参数异常,经纬度不能为空");
  216. }
  217. String[] split = lngAndLat.split(",");
  218. auth.setLng(new BigDecimal(split[0]));
  219. auth.setLat(new BigDecimal(split[1]));
  220. auth.setMobile(mobile);
  221. auth.setUserMobile(userMobile);
  222. auth.setFirstClubType(firstClubType);
  223. auth.setSecondClubType(secondClubType);
  224. auth.setMedicalLicenseImage(medicalLicenseImage);
  225. auth.setEmpNum(empNum);
  226. auth.setLogo(logo);
  227. auth.setCreateBy(createBy);
  228. // 机构用户编辑授权
  229. return authService.saveAuth(auth, bannerList, false, 2);
  230. }
  231. @ApiOperation("设备分类下拉框列表")
  232. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  233. @GetMapping("/product/type/select")
  234. public ResponseJson<List<ProductTypeListVo>> getProductTypeSelectList(Integer authUserId) {
  235. if (null == authUserId) {
  236. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  237. }
  238. return authProductService.getProductTypeSelectList(authUserId);
  239. }
  240. @ApiOperation("已认证商品详情")
  241. @ApiImplicitParam(required = false, name = "productId", value = "正品联盟商品Id")
  242. @GetMapping("/product/details")
  243. public ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId) {
  244. return authProductService.getAuthProductDetails(productId);
  245. }
  246. @ApiOperation("已认证医师列表")
  247. @ApiImplicitParams({
  248. @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
  249. @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"),
  250. @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"),
  251. @ApiImplicitParam(name = "doctorName", required = false, value = "医师名称"),
  252. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  253. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  254. })
  255. @GetMapping("/doctor/list")
  256. public ResponseJson<PageInfo<WxDoctorListVo>> getWxDoctorList(Integer authUserId, String appId, Integer doctorType, String doctorName,
  257. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  258. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  259. if (null == authUserId && StringUtils.isEmpty(appId)) {
  260. return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null);
  261. }
  262. return doctorService.getWxDoctorList(authUserId, appId, doctorType, doctorName, pageNum, pageSize);
  263. }
  264. @ApiOperation("已认证医师详情")
  265. @ApiImplicitParam(required = false, name = "doctorId", value = "正品联盟医师Id")
  266. @GetMapping("/doctor/details")
  267. public ResponseJson<DoctorFormVo> getAuthDoctorDetails(Integer doctorId) {
  268. return doctorService.getAuthDoctorDetails(doctorId);
  269. }
  270. }