admin
2021-06-02 512f368d7d8e71ee72a8f71dd7d2146f4c64f774
特价相关bug修改
20个文件已修改
1个文件已添加
1971 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/LostOrderControllerV2.java 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java 1507 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/SystemFunction.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOverViews.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/lijin/manager/GoodsLijinMnager.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/lijin/manager/UserLijinMnager.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderHongBaoMoneyComputeServiceImpl.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/MsgOrderDetailServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/manger/PIDManager.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOverViewsFactory.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderGoodsVO.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/ehcache.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -176,6 +176,7 @@
        List<GoodsDetailVO> goodsDetailVOList = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO);
        int p = 0;
        for (GoodsDetailVO vo : goodsDetailVOList) {
            vo.setCreatetime(null);
            if (type == CommonContentTypeEnum.mianDan)// 免单商品
            {
                vo.getMoneyInfo().setFanliMoney("¥" + TaoBaoUtil.getCouponPrice(goodsList.get(p)));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -151,7 +151,6 @@
    private CommonShareInfoService commonShareInfoService;
    @Resource
    private PIDManager pidManager;
@@ -678,8 +677,16 @@
                        List<ImgInfo> listInfoNew = new ArrayList<ImgInfo>();
                        for (ImgInfo imgInfo : goodsEvaluate.getImgList()) {
                            if (acceptData.getSystem() == SystemEnum.yhqjx) {
                                imgInfo.setGoods(null);
                                imgInfo.setGoodsVO(null);
                            }
                            if (imgInfo.getType() != ImgEnum.activity) {
                                listInfoNew.add(imgInfo);
                                continue;
                            }
                            ImgInfo infoNew = new ImgInfo();
@@ -999,7 +1006,7 @@
        if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
            TaoBaoLink taoBaoLink = null;
            try {
                taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system,user.getId(), Long.parseLong(goodsVO.getGoodsId()),
                taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, user.getId(), Long.parseLong(goodsVO.getGoodsId()),
                        relationId, null);
            } catch (TaoBaoConvertLinkException e) {
                e.printStackTrace();
@@ -1019,7 +1026,7 @@
                couponUrl = couponInfo.getLink();
            }
            String materialId = "https://item.jd.com/" + goodsVO.getGoodsId() + ".html";
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,  pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share),
            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share),
                    user.getId() + "");
        } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsVO.getGoodsId()));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -413,6 +413,9 @@
        TaoBaoGoodsBrief tb = goods;
        //创建时间设置为空,防止前端用long解析
        tb.setCreatetime(null);
        if (tb == null) {
            out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/LostOrderControllerV2.java
New file
@@ -0,0 +1,121 @@
package com.yeshi.fanli.controller.client.v2;
import com.google.gson.Gson;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.Utils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.NumberUtil;
import org.yeshi.utils.TimeUtil;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.util.List;
/**
 * 动态
 *
 * @author Administrator
 *
 */
@Controller
@RequestMapping("api/v2/lostOrder")
public class LostOrderControllerV2 {
    @Resource
    private LostOrderService lostOrderService;
    @Resource
    private ConfigService configService;
    @RequestMapping("findLostOrder")
    public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, HttpServletRequest request, PrintWriter out) {
        Integer type = lostOrder.getType();
        if (type == null) {
            type = Constant.SOURCE_TYPE_TAOBAO;
        }
        boolean orderNum = true;
        String orderId = lostOrder.getOrderId();
        if (type == Constant.SOURCE_TYPE_TAOBAO) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 12 || orderId.length() > 20)) {
                orderNum = false;
            } else {
                orderNum = Utils.isOrderNum(orderId);
            }
        } else if (type == Constant.SOURCE_TYPE_JD) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 6 || orderId.length() > 20)) {
                orderNum = false;
            }
        } else if (type == Constant.SOURCE_TYPE_PDD) {
            if (!orderId.contains("-")) {
                orderNum = false;
            } else {
                String[] split = orderId.split("-");
                if (split == null || split.length != 2) {
                    orderNum = false;
                } else {
                    if (!NumberUtil.isNumeric(split[0]) || !NumberUtil.isNumeric(split[1])) {
                        orderNum = false;
                    }
                }
            }
        } else if (type == Constant.SOURCE_TYPE_VIP) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 10 || orderId.length() > 18)) {
                orderNum = false;
            }
        } else if (type == Constant.SOURCE_TYPE_SUNING) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 10 || orderId.length() > 15)) {
                orderNum = false;
            }
        }
        if (lostOrder.getUserInfo() == null || lostOrder.getUserInfo().getId() == null
                || lostOrder.getUserInfo().getId() <= 0) {
            out.print(JsonUtil.loadFalseResult(1,
                    String.format("请登录%s账号", Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))));
            return;
        }
        lostOrder.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort());
        int state;
        String stateInfo = "提交成功,请等待审核结果";
        if (!orderNum) {
            state = -4;
            stateInfo = "请提交准确的订单号";
        } else {
            lostOrder.setResultCode(LostOrder.RESULT_CODE_VERFING);
            state = lostOrderService.addLostOrder(lostOrder);
            if (state == -3) {
                stateInfo = "该订单已被统计,无需申诉";
            } else if (state == -2) {
                stateInfo = "请勿重复提交,该订单正在审核中";
            } else if (state == -1) {
                stateInfo = "该订单申诉已通过,请在订单列表中查看";
            } else if (state == -5) {
                stateInfo = "分享奖金订单无需申诉";
            } else if (state == -6) {
                stateInfo = "该订单申诉已失败,请在订单列表中查看";
            } else if (state == -7) {
                stateInfo = "今日申诉次数已达上限";
            } else if (state == -1001) {
                stateInfo = "订单违规";
            }
        }
        JSONObject data = new JSONObject();
        data.put("state", state);
        data.put("info", stateInfo);
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -1913,6 +1913,7 @@
            dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
            GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
            detailVO.setCreatetime(null);
            detailVO.setId(commonGoods.getId());
            dataObject.put("goods", gson.toJson(detailVO));
            array.add(dataObject);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java
@@ -12,6 +12,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -88,848 +89,856 @@
@RequestMapping("api/v2/user/order")
public class UserOrderControllerV2 {
    @Resource
    private ConfigService configService;
    @Resource
    private ConfigService configService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private CommonOrderService commonOrderService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Resource
    private UserCustomSettingsService userCustomSettingsService;
    @Resource
    private ESOrderService esOrderService;
    @Resource
    private ESOrderService esOrderService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    @Resource
    private CommonOrderGoodsService commonOrderGoodsService;
    @Resource
    private CommonOrderGoodsService commonOrderGoodsService;
    @Resource
    private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
    @Resource
    private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Resource
    private UserInviteService userInviteService;
    @Resource
    private UserInviteService userInviteService;
    @Resource
    private OrderHongBaoMapService orderHongBaoMapService;
    @Resource
    private OrderHongBaoMapService orderHongBaoMapService;
    @Resource
    private PreviewInfoService previewInfoService;
    @Resource
    private PreviewInfoService previewInfoService;
    @Resource
    private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService;
    @Resource
    private TeamDividentsSourceOrderUserMapService teamDividentsSourceOrderUserMapService;
    @Resource
    private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
    @Resource
    private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
    @Resource
    private ThreeSaleDetailService threeSaleDetailService;
    @Resource
    private ThreeSaleDetailService threeSaleDetailService;
    /**
     * 处理搜索条件
     *
     * @param filter
     */
    private void handleSearchFilter(SearchFilterOrder filter) {
        Integer goodsType = filter.getGoodsType();
        if (goodsType != null && goodsType == 0) {
            goodsType = null;
            filter.setGoodsType(goodsType);
        }
    /**
     * 处理搜索条件
     *
     * @param filter
     */
    private void handleSearchFilter(SearchFilterOrder filter) {
        Integer goodsType = filter.getGoodsType();
        if (goodsType != null && goodsType == 0) {
            goodsType = null;
            filter.setGoodsType(goodsType);
        }
        List<Integer> listSource = new ArrayList<>();
        if (goodsType != null) {
            listSource.add(goodsType);
        }
        filter.setListSource(listSource);
        List<Integer> listSource = new ArrayList<>();
        if (goodsType != null) {
            listSource.add(goodsType);
        }
        filter.setListSource(listSource);
        // 订单类型
        String type = filter.getType();
        Integer orderType = null;
        if (StringUtil.isNullOrEmpty(type)) {
            orderType = null;
        } else if (!"0".equalsIgnoreCase(type)) {
            orderType = Integer.parseInt(type);
        }
        filter.setOrderType(orderType);
        // 订单类型
        String type = filter.getType();
        Integer orderType = null;
        if (StringUtil.isNullOrEmpty(type)) {
            orderType = null;
        } else if (!"0".equalsIgnoreCase(type)) {
            orderType = Integer.parseInt(type);
        }
        filter.setOrderType(orderType);
        // 转换状态
        Integer orderState = filter.getOrderState();
        Integer state = filter.getState();
        if (state != null) {
            if (state == 0) {
                state = null; // 所有
            } else if (state == 4) {
                state = null;
                orderState = 4; // 已收货
            } else if (state == 5) {
                state = null;
                orderState = 2; // 已维权
            }
        }
        if (state != null && orderState != null && (orderState == 2 || orderState == 3)) {
            state = null;
        }
        filter.setState(state);
        filter.setOrderState(orderState);
        // 转换状态
        Integer orderState = filter.getOrderState();
        Integer state = filter.getState();
        if (state != null) {
            if (state == 0) {
                state = null; // 所有
            } else if (state == 4) {
                state = null;
                orderState = 4; // 已收货
            } else if (state == 5) {
                state = null;
                orderState = 2; // 已维权
            }
        }
        if (state != null && orderState != null && (orderState == 2 || orderState == 3)) {
            state = null;
        }
        filter.setState(state);
        filter.setOrderState(orderState);
        // 筛选时间
        Integer dateType = filter.getDateType();
        String startTime = filter.getStartTime();
        String endTime = filter.getEndTime();
        Integer slotTime = filter.getSlotTime();
        if (slotTime != null) {
            try {
                SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
        // 筛选时间
        Integer dateType = filter.getDateType();
        String startTime = filter.getStartTime();
        String endTime = filter.getEndTime();
        Integer slotTime = filter.getSlotTime();
        if (slotTime != null) {
            try {
                SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
                switch (slotTime) {
                case 1: // 最近三天
                    endTime = sd.format(new Date());
                    startTime = DateUtil.reduceDay(2, endTime);
                    break;
                case 2: // 最近七天
                    endTime = sd.format(new Date());
                    startTime = DateUtil.reduceDay(6, endTime);
                    break;
                case 3: // 最近15天 (半月)
                    endTime = sd.format(new Date());
                    startTime = DateUtil.reduceDay(14, endTime);
                    break;
                case 4: // 最近三十天 (本月)
                    dateType = 10;
                    break;
                case 5: // 最近九十天(近三月)
                    dateType = 11;
                    break;
                case 6: // 最近一百八十天(近半年)
                    dateType = 12;
                    break;
                default:
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        filter.setDateType(dateType);
        filter.setStartTime(startTime);
                switch (slotTime) {
                    case 1: // 最近三天
                        endTime = sd.format(new Date());
                        startTime = DateUtil.reduceDay(2, endTime);
                        break;
                    case 2: // 最近七天
                        endTime = sd.format(new Date());
                        startTime = DateUtil.reduceDay(6, endTime);
                        break;
                    case 3: // 最近15天 (半月)
                        endTime = sd.format(new Date());
                        startTime = DateUtil.reduceDay(14, endTime);
                        break;
                    case 4: // 最近三十天 (本月)
                        dateType = 10;
                        break;
                    case 5: // 最近九十天(近三月)
                        dateType = 11;
                        break;
                    case 6: // 最近一百八十天(近半年)
                        dateType = 12;
                        break;
                    default:
                        break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        filter.setDateType(dateType);
        filter.setStartTime(startTime);
        if (endTime != null && endTime.trim().length() > 0) {
            endTime += " 23:59:59";
        }
        filter.setEndTime(endTime);
        if (endTime != null && endTime.trim().length() > 0) {
            endTime += " 23:59:59";
        }
        filter.setEndTime(endTime);
    }
    }
    /**
     * 订单列表
     * @param acceptData
     * @param page
     * @param filter
     * @param out
     */
    @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
    public void getOrderList(AcceptData acceptData, Integer page, SearchFilterOrder filter, PrintWriter out) {
        Long uid = filter.getUid();
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
    /**
     * 订单列表
     *
     * @param acceptData
     * @param page
     * @param filter
     * @param out
     */
    @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
    public void getOrderList(AcceptData acceptData, Integer page, SearchFilterOrder filter, PrintWriter out) {
        Long uid = filter.getUid();
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (page == null || page < 1)
            page = 1;
        if (page == null || page < 1)
            page = 1;
        handleSearchFilter(filter);
        String startTime = filter.getStartTime();
        String endTime = filter.getEndTime();
        Integer orderType = filter.getOrderType();
        Integer dateType = filter.getDateType();
        Integer state = filter.getState();
        List<Integer> listSource = filter.getListSource();
        Integer orderState = filter.getOrderState();
        handleSearchFilter(filter);
        String startTime = filter.getStartTime();
        String endTime = filter.getEndTime();
        Integer orderType = filter.getOrderType();
        Integer dateType = filter.getDateType();
        Integer state = filter.getState();
        List<Integer> listSource = filter.getListSource();
        Integer orderState = filter.getOrderState();
        try {
            if (!VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
                if (listSource.size() == 0) {
                    listSource.add(Constant.SOURCE_TYPE_TAOBAO);
                    listSource.add(Constant.SOURCE_TYPE_JD);
                    listSource.add(Constant.SOURCE_TYPE_PDD);
                }
            }
            // 搜索内容、订单号
            String orderNo = filter.getOrderNo();
            if (!StringUtil.isNullOrEmpty(orderNo)
                    && VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) {
                searchOrder(acceptData, orderNo, page, uid, listSource, out);
                return;
            }
        try {
            if (!VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
                if (listSource.size() == 0) {
                    listSource.add(Constant.SOURCE_TYPE_TAOBAO);
                    listSource.add(Constant.SOURCE_TYPE_JD);
                    listSource.add(Constant.SOURCE_TYPE_PDD);
                }
            }
            // 筛选结果顶部统计
            String validMoney = "0.00";
            String invalidMoney = "0.00";
            if (page == 1) {
                BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
                        orderType, 1, orderNo, state, startTime, endTime, listSource);
                if (predictMoney != null)
                    validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
            // 搜索内容、订单号
            String orderNo = filter.getOrderNo();
            if (!StringUtil.isNullOrEmpty(orderNo)
                    && VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) {
                searchOrder(acceptData, orderNo, page, uid, listSource, out);
                return;
            }
                BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
                        orderType, 2, orderNo, state, startTime, endTime, listSource);
                if (postSaleMoney != null)
                    invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
            // 筛选结果顶部统计
            String validMoney = "0.00";
            String invalidMoney = "0.00";
            if (page == 1) {
                BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
                        orderType, 1, orderNo, state, startTime, endTime, listSource);
                if (predictMoney != null)
                    validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
                if (orderType != null && dateType != null && dateType == 4) {
                    if (orderType == 1) {
                        dateType = 6; // 返利订单有效
                    } else {
                        dateType = 5; // 新版查询本月到账
                    }
                }
            }
                BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, filter.getDateType(),
                        orderType, 2, orderNo, state, startTime, endTime, listSource);
                if (postSaleMoney != null)
                    invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
            long count = 0L;
            List<CommonOrderVO> list = null;
            if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
                list = commonOrderService.getOrderList(acceptData, page, uid, state, orderType, orderState, orderNo,
                        startTime, endTime, dateType, listSource);
                if (orderType != null && dateType != null && dateType == 4) {
                    if (orderType == 1) {
                        dateType = 6; // 返利订单有效
                    } else {
                        dateType = 5; // 新版查询本月到账
                    }
                }
            }
                count = commonOrderService.countOrderList(uid, state, orderType, orderState, orderNo, startTime,
                        endTime, dateType, listSource);
            } else {
                list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState, orderNo,
                        startTime, endTime, dateType, listSource);
                count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
                        endTime, dateType, listSource);
            }
            long count = 0L;
            List<CommonOrderVO> list = null;
            if (acceptData.getSystem() == SystemEnum.yhqjx) {
                list = commonOrderService.getOrderList(acceptData, page, uid, state, orderType, orderState, orderNo,
                        startTime, endTime, dateType, listSource);
                count = commonOrderService.countOrderList(uid, state, orderType, orderState, orderNo, startTime,
                        endTime, dateType, listSource);
            } else {
                if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
                    list = commonOrderService.getOrderList(acceptData, page, uid, state, orderType, orderState, orderNo,
                            startTime, endTime, dateType, listSource);
            // 判断是否需要显示订单找回提示 8秒内请求3次触发
            String orderFindUrl = null;
            if (state == null && page == 1) {
                if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4) || count == 0L) {
                    orderFindUrl = configService.getValue(ConfigKeyEnum.orderFindNotifyUrl.getKey(),acceptData.getSystem());
                }
            }
                    count = commonOrderService.countOrderList(uid, state, orderType, orderState, orderNo, startTime,
                            endTime, dateType, listSource);
                } else {
                    list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState, orderNo,
                            startTime, endTime, dateType, listSource);
                    count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
                            endTime, dateType, listSource);
                }
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
            data.put("helpUrl", configService.getValue(ConfigKeyEnum.orderListHelp.getKey(),acceptData.getSystem()));
            data.put("validMoney", "¥ " + validMoney);
            data.put("invalidMoney", "¥ " + invalidMoney);
            data.put("findOrderHelpUrl", orderFindUrl);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (CommonOrderException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
            // 判断是否需要显示订单找回提示 8秒内请求3次触发
            String orderFindUrl = null;
            if (state == null && page == 1) {
                if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4) || count == 0L) {
                    orderFindUrl = configService.getValue(ConfigKeyEnum.orderFindNotifyUrl.getKey(), acceptData.getSystem());
                }
            }
    /**
     * 搜索订单
     *
     * @param key
     * @param out
     */
    private void searchOrder(AcceptData acceptData, String key, Integer page, Long uid, List<Integer> listSource, PrintWriter out) {
        try {
            long count = 0;
            List<CommonOrderVO> list = null;
            if (NumberUtil.isNumeric(key.replace("-", ""))) {
                if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
                    list =    commonOrderService.getOrderList(acceptData, page, uid, null, null, null, key, null, null, null,listSource);
                } else
                    list = commonOrderService.getOrderByUid(acceptData, page, uid, null, null, null, key, null, null, null, listSource);
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
            data.put("helpUrl", configService.getValue(ConfigKeyEnum.orderListHelp.getKey(), acceptData.getSystem()));
            data.put("validMoney", "¥ " + validMoney);
            data.put("invalidMoney", "¥ " + invalidMoney);
            data.put("findOrderHelpUrl", orderFindUrl);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (CommonOrderException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
            LogHelper.errorDetailInfo(e);
        }
    }
            if (list == null || list.size() == 0) {
                List<ESOrder> listES = esOrderService.query(key, uid.toString(), null);
                if (listES.size() != 0) {
                    list = commonOrderService.searchOrderByUid(acceptData, page, Constant.PAGE_SIZE, uid, listES);
                    count = commonOrderService.countSearchOrderByUid(uid, listES);
                }
            } else {
                count = list.size();
            }
    /**
     * 搜索订单
     *
     * @param key
     * @param out
     */
    private void searchOrder(AcceptData acceptData, String key, Integer page, Long uid, List<Integer> listSource, PrintWriter out) {
        try {
            long count = 0;
            List<CommonOrderVO> list = null;
            if (NumberUtil.isNumeric(key.replace("-", ""))) {
                if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
                    list = commonOrderService.getOrderList(acceptData, page, uid, null, null, null, key, null, null, null, listSource);
                } else
                    list = commonOrderService.getOrderByUid(acceptData, page, uid, null, null, null, key, null, null, null, listSource);
            }
            if (list == null) {
                list = new ArrayList<>();
            }
            if (list == null || list.size() == 0) {
                List<ESOrder> listES = esOrderService.query(key, uid.toString(), null);
                if (listES.size() != 0) {
                    list = commonOrderService.searchOrderByUid(acceptData, page, Constant.PAGE_SIZE, uid, listES);
                    count = commonOrderService.countSearchOrderByUid(uid, listES);
                }
            } else {
                count = list.size();
            }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
            e.printStackTrace();
            LogHelper.errorDetailInfo(e);
        }
    }
            if (list == null) {
                list = new ArrayList<>();
            }
    /**
     * 用户订单统计
     *
     * @param acceptData
     * @param uid        用户id type 类型:0全部、1淘宝 2京东、拼多多
     * @param out
     */
    @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
    public void getOrderCount(AcceptData acceptData, Long uid, Integer type, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "请求参数不正确"));
            return;
        }
            JSONObject data = new JSONObject();
            data.put("count", count);
            data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "查询失败"));
            e.printStackTrace();
            LogHelper.errorDetailInfo(e);
        }
    }
        try {
            UserInfo user = userInfoService.selectByPKey(uid);
            if (user == null) {
                out.print(JsonUtil.loadFalseResult(1, "用户不存在"));
                return;
            }
    /**
     * 用户订单统计
     *
     * @param acceptData
     * @param uid        用户id type 类型:0全部、1淘宝 2京东、拼多多
     * @param out
     */
    @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
    public void getOrderCount(AcceptData acceptData, Long uid, Integer type, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "请求参数不正确"));
            return;
        }
            UserInfo userInfo = UserUtil.filterForClientUser(user);
            UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
            if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
                userInfo.setRankIcon(userInfoExtra.getUserRank().getIcon());
                userInfo.setRankNamePicture(userInfoExtra.getUserRank().getPicture());
            }
            JSONObject data = new JSONObject();
            data.put("userInfo", userInfo);
        try {
            UserInfo user = userInfoService.selectByPKey(uid);
            if (user == null) {
                out.print(JsonUtil.loadFalseResult(1, "用户不存在"));
                return;
            }
            List<Integer> listSource = new ArrayList<>();
            if (type == null || type == 0) {
                OrderCountVO total = commonOrderService.getOrderCount(uid, null, null);
                data.put("total", total.getSelf() + total.getShared() + total.getInvite());
                data.put("self", total.getSelf());
                data.put("shared", total.getShared());
                data.put("invite", total.getInvite());
            } else {
                data.put("total", 0);
                data.put("self", 0);
                data.put("shared", 0);
                data.put("invite", 0);
            UserInfo userInfo = UserUtil.filterForClientUser(user);
            UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
            if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
                userInfo.setRankIcon(userInfoExtra.getUserRank().getIcon());
                userInfo.setRankNamePicture(userInfoExtra.getUserRank().getPicture());
            }
            JSONObject data = new JSONObject();
            data.put("userInfo", userInfo);
                listSource.add(type);
            }
            List<Integer> listSource = new ArrayList<>();
            if (type == null || type == 0) {
                OrderCountVO total = commonOrderService.getOrderCount(uid, null, null);
                data.put("total", total.getSelf() + total.getShared() + total.getInvite());
                data.put("self", total.getSelf());
                data.put("shared", total.getShared());
                data.put("invite", total.getInvite());
            } else {
                data.put("total", 0);
                data.put("self", 0);
                data.put("shared", 0);
                data.put("invite", 0);
            // 今天
            OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
            today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
            // 昨天
            OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource);
            yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite());
            // 本月
            OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource);
            thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite());
            // 上月
            OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource);
            lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite());
                listSource.add(type);
            }
            data.put("today", today);
            data.put("yesterday", yesterday);
            data.put("thisMonth", thisMonth);
            data.put("lastMonth", lastMonth);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "获取信息失败"));
            e.printStackTrace();
        }
    }
            // 今天
            OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
            today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
            // 昨天
            OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource);
            yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite());
            // 本月
            OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource);
            thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite());
            // 上月
            OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource);
            lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite());
    /**
     * 统计奖金
     *
     * @param acceptData
     * @param uid
     * @param dateType   1-今日 2-昨天 3-本月 4-上个月
     * @param out
     */
    @RequestMapping(value = "getBonusCount", method = RequestMethod.POST)
    public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
            data.put("today", today);
            data.put("yesterday", yesterday);
            data.put("thisMonth", thisMonth);
            data.put("lastMonth", lastMonth);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult(1, "获取信息失败"));
            e.printStackTrace();
        }
    }
        boolean show = false;
        UserSettingsVO settings = null;
        try {
            settings = userCustomSettingsService.getMySettings(uid);
        } catch (Exception e) {
        }
    /**
     * 统计奖金
     *
     * @param acceptData
     * @param uid
     * @param dateType   1-今日 2-昨天 3-本月 4-上个月
     * @param out
     */
    @RequestMapping(value = "getBonusCount", method = RequestMethod.POST)
    public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
        if (uid == null) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        // 验证是否显示模块
        if (settings != null && settings.getNoBonusCount() != null) {
            if (settings.getNoBonusCount() == 1) {
                show = false;
            } else if (settings.getNoBonusCount() == 0) {
                show = true;
            }
        } else {
            show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
        }
        boolean show = false;
        UserSettingsVO settings = null;
        try {
            settings = userCustomSettingsService.getMySettings(uid);
        } catch (Exception e) {
        }
        BigDecimal selfMoney = null;
        BigDecimal shareMoney = null;
        BigDecimal teamMoney = null;
        // VIP预览信息
        if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
            String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo);
            if (!StringUtil.isNullOrEmpty(redisContent)) {
                MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class);
                if (vo != null) {
                    if (!StringUtil.isNullOrEmpty(vo.getSelfRebate()))
                        selfMoney = new BigDecimal(vo.getSelfRebate());
                    if (!StringUtil.isNullOrEmpty(vo.getShareBonus()))
                        shareMoney = new BigDecimal(vo.getShareBonus());
                    if (!StringUtil.isNullOrEmpty(vo.getTeamBonus()))
                        teamMoney = new BigDecimal(vo.getTeamBonus());
                }
            }
        }
        // 验证是否显示模块
        if (settings != null && settings.getNoBonusCount() != null) {
            if (settings.getNoBonusCount() == 1) {
                show = false;
            } else if (settings.getNoBonusCount() == 0) {
                show = true;
            }
        } else {
            show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
        }
        BigDecimal selfMoney = null;
        BigDecimal shareMoney = null;
        BigDecimal teamMoney = null;
        // VIP预览信息
        if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
            String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo);
            if (!StringUtil.isNullOrEmpty(redisContent)) {
                MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class);
                if (vo != null) {
                    if (!StringUtil.isNullOrEmpty(vo.getSelfRebate()))
                        selfMoney = new BigDecimal(vo.getSelfRebate());
                    if (!StringUtil.isNullOrEmpty(vo.getShareBonus()))
                        shareMoney = new BigDecimal(vo.getShareBonus());
                    if (!StringUtil.isNullOrEmpty(vo.getTeamBonus()))
                        teamMoney = new BigDecimal(vo.getTeamBonus());
                }
            }
        }
        if (selfMoney == null) {
            selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
            shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
            teamMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
        }
        if (selfMoney == null) {
            selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
            shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
            teamMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
        }
        JSONObject data = new JSONObject();
        data.put("show", show);
        data.put("selfMoney", selfMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        data.put("shareMoney", shareMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        data.put("inviteMoney", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        out.print(JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("show", show);
        data.put("selfMoney", selfMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        data.put("shareMoney", shareMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        data.put("inviteMoney", teamMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 返利说明
     *
     * @param acceptData
     * @param uid
     * @param orderNo
     * @param sourceType
     * @param out
     */
    @RequestMapping(value = "getReBateInfo")
    public void getReBateInfo(String callback, AcceptData acceptData, Long uid, String orderNo, Integer sourceType,
            PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
    /**
     * 返利说明
     *
     * @param acceptData
     * @param uid
     * @param orderNo
     * @param sourceType
     * @param out
     */
    @RequestMapping(value = "getReBateInfo")
    public void getReBateInfo(String callback, AcceptData acceptData, Long uid, String orderNo, Integer sourceType,
                              PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
            return;
        }
        UserInfo user = userInfoService.selectByPKey(uid);
        if (user == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        UserInfo user = userInfoService.selectByPKey(uid);
        if (user == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
        // 红包信息
        List<HongBaoOrder> hoList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType,
                uid);
        HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hoList);
        // 红包信息
        List<HongBaoOrder> hoList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType,
                uid);
        HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hoList);
        Integer hongBaoState = hongBaoCountVO.getCurrentState();
        String stateDesc = "";
        String predictDesc = "";
        if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
            stateDesc = "未到账";
            predictDesc = "预估";
        } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
            stateDesc = "已到账";
        } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
            stateDesc = "已失效";
        }
        Integer hongBaoState = hongBaoCountVO.getCurrentState();
        String stateDesc = "";
        String predictDesc = "";
        if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
            stateDesc = "未到账";
            predictDesc = "预估";
        } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
            stateDesc = "已到账";
        } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
            stateDesc = "已失效";
        }
        int type = 0;
        String typeName = "";
        int hongBaoType = hoList.get(0).getHongBaoV2().getType();
        if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            type = 1;
            typeName = "返利";
        } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
            type = 2;
            typeName = "奖金";
        } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType
                || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                || HongBaoV2.TYPE_ERJI == hongBaoType) {
            type = 3;
            typeName = "收益";
        }
        int type = 0;
        String typeName = "";
        int hongBaoType = hoList.get(0).getHongBaoV2().getType();
        if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            type = 1;
            typeName = "返利";
        } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
            type = 2;
            typeName = "奖金";
        } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType
                || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                || HongBaoV2.TYPE_ERJI == hongBaoType) {
            type = 3;
            typeName = "收益";
        }
        List<Long> goodsIdList = new ArrayList<>();
        if (hoList != null)
            for (HongBaoOrder hongBaoOrder : hoList) {
                if (hongBaoOrder.getCommonOrder() != null)
                    goodsIdList.add(hongBaoOrder.getCommonOrder().getCommonOrderGoods().getId());
            }
        List<Long> goodsIdList = new ArrayList<>();
        if (hoList != null)
            for (HongBaoOrder hongBaoOrder : hoList) {
                if (hongBaoOrder.getCommonOrder() != null)
                    goodsIdList.add(hongBaoOrder.getCommonOrder().getCommonOrderGoods().getId());
            }
        Map<Long, CommonOrderGoods> orderGoodsMap = new HashMap<>();
        List<CommonOrderGoods> goodsList = commonOrderGoodsService.listByByPrimaryKeys(goodsIdList);
        if (goodsList != null)
            for (CommonOrderGoods goods : goodsList)
                orderGoodsMap.put(goods.getId(), goods);
        Map<Long, CommonOrderGoods> orderGoodsMap = new HashMap<>();
        List<CommonOrderGoods> goodsList = commonOrderGoodsService.listByByPrimaryKeys(goodsIdList);
        if (goodsList != null)
            for (CommonOrderGoods goods : goodsList)
                orderGoodsMap.put(goods.getId(), goods);
        OrderRebateVO orderRebateVO = new OrderRebateVO();
        // 红包信息
        BigDecimal hongBao = hongBaoCountVO.getValidMoney();
        if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderNo);
            if (listWQ != null && listWQ.size() > 0) {
                BigDecimal weiQuanMoney = commonOrderService.getWeiQuanMoney(listWQ, sourceType, uid);
        OrderRebateVO orderRebateVO = new OrderRebateVO();
        // 红包信息
        BigDecimal hongBao = hongBaoCountVO.getValidMoney();
        if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderNo);
            if (listWQ != null && listWQ.size() > 0) {
                BigDecimal weiQuanMoney = commonOrderService.getWeiQuanMoney(listWQ, sourceType, uid);
                orderRebateVO.setWq(true);
                orderRebateVO.setWqMoney("¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN));
                if (hongBao.compareTo(weiQuanMoney) > 0) {
                    orderRebateVO.setWqDesc("部分售后退回");
                } else {
                    orderRebateVO.setWqDesc("售后退回");
                }
                // 计算剩余红包
                hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
            }
        }
                orderRebateVO.setWq(true);
                orderRebateVO.setWqMoney("¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN));
                if (hongBao.compareTo(weiQuanMoney) > 0) {
                    orderRebateVO.setWqDesc("部分售后退回");
                } else {
                    orderRebateVO.setWqDesc("售后退回");
                }
                // 计算剩余红包
                hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
            }
        }
        // 红包获得者
        HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2();
        UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank());
        if (userLevel == null)
            userLevel = UserLevelEnum.daRen;
        UserLevelEnum upperLevel = UserLevelEnum.superVIP;
        // 红包获得者
        HongBaoV2 hongBaoV2 = hoList.get(0).getHongBaoV2();
        UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(hongBaoV2.getUrank());
        if (userLevel == null)
            userLevel = UserLevelEnum.daRen;
        UserLevelEnum upperLevel = UserLevelEnum.superVIP;
        // 订单购买者
        CommonOrder commonOrder1 = hoList.get(0).getCommonOrder();
        Date downTime = commonOrder1.getThirdCreateTime();
        UserLevelEnum buyer = UserLevelUtil.getByOrderRank(commonOrder1.getUrank());
        if (buyer == null) {
            buyer = UserLevelEnum.daRen;
        }
        // 订单购买者
        CommonOrder commonOrder1 = hoList.get(0).getCommonOrder();
        Date downTime = commonOrder1.getThirdCreateTime();
        UserLevelEnum buyer = UserLevelUtil.getByOrderRank(commonOrder1.getUrank());
        if (buyer == null) {
            buyer = UserLevelEnum.daRen;
        }
        BigDecimal upperTotalMoney = new BigDecimal(0);
        List<GoodsRebateVO> voList = new ArrayList<>();
        for (HongBaoOrder hongBaoOrder : hoList) {
            if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_SHIXIAO)
                hongBaoOrder.getHongBaoV2().setMoney(new BigDecimal(0));
        BigDecimal upperTotalMoney = new BigDecimal(0);
        List<GoodsRebateVO> voList = new ArrayList<>();
        for (HongBaoOrder hongBaoOrder : hoList) {
            if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_SHIXIAO)
                hongBaoOrder.getHongBaoV2().setMoney(new BigDecimal(0));
            GoodsRebateVO goodsVO = new GoodsRebateVO();
            GoodsRebateVO goodsVO = new GoodsRebateVO();
            // 标题、图片
            CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
            if (orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()) != null) {
                goodsVO.setTitle(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getTitle());
                goodsVO.setPicture(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getPicture());
            }
            // 标题、图片
            CommonOrder commonOrder = hongBaoOrder.getCommonOrder();
            if (orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()) != null) {
                goodsVO.setTitle(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getTitle());
                goodsVO.setPicture(orderGoodsMap.get(commonOrder.getCommonOrderGoods().getId()).getPicture());
            }
            // 实付款
            BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
            // 若已结算 -显示结算金额
            Integer orderState = hongBaoOrder.getCommonOrder().getState();
            if (hongBaoOrder.getCommonOrder().getSettlement() != null
                    && (orderState == CommonOrder.STATE_JS || orderState == CommonOrder.STATE_WQ))
                payment = hongBaoOrder.getCommonOrder().getSettlement();
            if (payment == null)
                payment = new BigDecimal(0);
            goodsVO.setActualPay("¥" + payment.setScale(2, BigDecimal.ROUND_DOWN));
            // 实付款
            BigDecimal payment = hongBaoOrder.getCommonOrder().getPayment();
            // 若已结算 -显示结算金额
            Integer orderState = hongBaoOrder.getCommonOrder().getState();
            if (hongBaoOrder.getCommonOrder().getSettlement() != null
                    && (orderState == CommonOrder.STATE_JS || orderState == CommonOrder.STATE_WQ))
                payment = hongBaoOrder.getCommonOrder().getSettlement();
            if (payment == null)
                payment = new BigDecimal(0);
            goodsVO.setActualPay("¥" + payment.setScale(2, BigDecimal.ROUND_DOWN));
            BigDecimal fanli = hongBaoOrder.getHongBaoV2().getMoney();
            // 基础佣金
            BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
            goodsVO.setCommision("¥" + commission.setScale(2, BigDecimal.ROUND_DOWN));
            BigDecimal fanli = hongBaoOrder.getHongBaoV2().getMoney();
            // 基础佣金
            BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
            goodsVO.setCommision("¥" + commission.setScale(2, BigDecimal.ROUND_DOWN));
            // 平台补贴 = 返利 - 基础佣金
            goodsVO.setSubsidy("¥" + fanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN));
            // 达人补贴
            if (userLevel != UserLevelEnum.daRen) {
                BigDecimal darenFanli = orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder,
                        UserLevelEnum.daRen);
                goodsVO.setOriginSubsidy("¥" + darenFanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN) + "");
            }
            // 平台补贴 = 返利 - 基础佣金
            goodsVO.setSubsidy("¥" + fanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN));
            // 达人补贴
            if (userLevel != UserLevelEnum.daRen) {
                BigDecimal darenFanli = orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder,
                        UserLevelEnum.daRen);
                goodsVO.setOriginSubsidy("¥" + darenFanli.subtract(commission).setScale(2, BigDecimal.ROUND_DOWN) + "");
            }
            if (type == 3) { // 奖金
                goodsVO.setBonus("¥" + fanli.setScale(2, BigDecimal.ROUND_DOWN) + "");
            }
            if (type == 3) { // 奖金
                goodsVO.setBonus("¥" + fanli.setScale(2, BigDecimal.ROUND_DOWN) + "");
            }
            voList.add(goodsVO);
            voList.add(goodsVO);
            if (type == 1) {
                upperTotalMoney = upperTotalMoney
                        .add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
            } else if (type == 2) {
                upperTotalMoney = upperTotalMoney
                        .add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel));
            } else if (type == 3) {
                List<UserTeamLevel> bossLevelList = new ArrayList<>();
                if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
                    bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
                    upperTotalMoney = upperTotalMoney.add(
                            orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyer, bossLevelList));
                } else {
                    Integer bRank = hongBaoV2Service
                            .getDirectBossUrankByPid(hongBaoOrder.getHongBaoV2().getParent().getId());
                    UserLevelEnum directBoss = UserLevelUtil.getByOrderRank(bRank);
                    if (directBoss == null) {
                        directBoss = UserLevelEnum.daRen;
                    }
                    bossLevelList.add(new UserTeamLevel(null, directBoss));
                    bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
                    upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService
                            .computeSecondInviteMoney(commonOrder, buyer, bossLevelList));
                }
            }
        }
            if (type == 1) {
                upperTotalMoney = upperTotalMoney
                        .add(orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, upperLevel));
            } else if (type == 2) {
                upperTotalMoney = upperTotalMoney
                        .add(orderHongBaoMoneyComputeService.computeShareMoney(commonOrder, upperLevel));
            } else if (type == 3) {
                List<UserTeamLevel> bossLevelList = new ArrayList<>();
                if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
                    bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
                    upperTotalMoney = upperTotalMoney.add(
                            orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyer, bossLevelList));
                } else {
                    Integer bRank = hongBaoV2Service
                            .getDirectBossUrankByPid(hongBaoOrder.getHongBaoV2().getParent().getId());
                    UserLevelEnum directBoss = UserLevelUtil.getByOrderRank(bRank);
                    if (directBoss == null) {
                        directBoss = UserLevelEnum.daRen;
                    }
                    bossLevelList.add(new UserTeamLevel(null, directBoss));
                    bossLevelList.add(new UserTeamLevel(null, UserLevelEnum.superVIP));
                    upperTotalMoney = upperTotalMoney.add(orderHongBaoMoneyComputeService
                            .computeSecondInviteMoney(commonOrder, buyer, bossLevelList));
                }
            }
        }
        orderRebateVO.setFanLiDesc(predictDesc + typeName);
        orderRebateVO.setFanLi("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN));
        orderRebateVO.setType(type);
        orderRebateVO.setStateDesc(stateDesc);
        orderRebateVO.setListGoods(voList);
        if (downTime.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME) {
            orderRebateVO.setUserLevel(UserLevelEnum.superVIP.name()); // 隐藏
        } else {
            orderRebateVO.setUserLevel(userLevel.name());
        }
        orderRebateVO.setFanLiDesc(predictDesc + typeName);
        orderRebateVO.setFanLi("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN));
        orderRebateVO.setType(type);
        orderRebateVO.setStateDesc(stateDesc);
        orderRebateVO.setListGoods(voList);
        if (downTime.getTime() < Constant.NEW_ORDER_FANLI_RULE_TIME) {
            orderRebateVO.setUserLevel(UserLevelEnum.superVIP.name()); // 隐藏
        } else {
            orderRebateVO.setUserLevel(userLevel.name());
        }
        // 超级会员返利
        if (upperLevel != null) {
            orderRebateVO.setUpperFanLi("¥" + upperTotalMoney);
            orderRebateVO.setJumpLink(upperLevel.getDetailLink());
        }
        // 超级会员返利
        if (upperLevel != null) {
            orderRebateVO.setUpperFanLi("¥" + upperTotalMoney);
            orderRebateVO.setJumpLink(upperLevel.getDetailLink());
        }
        int freeState = 0;
        boolean rewardSuccess = false;
        List<String> listNo = new ArrayList<String>();
        listNo.add(orderNo);
        List<UserSystemCouponRecord> useRecord = userSystemCouponRecordService.getRecordByOrderNoList(sourceType,
                listNo);
        if (useRecord != null && useRecord.size() > 0) {
            for (UserSystemCouponRecord couponRecord : useRecord) {
                Integer state = couponRecord.getState();
                String cType = couponRecord.getCouponType();
                if (CouponTypeEnum.rebatePercentCoupon.name().equals(cType)
                        && UserSystemCouponRecord.STATE_SUCCESS == state) {
                    rewardSuccess = true;
                    break;
                } else if (CouponTypeEnum.freeCoupon.name().equals(cType)
                        || CouponTypeEnum.welfareFreeCoupon.name().equals(cType)
                        || CouponTypeEnum.freeCouponBuy.name().equals(cType)) {
                    freeState = state;
                    break;
                }
            }
        }
        int freeState = 0;
        boolean rewardSuccess = false;
        List<String> listNo = new ArrayList<String>();
        listNo.add(orderNo);
        List<UserSystemCouponRecord> useRecord = userSystemCouponRecordService.getRecordByOrderNoList(sourceType,
                listNo);
        if (useRecord != null && useRecord.size() > 0) {
            for (UserSystemCouponRecord couponRecord : useRecord) {
                Integer state = couponRecord.getState();
                String cType = couponRecord.getCouponType();
                if (CouponTypeEnum.rebatePercentCoupon.name().equals(cType)
                        && UserSystemCouponRecord.STATE_SUCCESS == state) {
                    rewardSuccess = true;
                    break;
                } else if (CouponTypeEnum.freeCoupon.name().equals(cType)
                        || CouponTypeEnum.welfareFreeCoupon.name().equals(cType)
                        || CouponTypeEnum.freeCouponBuy.name().equals(cType)) {
                    freeState = state;
                    break;
                }
            }
        }
        if (rewardSuccess) { // 已使用奖励券
            JSONObject params = new JSONObject();
            params.put("orderNo", orderNo);
            params.put("goodsType", sourceType + "");
            BigDecimal couponMoney = orderHongBaoMapService.getCouponHongbaoByOrderNo(orderNo, uid);
            if (couponMoney == null) {
                couponMoney = new BigDecimal(0);
            }
            orderRebateVO.setCouponType(1);
            orderRebateVO.setCouponUse(true);
            orderRebateVO.setCouponText("奖励成功");
            orderRebateVO.setCouponDesc("已再返¥" + couponMoney.setScale(2, BigDecimal.ROUND_DOWN));
            orderRebateVO.setCouponParams(params.toString());
            orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
        } else if (freeState > 0) { // 已使用免单券
            JSONObject params = new JSONObject();
            params.put("orderNo", orderNo);
            params.put("goodsType", sourceType + "");
            orderRebateVO.setCouponType(2);
            orderRebateVO.setCouponUse(true);
            orderRebateVO.setCouponParams(params.toString());
            orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
            if (UserSystemCouponRecord.STATE_FREE_ON == freeState) {
                orderRebateVO.setCouponText("免单中");
            } else if (UserSystemCouponRecord.STATE_SUCCESS == freeState) {
                orderRebateVO.setCouponText("免单成功");
            } else if (UserSystemCouponRecord.STATE_FAIL_RULE == freeState
                    || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == freeState) {
                orderRebateVO.setCouponText("免单失败");
            }
        } else {
            Date accountTime = hongBaoV2.getGetTime();
            // 到账时间 -红包金额限制
            if (accountTime != null && hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) <= 0) {
                boolean vip = userInviteService.verifyVIP(uid);
                Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
                long currentTime = java.lang.System.currentTimeMillis();
                if (endDay.getTime() > currentTime && !vip) {
                    UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo,
                            sourceType, null);
                    if (couponRecord == null) {
                        orderRebateVO.setCoupon(true);
                        orderRebateVO.setCouponType(1);
                        orderRebateVO.setCouponText("立即使用");
                        orderRebateVO.setCouponDesc("返利再返");
                    }
                }
            }
        }
        if (rewardSuccess) { // 已使用奖励券
            JSONObject params = new JSONObject();
            params.put("orderNo", orderNo);
            params.put("goodsType", sourceType + "");
            BigDecimal couponMoney = orderHongBaoMapService.getCouponHongbaoByOrderNo(orderNo, uid);
            if (couponMoney == null) {
                couponMoney = new BigDecimal(0);
            }
            orderRebateVO.setCouponType(1);
            orderRebateVO.setCouponUse(true);
            orderRebateVO.setCouponText("奖励成功");
            orderRebateVO.setCouponDesc("已再返¥" + couponMoney.setScale(2, BigDecimal.ROUND_DOWN));
            orderRebateVO.setCouponParams(params.toString());
            orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
        } else if (freeState > 0) { // 已使用免单券
            JSONObject params = new JSONObject();
            params.put("orderNo", orderNo);
            params.put("goodsType", sourceType + "");
            orderRebateVO.setCouponType(2);
            orderRebateVO.setCouponUse(true);
            orderRebateVO.setCouponParams(params.toString());
            orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
            if (UserSystemCouponRecord.STATE_FREE_ON == freeState) {
                orderRebateVO.setCouponText("免单中");
            } else if (UserSystemCouponRecord.STATE_SUCCESS == freeState) {
                orderRebateVO.setCouponText("免单成功");
            } else if (UserSystemCouponRecord.STATE_FAIL_RULE == freeState
                    || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == freeState) {
                orderRebateVO.setCouponText("免单失败");
            }
        } else {
            Date accountTime = hongBaoV2.getGetTime();
            // 到账时间 -红包金额限制
            if (accountTime != null && hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) <= 0) {
                boolean vip = userInviteService.verifyVIP(uid);
                Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
                long currentTime = java.lang.System.currentTimeMillis();
                if (endDay.getTime() > currentTime && !vip) {
                    UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo,
                            sourceType, null);
                    if (couponRecord == null) {
                        orderRebateVO.setCoupon(true);
                        orderRebateVO.setCouponType(1);
                        orderRebateVO.setCouponText("立即使用");
                        orderRebateVO.setCouponDesc("返利再返");
                    }
                }
            }
        }
        JSONObject data = new JSONObject();
        data.put("result", orderRebateVO);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
        JSONObject data = new JSONObject();
        data.put("result", orderRebateVO);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    /**
     * 用户订单统计
     *
     * @param acceptData
     * @param uid        用户id type 类型:0全部、1淘宝 2京东、拼多多
     * @param out
     */
    @RequestMapping(value = "teamOrderSearch")
    public void teamOrderSearch(String callback, AcceptData acceptData, Long uid, Integer page, String key,
            PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
    /**
     * 用户订单统计
     *
     * @param acceptData
     * @param uid        用户id type 类型:0全部、1淘宝 2京东、拼多多
     * @param out
     */
    @RequestMapping(value = "teamOrderSearch")
    public void teamOrderSearch(String callback, AcceptData acceptData, Long uid, Integer page, String key,
                                PrintWriter out) {
        if (uid == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        List<TeamOrderVO> resultList = new ArrayList<>();
        if (StringUtil.isNullOrEmpty(key)) {
            JSONObject data = new JSONObject();
            data.put("count", 0);
            data.put("list", resultList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            return;
        }
        List<TeamOrderVO> resultList = new ArrayList<>();
        if (StringUtil.isNullOrEmpty(key)) {
            JSONObject data = new JSONObject();
            data.put("count", 0);
            data.put("list", resultList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            return;
        }
        try {
            if (page == null)
                page = 1;
        try {
            if (page == null)
                page = 1;
            List<TeamOrderVO> list = teamDividentsSourceOrderUserMapService.searchByOrderNoOrSourceUid((page - 1) * 20,
                    20, uid, key);
            if (list == null) {
                list = new ArrayList<>();
            }
            List<TeamOrderVO> list = teamDividentsSourceOrderUserMapService.searchByOrderNoOrSourceUid((page - 1) * 20,
                    20, uid, key);
            if (list == null) {
                list = new ArrayList<>();
            }
            if (list.size() > 0) {
                for (int i = 0; i < list.size(); i++) {
                    TeamOrderVO teamVO = list.get(i);
                    // 粉丝代数
                    ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, teamVO.getUid());
                    if (threeDetail == null) {
                        list.remove(i);
                        i--;
                        continue;
                    }
                    teamVO.setTeamGrade(threeDetail.getLevel());
            if (list.size() > 0) {
                for (int i = 0; i < list.size(); i++) {
                    TeamOrderVO teamVO = list.get(i);
                    // 粉丝代数
                    ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, teamVO.getUid());
                    if (threeDetail == null) {
                        list.remove(i);
                        i--;
                        continue;
                    }
                    teamVO.setTeamGrade(threeDetail.getLevel());
                    // 粉丝基本信息
                    UserInfo userInfo = userInfoService.getUserByIdWithMybatis(teamVO.getUid());
                    if (userInfo == null) {
                        list.remove(i);
                        i--;
                        continue;
                    }
                    teamVO.setNickName(userInfo.getNickName());
                    teamVO.setPortrait(userInfo.getPortrait());
                    // 粉丝基本信息
                    UserInfo userInfo = userInfoService.getUserByIdWithMybatis(teamVO.getUid());
                    if (userInfo == null) {
                        list.remove(i);
                        i--;
                        continue;
                    }
                    teamVO.setNickName(userInfo.getNickName());
                    teamVO.setPortrait(userInfo.getPortrait());
                    BigDecimal payment = BigDecimal.ZERO;
                    List<CommonOrder> listOrder = commonOrderService.listBySourceTypeAndOrderId(teamVO.getSourceType(),
                            teamVO.getOrderNo());
                    if (listOrder != null && listOrder.size() > 0) {
                        for (CommonOrder order : listOrder) {
                            payment = payment.add(order.getPayment());
                            teamVO.setSourceName(order.getChildSourceType());
                            teamVO.setDownTime(TimeUtil.formatDate(order.getThirdCreateTime()));
                    BigDecimal payment = BigDecimal.ZERO;
                    List<CommonOrder> listOrder = commonOrderService.listBySourceTypeAndOrderId(teamVO.getSourceType(),
                            teamVO.getOrderNo());
                    if (listOrder != null && listOrder.size() > 0) {
                        for (CommonOrder order : listOrder) {
                            payment = payment.add(order.getPayment());
                            teamVO.setSourceName(order.getChildSourceType());
                            teamVO.setDownTime(TimeUtil.formatDate(order.getThirdCreateTime()));
                            // 下单时等级
                            UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(order.getUrank());
                            if (userLevel == null)
                                userLevel = UserLevelEnum.daRen;
                            teamVO.setUserRank(UserLevelUtil.getShowLevel(userLevel).name());
                            // 下单时等级
                            UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(order.getUrank());
                            if (userLevel == null)
                                userLevel = UserLevelEnum.daRen;
                            teamVO.setUserRank(UserLevelUtil.getShowLevel(userLevel).name());
                            // 结算时间
                            Date settleTime = order.getSettleTime();
                            if (settleTime != null)
                                teamVO.setSettleTime(TimeUtil.formatDate(settleTime));
                            // 结算时间
                            Date settleTime = order.getSettleTime();
                            if (settleTime != null)
                                teamVO.setSettleTime(TimeUtil.formatDate(settleTime));
                            // 维权信息
                            Integer orderState = order.getState();
                            if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())
                                    && CommonOrder.STATE_WQ == orderState) {
                                if (order.getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
                                    UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService
                                            .selectByOrderInfoAndUid(uid, order.getTradeId(), order.getSourceType());
                                    if (record != null) {
                                        teamVO.setServiceTime(TimeUtil.formatDate(record.getCreateTime()));
                                    }
                                }
                            }
                            // 维权信息
                            Integer orderState = order.getState();
                            if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())
                                    && CommonOrder.STATE_WQ == orderState) {
                                if (order.getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
                                    UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService
                                            .selectByOrderInfoAndUid(uid, order.getTradeId(), order.getSourceType());
                                    if (record != null) {
                                        teamVO.setServiceTime(TimeUtil.formatDate(record.getCreateTime()));
                                    }
                                }
                            }
                        }
                    }
                    teamVO.setPayment(payment);
                        }
                    }
                    teamVO.setPayment(payment);
                    // 订单时间信息
                    String orderTime = "下单" + teamVO.getDownTime();
                    if (!StringUtil.isNullOrEmpty(teamVO.getSettleTime())) {
                        orderTime += "\n收货" + teamVO.getSettleTime();
                    }
                    if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())) {
                        orderTime += "\n售后" + teamVO.getServiceTime();
                    }
                    teamVO.setOrderTime(orderTime);
                }
            }
                    // 订单时间信息
                    String orderTime = "下单" + teamVO.getDownTime();
                    if (!StringUtil.isNullOrEmpty(teamVO.getSettleTime())) {
                        orderTime += "\n收货" + teamVO.getSettleTime();
                    }
                    if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())) {
                        orderTime += "\n售后" + teamVO.getServiceTime();
                    }
                    teamVO.setOrderTime(orderTime);
                }
            }
            GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
            gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
                @Override
                public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                    if (value == null) {
                        return new JsonPrimitive("");
                    } else {
                        // 保留2位小数
                        value = value.setScale(2, BigDecimal.ROUND_DOWN);
                        return new JsonPrimitive(value.toString());
                    }
                }
            });
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("count", teamDividentsSourceOrderUserMapService.countSearchByOrderNoOrSourceUid(uid, key));
            data.put("list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
    }
            GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
            gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
                @Override
                public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                    if (value == null) {
                        return new JsonPrimitive("");
                    } else {
                        // 保留2位小数
                        value = value.setScale(2, BigDecimal.ROUND_DOWN);
                        return new JsonPrimitive(value.toString());
                    }
                }
            });
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("count", teamDividentsSourceOrderUserMapService.countSearchByOrderNoOrSourceUid(uid, key));
            data.put("list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
            return;
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/SystemEnum.java
@@ -7,11 +7,11 @@
 * 系统枚举
 */
public enum SystemEnum {
    blks("com.yeshi.ec.rebate", "com.xyj.ec.fanli-ios", new String[]{}, new SystemFunction[]{
    blks("com.yeshi.ec.rebate", "com.xyj.ec.fanli-ios", new String[]{}, new SystemFunction[]{SystemFunction.share,
            SystemFunction.bindPhone, SystemFunction.threeSale, SystemFunction.cloudOrder, SystemFunction.godenCorn, SystemFunction.redPack,SystemFunction.faQuan,SystemFunction.fanli,SystemFunction.vip,SystemFunction.inviteCode
    }, 1, "板栗快省","板栗快省"),
    flq("com.fanliunion.android", "com.xyj.ec.flq-ios", new String[]{}, new SystemFunction[]{SystemFunction.faQuan,SystemFunction.fanli}, 11, "返利联盟","淘拼团"),
    yhqjx("com.youhuiquan.android","com.youhuiquanjx.ios",new String[]{}, new SystemFunction[]{SystemFunction.faQuan,SystemFunction.fanli,SystemFunction.lijinSub,SystemFunction.bindPhone}, 12, "优惠券精选","特价App");
    flq("com.fanliunion.android", "com.xyj.ec.flq-ios", new String[]{}, new SystemFunction[]{SystemFunction.share,SystemFunction.faQuan,SystemFunction.fanli}, 11, "返利联盟","淘拼团"),
    yhqjx("com.youhuiquan.android","com.youhuiquanjx.ios",new String[]{}, new SystemFunction[]{SystemFunction.fanli,SystemFunction.lijinSub,SystemFunction.bindPhone}, 12, "特价","特价App");
    private String packageName;
    private String bundleId;
    private int systemId;
fanli/src/main/java/com/yeshi/fanli/entity/SystemFunction.java
@@ -13,7 +13,8 @@
    faQuan("发圈"),
    vip("超级会员"),
    fanli("是否需要返利"),
    lijinSub("礼金立减");
    lijinSub("礼金立减"),
    share("是否需要分享");
    private SystemFunction(String desc) {
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOverViews.java
@@ -3,6 +3,7 @@
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.util.Date;
@@ -14,11 +15,16 @@
    @Id
    private String id;
    @Indexed
    @Field
    private Long uid;
    @Field
    private MsgTypeEnum msgType;
    @Field
    private Long identityCode;//主键
    @Indexed
    @Field
    private Date createTime;
    @Field
    @Indexed
    private Date updateTime;
fanli/src/main/java/com/yeshi/fanli/lijin/manager/GoodsLijinMnager.java
@@ -166,9 +166,11 @@
    private List<GoodsDetailVOWithKey> loadTBMoneyInfo(SystemEnum system, Long uid, List<TaoBaoGoodsBrief> goodsBriefList, List<String> goodsKeyList, GoodsMoneyConfigParamsDTO paramsDTO) {
        Map<String, MoneyInfo> lijinMap = null;
        boolean hasCreateTime = false;
        if (SystemInfoUtil.hasFunctions(system, SystemFunction.lijinSub)) {
            loadMaterialLibsType(goodsBriefList);
            lijinMap = getTBLijinList(uid, goodsBriefList);
            hasCreateTime = true;
        }
        List<GoodsDetailVOWithKey> voList = new ArrayList<>();
        for (int i = 0; i < goodsBriefList.size(); i++) {
@@ -189,9 +191,11 @@
        if (goodsList == null || goodsList.size() == 0)
            return voList;
        boolean hasCreateTime = false;
        BigDecimal fanliRate = null;
        if (system == SystemEnum.yhqjx) {
            fanliRate = getFanLiRate(uid);
            hasCreateTime = true;
        }
        BigDecimal couponPrice = null;
@@ -306,8 +310,14 @@
        }
        for (GoodsDetailVO vo : otherVOList) {
            int p = positionMap.get(vo.getGoodsId() + "#" + vo.getGoodsType() + "#" + vo.getId());
            String goodsId = vo.getGoodsId();
            if (goodsId.contains("-"))
                goodsId = goodsId.split("-")[1];
            Integer p = positionMap.get(goodsId + "#" + vo.getGoodsType() + "#" + vo.getId());
//            if (p != null)
            vos[p] = vo;
//            else
//                System.out.println(vo);
        }
        List<GoodsDetailVO> finalList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/lijin/manager/UserLijinMnager.java
@@ -17,6 +17,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Component
@@ -64,6 +65,16 @@
        VIPEnum rank = null;
        if (uid != null)
            rank = vipCenterService.getVIPEnumByUid(getUid(uid));
        if (rank == null)
            rank = vipGradeService.getDefaultGrade().getIdentity();
        return rank;
    }
    public VIPEnum getVIPRank(Long uid, Date date) {
        VIPEnum rank = null;
        if (uid != null)
            rank = vipCenterService.getVIPEnumByUid(getUid(uid), date);
        if (rank == null)
            rank = vipGradeService.getDefaultGrade().getIdentity();
        return rank;
@@ -174,4 +185,18 @@
    }
    /**
     * 获取用户的返利比例
     *
     * @param uid
     * @param date
     * @return
     */
    public BigDecimal getUserFanliRate(Long uid, Date date) {
        VIPEnum vipRank = getVIPRank(uid, date);
        VipGradePotence potence = vipGradePotenceService.getPotenceByVipEnum(vipRank, date);
        return potence.getRebatePercent();
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -18,10 +18,14 @@
import javax.imageio.ImageIO;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemFunction;
import com.yeshi.fanli.entity.SystemPIDInfo;
import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
import com.yeshi.fanli.service.manger.PIDManager;
import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.util.FileUtil;
import com.yeshi.fanli.util.StringUtil;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@@ -29,8 +33,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.ImageCropUtil;
import org.yeshi.utils.*;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
@@ -67,13 +70,6 @@
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service;
import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.FileUtil;
import org.yeshi.utils.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import org.yeshi.utils.TimeUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -85,6 +81,7 @@
import com.yeshi.fanli.vo.goods.CouponInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.common.vo.ClientTextStyleVO;
import sun.plugin2.util.SystemUtil;
@Service
public class GoodsEvaluateServiceImpl implements GoodsEvaluateService {
@@ -346,6 +343,9 @@
                }
            }
        }
        if (oldGoodsVO != null) {
            oldGoodsVO.setCreatetime(null);
        }
        // 视频部分
        if (fileRequest != null) {
@@ -452,6 +452,8 @@
        if (goodsDetailVO == null) {
            throw new GoodsEvaluateException(1, "该商品信息不存在");
        }
        goodsDetailVO.setCreatetime(null);
        List<ImgInfo> tempList = new ArrayList<ImgInfo>();
        int totalImg = 0;
@@ -682,6 +684,8 @@
            PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
            goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
        }
        if (goodsDetail != null)
            goodsDetail.setCreatetime(null);
        return goodsDetail;
    }
@@ -1696,6 +1700,7 @@
                    if (typeEnum != null && typeEnum == EvaluateEnum.single) {
                        GoodsDetailVO goods = evaluateNew.getGoods();
                        goods.setCreatetime(null);
                        if (goods != null) {
                            String content = commentInfoNew.getContent();
                            if (!StringUtil.isNullOrEmpty(content)) {
@@ -1715,6 +1720,9 @@
                                for (String st : activityIdList)
                                    content = content.replace(st, "");
                                content = content.replace("{relationId}", "");
                                if (system == SystemEnum.yhqjx) {
                                    content = content.replace("\n", "<br>");
                                }
                                commentInfoNew.setContent(content);
                            }
                        }
@@ -1733,6 +1741,7 @@
                    CommentInfoEnum typeComment = commentInfoNew.getTypeEnum();
                    if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) {
                        GoodsDetailVO goods = evaluateNew.getGoods();
                        goods.setCreatetime(null);
                        if (goods != null && goods.isHasCoupon()) {
                            commentNew.add(commentInfoNew);
                            continue;
@@ -1774,9 +1783,23 @@
                evaluateNew.setComments(commentNew);
                if (typeEnum != null && typeEnum == EvaluateEnum.single) {
                    if (!SystemInfoUtil.hasFunctions(system, SystemFunction.share)) {
                        List<ImgInfo> imgList = evaluateNew.getImgList();
                        if (imgList != null) {
                            for (ImgInfo imgInfo : imgList) {
                                imgInfo.setGoods(null);
                                if (imgInfo.getType() == ImgEnum.goods)
                                    imgInfo.setType(ImgEnum.img);
                            }
                        }
                    }
                    if (!currencyCoupon && !singleCoupn) { // 所有券评论下架
                        GoodsDetailVO goods = evaluateNew.getGoods();
                        if (goods != null) {
                            goods.setCreatetime(null);
                            goods.setState(1); // 评论不存在 下架
                            evaluateNew.setRemarks("评论验证下架");
                        }
@@ -1788,6 +1811,9 @@
                                if (simpleGoods != null) {
                                    simpleGoods.setState(1);
                                    simpleGoods.setRemarks("评论验证下架");
                                }
                                if (system == SystemEnum.yhqjx) {
                                    imgInfo.setGoods(null);
                                }
                            }
@@ -1801,17 +1827,19 @@
        List<GoodsEvaluate> listOBJ = list;
        // 更新商品信息
        executor.execute(new Runnable() {
            @Override
            public void run() {
                updateGoodInfo(listOBJ);
        executor.execute(new
                // 删除已过期
                removeOverdue();
                                 Runnable() {
                                     @Override
                                     public void run() {
                                         updateGoodInfo(listOBJ);
                removeDownGoods();
            }
        });
                                         // 删除已过期
                                         removeOverdue();
                                         removeDownGoods();
                                     }
                                 });
        return listNew;
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -368,6 +368,8 @@
                    CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO();
                    PropertyUtils.copyProperties(commonGoodsVO, goods);
                    commonGoodsVO.setGoodsType(sourceType);
                    commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm"));
                    // 淘宝商品图片处理
                    String picture = commonGoodsVO.getPicture();
@@ -384,6 +386,11 @@
                    if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                        totalSettlement = commonOrder.getTotalPayment();
                    }
                    if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0)
                        commonGoodsVO.setPayState("未付款/已退款");
                    else
                        commonGoodsVO.setPayState("已付款");
                    commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
                    // 邀请订单信息保护
@@ -1745,6 +1752,7 @@
                } catch (Exception e) {
                    e.printStackTrace();
                }
                commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(commonOrder.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm"));
                String picture = commonGoodsVO.getPicture();
                if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) {
@@ -1771,6 +1779,10 @@
                if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                    totalSettlement = commonOrder.getTotalPayment();
                }
                if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0)
                    commonGoodsVO.setPayState("未付款/已退款");
                else
                    commonGoodsVO.setPayState("已付款");
                // 实付款
                commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
@@ -2110,6 +2122,7 @@
                    if (commonGoodsVO.getGoodsType() == null) {
                        commonGoodsVO.setGoodsType(sourceType);
                    }
                    commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm"));
                    // 淘宝商品图片处理
                    String picture = commonGoodsVO.getPicture();
@@ -2126,6 +2139,11 @@
                    if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                        totalSettlement = commonOrder.getTotalPayment();
                    }
                    if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0)
                        commonGoodsVO.setPayState("未付款/已退款");
                    else
                        commonGoodsVO.setPayState("已付款");
                    commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
                    // 邀请订单信息保护
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderHongBaoMoneyComputeServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.lijin.manager.UserLijinMnager;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import org.springframework.stereotype.Service;
@@ -33,16 +34,19 @@
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserLijinMnager userLijinMnager;
    @Override
    public BigDecimal computeBaseFanliMoney(CommonOrder order) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        return getBaseCommission(order,system);
        return getBaseCommission(order, system);
    }
    @Override
    public BigDecimal computeBaseShareMoney(CommonOrder order) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        return getBaseCommission(order,system);
        return getBaseCommission(order, system);
    }
    private UserLevelEnum getCommonUserLevel(Date time, UserLevelEnum userLevel) {
@@ -68,12 +72,18 @@
    @Override
    public BigDecimal computeFanliMoney(CommonOrder order, UserLevelEnum userLevel) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(),system)
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), false,system));
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        BigDecimal rate = null;
        if (system == SystemEnum.yhqjx) {
            rate = userLijinMnager.getUserFanliRate(order.getUserInfo().getId(), order.getThirdCreateTime());
        } else {
            rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(), system)
                    .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                            getCommonUserLevel(order.getThirdCreateTime(), userLevel), false, system));
            if (userLevel == UserLevelEnum.normalVIP) {
                rate = new BigDecimal("61");
            }
        }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
@@ -86,13 +96,18 @@
    @Override
    public BigDecimal computeShareMoney(CommonOrder order, UserLevelEnum userLevel) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(),system)
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), true,system));
        if (system == SystemEnum.yhqjx) {
            return new BigDecimal(0);
        }
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(order.getThirdCreateTime().getTime(), system)
                .add(getOfficialSubsidyRate(order.getThirdCreateTime(),
                        getCommonUserLevel(order.getThirdCreateTime(), userLevel), true, system));
        if (userLevel == UserLevelEnum.normalVIP) {
            rate = new BigDecimal("61");
        }
        if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
            return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.geteIncome()), new BigDecimal(100));
@@ -106,9 +121,12 @@
    public BigDecimal computeFirstInviteMoney(CommonOrder order, UserLevelEnum buyer,
                                              List<UserTeamLevel> bossLevelList) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        if (system == SystemEnum.yhqjx) {
            return new BigDecimal(0);
        }
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 1,system).getRate();
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 1, system).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
@@ -116,12 +134,12 @@
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime(),system);
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_6", order.getThirdCreateTime().getTime(), system);
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order, system)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order, system)),
                        new BigDecimal(100));
        }
@@ -132,9 +150,12 @@
    public BigDecimal computeSecondInviteMoney(CommonOrder order, UserLevelEnum buyer,
                                               List<UserTeamLevel> bossLevelList) {
        SystemEnum system = userInfoService.getUserSystem(order.getUserInfo().getId());
        if (system == SystemEnum.yhqjx) {
            return new BigDecimal(0);
        }
        BigDecimal rate = null;
        if (order.getThirdCreateTime().getTime() >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 2,system).getRate();
            rate = getTeamRewardRate(buyer, bossLevelList, order.getThirdCreateTime(), 2, system).getRate();
            if (rate == null)
                return null;
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
@@ -142,12 +163,12 @@
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, order.getEstimate()), new BigDecimal(100));
        } else {// 老的返利比例
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime(),system);
            rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_7", order.getThirdCreateTime().getTime(), system);
            if (order.getState() == CommonOrder.STATE_JS || order.getState() == CommonOrder.STATE_WQ)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order, system)),
                        new BigDecimal(100));
            else if (order.getEstimate() != null)
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order,system)),
                return MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(rate, getBaseCommission(order, system)),
                        new BigDecimal(100));
        }
@@ -165,7 +186,10 @@
     * @Title: getOfficialSubsidyRate
     * @Description:
     */
    private BigDecimal getOfficialSubsidyRate(Date date, UserLevelEnum userLevel, boolean share,SystemEnum system) {
    private BigDecimal getOfficialSubsidyRate(Date date, UserLevelEnum userLevel, boolean share, SystemEnum system) {
        if (system == SystemEnum.yhqjx) {
            return new BigDecimal(0);
        }
        String key = null;
        if (share)
            key = String.format("official_subsidy_share_%s", userLevel.getLevel());
@@ -174,24 +198,30 @@
        BigDecimal rate = null;
        if (date != null)
            rate = hongBaoManageService.getByKeyAndMaxTimeCache(key, TimeUtil
                    .convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system);
                    .convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"), system);
        else
            rate = new BigDecimal(hongBaoManageService.get(key,system));
            rate = new BigDecimal(hongBaoManageService.get(key, system));
        return rate;
    }
    private BigDecimal getRateByLevel(UserLevelEnum level, Date date,SystemEnum system) {
    private BigDecimal getRateByLevel(UserLevelEnum level, Date date, SystemEnum system) {
        if (system == SystemEnum.yhqjx) {
            return new BigDecimal(0);
        }
        BigDecimal baseRate = hongBaoManageService.getBaseFanliRateCache(
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system);
                TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(date.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"), system);
        BigDecimal subsidyRate = getOfficialSubsidyRate(date, level, false,system);
        BigDecimal subsidyRate = getOfficialSubsidyRate(date, level, false, system);
        return baseRate.add(subsidyRate);
    }
    @Override
    public UserTeamRate getTeamRewardRate(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList, Date date,
                                          int deep,SystemEnum system) {
                                          int deep, SystemEnum system) {
        if (system == SystemEnum.yhqjx) {
            return null;
        }
        if (deep == 1) {// 直接邀请人奖金
            UserTeamLevel boss = bossLevelList.get(0);
            BigDecimal rate = null;
@@ -199,12 +229,12 @@
                return null;
            if (buyerLevel == UserLevelEnum.daRen && boss.getLevel() == UserLevelEnum.daRen) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(),system);
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(), system);
            } else if (buyerLevel == UserLevelEnum.normalVIP && boss.getLevel() == UserLevelEnum.normalVIP) {
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(),system);
                rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_6", date.getTime(), system);
            } else {
                BigDecimal bossRate = getRateByLevel(boss.getLevel(), date,system);
                BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
                BigDecimal bossRate = getRateByLevel(boss.getLevel(), date, system);
                BigDecimal buyerRate = getRateByLevel(buyerLevel, date, system);
                rate = bossRate.subtract(buyerRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
@@ -216,34 +246,34 @@
            if (bossLevelList == null || bossLevelList.size() < 2)
                return null;
            BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
            BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, date, 1,system).getRate();
            BigDecimal buyerRate = getRateByLevel(buyerLevel, date, system);
            BigDecimal firstRate = getTeamRewardRate(buyerLevel, bossLevelList, date, 1, system).getRate();
            UserTeamLevel boss = bossLevelList.get(1);
            UserTeamLevel firstBoss = bossLevelList.get(0);
            BigDecimal rate = null;
            if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.daRen) {
                if (boss.getLevel() == UserLevelEnum.daRen)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(), system);
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.normalVIP && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(), system);
                else {
                    rate = null;
                }
            } else if (buyerLevel == UserLevelEnum.daRen && firstBoss.getLevel() == UserLevelEnum.normalVIP) {
                if (boss.getLevel() == UserLevelEnum.normalVIP)
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(),system);
                    rate = hongBaoManageService.getByKeyAndMaxTime("new_invite_daren_7", date.getTime(), system);
                else {
                    rate = null;
                }
            }
            // 极差计算法
            if (rate == null) {
                rate = getRateByLevel(boss.getLevel(), date,system).subtract(buyerRate).subtract(firstRate);
                rate = getRateByLevel(boss.getLevel(), date, system).subtract(buyerRate).subtract(firstRate);
                if (rate.compareTo(new BigDecimal(0)) < 0)
                    rate = new BigDecimal(0);
            }
@@ -255,25 +285,28 @@
    @Override
    public List<UserTeamRate> getTeamRewardMoreThan2LevelRates(UserLevelEnum buyerLevel,
                                                               List<UserTeamLevel> bossLevelList, Date date,SystemEnum system) {
                                                               List<UserTeamLevel> bossLevelList, Date date, SystemEnum system) {
        if (system == SystemEnum.yhqjx) {
            return null;
        }
        if (bossLevelList == null || bossLevelList.size() < 3)
            return null;
        UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 1,system);
        UserTeamRate firstBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 1, system);
        if (firstBoss == null)
            return null;
        UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 2,system);
        UserTeamRate secondBoss = getTeamRewardRate(buyerLevel, bossLevelList, date, 2, system);
        if (secondBoss == null)
            return null;
        BigDecimal buyerRate = getRateByLevel(buyerLevel, date,system);
        BigDecimal buyerRate = getRateByLevel(buyerLevel, date, system);
        BigDecimal totalRate = firstBoss.getRate().add(secondBoss.getRate()).add(buyerRate);
        List<UserTeamRate> rateList = new ArrayList<>();
        for (int i = 2; i < bossLevelList.size(); i++) {
            BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel(), date,system);
            BigDecimal rate = getRateByLevel(bossLevelList.get(i).getLevel(), date, system);
            if (rate.compareTo(totalRate) > 0) {
                BigDecimal subRate = rate.subtract(totalRate);
                totalRate = subRate.add(totalRate);// 累计分成比例
@@ -287,7 +320,10 @@
    // 团队分红
    @Override
    public List<UserTeamRate> getTeamDividentsRates(UserLevelEnum buyerLevel, List<UserTeamLevel> bossLevelList,
                                                    Date date,SystemEnum system) {
                                                    Date date, SystemEnum system) {
        if (system == SystemEnum.yhqjx) {
            return null;
        }
        List<UserTeamRate> rateList = new ArrayList<>();
        List<UserTeamLevel> levelList = new ArrayList<>();
@@ -318,9 +354,9 @@
        }
        BigDecimal highTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_high",
                date.getTime(),system);
                date.getTime(), system);
        BigDecimal vipTotalRate = hongBaoManageService.getByKeyAndMaxTime("dividents_rate_same_level_super",
                date.getTime(),system);
                date.getTime(), system);
        if (vipList.size() > 0 && highList.size() > 0) {
@@ -364,7 +400,7 @@
        for (UserTeamLevel level : bossLevelList) {
            if (level.getLevel() == UserLevelEnum.tearcher) {
                rateList.add(new UserTeamRate(level,
                        hongBaoManageService.getByKeyAndMaxTime("dividents_rate_tearcher", date.getTime(),system)));
                        hongBaoManageService.getByKeyAndMaxTime("dividents_rate_tearcher", date.getTime(), system)));
                break;
            }
        }
@@ -374,16 +410,16 @@
    @Override
    public UserTeamRate getTearcherSubsidy(UserLevelEnum buyerLevel, BigDecimal money,
                                           List<UserTeamLevel> bossLevelList, Date date,SystemEnum system) {
                                           List<UserTeamLevel> bossLevelList, Date date, SystemEnum system) {
        // TODO Auto-generated method stub
        return null;
    }
    private BigDecimal getFanliRate(Date time, UserLevelEnum userLevel,SystemEnum system) {
    private BigDecimal getFanliRate(Date time, UserLevelEnum userLevel, SystemEnum system) {
        BigDecimal rate = hongBaoManageService
                .getBaseFanliRateCache(TimeUtil
                        .convertToTimeTemp(TimeUtil.getGernalTime(time.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"),system)
                .add(getOfficialSubsidyRate(time, getCommonUserLevel(time, userLevel), false,system));
                        .convertToTimeTemp(TimeUtil.getGernalTime(time.getTime(), "yyyy-MM-dd HH"), "yyyy-MM-dd HH"), system)
                .add(getOfficialSubsidyRate(time, getCommonUserLevel(time, userLevel), false, system));
        if (userLevel == UserLevelEnum.normalVIP)
            rate = new BigDecimal("61");
@@ -392,10 +428,10 @@
    @Override
    public GoodsMoneyConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel, SystemEnum system) {
        BigDecimal fanLiRate = getFanliRate(new Date(), userLevel,system);
        BigDecimal fanLiRate = getFanliRate(new Date(), userLevel, system);
        BigDecimal shareRate = fanLiRate;
        GoodsMoneyConfigParamsDTO paramsDTO = new GoodsMoneyConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                getFanliRate(new Date(), UserLevelEnum.superVIP,system));
                getFanliRate(new Date(), UserLevelEnum.superVIP, system));
        if (VersionUtil.greaterThan_2_0_5(platform, version)) {
            paramsDTO.setMaxRewardRate(null);
        }
@@ -404,13 +440,13 @@
    @Override
    public GoodsMoneyConfigParamsDTO getShowComputeRate(String platform, String version, SystemEnum system) {
        return getShowComputeRate(platform, version, UserLevelEnum.daRen,system);
        return getShowComputeRate(platform, version, UserLevelEnum.daRen, system);
    }
    @Override
    public BigDecimal getFanliRate(UserLevelEnum userLevel, Date date,SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(date.getTime(),system)
                .add(getOfficialSubsidyRate(date, getCommonUserLevel(date, userLevel), false,system));
    public BigDecimal getFanliRate(UserLevelEnum userLevel, Date date, SystemEnum system) {
        BigDecimal rate = hongBaoManageService.getBaseFanliRate(date.getTime(), system)
                .add(getOfficialSubsidyRate(date, getCommonUserLevel(date, userLevel), false, system));
        return rate;
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -209,8 +209,8 @@
    //获取推广位类型
    private SystemPIDInfo.PidType getPidType(int sourceType, String pid) {
        List<SystemPIDInfo> pidInfoList = pidManager.listPidInfoByPidCache(pid, Constant.SOURCE_TYPE_TAOBAO);
        if (pidInfoList == null || pidInfoList.size() == 0) {
        List<SystemPIDInfo> pidInfoList = pidManager.listPidInfoByPidCache(pid, sourceType);
        if ((pidInfoList == null || pidInfoList.size() == 0) && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            pidInfoList = pidManager.listPidInfoByPidCache(pid, Constant.SOURCE_TYPE_ELME);
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/MsgOrderDetailServiceImpl.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
@@ -44,6 +45,7 @@
    private MsgOverViewsService msgOverViewsService;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void addMsgOrderDetail(MsgOrderDetail detail, boolean needNotify) throws MsgOrderDetailException {
        if (detail == null)
@@ -88,7 +90,7 @@
                    update.setBeiZhu(detail.getBeiZhu());
                    msgOrderDetailMapper.updateByPrimaryKeySelective(update);
                    //更新消息索引时间
                    msgOverViewsService.updateTime(MsgOverViewsFactory.create(detail).getId(), update.getUpdateTime());
                    msgOverViewsService.updateTime(MsgOverViewsFactory.create(update).getId(), update.getUpdateTime());
                    msgExtraService.addMsgExtra(update.getId(), detail.getExtraInfo(), MsgExtra.MSG_TYPE_ORDER);
                }
                if (needNotify)
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
@@ -123,7 +123,6 @@
     * @param beiZhu     备注信息 - 非必填
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    private void addOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount,
                                    BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu, boolean needNotify) {
        try {
fanli/src/main/java/com/yeshi/fanli/service/manger/PIDManager.java
@@ -29,7 +29,7 @@
     * @param sourceType
     * @return
     */
    public List<SystemPIDInfo> listPidInfoByPid(String pid, int sourceType) {
    public List<SystemPIDInfo> listPidInfoByPid(String pid, Integer sourceType) {
        SystemPIDInfoDao.DaoQuery daoQuery = new SystemPIDInfoDao.DaoQuery();
        daoQuery.sourceType = sourceType;
        daoQuery.pid = pid;
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOverViewsFactory.java
@@ -6,8 +6,6 @@
import com.yeshi.fanli.entity.bus.msg.MsgTypeEnum;
import com.yeshi.fanli.lijin.entity.MsgLijinVIPDetail;
import java.util.Date;
public class MsgOverViewsFactory {
    public static MsgOverViews create(MsgOrderDetail msgOrderDetail) {
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderGoodsVO.java
@@ -32,7 +32,14 @@
    // 商品标题、颜色、背景色
    @Expose
    private Map<String, String> goodsTitle;
    //下单时间
    @Expose
    private String placeOrderTime;
    //订单状态
    @Expose
    private String payState;
    public String getActualCount() {
        return actualCount;
@@ -66,4 +73,23 @@
        this.goodsType = goodsType;
    }
    public String getPlaceOrderTime() {
        return placeOrderTime;
    }
    public void setPlaceOrderTime(String placeOrderTime) {
        this.placeOrderTime = placeOrderTime;
    }
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }
    public String getPayState() {
        return payState;
    }
    public void setPayState(String payState) {
        this.payState = payState;
    }
}
fanli/src/main/resource/ehcache.xml
@@ -100,6 +100,12 @@
        timeToLiveSeconds="120" overflowToDisk="true"
        memoryStoreEvictionPolicy="LRU" />
    <cache name="systemConfig" maxElementsInMemory="1000"
           maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120"
           timeToLiveSeconds="120" overflowToDisk="true"
           memoryStoreEvictionPolicy="LRU" />
    <cache name="homeBaoManage" maxElementsInMemory="1000"
        maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="18000"
        timeToLiveSeconds="18000" overflowToDisk="true"