From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 15:58:24 +0800 Subject: [PATCH] 邀请码添加返回状态 --- fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java | 305 +++++++++++++++++++++++++++++--------------------- 1 files changed, 177 insertions(+), 128 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java index 3b98bc4..f604d7a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java @@ -2,13 +2,17 @@ import java.io.Serializable; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; + +import net.sf.json.JSONObject; import org.hibernate.HibernateException; import org.hibernate.Query; @@ -21,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import org.yeshi.utils.DateUtil; import com.yeshi.fanli.dao.hongbao.HongBaoDao; import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper; @@ -80,8 +85,6 @@ import com.yeshi.fanli.util.push.XiaoMiPushUtil; import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; - -import net.sf.json.JSONObject; @Service public class HongBaoServiceImpl implements HongBaoService { @@ -993,131 +996,6 @@ System.out.println("璁㈠崟:" + order); } - @Transactional - @Override - public void addHongBao(Order order, TaoBaoOrder taoBaoOrder, Long orderItemId) { - OrderItem orderItem = orderItemMapper.selectByPrimaryKey(orderItemId); - // 璁㈠崟杩斿埄姣斾緥 - BigDecimal proportion = hongBaoManageService.getFanLiRate(); - BigDecimal baseRate = proportion.divide(new BigDecimal(100)); - - // 鍒涘缓绾㈠寘 - JSONObject data = new JSONObject(); - HongBao hongBao = null; - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟缁撶畻")) - // 璁㈠崟缁撶畻搴旇鍙栫粨绠楅噾棰濅笌棰勪及鏀跺叆 - hongBao = HongBaoFactory.createHongBao(MoneyBigDecimalUtil.mul(baseRate, taoBaoOrder.geteIncome()), - data.toString(), order.getId(), null, order.getUserInfo(), 1, taoBaoOrder.getSettlement(), - taoBaoOrder.getAuctionId()); - else - hongBao = HongBaoFactory.createHongBao(MoneyBigDecimalUtil.mul(baseRate, taoBaoOrder.getEstimate()), - data.toString(), order.getId(), null, order.getUserInfo(), 1, taoBaoOrder.getPayment(), - taoBaoOrder.getAuctionId()); - - hongBao.setOrderId(taoBaoOrder.getOrderId()); - hongBao.setOrderItemId(orderItem.getId()); - hongBao.setPreGettime(0L); - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟缁撶畻") - && !StringUtil.isNullOrEmpty(taoBaoOrder.getSettlementTime())) - hongBao.setBalanceTime( - new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getSettlementTime(), "yyyy-MM-dd HH:mm:ss"))); - - UserInfo boss = threeSaleMapper.selectBoss(order.getUserInfo().getId()); - - if (boss != null) { - hongBao.setHasChild(true); - } - - // 濡傛灉澶辨晥灏卞垽瀹氬凡缁忓け鏁� - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟澶辨晥")) - hongBao.setState(HongBao.STATE_SHIXIAO); - - hongBaoMapper.insertSelective(hongBao); - // 閫氱煡鐢ㄦ埛璁㈠崟琚粺璁� - if (!taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟澶辨晥")) { - try { - userNotificationService.orderFanliStatisticed(hongBao.getUserInfo().getId(), order.getOrderId()); - } catch (Exception e) { - } - } - - // 鎻愭垚璁㈠崟涓嶅鐞嗗け鏁堣鍗� - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟澶辨晥")) - return; - if (boss != null) { - // 璁$畻涓婄骇杩斿埄閲戦 - HongBaoManage hbm = hongBaoManageMapper - .selectByKey("sale_6_" + (boss.getRank() == null ? 0 : boss.getRank())); - BigDecimal rate = null; - if (hbm == null) - rate = new BigDecimal(0); - else - rate = new BigDecimal(hbm.getValue()).divide(new BigDecimal(100)); - if (rate.compareTo(new BigDecimal(0)) > 0) { - HongBao hongBao2 = null; - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟缁撶畻")) { - // 璁㈠崟缁撶畻搴旇鍙栫粨绠楅噾棰濅笌棰勪及鏀跺叆 - hongBao2 = HongBaoFactory.createHongBao( - MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.geteIncome(), baseRate)), - null, hongBao, boss, Constant.ONESALE); - } else { - hongBao2 = HongBaoFactory.createHongBao( - MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)), - null, hongBao, boss, Constant.ONESALE); - } - - HongBaoFactory.createHongBao( - MoneyBigDecimalUtil.mul(rate, MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)), - null, hongBao, boss, Constant.ONESALE); - // 璁剧疆璁㈠崟鍙� - hongBao2.setOrderId(taoBaoOrder.getOrderId()); - - hongBaoMapper.insertSelective(hongBao2); - - try { - // 閫氱煡鎻愭垚璁㈠崟琚粺璁� - userNotificationService.tiChengStatisticed(hongBao2.getUserInfo().getId(), hongBao2.getOrderId(), - hongBao2.getMoney()); - } catch (Exception e) { - } - - } - - UserInfo boss2 = threeSaleMapper.selectBoss(boss.getId()); - // 璁$畻涓婁笂绾ц繑鍒� - if (boss2 != null) { - hbm = hongBaoManageMapper.selectByKey("sale_7_" + (boss.getRank() == null ? 0 : boss.getRank())); - if (hbm == null) - rate = new BigDecimal(0); - else - rate = new BigDecimal(hbm.getValue()).divide(new BigDecimal(100)); - if (rate.compareTo(new BigDecimal(0)) > 0) { - // 璁㈠崟缁撶畻搴旇鍙栫粨绠楅噾棰濅笌棰勪及鏀跺叆 - HongBao hongBao3 = null; - if (taoBaoOrder.getOrderState().equalsIgnoreCase("璁㈠崟缁撶畻")) - hongBao3 = HongBaoFactory.createHongBao( - MoneyBigDecimalUtil.mul(rate, - MoneyBigDecimalUtil.mul(taoBaoOrder.geteIncome(), baseRate)), - null, hongBao, boss2, Constant.TWOSALE); - else - hongBao3 = HongBaoFactory.createHongBao( - MoneyBigDecimalUtil.mul(rate, - MoneyBigDecimalUtil.mul(taoBaoOrder.getEstimate(), baseRate)), - null, hongBao, boss2, Constant.TWOSALE); - // 璁剧疆杩斿埄璁㈠崟鍙� - hongBao3.setOrderId(taoBaoOrder.getOrderId()); - hongBaoMapper.insertSelective(hongBao3); - - try { - // 閫氱煡鎻愭垚璁㈠崟琚粺璁� - userNotificationService.tiChengStatisticed(hongBao3.getUserInfo().getId(), - hongBao3.getOrderId(), hongBao3.getMoney()); - } catch (Exception e) { - } - } - } - } - } @Override public BigDecimal getTotalTiChengMoney(Long uid) { @@ -1226,8 +1104,179 @@ @Override public int getTotalTiChengCount(Long uid) { - return hongBaoMapper.getTotalTiChengCount(uid); } + + @Override + public List<Map<String, Object>> count24HOderByChannel(String channel, Integer type, String years, + String startTime, String endTime) throws Exception{ + return hongBaoMapper.count24HOderByChannel(channel, type, years, startTime, endTime); + } + + @Override + public List<Map<String, Object>> countHistoryOderByChannel(String channel, Integer type, String years, + String startTime, String endTime) throws Exception{ + + return hongBaoMapper.countHistoryOderByChannel(channel, type, years, + startTime, endTime); + } + + + public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception { + + List<Object> listObject = new ArrayList<Object>(); + + if (startTime.equals(endTime)) { + + Map<String, Object> map = list.get(0); + Object payMoney = map.get("payMoney"); + Object countOrder = map.get("countOrder"); + Object commision = map.get("commision"); + + if (payMoney == null) { + map.put("payMoney", 0); + } + if (countOrder == null) { + map.put("countOrder", 0); + } + if (commision == null) { + map.put("commision", 0); + } + listObject.add(map); + return listObject; + } + + + String plusDay = ""; + for (int i = 0; i < 1000 ; i++) { + if (i == 0) { + plusDay = startTime; + } else { + plusDay = DateUtil.plusDay(i, startTime); + } + + Map<String, Object> mapObject = new HashMap<String, Object>(); + Object payMoney = null; + Object countOrder = null; + Object commision = null; + + for (int j = 0; j < list.size(); j++) { + Map<String, Object> map = list.get(j); + Object createDate = map.get("showDate"); + String month = createDate.toString(); + if (plusDay.equalsIgnoreCase(month)) { + payMoney = map.get("payMoney"); + countOrder = map.get("countOrder"); + commision = map.get("commision"); + break; + } + } + + if (payMoney == null) { + payMoney = 0; + } + mapObject.put("payMoney", payMoney); + + if (countOrder == null) { + countOrder = 0; + } + mapObject.put("countOrder", countOrder); + + if (commision == null) { + commision = 0; + } + mapObject.put("commision", commision); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd"); + Date parseDate = sdf.parse(plusDay.toString()); + + mapObject.put("showDate", sdf2.format(parseDate)); + + listObject.add(mapObject); + + if (plusDay.equals(endTime)) { + break; // 鏃堕棿缁撴潫 + } + } + + return listObject; + } + + + public List<Object> monthFactory(List<Map<String, Object>> list) { + + List<Object> listObject = new ArrayList<Object>(); + // 12 涓湀澶勭悊 + for (int i = 1; i <= 12; i++) { + Map<String, Object> mapObject = new HashMap<String, Object>(); + Object payMoney = null; + Object countOrder = null; + Object commision = null; + + for (int j = 0; j < list.size(); j++) { + Map<String, Object> map = list.get(j); + Object createDate = map.get("showDate"); + String month = createDate.toString(); + if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) { + payMoney = map.get("payMoney"); + countOrder = map.get("countOrder"); + commision = map.get("commision"); + break; + } + } + + if (payMoney == null) { + payMoney = 0; + } + mapObject.put("payMoney", payMoney); + + if (countOrder == null) { + countOrder = 0; + } + mapObject.put("countOrder", countOrder); + + if (commision == null) { + commision = 0; + } + mapObject.put("commision", commision); + + mapObject.put("showDate", i + "鏈�"); + + listObject.add(mapObject); + } + return listObject; + } + + public List<Object> yearFactory(List<Map<String, Object>> list) { + + List<Object> listObject = new ArrayList<Object>(); + + for (int i = 0; i < list.size(); i++) { + Map<String, Object> map = list.get(i); + Object payMoney = map.get("payMoney"); + Object countOrder = map.get("countOrder"); + Object commision = map.get("commision"); + + if (payMoney == null) { + payMoney = 0; + } + map.put("payMoney", payMoney); + + if (countOrder == null) { + countOrder = 0; + } + map.put("countOrder", countOrder); + + if (commision == null) { + commision = 0; + } + map.put("commision", commision); + + listObject.add(map); + } + + return listObject; + } } -- Gitblit v1.8.0