yujian
2020-04-01 27c1fd58461e2fd15be392b3c308b4343af8d973
发圈统计
5个文件已修改
4个文件已添加
494 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/login/LoginAdminController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/user/count/DailyCountMomentsDao.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/DailyCountMoments.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountMomentsServiceImpl.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/DailyCountMomentsService.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java
@@ -21,9 +21,11 @@
import com.yeshi.fanli.entity.admin.count.CountOrderTrackRate;
import com.yeshi.fanli.entity.admin.count.CountUserInfo;
import com.yeshi.fanli.entity.admin.count.DailyCountCoupon;
import com.yeshi.fanli.entity.admin.count.DailyCountMoments;
import com.yeshi.fanli.entity.admin.count.DailyCountOrder;
import com.yeshi.fanli.entity.admin.count.DailyCountUser;
import com.yeshi.fanli.service.inter.count.DailyCountCouponService;
import com.yeshi.fanli.service.inter.count.DailyCountMomentsService;
import com.yeshi.fanli.service.inter.count.DailyCountOrderService;
import com.yeshi.fanli.service.inter.count.DailyCountUserService;
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
@@ -53,6 +55,9 @@
    
    @Resource
    private DailyCountOrderService dailyCountOrderService;
    @Resource
    private DailyCountMomentsService dailyCountMomentsService;
    
    
    private void verifyQueryData(String callback, Integer dateType, String year, String startTime, 
@@ -898,7 +903,7 @@
    
    
    /**
     * 用户相关图表数据
     * 订单相关图表数据
     * @param callback
     * @param dateType
     * @param year
@@ -1027,4 +1032,87 @@
        }
        return list;
    }
    @RequestMapping(value = "getMomentsCharts")
    public void getMomentsCharts(String callback, Integer dateType, String year, String startTime, String endTime,
            String typeArray, 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> typelList = null;
            if (typeArray != null && typeArray.trim().length() > 4) {
                typelList = gson.fromJson(typeArray, new TypeToken<ArrayList<String>>() {}.getType());
            }
            if (typelList == null || typelList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递类型错误"));
                return;
            }
            JSONArray line_list = new JSONArray();
            for (String type: typelList) {
                List<DailyCountMoments> listData = dailyCountMomentsService.getDailyCountList(type, beginDate, endDate);
                // 处理数据
                List<Object> list = machineDailyCountMoments(dateList, dateType, listData);
                JSONObject innerList = new JSONObject();
                innerList.put("name", dailyCountMomentsService.getTypeEnumDesc(type));
                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();
        }
    }
    private List<Object> machineDailyCountMoments(List<String> dateList, Integer dateType, List<DailyCountMoments> listData) {
        List<Object> list = new ArrayList<>();
        for (String date: dateList) {
            BigDecimal result = new BigDecimal(0);
            if (listData != null) {
                for (DailyCountMoments history: listData) {
                    if (dateType == 1) {
                        String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            result = MoneyBigDecimalUtil.add(result, history.getTotal());
                        }
                    } else if (dateType == 2){
                        String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay());
                        if(gernalTime.startsWith("0")) {
                            gernalTime = gernalTime.substring(1, 2);
                        }
                        if (gernalTime.equalsIgnoreCase(date)) {
                            result = MoneyBigDecimalUtil.add(result, history.getTotal());
                        }
                    } else if (dateType == 3) {
                        String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay());
                        if (gernalTime.equalsIgnoreCase(date)) {
                            result = MoneyBigDecimalUtil.add(result, history.getTotal());
                        }
                    }
                }
            }
            list.add(result);
        }
        return list;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -12,6 +12,7 @@
import javax.annotation.Resource;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -42,13 +43,13 @@
import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
import com.yeshi.fanli.exception.share.ShareGoodsException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.DailyCountMomentsService;
import com.yeshi.fanli.service.inter.dynamic.ArticleOfficialService;
import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
@@ -135,6 +136,13 @@
    @Resource
    private ShareGoodsService shareGoodsService;
    @Resource
    private DailyCountMomentsService dailyCountMomentsService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    private final static long TYPE_REXIAO = 1;// 热销
    private final static long TYPE_TUIJIAN = 2;// 推荐
@@ -877,6 +885,13 @@
            if (type == 3) {
                shareCount++;
                goodsEvaluateService.addShareNum(id);
                executor.execute(new Runnable() {
                    @Override
                    public void run() { // 添加每日统计
                        dailyCountMomentsService.addShareClick();
                    }
                });
            }
            if (list.size() == 0) {
@@ -1000,7 +1015,7 @@
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
                LogHelper.errorDetailInfo(e);
                out.print(JsonUtil.loadFalseResult("评论生成失败"));
                return;
            }
@@ -1024,6 +1039,13 @@
        JSONObject data = new JSONObject();
        data.put("text", newText);
        out.print(JsonUtil.loadTrueResult(data));
        executor.execute(new Runnable() {
            @Override
            public void run() { // 添加每日统计
                dailyCountMomentsService.addCopyComment();
            }
        });
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/login/LoginAdminController.java
@@ -85,13 +85,11 @@
            HttpServletRequest request,PrintWriter out) {
        
        String ocode = request.getSession().getAttribute(Constant.RANDKEY) + "";
        request.getSession().removeAttribute(Constant.RANDKEY);
        if (StringUtil.isNullOrEmpty(code) || !code.equalsIgnoreCase(ocode)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("验证码错误"));
            return;
        } 
        request.getSession().removeAttribute(Constant.RANDKEY);
        
        if (StringUtil.isNullOrEmpty(username)||StringUtil.isNullOrEmpty(pwd)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户名或密码为空"));
@@ -112,4 +110,12 @@
        return;
    }
    
    @RequestMapping("loginExitJP")
    public void loginExitJP(String callback, HttpServletRequest request,PrintWriter out) {
        request.getSession().removeAttribute(Constant.SESSION_ADMIN);
        request.getSession().invalidate();
        JsonUtil.printMode(out, callback,JsonUtil.loadTrueResult("退出成功"));
        return;
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/user/count/DailyCountMomentsDao.java
New file
@@ -0,0 +1,46 @@
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.DailyCountMoments;
import com.yeshi.fanli.entity.admin.count.DailyCountMoments.DailyCountMomentsEnum;
@Repository
public class DailyCountMomentsDao extends MongodbBaseDao<DailyCountMoments> {
    /**
     * 查询统计最大的一天
     *
     * @return
     */
    public DailyCountMoments getMaxDate(DailyCountMomentsEnum couponEnum) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(couponEnum.name()));
        query.with(new Sort(Sort.Direction.DESC, "day")).limit(1);
        return mongoTemplate.findOne(query, DailyCountMoments.class);
    }
    /**
     * 查询视图
     *
     * @param userEnum
     * @param startTime
     * @param endTime
     * @return
     */
    public List<DailyCountMoments> query(DailyCountMomentsEnum 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, DailyCountMoments.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/admin/count/DailyCountMoments.java
New file
@@ -0,0 +1,87 @@
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 = "daily_count_moments")
public class DailyCountMoments {
    public enum DailyCountMomentsEnum {
        shareClick("分享点击次数"), copyComment("复制评论次数");
        private final String desc;
        private DailyCountMomentsEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
    @Field("_id")
    private String id;
    // 日期:年月日
    @Field("day")
    private Date day;
    // 总数 -每日结果数据
    @Field("total")
    private BigDecimal total;
    // 类型
    @Field("type")
    private DailyCountMomentsEnum type;
    // 更新日期
    @Field("updateDate")
    private Date updateDate;
    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 BigDecimal getTotal() {
        return total;
    }
    public void setTotal(BigDecimal total) {
        this.total = total;
    }
    public DailyCountMomentsEnum getType() {
        return type;
    }
    public void setType(DailyCountMomentsEnum type) {
        this.type = type;
    }
    public Date getUpdateDate() {
        return updateDate;
    }
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountMomentsServiceImpl.java
New file
@@ -0,0 +1,144 @@
package com.yeshi.fanli.service.impl.count;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.user.count.DailyCountMomentsDao;
import com.yeshi.fanli.entity.admin.count.DailyCountMoments;
import com.yeshi.fanli.entity.admin.count.DailyCountMoments.DailyCountMomentsEnum;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.count.DailyCountMomentsService;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@Service
public class DailyCountMomentsServiceImpl implements DailyCountMomentsService {
    @Resource
    private DailyCountMomentsDao dailyCountMomentsDao;
    @Override
    public List<DailyCountMoments> getDailyCountList(String type, Date startTime, Date endTime) throws Exception {
        // 查询类型
        DailyCountMomentsEnum typeEnum = getTypeEnum(type);
        if (typeEnum == null) {
            return null;
        }
        return dailyCountMomentsDao.query(typeEnum, startTime, endTime);
    }
    /**
     * 获取枚举类型
     *
     * @param type
     * @return
     */
    private DailyCountMomentsEnum getTypeEnum(String name) {
        if (StringUtil.isNullOrEmpty(name)) {
            return null;
        }
        DailyCountMomentsEnum[] array = DailyCountMomentsEnum.values();
        for (int i = 0; i < array.length; i++) {
            if (array[i].name().equals(name)) {
                return array[i];
            }
        }
        return null;
    }
    /**
     * 获取枚举类型
     *
     * @param type
     * @return
     */
    @Override
    public String getTypeEnumDesc(String name) {
        if (StringUtil.isNullOrEmpty(name)) {
            return "";
        }
        DailyCountMomentsEnum[] array = DailyCountMomentsEnum.values();
        for (int i = 0; i < array.length; i++) {
            if (array[i].name().equals(name)) {
                return array[i].getDesc();
            }
        }
        return "";
    }
    /**
     * 添加分享次数统计
     */
    @Override
    public void addShareClick() {
        try {
            BigDecimal num = new BigDecimal(1);
            // 当日日期
            String toDay = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
            String id = StringUtil.Md5(toDay + DailyCountMomentsEnum.shareClick.name());
            DailyCountMoments moments = dailyCountMomentsDao.get(id);
            if (moments != null) {
                moments.setTotal(MoneyBigDecimalUtil.add(moments.getTotal(), num));
                moments.setUpdateDate(new Date());
                dailyCountMomentsDao.save(moments);
            } else {
                moments = new DailyCountMoments();
                moments.setId(id);
                moments.setTotal(num);
                moments.setType(DailyCountMomentsEnum.shareClick);
                moments.setUpdateDate(new Date());
                moments.setDay(TimeUtil.parse(toDay));
                dailyCountMomentsDao.save(moments);
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogHelper.error(e);
        }
    }
    /**
     * 添加复制评论统计
     */
    @Override
    public void addCopyComment() {
        try {
            BigDecimal num = new BigDecimal(1);
            // 当日日期
            String toDay = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
            String id = StringUtil.Md5(toDay + DailyCountMomentsEnum.copyComment.name());
            DailyCountMoments moments = dailyCountMomentsDao.get(id);
            if (moments != null) {
                moments.setTotal(MoneyBigDecimalUtil.add(moments.getTotal(), num));
                moments.setUpdateDate(new Date());
                dailyCountMomentsDao.save(moments);
            } else {
                moments = new DailyCountMoments();
                moments.setId(id);
                moments.setTotal(num);
                moments.setType(DailyCountMomentsEnum.copyComment);
                moments.setUpdateDate(new Date());
                moments.setDay(TimeUtil.parse(toDay));
                dailyCountMomentsDao.save(moments);
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogHelper.error(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1856,7 +1856,9 @@
                if (sourceType.equals(commonOrder.getSourceType()) && orderNo.equals(commonOrder.getOrderNo())) {
                    CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO();
                    PropertyUtils.copyProperties(commonGoodsVO, goods);
                    commonGoodsVO.setGoodsType(sourceType);
                    if (commonGoodsVO.getGoodsType() == null) {
                        commonGoodsVO.setGoodsType(sourceType);
                    }
                    // 淘宝商品图片处理
                    String picture = commonGoodsVO.getPicture();
@@ -1888,24 +1890,35 @@
                    }
                    // 订单类型为空时 已商品类为准
                    Integer orderType = order.getOrderType();
                    if (orderType == null) {
                        String shopType = commonGoodsVO.getShopType();
                        if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) {
                            order.setOrderType(1);
                        } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                            order.setOrderType(2);
                        }
                    String shopType = commonGoodsVO.getShopType();
                    if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) {
                        order.setOrderType(1);
                    } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                        order.setOrderType(2);
                    }
                    
                    Integer goodsType = commonGoodsVO.getGoodsType();
                    if (goodsType != null & goodsType == 6) {
                        order.setOrderType(5); // 饿了么订单
                    if (goodsType != null & goodsType == Constant.SOURCE_TYPE_ELME) {
                        order.setOrderType(Constant.SOURCE_TYPE_ELME); // 饿了么订单
                    }
                    order.getListOrderGoods().add(commonGoodsVO);
                }
            }
            // 订单类型
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                Integer orderType = order.getOrderType();
                if (orderType == null) {
                    order.setOrderType(1);
                }
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
                order.setOrderType(3);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
                order.setOrderType(4);
            }
            Date thirdCreateTime = order.getThirdCreateTime();
            if (thirdCreateTime != null) {
@@ -1918,16 +1931,6 @@
                order.setReceiveTime("收货时间:" + format.format(settleTime));
            }
            // 订单类型
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                Integer orderType = order.getOrderType();
                if (orderType == null)
                    order.setOrderType(1);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
                order.setOrderType(3);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
                order.setOrderType(4);
            }
            /* 订单状态 转换处理 */
            String orderStateContent = "";
@@ -1978,7 +1981,6 @@
                    List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                            .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
                    boolean isPart = false;// 默认失效
                    BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
                    if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) {
                        orderStateContent = "售后成功";
fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
@@ -168,11 +168,11 @@
    public void applyVIP(Long uid) throws UserVIPInfoException {
        UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid);
        if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) {
            throw new UserVIPInfoException(1, "该用户还不是高级会员");
            throw new UserVIPInfoException(1, "请先升级为高级会员");
        }
        if (!verifyVip(uid))
            throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
            throw new UserVIPInfoException(1, "不满足升级条件");
        UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
        if (userInfo == null) {
fanli/src/main/java/com/yeshi/fanli/service/inter/count/DailyCountMomentsService.java
New file
@@ -0,0 +1,39 @@
package com.yeshi.fanli.service.inter.count;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.admin.count.DailyCountMoments;
public interface DailyCountMomentsService {
    /**
     * 查询统计
     * @param type
     * @param startTime
     * @param endTime
     * @param channel
     * @return
     * @throws Exception
     */
    public List<DailyCountMoments> getDailyCountList(String type, Date startTime, Date endTime) throws Exception;
    /**
     * 获取类型说明
     * @param type
     * @return
     */
    public String getTypeEnumDesc(String type);
    /**
     * 添加分享次数
     */
    public void addShareClick();
    /**
     * 添加复制评论
     */
    public void addCopyComment();
}