admin
2019-11-06 c23bccf7f39ebae903cc20d255b014d3e80c0221
红包H5接口修改
4个文件已修改
1个文件已添加
166 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/AppPageNotification.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/UserInviteUtil.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
@@ -45,6 +45,7 @@
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;
@@ -366,6 +367,8 @@
        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());
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/AppPageNotification.java
@@ -25,13 +25,39 @@
    // 消息类型的枚举
    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) {
fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java
@@ -21,6 +21,7 @@
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 {
@@ -131,21 +132,21 @@
        }
        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";
@@ -155,44 +156,43 @@
            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 {
@@ -201,7 +201,7 @@
            // 上传文件
            String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
            // 删除本地缓存文件
            new File(targetPath).delete();
@@ -209,21 +209,21 @@
        }
        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";
@@ -233,7 +233,7 @@
            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";
@@ -245,23 +245,22 @@
            } 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("/");
@@ -269,7 +268,7 @@
            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 {
@@ -282,7 +281,7 @@
            new File(targetPath).delete();
            return imgUrl;
        }
        }
        return null;
    }
fanli/src/main/java/com/yeshi/fanli/util/UserInviteUtil.java
New file
@@ -0,0 +1,16 @@
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;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -25,7 +25,7 @@
        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);
@@ -169,6 +169,7 @@
    }
    /**
     * 板栗商城使用
     * 
     * @param giveRecord
     * @return
@@ -183,7 +184,7 @@
        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));
@@ -191,10 +192,10 @@
        detail.setDescInfo(setName);
        return detail;
    }
    /**
     *  新人奖励
     * 新人奖励
     *
     * @param winInvite
     * @return
     * @throws RedPackDetailException
@@ -202,7 +203,7 @@
    public static RedPackDetail createNewUserReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
@@ -215,9 +216,10 @@
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 立得现金
     *
     * @param winInvite
     * @return
     * @throws RedPackDetailException
@@ -225,7 +227,7 @@
    public static RedPackDetail createInvite(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
@@ -238,9 +240,10 @@
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 递增奖励 + 好友完成分享订单
     *
     * @param winInvite
     * @return
     * @throws RedPackDetailException
@@ -248,7 +251,7 @@
    public static RedPackDetail createIncreaseReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
@@ -261,10 +264,10 @@
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 连续奖励 + 好友完成分享订单
     *
     * @param winInvite
     * @return
     * @throws RedPackDetailException
@@ -272,7 +275,7 @@
    public static RedPackDetail createSeriesReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
@@ -285,8 +288,7 @@
        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)