| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.UserInviteUtil;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackWinInviteVO;
|
| | |
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("balance", redPackBalanceService.getBalance(uid));
|
| | | data.put("ruleLink", redPackConfigService.getValueByKey("invite_reward_rule_link"));
|
| | | data.put("shareLink", UserInviteUtil.getShareUrl(uid));
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | data.put("inviteCode", userInfoExtra.getInviteCode());
|
| | |
| | |
|
| | | // 消息类型的枚举
|
| | | public enum AppPageNotificationTypeEnum {
|
| | | home("首页"), coupon("优惠券页"), invite("邀请有奖页"), activity("动态"), goodsDetail("详情过度页"), mine("我的"), money(
|
| | | "资金"), accountDetail("账户明细"), extract("提现"), orderFanli("返利订单"), orderTiCheng("提成订单"), orderTaoBao(
|
| | | "淘宝订单"), coollect("收藏"), scanHistory("足迹"), team("队员"), kefu("联系客服"), taoBaoShoppingCart(
|
| | | "淘宝购物车"), orderFind("订单申诉"), msgCenter("消息中心"), newOrder("订单"), shareHistory(
|
| | | "分享记录"), goodsStorage(
|
| | | "选品库"), tlj("分享爆款详情"), tlj_buy("自购立减详情"), hongbao_balance("红包余额"),
|
| | | goodsDetailJD("京东详情"),goodsDetailPDD("拼多多详情"),orderFindJD("拼多多订单找回"),orderFindPDD("京东订单找回");
|
| | | home("首页"),
|
| | | coupon("优惠券页"),
|
| | | invite("邀请有奖页"),
|
| | | activity("动态"),
|
| | | goodsDetail("详情过度页"),
|
| | | mine("我的"),
|
| | | money("资金"),
|
| | | accountDetail("账户明细"),
|
| | | extract("提现"),
|
| | | orderFanli("返利订单"),
|
| | | orderTiCheng("提成订单"),
|
| | | orderTaoBao("淘宝订单"),
|
| | | coollect("收藏"),
|
| | | scanHistory("足迹"),
|
| | | team("队员"),
|
| | | kefu("联系客服"),
|
| | | taoBaoShoppingCart("淘宝购物车"),
|
| | | orderFind("订单申诉"),
|
| | | msgCenter("消息中心"),
|
| | | newOrder("订单"),
|
| | | shareHistory("分享记录"),
|
| | | goodsStorage("选品库"),
|
| | | tlj("分享爆款详情"),
|
| | | tlj_buy("自购立减详情"),
|
| | | hongbao_balance("红包余额"),
|
| | | goodsDetailJD("京东详情"),
|
| | | goodsDetailPDD("拼多多详情"),
|
| | | orderFindJD("拼多多订单找回"),
|
| | | orderFindPDD("京东订单找回"),
|
| | | shareSingle("商品详情单图分享"),
|
| | | dynamicShareSingle("动态单图分享"),
|
| | | dynamicShareMulti("动态多图分享");
|
| | |
|
| | | private final String desc;
|
| | |
|
| | | private AppPageNotificationTypeEnum(String desc) {
|
| | |
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.UserInviteUtil;
|
| | |
|
| | | @Service
|
| | | public class QrCodeServiceImpl implements QrCodeService {
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public String drawInviteQrCodeNew(String url, Long uid, String portrait, Integer pX, Integer pY, Integer size, String inviteCode) throws IOException {
|
| | | |
| | | public String drawInviteQrCodeNew(String url, Long uid, String portrait, Integer pX, Integer pY, Integer size,
|
| | | String inviteCode) throws IOException {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(url)) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | String targetPath = null;
|
| | | String erCodeTempPath = null;
|
| | | InputStream erCodeInputStream = null; // 二维码
|
| | | InputStream erCodeInputStream = null; // 二维码
|
| | | InputStream portraitInputStream = null; // 头像
|
| | | InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 背景
|
| | | |
| | |
|
| | | String uuid = UUID.randomUUID().toString().replace("-", "");
|
| | | if (uid == null) {
|
| | | targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
|
| | |
| | | erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
|
| | | // 官方默认头像
|
| | | portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
|
| | | |
| | |
|
| | | } else {
|
| | | |
| | |
|
| | | targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
|
| | | erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
|
| | | |
| | | String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/"
|
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | |
|
| | | String erCode = UserInviteUtil.getShareUrl(uid);
|
| | | // 生成
|
| | | try {
|
| | | QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | urlInputStream = HttpUtil.getAsInputStream(url); // 背景
|
| | | portraitInputStream = HttpUtil.getAsInputStream(portrait); // 头像
|
| | | erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 二维码
|
| | | }
|
| | | |
| | |
|
| | | // 开始根据 url(背景图), qrCode(二维码), portrait(头像) 生成图片
|
| | | ImageUtil.inviteFriendImgWhitecustom(urlInputStream, portraitInputStream, erCodeInputStream, targetPath,
|
| | | pX, pY, size, inviteCode);
|
| | | |
| | | ImageUtil.inviteFriendImgWhitecustom(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, pX, pY,
|
| | | size, inviteCode);
|
| | |
|
| | | // 删除二维码文件
|
| | | if(erCodeInputStream != null) {
|
| | | if (erCodeInputStream != null) {
|
| | | erCodeInputStream.close();
|
| | | }
|
| | | if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
|
| | | new File(erCodeTempPath).delete();
|
| | | }
|
| | | |
| | |
|
| | | // 上传文件相对位置
|
| | | if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
|
| | | int index = url.lastIndexOf("/");
|
| | | String newUrl = url.substring(index + 1);
|
| | | String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
|
| | | String fileUrl= null;
|
| | | String fileUrl = null;
|
| | | if (uid == null) {
|
| | | fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | } else {
|
| | |
| | |
|
| | | // 上传文件
|
| | | String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
|
| | | |
| | |
|
| | | // 删除本地缓存文件
|
| | | new File(targetPath).delete();
|
| | |
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public String drawInviteToGreet(String url, Long uid, String portrait, String inviteCode, String content, |
| | | Date date) throws IOException {
|
| | | |
| | | public String drawInviteToGreet(String url, Long uid, String portrait, String inviteCode, String content, Date date)
|
| | | throws IOException {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(url)) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | String targetPath = null;
|
| | | String erCodeTempPath = null;
|
| | | InputStream erCodeInputStream = null; // 二维码
|
| | | InputStream erCodeInputStream = null; // 二维码
|
| | | InputStream portraitInputStream = null; // 头像
|
| | | InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 背景
|
| | | |
| | |
|
| | | String uuid = UUID.randomUUID().toString().replace("-", "");
|
| | | if (uid == null) {
|
| | | targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
|
| | |
| | | erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
|
| | | // 官方默认头像
|
| | | portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
|
| | | |
| | |
|
| | | } else {
|
| | | targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
|
| | | erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); |
| | | erCodeInputStream = new FileInputStream(new File(erCodeTempPath));
|
| | | portraitInputStream = HttpUtil.getAsInputStream(portrait); // 头像
|
| | | }
|
| | | |
| | | |
| | | // 开始根据 url(背景图), qrCode(二维码), portrait(头像) 生成图片
|
| | | ImageUtil.drawInviteToGreet(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode, content, date);
|
| | |
|
| | | |
| | | // 开始根据 url(背景图), qrCode(二维码), portrait(头像) 生成图片
|
| | | ImageUtil.drawInviteToGreet(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode,
|
| | | content, date);
|
| | |
|
| | | // 删除二维码文件
|
| | | if(erCodeInputStream != null) {
|
| | | if (erCodeInputStream != null) {
|
| | | erCodeInputStream.close();
|
| | | }
|
| | | if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
|
| | | new File(erCodeTempPath).delete();
|
| | | }
|
| | | |
| | |
|
| | | // 上传文件
|
| | | if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
|
| | | int index = url.lastIndexOf("/");
|
| | |
| | | String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
|
| | |
|
| | | // 上传文件相对位置
|
| | | String fileUrl= null;
|
| | | String fileUrl = null;
|
| | | if (uid == null) {
|
| | | fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | } else {
|
| | |
| | | new File(targetPath).delete();
|
| | |
|
| | | return imgUrl;
|
| | | } |
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | public class UserInviteUtil {
|
| | |
|
| | | /**
|
| | | * 获取分享链接
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public static String getShareUrl(Long uid) {
|
| | | String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/"
|
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | return erCode;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setDescInfo( "等待人工审核");
|
| | | detail.setDescInfo("等待人工审核");
|
| | | detail.setUid(exchange.getUid());
|
| | | detail.setMoney(new BigDecimal("-" + exchange.getMoney()));
|
| | | detail.setType(RedPackDetailTypeEnum.redExchange);
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 板栗商城使用
|
| | | *
|
| | | * @param giveRecord
|
| | | * @return
|
| | |
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(false);
|
| | | detail.setUid(uid);
|
| | | detail.setMoney(money);
|
| | | detail.setMoney(new BigDecimal(0).subtract(money));
|
| | | detail.setType(RedPackDetailTypeEnum.useByShopOrder);
|
| | | detail.setTitle(title);
|
| | | detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.useByShopOrder.name() + "-" + orderId));
|
| | |
| | | detail.setDescInfo(setName);
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 新人奖励
|
| | | * 新人奖励
|
| | | * |
| | | * @param winInvite
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | |
| | | public static RedPackDetail createNewUserReward(RedPackWinInvite winInvite) throws RedPackDetailException {
|
| | | if (winInvite == null)
|
| | | throw new RedPackDetailException(1, "获得记录不能为空");
|
| | | |
| | |
|
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | |
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 立得现金
|
| | | * |
| | | * @param winInvite
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | |
| | | public static RedPackDetail createInvite(RedPackWinInvite winInvite) throws RedPackDetailException {
|
| | | if (winInvite == null)
|
| | | throw new RedPackDetailException(1, "获得记录不能为空");
|
| | | |
| | |
|
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | |
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 递增奖励 + 好友完成分享订单
|
| | | * |
| | | * @param winInvite
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | |
| | | public static RedPackDetail createIncreaseReward(RedPackWinInvite winInvite) throws RedPackDetailException {
|
| | | if (winInvite == null)
|
| | | throw new RedPackDetailException(1, "获得记录不能为空");
|
| | | |
| | |
|
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | |
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 连续奖励 + 好友完成分享订单
|
| | | * |
| | | * @param winInvite
|
| | | * @return
|
| | | * @throws RedPackDetailException
|
| | |
| | | public static RedPackDetail createSeriesReward(RedPackWinInvite winInvite) throws RedPackDetailException {
|
| | | if (winInvite == null)
|
| | | throw new RedPackDetailException(1, "获得记录不能为空");
|
| | | |
| | |
|
| | | // 红包明细- 退回红包
|
| | | RedPackDetail detail = new RedPackDetail();
|
| | | detail.setDisplay(true);
|
| | |
| | | detail.setCreateTime(new Date());
|
| | | return detail;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | public static RedPackDetail createShopOrderDrawBack(Long orderId, Long uid, String title, String setName,
|
| | | BigDecimal money) throws RedPackDetailException {
|
| | | if (orderId == null)
|