| @@ -6,14 +6,18 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.file.aliyun.AliyunOSS; | import com.iformall.file.aliyun.AliyunOSS; | ||||
| import com.iformall.ueditor.define.FileType; | |||||
| 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; | ||||
| import org.apache.commons.codec.binary.Base64; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RequestParam; | import org.springframework.web.bind.annotation.RequestParam; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| @@ -208,5 +212,16 @@ public class UploadController extends BaseController { | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | ||||
| } | } | ||||
| } | } | ||||
| @ApiOperation("base64Upload") | |||||
| @PostMapping("base64Upload") | |||||
| public ResultData base64Upload(String content) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| byte[] fileBytes = Base64.decodeBase64(content); | |||||
| String suffix = FileType.getSuffix("JPG"); | |||||
| ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), suffix, fileBytes); | |||||
| return data; | |||||
| } | |||||
| } | } | ||||
| @@ -57,3 +57,6 @@ ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `owe` VARCHAR(30); | |||||
| ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `need_pay` VARCHAR(30); | ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `need_pay` VARCHAR(30); | ||||
| ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `return_price` VARCHAR(30); | ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `return_price` VARCHAR(30); | ||||
| ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `service_charge_pay` VARCHAR(30); | ALTER TABLE wx_bill_property_deposit MODIFY COLUMN `service_charge_pay` VARCHAR(30); | ||||
| ALTER TABLE wx_raffle_activity_record ADD COLUMN sign_img VARCHAR(1000) COMMENT '签名图片'; | |||||
| @@ -69,7 +69,8 @@ public class WxRaffleActivityRecord extends TenantEntity { | |||||
| private Date createDateEnd; | private Date createDateEnd; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "签名图片", name = "updateDate") | |||||
| private String signImg; | |||||
| @Excel(name="中奖信息",width = 20, orderNum = "16") | @Excel(name="中奖信息",width = 20, orderNum = "16") | ||||
| @io.swagger.annotations.ApiModelProperty(value = "中奖信息", name = "itemDetail") | @io.swagger.annotations.ApiModelProperty(value = "中奖信息", name = "itemDetail") | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @@ -10,11 +10,16 @@ import com.aliyun.oss.model.PutObjectRequest; | |||||
| import com.aliyun.oss.model.PutObjectResult; | import com.aliyun.oss.model.PutObjectResult; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.file.aliyun.bean.AliyunOSSConfig; | import com.iformall.file.aliyun.bean.AliyunOSSConfig; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import java.io.BufferedOutputStream; | |||||
| import java.io.File; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -28,6 +33,21 @@ public class AliyunOSS { | |||||
| @Autowired | @Autowired | ||||
| private AliyunOSSConfig aliyunOSSConfig; | private AliyunOSSConfig aliyunOSSConfig; | ||||
| public ResultData uploadFile(String folder, String suffix,byte[] fileBytes){ | |||||
| String upload = upload(folder,suffix, fileBytes); | |||||
| ResultData data; | |||||
| if(StringUtils.isNotBlank(upload)){ | |||||
| data = new ResultData(); | |||||
| Map<String, String> map = new HashMap<>(); | |||||
| map.put("url", upload); | |||||
| map.put("bucketName", aliyunOSSConfig.getBucketname()); | |||||
| data.data = map; | |||||
| }else{ | |||||
| data = new ResultData(ResultData.ERROR,"上传失败"); | |||||
| } | |||||
| return data; | |||||
| } | |||||
| public ResultData uploadFile(String folder, String suffix,InputStream inputStream){ | public ResultData uploadFile(String folder, String suffix,InputStream inputStream){ | ||||
| String upload = upload(folder,suffix, inputStream); | String upload = upload(folder,suffix, inputStream); | ||||
| @@ -103,5 +123,84 @@ public class AliyunOSS { | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| /** | |||||
| * 上传 | |||||
| * @param inputStream | |||||
| * @return | |||||
| */ | |||||
| public String upload(String folder, String suffix,byte[] fileBytes){ | |||||
| log.info("=========>OSS文件上传开始:"); | |||||
| String endpoint = aliyunOSSConfig.getEndpoint(); | |||||
| String accessKeyId = aliyunOSSConfig.getKeyid(); | |||||
| String accessKeySecret = aliyunOSSConfig.getKeysecret(); | |||||
| String bucketName = aliyunOSSConfig.getBucketname(); | |||||
| String fileHost = aliyunOSSConfig.getFilehost(); | |||||
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | |||||
| String dateStr = format.format(new Date()); | |||||
| if(null == fileBytes){ | |||||
| return null; | |||||
| } | |||||
| OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId,accessKeySecret); | |||||
| try { | |||||
| //容器不存在,就创建 | |||||
| if(! ossClient.doesBucketExist(bucketName)){ | |||||
| ossClient.createBucket(bucketName); | |||||
| CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName); | |||||
| createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead); | |||||
| ossClient.createBucket(createBucketRequest); | |||||
| } | |||||
| if(StringUtils.isNotBlank(folder)){ | |||||
| folder = folder + "/"; | |||||
| }else{ | |||||
| folder = ""; | |||||
| } | |||||
| //创建文件路径 | |||||
| String fileUrl = folder + fileHost + "/" + dateStr + "/" | |||||
| + UUID.randomUUID().toString().replace("-","") + suffix; | |||||
| File file = saveBinaryFile(fileBytes,fileUrl); | |||||
| if (null == file) { | |||||
| return null; | |||||
| } | |||||
| //上传文件 | |||||
| PutObjectResult result = ossClient.putObject(new PutObjectRequest(bucketName, fileUrl, file)); | |||||
| //设置权限 这里是公开读 | |||||
| ossClient.setBucketAcl(bucketName,CannedAccessControlList.PublicRead); | |||||
| if(null != result){ | |||||
| log.info("==========>OSS文件上传成功,OSS地址:"+fileUrl); | |||||
| //JPG的加上压缩 | |||||
| if (suffix.equals(".JPG") || suffix.equals(".jpg")) { | |||||
| return aliyunOSSConfig.getFiledomain() + "/" + fileUrl+"?x-oss-process=image/resize,w_10000/quality,q_60"; | |||||
| }else { | |||||
| return aliyunOSSConfig.getFiledomain() + "/" + fileUrl; | |||||
| } | |||||
| } | |||||
| }catch (OSSException oe){ | |||||
| log.error(oe.getMessage()); | |||||
| }catch (ClientException ce){ | |||||
| log.error(ce.getMessage()); | |||||
| }finally { | |||||
| //关闭 | |||||
| ossClient.shutdown(); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private static File saveBinaryFile(byte[] data, String path) { | |||||
| File file = null; | |||||
| try { | |||||
| file = new File(path); | |||||
| BufferedOutputStream bos = new BufferedOutputStream( | |||||
| new FileOutputStream(file)); | |||||
| bos.write(data); | |||||
| bos.flush(); | |||||
| bos.close(); | |||||
| } catch (IOException ioe) { | |||||
| file = null; | |||||
| log.error("saveBinaryFile error.",ioe); | |||||
| } | |||||
| return file; | |||||
| } | |||||
| } | } | ||||
| @@ -402,6 +402,15 @@ public class WxRaffleActivityServiceImpl implements WxRaffleActivityService { | |||||
| return; | return; | ||||
| } | } | ||||
| if (StringUtils.isNotBlank(record.getSignImg())) { | |||||
| WxRaffleActivityRecord ar = new WxRaffleActivityRecord(); | |||||
| ar.updateTenantInfo(record); | |||||
| ar.setId(r.getId()); | |||||
| ar.setSignImg(record.getSignImg()); | |||||
| ar.setUpdateDate(new Date()); | |||||
| wxActivityRecordMapper.updateById(ar); | |||||
| } | |||||
| WxRaffleActivityRecordItem ri = new WxRaffleActivityRecordItem(); | WxRaffleActivityRecordItem ri = new WxRaffleActivityRecordItem(); | ||||
| ri.updateTenantInfo(r); | ri.updateTenantInfo(r); | ||||
| ri.setActivityId(r.getActivityId()); | ri.setActivityId(r.getActivityId()); | ||||
| @@ -16,12 +16,12 @@ | |||||
| <result column="audit_remark" jdbcType="VARCHAR" property="auditRemark" /> | <result column="audit_remark" jdbcType="VARCHAR" property="auditRemark" /> | ||||
| <result column="audit_status" jdbcType="INTEGER" property="auditStatus" /> | <result column="audit_status" jdbcType="INTEGER" property="auditStatus" /> | ||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | ||||
| <result column="sign_img" jdbcType="VARCHAR" property="signImg" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`activity_id`,`order_no`,`order_money`,`cus_name`,`create_date`,`update_date`,`phone`, | `id`,`tenant_id`,`parent_tenant_id`,`activity_id`,`order_no`,`order_money`,`cus_name`,`create_date`,`update_date`,`phone`, | ||||
| `address`,`audit_remark`,`audit_status`,`merchant_id` | |||||
| `address`,`audit_remark`,`audit_status`,`merchant_id`,`sign_img` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||