|
@@ -1,150 +0,0 @@
|
|
|
-package com.zhongshu.card.server.core.service.payment;
|
|
|
|
|
-
|
|
|
|
|
-import cn.hutool.core.codec.Base64;
|
|
|
|
|
-import cn.hutool.core.io.IoUtil;
|
|
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
-import com.github.microservice.auth.client.content.ResultContent;
|
|
|
|
|
-import com.github.microservice.auth.client.content.ResultState;
|
|
|
|
|
-import com.zhongshu.card.client.model.dahua.PicUploadRequestModel;
|
|
|
|
|
-import com.zhongshu.card.client.model.dahua.PicUploadResponseModel;
|
|
|
|
|
-import com.zhongshu.card.client.model.payment.BaseModel;
|
|
|
|
|
-import com.zhongshu.card.client.model.payment.ComplexModel;
|
|
|
|
|
-import com.zhongshu.card.client.model.payment.PicUpModel;
|
|
|
|
|
-import com.zhongshu.card.client.model.payment.RegmerTypeModel;
|
|
|
|
|
-import com.zhongshu.card.client.service.payment.SignatureService;
|
|
|
|
|
-import com.zhongshu.card.client.type.payment.PicType;
|
|
|
|
|
-import com.zhongshu.card.server.core.dao.payment.ComplexDao;
|
|
|
|
|
-import com.zhongshu.card.server.core.dao.payment.PicDao;
|
|
|
|
|
-import com.zhongshu.card.server.core.domain.payment.Complex;
|
|
|
|
|
-import com.zhongshu.card.server.core.domain.payment.Pic;
|
|
|
|
|
-import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
|
|
-import com.zhongshu.card.server.core.util.CustomBeanUtils;
|
|
|
|
|
-import lombok.SneakyThrows;
|
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
-import org.springframework.util.Assert;
|
|
|
|
|
-
|
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
-import java.net.URL;
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * @author TRX
|
|
|
|
|
- * @date 2024/6/19
|
|
|
|
|
- */
|
|
|
|
|
-@Slf4j
|
|
|
|
|
-@Service
|
|
|
|
|
-public class SignatureServiceImpl extends SuperService implements SignatureService {
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- PicDao picDao;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- ComplexDao complexDao;
|
|
|
|
|
-
|
|
|
|
|
- @Transactional
|
|
|
|
|
- public ResultContent<Complex> startComplex(RegmerTypeModel typeModel) {
|
|
|
|
|
- String accesseId = typeModel.getAccesseId();
|
|
|
|
|
- if (ObjectUtil.isEmpty(accesseId)) {
|
|
|
|
|
- return ResultContent.build(ResultState.Success, newComplex(typeModel));
|
|
|
|
|
- }
|
|
|
|
|
- Complex complex = findComplex(typeModel);
|
|
|
|
|
- if (ObjectUtil.isEmpty(complex) || !complex.getReg_mer_type().equals(typeModel.getReg_mer_type())) {
|
|
|
|
|
- picDao.deleteByAccesserId(accesseId);
|
|
|
|
|
- complexDao.deleteByAccesser_user_id(accesseId);
|
|
|
|
|
-
|
|
|
|
|
- return ResultContent.build(ResultState.Success, newComplex(typeModel));
|
|
|
|
|
- }
|
|
|
|
|
- return ResultContent.build(ResultState.Success, complex);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询正在进行的流程
|
|
|
|
|
- *
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public ResultContent<ComplexModel> complexIng(BaseModel baseModel) {
|
|
|
|
|
- String accesseId = baseModel.getAccesseId();
|
|
|
|
|
-
|
|
|
|
|
- Complex complex = findComplex(baseModel);
|
|
|
|
|
- ArrayList<PicUpModel> picUpModels = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- picDao.findAllByAccesserId(accesseId).forEach(it -> {
|
|
|
|
|
- PicUpModel picUpModel = new PicUpModel();
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(it, picUpModel);
|
|
|
|
|
- picUpModels.add(picUpModel);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- ComplexModel complexModel = new ComplexModel();
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(complex, complexModel);
|
|
|
|
|
- complexModel.setPic_list(picUpModels);
|
|
|
|
|
- return ResultContent.build(ResultState.Success, complexModel);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 上传图片
|
|
|
|
|
- *
|
|
|
|
|
- * @param picUpModel
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public ResultContent picUpload(PicUpModel picUpModel) {
|
|
|
|
|
- String accesseId = picUpModel.getAccesseId();
|
|
|
|
|
- String base64 = imageToBase64(picUpModel.getFileUrl());
|
|
|
|
|
-
|
|
|
|
|
- PicUploadRequestModel picUploadModel = new PicUploadRequestModel();
|
|
|
|
|
- picUploadModel.setPic_base64(base64);
|
|
|
|
|
- PicUploadResponseModel picUploadResponseModel = null;
|
|
|
|
|
-// PicUploadResponseModel picUploadResponseModel = daHuaApi.picUpload(picUploadModel);
|
|
|
|
|
- PicType picType = picUpModel.getPicType();
|
|
|
|
|
- Pic pic = picDao.findByAccesserIdAndDocument_type(accesseId, picType.getDocument_type());
|
|
|
|
|
- if (ObjectUtil.isEmpty(pic)) {
|
|
|
|
|
-
|
|
|
|
|
- Pic newPic = new Pic();
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(picUploadResponseModel, newPic);
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(picUpModel, newPic);
|
|
|
|
|
- newPic.setEpId(picUpModel.getOid());
|
|
|
|
|
- newPic.setAccesserId(accesseId);
|
|
|
|
|
- newPic.setDocument_type(picType.getDocument_type());
|
|
|
|
|
- newPic.setDocument_name(picType.getName());
|
|
|
|
|
- picDao.save(newPic);
|
|
|
|
|
- return ResultContent.build(ResultState.Success);
|
|
|
|
|
- } else {
|
|
|
|
|
-// pic.setEpId(pic.getEpId());
|
|
|
|
|
-// pic.setAccesserId(accesseId);
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(picUploadResponseModel, pic);
|
|
|
|
|
- CustomBeanUtils.copyPropertiesIgnoreNull(picUpModel, pic);
|
|
|
|
|
- picDao.save(pic);
|
|
|
|
|
- return ResultContent.build(ResultState.Success);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private Complex findComplex(BaseModel baseModel) {
|
|
|
|
|
- Complex complex = complexDao.findByAccesser_user_idAndEpId(baseModel.getAccesseId(), baseModel.getOid());
|
|
|
|
|
- Assert.isTrue(null != complex, "申请流程不存在");
|
|
|
|
|
- return complex;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private Complex newComplex(RegmerTypeModel typeModel) {
|
|
|
|
|
- String newAccesseId = IdUtil.fastSimpleUUID();
|
|
|
|
|
- Complex newComplex = new Complex();
|
|
|
|
|
- newComplex.setEpId(typeModel.getOid());
|
|
|
|
|
- newComplex.setAccesser_user_id(newAccesseId);
|
|
|
|
|
- newComplex.setReg_mer_type(typeModel.getReg_mer_type());
|
|
|
|
|
- return complexDao.save(newComplex);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @SneakyThrows
|
|
|
|
|
- private String imageToBase64(String urlIm) {
|
|
|
|
|
- String imgType = urlIm.substring(urlIm.lastIndexOf(".") + 1, urlIm.length());
|
|
|
|
|
- URL url = new URL(urlIm);
|
|
|
|
|
- InputStream inputStream = url.openStream();
|
|
|
|
|
- byte[] bytes = IoUtil.readBytes(inputStream);
|
|
|
|
|
- String imgBase64Head = "data:image/" + imgType + ";base64,";
|
|
|
|
|
- String body = Base64.encode(bytes);
|
|
|
|
|
- return imgBase64Head + body;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|