From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 19 五月 2020 17:13:23 +0800 Subject: [PATCH] 饿了么绘图,添加口碑 --- fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java | 89 ++++++++++++++++++++++++++++---------------- 1 files changed, 56 insertions(+), 33 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java index 28cef8e..6ca537f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java @@ -3,15 +3,18 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; -import java.util.Map; import javax.annotation.Resource; +import org.apache.commons.beanutils.PropertyUtils; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponCountMapper; import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserSystemCoupon; import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord; +import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; +import com.yeshi.fanli.service.inter.config.SystemCouponService; import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; import com.yeshi.fanli.service.inter.count.UserSystemCouponCountService; import com.yeshi.fanli.service.inter.order.CommonOrderCountService; @@ -38,6 +41,9 @@ @Resource private HongBaoV2CountService hongBaoV2CountService; + + @Resource + private SystemCouponService systemCouponService; /** * 濂栧姳鍒哥粺璁� @@ -133,11 +139,13 @@ } for (SystemCouponVO systemCouponVO: list) { + BigDecimal money = null; + if (systemCouponVO.getType() != CouponTypeEnum.freeCouponGive) + money = userSystemCouponCountMapper.countFreeMoneyByCouponId(systemCouponVO.getId()); - BigDecimal money = userSystemCouponCountMapper.countFreeMoneyByCouponId(systemCouponVO.getId()); - if (money == null) { + if (money == null) money = new BigDecimal(0); - } + systemCouponVO.setMoney(money); } return list; @@ -179,7 +187,6 @@ orderMoney = new BigDecimal(0); } userSystemCouponVO.setOrderMoney(orderMoney); - } } @@ -197,36 +204,53 @@ public List<UserSystemCouponCountVO> listFreeCouponRecord(long start,int count, String key, Integer keyType, Integer state){ - List<UserSystemCouponCountVO> list = userSystemCouponCountMapper.listFreeCouponRecord(start, count, key, + List<UserSystemCouponRecord> list = userSystemCouponCountMapper.listFreeCouponRecord(start, count, key, keyType, state); - if (list == null ) { - list = new ArrayList<UserSystemCouponCountVO>(); + if (list == null || list.size() == 0) { + return null; } - for (UserSystemCouponCountVO userSystemCouponVO: list) { + List<UserSystemCouponCountVO> listvo = new ArrayList<UserSystemCouponCountVO>(); + + for (UserSystemCouponRecord couponRecord: list) { + + UserSystemCouponCountVO vo = new UserSystemCouponCountVO(); + UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon(); + try { + PropertyUtils.copyProperties(vo, userSystemCoupon); + } catch (Exception e) { + e.printStackTrace(); + } + + vo.setUserSystemCouponRecord(couponRecord); + +// SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon(); +// SystemCoupon baseCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId()); +// if (baseCoupon == null || baseCoupon.getId() == null) { +// continue; +// } +// vo.setSystemCoupon(baseCoupon); + // 鐢ㄦ埛淇℃伅 - Long uid = userSystemCouponVO.getUid(); + Long uid = userSystemCoupon.getUid(); UserInfo userInfo = userInfoService.selectByPKey(uid); if (userInfo == null) { userInfo = new UserInfo(); userInfo.setId(uid); } - userSystemCouponVO.setUserInfo(userInfo); + vo.setUserInfo(userInfo); - UserSystemCouponRecord couponRecord = userSystemCouponVO.getUserSystemCouponRecord(); - if (couponRecord != null) { - String orderNo = couponRecord.getOrderNo(); - BigDecimal orderMoney = commonOrderCountService.getMoneyByOrderNo(orderNo); - if (orderMoney == null) { - orderMoney = new BigDecimal(0); - } - userSystemCouponVO.setOrderMoney(orderMoney); - + String orderNo = couponRecord.getOrderNo(); + BigDecimal orderMoney = commonOrderCountService.getMoneyByOrderNo(orderNo); + if (orderMoney == null) { + orderMoney = new BigDecimal(0); } + vo.setOrderMoney(orderMoney); + + listvo.add(vo); } - - return list; + return listvo; } @@ -237,21 +261,20 @@ @Override - public List<Map<String, Object>> getRebateCouponUsedNumToCharts(Integer dateType, String year, - String startTime, String endTime){ - return userSystemCouponCountMapper.getRebateCouponUsedNumToCharts(dateType, year, startTime, endTime); + public BigDecimal countRebateMoneyByDay(String preDay){ + return userSystemCouponCountMapper.countRebateMoneyByDay(preDay); } - @Override - public List<Map<String, Object>> getRebateCouponMoneyToCharts(Integer dateType, String year, - String startTime, String endTime){ - return userSystemCouponCountMapper.getRebateCouponMoneyToCharts(dateType, year, startTime, endTime); - } @Override - public List<Map<String, Object>> getFreeCouponMoneyToCharts(Integer dateType, String year, String startTime, - String endTime, String couponType){ - return userSystemCouponCountMapper.getFreeCouponMoneyToCharts(dateType, year, startTime, endTime, couponType); + public BigDecimal countFreeMoneyByTypeAndDay(CouponTypeEnum typeEnum, String preDay){ + return userSystemCouponCountMapper.countFreeMoneyByTypeAndDay(typeEnum.name(), preDay); + } + + + @Override + public BigDecimal countCouponNumByDay(CouponTypeEnum typeEnum, String preDay){ + return userSystemCouponCountMapper.countCouponNumByDay(typeEnum.name(), preDay); } } -- Gitblit v1.8.0