| @@ -13,13 +13,11 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.*; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.image.BufferedImage; | |||
| import java.util.*; | |||
| import java.util.List; | |||
| @@ -30,8 +28,6 @@ public class UploadController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| @@ -45,19 +41,25 @@ public class UploadController extends BaseController { | |||
| @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传文件") | |||
| @SystemControllerLog(description = "文件上传") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| @@ -71,7 +73,8 @@ public class UploadController extends BaseController { | |||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传图片") | |||
| @SystemControllerLog(description = "上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq | |||
| ,@RequestParam Map<String, String> param) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| @@ -81,45 +84,40 @@ public class UploadController extends BaseController { | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||
| } | |||
| String tempFileName = UUID.randomUUID().toString(); | |||
| String fileFormat = ""; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| FileOutputStream fos = null; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| String localImgFileName = fmUploadDir + tempFileName + "-1" + fileFormat; | |||
| String localNewImgFileName = fmUploadDir + tempFileName + fileFormat; | |||
| BufferedInputStream fs = null; | |||
| File localFile = new File(localImgFileName); | |||
| fos = new FileOutputStream(localFile); | |||
| fs = (BufferedInputStream) multiReq.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| logger.info("local file: " + localImgFileName); | |||
| File newFile = ImgUtil.thinImage(localImgFileName, localNewImgFileName, imgFormat); | |||
| logger.info("local new file: " + localNewImgFileName); | |||
| // 删除本地缓存 | |||
| localFile.delete(); | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, new FileInputStream(newFile)); | |||
| // 删除本地缓存 | |||
| newFile.delete(); | |||
| return data; | |||
| } else { | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } | |||
| long maxSize = 0l; | |||
| try { | |||
| maxSize = Long.parseLong(param.get("size")); | |||
| } catch (NumberFormatException e) {} | |||
| if(maxSize > 0l && size > maxSize*1024){ | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_CUSTOMIZE); | |||
| } | |||
| BufferedImage bufferedImage = ImageIO.read(multiReq.getInputStream()); | |||
| if(bufferedImage != null){ | |||
| int width = 0;int hight = 0; | |||
| try { | |||
| width = Integer.parseInt(param.get("width")); | |||
| hight = Integer.parseInt(param.get("hight")); | |||
| } catch (NumberFormatException e) {} | |||
| Integer relWidth = bufferedImage.getWidth(); | |||
| Integer relHeight = bufferedImage.getHeight(); | |||
| if((width > 0 && width != relWidth.intValue()) | |||
| || (hight > 0 && hight != relHeight.intValue())){ | |||
| return new ResultData(ErrorCode.PICTURE_W_H_CUSTOMIZE); | |||
| } | |||
| } | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| @@ -136,65 +134,75 @@ public class UploadController extends BaseController { | |||
| @PostMapping(value = "/awsFilesUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("多文件上传") | |||
| @SystemControllerLog(description = "多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) throws Exception{ | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||
| try { | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||
| } | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 内部接口-C端上传图片文件 | |||
| * 内部接口-A端上传图片文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("内部接口-C端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| @ApiOperation("内部接口-A端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile("cimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile("aimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,100 @@ | |||
| update wx_credit_history_0 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_1 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_2 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_3 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_4 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_5 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_6 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_7 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_8 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_9 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_10 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_11 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_12 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_13 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_14 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_15 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_16 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_17 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_18 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_19 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_20 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_21 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_22 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_23 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_24 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_25 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_26 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_27 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_28 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_29 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_30 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_31 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_32 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_33 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_34 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_35 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_36 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_37 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_38 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_39 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_40 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_41 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_42 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_43 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_44 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_45 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_46 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_47 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_48 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_49 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_50 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_51 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_52 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_53 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_54 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_55 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_56 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_57 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_58 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_59 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_60 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_61 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_62 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_63 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_64 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_65 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_66 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_67 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_68 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_69 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_70 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_71 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_72 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_73 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_74 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_75 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_76 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_77 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_78 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_79 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_80 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_81 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_82 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_83 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_84 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_85 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_86 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_87 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_88 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_89 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_90 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_91 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_92 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_93 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_94 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_95 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_96 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_97 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_98 set operator_type = 2 where operator_type = 1; | |||
| update wx_credit_history_99 set operator_type = 2 where operator_type = 1; | |||
| @@ -0,0 +1,3 @@ | |||
| ALTER TABLE `wx_user_channel` | |||
| DROP INDEX `scene_address_index`, | |||
| ADD UNIQUE INDEX `scene_address_index`(`scene_address`) USING BTREE; | |||
| @@ -1,6 +1,6 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| @@ -11,13 +11,11 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.*; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.image.BufferedImage; | |||
| import java.util.*; | |||
| import java.util.List; | |||
| @@ -28,36 +26,40 @@ public class UploadController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| /** | |||
| * 上传文件 | |||
| * | |||
| * @param | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/awsFileUpload") | |||
| @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传文件") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 图片上传 | |||
| * | |||
| @@ -67,47 +69,54 @@ public class UploadController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq | |||
| ,@RequestParam Map<String, String> param) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| String tempFileName = UUID.randomUUID().toString(); | |||
| String fileFormat = ""; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| long size = multiReq.getSize(); | |||
| final long length = 2097152; | |||
| if (size > length) { | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||
| } | |||
| FileOutputStream fos = null; | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| String localImgFileName = fmUploadDir + tempFileName + "-1" + fileFormat; | |||
| String localNewImgFileName = fmUploadDir + tempFileName + fileFormat; | |||
| BufferedInputStream fs = null; | |||
| File localFile = new File(localImgFileName); | |||
| fos = new FileOutputStream(localFile); | |||
| fs = (BufferedInputStream) multiReq.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| String fileFormat = ""; | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| long maxSize = 0l; | |||
| try { | |||
| maxSize = Long.parseLong(param.get("size")); | |||
| } catch (NumberFormatException e) {} | |||
| if(maxSize > 0l && size > maxSize*1024){ | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_CUSTOMIZE); | |||
| } | |||
| BufferedImage bufferedImage = ImageIO.read(multiReq.getInputStream()); | |||
| if(bufferedImage != null){ | |||
| int width = 0;int hight = 0; | |||
| try { | |||
| width = Integer.parseInt(param.get("width")); | |||
| hight = Integer.parseInt(param.get("hight")); | |||
| } catch (NumberFormatException e) {} | |||
| Integer relWidth = bufferedImage.getWidth(); | |||
| Integer relHeight = bufferedImage.getHeight(); | |||
| if((width > 0 && width != relWidth.intValue()) | |||
| || (hight > 0 && hight != relHeight.intValue())){ | |||
| return new ResultData(ErrorCode.PICTURE_W_H_CUSTOMIZE); | |||
| } | |||
| } | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| File newFile = ImgUtil.thinImage(localImgFileName, localNewImgFileName, imgFormat); | |||
| // 删除本地缓存 | |||
| localFile.delete(); | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, new FileInputStream(newFile)); | |||
| // 删除本地缓存 | |||
| newFile.delete(); | |||
| return data; | |||
| } else { | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| @@ -120,42 +129,75 @@ public class UploadController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/awsFilesUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) throws Exception { | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if (files.length > 0) { | |||
| ResultData data = new ResultData(); | |||
| List<Map<String, String>> dataList = new ArrayList<Map<String, String>>(); | |||
| for (MultipartFile multipartFile : files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); | |||
| try { | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||
| } | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if (data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map) data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 内部接口-B端上传图片文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("内部接口-B端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile("bimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxCUserBasicChild; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| @@ -11,6 +12,7 @@ import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicChildService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.Constant; | |||
| @@ -35,6 +37,7 @@ import java.beans.PropertyEditorSupport; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @RestController | |||
| public class BaseController { | |||
| @@ -52,6 +55,9 @@ public class BaseController { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxCUserBasicChildService wxCUserBasicChildService; | |||
| @Autowired | |||
| private CUserTokenService cUserTokenService; | |||
| @@ -156,7 +162,9 @@ public class BaseController { | |||
| if (member == null) { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| RedisCacheUtils.cache(cuserBasicInfoTemplate, key, member, seconds); | |||
| setCUserBasicChild(member); | |||
| RedisCacheUtils.cache(cuserBasicInfoTemplate, key, member, seconds); | |||
| } | |||
| return member; | |||
| } | |||
| @@ -276,5 +284,13 @@ public class BaseController { | |||
| return ipaddress; | |||
| } | |||
| private void setCUserBasicChild(WxCUserBasicInfo basicInfo){ | |||
| WxCUserBasicChild child = new WxCUserBasicChild(); | |||
| child.setCUserId(basicInfo.getId()); | |||
| child.setTenantId(basicInfo.getFinalTenantId()); | |||
| List<WxCUserBasicChild> list = wxCUserBasicChildService.findList(child); | |||
| basicInfo.setChildrenList(list); | |||
| } | |||
| } | |||
| @@ -4,19 +4,20 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.utils.ImgUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.IOException; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.image.BufferedImage; | |||
| import java.util.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping(value = "/api/upload") | |||
| @@ -28,7 +29,6 @@ public class UploadController extends BaseController { | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| /** | |||
| * 上传文件 | |||
| * | |||
| @@ -43,20 +43,81 @@ public class UploadController extends BaseController { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 图片上传 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq | |||
| ,@RequestParam Map<String, String> param) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| long size = multiReq.getSize(); | |||
| final long length = 2097152; | |||
| if (size > length) { | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||
| } | |||
| String fileFormat = ""; | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| long maxSize = 0l; | |||
| try { | |||
| maxSize = Long.parseLong(param.get("size")); | |||
| } catch (NumberFormatException e) {} | |||
| if(maxSize > 0l && size > maxSize*1024){ | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_CUSTOMIZE); | |||
| } | |||
| BufferedImage bufferedImage = ImageIO.read(multiReq.getInputStream()); | |||
| if(bufferedImage != null){ | |||
| int width = 0;int hight = 0; | |||
| try { | |||
| width = Integer.parseInt(param.get("width")); | |||
| hight = Integer.parseInt(param.get("hight")); | |||
| } catch (NumberFormatException e) {} | |||
| Integer relWidth = bufferedImage.getWidth(); | |||
| Integer relHeight = bufferedImage.getHeight(); | |||
| if((width > 0 && width != relWidth.intValue()) | |||
| || (hight > 0 && hight != relHeight.intValue())){ | |||
| return new ResultData(ErrorCode.PICTURE_W_H_CUSTOMIZE); | |||
| } | |||
| } | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (IOException e) { | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| @@ -70,27 +131,26 @@ public class UploadController extends BaseController { | |||
| @ApiOperation("多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| try { | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||
| } | |||
| if (files.length > 0) { | |||
| ResultData data = new ResultData(); | |||
| List<Map<String, String>> dataList = new ArrayList<Map<String, String>>(); | |||
| for (MultipartFile multipartFile : files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if (data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map) data1.data; | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| @@ -99,18 +159,45 @@ public class UploadController extends BaseController { | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| } catch (IOException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 内部接口-C端上传图片文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("内部接口-C端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile("cimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -71,7 +71,7 @@ public class WxCreditHistoryController extends BaseController{ | |||
| wxCreditHistory.setTenantId(wxCUser.getFinalTenantId()); | |||
| wxCreditHistory.setCUserId(wxCUser.getUserId()); | |||
| wxCreditHistory.setOperatorId(wxCUser.getUserId()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| if(wxCreditHistory.getCreditType().equals(EnumScoreType.GAME_ADD_CREDIT.getCode())){ | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.GAME_ADD_CREDIT.getMessage()); | |||
| @@ -4,8 +4,10 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumGameStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| import com.iformall.service.WxGameService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -83,7 +85,9 @@ public class WxGameController extends BaseController { | |||
| public ResultData getCount(String gameId) { | |||
| try { | |||
| Long gameIdL = Long.valueOf(gameId); | |||
| return wxGameService.getCount(gameIdL,getMemberId()); | |||
| ResultData resultData = wxGameService.getCount(gameIdL, getMemberId()); | |||
| logger.info("游戏次数详情-----"+resultData.data.toString()); | |||
| return resultData; | |||
| } catch (Exception e){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| @@ -95,6 +99,7 @@ public class WxGameController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "gameId", value = "游戏ID", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData freeGameGo(@RequestBody Map<String,String> paramMap) { | |||
| logger.info("freeGameGo----start-------"+paramMap.get("gameId")); | |||
| try { | |||
| Long gameIdL = Long.valueOf(paramMap.get("gameId")); | |||
| if(gameIdL == null){ | |||
| @@ -105,22 +110,24 @@ public class WxGameController extends BaseController { | |||
| return new ResultData(ErrorCode.GAME_NOT_FOUND); | |||
| } | |||
| int playLimit = (int) data.get("playLimit"); | |||
| if(playLimit < 0){ | |||
| if(playLimit < Constant.limit){ | |||
| return new ResultData(ErrorCode.GAME_NOT_COUNT); | |||
| } | |||
| int AwardLimit = (int) data.get("AwardLimit"); | |||
| int AwardCount = (int) data.get("AwardCount"); | |||
| if(AwardLimit != 0 && AwardCount >= AwardLimit){ | |||
| if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){ | |||
| return new ResultData(ErrorCode.GAME_NOT_WIN_COUNT); | |||
| } | |||
| int playCount = (int) data.get("playCount"); | |||
| if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){ | |||
| if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){ | |||
| return new ResultData(ErrorCode.GAME_NOT_HAVE_COUNT); | |||
| } | |||
| ResultData resultData = wxGameService.luckDraw(gameIdL, getMemberId(),0); | |||
| removeCacheCUser(); | |||
| return resultData; | |||
| } catch (MallinkException me){ | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } catch (Exception e){ | |||
| logger.error("freeGameGo------error-------",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| @@ -131,6 +138,7 @@ public class WxGameController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "gameId", value = "游戏ID", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData freeCridetGameGo(@RequestBody Map<String,String> paramMap) { | |||
| logger.info("freeCridetGameGo-----start-------"+paramMap.get("gameId")); | |||
| try { | |||
| Long gameIdL = Long.valueOf(paramMap.get("gameId")); | |||
| if(gameIdL == null){ | |||
| @@ -141,28 +149,30 @@ public class WxGameController extends BaseController { | |||
| return new ResultData(ErrorCode.GAME_NOT_FOUND); | |||
| } | |||
| int playLimit = (int) data.get("playLimit"); | |||
| if(playLimit < 0){ | |||
| return new ResultData(ErrorCode.GAME_NOT_COUNT); | |||
| } | |||
| // if(playLimit < Constant.limit){ | |||
| // return new ResultData(ErrorCode.GAME_NOT_COUNT); | |||
| // } | |||
| int AwardLimit = (int) data.get("AwardLimit"); | |||
| int AwardCount = (int) data.get("AwardCount"); | |||
| if(AwardLimit != 0 && AwardCount >= AwardLimit){ | |||
| if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){ | |||
| return new ResultData(ErrorCode.GAME_NOT_WIN_COUNT); | |||
| } | |||
| int playCount = (int) data.get("playCount"); | |||
| if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){ | |||
| if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){ | |||
| int playCreditLimit = (int) data.get("playCreditLimit"); | |||
| int playCreditCount = (int) data.get("playCreditCount"); | |||
| if((playCreditLimit > 0 && playCreditCount >= playCreditLimit) || playCreditLimit < 0){//积分不能玩了 | |||
| if((playCreditLimit > Constant.limit && playCreditCount >= playCreditLimit) || playCreditLimit == Constant.notLimit){//积分不能玩了 | |||
| return new ResultData(ErrorCode.GAME_NOT_HAVEC_COUNT); | |||
| } | |||
| }else{ | |||
| return new ResultData(ErrorCode.GAME_HAVE_COUNT); | |||
| } | |||
| ResultData resultData = wxGameService.cridetLuckDraw(gameIdL, getMemberId()); | |||
| removeCacheCUser(); | |||
| return resultData; | |||
| } catch (MallinkException me){ | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } catch (Exception e){ | |||
| logger.error("freeCridetGameGo------error-------",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| @@ -8,7 +8,6 @@ import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| @@ -42,7 +41,6 @@ import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| @RestController | |||
| @RequestMapping("/api/user") | |||
| @@ -224,9 +222,6 @@ public class WxUserGrantController extends BaseController { | |||
| String session_key = null; | |||
| String openId = null; | |||
| String unionId = null; | |||
| boolean boolHaveUnionId = false; | |||
| boolean boolFindByUnionId = false; | |||
| Long userId = null; | |||
| try { | |||
| WxMaJscode2SessionResult session = wxMaService.jsCode2SessionInfo(code); | |||
| @@ -239,9 +234,6 @@ public class WxUserGrantController extends BaseController { | |||
| session_key = session.getSessionKey(); | |||
| openId = session.getOpenid(); | |||
| unionId = session.getUnionid(); | |||
| // if (StringUtils.isNotBlank(unionId)) { | |||
| // boolHaveUnionId = true; | |||
| // } | |||
| logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); | |||
| resultMap.put("openId", openId); | |||
| @@ -251,75 +243,31 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| WxCUser newUser = new WxCUser(); | |||
| newUser.updateTenantInfo(wxMall.getTenantInfo()); | |||
| newUser.setAppId(appId); | |||
| newUser.setOpenId(openId); | |||
| if (boolHaveUnionId) { | |||
| newUser.setUnionId(unionId); | |||
| } | |||
| WxCUser oldUser = null; | |||
| // if (boolHaveUnionId) { | |||
| // // 优先根据unionId查询 | |||
| // WxCUser userQ = new WxCUser(); | |||
| // userQ.updateTenantInfo(wxMall.getTenantInfo()); | |||
| // userQ.setUnionId(unionId); | |||
| // oldUser = wxCUserService.getByObject(userQ); | |||
| // if(oldUser != null) { | |||
| // boolFindByUnionId = true; | |||
| // } | |||
| // } | |||
| if (oldUser == null) { | |||
| oldUser = wxCUserService.getByOpenId(newUser); | |||
| } | |||
| WxCUser oldUser = wxCUserService.getByOpenId(newUser); | |||
| if (oldUser != null) { | |||
| // 已有用户 | |||
| token = oldUser.createToken(new Date(),oldUser.getTenantId()); | |||
| resultMap.put("token", token); | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | |||
| request.setAttribute(Constant.TENANT_ID, oldUser.getTenantId()); | |||
| if(StringUtils.isBlank(oldUser.getParentTenantId()) && StringUtils.isNotBlank(wxMall.getParentTenantId())){ | |||
| oldUser.setParentTenantId(wxMall.getParentTenantId()); | |||
| } | |||
| if(StringUtils.isNotBlank(oldUser.getParentTenantId())){ | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, oldUser.getParentTenantId()); | |||
| } | |||
| // 老用户,给出来已选中的mall | |||
| // if (mallList != null) { | |||
| // WxMall selectedMall = null; | |||
| // if (StringUtils.isNotBlank(oldUser.getParentTenantId())) { | |||
| // final String lastSubTenant = oldUser.getTenantId(); | |||
| // List<WxMall> selMallList = mallList.stream().filter(ml -> ml.getTenantId().equalsIgnoreCase(lastSubTenant)).collect(Collectors.toList()); | |||
| // if (selMallList.size() > 0) { | |||
| // selectedMall = selMallList.get(0); | |||
| // } | |||
| // } | |||
| // if (selectedMall == null){ | |||
| // WxMall firstMall = mallList.get(0); | |||
| // if (firstMall != null) { | |||
| // selectedMall = firstMall; | |||
| // } | |||
| // } | |||
| // if (selectedMall != null) { | |||
| // request.setAttribute(Constant.TENANT_ID, selectedMall.getTenantId()); | |||
| // resultMap.put("selectedMall", selectedMall.getTenantId()); | |||
| //// oldUser.setParentTenantId(selectedMall.getParentTenantId()); | |||
| // } | |||
| // } | |||
| oldUser.setRegisterIp(ipaddress); | |||
| oldUser.setSessionKey(session_key); | |||
| oldUser.setAppId(appId); | |||
| oldUser.setOpenId(openId); | |||
| if (boolHaveUnionId) { | |||
| oldUser.setUnionId(unionId); | |||
| } | |||
| oldUser.setUnionId(unionId); | |||
| if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | |||
| oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | |||
| } | |||
| @@ -328,7 +276,7 @@ public class WxUserGrantController extends BaseController { | |||
| oldUser.setSceneAddress(sceneAddress); | |||
| } | |||
| if (StringUtils.isBlank(oldUser.getScene()) || | |||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||
| oldUser.setScene(scene); | |||
| } | |||
| if (StringUtils.isNotBlank(longitude)) { | |||
| @@ -345,12 +293,14 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| oldUser.setLoginCount(oldUser.getLoginCount() + 1); | |||
| oldUser.setActiveTime(new Date()); | |||
| wxCUserService.saveOrUpdate(oldUser); | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | |||
| // 登录后处理 | |||
| int score = wxCUserService.actionAfterLogin(oldUser, boolFindByUnionId); | |||
| updateCacheCUser(token, oldUser); | |||
| resultMap.put("score", score); | |||
| // 登录后处理 | |||
| wxCUserService.actionMsgAfterLogin(oldUser); | |||
| } else { | |||
| // 新用户 | |||
| newUser.updateTenantInfo(wxMall.getTenantInfo()); | |||
| @@ -358,6 +308,7 @@ public class WxUserGrantController extends BaseController { | |||
| newUser.setParentTenantId(wxMall.getParentTenantId()); | |||
| } | |||
| token = newUser.createToken(new Date(),newUser.getTenantId()); | |||
| resultMap.put("token", token); | |||
| newUser.setRegisterIp(ipaddress); | |||
| if (StringUtils.isNotBlank(sceneAddress) && | |||
| @@ -382,30 +333,14 @@ public class WxUserGrantController extends BaseController { | |||
| newUser.setExtraInfo(extraInfo.toJSONString()); | |||
| } | |||
| newUser.setLoginCount(1); | |||
| oldUser.setActiveTime(new Date()); | |||
| wxCUserService.saveOrUpdate(newUser); | |||
| resultMap.put("token", token); | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); | |||
| request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); | |||
| if(StringUtils.isNotBlank(newUser.getParentTenantId())){ | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, newUser.getParentTenantId()); | |||
| } | |||
| // if (mallList != null) { | |||
| // WxMall firstMall = mallList.get(0); | |||
| // if (firstMall != null) { | |||
| // // 默认选中第一个mall, 或者经纬度最近的那个 | |||
| // request.setAttribute(Constant.TENANT_ID, firstMall.getTenantId()); | |||
| // resultMap.put("selectedMall", firstMall.getTenantId()); | |||
| // newUser.setParentTenantId(firstMall.getTenantId()); | |||
| // } | |||
| // } | |||
| // 登录后处理 | |||
| int score = wxCUserService.actionAfterLogin(newUser, null); | |||
| resultMap.put("score", score); | |||
| updateCacheCUser(token, newUser); | |||
| // 登录后处理 | |||
| wxCUserService.actionMsgAfterLogin(newUser); | |||
| } | |||
| if (StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token) ) { | |||
| @@ -794,6 +729,7 @@ public class WxUserGrantController extends BaseController { | |||
| userVo.setSex(wxCUserBasicInfo.getSex()); | |||
| userVo.setAddress(wxCUserBasicInfo.getAddress()); | |||
| userVo.setStatus(wxCUserBasicInfo.getStatus()); | |||
| userVo.setChildrenList(wxCUserBasicInfo.getChildrenList()); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("userinfo error.",e); | |||
| @@ -946,6 +882,8 @@ public class WxUserGrantController extends BaseController { | |||
| record.setAddress(wxCUserBasicInfo.getAddress()); | |||
| record.setUpdateDate(new Date()); | |||
| record.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| record.setChildrenList(wxCUserBasicInfo.getChildrenList()); | |||
| record.setUpdChild(true); | |||
| wxCUserBasicInfoService.update(record); | |||
| wxScoreRulesService.addScore(tenantEntity,EnumScoreType.COMPLETE_INFO, record); | |||
| //增加积分 | |||
| @@ -957,7 +895,7 @@ public class WxUserGrantController extends BaseController { | |||
| wxCreditHistory.setCreateDate(new Date()); | |||
| wxCreditHistory.setCreditType(EnumScoreType.COMPLETE_INFO.getCode()); | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.COMPLETE_INFO.getMessage()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(memberId); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, record,tenantEntity); | |||
| @@ -544,6 +544,8 @@ public enum ErrorCode{ | |||
| */ | |||
| PICTURE_SIZE_EXCEED(40001, "图片超过2M限制"), | |||
| PICTURE_ANALYZING_ERROR(40002, "您上传的图片无法解析,请检查"), | |||
| PICTURE_SIZE_CUSTOMIZE(40003, "图片超过大小限制"), | |||
| PICTURE_W_H_CUSTOMIZE(40004, "图片不符合宽高限制"), | |||
| /** | |||
| * 电费生成配置 | |||
| @@ -82,6 +82,13 @@ public class BaseMyBatisConfiguration { | |||
| wxbasicChildSharding.setCount(100); | |||
| wxbasicChildSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(wxbasicChildSharding); | |||
| ShardingSphere wxCUserFromSharding = new ShardingSphere(); | |||
| wxCUserFromSharding.setColumn("tenant_id"); | |||
| wxCUserFromSharding.setTableName("wx_c_user_from"); | |||
| wxCUserFromSharding.setCount(100); | |||
| wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(wxCUserFromSharding); | |||
| ShardingSphere wxOrderSharding = new ShardingSphere(); | |||
| wxOrderSharding.setColumn("tenant_id"); | |||
| @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.TenantEntityWithoutFinalTenantId; | |||
| @@ -130,6 +129,9 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| @TableField(exist = false) | |||
| private List<WxCUserBasicChild> childrenList; | |||
| @TableField(exist = false) | |||
| private boolean updChild = false; | |||
| @TableField(exist = false) | |||
| private String tagIds; | |||
| @@ -0,0 +1,104 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCUserFrom; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_c_user_from") | |||
| @JsonIgnoreProperties(ignoreUnknown = true) | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserFrom extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | |||
| protected Long cUserId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserNickName",name="cUserNickName") | |||
| protected String cUserNickName; | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") | |||
| private String scene; | |||
| @io.swagger.annotations.ApiModelProperty(value="渠道,小程序",name="sceneAddress") | |||
| private String sceneAddress; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="sceneAddress描述",name="sceneAddressDesc") | |||
| private String sceneAddressDesc; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumCUserFrom",name="fromType") | |||
| private Integer fromType; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="fromType描述",name="fromTypeDesc") | |||
| private String fromTypeDesc; | |||
| public String getFromTypeDesc(){ | |||
| if(this.getFromType() != null){ | |||
| EnumCUserFrom anEnum = EnumCUserFrom.getEnum(this.getFromType()); | |||
| if(anEnum != null){ | |||
| fromTypeDesc = anEnum.getMessage(); | |||
| } | |||
| } | |||
| return fromTypeDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="来源ID",name="fromId") | |||
| protected Long fromId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源Name",name="fromName") | |||
| protected String fromName; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户(0:否1:是)EnumYesOrNo",name="isNewUser") | |||
| private Integer isNewUser; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户",name="isNewUserStr") | |||
| private String isNewUserStr; | |||
| public String getIsNewUserStr(){ | |||
| if(this.getIsNewUser() != null){ | |||
| EnumYesOrNo anEnum = EnumYesOrNo.getEnum(this.getFromType()); | |||
| if(anEnum != null){ | |||
| isNewUserStr = anEnum.getMessage(); | |||
| } | |||
| } | |||
| return isNewUserStr; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="分享者 EnumUserType",name="shareUserType") | |||
| private Integer shareUserType; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="shareUserType描述",name="shareUserType") | |||
| private String shareUserTypeDesc; | |||
| public String getShareUserTypeDesc(){ | |||
| if(this.getShareUserType() != null){ | |||
| EnumUserType anEnum = EnumUserType.getEnum(this.getFromType()); | |||
| if(anEnum != null){ | |||
| shareUserTypeDesc = anEnum.getMessage(); | |||
| } | |||
| } | |||
| return shareUserTypeDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUser") | |||
| protected Long shareUser; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUserName") | |||
| protected String shareUserName; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @TableField(exist = false) | |||
| protected Date startDate; | |||
| @TableField(exist = false) | |||
| protected Date endDate; | |||
| } | |||
| @@ -8,15 +8,18 @@ import lombok.ToString; | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class FmInsideCLoginMsg extends BaseMsg{ | |||
| private static final long serialVersionUID = 1L; | |||
| @io.swagger.annotations.ApiModelProperty(value = "id", name = "id") | |||
| private Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="父租户id",name="parentTenantId") | |||
| private String parentTenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "cUserId") | |||
| private Long cUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId") | |||
| private Long userId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否从unionId更新", name = "findByUnionId") | |||
| private Boolean findByUnionId; | |||
| } | |||
| @@ -1,12 +1,15 @@ | |||
| package com.iformall.domain.vo; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicChild; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| * Created by syf on 2018/8/30. | |||
| @@ -39,4 +42,7 @@ public class WxCUserVo extends WxCUser { | |||
| @io.swagger.annotations.ApiModelProperty(value = "0正常1锁定", name = "status") | |||
| private Integer status; | |||
| @TableField(exist = false) | |||
| private List<WxCUserBasicChild> childrenList; | |||
| } | |||
| @@ -0,0 +1,43 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author Stormeye | |||
| */ | |||
| public enum EnumCUserFrom { | |||
| FROM_C_USER(1,"来源于微信用户"), | |||
| FROM_C_USER_BASIC_INFO(2,"来源于会员"), | |||
| FROM_MERCHANT_B_USER(3,"来源于B端用户"), | |||
| FROM_MALL_USER_INFO(4,"来源于A端用户"), | |||
| FROM_MERCHANT(5,"来源于门店"), | |||
| FROM_COUPON_CHANNEL(6,"来源于卷"), | |||
| FROM_ACTIVITY(7,"来源于活动"), | |||
| ; | |||
| public static EnumCUserFrom getEnum(Integer code) { | |||
| for (EnumCUserFrom value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCUserFrom(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -3,7 +3,7 @@ package com.iformall.enums; | |||
| public enum EnumUserType { | |||
| CUSER(1, "C端用户"), | |||
| CUSERBASIC(2, "C端用户(偏向A端)"), | |||
| CUSERBASIC(2, "C端用户(会员)"), | |||
| BUSER(3, "B端用户"), | |||
| MALLUSER(4, "A端用户") | |||
| ; | |||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCUserBasicChild; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import java.util.List; | |||
| @@ -12,4 +13,5 @@ public interface WxCUserBasicChildMapper extends CommonMapper<WxCUserBasicChild, | |||
| int updDelById(WxCUserBasicChild record); | |||
| int deleteByUserBasicId(WxCUserBasicChild record); | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| import java.util.List; | |||
| public interface WxCUserFromMapper extends CommonMapper<WxCUserFrom, Long>{ | |||
| List<WxCUserFrom> findList(WxCUserFrom record); | |||
| } | |||
| @@ -14,5 +14,6 @@ public interface WxCUserBasicChildService { | |||
| int updDelById(WxCUserBasicChild record); | |||
| int deleteByUserBasicId(WxCUserBasicChild record); | |||
| } | |||
| @@ -83,7 +83,6 @@ public interface WxCUserBasicInfoService { | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| //void deleteById(Long id); | |||
| @@ -152,14 +151,12 @@ public interface WxCUserBasicInfoService { | |||
| /** | |||
| * 自然增长用户 | |||
| * @param dto | |||
| * @return | |||
| */ | |||
| long findGrowUserCount(TenantEntity tenantEntity); | |||
| /** | |||
| * 导入用户数 | |||
| * @param dto | |||
| * @return | |||
| */ | |||
| long findImportUserCount(TenantEntity tenantEntity); | |||
| @@ -0,0 +1,19 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| public interface WxCUserFromService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | |||
| } | |||
| @@ -125,14 +125,14 @@ public interface WxCUserService { | |||
| * 登录后发消息 | |||
| * @param user | |||
| */ | |||
| void actionMsgAfterLogin(WxCUser user, Boolean findByUnionId); | |||
| void actionMsgAfterLogin(WxCUser user); | |||
| /** | |||
| * 登录后处理 | |||
| * @param user | |||
| * @return | |||
| */ | |||
| int actionAfterLogin(WxCUser user, Boolean findByUnionId); | |||
| int actionAfterLogin(WxCUser user); | |||
| /** | |||
| * 积分 | |||
| @@ -52,4 +52,9 @@ public class WxCUserBasicChildServiceImpl implements WxCUserBasicChildService { | |||
| public int updDelById(WxCUserBasicChild record) { | |||
| return wxCUserBasicChildMapper.updDelById(record); | |||
| } | |||
| @Override | |||
| public int deleteByUserBasicId(WxCUserBasicChild record) { | |||
| return wxCUserBasicChildMapper.deleteByUserBasicId(record); | |||
| } | |||
| } | |||
| @@ -65,6 +65,9 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| @Autowired | |||
| WxCUserTagsService wxCUserTagsService; | |||
| @Autowired | |||
| WxCUserBasicChildService wxCUserBasicChildService; | |||
| @Autowired | |||
| WxScoreRulesService wxScoreRulesService; | |||
| @@ -642,6 +645,20 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| @Override | |||
| public void update(WxCUserBasicInfo record) { | |||
| if(record.isUpdChild()){ | |||
| WxCUserBasicChild childvo = new WxCUserBasicChild(); | |||
| childvo.setCUserId(record.getId()); | |||
| childvo.setTenantId(record.getFinalTenantId()); | |||
| wxCUserBasicChildService.deleteByUserBasicId(childvo); | |||
| List<WxCUserBasicChild> childrenList = record.getChildrenList(); | |||
| if(childrenList != null && childrenList.size() > 0){ | |||
| for (WxCUserBasicChild child:childrenList) { | |||
| child.setId(null); | |||
| child.setCUserId(record.getId()); | |||
| wxCUserBasicChildService.saveOrUpdate(child); | |||
| } | |||
| } | |||
| } | |||
| wxCUserBasicInfoMapper.updateById(record); | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| @Slf4j | |||
| public class WxCUserFromServiceImpl implements WxCUserFromService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCUserFromMapper wxCUserFromMapper; | |||
| @Override | |||
| public PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.findList(record)); | |||
| } | |||
| } | |||
| @@ -88,19 +88,19 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| Date curr = new Date(); | |||
| if (user.getId() == null) { | |||
| // 检查用户是否已有同一微信开放平台账号 | |||
| if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { | |||
| WxCUser oldUser = wxCUserMapper.findByUnionId(user); | |||
| if(oldUser != null) { | |||
| // 已有,更新 | |||
| user.setId(oldUser.getId()); | |||
| user.setLoginCount(oldUser.getLoginCount()==null?0:oldUser.getLoginCount() + 1); | |||
| user.setUpdateDate(curr); | |||
| user.updateTenantInfo(oldUser); | |||
| // TODO 是否其他信息需要更新 | |||
| ret = wxCUserMapper.updateById(user); | |||
| return ret; | |||
| } | |||
| } | |||
| // if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { | |||
| // WxCUser oldUser = wxCUserMapper.findByUnionId(user); | |||
| // if(oldUser != null) { | |||
| // // 已有,更新 | |||
| // user.setId(oldUser.getId()); | |||
| // user.setLoginCount(oldUser.getLoginCount()==null?0:oldUser.getLoginCount() + 1); | |||
| // user.setUpdateDate(curr); | |||
| // user.updateTenantInfo(oldUser); | |||
| // // TODO 是否其他信息需要更新 | |||
| // ret = wxCUserMapper.updateById(user); | |||
| // return ret; | |||
| // } | |||
| // } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| user.setId(idWorker.nextId()); | |||
| user.setLoginCount(1); | |||
| @@ -253,18 +253,18 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| } | |||
| @Override | |||
| public void actionMsgAfterLogin(WxCUser user, Boolean findByUnionId) { | |||
| public void actionMsgAfterLogin(WxCUser user) { | |||
| FmInsideCLoginMsg loginMsg = new FmInsideCLoginMsg(); | |||
| loginMsg.setId(user.getId()); | |||
| loginMsg.setMsgType(EnumMsgRecordType.INSIDE_C_LOGIN.getCode()); | |||
| loginMsg.updateTenantInfo(user); | |||
| loginMsg.setCUserId(user.getId()); | |||
| loginMsg.setFindByUnionId(findByUnionId); | |||
| loginMsg.setUserId(user.getUserId()); | |||
| mqBaseProducer.sendMessage(loginMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| } | |||
| @Override | |||
| public int actionAfterLogin(WxCUser user, Boolean findByUnionId) { | |||
| public int actionAfterLogin(WxCUser user) { | |||
| int score = 0; | |||
| int credit = 0; | |||
| // 成长值 | |||
| @@ -291,43 +291,28 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| if (wxCUserBasicInfo != null) { | |||
| WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); | |||
| basicInfo.setId(wxCUserBasicInfo.getId()); | |||
| basicInfo.setFinalTenantId(user.getFinalTenantId()); | |||
| basicInfo.setActiveTime(new Date()); | |||
| int loingcount = 0; | |||
| try { | |||
| loingcount = Integer.parseInt(wxCUserBasicInfo.getLoginCount().toString()); | |||
| }catch(Exception e) { | |||
| } | |||
| basicInfo.setFinalTenantId(user.getFinalTenantId()); | |||
| basicInfo.setLoginCount(loingcount+1); | |||
| wxCUserBasicInfoService.update(basicInfo); | |||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_LOGIN, user,user); | |||
| } | |||
| WxCUser wxCUser = getById(user.getId(),user.getTenantId()); | |||
| if (wxCUser != null) { | |||
| WxCUser cUser = new WxCUser(); | |||
| cUser.setId(user.getId()); | |||
| cUser.setActiveTime(new Date()); | |||
| cUser.setTenantId(user.getTenantId()); | |||
| saveOrUpdate(cUser); | |||
| } | |||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_LOGIN, wxCUser,user); | |||
| } | |||
| // 用户从unionId来的,可能会有重复 | |||
| // if(findByUnionId != null) { | |||
| // if(findByUnionId) { | |||
| // WxCUser userQ = new WxCUser(); | |||
| // userQ.setOpenAppId(user.getAppId()); | |||
| // userQ.setOpenId(user.getOpenId()); | |||
| // List<WxCUser> userList = wxCUserMapper.findList(userQ); | |||
| // if(userList.size() > 1) { | |||
| // for(WxCUser tempUser: userList) { | |||
| // if(tempUser.getUnionId() == null) { | |||
| // // 删除 无unionId的用户 | |||
| // wxCUserMapper.deleteById(tempUser.getId()); | |||
| // } | |||
| // } | |||
| // } | |||
| // WxCUser wxCUser = getById(user.getId(),user.getTenantId()); | |||
| // if (wxCUser != null) { | |||
| // WxCUser cUser = new WxCUser(); | |||
| // cUser.setId(user.getId()); | |||
| // cUser.setActiveTime(new Date()); | |||
| // cUser.setTenantId(user.getTenantId()); | |||
| // saveOrUpdate(cUser); | |||
| // } | |||
| // } | |||
| } | |||
| String key = Constant.tokenPrev + user.getToken(); | |||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||
| baseCUserTokenRedisTemplate.delete(key); | |||
| @@ -349,10 +334,7 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| wxCreditHistory.setChangePurpose(enumScoreType.getMessage()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(user.getUserId()); | |||
| // wxCreditHistory.setCreditNum(user.getCredit()); | |||
| // wxCreditHistory.setCreditAmount(user.getCredit()); | |||
| WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| // user.setCredit(record.getCreditAmount()); | |||
| return record.getCreditAmount(); | |||
| } | |||
| @@ -606,7 +606,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| return resList; | |||
| } | |||
| private List<WxTags> assignTypeId21(WxCUserBasicInfo user,String tenantId) { | |||
| private List<WxTags> assignTypeId21(WxCUserBasicInfo user,TenantEntity tenantEntity) { | |||
| List<WxTags> resList = null; | |||
| Calendar startC = Calendar.getInstance(); | |||
| startC.setTime(new Date()); | |||
| @@ -616,7 +616,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| wxCouponOrder.setCUserId(user.getId()); | |||
| wxCouponOrder.setStartTime(startC.getTime()); | |||
| wxCouponOrder.setEndTime(new Date()); | |||
| wxCouponOrder.setTenantId(tenantId); | |||
| wxCouponOrder.updateTenantInfo(tenantEntity); | |||
| int count = wxCouponOrderMapper.findCount(wxCouponOrder); | |||
| @@ -715,27 +715,27 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| WxCUserBasicInfo param = (WxCUserBasicInfo) obj; | |||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(param.getId(),param.getFinalTenantId()); | |||
| if (user != null) { | |||
| if (param.getSex() != null) { | |||
| if (user.getSex() != null) { | |||
| //性别 | |||
| resList = assignTypeId1(user, param.getSex()); | |||
| resList = assignTypeId1(user, user.getSex()); | |||
| } | |||
| if (param.getBirthdate() != null) { | |||
| if (user.getBirthdate() != null) { | |||
| //X0后 | |||
| resList = assignTypeId2(user, param.getBirthdate()); | |||
| resList = assignTypeId2(user, user.getBirthdate()); | |||
| //生肖 | |||
| resList = assignTypeId3(user, param.getBirthdate()); | |||
| resList = assignTypeId3(user, user.getBirthdate()); | |||
| //星座 | |||
| resList = assignTypeId4(user, param.getBirthdate()); | |||
| resList = assignTypeId4(user, user.getBirthdate()); | |||
| } | |||
| if (param.getPhone() != null) { | |||
| if (user.getPhone() != null) { | |||
| //来源 | |||
| resList = assignTypeId5(user, false); | |||
| //运营商 | |||
| resList = assignTypeId7(user, param.getPhone()); | |||
| resList = assignTypeId7(user, user.getPhone()); | |||
| } | |||
| if (param.getEducation() != null) { | |||
| if (user.getEducation() != null) { | |||
| //学历 | |||
| resList = assignTypeId6(user, param.getEducation()); | |||
| resList = assignTypeId6(user, user.getEducation()); | |||
| } | |||
| resList = assignTypeId29(user); | |||
| } | |||
| @@ -754,11 +754,11 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| WxCUser param = (WxCUser) obj; | |||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(param.getUserId(),param.getFinalTenantId()); | |||
| if (user != null) { | |||
| if (param.getPhone() != null) { | |||
| if (user.getPhone() != null) { | |||
| //来源 | |||
| resList = assignTypeId5(user, true); | |||
| //运营商 | |||
| resList = assignTypeId7(user, param.getPhone()); | |||
| resList = assignTypeId7(user, user.getPhone()); | |||
| } | |||
| } | |||
| } | |||
| @@ -782,24 +782,25 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| case ASSIGN_TAGS_TRIGGER_LOGIN: { | |||
| WxCUser param = (WxCUser) obj; | |||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(param.getUserId(),param.getFinalTenantId()); | |||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(param.getUserId(),param.getFinalTenantId()); | |||
| if (user != null) { | |||
| if (param.getGender() != null) { | |||
| if (user.getSex() != null) { | |||
| //性别 | |||
| resList = assignTypeId1(user, param.getGender()); | |||
| resList = assignTypeId1(user, user.getSex()); | |||
| } | |||
| if (param.getExtraInfo() != null) { | |||
| //手机品牌 | |||
| resList = assignTypeId9(user, param.getExtraInfo()); | |||
| } | |||
| if (param.getPhone() != null) { | |||
| if (user.getPhone() != null) { | |||
| //来源 | |||
| resList = assignTypeId5(user, true); | |||
| //运营商 | |||
| resList = assignTypeId7(user, param.getPhone()); | |||
| resList = assignTypeId7(user, user.getPhone()); | |||
| } | |||
| //活跃 | |||
| resList = assignTypeId21(user,param.getTenantId()); | |||
| resList = assignTypeId21(user,tenantEntity); | |||
| } | |||
| } | |||
| break; | |||
| @@ -843,7 +844,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| //消费频度 | |||
| resList = assignTypeId22(user); | |||
| //活跃 | |||
| resList = assignTypeId21(user,suser.getTenantId()); | |||
| resList = assignTypeId21(user,tenantEntity); | |||
| //车 | |||
| WxCUserCar wxCUserCar = new WxCUserCar(); | |||
| @@ -157,7 +157,7 @@ public class WxGameServiceImpl implements WxGameService { | |||
| WxGameActionLog wxGameActionLog = new WxGameActionLog(); | |||
| if(wxGame.getLimitType().equals(1)){//每天 | |||
| if(wxGame.getLimitType().equals(Constant.limitType)){//每天 | |||
| Calendar calendar = Calendar.getInstance(); | |||
| calendar.setTime(new Date()); | |||
| calendar.set(Calendar.HOUR_OF_DAY, 0); | |||
| @@ -197,11 +197,11 @@ public class WxGameServiceImpl implements WxGameService { | |||
| map.put("AwardCount",AwardCount);//当前中奖次数 | |||
| boolean playAble = true; | |||
| if(AwardLimit != 0 && AwardCount >= AwardLimit){//中奖次数没了,不能完了 | |||
| if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){//中奖次数没了,不能完了 | |||
| playAble = false; | |||
| } | |||
| if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){//免费不能玩了 | |||
| if((playCreditLimit > 0 && playCreditCount >= playCreditLimit) || playCreditLimit < 0){//积分不能玩了 | |||
| if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){//免费不能玩了 | |||
| if((playCreditLimit > Constant.limit && playCreditCount >= playCreditLimit) || playCreditLimit == Constant.notLimit){//积分不能玩了 | |||
| playAble = false; | |||
| } | |||
| } | |||
| @@ -231,16 +231,17 @@ public class WxGameServiceImpl implements WxGameService { | |||
| List couponIdsList = new ArrayList(); | |||
| JSONArray couponChannelIds = JSON.parseArray(record.getCouponIds()); | |||
| ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); | |||
| for(int i=0; i<couponChannelIds.size();i++) { | |||
| for(int i = 0; i<couponChannelIds.size();i++) { | |||
| JSONObject couponChanObj = (JSONObject) couponChannelIds.get(i); | |||
| Integer type = couponChanObj.getInteger("prizeType"); | |||
| if(type != null && type == 0){ | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("prizeType",0); | |||
| map.put("gameWeight",couponChanObj.getInteger("weight")); | |||
| map.put("credit",couponChanObj.getInteger("credit")); | |||
| map.put("couponId",couponChanObj.getLong("couponId")); | |||
| couponIdsList.add(map); | |||
| Integer prizeType = couponChanObj.getInteger("prizeType"); | |||
| if(prizeType != null && prizeType == Constant.creditPlayType){ | |||
| // Map jsonToMap = JSONObject.parseObject(couponChanObj.toJSONString()); | |||
| // Map<String,Object> map = new HashMap<>(); | |||
| // map.put("prizeType",Constant.creditPlayType); | |||
| // map.put("gameWeight",couponChanObj.getInteger("weight")); | |||
| // map.put("credit",couponChanObj.getInteger("credit")); | |||
| // map.put("id",couponChanObj.getLong("id")); | |||
| couponIdsList.add(couponChanObj); | |||
| }else{ | |||
| Long couponId = couponChanObj.getLong("couponId"); | |||
| @@ -327,14 +328,16 @@ public class WxGameServiceImpl implements WxGameService { | |||
| // 上架 couponChannel 更新 | |||
| for(int i=0; i<couponIds.size();i++) { | |||
| JSONObject obj = (JSONObject)couponIds.get(i); | |||
| Long couponId = obj.getLong("couponId"); | |||
| int weight = obj.getIntValue("weight"); | |||
| try { | |||
| if(couponId != null){ | |||
| saveOrUpdateCouponChannel(couponId, wxCouponChannelsMap, record); | |||
| Integer prizeType = obj.getInteger("prizeType"); | |||
| if(prizeType == null || prizeType != Constant.creditPlayType){ | |||
| Long couponId = obj.getLong("couponId"); | |||
| try { | |||
| if(couponId != null){ | |||
| saveOrUpdateCouponChannel(couponId, wxCouponChannelsMap, record); | |||
| } | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| } | |||
| @@ -422,12 +425,13 @@ public class WxGameServiceImpl implements WxGameService { | |||
| if(couponIdsList != null || couponIdsList.size() > 0){ | |||
| for (Object a:couponIdsList) { | |||
| int weight = 0; | |||
| if(a instanceof Map){ | |||
| Map map = (Map) a; | |||
| weight = (int) map.get("gameWeight"); | |||
| }else if(a instanceof WxCouponChannelVo){ | |||
| if(a instanceof WxCouponChannelVo){ | |||
| WxCouponChannelVo vo = (WxCouponChannelVo) a; | |||
| weight = vo.getGameWeight(); | |||
| }else if(a instanceof JSONObject){ | |||
| JSONObject map = (JSONObject) a; | |||
| Integer w = map.getInteger("weight"); | |||
| weight = (w==null?0:w); | |||
| } | |||
| y += weight; | |||
| if(x <= y){ | |||
| @@ -440,43 +444,48 @@ public class WxGameServiceImpl implements WxGameService { | |||
| Long orderId = 0L; | |||
| Integer addCredit = 0; | |||
| if(data != null){ | |||
| if(data instanceof Map){ | |||
| Map dataMap = (Map) data; | |||
| logger.info("userId:"+userId+",中奖了,"+data.toString()); | |||
| if(data instanceof WxCouponChannelVo){ | |||
| WxCouponChannelVo vo = (WxCouponChannelVo) data; | |||
| OrderSaveDto orderSaveDto = new OrderSaveDto(); | |||
| orderSaveDto.setCouponChannelId(vo.getId()); | |||
| orderSaveDto.setCouponId(vo.getCouponId()); | |||
| ResultData resultData1 = wxOrderService.saveOrder(orderSaveDto, userId, EnumPayWay.PAY_WAY_WECHAT, wxGame); | |||
| if(resultData1.code == Result.SUCCESS && resultData1.data != null && resultData1.data instanceof WxOrder){ | |||
| WxOrder order = (WxOrder)resultData1.data; | |||
| orderId = order.getId(); | |||
| }else{ | |||
| logger.info("userId:"+userId+",中奖了发卷失败,"+resultData1.toString()); | |||
| resultData.data = null; | |||
| } | |||
| }else if(data instanceof JSONObject){ | |||
| JSONObject dataMap = (JSONObject) data; | |||
| // Integer prizeType = (Integer) dataMap.get("prizeType"); | |||
| // if(prizeType != null && prizeType == 0){ | |||
| Integer credit = (Integer) dataMap.get("credit"); | |||
| if(credit > 0){ | |||
| Integer credit = dataMap.getInteger("credit"); | |||
| if(credit != null && credit > 0){ | |||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||
| wxCreditHistory.setTenantId(wxGame.getFinalTenantId()); | |||
| wxCreditHistory.setCUserId(userId); | |||
| wxCreditHistory.setOperatorId(userId); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setCreditNum(credit); | |||
| wxCreditHistory.setCreditType(EnumScoreType.GAME_ADD_CREDIT.getCode()); | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.GAME_ADD_CREDIT.getMessage()); | |||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ; | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| addCredit = credit; | |||
| orderId = -1L; | |||
| } | |||
| resultData.data = null; | |||
| // } | |||
| }else if(data instanceof WxCouponChannelVo){ | |||
| WxCouponChannelVo vo = (WxCouponChannelVo) data; | |||
| OrderSaveDto orderSaveDto = new OrderSaveDto(); | |||
| orderSaveDto.setCouponChannelId(vo.getId()); | |||
| orderSaveDto.setCouponId(vo.getCouponId()); | |||
| ResultData resultData1 = wxOrderService.saveOrder(orderSaveDto, userId, EnumPayWay.PAY_WAY_WECHAT, wxGame); | |||
| if(resultData1.code == Result.SUCCESS && resultData1.data != null && resultData1.data instanceof WxOrder){ | |||
| WxOrder order = (WxOrder)resultData1.data; | |||
| orderId = order.getId(); | |||
| orderId = Constant.creditPlayOrderIdTab; | |||
| }else{ | |||
| logger.info("userId:"+userId+",中奖了加积分为零"); | |||
| resultData.data = null; | |||
| } | |||
| } | |||
| // } | |||
| } | |||
| }else{ | |||
| logger.info("userId:"+userId+",没中奖,"); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxGameActionLog wxGameActionLog = new WxGameActionLog(); | |||
| @@ -487,7 +496,7 @@ public class WxGameServiceImpl implements WxGameService { | |||
| wxGameActionLog.setCreateTime(new Date()); | |||
| wxGameActionLog.setUsedCredit(userCredit); | |||
| if(userCredit > 0){ | |||
| wxGameActionLog.setType(1); | |||
| wxGameActionLog.setType(Constant.creditPlayType); | |||
| } | |||
| wxGameActionLog.setCouponOrderId(orderId); | |||
| wxGameActionLog.setAddCredit(addCredit); | |||
| @@ -507,12 +516,12 @@ public class WxGameServiceImpl implements WxGameService { | |||
| wxCreditHistory.setTenantId(wxGame.getFinalTenantId()); | |||
| wxCreditHistory.setCUserId(userId); | |||
| wxCreditHistory.setOperatorId(userId); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setCreditNum(wxGame.getPlayCredit()); | |||
| wxCreditHistory.setCreditType(EnumScoreType.GAME_LES_CREDIT.getCode()); | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.GAME_LES_CREDIT.getMessage()); | |||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ; | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| return this.luckDraw(gameId,userId,wxGame.getPlayCredit()); | |||
| }else{ | |||
| @@ -35,12 +35,11 @@ public class FmInsideCLoginMsgServiceImpl implements MsgSendService { | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception { | |||
| FmInsideCLoginMsg msg = (FmInsideCLoginMsg)baseMsg; | |||
| WxCUser user = userService.getById(msg.getCUserId(),msg.getTenantId()); | |||
| WxCUser user = userService.getById(msg.getId(),msg.getTenantId()); | |||
| if(user == null) { | |||
| logger.error("用户ID未找到: " + msg.getCUserId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + msg.getCUserId()); | |||
| logger.error("用户ID未找到: " + msg.getId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + msg.getId()); | |||
| } | |||
| userService.actionAfterLogin(user, msg.getFindByUnionId()); | |||
| userService.actionAfterLogin(user); | |||
| } | |||
| } | |||
| @@ -86,7 +86,7 @@ public class ParkHelper { | |||
| // wxCreditHistory.setCreateDate(new Date()); | |||
| wxCreditHistory.setCreditType(EnumScoreType.BIND_CAR.getCode()); | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.BIND_CAR.getMessage()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(cuUserId); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| } | |||
| @@ -10,6 +10,15 @@ public class Constant { | |||
| public static final int WX_LIMIT_DAYS = 30; // 微信分账限制30天 | |||
| //游戏常量 | |||
| public static final int limit = 0;//游戏玩法不限次数 | |||
| public static final int notLimit = -1;//游戏玩法不限能玩 | |||
| public static final int creditPlayType = 1;//积分玩法类型 | |||
| public static final Long creditPlayOrderIdTab = -1L;//积分中奖 orderId标识 | |||
| public static final int limitType = 1;//游戏玩法次数类型 表示每天的次数 | |||
| // 前端未初始常量 | |||
| public static final String UNDEFINED = "undefined"; | |||
| @@ -0,0 +1,109 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxCUserFromMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserFrom"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||
| <result column="scene" jdbcType="VARCHAR" property="scene"/> | |||
| <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/> | |||
| <result column="scene_address_desc" jdbcType="VARCHAR" property="sceneAddressDesc" /> | |||
| <result column="from_type" jdbcType="INTEGER" property="fromType" /> | |||
| <result column="from_id" jdbcType="BIGINT" property="fromId" /> | |||
| <result column="from_name" jdbcType="VARCHAR" property="fromName" /> | |||
| <result column="is_new_user" jdbcType="INTEGER" property="isNewUser" /> | |||
| <result column="share_user_type" jdbcType="INTEGER" property="shareUserType" /> | |||
| <result column="share_user" jdbcType="BIGINT" property="shareUser" /> | |||
| <result column="share_user_name" jdbcType="VARCHAR" property="shareUserName" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| wcuf.`id`,wcuf.`tenant_id`,wcuf.`parent_tenant_id`,wcuf.`c_user_id`,wcuf.`scene`,wcuf.`scene_address`, | |||
| wcuf.`from_type`,wcuf.`from_id`,wcuf.`is_new_user`,wcuf.`share_user_type`,wcuf.`share_user`,wcuf.`create_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and wcuf.`id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcuf.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wcuf.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != cUserId "> | |||
| and wcuf.`c_user_id` = #{cUserId} | |||
| </if> | |||
| <if test=" null != scene and '' != scene"> | |||
| and wcuf.`scene` = #{scene} | |||
| </if> | |||
| <if test=" null != sceneAddress and '' != sceneAddress"> | |||
| and wcuf.`scene_address` = #{sceneAddress} | |||
| </if> | |||
| <if test=" null != fromType "> | |||
| and wcuf.`from_type` = #{fromType} | |||
| </if> | |||
| <if test=" null != fromId "> | |||
| and wcuf.`from_id` = #{fromId} | |||
| </if> | |||
| <if test=" null != isNewUser "> | |||
| and wcuf.`is_new_user` = #{isNewUser} | |||
| </if> | |||
| <if test=" null != shareUserType "> | |||
| and wcuf.`share_user_type` = #{shareUserType} | |||
| </if> | |||
| <if test=" null != shareUser "> | |||
| and wcuf.`share_user` = #{shareUser} | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and wcuf.`create_date` >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and wcuf.`create_date` <= #{endTime} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and wcuf.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| order by wcuf.`create_date` desc | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserFrom" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> | |||
| ,(select nick_name from wx_c_user where id = wcuf.c_user_id ) c_user_nick_name | |||
| ,(select description from wx_user_channel where scene_address = wcuf.scene_address ) scene_address_desc | |||
| ,case when wcuf.from_type = 1 then (select nick_name from wx_c_user where id = wcuf.from_id) | |||
| when wcuf.from_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.from_id) | |||
| when wcuf.from_type = 3 then (select name from wx_merchant_b_user where id = wcuf.from_id) | |||
| when wcuf.from_type = 4 then (select name from mall_user_info where id = wcuf.from_id) | |||
| when wcuf.from_type = 5 then (select name from wx_merchant where id = wcuf.from_id) | |||
| when wcuf.from_type = 6 then (select title from wx_coupon_channel where id = wcuf.from_id) | |||
| when wcuf.from_type = 7 then (select title from wx_activity where id = wcuf.from_id) | |||
| else '' end from_name | |||
| ,case when wcuf.share_user_type = 1 then (select nick_name from wx_c_user where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 3 then (select name from wx_merchant_b_user where id = wcuf.share_user) | |||
| when wcuf.share_user_type = 4 then (select name from mall_user_info where id = wcuf.share_user) | |||
| else '' end share_user_name | |||
| from wx_c_user_from wcuf | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -298,7 +298,7 @@ | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | |||
| select <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId} | |||
| </select> | |||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||
| @@ -160,7 +160,7 @@ | |||
| credit.ticket_number ticketNumber, | |||
| case when credit.operator_type=4 then (select name from mall_user_info where id=credit.operator_id) | |||
| when credit.operator_type=3 then (select name from wx_merchant_b_user where id=credit.operator_id) | |||
| when credit.operator_type=1 then (select nick_name from wx_c_user_basic_info where id=credit.operator_id) | |||
| when credit.operator_type=2 then (select nick_name from wx_c_user_basic_info where id=credit.operator_id) | |||
| else '' end operator, | |||
| credit.change_purpose changePurpose | |||
| FROM | |||
| @@ -65,4 +65,9 @@ | |||
| update wx_c_user_basic_child set del_status = 0 where id = #{id} and tenant_id = #{tenantId} | |||
| </update> | |||
| <delete id="deleteByUserBasicId" parameterType="com.iformall.domain.po.WxCUserBasicChild"> | |||
| delete from wx_c_user_basic_child where c_user_id = #{cUserId} and tenant_id = #{tenantId} | |||
| </delete> | |||
| </mapper> | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -15,7 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.*; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.image.BufferedImage; | |||
| import java.util.*; | |||
| import java.util.List; | |||
| @@ -26,13 +28,9 @@ public class UploadController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| /** | |||
| * 上传文件 | |||
| * | |||
| @@ -42,21 +40,29 @@ public class UploadController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传文件") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { | |||
| @SystemControllerLog(description = "文件上传") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 图片上传 | |||
| * | |||
| @@ -66,46 +72,55 @@ public class UploadController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| @SystemControllerLog(description = "上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq | |||
| ,@RequestParam Map<String, String> param) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| String tempFileName = UUID.randomUUID().toString(); | |||
| String fileFormat = ""; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| long size = multiReq.getSize(); | |||
| final long length = 2097152; | |||
| if (size > length) { | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||
| } | |||
| FileOutputStream fos = null; | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| String localImgFileName = fmUploadDir + tempFileName + "-1" + fileFormat; | |||
| String localNewImgFileName = fmUploadDir + tempFileName + fileFormat; | |||
| BufferedInputStream fs = null; | |||
| File localFile = new File(localImgFileName); | |||
| fos = new FileOutputStream(localFile); | |||
| fs = (BufferedInputStream) multiReq.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| String fileFormat = ""; | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| File newFile = ImgUtil.thinImage(localImgFileName, localNewImgFileName, imgFormat); | |||
| // 删除本地缓存 | |||
| localFile.delete(); | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, new FileInputStream(newFile)); | |||
| // 删除本地缓存 | |||
| newFile.delete(); | |||
| return data; | |||
| } else { | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| long maxSize = 0l; | |||
| try { | |||
| maxSize = Long.parseLong(param.get("size")); | |||
| } catch (NumberFormatException e) {} | |||
| if(maxSize > 0l && size > maxSize*1024){ | |||
| return new ResultData(ErrorCode.PICTURE_SIZE_CUSTOMIZE); | |||
| } | |||
| BufferedImage bufferedImage = ImageIO.read(multiReq.getInputStream()); | |||
| if(bufferedImage != null){ | |||
| int width = 0;int hight = 0; | |||
| try { | |||
| width = Integer.parseInt(param.get("width")); | |||
| hight = Integer.parseInt(param.get("hight")); | |||
| } catch (NumberFormatException e) {} | |||
| Integer relWidth = bufferedImage.getWidth(); | |||
| Integer relHeight = bufferedImage.getHeight(); | |||
| if((width > 0 && width != relWidth.intValue()) | |||
| || (hight > 0 && hight != relHeight.intValue())){ | |||
| return new ResultData(ErrorCode.PICTURE_W_H_CUSTOMIZE); | |||
| } | |||
| } | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| @@ -118,66 +133,76 @@ public class UploadController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/awsFilesUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) throws Exception { | |||
| @SystemControllerLog(description = "多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); | |||
| try { | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length());; | |||
| } | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| ResultData data1 = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multipartFile.getInputStream()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * C端上传图片文件 | |||
| * 内部接口-sys端上传图片文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("C端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception { | |||
| @ApiOperation("内部接口-sys端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) { | |||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| try { | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } | |||
| ResultData data = aliyunOSS.uploadFile("cimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| ResultData data = aliyunOSS.uploadFile("sysimg", fileFormat, multiReq.getInputStream()); | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| } | |||