Administrator
2020-02-18 c460c9d4f116be480ab5b6604b77be3bbc76a128
发圈信息
1个文件已修改
21个文件已添加
3701 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java 728 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java 592 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountOrderInfoDao.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountOrderTrackRateDao.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountUserInfoDao.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/order/CountOrderDTO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountOrderInfo.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountOrderTrackRate.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountUserInfo.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/CommentInfo.java 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java 285 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/ImgInfo.java 158 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/SimpleGoods.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/system/ChannelEnum.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/dynamic/ActivityUserException.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/dynamic/GoodsEvaluateException.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/CountUserInfoJob.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 695 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/ChannelEnumHandler.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java
New file
@@ -0,0 +1,728 @@
package com.yeshi.fanli.controller.admin;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.entity.admin.count.CountOrderInfo;
import com.yeshi.fanli.entity.admin.count.CountOrderTrackRate;
import com.yeshi.fanli.entity.admin.count.CountUserInfo;
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/countCharts")
public class CountChartsAdminController {
    @Resource
    private UserInfoCountService userInfoCountService;
    @Resource
    private CommonOrderCountService commonOrderCountService;
    private void verifyQueryData(String callback, Integer dateType, String year, String startTime,
            String endTime, PrintWriter out) throws Exception {
        String validateMsg = null;
        if (dateType == null) {
            validateMsg = "请选择视图类型";
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime))) {
            validateMsg  = "请选择时间区间";
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
    }
    private Date getBeginDate(Integer dateType, String year, String startTime) throws Exception{
        Date beginDate = null;
        if (dateType == 1) {
            beginDate = TimeUtil.parse(startTime);
        } else if (dateType == 2) {
            Calendar calendar=Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            if (!StringUtil.isNullOrEmpty(year)) {
                currentYear = Integer.parseInt(year);
            }
            calendar.clear();
            calendar.set(Calendar.YEAR, currentYear);
            beginDate =calendar.getTime();
        } else if (dateType == 3) {
            beginDate = TimeUtil.parse("2018-01-01");
        }
        return beginDate;
    }
    private Date getEndDate(Integer dateType, String year, String endTime) throws Exception{
        Date endDate = null;
        if (dateType == 1) {
            endDate = TimeUtil.parse(endTime);
        } else if (dateType == 2) {
            Calendar calendar=Calendar.getInstance();
            int currentYear = calendar.get(Calendar.YEAR);
            if (!StringUtil.isNullOrEmpty(year)) {
                currentYear = Integer.parseInt(year);
            }
            calendar.clear();
            calendar.set(Calendar.YEAR, currentYear);
            calendar.roll(Calendar.DAY_OF_YEAR, -1);
            endDate=calendar.getTime();
        } else if (dateType == 3) {
            endDate = new Date();
        }
        return endDate;
    }
    private List<Object> machineOrderResultNum(List<String> dateList, Integer dateType, List<CountOrderInfo> listHistory) {
        List<Object> list = new ArrayList<>();
        for (String date: dateList) {
            int value = 0;
            if (listHistory != null) {
                for (CountOrderInfo history: listHistory) {
                    if (dateType == 1) {
                        String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value += history.getNum();
                            continue;
                        }
                    } else if (dateType == 2){
                        String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                        if(gernalTime.startsWith("0")) {
                            gernalTime = gernalTime.substring(1, 2);
                        }
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value +=  history.getNum();
                            continue;
                        }
                    } else if (dateType == 3) {
                        String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value +=  history.getNum();
                            continue;
                        }
                    }
                }
            }
            list.add(value + "");
        }
        return list;
    }
    private List<Object> machineOrderResultMoney(List<String> dateList, Integer dateType, List<CountOrderInfo> listHistory) {
        List<Object> list = new ArrayList<>();
        for (String date: dateList) {
            BigDecimal money = new BigDecimal(0);
            if (listHistory != null) {
                for (CountOrderInfo history: listHistory) {
                    if (dateType == 1) {
                        String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            if (history.getMoney() != null) {
                                money = MoneyBigDecimalUtil.add(money, history.getMoney());
                            }
                            continue;
                        }
                    } else if (dateType == 2){
                        String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                        if(gernalTime.startsWith("0")) {
                            gernalTime = gernalTime.substring(1, 2);
                        }
                        if (gernalTime.equalsIgnoreCase(date) && history.getMoney() != null) {
                            money = MoneyBigDecimalUtil.add(money, history.getMoney());
                        }
                    } else if (dateType == 3) {
                        String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            if (history.getMoney() != null) {
                                money = MoneyBigDecimalUtil.add(money, history.getMoney());
                            }
                        }
                    }
                }
            }
            list.add(money + "");
        }
        return list;
    }
    private List<Object> machineResultNum(List<String> dateList, Integer dateType, List<CountUserInfo> listHistory) {
        List<Object> list = new ArrayList<>();
        for (String date: dateList) {
            int value = 0;
            if (listHistory != null) {
                for (CountUserInfo history: listHistory) {
                    if (dateType == 1) {
                        String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value += history.getNum();
                            continue;
                        }
                    } else if (dateType == 2){
                        String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                        if(gernalTime.startsWith("0")) {
                            gernalTime = gernalTime.substring(1, 2);
                        }
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value +=  history.getNum();
                            continue;
                        }
                    } else if (dateType == 3) {
                        String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            value +=  history.getNum();
                            continue;
                        }
                    }
                }
            }
            list.add(value + "");
        }
        return list;
    }
    /**
     * 统计新人下单情况
     * @param callback
     * @param channelArray
     * @param dateType 日期类型
     * @param year
     * @param startTime
     * @param endTime
     * @param countType 统计类型: 1-当日下单 、 2-当周下单、3-当周下3单
     * @param out
     */
    @RequestMapping(value = "getNewUserDownOder")
    public void getNewUserDownOder(String callback, String channelArray, Integer dateType, String year,
            String startTime, String endTime, Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            // 渠道
            List<String> channelList = null;
            if (channelArray != null && channelArray.trim().length() > 4) {
                channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType());
            }
            JSONArray line_list = new JSONArray();
            if (channelList != null && channelList.size() > 0) {
                for (String channel : channelList) {
                    List<CountUserInfo> listData = null;
                    if (countType == 1) {
                        listData = userInfoCountService.countUserDownOrderByChannelAndToday(channel, beginDate, endDate);
                    } else if (countType == 2) {
                        listData = userInfoCountService.countUseByChannelAndWeekOrder(channel, beginDate, endDate);
                    } else if (countType == 3) {
                        listData = userInfoCountService.countUseByChannelAndWeekThreeOrder(channel, beginDate, endDate);
                    }
                    List<Object> list = machineResultNum(dateList, dateType, listData);
                    JSONObject innerList = new JSONObject();
                    innerList.put("name", channel);
                    innerList.put("data", gson.toJson(list));
                    line_list.add(innerList);
                }
            } else {
                List<CountUserInfo> listData = null;
                if (countType == 1) {
                    listData = userInfoCountService.countUserDownOrderByChannelAndToday(null, beginDate, endDate);
                } else if (countType == 2) {
                    listData = userInfoCountService.countUseByChannelAndWeekOrder(null, beginDate, endDate);
                } else if (countType == 3) {
                    listData = userInfoCountService.countUseByChannelAndWeekThreeOrder(null, beginDate, endDate);
                }
                List<Object> list = machineResultNum(dateList, dateType, listData);
                JSONObject innerList = new JSONObject();
                innerList.put("name", "全部");
                innerList.put("data", gson.toJson(list));
                line_list.add(innerList);
            }
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     * 统计订单情况
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param countType 1-新用户24小时订单  、  2- 总订单数量
     * @param out
     */
    @RequestMapping(value = "getDownOderNum")
    public void getDownOderNum(String callback, String channelArray, Integer dateType, String year,
            String startTime, String endTime, Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            // 渠道
            List<String> channelList = null;
            if (channelArray != null && channelArray.trim().length() > 4) {
                channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType());
            }
            JSONArray line_list = new JSONArray();
            if (channelList != null && channelList.size() > 0) {
                for (String channel : channelList) {
                    List<CountOrderInfo> listData = null;
                    if (countType == 1) {
                        listData = userInfoCountService.count24HOderByChannel(channel, beginDate, endDate);
                    } else if (countType == 2) {
                        listData = userInfoCountService.countOderByChannel(channel, beginDate, endDate);
                    }
                    List<Object> list = machineOrderResultNum(dateList, dateType, listData);
                    JSONObject innerList = new JSONObject();
                    innerList.put("name", channel);
                    innerList.put("data", gson.toJson(list));
                    line_list.add(innerList);
                }
            } else {
                List<CountOrderInfo> listData = null;
                if (countType == 1) {
                    listData = userInfoCountService.count24HOderByChannel(null, beginDate, endDate);
                } else if (countType == 2) {
                    listData = userInfoCountService.countOderByChannel(null, beginDate, endDate);
                }
                List<Object> list = machineOrderResultNum(dateList, dateType, listData);
                JSONObject innerList = new JSONObject();
                innerList.put("name", "全部");
                innerList.put("data", gson.toJson(list));
                line_list.add(innerList);
            }
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     * 统计订单佣金
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getCommissionMoney")
    public void getCommissionMoney(String callback, String channelArray, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            // 渠道
            List<String> channelList = null;
            if (channelArray != null && channelArray.trim().length() > 4) {
                channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType());
            }
            JSONArray line_list = new JSONArray();
            if (channelList != null && channelList.size() > 0) {
                for (String channel : channelList) {
                    List<CountOrderInfo> listData = userInfoCountService.countHongBaoByChannel(channel, beginDate, endDate);
                    List<Object> list = machineOrderResultMoney(dateList, dateType, listData);
                    JSONObject innerList = new JSONObject();
                    innerList.put("name", channel);
                    innerList.put("data", gson.toJson(list));
                    line_list.add(innerList);
                }
            } else {
                List<CountOrderInfo> listData = userInfoCountService.countHongBaoByChannel(null, beginDate, endDate);
                List<Object> list = machineOrderResultMoney(dateList, dateType, listData);
                JSONObject innerList = new JSONObject();
                innerList.put("name", "全部");
                innerList.put("data", gson.toJson(list));
                line_list.add(innerList);
            }
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     * 统计订单佣金
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getOrderTypeNum")
    public void getOrderTypeNum(String callback, String typeArray, Integer dateType, String year,
            String startTime, String endTime, Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            // 渠道
            List<Integer> typeList = null;
            if (typeArray != null && typeArray.trim().length() > 4) {
                typeList = gson.fromJson(typeArray, new TypeToken<ArrayList<Integer>>() {}.getType());
            }
            JSONArray line_list = new JSONArray();
            if (typeList != null && typeList.size() > 0) {
                for (Integer type : typeList) {
                    List<CountOrderInfo> listData = userInfoCountService.countOrderType(type, beginDate, endDate);
                    List<Object> list = machineOrderResultMoney(dateList, dateType, listData);
                    JSONObject innerList = new JSONObject();
                    String name = "";
                    if (type == 1) {
                        name = "自购订单";
                    } else if (type == 2) {
                        name = "分享订单";
                    } else if (type == 3) {
                        name = "邀请订单";
                    }
                    innerList.put("name", name);
                    innerList.put("data", gson.toJson(list));
                    line_list.add(innerList);
                }
            } else {
                List<CountOrderInfo> listData = userInfoCountService.countOrderType(null, beginDate, endDate);
                List<Object> list = machineOrderResultMoney(dateList, dateType, listData);
                JSONObject innerList = new JSONObject();
                innerList.put("name", "全部");
                innerList.put("data", gson.toJson(list));
                line_list.add(innerList);
            }
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     *  维权订单  金额、订单号数量
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getWeiQuanOrderInfo")
    public void getWeiQuanOrderInfo(String callback, Integer dateType, String year,
            String startTime, String endTime, Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            JSONArray line_list = new JSONArray();
            List<Object> list = null;
            String name = "";
            if (countType == 1) {
                name = "维权数量";
                List<CountOrderInfo> listData = userInfoCountService.countWeiQuanOrder(beginDate, endDate);
                list = machineOrderResultNum(dateList, dateType, listData);
            } else if (countType == 2) {
                name = "维权金额";
                List<CountOrderInfo> listData = userInfoCountService.countWeiQuanOrderMoney(beginDate, endDate);
                list = machineOrderResultMoney(dateList, dateType, listData);
            }
            JSONObject innerList = new JSONObject();
            innerList.put("name", name);
            innerList.put("data", gson.toJson(list));
            line_list.add(innerList);
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     *    订单找回  金额、订单号数量
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getLostOrderInfo")
    public void getLostOrderInfo(String callback, Integer dateType, String year,
            String startTime, String endTime, Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            JSONArray line_list = new JSONArray();
            List<Object> list = null;
            String name = "";
            if (countType == 1) {
                name = "申诉数量";
                List<CountOrderInfo> listData = userInfoCountService.counOrderLastNum(beginDate, endDate);
                list = machineOrderResultNum(dateList, dateType, listData);
            } else if (countType == 2) {
                name = "申诉佣金";
                List<CountOrderInfo> listData = userInfoCountService.counOrderLastMoney(beginDate, endDate);
                list = machineOrderResultMoney(dateList, dateType, listData);
            }
            JSONObject innerList = new JSONObject();
            innerList.put("name", name);
            innerList.put("data", gson.toJson(list));
            line_list.add(innerList);
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     *    订单找回  金额、订单号数量
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getOrderCount")
    public void getOrderCount(String callback, Integer dateType, String year, String startTime, String endTime,
            Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            JSONArray line_list = new JSONArray();
            List<Object> list = null;
            String name = "";
            if (countType == 1) {
                name = "单数";
                List<CountOrderInfo> listData = userInfoCountService.counOrderTotalNum(beginDate, endDate);
                list = machineOrderResultNum(dateList, dateType, listData);
            } else if (countType == 2) {
                name = "佣金";
                List<CountOrderInfo> listData = userInfoCountService.counOrderTotalCommission(beginDate, endDate);
                list = machineOrderResultMoney(dateList, dateType, listData);
            }
            JSONObject innerList = new JSONObject();
            innerList.put("name", name);
            innerList.put("data", gson.toJson(list));
            line_list.add(innerList);
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     *    订单跟踪率
     * @param callback
     * @param channelArray
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getOrderTrackRate")
    public void getOrderTrackRate(String callback, Integer dateType, String year, String startTime, String endTime,
            Integer countType, PrintWriter out) {
        try {
            // 数据验证处理
            verifyQueryData(callback, dateType, year, startTime, endTime, out);
            Date beginDate = getBeginDate(dateType, year, startTime);
            Date endDate = getEndDate(dateType, year, endTime);
            Gson gson = new Gson();
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            JSONArray line_list = new JSONArray();
            List<CountOrderTrackRate> listHistory = commonOrderCountService.getOrderTrackRate(countType, beginDate, endDate);
            List<Object> list = new ArrayList<>();
            DecimalFormat df = new DecimalFormat("#.00");
            for (String date: dateList) {
                double proportion = 0;
                if (listHistory != null) {
                    Long upValue = 0L;
                    Long downValue = 0L;
                    for (CountOrderTrackRate history: listHistory) {
                        if (dateType == 1) {
                            String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                            if (gernalTime.equalsIgnoreCase(date)) {
                                if(history.getNum() != null)
                                    upValue = history.getNum();
                                if(history.getTotalNum() != null)
                                    downValue = history.getTotalNum();
                                continue;
                            }
                        } else if (dateType == 2){
                            String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                            if(gernalTime.startsWith("0")) {
                                gernalTime = gernalTime.substring(1, 2);
                            }
                            if (gernalTime.equalsIgnoreCase(date)) {
                                if(history.getNum() != null)
                                    upValue = history.getNum();
                                if(history.getTotalNum() != null)
                                    downValue = history.getTotalNum();
                                continue;
                            }
                        } else if (dateType == 3) {
                            String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                            if (gernalTime.equalsIgnoreCase(date)) {
                                if(history.getNum() != null)
                                    upValue = history.getNum();
                                if(history.getTotalNum() != null)
                                    downValue = history.getTotalNum();
                                continue;
                            }
                        }
                    }
                    if(downValue != 0) {
                        proportion = upValue / (double) downValue;
                    }
                }
                list.add(Double.parseDouble(df.format(proportion * 100)) + "");
            }
            JSONObject innerList = new JSONObject();
            innerList.put("name", "跟踪率");
            innerList.put("data", gson.toJson(list));
            line_list.add(innerList);
            JSONObject data = new JSONObject();
            data.put("line_list", line_list);
            data.put("xAxis_list", gson.toJson(dateList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/GoodsEvaluateAdminController.java
New file
@@ -0,0 +1,592 @@
package com.yeshi.fanli.controller.admin;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.entity.dynamic.ImgInfo;
import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.manger.ClipboardAnalysisManager;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONObject;
/**
 * 轮播图管理
 *
 * @author Administrator
 *
 */
@Controller
@RequestMapping("admin/new/api/v1/evaluate")
public class GoodsEvaluateAdminController {
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private ClipboardAnalysisManager clipboardAnalysisManager;
    @Resource
    private RedisManager redisManager;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Resource
    private HongBaoManageService hongBaoManageService;
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "saveHead")
    public void saveHead(String callback, GoodsEvaluate evaluate, HttpServletRequest request, PrintWriter out) {
        try {
            if (request instanceof MultipartHttpServletRequest) {
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                goodsEvaluateService.saveHead(fileRequest.getFile("portraitFile"), evaluate);
            } else {
                goodsEvaluateService.saveHead(null, evaluate);
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "saveSingleGoods")
    public void saveSingleGoods(String callback, String pid, Long goodsId, Integer goodsType, String videoUrl,
            Integer picNum, String picUrls, HttpServletRequest request, PrintWriter out) {
        try {
            MultipartHttpServletRequest fileRequest = null;
            if (request instanceof MultipartHttpServletRequest) {
                fileRequest = (MultipartHttpServletRequest) request;
            }
            goodsEvaluateService.saveSingleGoods(pid, goodsId, goodsType, videoUrl, picNum, picUrls, fileRequest);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "saveSingleGoodsCoupon")
    public void saveSingleGoodsCoupon(String callback, String pid, CommentInfo commentInfo, PrintWriter out) {
        try {
            goodsEvaluateService.saveSingleGoodsCoupon(pid, commentInfo);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
    /**
     * 获取信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "getSingleGoodsinfo")
    public void getSingleGoodsinfo(String callback, String pid, PrintWriter out) {
        try {
            String goodsId = "";
            String goodsType = "";
            String videoUrl = "";
            String videoPic = "";
            Integer picNum = 1;
            List<String> list = new ArrayList<String>();
            GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid);
            if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) {
                List<ImgInfo> imgList = goodsEvaluate.getImgList();
                for (ImgInfo imgInfo : imgList) {
                    ImgEnum type = imgInfo.getType();
                    if (type == ImgEnum.video) {
                        videoPic = imgInfo.getUrl();
                        videoUrl = imgInfo.getVideoUrl();
                    } else if (type == ImgEnum.goods) {
                        list.add(imgInfo.getUrl());
                        goodsId = imgInfo.getGoods().getGoodsId().toString();
                        goodsType = imgInfo.getGoods().getGoodsType().toString();
                    } else if (type == ImgEnum.img) {
                        list.add(imgInfo.getUrl());
                    }
                }
                picNum = goodsEvaluate.getMainPicNum();
            }
            JSONObject data = new JSONObject();
            data.put("goodsId",  goodsId);
            data.put("goodsType",  goodsType);
            data.put("videoUrl",  videoUrl);
            data.put("videoPic",  videoPic);
            data.put("picNum",  picNum);
            data.put("list",  list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 获取信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "getSingleGoodsCoupon")
    public void getSingleGoodsCoupon(String callback, String pid, PrintWriter out) {
        try {
            CommentInfo commentInfo = new CommentInfo();
            GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid);
            if (goodsEvaluate != null && goodsEvaluate.getComments() != null && goodsEvaluate.getComments().size() > 0) {
                commentInfo = goodsEvaluate.getComments().get(0);
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(commentInfo));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "saveActivityPic")
    public void saveActivityPic(String callback, String pid, ImgInfo imgInfo,
            HttpServletRequest request, PrintWriter out) {
        try {
            MultipartHttpServletRequest fileRequest = null;
            if (request instanceof MultipartHttpServletRequest) {
                fileRequest = (MultipartHttpServletRequest) request;
            }
            goodsEvaluateService.saveActivityPic(pid, imgInfo, fileRequest);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
    /**
     * 获取信息
     *
     * @param callback
     * @param special
     *            0a39676f138c4dcba722e321d43c4284
     * @param out
     */
    @RequestMapping(value = "getActivityPic")
    public void getActivityPic(String callback, String pid, PrintWriter out) {
        try {
            String videoPic = "";
            String videoUrl = "";
            String activityPic = "";
            String activityUrl = "";
            GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid);
            if (goodsEvaluate != null && goodsEvaluate.getImgList() != null && goodsEvaluate.getImgList().size() > 0) {
                List<ImgInfo> imgList = goodsEvaluate.getImgList();
                for (ImgInfo imgInfo : imgList) {
                    ImgEnum type = imgInfo.getType();
                    if (type == ImgEnum.video) {
                        videoPic = imgInfo.getUrl();
                        videoUrl = imgInfo.getVideoUrl();
                    } else if (type == ImgEnum.activity) {
                        activityPic = imgInfo.getUrl();
                        activityUrl = imgInfo.getActivityUrl();
                    }
                }
            }
            JSONObject data = new JSONObject();
            data.put("videoUrl",  videoUrl);
            data.put("videoPic",  videoPic);
            data.put("activityPic",  activityPic);
            data.put("activityUrl",  activityUrl);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "getEvaluate")
    public void getEvaluate(String callback, String id, PrintWriter out) {
        try {
            GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id);
            if (goodsEvaluate == null)
                goodsEvaluate = new GoodsEvaluate();
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("result", gson.toJson(goodsEvaluate));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
    }
    /**
     * 删除图片以及信息
     *
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
                return;
            }
            Gson gson = new Gson();
            List<String> list = gson.fromJson(idArray, new TypeToken<ArrayList<String>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            goodsEvaluateService.deleteBatchByPrimaryKey(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param bannerId
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<GoodsEvaluate> list = goodsEvaluateService.query((pageIndex - 1) * pageSize, pageSize, key, state);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            for (GoodsEvaluate article : list) {
                Date startTime = article.getStartTime();
                if (startTime == null) {
                    article.setStartTimeChar("");
                } else {
                    article.setStartTimeChar(TimeUtil.formatDateAddT(startTime));
                }
                Date endTime = article.getEndTime();
                if (endTime == null) {
                    article.setEndTimeChar("");
                } else {
                    article.setEndTimeChar(TimeUtil.formatDateAddT(endTime));
                }
            }
            long count = goodsEvaluateService.count(key, state);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 根据链接查询商品
     *
     * @param callback
     * @param text
     * @param out
     */
    @RequestMapping(value = "getGoodsByUrl")
    public void getGoodsByUrl(String callback, String link, PrintWriter out) {
        try {
            // CommonGoods commonGoods =
            // clipboardAnalysisManager.parseLink(link);
            // if (commonGoods == null) {
            // JsonUtil.printMode(out, callback,
            // JsonUtil.loadFalseResult("未找到该商品"));
            // return;
            // }
            //
            GoodsDetailVO goodsDetail = null;
//             try {
//                  BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
//                  BigDecimal shareRate = hongBaoManageService.getShareRate();
//                  BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
//                  ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate,
//                  shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
//                 TaoBaoGoodsBrief goodsBrief =
//                 redisManager.getTaoBaoGoodsBrief(596617470742L);
//                 goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief,
//                 params);
//                 } catch (TaobaoGoodsDownException e) {
//                 JsonUtil.printMode(out, callback,
//                 JsonUtil.loadFalseResult("该商品已下架"));
//                 return;
//                 }
            // if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
            // try {
            // TaoBaoGoodsBrief goodsBrief =
            // redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
            // goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief,
            // params);
            // } catch (TaobaoGoodsDownException e) {
            // JsonUtil.printMode(out, callback,
            // JsonUtil.loadFalseResult("该商品已下架"));
            // return;
            // }
            // } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_JD)
            // {
            // JDGoods goodsInfo =
//             JDApiUtil.queryGoodsDetail(commonGoods.getGoodsId()); // 高级接口
            // if (goodsInfo == null) {
            // goodsInfo = JDUtil.getGoodsDetail(commonGoods.getGoodsId()); //
            // 爬取网页
            // //jdGoods = JDApiUtil.getGoodsDetail(goodsId); // 普通接口
            // }
            //// JDGoods goodsInfo =
            // jdGoodsCacheUtil.getGoodsInfo(commonGoods.getGoodsId());
            // goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo,
            // params);
            // } else if (commonGoods.getGoodsType() ==
            // Constant.SOURCE_TYPE_PDD) {
            // PDDGoodsDetail goodsInfo =
            // pinDuoDuoCacheUtil.getGoodsInfo(commonGoods.getGoodsId());
            // goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo,
            // params);
            // }
            // if (goodsDetail == null) {
            // JsonUtil.printMode(out, callback,
            // JsonUtil.loadFalseResult("未找到该商品"));
            // return;
            // }
            List<String> imgList = new ArrayList<>();
            imgList.add(
                    "https://img.alicdn.com/bao/uploaded/i1/2578900982/O1CN01SUiNLE1J7nWMlpy1A_!!0-item_pic.jpg_220x220");
            imgList.add(
                    "https://img.alicdn.com/bao/uploaded/i1/2398662401/O1CN01I2UoTF1TbhXVwhJrz_!!0-item_pic.jpg_220x220");
            imgList.add(
                    "https://img.alicdn.com/bao/uploaded/i4/2640238597/O1CN01A5xBr32DNTYWJSDZe_!!0-item_pic.jpg_220x220");
            imgList.add(
                    "https://img.alicdn.com/bao/uploaded/i3/2640238597/O1CN01H5Q0Ni2DNTYxGAy3V_!!0-item_pic.jpg_220x220");
            JSONObject object = new JSONObject();
            object.put("goodsId", 551062664275L);
            object.put("goodsType", 1);
            object.put("imgList", imgList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "saveComment")
    public void saveComment(String callback, String pid, CommentInfo commentInfo, PrintWriter out) {
        try {
            goodsEvaluateService.saveComment(pid, commentInfo);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
    /**
     * 删除信息
     *
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "deleteComment")
    public void deleteComment(String callback, String pid, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
                return;
            }
            Gson gson = new Gson();
            List<String> list = gson.fromJson(idArray, new TypeToken<ArrayList<String>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            goodsEvaluateService.deleteComment(pid, list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
        } catch (GoodsEvaluateException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询品论
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param bannerId
     * @param out
     */
    @RequestMapping(value = "queryComment")
    public void queryComment(String callback, String pid, PrintWriter out) {
        GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pid);
        if (goodsEvaluate == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该动态信息已不存在"));
            return;
        }
        List<CommentInfo> list = goodsEvaluate.getComments();
        if (list == null || list.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
        }
        try {
            long count = list.size();
            int totalPage = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
            PageEntity pe = new PageEntity(1, 100, count, totalPage);
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
New file
@@ -0,0 +1,125 @@
package com.yeshi.fanli.dao.dynamic;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.util.StringUtil;
@Repository
public class GoodsEvaluateDao {
    @Resource
    private MongoTemplate mongoTemplate;
    /**
     * 新增
     *
     * @param record
     */
    public void save(GoodsEvaluate record) {
        if (record == null) {
            return;
        }
        mongoTemplate.save(record);
    }
    /**
     * 根据id查询数据
     *
     * @param id
     * @return
     */
    public GoodsEvaluate getById(String id) {
        Query query = new Query();
        query.addCriteria(Criteria.where("id").is(id));
        return mongoTemplate.findOne(query, GoodsEvaluate.class);
    }
    /**
     * 删除
     *
     * @param id
     * @return
     */
    public void deleteById(String id) {
        GoodsEvaluate info = getById(id);
        if (info == null) {
            return;
        }
        mongoTemplate.remove(info);
    }
    /**
     * 查询
     *
     * @return
     */
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state) {
        Query query = new Query();
        if (state != null) {
            query.addCriteria(Criteria.where("state").is(state));
        }
        if (!StringUtil.isNullOrEmpty(key))
            query.addCriteria(new Criteria().orOperator(
                           Criteria.where("title").regex(Pattern.compile("^.*" + key + ".*$", Pattern.CASE_INSENSITIVE))));
        query.skip(start).limit(count);
        query.with(new Sort(Sort.Direction.DESC,"weight")).with(new Sort(Sort.Direction.DESC,"createTime"));
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    public long count(String key, Integer state) {
        Query query = new Query();
        if (state != null) {
            query.addCriteria(Criteria.where("state").is(state));
        }
        if (!StringUtil.isNullOrEmpty(key))
            query.addCriteria(new Criteria().orOperator(
                           Criteria.where("title").regex(Pattern.compile("^.*" + key + ".*$", Pattern.CASE_INSENSITIVE))));
        return mongoTemplate.count(query, GoodsEvaluate.class);
    }
    /**
     * 查询有效
     * @param start
     * @param count
     * @param key
     * @return
     */
    public List<GoodsEvaluate> queryValid(int start, int count) {
        Date now = new Date();
        Query query = new Query();
        query.addCriteria(Criteria.where("state").is(1));
        query.addCriteria(Criteria.where("startTime").lte(now));
        query.addCriteria(Criteria.where("endTime").gte(now));
        query.skip(start).limit(count);
        query.with(new Sort(Sort.Direction.DESC,"weight")).with(new Sort(Sort.Direction.DESC,"createTime"));
        return mongoTemplate.find(query, GoodsEvaluate.class);
    }
    /**
     * 统计有效
     * @param key
     * @return
     */
    public long countValid() {
        Date now = new Date();
        Query query = new Query();
        query.addCriteria(Criteria.where("state").is(1));
        query.addCriteria(Criteria.where("startTime").lte(now));
        query.addCriteria(Criteria.where("endTime").gte(now));
        return mongoTemplate.count(query, GoodsEvaluate.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountOrderInfoDao.java
New file
@@ -0,0 +1,91 @@
package com.yeshi.fanli.dao.user.count;
import java.util.Date;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.admin.count.CountOrderInfo;
import com.yeshi.fanli.entity.admin.count.CountOrderInfo.CountOrderEnum;
import com.yeshi.fanli.util.StringUtil;
@Repository
public class CountOrderInfoDao extends MongodbBaseDao<CountOrderInfo> {
    /**
     * 查询统计最大的一天
     *
     * @return
     */
    public CountOrderInfo getMaxDate(CountOrderEnum userEnum) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(userEnum.name()));
        query.with(new Sort(Sort.Direction.DESC, "day")).limit(1);
        return mongoTemplate.findOne(query, CountOrderInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountOrderInfo> query(CountOrderEnum userEnum, Date startTime, Date endTime) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        return mongoTemplate.find(query, CountOrderInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountOrderInfo> query(CountOrderEnum userEnum, Date startTime, Date endTime, String channel) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        if (!StringUtil.isNullOrEmpty(channel)) {
            Criteria c2 = Criteria.where("channel").is(channel);
            query.addCriteria(c2);
        }
        return mongoTemplate.find(query, CountOrderInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountOrderInfo> query(CountOrderEnum userEnum, Date startTime, Date endTime, Integer state) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        if (state != null) {
            Criteria c2 = Criteria.where("state").is(state);
            query.addCriteria(c2);
        }
        return mongoTemplate.find(query, CountOrderInfo.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountOrderTrackRateDao.java
New file
@@ -0,0 +1,48 @@
package com.yeshi.fanli.dao.user.count;
import java.util.Date;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.admin.count.CountOrderTrackRate;
import com.yeshi.fanli.entity.admin.count.CountOrderTrackRate.OrderTrackRateEnum;
@Repository
public class CountOrderTrackRateDao extends MongodbBaseDao<CountOrderTrackRate> {
    /**
     * 查询统计最大的一天
     *
     * @return
     */
    public CountOrderTrackRate getMaxDate(OrderTrackRateEnum userEnum) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(userEnum.name()));
        query.with(new Sort(Sort.Direction.DESC, "day")).limit(1);
        return mongoTemplate.findOne(query, CountOrderTrackRate.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountOrderTrackRate> query(OrderTrackRateEnum userEnum, Date startTime, Date endTime) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        return mongoTemplate.find(query, CountOrderTrackRate.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/user/count/CountUserInfoDao.java
New file
@@ -0,0 +1,91 @@
package com.yeshi.fanli.dao.user.count;
import java.util.Date;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.admin.count.CountUserInfo;
import com.yeshi.fanli.entity.admin.count.CountUserInfo.CountUserEnum;
import com.yeshi.fanli.util.StringUtil;
@Repository
public class CountUserInfoDao extends MongodbBaseDao<CountUserInfo> {
    /**
     * 查询统计最大的一天
     *
     * @return
     */
    public CountUserInfo getMaxDate(CountUserEnum userEnum) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(userEnum.name()));
        query.with(new Sort(Sort.Direction.DESC, "day")).limit(1);
        return mongoTemplate.findOne(query, CountUserInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountUserInfo> query(CountUserEnum userEnum, Date startTime, Date endTime) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        return mongoTemplate.find(query, CountUserInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountUserInfo> query(CountUserEnum userEnum, Date startTime, Date endTime, String channel) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        if (!StringUtil.isNullOrEmpty(channel)) {
            Criteria c2 = Criteria.where("channel").is(channel);
            query.addCriteria(c2);
        }
        return mongoTemplate.find(query, CountUserInfo.class);
    }
    /**
     * 查询视图
     *
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     */
    public List<CountUserInfo> query(CountUserEnum userEnum, Date startTime, Date endTime, Integer state) {
        Query query = new Query();
        Criteria ca = new Criteria();
        ca.andOperator(Criteria.where("type").is(userEnum.name()),Criteria.where("day").gte(startTime), Criteria.where("day").lte(endTime));
        query.addCriteria(ca);
        if (state != null) {
            Criteria c2 = Criteria.where("state").is(state);
            query.addCriteria(c2);
        }
        return mongoTemplate.find(query, CountUserInfo.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dto/order/CountOrderDTO.java
New file
@@ -0,0 +1,37 @@
package com.yeshi.fanli.dto.order;
import java.math.BigDecimal;
public class CountOrderDTO {
    // 用户id
    private Long uid;
    // 订单数
    private Integer totalOrder;
    // 佣金
    private BigDecimal commission;
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public Integer getTotalOrder() {
        return totalOrder;
    }
    public void setTotalOrder(Integer totalOrder) {
        this.totalOrder = totalOrder;
    }
    public BigDecimal getCommission() {
        return commission;
    }
    public void setCommission(BigDecimal commission) {
        this.commission = commission;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountOrderInfo.java
New file
@@ -0,0 +1,115 @@
package com.yeshi.fanli.entity.admin.count;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Field;
/**
 * 订单统计
 *
 * @author Administrator
 *
 */
public class CountOrderInfo {
    public enum  CountOrderEnum {
        channelTotal("订单渠道统计"),
        oder24H("新人24小时产生订单"),
        channelCommission("订单佣金"),
        orderType("订单类型数量"),
        weiQuanNum("订单维权数量"),
        weiQuanMoney("订单维权金额"),
        lastNum("订单找回数量"),
        lastMoney("订单找回金额"),
        totalNum("总订单数量"),
        totalCommission("总订单佣金");
        private final String desc;
        private CountOrderEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
    @Field("_id")
    private String id;
    // 日期
    @Field("day")
    private Date day;
    // 数量
    @Field("num")
    private Integer num;
    // 金额
    @Field("money")
    private BigDecimal money;
    @Field("state")
    private Integer state;
    // 类型
    @Field("type")
    private String type;
    // 渠道
    @Field("channel")
    private String channel;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getDay() {
        return day;
    }
    public void setDay(Date day) {
        this.day = day;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getChannel() {
        return channel;
    }
    public void setChannel(String channel) {
        this.channel = channel;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountOrderTrackRate.java
New file
@@ -0,0 +1,89 @@
package com.yeshi.fanli.entity.admin.count;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Field;
/**
 * 订单跟踪率
 *
 * @author Administrator
 *
 */
public class CountOrderTrackRate {
    public enum OrderTrackRateEnum {
        taobao(1,"订单渠道统计"), jd(2,"新人24小时产生订单"), pdd(3,"订单佣金");
        private final int value;
        private final String desc;
        private OrderTrackRateEnum(int value, String desc) {
            this.value = value;
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public int getValue() {
            return value;
        }
    }
    @Field("_id")
    private String id;
    // 日期
    @Field("day")
    private Date day;
    // 数量
    @Field("num")
    private Long num;
    // 金额
    @Field("money")
    private Long totalNum;
    // 类型
    @Field("type")
    private String type;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getDay() {
        return day;
    }
    public void setDay(Date day) {
        this.day = day;
    }
    public Long getNum() {
        return num;
    }
    public void setNum(Long num) {
        this.num = num;
    }
    public Long getTotalNum() {
        return totalNum;
    }
    public void setTotalNum(Long totalNum) {
        this.totalNum = totalNum;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/CountUserInfo.java
New file
@@ -0,0 +1,115 @@
package com.yeshi.fanli.entity.admin.count;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
/**
 * 渠道订单统计
 *
 * @author Administrator
 *
 */
@Document(collection = "CountUserInfo")
public class CountUserInfo {
    public enum CountUserEnum {
        newUser("其他"),
        extractApplyNumber("提现申请次数"),
        extractApplyMoney("提现申请次数"),
        extractAuditNumber("提现审核次数"),
        todayOrder("当日订单的用户数量"),
        weekOrder("7天内订单用户数量"),
        weekThreeOrder("7天内订单用户数量"),;
        private final String desc;
        private CountUserEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
    @Field("_id")
    private String id;
    // 日期
    @Field("day")
    private Date day;
    // 数量
    @Field("num")
    private Integer num;
    // 金额
    @Field("money")
    private BigDecimal money;
    @Field("state")
    private Integer state;
    // 类型
    @Field("type")
    private CountUserEnum type;
    // 渠道
    @Field("channel")
    private String channel;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getDay() {
        return day;
    }
    public void setDay(Date day) {
        this.day = day;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
    public CountUserEnum getType() {
        return type;
    }
    public void setType(CountUserEnum type) {
        this.type = type;
    }
    public String getChannel() {
        return channel;
    }
    public void setChannel(String channel) {
        this.channel = channel;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/CommentInfo.java
New file
@@ -0,0 +1,161 @@
package com.yeshi.fanli.entity.dynamic;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.format.annotation.DateTimeFormat;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
public class CommentInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    public enum CommentInfoEnum {
        goodsCoupon(1,"商品优惠券"), currencyCoupon(2,"通用优惠券");
        private final int vlaue;
        private final String desc;
        private CommentInfoEnum(int vlaue, String desc) {
            this.vlaue = vlaue;
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public int getVlaue() {
            return vlaue;
        }
    }
    @Expose
    private String id;
    // 类型
    @Expose
    private CommentInfoEnum type;
    // 内容
    @Expose
    private String content;
    // 标签
    @Expose
    private List<ClientTextStyleVO> tagList;
    // 标签说明
    @Expose
    private String tagDesc;
    // h5
    @Expose
    private String tagUrl;
    private Integer weight;
    // 券信息
    private String coupon;
    // 券来源
    private String couponSource;
    // 结束时间
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//    private Date endTime;
    private String tags;
    private String tagsColour;
    private String endTime;
    public CommentInfoEnum getType() {
        return type;
    }
    public void setType(CommentInfoEnum type) {
        this.type = type;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<ClientTextStyleVO> getTagList() {
        return tagList;
    }
    public void setTagList(List<ClientTextStyleVO> tagList) {
        this.tagList = tagList;
    }
    public String getTagDesc() {
        return tagDesc;
    }
    public void setTagDesc(String tagDesc) {
        this.tagDesc = tagDesc;
    }
    public String getTags() {
        return tags;
    }
    public void setTags(String tags) {
        this.tags = tags;
    }
    public String getTagsColour() {
        return tagsColour;
    }
    public void setTagsColour(String tagsColour) {
        this.tagsColour = tagsColour;
    }
    public Integer getWeight() {
        return weight;
    }
    public void setWeight(Integer weight) {
        this.weight = weight;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getTagUrl() {
        return tagUrl;
    }
    public void setTagUrl(String tagUrl) {
        this.tagUrl = tagUrl;
    }
    public String getCoupon() {
        return coupon;
    }
    public void setCoupon(String coupon) {
        this.coupon = coupon;
    }
    public String getCouponSource() {
        return couponSource;
    }
    public void setCouponSource(String couponSource) {
        this.couponSource = couponSource;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java
New file
@@ -0,0 +1,285 @@
package com.yeshi.fanli.entity.dynamic;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.format.annotation.DateTimeFormat;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.entity.bus.activity.ActivityUser;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
/**
 * 动态商品测评
 *
 * @author Administrator
 *
 */
@Document(collection = "goods_evaluate")
public class GoodsEvaluate implements Serializable {
    private static final long serialVersionUID = 1L;
    // 图片格式: 一排显示: 0无图 1一张 2两张 3张
    public final static int LINE_NUM_ZERO = 0;
    public final static int LINE_NUM_ONE = 1;
    public final static int LINE_NUM_TWO = 2;
    public final static int LINE_NUM_THREE = 3;
    public enum EvaluateEnum {
        single("单品"), multiple("多品"), activity("活动");
        private final String desc;
        private EvaluateEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
    @Id
    @Expose
    @Field("_id")
    private String id;
    // 类型
    @Field("type")
    private EvaluateEnum type;
    @Expose
    @Field("user")
    private ActivityUser user; // 发布用户
    @Expose
    @Field("title")
    private String title; // 发布内容
    @Expose
    @Field("shareNum")
    private Integer shareNum; // 分享次数
    // 图片一行显示: 0无图 1一张 2两张  3张
    @Expose
    @Field("lineNum")
    private Integer lineNum;
    @Expose
    @Field("imgList")
    private List<ImgInfo> imgList; // 图片信息
    @Field("shareNumReal")
    private Integer shareNumReal; // 分享次数真实
    @Expose
    @Field("goods")
    private GoodsDetailVO goods; // 商品信息
    @Expose
    @Field("comments")
    private List<CommentInfo> comments; // 评论信息
    @Expose
    @Field("publishTime")
    private Date publishTime; // 发布时间
    @Field("state")
    private Integer state; // 状态
    @Field("weight")
    private Double weight; // 权重
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("startTime")
    private Date startTime; // 开始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field("endTime")
    private Date endTime; // 结束时间
    @Field("createTime")
    private Date createTime; // 创建时间
    @Field("updateTime")
    private Date updateTime; // 更新时间
    @Field("mainPicNum")
    private Integer mainPicNum; // 图片主图
    private String startTimeChar;
    private String endTimeChar;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public ActivityUser getUser() {
        return user;
    }
    public void setUser(ActivityUser user) {
        this.user = user;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public List<ImgInfo> getImgList() {
        return imgList;
    }
    public void setImgList(List<ImgInfo> imgList) {
        this.imgList = imgList;
    }
    public Integer getLineNum() {
        return lineNum;
    }
    public void setLineNum(Integer lineNum) {
        this.lineNum = lineNum;
    }
    public Integer getShareNum() {
        return shareNum;
    }
    public void setShareNum(Integer shareNum) {
        this.shareNum = shareNum;
    }
    public GoodsDetailVO getGoods() {
        return goods;
    }
    public void setGoods(GoodsDetailVO goods) {
        this.goods = goods;
    }
    public List<CommentInfo> getComments() {
        return comments;
    }
    public void setComments(List<CommentInfo> comments) {
        this.comments = comments;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Double getWeight() {
        return weight;
    }
    public void setWeight(Double weight) {
        this.weight = weight;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Integer getShareNumReal() {
        return shareNumReal;
    }
    public void setShareNumReal(Integer shareNumReal) {
        this.shareNumReal = shareNumReal;
    }
    public String getStartTimeChar() {
        return startTimeChar;
    }
    public void setStartTimeChar(String startTimeChar) {
        this.startTimeChar = startTimeChar;
    }
    public String getEndTimeChar() {
        return endTimeChar;
    }
    public void setEndTimeChar(String endTimeChar) {
        this.endTimeChar = endTimeChar;
    }
    public Date getPublishTime() {
        return publishTime;
    }
    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }
    public Integer getMainPicNum() {
        return mainPicNum;
    }
    public void setMainPicNum(Integer mainPicNum) {
        this.mainPicNum = mainPicNum;
    }
    public EvaluateEnum getType() {
        return type;
    }
    public void setType(EvaluateEnum type) {
        this.type = type;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/ImgInfo.java
New file
@@ -0,0 +1,158 @@
package com.yeshi.fanli.entity.dynamic;
import java.io.Serializable;
import com.google.gson.annotations.Expose;
public class ImgInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    public enum ImgEnum {
        img(1, "图片"), goods(2, "商品"), video(3, "视频"), activity(4, "活动");
        private final int vlaue;
        private final String desc;
        private ImgEnum(int vlaue, String desc) {
            this.vlaue = vlaue;
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public int getVlaue() {
            return vlaue;
        }
    }
    private String id;
    // 上级id
    private String pid;
    // 类型
    @Expose
    private ImgEnum type;
    // 图片链接
    @Expose
    private String url;
    // 高清图片链接
    @Expose
    private String urlHD;
    // 视频链接
    @Expose
    private String videoUrl;
    // 宽度
    @Expose
    private Integer w;
    // 高度
    @Expose
    private Integer h;
    // 是否大图
    @Expose
    private boolean large;
    // 商品信息
    @Expose
    private SimpleGoods goods;
    private String activityPic;
    private String activityUrl;
    public ImgEnum getType() {
        return type;
    }
    public void setType(ImgEnum type) {
        this.type = type;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public Integer getW() {
        return w;
    }
    public void setW(Integer w) {
        this.w = w;
    }
    public Integer getH() {
        return h;
    }
    public void setH(Integer h) {
        this.h = h;
    }
    public SimpleGoods getGoods() {
        return goods;
    }
    public void setGoods(SimpleGoods goods) {
        this.goods = goods;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getUrlHD() {
        return urlHD;
    }
    public void setUrlHD(String urlHD) {
        this.urlHD = urlHD;
    }
    public String getVideoUrl() {
        return videoUrl;
    }
    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }
    public boolean isLarge() {
        return large;
    }
    public void setLarge(boolean large) {
        this.large = large;
    }
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    public String getActivityUrl() {
        return activityUrl;
    }
    public void setActivityUrl(String activityUrl) {
        this.activityUrl = activityUrl;
    }
    public String getActivityPic() {
        return activityPic;
    }
    public void setActivityPic(String activityPic) {
        this.activityPic = activityPic;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/SimpleGoods.java
New file
@@ -0,0 +1,67 @@
package com.yeshi.fanli.entity.dynamic;
import java.io.Serializable;
import java.math.BigDecimal;
import com.google.gson.annotations.Expose;
public class SimpleGoods implements Serializable {
    private static final long serialVersionUID = 1L;
    // 商品ID
    @Expose
    private Long goodsId;
    // 商品类型 1-淘宝 2-京东 3-拼多多
    @Expose
    private Integer goodsType;
    // 券后价
    @Expose
    private BigDecimal price;
    // 券面额
    @Expose
    private BigDecimal amount;
    // 状态
    @Expose
    private Integer state;
    public Long getGoodsId() {
        return goodsId;
    }
    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }
    public Integer getGoodsType() {
        return goodsType;
    }
    public void setGoodsType(Integer goodsType) {
        this.goodsType = goodsType;
    }
    public BigDecimal getPrice() {
        return price;
    }
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    public BigDecimal getAmount() {
        return amount;
    }
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/system/ChannelEnum.java
New file
@@ -0,0 +1,36 @@
package com.yeshi.fanli.entity.system;
public enum ChannelEnum {
    unknown("unknown","未知"),
    p360("360","360"),
    appstore("appstore","appstore"),
    douyin("douyin","抖音"),
    guanwang("GuanWang","官网"),
    lenovo("Lenovo","联想"),
    meizu("meizu","魅族"),
    oppo("OPPO","oppo"),
    pp("PP","pp"),
    qq("QQ","qq"),
    sougou("Sougou","搜狗"),
    vivo("VIVO","vivo"),
    xiaomi("xiaomi","小米"),
    yaoqing("yaoqing","邀请"),
    yingyin("Yingyin","影音"),
    huawei("huawei","华为");
    private final String vlaue;
    private final String desc;
    private ChannelEnum(String vlaue ,String desc) {
        this.vlaue = vlaue;
        this.desc = desc;
    }
    public String getDesc() {
        return desc;
    }
    public String getVlaue() {
        return vlaue;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/dynamic/ActivityUserException.java
New file
@@ -0,0 +1,16 @@
package com.yeshi.fanli.exception.dynamic;
import com.yeshi.fanli.exception.BaseException;
public class ActivityUserException extends BaseException {
    private static final long serialVersionUID = 1L;
    public ActivityUserException(int code, String msg) {
        super(code, msg);
    }
    public ActivityUserException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/dynamic/GoodsEvaluateException.java
New file
@@ -0,0 +1,16 @@
package com.yeshi.fanli.exception.dynamic;
import com.yeshi.fanli.exception.BaseException;
public class GoodsEvaluateException extends BaseException {
    private static final long serialVersionUID = 1L;
    public GoodsEvaluateException(int code, String msg) {
        super(code, msg);
    }
    public GoodsEvaluateException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/job/CountUserInfoJob.java
New file
@@ -0,0 +1,49 @@
package com.yeshi.fanli.job;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.yeshi.utils.DateUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.fanli.entity.admin.count.CountOrderInfo;
import com.yeshi.fanli.entity.admin.count.CountOrderInfo.CountOrderEnum;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.TimeUtil;
/**
 *  统计用户信息
 *
 * @author Administrator
 *
 */
@Component
public class CountUserInfoJob {
    @Resource
    private UserInfoCountService userInfoCountService;
    /**
     * 每天更新一次 数据统计
     */
    @XxlJob("countUserInfoJobHandler")
    public ReturnT<String> countUserJobHandler(String param) throws Exception {
        countInfo();
        return ReturnT.SUCCESS;
    }
    private void countInfo() {
        if (!Constant.IS_TASK)
            return;
        userInfoCountService.initCountUserWeekOrder();
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
New file
@@ -0,0 +1,695 @@
package com.yeshi.fanli.service.impl.dynamic;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.tencentcloud.COSManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.dao.dynamic.GoodsEvaluateDao;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.bus.activity.ActivityUser;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.entity.dynamic.ImgInfo;
import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
import com.yeshi.fanli.entity.dynamic.SimpleGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.dynamic.ActivityUserException;
import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.activity.ActivityUserService;
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.FilePathEnum;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.vo.goods.CouponInfoVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
@Service
public class GoodsEvaluateServiceImpl implements GoodsEvaluateService {
    @Resource
    private GoodsEvaluateDao goodsEvaluateDao;
    @Resource
    private ActivityUserService activityUserService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private JDGoodsCacheUtil jdGoodsCacheUtil;
    @Resource
    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
    @Override
    public void saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException {
        Integer state = record.getState();
        if (state == null) {
            state = 0;
        }
        String tilte = record.getTitle();
        if (StringUtil.isNullOrEmpty(tilte)) {
            throw new GoodsEvaluateException(1, "推荐语不能为空");
        }
        try {
            ActivityUser activityUser = activityUserService.getActivityUserByNickName(record.getUser(), file);
            if (activityUser == null)
                throw new GoodsEvaluateException(1, "请选择发布者");
            record.setUser(activityUser);
        } catch (ActivityUserException e) {
            throw new GoodsEvaluateException(1, e.getMsg());
        }
        if (record.getEndTime() != null) {
            if (record.getEndTime().getTime() <= java.lang.System.currentTimeMillis())
                throw new GoodsEvaluateException(1, "截止时间必须大于当前时间");
            if (record.getStartTime() != null && record.getEndTime().getTime() <= record.getStartTime().getTime())
                throw new GoodsEvaluateException(1, "截止时间必须大于开始时间");
        }
        if (record.getShareNum() == null)
            record.setShareNum(0);
        if (record.getWeight() == null)
            record.setWeight(0.0);
        if (record.getStartTime() == null)
            record.setStartTime(new Date());
        record.setPublishTime(record.getStartTime());
        if (StringUtil.isNullOrEmpty(record.getId())) {
            record.setId(UUID.randomUUID().toString().replace("-", ""));
            record.setShareNumReal(0);
            record.setCreateTime(new Date());
            goodsEvaluateDao.save(record);
        } else {
            GoodsEvaluate resultObj = goodsEvaluateDao.getById(record.getId());
            if (resultObj == null)
                throw new GoodsEvaluateException(1, "修改内容已不存在");
            resultObj.setUser(record.getUser());
            resultObj.setShareNum(record.getShareNum());
            resultObj.setWeight(record.getWeight());
            resultObj.setStartTime(record.getStartTime());
            resultObj.setEndTime(record.getEndTime());
            resultObj.setTitle(tilte);
            goodsEvaluateDao.save(resultObj);
        }
    }
    /**
     * 上传图片
     *
     * @param file
     * @return
     * @throws Exception
     */
    private String uploadPicture(MultipartFile file) throws Exception {
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        String filePath = FilePathEnum.goodsEvaluate.getPath() + UUID.randomUUID().toString().replace("-", "") + "."
                + type;
        return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
    }
    /**
     * 删除图片
     *
     * @param record
     * @throws Exception
     */
    private void removePicture(String picture) throws Exception {
        if (picture != null && picture.trim().length() > 0) {
            COSManager.getInstance().deleteFile(picture);
        }
    }
    @Override
    public void saveSingleGoods(String pid, Long goodsId, Integer goodsType, String videoUrl, Integer picNum,
            String picUrls, MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception {
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new GoodsEvaluateException(1, "请保存第一部分信息");
        }
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
        // 原封视频面图
        ImgInfo imgVideo = null;
        List<String> listDel = new ArrayList<String>();
        List<String> listOld = new ArrayList<String>();
        // 处理图片
        List<ImgInfo> resultList = resultObj.getImgList();
        if (resultList != null && resultList.size() > 0) {
            for (ImgInfo info : resultList) {
                ImgEnum type = info.getType();
                if (type == ImgEnum.video) {
                    imgVideo = info;
                } else if (type == ImgEnum.goods || type == ImgEnum.img) {
                    String url = info.getUrl();
                    if (!StringUtil.isNullOrEmpty(url)) {
                        listOld.add(url);
                    }
                }
            }
        }
        // 视频部分
        if (fileRequest != null) {
            MultipartFile filevideo = fileRequest.getFile("filevideo");
            if (filevideo != null) {
                if (StringUtil.isNullOrEmpty(videoUrl)) {
                    throw new GoodsEvaluateException(1, "视频链接不能为空");
                }
                String picLink = uploadPicture(filevideo);
                if (imgVideo != null) {
                    String url = imgVideo.getUrl();
                    if (!StringUtil.isNullOrEmpty(url)) {
                        listDel.add(url);
                    }
                    imgVideo.setUrl(picLink);
                    imgVideo.setUrlHD(picLink);
                } else {
                    imgVideo = new ImgInfo();
                    imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                    imgVideo.setW(1);
                    imgVideo.setH(1);
                    imgVideo.setLarge(true);
                    imgVideo.setPid(pid);
                    imgVideo.setUrl(picLink);
                    imgVideo.setUrlHD(picLink);
                    imgVideo.setVideoUrl(videoUrl);
                    imgVideo.setType(ImgEnum.video);
                }
            }
        }
        List<ImgInfo> listImg = new ArrayList<ImgInfo>();
        if (imgVideo != null) {
            if (!StringUtil.isNullOrEmpty(videoUrl)) {
                if (imgVideo != null && StringUtil.isNullOrEmpty(imgVideo.getUrl())) {
                    throw new GoodsEvaluateException(1, "视频封面图不能为空");
                }
                imgVideo.setVideoUrl(videoUrl);
                listImg.add(imgVideo);
            } else {
                String url = imgVideo.getUrl();
                if (!StringUtil.isNullOrEmpty(url)) {
                    listDel.add(url);
                }
            }
        }
        // 编辑图片
        List<String> listpic = null;
        if (!StringUtil.isNullOrEmpty(picUrls)) {
            String[] pics = picUrls.split(",");
            if (pics != null) {
                listpic = new ArrayList<>();
                for (int i = 0; i < pics.length; i++ ) {
                    if(pics[i].startsWith("http")){
                        listpic.add(pics[i]);
                    }
                }
            }
        }
        if (fileRequest != null) {
            for (int i = 0; i < 9; i++) {
                MultipartFile file = fileRequest.getFile("file" + i);
                if (file == null) {
                    continue;
                }
                // 上传文件
                String picLink = uploadPicture(file);
                if (listpic != null && listpic.size() > i) {
                    // 需要删除的list
                    String delUrl = listpic.get(i);
                    listDel.add(delUrl);
                    listpic.set(i, picLink);
                    continue;
                }
                listpic.add(picLink);
            }
            // 指定主图
            if (picNum == null || picNum > 9 || picNum < 1) {
                picNum = 1;
            }
            if (listpic != null && listpic.size() > 0) {
                // 对比图片
                for (int j = 0; j < listOld.size(); j++) {
                    boolean del = true;
                    for (int i = 0; i < listpic.size(); i++) {
                        if (listpic.get(i).equals(listOld.get(j))) {
                            del = false;
                            break;
                        }
                    }
                    if (del)
                        listDel.add(listOld.get(j));
                }
                for (int i = 0; i < listpic.size(); i++) {
                    ImgInfo imgInfo0 = new ImgInfo();
                    imgInfo0.setId(UUID.randomUUID().toString().replace("-", ""));
                    imgInfo0.setW(1);
                    imgInfo0.setH(1);
                    imgInfo0.setLarge(false);
                    imgInfo0.setPid(pid);
                    imgInfo0.setUrl(listpic.get(i));
                    imgInfo0.setUrlHD(listpic.get(i));
                    if (picNum - 1 == i) {
                        imgInfo0.setType(ImgEnum.goods);
                        // 商品信息
                        GoodsDetailVO goodsDetailVO = null; // TODO
//                                getGoodsDetailVO(goodsId, goodsType);
//                        if (goodsDetailVO == null) {
//                            throw new GoodsEvaluateException(1, "该商品信息不存在");
//                        }
                        SimpleGoods simpleGoods = new SimpleGoods();
                        simpleGoods.setGoodsId(goodsId);
                        simpleGoods.setGoodsType(goodsType);
//                        simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
//                        CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
//                        if (couponInfo == null) {
//                            simpleGoods.setState(1);
//                        } else {
//                            simpleGoods.setAmount(couponInfo.getAmount());
//                            simpleGoods.setState(0);
//                        }
                        imgInfo0.setGoods(simpleGoods);
                    } else {
                        imgInfo0.setType(ImgEnum.img);
                    }
                    listImg.add(imgInfo0);
                }
            }
        }
        // 保存图片信息
        resultObj.setMainPicNum(picNum);
        resultObj.setImgList(listImg);
        goodsEvaluateDao.save(resultObj);
        // 删除图片
        if (listDel.size() > 0) {
            for (String url : listDel) {
                if (url.contains(FilePathEnum.goodsEvaluate.getPath())) {
                    removePicture(url);
                }
            }
        }
    }
    public GoodsDetailVO getGoodsDetailVO(Long goodsId, Integer goodsType) throws GoodsEvaluateException {
        GoodsDetailVO goodsDetail = null;
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
        ConfigParamsDTO params = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, vipFanLiRate);
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
            try {
                TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(goodsId);
                goodsDetail = GoodsDetailVOFactory.convertTaoBao(goodsBrief, params);
            } catch (TaobaoGoodsDownException e) {
                throw new GoodsEvaluateException(1, "商品已下架");
            }
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(goodsId);
            goodsDetail = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params);
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
            goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, params);
        }
        return goodsDetail;
    }
    @Override
    public void saveSingleGoodsCoupon(String pid, CommentInfo commentInfo) throws GoodsEvaluateException, Exception {
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new GoodsEvaluateException(1, "请保存第一部分信息");
        }
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
        List<CommentInfo> comments = new ArrayList<>();
        if (commentInfo != null) {
            comments.add(commentInfo);
        }
        resultObj.setComments(comments);
        goodsEvaluateDao.save(resultObj);
    }
    @Override
    public void saveActivityPic(String pid, ImgInfo imgInfo, MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception {
        if (StringUtil.isNullOrEmpty(pid)) {
            throw new GoodsEvaluateException(1, "请保存第一部分信息");
        }
        GoodsEvaluate resultObj = goodsEvaluateDao.getById(pid);
        if (resultObj == null)
            throw new GoodsEvaluateException(1, "第一部分信息缺失");
        String videoPic = null;
        String activityPic = null;
        ImgInfo imgVideo = null;
        ImgInfo imgactivity = null;
        List<ImgInfo> resultList = resultObj.getImgList();
        if (resultList != null && resultList.size() > 0) {
            for(ImgInfo info: resultList) {
                if (info.getType() == ImgEnum.activity) {
                    activityPic = info.getActivityPic();
                    imgVideo = info;
                } else {
                    imgVideo = info;
                    videoPic = info.getUrl();
                }
            }
        }
        List<ImgInfo> listImg = new ArrayList<ImgInfo>();
        if (fileRequest != null) {
            MultipartFile filevideo = fileRequest.getFile("filevideo");
            if (filevideo != null) {
                removePicture(videoPic);
                String picLink = uploadPicture(filevideo);
                videoPic = picLink;
            }
            MultipartFile activityfile = fileRequest.getFile("activityfile");
            if (activityfile != null) {
                removePicture(activityPic);
                String picLink = uploadPicture(activityfile);
                activityPic = picLink;
            }
        }
        if (!StringUtil.isNullOrEmpty(videoPic) || !StringUtil.isNullOrEmpty(imgInfo.getVideoUrl())) {
            if (imgVideo != null){
                imgVideo.setUrl(videoPic);
                imgVideo.setUrlHD(videoPic);
                imgVideo.setVideoUrl(imgInfo.getVideoUrl());
            } else {
                imgVideo = new ImgInfo();
                imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                imgVideo.setW(1);
                imgVideo.setH(1);
                imgVideo.setLarge(true);
                imgVideo.setPid(pid);
                imgVideo.setUrl(videoPic);
                imgVideo.setUrlHD(videoPic);
                imgVideo.setVideoUrl(imgInfo.getVideoUrl());
                imgVideo.setType(ImgEnum.video);
            }
            listImg.add(imgVideo);
        }
        if (!StringUtil.isNullOrEmpty(activityPic) || !StringUtil.isNullOrEmpty(imgInfo.getActivityUrl())) {
            if (imgVideo != null){
                imgVideo.setUrl(activityPic);
                imgVideo.setUrlHD(activityPic);
                imgVideo.setVideoUrl(imgInfo.getVideoUrl());
            } else {
                imgVideo = new ImgInfo();
                imgVideo.setId(UUID.randomUUID().toString().replace("-", ""));
                imgVideo.setW(1);
                imgVideo.setH(1);
                imgVideo.setLarge(true);
                imgVideo.setPid(pid);
                imgVideo.setUrl(activityPic);
                imgVideo.setUrlHD(activityPic);
                imgVideo.setActivityUrl(imgInfo.getActivityUrl());
                imgVideo.setType(ImgEnum.activity);
            }
            listImg.add(imgVideo);
        }
        resultObj.setImgList(listImg);
        goodsEvaluateDao.save(resultObj);
    }
    @Override
    public void deleteBatchByPrimaryKey(List<String> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        for (String id : list) {
            goodsEvaluateDao.deleteById(id);
        }
    }
    @Override
    public GoodsEvaluate getById(String id) {
        return goodsEvaluateDao.getById(id);
    }
    @Override
    public void saveComment(String pid, CommentInfo commentInfo) throws GoodsEvaluateException {
        GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(pid);
        if (goodsEvaluate == null) {
            throw new GoodsEvaluateException(1, "动态已不存在");
        }
        String tags = commentInfo.getTags();
        if (!StringUtil.isNullOrEmpty(tags)) {
            String[] arrayTags = tags.split("\\s+");
            if (arrayTags != null && arrayTags.length > 0) {
                String[] arrayTagsColour = null;
                String tagsColour = commentInfo.getTagsColour();
                if (!StringUtil.isNullOrEmpty(tagsColour)) {
                    arrayTagsColour = tagsColour.split("\\s+");
                }
                String color = "#E5005C";
                List<ClientTextStyleVO> tagList = new ArrayList<ClientTextStyleVO>();
                for (int i = 0; i < arrayTags.length; i++) {
                    String tag = arrayTags[i];
                    if (arrayTagsColour != null && arrayTagsColour.length == arrayTags.length) {
                        color = arrayTagsColour[i];
                    }
                    ClientTextStyleVO styleVO = new ClientTextStyleVO();
                    styleVO.setColor(color);
                    styleVO.setContent(tag);
                    tagList.add(styleVO);
                }
                commentInfo.setTagList(tagList);
            }
        }
        List<CommentInfo> comments = goodsEvaluate.getComments();
        if (comments == null) {
            comments = new ArrayList<>();
        }
        Integer weight = commentInfo.getWeight();
        if (weight == null)
            commentInfo.setWeight(1);
        comments.add(commentInfo);
        Collections.shuffle(comments);
        Comparator<CommentInfo> cm = new Comparator<CommentInfo>() {
            @Override
            public int compare(CommentInfo o1, CommentInfo o2) {
                return o1.getWeight() != null && o2.getWeight() != null ? o2.getWeight() - o1.getWeight() : 0;
            }
        };
        Collections.sort(comments, cm);
        goodsEvaluate.setComments(comments);
        goodsEvaluateDao.save(goodsEvaluate);
    }
    @Override
    public void deleteComment(String pid, List<String> list) throws GoodsEvaluateException {
        if (list == null || list.size() == 0) {
            return;
        }
        GoodsEvaluate goodsEvaluate = goodsEvaluateDao.getById(pid);
        if (goodsEvaluate == null) {
            throw new GoodsEvaluateException(1, "动态已不存在");
        }
        List<CommentInfo> comments = goodsEvaluate.getComments();
        if (comments == null || comments.size() == 0) {
            return;
        }
        for (String id : list) {
            for (int i = 0; i < comments.size(); i++) {
                CommentInfo commentInfo = comments.get(i);
                if (id.equals(commentInfo.getId())) {
                    comments.remove(i);
                    i--;
                }
            }
        }
        goodsEvaluate.setComments(comments);
        goodsEvaluateDao.save(goodsEvaluate);
    }
    @Override
    public void addShareNum(String id) {
        GoodsEvaluate article = goodsEvaluateDao.getById(id);
        if (article != null) {
            Integer num = article.getShareNum();
            if (num == null) {
                num = 0;
            }
            article.setShareNum(num + 1);
            Integer numReal = article.getShareNumReal();
            if (numReal == null) {
                numReal = 0;
            }
            article.setShareNumReal(numReal + 1);
            goodsEvaluateDao.save(article);
        }
    }
    @Override
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state) {
        return goodsEvaluateDao.query(start, count, key, state);
    }
    @Override
    public long count(String key, Integer state) {
        return goodsEvaluateDao.count(key, state);
    }
    @Override
    @Cacheable(value = "dynamicCache", key = "'queryValidEvaluateCache-'+#start")
    public List<GoodsEvaluate> queryValidEvaluateCache(int start, int count) {
        List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count);
        // 更新商品信息
        executor.execute(new Runnable() {
            @Override
            public void run() {
                updateGoodInfo(list);
            }
        });
        return list;
    }
    @Override
    public long countValid() {
        return goodsEvaluateDao.countValid();
    }
    /**
     * 更新商品信息
     */
    public void updateGoodInfo(List<GoodsEvaluate> list) {
        if (!Constant.IS_OUTNET) {
            return; // 外网进行更新
        }
        if (list == null || list.size() == 0) {
            return;
        }
        try {
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            BigDecimal vipFanLiRate = hongBaoManageService.getVIPFanLiRate();
            ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
                    vipFanLiRate);
            for (GoodsEvaluate goodsEvaluate : list) {
                // 是否2个小时之内已更新
                Date updateTime = goodsEvaluate.getUpdateTime();
                if (updateTime != null) {
                    long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
                    long nh = 1000 * 60 * 60;// 一小时的毫秒数
                    long diff = System.currentTimeMillis() - updateTime.getTime();
                    long day = diff / nd;// 计算差多少天
                    long hour = diff % nd / nh + day * 24;// 计算差多少小时
                    if (hour < 2) {
                        continue;
                    }
                }
                GoodsDetailVO goods = goodsEvaluate.getGoods();
                if (goods != null) {
                    GoodsDetailVO goodsNew = getGoodsNewInfo(goods.getGoodsId(), goods.getGoodsType(), paramsDTO);
                }
                // 更新商品信息
                List<ImgInfo> imgList = goodsEvaluate.getImgList();
                if (imgList == null || imgList.size() == 0) {
                    continue;
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
    private GoodsDetailVO getGoodsNewInfo(Long goodsId, int goodsType, ConfigParamsDTO paramsDTO) {
        GoodsDetailVO vo = null;
        if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
        } else if (goodsType == Constant.SOURCE_TYPE_JD) {
            JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(goodsId);
            if (goodsInfo != null) {
                vo = GoodsDetailVOFactory.convertJDGoods(goodsInfo, paramsDTO);
            }
        } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
            PDDGoodsDetail goodsInfo = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
            if (goodsInfo != null)
                vo = GoodsDetailVOFactory.convertPDDGoods(goodsInfo, paramsDTO);
        }
        return vo;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java
New file
@@ -0,0 +1,94 @@
package com.yeshi.fanli.service.inter.dynamic;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.yeshi.fanli.entity.dynamic.CommentInfo;
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.entity.dynamic.ImgInfo;
import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
public interface GoodsEvaluateService {
    public void saveHead(MultipartFile file, GoodsEvaluate record) throws GoodsEvaluateException;
    public GoodsEvaluate getById(String id);
    public void deleteBatchByPrimaryKey(List<String> list);
    /**
     * 查询有效并缓存
     * @param start
     * @param count
     * @return
     */
    public List<GoodsEvaluate> queryValidEvaluateCache(int start, int count);
    public long countValid();
    /**
     * 查询
     * @param start
     * @param count
     * @param key
     * @param state
     * @return
     */
    public List<GoodsEvaluate> query(int start, int count, String key, Integer state);
    public long count(String key, Integer state);
    /**
     * 添加分享次数
     * @param id
     */
    public void addShareNum(String id);
    /**
     * 保存评论
     * @param pid
     * @param commentInfo
     * @throws GoodsEvaluateException
     */
    public void saveComment(String pid, CommentInfo commentInfo) throws GoodsEvaluateException;
    public void deleteComment(String pid, List<String> list) throws GoodsEvaluateException;
    /**
     * 保存商品信息单个
     * @param pid
     * @param goodsId
     * @param goodsType
     * @param videoUrl
     * @param picNum
     * @param picUrls
     * @param fileRequest
     * @throws GoodsEvaluateException
     * @throws Exception
     */
    public void saveSingleGoods(String pid, Long goodsId, Integer goodsType, String videoUrl, Integer picNum, String picUrls,
            MultipartHttpServletRequest fileRequest) throws GoodsEvaluateException, Exception;
    /**
     * 单个商品券信息
     * @param pid
     * @param commentInfo
     * @throws GoodsEvaluateException
     * @throws Exception
     */
    public void saveSingleGoodsCoupon(String pid, CommentInfo commentInfo) throws GoodsEvaluateException, Exception;
    public void saveActivityPic(String pid, ImgInfo imgInfo, MultipartHttpServletRequest fileRequest)
            throws GoodsEvaluateException, Exception;
}
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/ChannelEnumHandler.java
New file
@@ -0,0 +1,53 @@
package com.yeshi.fanli.util.mybatishandler;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import com.yeshi.fanli.entity.system.ChannelEnum;
public class ChannelEnumHandler extends BaseTypeHandler<ChannelEnum> {
    @Override
    public ChannelEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            return ChannelEnum.valueOf(key);
        }
    }
    @Override
    public ChannelEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return ChannelEnum.valueOf(key);
        }
    }
    @Override
    public ChannelEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return ChannelEnum.valueOf(key);
        }
    }
    @Override
    public void setNonNullParameter(PreparedStatement arg0, int arg1, ChannelEnum arg2, JdbcType arg3)
            throws SQLException {
        arg0.setString(arg1, arg2.name());
    }
}
utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -205,6 +205,23 @@
        return format.format(ca.getTime());
    }
    /**
     * 指定日期加上天数后的日期
     *
     * @param num     增加的天数
     * @param nowDate 创建时间
     * @return
     * @throws ParseException
     */
    public static Date plusDayReturnDate(int num, String nowDate) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date currdate = format.parse(nowDate);
        Calendar ca = Calendar.getInstance();
        ca.setTime(currdate);
        ca.add(Calendar.DATE, num);
        return ca.getTime();
    }
    /**
     * 指定日期加上天数后的日期
@@ -224,6 +241,7 @@
        return format.format(ca.getTime());
    }
    /**
     * 指定日期加上天数后的日期
     * 
@@ -293,6 +311,28 @@
     * @return
     * @throws ParseException
     */
    public static String reduceDay2(int num, Date date) throws ParseException {
        // 设置要获取到什么样的时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        // 获取String类型的时间
        String date_str = format.format(date);
        Date currdate = format.parse(date_str);
        Calendar ca = Calendar.getInstance();
        ca.setTime(currdate);
        ca.add(Calendar.DATE, -num); // 日期减 如果不够减会将月变动
        return format.format(ca.getTime());
    }
    /**
     * 指定日期减去天数后的日期
     *
     * @param num     减去的天数
     * @param nowDate 创建时间
     * @return
     * @throws ParseException
     */
    public static Date reduceDay(int num, Date date) throws ParseException {
        // 设置要获取到什么样的时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");