package com.caimei.controller.wechat; import com.alibaba.fastjson.JSONObject; import com.caimei.aop.IpSave; import com.caimei.model.ResponseJson; import com.caimei.model.dto.ProductSaveDto; import com.caimei.model.po.CmBrandAuthPo; import com.caimei.model.vo.*; import com.caimei.service.auth.*; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.math.BigDecimal; import java.util.List; /** * @author Aslee */ @Api(tags = "微信认证数据API") @Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/wx/auth") public class WxAuthApi { private final AuthClubService authClubService; private final AuthService authService; private final AuthProductService authProductService; private final DoctorService doctorService; private final ShopService shopService; @ApiOperation("供应商信息") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId") }) @GetMapping("/shop/info") public ResponseJson getWxShopInfo(Integer authUserId, String appId) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authClubService.getWxShopInfo(authUserId, appId); } @ApiOperation("已认证机构列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "lngAndLat", required = false, value = "用户当前经纬度"), @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"), @ApiImplicitParam(name = "provinceId", required = false, value = "省id"), @ApiImplicitParam(name = "cityId", required = false, value = "市id"), @ApiImplicitParam(name = "townId", required = false, value = "区id"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @IpSave(saveName = "已认证机构列表",saveParams = true) @GetMapping("/club/list") public ResponseJson> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId, Integer cityId, Integer townId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authClubService.getWxClubList(authUserId, appId, lngAndLat, authParty, provinceId, cityId, townId, pageNum, pageSize); } @ApiOperation("明星机构列表") @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id") @GetMapping("/club/start/list") public ResponseJson> getStarClubList(Integer authUserId) { if (null == authUserId) { return ResponseJson.error("参数异常,供应商用户id不能为空", null); } return authClubService.getWxStarClubList(authUserId); } @ApiOperation("已认证机构详情") @ApiImplicitParam(required = false, name = "authId", value = "正品联盟机构Id") @IpSave(saveName = "已认证机构详情",saveParams = true) @GetMapping("/club/details") public ResponseJson getWxClubDetails(Integer authId) { return authClubService.getWxClubDetails(authId); } @ApiOperation("设备分类列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "name", required = false, value = "设备分类名称"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @GetMapping("/product/type/list") public ResponseJson> getWxProductTypeList(Integer authUserId, String appId, String name, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return authProductService.getWxProductTypeList(authUserId, appId, name, pageNum, pageSize); } @ApiOperation("认证商品列表") @ApiImplicitParams({ @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1已上线设备列表 2设备认证记录列表"), @ApiImplicitParam(name = "authId", required = false, value = "机构id"), @ApiImplicitParam(name = "authParty", required = false, value = "机构名称"), @ApiImplicitParam(name = "productTypeId", required = false, value = "设备分类id"), @ApiImplicitParam(name = "snCode", required = false, value = "sn码"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @IpSave(saveName = "认证商品列表",saveParams = true) @GetMapping("/product/list") public ResponseJson> getWxProductList(Integer listType, Integer authId, Integer productTypeId, String authParty, String snCode, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { return authProductService.getWxProductList(listType, authId, authParty, productTypeId, snCode, pageNum, pageSize); } /** * 获取授权商品回显数据 */ @ApiOperation("授权商品回显数据") @ApiImplicitParam(name = "productId", required = true, value = "授权商品id") @GetMapping("/product/form/data") public ResponseJson getProductFormData(Integer productId) { return authProductService.getProductFormData(productId); } /** * 品牌列表 * * @return AuthVo */ @ApiOperation("品牌列表") @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false) @GetMapping("/shop/info/list") public ResponseJson> getShopInfoList(Integer authUserId) { return shopService.getShopInfoList(authUserId); } /** * 添加/编辑授权商品 * @param productSaveDto { * productId 授权商品id * authId 授权id * info 品牌信息id * productTypeId 设备分类id * snCode 商品SN码 * productImage 商品图片 * purchaseWay 购买渠道 * invoiceImage 发票图片 * status 上线状态:0已下线,1已上线,2待上线 * createBy 创建人id * source 来源:1供应商保存,2机构保存 * paramList 商品参数列表 * } */ @ApiOperation("添加/编辑授权商品") @PostMapping("/product/save") public ResponseJson saveProduct(@RequestBody ProductSaveDto productSaveDto) throws IOException { return authProductService.saveProduct(productSaveDto); } /** * 授权机构回显数据 */ @ApiOperation("授权机构回显数据") @ApiImplicitParam(name = "authId", required = true, value = "机构用户id") @GetMapping("/form/data") public ResponseJson getAuthFormData(Integer authId) { return authService.getAuthFormData(authId); } @ApiOperation("添加/编辑授权") @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" + "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" + "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" + "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" + "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+ "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true) @PostMapping("/save") public ResponseJson saveAuth(@RequestBody String params) { JSONObject paramsMap = JSONObject.parseObject(params); Integer authId = paramsMap.getInteger("authId"); Integer authUserId = paramsMap.getInteger("authUserId"); Integer provinceId = paramsMap.getInteger("provinceId"); Integer cityId = paramsMap.getInteger("cityId"); Integer townId = paramsMap.getInteger("townId"); String address = paramsMap.getString("address"); String lngAndLat = paramsMap.getString("lngAndLat"); String mobile = paramsMap.getString("mobile"); String userMobile = paramsMap.getString("userMobile"); Integer firstClubType = paramsMap.getInteger("firstClubType"); Integer secondClubType = paramsMap.getInteger("secondClubType"); String medicalLicenseImage = paramsMap.getString("medicalLicenseImage"); Integer empNum = paramsMap.getInteger("empNum"); String logo = paramsMap.getString("logo"); Integer customFlag = paramsMap.getInteger("customFlag"); String remarks = paramsMap.getString("remarks"); List bannerList = (List) paramsMap.get("bannerList"); String authParty = paramsMap.getString("authParty"); Integer createBy = paramsMap.getInteger("createBy"); /* 组装授权数据 */ CmBrandAuthPo auth = new CmBrandAuthPo(); auth.setId(authId); auth.setAuthUserId(authUserId); auth.setAuthParty(authParty); auth.setProvinceId(provinceId); auth.setCityId(cityId); auth.setTownId(townId); auth.setAddress(address); auth.setCustomFlag(customFlag); auth.setRemarks(remarks); if (StringUtils.isEmpty(lngAndLat)) { return ResponseJson.error("参数异常,经纬度不能为空"); } String[] split = lngAndLat.split(","); auth.setLng(new BigDecimal(split[0])); auth.setLat(new BigDecimal(split[1])); auth.setMobile(mobile); auth.setUserMobile(userMobile); auth.setFirstClubType(firstClubType); auth.setSecondClubType(secondClubType); auth.setMedicalLicenseImage(medicalLicenseImage); auth.setEmpNum(empNum); auth.setLogo(logo); auth.setCreateBy(createBy); // 机构用户编辑授权 return authService.saveAuth(auth, bannerList, false, 2); } @ApiOperation("设备分类下拉框列表") @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id") @GetMapping("/product/type/select") public ResponseJson> getProductTypeSelectList(Integer authUserId) { if (null == authUserId) { return ResponseJson.error("参数异常,供应商用户id不能为空", null); } return authProductService.getProductTypeSelectList(authUserId); } @ApiOperation("已认证商品详情") @ApiImplicitParam(required = false, name = "productId", value = "正品联盟商品Id") @GetMapping("/product/details") public ResponseJson getAuthProductDetails(Integer productId) { return authProductService.getAuthProductDetails(productId); } @ApiOperation("已认证医师列表") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "appId", required = false, value = "供应商公众号appId"), @ApiImplicitParam(name = "doctorType", required = false, value = "医师类型:1操作医师,2培训医师"), @ApiImplicitParam(name = "doctorName", required = false, value = "医师名称"), @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"), @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条") }) @GetMapping("/doctor/list") public ResponseJson> getWxDoctorList(Integer authUserId, String appId, Integer doctorType, String doctorName, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { if (null == authUserId && StringUtils.isEmpty(appId)) { return ResponseJson.error("参数异常,供应商用户id和appId不能同时为空", null); } return doctorService.getWxDoctorList(authUserId, appId, doctorType, doctorName, pageNum, pageSize); } @ApiOperation("已认证医师详情") @ApiImplicitParam(required = false, name = "doctorId", value = "正品联盟医师Id") @GetMapping("/doctor/details") public ResponseJson getAuthDoctorDetails(Integer doctorId) { return doctorService.getAuthDoctorDetails(doctorId); } }