| @@ -3,7 +3,9 @@ package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | import com.iformall.file.aliyun.AliyunOSS; | ||||
| import com.iformall.file.wx.MerchantMediaUpload; | |||||
| import com.iformall.utils.ImgUtil; | import com.iformall.utils.ImgUtil; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -34,6 +36,9 @@ public class WxMerchantMediaUploadController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private AliyunOSS aliyunOSS; | private AliyunOSS aliyunOSS; | ||||
| @Autowired | |||||
| private MerchantMediaUpload mediaUpload; | |||||
| /** | /** | ||||
| * 图片上传 | * 图片上传 | ||||
| @@ -85,10 +90,23 @@ public class WxMerchantMediaUploadController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||||
| return data; | |||||
| String url = aliyunOSS.upload(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||||
| if(StringUtils.isBlank(url)){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"上传图片异常"); | |||||
| } | |||||
| String mediaId = mediaUpload.mediaUpload(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); | |||||
| if(StringUtils.isBlank(mediaId)){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"上传微信异常"); | |||||
| } | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("url",url); | |||||
| map.put("mediaId",mediaId); | |||||
| return new ResultData(map); | |||||
| } catch (Exception e) { | |||||
| } catch(MallinkException e){ | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| }catch (Exception e) { | |||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | ||||
| } | } | ||||
| @@ -35,6 +35,10 @@ public class WxProfitSharingReceiverApplyController extends BaseController { | |||||
| @PostMapping("/receiverAdd") | @PostMapping("/receiverAdd") | ||||
| public ResultData receiverApply(@RequestBody WxProfitSharingReceiverApply receiverAdd) { | public ResultData receiverApply(@RequestBody WxProfitSharingReceiverApply receiverAdd) { | ||||
| log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::receiverAdd"); | log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::receiverAdd"); | ||||
| if(receiverAdd == null){ | |||||
| receiverAdd = new WxProfitSharingReceiverApply(); | |||||
| } | |||||
| receiverAdd.updateTenantInfo(getTenantInfo()); | |||||
| if(receiverAdd.getMerchantId() == null){ | if(receiverAdd.getMerchantId() == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "商户ID不能为空"); | ||||
| } | } | ||||
| @@ -7,7 +7,7 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumSharingReceiverContactType { | public enum EnumSharingReceiverContactType { | ||||
| LEGAL(1, "LEGAL", "法人"), | |||||
| LEGAL(1, "LEGAL", "经营者/法人"), | |||||
| SUPER(2, "SUPER", "经办人"), | SUPER(2, "SUPER", "经办人"), | ||||
| ; | ; | ||||
| @@ -0,0 +1,40 @@ | |||||
| package com.iformall.file.wx; | |||||
| import com.github.binarywang.wxpay.bean.media.ImageUploadResult; | |||||
| import com.github.binarywang.wxpay.exception.WxPayException; | |||||
| import com.github.binarywang.wxpay.service.WxPayService; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxPayAccountService; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.util.UUID; | |||||
| @Component | |||||
| @Slf4j | |||||
| public class MerchantMediaUpload { | |||||
| @Autowired | |||||
| WxPayAccountService wxPayAccountService; | |||||
| public String mediaUpload(String tenantId, String suffix,InputStream inputStream){ | |||||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantId); | |||||
| String fileName = UUID.randomUUID().toString().replace("-","") + suffix; | |||||
| try { | |||||
| ImageUploadResult uploadResult = wxPayService.getMerchantMediaService().imageUploadV3(inputStream,fileName); | |||||
| return uploadResult.getMediaId(); | |||||
| } catch (WxPayException e) { | |||||
| e.printStackTrace(); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"上传微信错误"); | |||||
| } | |||||
| } | |||||
| } | |||||