WxAuthApi.java 15 KB

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