admin
2018-12-25 4cb15e222cd7d099d533ccbeb7f9a8cd99bf180c
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -29,6 +29,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.admin.UserInfoAdmin;
import com.yeshi.fanli.entity.bus.user.AccountDetails;
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.MoneyRecord;
@@ -57,6 +58,7 @@
import com.yeshi.fanli.util.HongBaoUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import org.yeshi.utils.JsonUtil;
@Controller
@@ -1024,8 +1026,154 @@
      }
   }
   
   public static void main(String[] args) {
   /**
    * 队员关系
    * @param pageIndex
    * @param key
    * @param state
    * @param startTime
    * @param endTime
    * @param out
    */
   @RequestMapping(value = "getRelationList")
   public void getRelationList(String callback, Integer pageIndex, Integer pageSize, Long uid, Integer type,
         Integer state, String startTime, String endTime, PrintWriter out) {
      
      if (pageIndex == null || pageIndex < 1) {
         pageIndex = 1;
      }
      if (pageSize == null || pageSize < 1) {
         pageSize = Constant.PAGE_SIZE;
      }
      try {
         if (!StringUtil.isNullOrEmpty(endTime)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date enddate = sdf.parse(endTime);
            Calendar c = Calendar.getInstance();
            c.setTime(enddate);
            c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天
            endTime = sdf.format(c.getTime());
         }
         List<ThreeSale> listQuery = null;
         if (type == 0) {
            // 上级用户
            if (uid == null) {
               JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询上级需输入用户id"));
               return;
            }
            listQuery = threeSaleService.listSuperiorQuery((pageIndex - 1) * pageSize, pageSize, state, uid);
         } else if (type == 1) {
            // 一级用户
            listQuery = threeSaleService.listFirstTeamQuery((pageIndex - 1) * pageSize, pageSize, uid,
                  state, startTime, endTime);
         } else if (type == 2) {
            // 二级用户
            listQuery = threeSaleService.listSecondTeamQuery((pageIndex - 1) * pageSize, pageSize, uid,
                  state, startTime, endTime);
         }
         if (listQuery == null || listQuery.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
         }
         for (ThreeSale threeSale: listQuery) {
            Integer expire = threeSale.getExpire();
            if (threeSale.getState()) {
               threeSale.setExpire(1); // 邀请成功
            } else {
               if (expire != null && expire == 1) {
                  threeSale.setExpire(2); // 邀请失效
               } else {
                  threeSale.setExpire(0);// 已邀请
               }
            }
         }
         long count = 0;
         if (type == 0) {
            // 上级用户
            count = threeSaleService.countSuperiorQuery(state, uid);
         } else if (type == 1) {
            // 一级用户
            count = threeSaleService.countFirstTeamQuery(uid, state, startTime, endTime);
         } else if (type == 2) {
            // 二级用户
            count = threeSaleService.countSecondTeamQuery(uid, state, startTime, endTime);
         }
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
         JSONObject data = new JSONObject();
         data.put("pe", pe);
         data.put("result_list", listQuery);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
         e.printStackTrace();
      }
   }
   /**
    * 用户账户明细
    * @param callback
    * @param pageIndex
    * @param pageSize
    * @param id
    * @param out
    */
   @RequestMapping(value = "getAccountDetails")
   public void getAccountDetails(String callback, Integer pageIndex,Integer pageSize, Long uid, PrintWriter out) {
      if (pageIndex == null || pageIndex < 1) {
         pageIndex = 1;
      }
      if (pageSize == null || pageSize < 1) {
         pageSize = Constant.PAGE_SIZE;
      }
      if (uid == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确数据"));
         return;
      }
      try {
         List<AccountDetails> detailsList = accountDetailsService.findAccountDetailsList(uid, pageIndex);
         if (detailsList == null || detailsList.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
            return;
         }
         int count = accountDetailsService.getCount(uid);
         int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
         PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
         JSONObject data = new JSONObject();
         data.put("pe", pe);
         data.put("result_list", GsonUtil.toJsonExpose(detailsList));
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         e.printStackTrace();
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
      }
   }
   public static void main(String[] args) {
      java.lang.System.out.println(java.lang.System.currentTimeMillis());
   }