Przeglądaj źródła

商家结算卡信息

guomengjiao 3 miesięcy temu
rodzic
commit
ee3f97189c

+ 40 - 0
ruoyi-api/src/main/java/com/ruoyi/api/controller/common/CommonController.java

@@ -80,6 +80,41 @@ public class CommonController extends AbstractApiController {
         return R.ok(oss);
     }
 
+    /**
+     * 上传OSS对象存储
+     */
+    @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
+    @ApiOperation("上传OSS对象存储-旋转")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true)
+    })
+    @RepeatSubmit()
+    @PostMapping("/uploadOrient")
+    public R<SysOss> uploadOrient(@RequestPart("file") MultipartFile file) {
+        getUserId();
+        if (ObjectUtil.isNull(file)) {
+            throw new ServiceException("上传文件不能为空");
+        }
+        // 1. 将MultipartFile转为字节数组
+        byte[] originalBytes;
+        try {
+            originalBytes = file.getBytes();
+        } catch (IOException e) {
+            throw new ServiceException("上传文件不能为空");
+        }
+        // 2. 调用orientImage进行旋转处理
+        String mimeType = file.getContentType();
+        byte[] fileBytes = orientImage(originalBytes, mimeType);
+        // 创建临时MultipartFile
+        MultipartFile tempFile = new CustomMultipartFile(
+            fileBytes,
+            file.getOriginalFilename(),
+            mimeType
+        );
+        SysOss oss = iSysOssService.apiUpload(tempFile);
+        return R.ok(oss);
+    }
+
     @FilePathSplicing(type = FilePathSplicingType.RESPONSE)
     @ApiOperation("上传OSS对象存储")
     @ApiImplicitParams({
@@ -99,6 +134,7 @@ public class CommonController extends AbstractApiController {
         String mimeType = dataParts.length > 1 ? dataParts[0].split(":")[1].split(";")[0] : "application/octet-stream";
 
         // 创建自定义MultipartFile
+        //加旋转
         byte[] fileBytes = orientImage(Base64.getDecoder().decode(encodedData), mimeType);
 //        // 创建临时MultipartFile
         MultipartFile file = new CustomMultipartFile(
@@ -112,6 +148,10 @@ public class CommonController extends AbstractApiController {
 
     private byte[] orientImage(byte[] imageBytes, String mimeType) {
         try {
+            // 1. 校验是否为图片
+            if (!mimeType.startsWith("image/")) {
+                return imageBytes;
+            }
             BufferedImage original = ImageIO.read(new ByteArrayInputStream(imageBytes));
             BufferedImage rotated = rotateImage(original, 6);
             // 保留透明度通道(针对PNG)

+ 5 - 0
ruoyi-business/src/main/java/com/ruoyi/business/domain/vo/BusinessApplyVo.java

@@ -67,6 +67,11 @@ public class BusinessApplyVo {
      */
     @ApiModelProperty("上级商家ID")
     private Long parentBusinessId;
+    /**
+     * 上级商家邀请码
+     */
+    @ApiModelProperty(value = "上级商家邀请码", required = true)
+    private String parentBusinessCode;
     /**
      * 营业执照图片(多张)
      */

+ 2 - 0
ruoyi-business/src/main/java/com/ruoyi/business/service/IBusinessService.java

@@ -149,4 +149,6 @@ public interface IBusinessService {
     String queryFuKey(Long businessId);
 
     BigDecimal queryBusinessLimit(Long businessId);
+
+    String queryInviteCodeById(Long businessId);
 }

+ 5 - 1
ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BusinessApplyServiceImpl.java

@@ -302,7 +302,11 @@ public class BusinessApplyServiceImpl implements IBusinessApplyService {
 
     @Override
     public BusinessApplyVo queryByUserId(Long userId) {
-        return baseMapper.selectVoOne(new LambdaQueryWrapper<BusinessApply>().eq(BusinessApply::getUserId, userId).last("limit 1"));
+        BusinessApplyVo businessApplyVo = baseMapper.selectVoOne(new LambdaQueryWrapper<BusinessApply>().eq(BusinessApply::getUserId, userId).last("limit 1"));
+        if (ObjectUtil.isNotNull(businessApplyVo) && ObjectUtil.isNotNull(businessApplyVo.getParentBusinessId())) {
+            businessApplyVo.setParentBusinessCode(businessService.queryInviteCodeById(businessApplyVo.getParentBusinessId()));
+        }
+        return businessApplyVo;
     }
 
     @Override

+ 6 - 0
ruoyi-business/src/main/java/com/ruoyi/business/service/impl/BusinessServiceImpl.java

@@ -732,4 +732,10 @@ public class BusinessServiceImpl implements IBusinessService {
         return ObjectUtil.isNotNull(business) ? business.getOnlineOrderConsumptionLimit() : null;
     }
 
+    @Override
+    public String queryInviteCodeById(Long businessId) {
+        Business business = baseMapper.selectOne(new LambdaQueryWrapper<Business>().select(Business::getInviteCode).eq(Business::getBusinessId, businessId));
+        return ObjectUtil.isNotNull(business) ? business.getInviteCode() : null;
+    }
+
 }

+ 2 - 1
ruoyi-business/src/main/java/com/ruoyi/business/typehandler/ObjectToSettlementTypeHandler.java

@@ -23,7 +23,8 @@ public class ObjectToSettlementTypeHandler extends BaseTypeHandler<BusinessSettl
 
     @Override
     public void setNonNullParameter(PreparedStatement ps, int i, BusinessSettlementBo parameter, JdbcType jdbcType) throws SQLException {
-        ps.setObject(i, parameter);
+        String json = JsonUtils.toJsonString(parameter);
+        ps.setObject(i, json);
     }
 
     @Override