| | |
| | | package com.yeshi.fanli.service.impl.count;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.count.DailyCountOrderDao;
|
| | | import com.yeshi.fanli.dto.order.CountOrderDTO;
|
| | | import com.yeshi.fanli.entity.admin.count.DailyCountOrder;
|
| | | import com.yeshi.fanli.entity.admin.count.DailyCountOrder.DailyCountOrderEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.LostOrder;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoRegister;
|
| | | import com.yeshi.fanli.entity.system.ChannelEnum;
|
| | | import com.yeshi.fanli.service.inter.count.DailyCountOrderService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.UserOrderWeiQuanRecordService;
|
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoRegisterService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | @Service
|
| | | public class DailyCountOrderServiceImpl implements DailyCountOrderService {
|
| | |
|
| | | @Resource
|
| | | private DailyCountOrderDao dailyCountOrderDao;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderCountService commonOrderCountService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoRegisterService userInfoRegisterService;
|
| | |
|
| | | @Resource
|
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private JDOrderService jdOrderService;
|
| | |
|
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Override
|
| | | public List<DailyCountOrder> getDailyCountList(String type, Date startTime, Date endTime, String channel)
|
| | | throws Exception {
|
| | | // 查询类型
|
| | | DailyCountOrderEnum typeEnum = getTypeEnum(type);
|
| | | if (typeEnum == null) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 初始化数据
|
| | | initData(typeEnum);
|
| | |
|
| | | return dailyCountOrderDao.query(typeEnum, startTime, endTime, channel);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取枚举类型
|
| | | * |
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | private DailyCountOrderEnum getTypeEnum(String name) {
|
| | | if (StringUtil.isNullOrEmpty(name)) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | DailyCountOrderEnum[] array = DailyCountOrderEnum.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 "";
|
| | | }
|
| | |
|
| | | DailyCountOrderEnum[] array = DailyCountOrderEnum.values();
|
| | | for (int i = 0; i < array.length; i++) {
|
| | | if (array[i].name().equals(name)) {
|
| | | return array[i].getDesc();
|
| | | }
|
| | | }
|
| | |
|
| | | return "";
|
| | | }
|
| | |
|
| | | /**
|
| | | * 初始数据
|
| | | * |
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | @Override
|
| | | public void initData(DailyCountOrderEnum typeEnum) throws Exception {
|
| | | Date lastDate = null;
|
| | | DailyCountOrder lastRecord = dailyCountOrderDao.getMaxDate(typeEnum);
|
| | | if (lastRecord != null) {
|
| | | lastDate = lastRecord.getUpdateDate();
|
| | | } else {
|
| | | lastDate = TimeUtil.parse("2018-01-20");
|
| | | }
|
| | |
|
| | | long min = DateUtil.dateDiffMin(lastDate, new Date());
|
| | | if (min <= 10) { // 10分钟以内不统计
|
| | | return;
|
| | | }
|
| | |
|
| | | Date today = new Date();
|
| | | int betweenDays = DateUtil.daysBetween2(lastDate, today);
|
| | | for (int i = 0; i <= betweenDays; i++) {
|
| | | // 计算日期
|
| | | String preDay = DateUtil.plusDay(i, lastDate);
|
| | | // 统计数据
|
| | | if (DailyCountOrderEnum.fanliOrderNum == typeEnum) {
|
| | | addOrderNumCount(preDay, typeEnum, 1);
|
| | | } else if (DailyCountOrderEnum.shareOrderNum == typeEnum) {
|
| | | addOrderNumCount(preDay, typeEnum, 2);
|
| | | } else if (DailyCountOrderEnum.inviteOrderNum == typeEnum) {
|
| | | addOrderNumCount(preDay, typeEnum, 3);
|
| | | } else if (DailyCountOrderEnum.channelOrderNum24H == typeEnum) {
|
| | | addChannelOrderNum24H(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.channelOrderNum == typeEnum) {
|
| | | addChannelOrderNum(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.channelOrderMoney == typeEnum) {
|
| | | addChannelOrderMoney(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.weiQuanOrderNum == typeEnum) {
|
| | | addWeiQuanOrderNum(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.weiQuanOrderMoney == typeEnum) {
|
| | | addWeiQuanOrderMoney(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.tbOrderTrackRate == typeEnum) {
|
| | | addTBOrderTrackRate(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.jdOrderTrackRate == typeEnum) {
|
| | | addJDOrderTrackRate(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.pddOrderTrackRate == typeEnum) {
|
| | | addPDDOrderTrackRate(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.lastOrderUntreatedNum == typeEnum) {
|
| | | addLastOrderUntreatedNum(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.lastOrderSucceedNum == typeEnum) {
|
| | | addLastOrderSucceedNum(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.lastOrderFailNum == typeEnum) {
|
| | | addLastOrderFailNum(preDay, typeEnum);
|
| | | } else if (DailyCountOrderEnum.lastOrderSucceedMoney == typeEnum) {
|
| | | addLastOrderSucceedMoney(preDay, typeEnum);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计订单数量
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @param orderType
|
| | | * @throws Exception
|
| | | */
|
| | | private void addOrderNumCount(String preDay, DailyCountOrderEnum typeEnum, int orderType) throws Exception {
|
| | | Long count = hongBaoV2CountService.countOrderByTypeAndDate(orderType, preDay);
|
| | | if (count == null)
|
| | | count = 0L;
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(count));
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计各个渠道订单数据
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addChannelOrderNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | List<UserInfoRegister> listRegister = null;
|
| | | // 统计当日订单
|
| | | List<CountOrderDTO> listOrder = commonOrderCountService.countValidOrderByDay(preDay);
|
| | |
|
| | | if (listOrder != null && listOrder.size() > 0) {
|
| | | List<Long> listUid = new ArrayList<>();
|
| | | for (CountOrderDTO countOrderDTO : listOrder) {
|
| | | listUid.add(countOrderDTO.getUid());
|
| | | }
|
| | | listRegister = userInfoRegisterService.listByMultipleUids(listUid);
|
| | | }
|
| | |
|
| | | // 统计各个渠道
|
| | | ChannelEnum[] channels = ChannelEnum.values();
|
| | | for (int i = 0; i < channels.length; i++) {
|
| | | long count = 0;
|
| | | String channelVlaue = channels[i].getVlaue();
|
| | | if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) {
|
| | | for (CountOrderDTO dto : listOrder) {
|
| | | Long orderUid = dto.getUid();
|
| | | if (orderUid == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | for (UserInfoRegister register : listRegister) {
|
| | | Long uid = register.getId();
|
| | | String vlaue = register.getChannel();
|
| | | // 渠道 、用户id匹配
|
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == orderUid.longValue()) {
|
| | | count++;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(count));
|
| | | obj.setType(typeEnum);
|
| | | obj.setChannel(channels[i].name());
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计新人24H内下单数量
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addChannelOrderNum24H(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | ChannelEnum[] channels = ChannelEnum.values();
|
| | | for (int i = 0; i < channels.length; i++) {
|
| | | int count = 0;
|
| | |
|
| | | List<UserInfoRegister> list = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (UserInfoRegister user : list) {
|
| | | Date limitDay = DateUtil.plusDayDate(1, user.getCreateTime());
|
| | | Integer total = commonOrderCountService.countOderByUidAndDate(limitDay, user.getId());
|
| | | if (total != null)
|
| | | count += total;
|
| | | }
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(count));
|
| | | obj.setType(typeEnum);
|
| | | obj.setChannel(channels[i].name());
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计渠道金额
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addChannelOrderMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | List<UserInfoRegister> listRegister = null;
|
| | | // 查询订单佣金
|
| | | List<CountOrderDTO> listOrder = commonOrderCountService.countCommissionByDay(preDay);
|
| | |
|
| | | if (listOrder != null && listOrder.size() > 0) {
|
| | | List<Long> listUid = new ArrayList<>();
|
| | | for (CountOrderDTO countOrderDTO : listOrder) {
|
| | | listUid.add(countOrderDTO.getUid());
|
| | | }
|
| | | listRegister = userInfoRegisterService.listByMultipleUids(listUid);
|
| | | }
|
| | |
|
| | | ChannelEnum[] channels = ChannelEnum.values();
|
| | | for (int i = 0; i < channels.length; i++) {
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | String channelVlaue = channels[i].getVlaue();
|
| | |
|
| | | if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) {
|
| | | for (CountOrderDTO dto : listOrder) {
|
| | | Long orderUid = dto.getUid();
|
| | | BigDecimal commission = dto.getCommission();
|
| | | if (commission == null || orderUid == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | for (UserInfoRegister register : listRegister) {
|
| | | Long uid = register.getId();
|
| | | String vlaue = register.getChannel();
|
| | | // 渠道 、用户id匹配
|
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == orderUid.longValue()) {
|
| | | money = MoneyBigDecimalUtil.add(money, commission);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(money);
|
| | | obj.setType(typeEnum);
|
| | | obj.setChannel(channels[i].name());
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计维权订单数量
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addWeiQuanOrderNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | Integer count = userOrderWeiQuanRecordService.countWeiQaunOrderNumberByDate(preDay);
|
| | | if (count == null)
|
| | | count = 0;
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(count));
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询维权金额
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addWeiQuanOrderMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | BigDecimal money = userOrderWeiQuanRecordService.countWeiQaunOrderMoneyByDate(preDay);
|
| | | if (money == null)
|
| | | money = new BigDecimal(0);
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(money);
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝订单跟踪率
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addTBOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | // 统计跟踪到数据
|
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_TAOBAO, preDay);
|
| | |
|
| | | Long total = taoBaoOrderService.countOrderByDay(preDay);
|
| | |
|
| | | // 计算比例
|
| | | BigDecimal rate = new BigDecimal(0);
|
| | | if (total != null && total > 0 && count != null && count > 0) {
|
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total));
|
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100));
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setRate(true);
|
| | | obj.setTotalDay(BigDecimal.valueOf(total));
|
| | | obj.setTotalValid(BigDecimal.valueOf(count));
|
| | | obj.setTotal(rate);
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东订单跟踪率
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addJDOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | // 统计跟踪到数据
|
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_JD, preDay);
|
| | |
|
| | | Long total = jdOrderService.countOrderByDay(preDay);
|
| | |
|
| | | // 计算比例
|
| | | BigDecimal rate = new BigDecimal(0);
|
| | | if (total != null && total > 0 && count != null && count > 0) {
|
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total));
|
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100));
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setRate(true);
|
| | | obj.setTotalDay(BigDecimal.valueOf(total));
|
| | | obj.setTotalValid(BigDecimal.valueOf(count));
|
| | | obj.setTotal(rate);
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多订单跟踪率
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addPDDOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | // 统计跟踪到数据
|
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_PDD, preDay);
|
| | |
|
| | | Long total = pddOrderService.countOrderByDay(preDay);
|
| | | // 计算比例
|
| | | BigDecimal rate = new BigDecimal(0);
|
| | | if (total != null && total > 0 && count != null && count > 0) {
|
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total));
|
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100));
|
| | | }
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setRate(true);
|
| | | obj.setTotalDay(BigDecimal.valueOf(total));
|
| | | obj.setTotalValid(BigDecimal.valueOf(count));
|
| | | obj.setTotal(rate);
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计申诉订单未处理数量
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addLastOrderUntreatedNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_VERFING);
|
| | | if (num == null)
|
| | | num = 0;
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(num));
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计申诉订单 处理失败
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addLastOrderFailNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_FAIL);
|
| | | if (num == null)
|
| | | num = 0;
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(num));
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计申诉订单 处理成功
|
| | | * |
| | | * @param preDay
|
| | | * @param typeEnum
|
| | | * @throws Exception
|
| | | */
|
| | | private void addLastOrderSucceedNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_SUCCESS);
|
| | | if (num == null)
|
| | | num = 0;
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(BigDecimal.valueOf(num));
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单找回成功统计金额
|
| | | * |
| | | * @param preDay
|
| | | * @throws Exception
|
| | | */
|
| | | private void addLastOrderSucceedMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception {
|
| | | BigDecimal money = lostOrderService.countAppealMoney(preDay);
|
| | | if (money == null)
|
| | | money = new BigDecimal("0");
|
| | |
|
| | | DailyCountOrder obj = new DailyCountOrder();
|
| | | obj.setTotal(money);
|
| | | obj.setType(typeEnum);
|
| | | obj.setUpdateDate(new Date());
|
| | | obj.setDay(TimeUtil.parse(preDay));
|
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name()));
|
| | | dailyCountOrderDao.save(obj);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.count; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.DateUtil; |
| | | |
| | | import com.yeshi.fanli.dao.user.count.DailyCountOrderDao; |
| | | import com.yeshi.fanli.dto.order.CountOrderDTO; |
| | | import com.yeshi.fanli.entity.admin.count.DailyCountOrder; |
| | | import com.yeshi.fanli.entity.admin.count.DailyCountOrder.DailyCountOrderEnum; |
| | | import com.yeshi.fanli.entity.bus.user.LostOrder; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoRegister; |
| | | import com.yeshi.fanli.entity.system.ChannelEnum; |
| | | import com.yeshi.fanli.service.inter.count.DailyCountOrderService; |
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService; |
| | | import com.yeshi.fanli.service.inter.order.LostOrderService; |
| | | import com.yeshi.fanli.service.inter.order.UserOrderWeiQuanRecordService; |
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoRegisterService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | @Service |
| | | public class DailyCountOrderServiceImpl implements DailyCountOrderService { |
| | | |
| | | @Resource |
| | | private DailyCountOrderDao dailyCountOrderDao; |
| | | |
| | | @Resource |
| | | private HongBaoV2CountService hongBaoV2CountService; |
| | | |
| | | @Resource |
| | | private CommonOrderCountService commonOrderCountService; |
| | | |
| | | @Resource |
| | | private UserInfoRegisterService userInfoRegisterService; |
| | | |
| | | @Resource |
| | | private UserOrderWeiQuanRecordService userOrderWeiQuanRecordService; |
| | | |
| | | @Resource |
| | | private TaoBaoOrderService taoBaoOrderService; |
| | | |
| | | @Resource |
| | | private JDOrderService jdOrderService; |
| | | |
| | | @Resource |
| | | private PDDOrderService pddOrderService; |
| | | |
| | | @Resource |
| | | private LostOrderService lostOrderService; |
| | | |
| | | @Override |
| | | public List<DailyCountOrder> getDailyCountList(String type, Date startTime, Date endTime, String channel) |
| | | throws Exception { |
| | | // 查询类型 |
| | | DailyCountOrderEnum typeEnum = getTypeEnum(type); |
| | | if (typeEnum == null) { |
| | | return null; |
| | | } |
| | | |
| | | // 初始化数据 |
| | | initData(typeEnum); |
| | | |
| | | return dailyCountOrderDao.query(typeEnum, startTime, endTime, channel); |
| | | } |
| | | |
| | | /** |
| | | * 获取枚举类型 |
| | | * |
| | | * @param type |
| | | * @return |
| | | */ |
| | | private DailyCountOrderEnum getTypeEnum(String name) { |
| | | if (StringUtil.isNullOrEmpty(name)) { |
| | | return null; |
| | | } |
| | | |
| | | DailyCountOrderEnum[] array = DailyCountOrderEnum.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 ""; |
| | | } |
| | | |
| | | DailyCountOrderEnum[] array = DailyCountOrderEnum.values(); |
| | | for (int i = 0; i < array.length; i++) { |
| | | if (array[i].name().equals(name)) { |
| | | return array[i].getDesc(); |
| | | } |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 初始数据 |
| | | * |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void initData(DailyCountOrderEnum typeEnum) throws Exception { |
| | | Date lastDate = null; |
| | | DailyCountOrder lastRecord = dailyCountOrderDao.getMaxDate(typeEnum); |
| | | if (lastRecord != null) { |
| | | lastDate = lastRecord.getUpdateDate(); |
| | | } else { |
| | | lastDate = TimeUtil.parse("2018-01-20"); |
| | | } |
| | | |
| | | long min = DateUtil.dateDiffMin(lastDate, new Date()); |
| | | if (min <= 10) { // 10分钟以内不统计 |
| | | return; |
| | | } |
| | | |
| | | Date today = new Date(); |
| | | int betweenDays = DateUtil.daysBetween2(lastDate, today); |
| | | for (int i = 0; i <= betweenDays; i++) { |
| | | // 计算日期 |
| | | String preDay = DateUtil.plusDay(i, lastDate); |
| | | // 统计数据 |
| | | if (DailyCountOrderEnum.fanliOrderNum == typeEnum) { |
| | | addOrderNumCount(preDay, typeEnum, 1); |
| | | } else if (DailyCountOrderEnum.shareOrderNum == typeEnum) { |
| | | addOrderNumCount(preDay, typeEnum, 2); |
| | | } else if (DailyCountOrderEnum.inviteOrderNum == typeEnum) { |
| | | addOrderNumCount(preDay, typeEnum, 3); |
| | | } else if (DailyCountOrderEnum.channelOrderNum24H == typeEnum) { |
| | | addChannelOrderNum24H(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.channelOrderNum == typeEnum) { |
| | | addChannelOrderNum(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.channelOrderMoney == typeEnum) { |
| | | addChannelOrderMoney(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.weiQuanOrderNum == typeEnum) { |
| | | addWeiQuanOrderNum(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.weiQuanOrderMoney == typeEnum) { |
| | | addWeiQuanOrderMoney(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.tbOrderTrackRate == typeEnum) { |
| | | addTBOrderTrackRate(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.jdOrderTrackRate == typeEnum) { |
| | | addJDOrderTrackRate(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.pddOrderTrackRate == typeEnum) { |
| | | addPDDOrderTrackRate(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.lastOrderUntreatedNum == typeEnum) { |
| | | addLastOrderUntreatedNum(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.lastOrderSucceedNum == typeEnum) { |
| | | addLastOrderSucceedNum(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.lastOrderFailNum == typeEnum) { |
| | | addLastOrderFailNum(preDay, typeEnum); |
| | | } else if (DailyCountOrderEnum.lastOrderSucceedMoney == typeEnum) { |
| | | addLastOrderSucceedMoney(preDay, typeEnum); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计订单数量 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @param orderType |
| | | * @throws Exception |
| | | */ |
| | | private void addOrderNumCount(String preDay, DailyCountOrderEnum typeEnum, int orderType) throws Exception { |
| | | Long count = hongBaoV2CountService.countOrderByTypeAndDate(orderType, preDay); |
| | | if (count == null) |
| | | count = 0L; |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(count)); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 统计各个渠道订单数据 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addChannelOrderNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | List<UserInfoRegister> listRegister = null; |
| | | // 统计当日订单 |
| | | List<CountOrderDTO> listOrder = commonOrderCountService.countValidOrderByDay(preDay); |
| | | |
| | | if (listOrder != null && listOrder.size() > 0) { |
| | | List<Long> listUid = new ArrayList<>(); |
| | | for (CountOrderDTO countOrderDTO : listOrder) { |
| | | listUid.add(countOrderDTO.getUid()); |
| | | } |
| | | listRegister = userInfoRegisterService.listByMultipleUids(listUid); |
| | | } |
| | | |
| | | // 统计各个渠道 |
| | | ChannelEnum[] channels = ChannelEnum.values(); |
| | | for (int i = 0; i < channels.length; i++) { |
| | | long count = 0; |
| | | String channelVlaue = channels[i].getVlaue(); |
| | | if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) { |
| | | for (CountOrderDTO dto : listOrder) { |
| | | Long orderUid = dto.getUid(); |
| | | if (orderUid == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (UserInfoRegister register : listRegister) { |
| | | Long uid = register.getId(); |
| | | String vlaue = register.getChannel(); |
| | | // 渠道 、用户id匹配 |
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == orderUid.longValue()) { |
| | | count++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(count)); |
| | | obj.setType(typeEnum); |
| | | obj.setChannel(channels[i].name()); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计新人24H内下单数量 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addChannelOrderNum24H(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | ChannelEnum[] channels = ChannelEnum.values(); |
| | | for (int i = 0; i < channels.length; i++) { |
| | | int count = 0; |
| | | |
| | | List<UserInfoRegister> list = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay); |
| | | if (list != null && list.size() > 0) { |
| | | for (UserInfoRegister user : list) { |
| | | Date limitDay = DateUtil.plusDayDate(1, user.getCreateTime()); |
| | | Integer total = commonOrderCountService.countOderByUidAndDate(limitDay, user.getId()); |
| | | if (total != null) |
| | | count += total; |
| | | } |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(count)); |
| | | obj.setType(typeEnum); |
| | | obj.setChannel(channels[i].name()); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计渠道金额 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | public void addChannelOrderMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | List<UserInfoRegister> listRegister = null; |
| | | // 查询订单佣金 |
| | | List<CountOrderDTO> listOrder = commonOrderCountService.countCommissionByDay(preDay); |
| | | |
| | | if (listOrder != null && listOrder.size() > 0) { |
| | | List<Long> listUid = new ArrayList<>(); |
| | | for (CountOrderDTO countOrderDTO : listOrder) { |
| | | listUid.add(countOrderDTO.getUid()); |
| | | } |
| | | listRegister = userInfoRegisterService.listByMultipleUids(listUid); |
| | | } |
| | | |
| | | ChannelEnum[] channels = ChannelEnum.values(); |
| | | for (int i = 0; i < channels.length; i++) { |
| | | BigDecimal money = new BigDecimal(0); |
| | | String channelVlaue = channels[i].getVlaue(); |
| | | |
| | | if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) { |
| | | for (CountOrderDTO dto : listOrder) { |
| | | Long orderUid = dto.getUid(); |
| | | BigDecimal commission = dto.getCommission(); |
| | | if (commission == null || orderUid == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (UserInfoRegister register : listRegister) { |
| | | Long uid = register.getId(); |
| | | String vlaue = register.getChannel(); |
| | | // 渠道 、用户id匹配 |
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == orderUid.longValue()) { |
| | | money = MoneyBigDecimalUtil.add(money, commission); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(money); |
| | | obj.setType(typeEnum); |
| | | obj.setChannel(channels[i].name()); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计维权订单数量 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addWeiQuanOrderNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | Integer count = userOrderWeiQuanRecordService.countWeiQaunOrderNumberByDate(preDay); |
| | | if (count == null) |
| | | count = 0; |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(count)); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 查询维权金额 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addWeiQuanOrderMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | BigDecimal money = userOrderWeiQuanRecordService.countWeiQaunOrderMoneyByDate(preDay); |
| | | if (money == null) |
| | | money = new BigDecimal(0); |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(money); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 淘宝订单跟踪率 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addTBOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | // 统计跟踪到数据 |
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_TAOBAO, preDay); |
| | | |
| | | Long total = taoBaoOrderService.countOrderByDay(preDay); |
| | | |
| | | // 计算比例 |
| | | BigDecimal rate = new BigDecimal(0); |
| | | if (total != null && total > 0 && count != null && count > 0) { |
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total)); |
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100)); |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setRate(true); |
| | | obj.setTotalDay(BigDecimal.valueOf(total)); |
| | | obj.setTotalValid(BigDecimal.valueOf(count)); |
| | | obj.setTotal(rate); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 京东订单跟踪率 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addJDOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | // 统计跟踪到数据 |
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_JD, preDay); |
| | | |
| | | Long total = jdOrderService.countOrderByDay(preDay); |
| | | |
| | | // 计算比例 |
| | | BigDecimal rate = new BigDecimal(0); |
| | | if (total != null && total > 0 && count != null && count > 0) { |
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total)); |
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100)); |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setRate(true); |
| | | obj.setTotalDay(BigDecimal.valueOf(total)); |
| | | obj.setTotalValid(BigDecimal.valueOf(count)); |
| | | obj.setTotal(rate); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 拼多多订单跟踪率 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addPDDOrderTrackRate(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | // 统计跟踪到数据 |
| | | Long count = commonOrderCountService.countOrderBySourceTypeAndDay(Constant.SOURCE_TYPE_PDD, preDay); |
| | | |
| | | Long total = pddOrderService.countOrderByDay(preDay); |
| | | // 计算比例 |
| | | BigDecimal rate = new BigDecimal(0); |
| | | if (total != null && total > 0 && count != null && count > 0) { |
| | | rate = MoneyBigDecimalUtil.div(BigDecimal.valueOf(count), BigDecimal.valueOf(total)); |
| | | rate = MoneyBigDecimalUtil.mul(rate, BigDecimal.valueOf(100)); |
| | | } |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setRate(true); |
| | | obj.setTotalDay(BigDecimal.valueOf(total)); |
| | | obj.setTotalValid(BigDecimal.valueOf(count)); |
| | | obj.setTotal(rate); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 统计申诉订单未处理数量 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addLastOrderUntreatedNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_VERFING); |
| | | if (num == null) |
| | | num = 0; |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(num)); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 统计申诉订单 处理失败 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addLastOrderFailNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_FAIL); |
| | | if (num == null) |
| | | num = 0; |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(num)); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 统计申诉订单 处理成功 |
| | | * |
| | | * @param preDay |
| | | * @param typeEnum |
| | | * @throws Exception |
| | | */ |
| | | private void addLastOrderSucceedNum(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | Integer num = lostOrderService.countLostOrderNum(preDay, LostOrder.RESULT_CODE_SUCCESS); |
| | | if (num == null) |
| | | num = 0; |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(BigDecimal.valueOf(num)); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | |
| | | /** |
| | | * 订单找回成功统计金额 |
| | | * |
| | | * @param preDay |
| | | * @throws Exception |
| | | */ |
| | | private void addLastOrderSucceedMoney(String preDay, DailyCountOrderEnum typeEnum) throws Exception { |
| | | BigDecimal money = lostOrderService.countAppealMoney(preDay); |
| | | if (money == null) |
| | | money = new BigDecimal("0"); |
| | | |
| | | DailyCountOrder obj = new DailyCountOrder(); |
| | | obj.setTotal(money); |
| | | obj.setType(typeEnum); |
| | | obj.setUpdateDate(new Date()); |
| | | obj.setDay(TimeUtil.parse(preDay)); |
| | | obj.setId(StringUtil.Md5(preDay + typeEnum.name())); |
| | | dailyCountOrderDao.save(obj); |
| | | } |
| | | } |