admin
2019-04-29 d92226ce9f81c44fd0e159662d928767ce423b83
淘宝用于自购的渠道ID存储
2个文件已删除
21个文件已修改
7个文件已添加
1370 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/WebFrequencyLimitAspect.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java 137 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/web/WebSearchController.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/money/UserMoneyDebtMapper.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoBuyRelationMapMapper.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/clazz/GoodsClass.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/TaoBaoBuyRelationMap.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/taobao/TaoBaoBuyRelationMapException.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/money/UserMoneyDebtMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoBuyRelationMapMapper.xml 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/UserMoneyDebtServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoBuyRelationMapServiceImpl.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java 247 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 109 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/money/UserMoneyDebtService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoBuyRelationMapService.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/TaoBaoConstant.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/money/UserMoneyDebtTypeEnumHandler.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/money/UserMoneyDetailTypeEnumHandler.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/mybatis/MyBatisMapperUtil.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/WebFrequencyLimitAspect.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.monitor.MonitorService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
@@ -56,6 +57,9 @@
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
    /**
     * 获取淘宝的分享链接
     * 
@@ -66,7 +70,7 @@
     * @param out
     */
    @RequestMapping(value = "gettaobaolink")
    public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
    public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
            PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
@@ -111,13 +115,13 @@
            specialConvert = false;
        String specialId = null;
        String relationId=null;
        String relationId = null;
        // 查询用户ID是否绑定了会员运营ID
        UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
        if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
                && userInfo.getSpecialValid() == true) {
            specialId = userInfo.getSpecialId();
            relationId=userInfo.getRelationId();
            relationId = userInfo.getRelationId();
            // 已经绑定
            if (specialConvert) {
                isNative = true;
@@ -131,26 +135,48 @@
        }
        data.put("native", isNative);
        int pidType = PidUser.TYPE_FANLI_ANDROID;
        if (acceptData.getPlatform().equalsIgnoreCase("ios"))
            pidType = PidUser.TYPE_FANLI_IOS;
        try {
            int pidType = PidUser.TYPE_FANLI_ANDROID;
            if (acceptData.getPlatform().equalsIgnoreCase("ios"))
                pidType = PidUser.TYPE_FANLI_IOS;
            TaoBaoLink taoBaoLink = null;
            if (!StringUtil.isNullOrEmpty(specialId) && specialConvert) {
                taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
            } else {
                if (!specialConvert && !isNative) {
            // 是返利商品库的商品
            if (specialConvert) {
                if (!StringUtil.isNullOrEmpty(specialId)) {
                    taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
                    data.put("native", true);
                } else {
                    if (!specialConvert && !isNative) {
                        if (pidType == PidUser.TYPE_FANLI_ANDROID)
                            taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
                                    tbPidService.getAndroidDefault().getPid());
                        else
                            taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
                                    tbPidService.getIOSDefault().getPid());
                    } else
                        taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
                }
            } else {// 不是返利库的商品,用特殊PID替代
                try {
                    relationId = taoBaoBuyRelationMapService.getRelationId(uid);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e, "uid:" + uid, null);
                }
                if (!StringUtil.isNullOrEmpty(relationId)) {//
                    taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
                            TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
                    data.put("native", true);
                } else {
                    if (pidType == PidUser.TYPE_FANLI_ANDROID)
                        taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
                                tbPidService.getAndroidDefault().getPid());
                    else
                        taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
                                tbPidService.getIOSDefault().getPid());
                } else
                    taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
                }
            }
            JSONObject link = new JSONObject();
            link.put("clickUrl", taoBaoLink.getClickUrl());
            link.put("couponUrl", taoBaoLink.getCouponLink());
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -107,6 +107,7 @@
import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.user.UserSettingsVO;
import net.sf.json.JSONArray;
@@ -115,7 +116,6 @@
@Controller
@RequestMapping("api/v1/user")
public class RecommendController {
    @Resource
    private BusinessSystemService businessSystemService;
@@ -140,7 +140,6 @@
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private TaoBaoCouponService taoBaoCouponService;
@@ -213,10 +212,9 @@
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private QualityFlashSaleService qualityFlashSaleService;
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
@@ -1561,7 +1559,6 @@
        out.print(JsonUtil.loadTrueResult(root));
    }
    /**
     * 新版推荐专题管理(1.5.3)
     * 
@@ -1571,7 +1568,7 @@
    @RequestMapping(value = "getRecommendIndex")
    public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) {
        try {
            //  1、专题模块
            // 1、专题模块
            JSONObject root = specialService.listCacheSpecialToIndex(acceptData);
            // 2、顶部轮播图
@@ -1580,29 +1577,27 @@
                topPicList = new ArrayList<SwiperPicture>();
            }
            root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
            // 3、邀请有奖
            List<SwiperPicture> invitePicList = null;
            if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                    && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
                // 如果IOS当前版本处于审核状态就不返回
            } else {
                invitePicList = getSwiperByCard("index_invite");
                invitePicList = getSwiperByCard("index_invite");
            }
            if (invitePicList == null) {
                invitePicList = new ArrayList<SwiperPicture>();
            }
            }
            root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
            // 4、IOS的底部网页链接
            String platform = acceptData.getPlatform();
            if ("ios".equalsIgnoreCase(platform)) {
                root.put("htmlLink", configService.get("index_html_link_ios"));
            }
            }
            out.print(JsonUtil.loadTrueResult(root));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "获取数据失败"));
@@ -1610,32 +1605,30 @@
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            }
        }
    }
    /**
     * 邀请有奖是否需要返回
     *
     * @param uid
     * @param acceptData
     * @return
     */
    public List<SwiperPicture>  getInvitePicList(Long uid, AcceptData acceptData) {
    public List<SwiperPicture> getInvitePicList(Long uid, AcceptData acceptData) {
        // 如果IOS当前版本处于审核状态就不返回
        if ("ios".equalsIgnoreCase(acceptData.getPlatform())
                && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
            return null;
        }
        List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
        }
        List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
        return invitePicList;
    }
    public List<SwiperPicture> getSwiperByCard(String card){
    public List<SwiperPicture> getSwiperByCard(String card) {
        List<SwiperPicture> swiperList = null;
        try {
            swiperList = swiperPictureService.getByBannerCard(card);
@@ -1649,8 +1642,7 @@
        }
        return swiperList;
    }
    /**
     * 限时秒杀 1.5.3
     * 
@@ -1659,91 +1651,90 @@
     */
    @RequestMapping(value = "getSpikeGoods")
    public void getSpikeGoods(AcceptData acceptData, PrintWriter out) {
        // 下一次倒计时的时间
        int type = qualityFlashSaleService.getNowType() + 1;
        int hour = 0;
        switch(type) {
            case 1:
                hour = 0;
                break;
            case 2:
                hour = 9;
                break;
            case 3:
                hour = 12;
                break;
            case 4:
                hour = 14;
                break;
            case 5:
                hour = 16;
                break;
            case 6:
                hour = 20;
                break;
            case 7:
                hour = 22;
                break;
            default:
                break;
        switch (type) {
        case 1:
            hour = 0;
            break;
        case 2:
            hour = 9;
            break;
        case 3:
            hour = 12;
            break;
        case 4:
            hour = 14;
            break;
        case 5:
            hour = 16;
            break;
        case 6:
            hour = 20;
            break;
        case 7:
            hour = 22;
            break;
        default:
            break;
        }
        Calendar nextTime = Calendar.getInstance();
        nextTime.set(Calendar.HOUR_OF_DAY, hour);
        nextTime.set(Calendar.MINUTE, 0);
        nextTime.set(Calendar.SECOND, 0);
        nextTime.set(Calendar.MILLISECOND, 0);
        JSONArray array = null;
        String timekey = "spikeGoods_hour";
        String cachekey = "spikeGoodsList";
        String timeValue = redisManager.getCommonString(timekey);
        if (timeValue == null || !timeValue.equals(hour+"")) {
            redisManager.cacheCommonString(timekey, hour+"", 60 * 30);
        if (timeValue == null || !timeValue.equals(hour + "")) {
            redisManager.cacheCommonString(timekey, hour + "", 60 * 30);
        } else {
            String cacheValue = redisManager.getCommonString(cachekey);
            if (!StringUtil.isNullOrEmpty(cacheValue)) {
                array = JSONArray.fromObject(cacheValue);
            }
        }
        if (array == null) {
            array = new JSONArray();
            BigDecimal proportion = manageService.getFanLiRate();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            // 缓存中不存在
            List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods();
            if (listGoods == null) {
                listGoods = new ArrayList<QualityFactory>();
            }
            /* 遍历列表数据 */
            for (QualityFactory qualityFactory : listGoods) {
                TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
                if (taoBaoGoodsBrief == null) {
                    continue;
                }
                array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
                array.add(gson
                        .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
            }
            // 缓存半个小时
            redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
        }
        JSONObject root = new JSONObject();
        root.put("time", nextTime.getTimeInMillis());
        root.put("listgoods", array);
        out.print(JsonUtil.loadTrueResult(root));
    }
    /**
     * 商品基本详情 (1.4.0)
     * 
@@ -2013,6 +2004,11 @@
        }
        goodsJson.put("hongBao", hongBao);
        List<ClientTextStyleVO> labels = new ArrayList<>();
        labels.add(new ClientTextStyleVO("标签测试内容1", "#FF0000"));
        labels.add(new ClientTextStyleVO("标签测试内容2", "#00FF00"));
        goodsJson.put("labels", labels);
        data.put("tbPidInfo", clientTBPid);
        String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId();
@@ -2042,6 +2038,7 @@
        }
        // 店铺
        goodsJson.put("shopInfo", tbShopInfo);
        goodsJson.put("fanliValid", true);// 是否有返利
        // 分享路径
        String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl());
fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
@@ -1156,13 +1156,17 @@
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    }
                    AdminUser adminUser = adminUserService.selectByPrimaryKey(4L);
                    long[] targetUids = new long[] { 3L, 4L };
                    Config config = configService.getConfig("extract_code_email_from");
                    String[] sts = config.getValue().split(",");
                    String account = sts[0];
                    String pwd = sts[1];
                    String msg = "提现审核链接:" + url;
                    boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的提现审核", msg);
                    for (long adminId : targetUids) {
                        AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
                        String msg = "提现审核链接:" + url;
                        boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的提现审核", msg);
                    }
                }
            });
            return;
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
@@ -18,16 +18,23 @@
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.service.inter.config.AppVersionService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -59,6 +66,12 @@
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private OrderService orderService;
    /**
     * 订单列表
@@ -422,24 +435,60 @@
            out.print(JsonUtil.loadFalseResult(1, "数据错误"));
            return;
        }
        String orderId = null;
        String[] orders = null;
        try {
            orderId = DESUtil.decode(orderData, StringUtil.getBase64String("YeShiFANLI889*+"),
            String orderIds = DESUtil.decode(orderData, StringUtil.getBase64String("YeShiFANLI889*+"),
                    StringUtil.getBase64String("*M#34f?,"));
            if (orderId != null && orderId.contains(","))
                orderId = orderId.split(",")[0];
            orders = orderIds.split(",");
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!StringUtil.isNullOrEmpty(orderId) && orderId.length() > 6) {
            orderId = orderId.substring(orderId.length() - 6, orderId.length());
            UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid);
            if (info != null) {
                UserExtraTaoBaoInfo update = new UserExtraTaoBaoInfo();
                update.setId(info.getId());
                update.setTaoBaoOrderEnd6Num(orderId);
                userExtraTaoBaoInfoService.updateSelective(update);
        if ("findOrder".equalsIgnoreCase(source)) {
            // 匹配订单
            for (String order : orders) {
                if (!StringUtil.isNullOrEmpty(order)) {
                    List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(order);
                    if (orderList != null && orderList.size() > 0) {
                        List<CommonOrder> commonOrderList = commonOrderService
                                .listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO, order);
                        if (commonOrderList == null || commonOrderList.size() == 0) {
                            Order or = new Order();
                            or.setBeizhu("人工自动找回补单");
                            or.setCreatetime(System.currentTimeMillis());
                            or.setOrderId(order);
                            or.setOrderType(1);
                            or.setState(Order.STATE_YIZHIFU);
                            or.setUserInfo(new UserInfo(uid));
                            or.setVersion(2);
                            // 加入到订单表
                            boolean isS;
                            try {
                                isS = orderService.addOrder(or);
                                if (isS) {
                                    CMQManager.getInstance().addTaoBaoOrderMsg(order, orderList);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        } else {
            String orderId = null;
            if (orders != null && orders.length > 0)
                orderId = orders[0];
            if (!StringUtil.isNullOrEmpty(orderId) && orderId.length() > 6) {
                orderId = orderId.substring(orderId.length() - 6, orderId.length());
                UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService.getByUid(uid);
                if (info != null) {
                    UserExtraTaoBaoInfo update = new UserExtraTaoBaoInfo();
                    update.setId(info.getId());
                    update.setTaoBaoOrderEnd6Num(orderId);
                    userExtraTaoBaoInfoService.updateSelective(update);
                }
            }
        }
        out.print(JsonUtil.loadTrueResult(""));
fanli/src/main/java/com/yeshi/fanli/controller/web/WebSearchController.java
@@ -179,7 +179,15 @@
                sf.setStartTkRate(Integer.parseInt(rate));
            } catch (Exception e) {
            }
        if (!StringUtil.isNullOrEmpty(order))
            if (Integer.parseInt(order) == 0)
                sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
            else if (Integer.parseInt(order) == 2)
                sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH);
            else if (Integer.parseInt(order) == 3)
                sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW);
            else if (Integer.parseInt(order) == 4)
                sf.setSort(TaoBaoUtil.SORT_TKRATE_HIGH_TO_LOW);
        if (StringUtil.isNullOrEmpty(kw))
            recommend = true;
@@ -243,12 +251,12 @@
                        }
                } else {
                    TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra;
                    if(taoBaoGoodsBriefs!=null)
                    for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
                        taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                                proportion.toString(), "");
                        listExtra.add(taoBaoGoodsBriefExtra);
                    }
                    if (taoBaoGoodsBriefs != null)
                        for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
                            taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
                                    proportion.toString(), "");
                            listExtra.add(taoBaoGoodsBriefExtra);
                        }
                }
                count = result.getTaoBaoHead().getDocsfound();
            }
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/money/UserMoneyDebtMapper.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.dao.mybatis.money;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -17,8 +19,18 @@
     */
    UserMoneyDebt selectByUidAndTypeAndSourceId(@Param("uid") Long uid, @Param("type") UserMoneyDebtTypeEnum type,
            @Param("sourceId") Long sourceId);
    UserMoneyDebt    selectByTypeAndSourceId(@Param("type") UserMoneyDebtTypeEnum type,
            @Param("sourceId") Long sourceId);
    UserMoneyDebt selectByTypeAndSourceId(@Param("type") UserMoneyDebtTypeEnum type, @Param("sourceId") Long sourceId);
    /**
     * 查询欠债
     *
     * @param uid
     * @param start
     * @param count
     * @return
     */
    List<UserMoneyDebt> listByUidWithHasLeftMoney(@Param("uid") Long uid, @Param("start") long start,
            @Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoBuyRelationMapMapper.java
New file
@@ -0,0 +1,35 @@
package com.yeshi.fanli.dao.mybatis.taobao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap;
public interface TaoBaoBuyRelationMapMapper extends BaseMapper<TaoBaoBuyRelationMap> {
    /**
     * 获取有效的渠道ID
     *
     * @param uid
     * @param count
     * @return
     */
    List<String> listValidRelaionId(@Param("uid")Long uid,@Param("count") int count);
    /**
     * 通过渠道ID查询
     *
     * @param relationId
     * @return
     */
    TaoBaoBuyRelationMap selectByRelationId(String relationId);
    /**
     * 根据用户id查询
     *
     * @param uid
     * @return
     */
    TaoBaoBuyRelationMap selectByUid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/clazz/GoodsClass.java
@@ -74,6 +74,11 @@
        this.id = id;
    }
    public GoodsClass(Long id, String name) {
        this.id = id;
        this.name = name;
    }
    public GoodsClass(String name, String picture, Integer orderby, Long createtime) {
        super();
        this.name = name;
fanli/src/main/java/com/yeshi/fanli/entity/taobao/TaoBaoBuyRelationMap.java
New file
@@ -0,0 +1,51 @@
package com.yeshi.fanli.entity.taobao;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
@Table("yeshi_ec_taobao_buy_relation")
public class TaoBaoBuyRelationMap {
    @Column(name="tbr_id")
    private Long id;
    @Column(name="tbr_uid")
    private Long uid;
    @Column(name="tbr_realtion_id")
    private String relationId;
    @Column(name="tbr_create_time")
    private Date createTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public String getRelationId() {
        return relationId;
    }
    public void setRelationId(String relationId) {
        this.relationId = relationId;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/taobao/TaoBaoBuyRelationMapException.java
New file
@@ -0,0 +1,33 @@
package com.yeshi.fanli.exception.taobao;
//淘宝商品下架
public class TaoBaoBuyRelationMapException extends Exception {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public TaoBaoBuyRelationMapException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public TaoBaoBuyRelationMapException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/money/UserMoneyDebtMapper.xml
@@ -9,7 +9,7 @@
            jdbcType="DECIMAL" />
        <result column="ud_left_money" property="leftMoney" jdbcType="DECIMAL" />
        <result column="ud_type" property="type" jdbcType="VARCHAR"
            typeHandler="com.yeshi.fanli.util.mybatishandler.money.UserMoneyDetailTypeEnumHandler" />
            typeHandler="com.yeshi.fanli.util.mybatishandler.money.UserMoneyDebtTypeEnumHandler" />
        <result column="ud_source_id" property="sourceId" jdbcType="BIGINT" />
        <result column="ud_beizhu" property="beiZhu" jdbcType="VARCHAR" />
        <result column="ud_create_time" property="createTime" jdbcType="TIMESTAMP" />
@@ -38,8 +38,12 @@
        from yeshi_ec_user_debt where ud_type=#{type} and
        ud_source_id=#{sourceId} limit 1 for update
    </select>
    <select id="listByUidWithHasLeftMoney" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user_debt where ud_uid=#{uid} and ud_left_money>0 limit #{start},#{count}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_user_debt where ud_id = #{id,jdbcType=BIGINT}
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoBuyRelationMapMapper.xml
New file
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.taobao.TaoBaoBuyRelationMapMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap">
        <id column="tbr_id" property="id" jdbcType="BIGINT" />
        <result column="tbr_uid" property="uid" jdbcType="BIGINT" />
        <result column="tbr_relation_id" property="relationId"
            jdbcType="VARCHAR" />
        <result column="tbr_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">tbr_id,tbr_uid,tbr_relation_id,tbr_create_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_buy_relation where tbr_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="listValidRelaionId" resultType="java.lang.String">
        SELECT
        t.`uiet_relation_id` FROM `yeshi_ec_user_info_extra_taobao` t LEFT
        JOIN `yeshi_ec_taobao_buy_relation` r ON
        t.`uiet_relation_id`=r.`tbr_relation_id` WHERE t.`uiet_relation_id` IS
        NOT NULL AND r.`tbr_id` IS NULL AND t.`uiet_uid`!=#{uid} AND
        t.`uiet_relation_valid`=1 LIMIT #{count}
    </select>
    <select id="selectByRelationId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_buy_relation where tbr_relation_id = #{0}
    </select>
    <select id="selectByUid" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_buy_relation where tbr_uid = #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_buy_relation where tbr_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_taobao_buy_relation
        (tbr_id,tbr_uid,tbr_relation_id,tbr_create_time) values
        (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{relationId,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_taobao_buy_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">tbr_id,</if>
            <if test="uid != null">tbr_uid,</if>
            <if test="relationId != null">tbr_relation_id,</if>
            <if test="createTime != null">tbr_create_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
            <if test="relationId != null">#{relationId,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap">update
        yeshi_ec_taobao_buy_relation set tbr_uid =
        #{uid,jdbcType=BIGINT},tbr_relation_id =
        #{relationId,jdbcType=VARCHAR},tbr_create_time =
        #{createTime,jdbcType=TIMESTAMP} where tbr_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap">
        update yeshi_ec_taobao_buy_relation
        <set>
            <if test="uid != null">tbr_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="relationId != null">tbr_relation_id=#{relationId,jdbcType=VARCHAR},</if>
            <if test="createTime != null">tbr_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
        </set>
        where tbr_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -551,4 +551,94 @@
        return userShareGoodsHistoryMapper.selectByUidAndAuctionId(uid, auctionId);
    }
    @Override
    public TaoBaoLink getTaoBaoLinkForShare(Long uid, Long auctionId, String relationId, String pid)
            throws ShareGoodsException {
        if (uid == null || uid <= 0) {
            throw new ShareGoodsException(1, "用户ID不能为空");
        }
        if (auctionId == null || auctionId <= 0) {
            throw new ShareGoodsException(2, "商品ID不能为空");
        }
        TaoKeAppInfo info = new TaoKeAppInfo();
        if (!StringUtil.isNullOrEmpty(relationId)) {
            String appId = pid.split("_")[2];
            String adzoneId = pid.split("_")[3];
            TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
            info.setAdzoneId(adzoneId);
            info.setAppKey(taoBaoUnionConfig.getAppKey());
            info.setAppSecret(taoBaoUnionConfig.getAppSecret());
            info.setPid(pid);
        } else {
            TBPid tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
            if (tbPid == null) {
                throw new ShareGoodsException(3, "获取推广位失败");
            }
            String appId = tbPid.getPid().split("_")[2];
            TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
            String adzoneId = tbPid.getPid().split("_")[3];
            info.setAdzoneId(adzoneId);
            info.setAppKey(taoBaoUnionConfig.getAppKey());
            info.setAppSecret(taoBaoUnionConfig.getAppSecret());
            info.setPid(tbPid.getPid());
        }
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId, info);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(4, "商品已下架");
        } finally {
        }
        if (goods == null) {
            throw new ShareGoodsException(5, "获取商品详情失败");
        }
        if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
            TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
            if (taoBaoLink == null) {
                throw new ShareGoodsException(201, "商品转链失败");
            }
            goods.setCouponLink(taoBaoLink.getCouponLink());
            goods.setAuctionUrl(taoBaoLink.getAuctionUrl());
        }
        if (!StringUtil.isNullOrEmpty(relationId)) {
            if (!StringUtil.isNullOrEmpty(goods.getAuctionUrl()))
                goods.setAuctionUrl(goods.getAuctionUrl() + "&relationId=" + relationId);
            if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
                goods.setCouponLink(goods.getCouponLink() + "&relationId=" + relationId);
        }
        // 保存商品详情
        // 创建淘口令
        TaoBaoLink tbLink = new TaoBaoLink();
        tbLink.setAuctionId(goods.getAuctionId());
        tbLink.setClickUrl(goods.getAuctionUrl());
        tbLink.setCouponLink(goods.getCouponLink());
        if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
                tbLink.setTaoToken(quanToken);
            }
        }
        tbLink.setGoods(goods);
        // 存储分享商品的信息,用于加快分享网页接口请求速度
        if (Constant.IS_OUTNET)
            redisManager.saveTaoBaoGoodsBriefTemp(goods);
        return tbLink;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/UserMoneyDebtServiceImpl.java
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -18,6 +19,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
import com.yeshi.fanli.exception.money.UserMoneyDebtException;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
@@ -144,7 +146,7 @@
                // 新版通知
                userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(), money,
                        userInfoService.getMyHB(uid));
                        userInfoService.getBalance(uid));
                break;
            case HongBaoV2.TYPE_SHARE_GOODS:
@@ -156,7 +158,7 @@
                    userMoneyService.subUserMoney(uid, money, userMoneyDetail);
                    userMoneyMsgNotificationService.shareOrderWeiQuan(debt.getUid(), weiQuanDrawBack.getOrderId(),
                            money, userInfoService.getMyHB(uid));
                            money, userInfoService.getBalance(uid));
                } catch (UserMoneyDetailException e) {
                    throw new UserMoneyDebtException(12, "插入资金详情出错");
@@ -178,11 +180,32 @@
                // 新版通知
                userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, weiQuanDrawBack.getOrderId(), money,
                        userInfoService.getMyHB(uid));
                        userInfoService.getBalance(uid));
                break;
            }
        }
    }
    @Transactional
    @Override
    public void repayDebt(Long uid) {
        // 查询是否有欠债
        List<UserMoneyDebt> list = userMoneyDebtMapper.listByUidWithHasLeftMoney(uid, 0, 50);
        if (list != null && list.size() > 0) {// 有欠债
            for (UserMoneyDebt debt : list) {
                BigDecimal leftMoney = userInfoService.getBalance(uid);
                if (leftMoney.compareTo(debt.getLeftMoney()) >= 0) {// 有足够的资金偿还债务
                    try {
                        repayDebt(debt, debt.getLeftMoney());
                    } catch (UserMoneyDebtException e) {
                        try {
                            LogHelper.errorDetailInfo(e, "uid:" + uid + " debtId:" + debt.getId(), null);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            }
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -54,6 +54,7 @@
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanDrawBackService;
@@ -138,6 +139,9 @@
    @Resource
    private UserMoneyService userMoneyService;
    @Resource
    private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
    @Override
    public void processOrder(Map<String, List<TaoBaoOrder>> orders) {
@@ -579,8 +583,8 @@
                    if (drawBack == null) {// 还未扣款
                        try {
                            taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId());
                            taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
                            taoBaoWeiQuanDrawBackService.doWeiQuanShare(order.getOrderId());
                            taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
                        } catch (TaoBaoWeiQuanException e) {
                            try {
                                LogHelper.errorDetailInfo(e, null, "订单号:" + order.getOrderId());
@@ -923,15 +927,21 @@
                    orderMapper.insertSelective(order);
                    oldOrder = order;
                } else {
                    UserExtraTaoBaoInfo info = null;
                    Long targetUid = null;
                    if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
                            && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
                        info = userExtraTaoBaoInfoService.getByRelationId(orderList.get(0).getRelationId());
                        targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
                    } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
                        info = userExtraTaoBaoInfoService.getBySpecialId(orderList.get(0).getSpecialId());
                        UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
                                .getBySpecialId(orderList.get(0).getSpecialId());
                        if (info != null && info.getUser() != null)
                            targetUid = info.getUser().getId();
                    }
                    if (info != null && info.getUser() != null) {
                        uid = info.getUser().getId();
                    if (targetUid != null) {
                        uid = targetUid;
                        // 插入到Order中
                        // 添加到订单中去
                        Order order = new Order();
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoBuyRelationMapServiceImpl.java
New file
@@ -0,0 +1,65 @@
package com.yeshi.fanli.service.impl.taobao;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoBuyRelationMapMapper;
import com.yeshi.fanli.entity.taobao.TaoBaoBuyRelationMap;
import com.yeshi.fanli.exception.taobao.TaoBaoBuyRelationMapException;
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.util.StringUtil;
@Service
public class TaoBaoBuyRelationMapServiceImpl implements TaoBaoBuyRelationMapService {
    @Resource
    private TaoBaoBuyRelationMapMapper taoBaoBuyRelationMapMapper;
    @Transactional
    @Override
    public String getRelationId(Long uid) throws TaoBaoBuyRelationMapException {
        TaoBaoBuyRelationMap relationMap = taoBaoBuyRelationMapMapper.selectByUid(uid);
        if (relationMap != null)
            return relationMap.getRelationId();
        String relationId = null;
        // 总共尝试3次分配
        for (int i = 0; i < 3; i++) {
            if (!StringUtil.isNullOrEmpty(relationId))
                break;
            try {
                List<String> list = taoBaoBuyRelationMapMapper.listValidRelaionId(uid, 1);
                if (list == null || list.size() == 0)
                    throw new TaoBaoBuyRelationMapException(1, "渠道ID库存不足");
                TaoBaoBuyRelationMap map = new TaoBaoBuyRelationMap();
                map.setCreateTime(new Date());
                map.setRelationId(list.get(0));
                map.setUid(uid);
                taoBaoBuyRelationMapMapper.insertSelective(map);
                relationId = map.getRelationId();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (StringUtil.isNullOrEmpty(relationId))
            throw new TaoBaoBuyRelationMapException(2, "渠道ID分配失败");
        return relationId;
    }
    @Override
    public Long selectUidByRelationId(String relationId) {
        TaoBaoBuyRelationMap map = taoBaoBuyRelationMapMapper.selectByRelationId(relationId);
        if (map != null)
            return map.getUid();
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java
@@ -319,8 +319,8 @@
                if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
                    continue;
                // 返利红包不计入
                if (hongBao.getType() != HongBaoV2.TYPE_ZIGOU) {
                // 只计入分享赚的红包
                if (hongBao.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
                    // 累计主红包的金额
                    if (fanMoneyMap.get(hongBao.getUserInfo().getId()) == null) {
                        fanMoneyMap.put(hongBao.getUserInfo().getId(), hongBao.getMoney());
@@ -328,18 +328,6 @@
                        fanMoneyMap.put(hongBao.getUserInfo().getId(),
                                fanMoneyMap.get(hongBao.getUserInfo().getId()).add(hongBao.getMoney()));
                }
                // 累计子红包的金额
                List<HongBaoV2> childHongBaoList = hongBaoV2Mapper.listChildrenById(hongBao.getId());
                if (childHongBaoList != null)
                    for (HongBaoV2 child : childHongBaoList) {
                        if (child.getState() == HongBaoV2.STATE_SHIXIAO)
                            continue;
                        if (fanMoneyMap.get(child.getUserInfo().getId()) == null) {
                            fanMoneyMap.put(child.getUserInfo().getId(), child.getMoney());
                        } else
                            fanMoneyMap.put(child.getUserInfo().getId(),
                                    fanMoneyMap.get(child.getUserInfo().getId()).add(child.getMoney()));
                    }
            }
        // 计算每个用户的返利比例
@@ -395,6 +383,15 @@
                                weiQuanOrder.getOrderItemId());
                        if (co != null) {
                            HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
                            BigDecimal drawback = MoneyBigDecimalUtil.div(
                                    hongBaoOrder.getHongBaoV2().getMoney().multiply(weiQuanOrder.getFanMoney()),
                                    totalFee);
                            try {
                                addDebt(uid, hongBaoOrder.getHongBaoV2().getId(), drawback);
                            } catch (UserMoneyDebtException e) {
                                throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                            }
                            if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
                                List<HongBaoV2> hongBaoList = hongBaoV2Mapper
                                        .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
@@ -406,10 +403,10 @@
                                }
                                for (HongBaoV2 hb : hongBaoList) {
                                    BigDecimal drawback = MoneyBigDecimalUtil
                                    drawback = MoneyBigDecimalUtil
                                            .div(hb.getMoney().multiply(weiQuanOrder.getFanMoney()), totalFee);
                                    try {
                                        addDebt(uid, hb.getId(), drawback);
                                        addDebt(hb.getUserInfo().getId(), hb.getId(), drawback);
                                    } catch (UserMoneyDebtException e) {
                                        throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                                    }
@@ -440,7 +437,6 @@
            userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney);
        }
    }
    @Transactional
@@ -453,175 +449,80 @@
        if (list == null || list.size() == 0)
            return;
        // 查询订单库
        List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
        // 计算淘宝联盟返给平台的资金
        BigDecimal sumFee = new BigDecimal("0");
        for (TaoBaoOrder order : orderList)
            if (order.getOrderState().equalsIgnoreCase("订单结算")) {
                sumFee = sumFee.add(order.geteIncome());
                if (order.getSubsidy() != null)
                    sumFee = sumFee.add(order.getSubsidy());
        for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
            TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
            BigDecimal fanMoney = weiQuanOrder.getFanMoney();
            if (taoBaoOrder == null)
                throw new TaoBaoWeiQuanException(1, "来源交易ID有误");
            BigDecimal sumFee = new BigDecimal("0");
            if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算")) {
                sumFee = sumFee.add(taoBaoOrder.geteIncome());
                if (taoBaoOrder.getSubsidy() != null)
                    sumFee = sumFee.add(taoBaoOrder.getSubsidy());
            }
        // 获取和该订单号有关联的用户
        // 获取主红包(同一个订单号的单只会对应同一个用户)
        List<CommonOrderVO> typeList = new ArrayList<>();
        CommonOrderVO cv = new CommonOrderVO();
        cv.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
        cv.setOrderNo(orderId);
        typeList.add(cv);
        List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
        List<HongBaoV2> mainHongBaoList = new ArrayList<>();
        if (commonOrderList != null)
            for (CommonOrderVO vo : commonOrderList) {
                CommonOrder co = commonOrderMapper.selectByPrimaryKey(vo.getId());
                if (co.getState() != CommonOrder.STATE_WQ) {
                    co = new CommonOrder(vo.getId());
                    co.setState(CommonOrder.STATE_WQ);
                    co.setUpdateTime(new Date());
                    commonOrderMapper.updateByPrimaryKeySelective(co);
                }
            // 查询下级子用户
            CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                    weiQuanOrder.getOrderItemId());
            if (commonOrder == null)
                throw new TaoBaoWeiQuanException(2, "订单有误");
                HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
                mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
            }
        if (mainHongBaoList == null || mainHongBaoList.size() == 0)
            return;
            HongBaoOrder hongbaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
        // 主用户ID
        Map<Long, BigDecimal> fanMoneyMap = new HashMap<>();
            if (hongbaoOrder == null || hongbaoOrder.getHongBaoV2() == null)
                throw new TaoBaoWeiQuanException(3, "红包有误");
        if (mainHongBaoList != null)
            for (HongBaoV2 hongBao : mainHongBaoList) {
                HongBaoV2 hb = hongBaoV2Mapper.selectByPrimaryKey(hongBao.getId());
                hongBao = hb;
            List<HongBaoV2> childList = hongBaoV2Mapper.listChildrenById(hongbaoOrder.getHongBaoV2().getId());
                if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
                    continue;
                // 返利红包不计入
                if (hongBao.getType() != HongBaoV2.TYPE_ZIGOU) {
                    // 累计主红包的金额
                    if (fanMoneyMap.get(hongBao.getUserInfo().getId()) == null) {
                        fanMoneyMap.put(hongBao.getUserInfo().getId(), hongBao.getMoney());
                    } else
                        fanMoneyMap.put(hongBao.getUserInfo().getId(),
                                fanMoneyMap.get(hongBao.getUserInfo().getId()).add(hongBao.getMoney()));
                }
                // 累计子红包的金额
                List<HongBaoV2> childHongBaoList = hongBaoV2Mapper.listChildrenById(hongBao.getId());
                if (childHongBaoList != null)
                    for (HongBaoV2 child : childHongBaoList) {
                        if (child.getState() == HongBaoV2.STATE_SHIXIAO)
                            continue;
                        if (fanMoneyMap.get(child.getUserInfo().getId()) == null) {
                            fanMoneyMap.put(child.getUserInfo().getId(), child.getMoney());
                        } else
                            fanMoneyMap.put(child.getUserInfo().getId(),
                                    fanMoneyMap.get(child.getUserInfo().getId()).add(child.getMoney()));
            if (childList != null)
                for (HongBaoV2 child : childList) {
                    Long uid = child.getUserInfo().getId();
                    if (child.getState() != HongBaoV2.STATE_YILINGQU)
                        continue;
                    TaoBaoWeiQuanDrawBack weiQuanDrawBack = taoBaoWeiQuanDrawBackMapper
                            .selectByOrderItemIdAndUid(weiQuanOrder.getOrderItemId(), child.getUserInfo().getId());
                    if (weiQuanDrawBack != null)
                        continue;
                    BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(child.getMoney().multiply(fanMoney), sumFee);
                    weiQuanDrawBack = new TaoBaoWeiQuanDrawBack();
                    weiQuanDrawBack.setCreateTime(new Date());
                    weiQuanDrawBack.setDrawBackMoney(drawBackMoney);
                    weiQuanDrawBack.setOrderId(weiQuanOrder.getOrderId());
                    weiQuanDrawBack.setOrderItemId(weiQuanOrder.getOrderItemId());
                    weiQuanDrawBack.setUser(child.getUserInfo());
                    taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
                    // 判断资金是否足够扣款
                    UserInfo user = userInfoMapper.selectByPKey(uid);
                    if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
                    {
                        try {
                            addDebt(uid, child.getId(), drawBackMoney);
                        } catch (UserMoneyDebtException e) {
                            throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                        }
                        continue;
                    }
            }
        // 计算每个用户的返利比例
        Iterator<Long> its = fanMoneyMap.keySet().iterator();
        while (its.hasNext()) {
            Long uid = its.next();
            BigDecimal userGetMoney = fanMoneyMap.get(uid);
            BigDecimal fanMoney = new BigDecimal("0");
            // 统计用户在这个单中需要扣除的资金
            TaoBaoWeiQuanDrawBack weiQuanDrawBack = null;
            List<TaoBaoWeiQuanDrawBack> newWeiQuanDrawBackList = new ArrayList<>();
            for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
                weiQuanDrawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(weiQuanOrder.getOrderItemId(),
                        uid);
                if (weiQuanDrawBack != null)
                    continue;
                // 退款的资金
                fanMoney = fanMoney.add(weiQuanOrder.getFanMoney());
                // 插入记录
                weiQuanDrawBack = new TaoBaoWeiQuanDrawBack();
                weiQuanDrawBack.setCreateTime(new Date());
                // TODO 暂时设为0
                weiQuanDrawBack.setDrawBackMoney(new BigDecimal(0));
                weiQuanDrawBack.setOrderId(weiQuanOrder.getOrderId());
                weiQuanDrawBack.setOrderItemId(weiQuanOrder.getOrderItemId());
                weiQuanDrawBack.setUser(new UserInfo(uid));
                newWeiQuanDrawBackList.add(weiQuanDrawBack);
            }
                    userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
            if (fanMoney.compareTo(new BigDecimal("0")) <= 0)
                continue;
            for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList)
                taoBaoWeiQuanDrawBackMapper.insertSelective(drawBack);
            // 退款金额
            BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
            // 计算资金是否充足
            UserInfo user = userInfoMapper.selectByPKey(uid);
            if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
            {
                // 添加债务
                for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
                    TaoBaoOrder taoBaoOrder = taoBaoOrderMapper
                            .selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
                    if (taoBaoOrder != null) {
                        BigDecimal totalFee = taoBaoOrder.geteIncome();
                        if (taoBaoOrder.getSubsidy() != null)
                            totalFee = totalFee.add(taoBaoOrder.getSubsidy());
                        //
                        CommonOrder co = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                                weiQuanOrder.getOrderItemId());
                        if (co != null) {
                            HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
                            if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
                                List<HongBaoV2> hongBaoList = hongBaoV2Mapper
                                        .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
                                for (int i = 0; i < hongBaoList.size(); i++) {
                                    if (hongBaoList.get(i).getUserInfo().getId().longValue() != uid) {
                                        hongBaoList.remove(i);
                                        i--;
                                    }
                                }
                                for (HongBaoV2 hb : hongBaoList) {
                                    BigDecimal drawback = MoneyBigDecimalUtil
                                            .div(hb.getMoney().multiply(weiQuanOrder.getFanMoney()), totalFee);
                                    try {
                                        addDebt(uid, hb.getId(), drawback);
                                    } catch (UserMoneyDebtException e) {
                                        throw new TaoBaoWeiQuanException(101, "资金借贷异常");
                                    }
                                }
                            }
                    // 新版资金记录
                    try {
                        UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid,
                                weiQuanDrawBack, drawBackMoney);
                        userMoneyDetailMapper.insert(userMoneyDetail);
                    } catch (UserMoneyDetailException e) {
                        try {
                            LogHelper.errorDetailInfo(e);
                        } catch (Exception e1) {
                            e1.printStackTrace();
                        }
                    }
                    // 新版通知
                    userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
                            userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
                }
                continue;
            }
            userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
            // 新版资金记录
            try {
                UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
                        drawBackMoney);
                userMoneyDetailMapper.insert(userMoneyDetail);
            } catch (UserMoneyDetailException e) {
                try {
                    LogHelper.errorDetailInfo(e);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            // 新版通知
            userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
                    userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
            userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney);
        }
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -95,20 +95,18 @@
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private UserRankService userRankService;
    @Resource
    private UserActiveLogService userActiveLogService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService;
    public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
        List<UserInfo> list = null;
@@ -639,32 +637,28 @@
    }
    @Override
    public BigDecimal getMyHB(Long id) {
        return userInfoMapper.getMyHB(id);
    }
    @Override
    public UserInfo getUserByIdWithMybatis(long uid) {
        UserInfo user = userInfoMapper.selectByPKey(uid);
        return UserUtil.filterForClientUser(user);
    }
    @Override
    public long queryCount( Integer userState, String key, Integer keyType, String userRank, Integer days, String startTime, String endTime) {
    public long queryCount(Integer userState, String key, Integer keyType, String userRank, Integer days,
            String startTime, String endTime) {
        return userInfoMapper.queryCount(userState, key, keyType, userRank, days, startTime, endTime);
    }
    @Override
    public List<UserInfoVO> query(long start, int count,  Integer userState, String key, Integer keyType,
    public List<UserInfoVO> query(long start, int count, Integer userState, String key, Integer keyType,
            String userRank, Integer days, String startTime, String endTime, Integer orderField, Integer orderMode) {
        List<UserInfoVO> userList = userInfoMapper.query(start, count,userState, key, keyType, userRank, days, startTime, endTime,
                orderField, orderMode);
        List<UserInfoVO> userList = userInfoMapper.query(start, count, userState, key, keyType, userRank, days,
                startTime, endTime, orderField, orderMode);
        if (userList == null || userList.size() == 0) {
            return null;
        }
        for (UserInfoVO userInfoVO : userList) {
            // 数据加工处理
            convertUserInfoVOData(userInfoVO);
@@ -672,53 +666,52 @@
        return userList;
    }
    public void convertUserInfoVOData(UserInfoVO userInfoVO) {
        String rankName = userInfoVO.getRankName();
        if (rankName == null || rankName.trim().length() == 0) {
            userInfoVO.setRankName("青铜");
            userInfoVO.setRankPicture("http://img.flqapp.com/resource/rank/rank_picture_new_1.png");
        }
        String f_alipayAccount = userInfoVO.getAlipayAccountInvalid();
        if (f_alipayAccount != null && f_alipayAccount.trim().length() > 0) {
            userInfoVO.setAlipayAccountState(1);
        }
        String f_phone = userInfoVO.getPhoneInvalid();
        if (f_phone != null && f_phone.trim().length() > 0) {
            userInfoVO.setPhoneState(1);
        }
        String f_taobaoUid = userInfoVO.getTaobaoUidInvalid();
        if (f_taobaoUid != null && f_taobaoUid.trim().length() > 0) {
            userInfoVO.setTaobaoUidState(1);
        }
        String f_wxUnionId = userInfoVO.getWxUnionIdInvalid();
        if (f_wxUnionId != null && f_wxUnionId.trim().length() > 0) {
            userInfoVO.setWxUnionIdState(1);
        }
        // 最近登录时间
        Long lastLoginTime = userInfoVO.getLastLoginTime();
        if (lastLoginTime != null && lastLoginTime == 0) {
            userInfoVO.setLastLoginTime(null);
        }
        /* 显示用户微信 淘宝  老版本存在
         * String wxUnionId = userInfoVO.getWxUnionId(); if (wxUnionId == null ||
         * wxUnionId.trim().length() == 0) { userInfoVO.setWxName(null); }
        /*
         * 显示用户微信 淘宝 老版本存在 String wxUnionId = userInfoVO.getWxUnionId(); if
         * (wxUnionId == null || wxUnionId.trim().length() == 0) {
         * userInfoVO.setWxName(null); }
         * 
         * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null ||
         * taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
         * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null
         * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
         */
        Long uid = userInfoVO.getId();
        /* 绑定收款账号信息 */
        List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
        if (account != null && account.size() > 0) {
@@ -737,7 +730,7 @@
                userInfoVO.setAccountBindIdWX(bindingAccount.getId());
            }
        }
        // 最近一次下单时间
        Date lastOrderTime = hongBaoV2CountService.getLastHongBaoTime(uid);
        if (lastOrderTime != null && lastOrderTime.getTime() != 0) {
@@ -785,7 +778,6 @@
        int secondTeamCount = shareMapper.mySecondTeamCount(uid + "");
        userInfoVO.setCountLevelTwo(secondTeamCount);
    }
    @Override
    public double querySumMoney(String key, Integer userType, Integer days, String startTime, String endTime) {
@@ -847,36 +839,36 @@
    public UserInfo getInfoByPhoneOrInviteCode(String phone, String inviteCode) {
        return userInfoMapper.getInfoByPhoneOrInviteCode(phone, inviteCode);
    }
    @Override
    public UserInfo getEffectiveUserInfoByPhone(String phone) {
        return userInfoMapper.getEffectiveUserInfoByPhone(phone);
    }
    @Override
    public UserInfo getEffectiveUserInfoByWXUnionId(String unionId) {
        return userInfoMapper.getEffectiveUserInfoByWXUnionId(unionId);
    }
    @Override
    public UserInfo getUserInfo(Long uid) throws UserInfoException{
    public UserInfo getUserInfo(Long uid) throws UserInfoException {
        if (uid == null) {
            throw new UserInfoException(1, "请求参数为空");
        }
        UserInfo userInfo = userInfoMapper.selectByPKey(uid);
        if(userInfo == null) {
        if (userInfo == null) {
            throw new UserInfoException(1, "用户不存在");
        }
        if (userInfo.getState() == UserInfo.STATE_FORBIDDEN) {
            throw new UserInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
        }
        if (userInfo.getState()!= UserInfo.STATE_NORMAL) {
        if (userInfo.getState() != UserInfo.STATE_NORMAL) {
            throw new UserInfoException(1, "用户不存在");
        }
        // 淘宝昵称 组织
        boolean clearOpenid = true;
        UserExtraTaoBaoInfo extraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
@@ -884,28 +876,35 @@
            String specialId = extraTaoBaoInfo.getSpecialId();
            String relationId = extraTaoBaoInfo.getRelationId();
            String taoBaoNickName = extraTaoBaoInfo.getTaoBaoNickName();
            if(!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) {
            if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) {
                clearOpenid = false;
                userInfo.setOpenid(extraTaoBaoInfo.getTaoBaoUid());
                if(!StringUtil.isNullOrEmpty(taoBaoNickName)) {
                if (!StringUtil.isNullOrEmpty(taoBaoNickName)) {
                    userInfo.setTbName(taoBaoNickName);
                } else {
                    String taoBaoUserNick = taoBaoUnionAuthRecordService.getTaoBaoUserNick(uid);
                    if(!StringUtil.isNullOrEmpty(taoBaoUserNick)) {
                    if (!StringUtil.isNullOrEmpty(taoBaoUserNick)) {
                        userInfo.setTbName(taoBaoUserNick);
                    }
                }
            }
        }
        if (clearOpenid) {
            userInfo.setOpenid(null);
        }
        return userInfo;
    }
    @Override
    public BigDecimal getBalance(Long uid) {
        UserInfo user = userInfoMapper.selectByPKey(uid);
        if (user != null)
            return user.getMyHongBao();
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ShareGoodsService.java
@@ -65,6 +65,17 @@
     */
    public TaoBaoLink getTaoBaoLinkForShare(Long uid, Long auctionId, String relationId) throws ShareGoodsException;
    /**
     * 获取商品的分享转链链接
     * @param uid
     * @param auctionId
     * @param relationId
     * @param pid
     * @return
     * @throws ShareGoodsException
     */
    public TaoBaoLink getTaoBaoLinkForShare(Long uid, Long auctionId, String relationId,String pid) throws ShareGoodsException;
    /**
     * 获取商品的购买转链链接
fanli/src/main/java/com/yeshi/fanli/service/inter/money/UserMoneyDebtService.java
@@ -31,5 +31,11 @@
     * @throws UserMoneyDebtException
     */
    public void repayDebt(UserMoneyDebt debt,BigDecimal money) throws UserMoneyDebtException;
    /**
     * 偿还
     * @param uid
     */
    public void repayDebt(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoBuyRelationMapService.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.service.inter.taobao;
import com.yeshi.fanli.exception.taobao.TaoBaoBuyRelationMapException;
public interface TaoBaoBuyRelationMapService {
    /**
     * 获取有效的渠道ID
     *
     * @param uid
     * @return
     */
    public String getRelationId(Long uid) throws TaoBaoBuyRelationMapException;
    /**
     * 根据渠道ID获取用户ID
     *
     * @param relationId
     * @return
     */
    public Long selectUidByRelationId(String relationId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoService.java
@@ -95,8 +95,6 @@
    public BigDecimal getNewPeopleHB(Long id);
    public BigDecimal getMyHB(Long id);
    /**
     * 查询用户信息  -- 用户管理列表
     * @param start
@@ -177,5 +175,13 @@
     * @return
     */
    public UserInfo getEffectiveUserInfoByWXUnionId(String unionId);
    /**
     * 获取用户余额
     * @param uid
     * @return
     */
    public BigDecimal getBalance(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/util/TaoBaoConstant.java
@@ -12,6 +12,6 @@
    public static final String TAOBAO_COMMON_APPSECRET = "bc8265e2bf8d8115329d652f9d3d4cd8";
    public static final String TAOBAO_COMMON_PID = "mm_124933865_43788020_437192946";
    // 淘宝将渠道ID处理成会员ID的pid
    public static final String TAOBAO_RELATION_AS_SPECIAL_PID = "";
    public static final String TAOBAO_RELATION_AS_SPECIAL_PID = "mm_124933865_56750082_18689550042";
}
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/money/UserMoneyDebtTypeEnumHandler.java
New file
@@ -0,0 +1,53 @@
package com.yeshi.fanli.util.mybatishandler.money;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
public class UserMoneyDebtTypeEnumHandler extends BaseTypeHandler<UserMoneyDebtTypeEnum> {
    @Override
    public UserMoneyDebtTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            return UserMoneyDebtTypeEnum.valueOf(key);
        }
    }
    @Override
    public UserMoneyDebtTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return UserMoneyDebtTypeEnum.valueOf(key);
        }
    }
    @Override
    public UserMoneyDebtTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return UserMoneyDebtTypeEnum.valueOf(key);
        }
    }
    @Override
    public void setNonNullParameter(PreparedStatement arg0, int arg1, UserMoneyDebtTypeEnum arg2, JdbcType arg3)
            throws SQLException {
        arg0.setString(arg1, arg2.name());
    }
}
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/money/UserMoneyDetailTypeEnumHandler.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -34,6 +34,25 @@
 */
public class DaTaoKeUtil {
    public static List<GoodsClass> goodsClasses;
    static {
        goodsClasses = new ArrayList<>();
        goodsClasses.add(new GoodsClass(4L, "居家日用"));
        goodsClasses.add(new GoodsClass(6L, "美食"));
        goodsClasses.add(new GoodsClass(2L, "母婴"));
        goodsClasses.add(new GoodsClass(3L, "美妆"));
        goodsClasses.add(new GoodsClass(1L, "女装"));
        goodsClasses.add(new GoodsClass(8L, "数码家电"));
        goodsClasses.add(new GoodsClass(7L, "文娱车品"));
        goodsClasses.add(new GoodsClass(10L, "内衣"));
        goodsClasses.add(new GoodsClass(14L, "家装家纺"));
        goodsClasses.add(new GoodsClass(5L, "鞋品"));
        goodsClasses.add(new GoodsClass(9L, "男装"));
        goodsClasses.add(new GoodsClass(12L, "配饰"));
        goodsClasses.add(new GoodsClass(13L, "户外运动"));
        goodsClasses.add(new GoodsClass(11L, "箱包"));
    }
    public static final String HOST = "http://dataoke.yeshitv.com";
    public static void search(String key) {
@@ -78,7 +97,7 @@
        int[] ids = new int[] { 1, 9, 10, 2, 3, 4, 5, 6, 7, 8 };
        for (int i = 0; i < names.length; i++) {
            GoodsClass gc = new GoodsClass();
            gc.setId(Long.parseLong(ids[i]+""));
            gc.setId(Long.parseLong(ids[i] + ""));
            gc.setName(names[i]);
            list.add(gc);
        }
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -760,8 +760,10 @@
        // 测试使用
        tg.setMoneyType(Math.random() > 0.5 ? 1 : 2);
        tg.setSalesType(Math.random() > 0.5 ? 1 : 2);
        tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
        List<ClientTextStyleVO> labels = new ArrayList<>();
        labels.add(new ClientTextStyleVO("标签测试内容", "#FF0000"));
        labels.add(new ClientTextStyleVO("标签测试内容1", "#FF0000"));
        labels.add(new ClientTextStyleVO("标签测试内容2", "#00FF00"));
        tg.setLabels(labels);
        return tg;
@@ -1010,8 +1012,10 @@
        // 测试使用
        tg.setMoneyType(Math.random() > 0.5 ? 1 : 2);
        tg.setSalesType(Math.random() > 0.5 ? 1 : 2);
        tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
        List<ClientTextStyleVO> labels = new ArrayList<>();
        labels.add(new ClientTextStyleVO("标签测试内容", "#FF0000"));
        labels.add(new ClientTextStyleVO("标签测试内容1", "#FF0000"));
        labels.add(new ClientTextStyleVO("标签测试内容2", "#00FF00"));
        tg.setLabels(labels);
        return tg;
pom.xml
@@ -517,6 +517,14 @@
            <version>1.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>27.0.1-jre</version>
        </dependency>
    </dependencies>
    <build>
utils/src/main/java/org/yeshi/utils/mybatis/MyBatisMapperUtil.java
@@ -55,20 +55,8 @@
        buffer.append("\n\n");
        buffer.append("import " + clz.getName() + ";");
        buffer.append("\n\n");
        buffer.append(String.format("public interface %sMapper {", clz.getSimpleName()));
        buffer.append(String.format("public interface %sMapper extends BaseMapper<%s> {", clz.getSimpleName(),clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("int deleteByPrimaryKey(Long id);"));
        buffer.append("\n\n\t");
        buffer.append(String.format("int insert(%s record);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("int insertSelective(%s record);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("%s selectByPrimaryKey(Long id);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("int updateByPrimaryKeySelective(%s record);", clz.getSimpleName()));
        buffer.append("\n\n\t");
        buffer.append(String.format("int updateByPrimaryKey(%s record);", clz.getSimpleName()));
        buffer.append("\n");
        buffer.append("}");
        String daoName = String.format("%sMapper.java", clz.getSimpleName());
        String daoPath = basePath + "/dao/" + daoName;