|
@@ -1,27 +1,40 @@
|
|
|
package com.caimei365.user.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.oss.OSS;
|
|
|
+import com.aliyun.oss.OSSClientBuilder;
|
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
|
import com.caimei365.user.mapper.ClubMapper;
|
|
|
import com.caimei365.user.mapper.RegisterMapper;
|
|
|
import com.caimei365.user.mapper.SuperVipMapper;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
+import com.caimei365.user.model.dto.ClubRemarksDto;
|
|
|
import com.caimei365.user.model.dto.ClubUpdateDto;
|
|
|
import com.caimei365.user.model.dto.SuperVipDto;
|
|
|
import com.caimei365.user.model.po.SuperVipPo;
|
|
|
+import com.caimei365.user.model.dto.JsonParamsDto;
|
|
|
+import com.caimei365.user.model.po.RemarksFilePo;
|
|
|
+import com.caimei365.user.model.po.ClubRemarksPo;
|
|
|
import com.caimei365.user.model.po.UserBeansHistoryPo;
|
|
|
import com.caimei365.user.model.po.UserPo;
|
|
|
import com.caimei365.user.model.vo.*;
|
|
|
import com.caimei365.user.service.ClubService;
|
|
|
+import com.caimei365.user.utils.OssUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.alibaba.fastjson.JSON.parseArray;
|
|
|
+import static com.alibaba.fastjson.JSON.parseObject;
|
|
|
+
|
|
|
/**
|
|
|
* Description
|
|
|
*
|
|
@@ -339,4 +352,118 @@ public class ClubServiceImpl implements ClubService {
|
|
|
clubMapper.updateUserBeans(userId, beansNum);
|
|
|
return ResponseJson.success("抵扣成功");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存机构资料备注
|
|
|
+ * @param jsonParamsDto:{
|
|
|
+ * remarksId: 备注id,
|
|
|
+ * 机构id: 机构id,
|
|
|
+ * serviceProviderId: 协销id,
|
|
|
+ * remarks: 文字备注,
|
|
|
+ * fileList: [{fileName:"文件名称",ossName:"oss文件名称"},{fileName:"文件名称",ossName:"oss文件名称"}...]
|
|
|
+ * imageList: ["图片","图片",...]
|
|
|
+ * }
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson saveClubRemarks(JsonParamsDto jsonParamsDto) {
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = parseObject(jsonParamsDto.getParams());
|
|
|
+ Integer clubId = jsonObject.getInteger("clubId");
|
|
|
+ Integer remarksId = jsonObject.getInteger("remarksId");
|
|
|
+ Integer serviceProviderId = jsonObject.getInteger("serviceProviderId");
|
|
|
+ String remarks = jsonObject.getString("remarks");
|
|
|
+ if (null == clubId) {
|
|
|
+ return ResponseJson.error("参数异常,机构id不能为空");
|
|
|
+ }
|
|
|
+ if (null == serviceProviderId) {
|
|
|
+ return ResponseJson.error("参数异常,协销id不能为空");
|
|
|
+ }
|
|
|
+ // 是否新增备注
|
|
|
+ boolean newRemarks = null == remarksId;
|
|
|
+ ClubRemarksPo clubRemarksPo = new ClubRemarksPo();
|
|
|
+ clubRemarksPo.setRemarksId(remarksId);
|
|
|
+ clubRemarksPo.setClubId(clubId);
|
|
|
+ clubRemarksPo.setServiceProviderId(serviceProviderId);
|
|
|
+ clubRemarksPo.setRemarks(remarks);
|
|
|
+ if (newRemarks) {
|
|
|
+ // 新增备注
|
|
|
+ clubMapper.insertRemarks(clubRemarksPo);
|
|
|
+ } else {
|
|
|
+ // 修改备注
|
|
|
+ clubMapper.updateRemarks(clubRemarksPo);
|
|
|
+ // 删除旧的备注图片和文件
|
|
|
+ clubMapper.clearRearksFiles(remarksId);
|
|
|
+ }
|
|
|
+ JSONArray filesArray = jsonObject.getJSONArray("fileList");
|
|
|
+ JSONArray imagesArray = jsonObject.getJSONArray("imageList");
|
|
|
+ remarksId = clubRemarksPo.getRemarksId();
|
|
|
+ //保存图片
|
|
|
+ if (!imagesArray.isEmpty()) {
|
|
|
+ for (Object imageObj: imagesArray) {
|
|
|
+ String image = String.valueOf(imageObj);
|
|
|
+ // 保存资质图片
|
|
|
+ clubMapper.insertRemarksImage(remarksId, image);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存文件
|
|
|
+ if (!filesArray.isEmpty()) {
|
|
|
+ for (Object fileObj: filesArray) {
|
|
|
+ JSONObject file = (JSONObject) fileObj;
|
|
|
+ String fileName = file.getString("fileName");
|
|
|
+ String ossName = file.getString("ossName");
|
|
|
+ // 保存资质文件
|
|
|
+ clubMapper.insertRemarksFile(remarksId, fileName, ossName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.success("保存资料备注成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("保存机构资料备注参数:" + jsonParamsDto.toString());
|
|
|
+ log.error("【保存机构资料备注】>>>参数解析异常try-catch:", e);
|
|
|
+ return ResponseJson.error("保存机构资料备注参数解析异常!", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<PaginationVo<RemarksVo>> getRemarksList(Integer clubId, int pageNum, int pageSize) {
|
|
|
+ if (null == clubId) {
|
|
|
+ return ResponseJson.error("参数异常,机构id不能为空", null);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<RemarksVo> remarksList = clubMapper.getRemarksList(clubId);
|
|
|
+ return ResponseJson.success(new PaginationVo<>(remarksList));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<RemarksVo> getRemarksDetail(Integer remarksId) {
|
|
|
+ if (null == remarksId) {
|
|
|
+ return ResponseJson.error("参数异常,备注id不能为空", null);
|
|
|
+ }
|
|
|
+ RemarksVo remarksVo = clubMapper.getRemarks(remarksId);
|
|
|
+ List<String> imageList = clubMapper.getRemarksImageList(remarksId);
|
|
|
+ List<RemarksFileVo> fileList = clubMapper.getRemarksFileList(remarksId);
|
|
|
+ fileList.forEach(file->{
|
|
|
+ file.setFileUrl(OssUtil.getOssUrl(file.getOssName())); ;
|
|
|
+ });
|
|
|
+ remarksVo.setImageList(imageList);
|
|
|
+ remarksVo.setFileList(fileList);
|
|
|
+ return ResponseJson.success(remarksVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson deleteClubRemarks(Integer remarksId) {
|
|
|
+ if (null == remarksId) {
|
|
|
+ return ResponseJson.error("参数异常,备注id不能为空");
|
|
|
+ }
|
|
|
+ clubMapper.deleteRemarks(remarksId);
|
|
|
+ //删除oss服务器上的文件
|
|
|
+ List<RemarksFileVo> fileList = clubMapper.getRemarksFileList(remarksId);
|
|
|
+ fileList.forEach(file->{
|
|
|
+ OssUtil.deleteSingleFile(file.getOssName());
|
|
|
+ });
|
|
|
+ //删除备注包含的文件
|
|
|
+ clubMapper.deleteRemarksFiles(remarksId);
|
|
|
+ return ResponseJson.success("删除成功");
|
|
|
+ }
|
|
|
}
|