| | |
| | | package com.yeshi.fanli.service.impl.user; |
| | | |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.entity.FileUploadResult; |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | |
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService; |
| | | import com.yeshi.fanli.service.inter.user.PreviewInfoService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService; |
| | | import com.yeshi.fanli.util.ImageUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TimeUtil; |
| | |
| | | @Resource |
| | | private ThreeSaleDetailService threeSaleDetailService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | info.setUpdateTime(new Date()); |
| | | previewInfoDao.save(info); |
| | | |
| | | if (type == PreviewEnum.extractRecord) { |
| | | if (type == PreviewEnum.extractRecord || type == PreviewEnum.moneyArrival) { |
| | | return; |
| | | } |
| | | |
| | | // redis缓存 |
| | | if (StringUtil.isNullOrEmpty(content)) { |
| | | removePreview(preUid, type); |
| | | } else { |
| | | adddPreview(preUid, type, content); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 缓存10分钟 |
| | |
| | | |
| | | |
| | | @Override |
| | | public String saveMoneyArrival(Long uid, BigDecimal money, String time,String orderNo) throws PreviewInfoException { |
| | | public String saveMoneyArrival(Long uid, BigDecimal money, String time,String orderNo, String platform) |
| | | throws PreviewInfoException,Exception { |
| | | if (uid == null ) |
| | | throw new PreviewInfoException(1, "请先登录"); |
| | | if (money == null ) |
| | | throw new PreviewInfoException(1, "请输入金额"); |
| | | if(StringUtil.isNullOrEmpty(time)) |
| | | if(StringUtil.isNullOrEmpty(orderNo)) |
| | | throw new PreviewInfoException(1, "请输入订单号"); |
| | | if(StringUtil.isNullOrEmpty(time)) |
| | | throw new PreviewInfoException(1, "请输入创建时间"); |
| | | Date parse = TimeUtil.parseDotCommon2(time); |
| | | if (parse == null) |
| | | Date date = TimeUtil.parseDotCommon2(time); |
| | | if (date == null) |
| | | throw new PreviewInfoException(1, "请输入正确的时间格式,如:2020.01.01 01:01"); |
| | | |
| | | // 转换格式 |
| | | time = TimeUtil.formatYMDHHMM(date); |
| | | |
| | | String content = ""; // TODO |
| | | // save(uid, PreviewEnum.moneyArrival, gson.toJson(infoVO)); |
| | | return content; |
| | | InputStream drawStream = null; |
| | | if ("ios".equalsIgnoreCase(platform)) { |
| | | drawStream = ImageUtil.drawAlipayIOS(money, orderNo, time); |
| | | } else { |
| | | drawStream = ImageUtil.drawAlipayAndroid(money, orderNo, time); |
| | | } |
| | | |
| | | if (drawStream == null) |
| | | throw new PreviewInfoException(1, "预览生成失败"); |
| | | |
| | | // 上传文件 |
| | | String uuid = UUID.randomUUID().toString().replace("-", ""); |
| | | String upPath = "/user/img/preview/" + uuid + "_" + System.currentTimeMillis() + ".png"; |
| | | FileUploadResult result = COSManager.getInstance().uploadInputStream(drawStream, upPath); |
| | | if (result == null) { |
| | | throw new PreviewInfoException(1, "预览生成失败"); |
| | | } |
| | | |
| | | // 保存信息 |
| | | save(uid, uid, PreviewEnum.moneyArrival, result.getUrl()); |
| | | |
| | | return result.getUrl(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |