yujian
2019-09-25 011d53f9f3d08af8cd622585ce40eb880f313aaf
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserOrderController.java
@@ -3,6 +3,9 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -21,6 +24,7 @@
import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -42,6 +46,7 @@
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -110,8 +115,9 @@
    */
   @RequestMapping(value = "getorder", method = RequestMethod.POST)
   public void getOrder(AcceptData acceptData, Integer page, Long uid, Integer state,
         @RequestParam(name = "type",required = false) String type1, Integer orderState, String orderNo, String startTime, String endTime,
         Integer slotTime, Boolean needCount, Integer dateType, Integer goodsType, PrintWriter out) {
         @RequestParam(name = "type", required = false) String type1, Integer orderState, String orderNo,
         String startTime, String endTime, Integer slotTime, Boolean needCount, Integer dateType, Integer goodsType,
         PrintWriter out) {
      Integer type = null;
      
      if (StringUtil.isNullOrEmpty(type1)) {
@@ -187,8 +193,8 @@
         BigDecimal todayMoney = null;
         // 查询列表
         List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, type, orderState, orderNo,
               startTime, endTime, dateType, goodsType);
         List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, type, orderState,
               orderNo, startTime, endTime, dateType, goodsType);
         if (list != null && list.size() > 0) {
            // 统计总数
@@ -199,21 +205,23 @@
         // 需要统计筛选信息 :未失效的总金额 以及订单
         if (needCount && page == 1) {
            todayMoney = commonOrderService.countBonusOrderMoney(uid, type, dateType, startTime, endTime, goodsType);
            todayMoney = commonOrderService.countBonusOrderMoney(uid, type, dateType, startTime, endTime,
                  goodsType);
            todayTotal = commonOrderService.countBonusOrderNumber(uid, type, dateType, startTime, endTime, goodsType);
            todayTotal = commonOrderService.countBonusOrderNumber(uid, type, dateType, startTime, endTime,
                  goodsType);
            // 有效订单
            totalValid = commonOrderService.countUserOrderToApp(uid, type, startTime,
                  endTime, dateType, goodsType, tempState, 1);
            totalValid = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                  tempState, 1);
            
            // 维权订单
            totalProces = commonOrderService.countUserOrderToApp(uid, type, startTime,
                  endTime, dateType, goodsType, null, 2);
            totalProces = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                  null, 2);
            
            // 失效订单
            totalInvite = commonOrderService.countUserOrderToApp(uid, type, startTime,
                  endTime, dateType, goodsType, null, 3);
            totalInvite = commonOrderService.countUserOrderToApp(uid, type, startTime, endTime, dateType, goodsType,
                  null, 3);
         }
         if (todayMoney == null) {
@@ -393,9 +401,9 @@
      }
   }
   
   /**
    * 统计各个平台数据
    *
    * @param acceptData
    * @param uid
    * @param goodsType
@@ -470,7 +478,6 @@
      out.print(JsonUtil.loadTrueResult(data));
   }
   
   /**
    * 统计奖金
    * 
@@ -480,24 +487,46 @@
    */
   @RequestMapping(value = "countBonus", method = RequestMethod.POST)
   public void countBonus(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
      if (uid == null) {
         out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
         return;
      }
      try {
      long nowTime = System.currentTimeMillis();
      long recievedTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyy-MM") + "-25 10",
            "yyyy-MM-dd HH");
      try {
         Object shareCount = 0;
         BigDecimal sharemoney = new BigDecimal(0.00);
         Object inviteCount = 0;
         BigDecimal inviteMoney = new BigDecimal(0.00);
         
         if (nowTime > recievedTime && dateType == 4) {// 实际到账
            List<Integer> inviteTypes = new ArrayList<>();
            inviteTypes.add(HongBaoV2.TYPE_YIJI);
            inviteTypes.add(HongBaoV2.TYPE_ERJI);
            inviteTypes.add(HongBaoV2.TYPE_SHARE_YIJI);
            inviteTypes.add(HongBaoV2.TYPE_SHARE_ERJI);
            List<Integer> shareTypes = new ArrayList<>();
            shareTypes.add(HongBaoV2.TYPE_SHARE_GOODS);
            Date minGetTime = new Date(
                  TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyy-MM") + "-25", "yyyy-MM-dd"));
            Date maxGetTime = new Date(nowTime);
            inviteMoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
            inviteCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, inviteTypes, minGetTime, maxGetTime);
            sharemoney = hongBaoV2CountService.sumAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
            shareCount = hongBaoV2CountService.countAlreadyGetMoneyByUid(uid, shareTypes, minGetTime, maxGetTime);
         } else {// 预估到账
         Integer goodsType = null; // 版本区分
         if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
            goodsType = Constant.SOURCE_TYPE_TAOBAO;
         } 
         Map<String, Object> shareMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 2, dateType, null,
               null, goodsType);
         if (shareMap != null) {
@@ -513,6 +542,7 @@
         }
         // 邀请统计
         Map<String, Object> inviteMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 3, dateType, null,
               null, goodsType);
         if (inviteMap != null) {
@@ -526,6 +556,7 @@
               inviteMoney = (BigDecimal) totalmoney;
            }
         }
         }
         JSONObject data = new JSONObject();
         data.put("shareCount", shareCount);