yujian
2019-01-05 3590da403de193aa6bb7633d7526bd04f3821736
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -15,6 +15,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -40,7 +42,9 @@
import com.yeshi.fanli.exception.ObjectStateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.AdminUserService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.ExtractCountService;
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
import com.yeshi.fanli.service.inter.order.PidOrderService;
@@ -57,14 +61,18 @@
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/extract")
public class ExtractAdminController {
   @Resource
   private ExtractService extractService;
   @Resource
   private ConfigService configService;
   @Resource
   private UserInfoCountService userInfoCountService;
   @Resource
   private ExtractCountService extractCountService;
@@ -508,6 +516,23 @@
            if (adminUser == null) {
               record.setAdminUser(new AdminUser());
            }
            int warnLevel = 0;
            Extract extract = record.getExtract();
            if (extract != null) {
               Integer extractState = extract.getState();
               if (extractState != null && extractState == 0) {
                  UserInfo userInfo = extract.getUserInfo();
                  if (userInfo != null) {
                     double countTodayMoney = extractService.countTodayMoney(userInfo.getId());
                     if (countTodayMoney >= 100) {
                        warnLevel = 1;
                     }
                  }
               }
            }
            record.setWarnLevel(warnLevel);
         }
         int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days);
@@ -1009,7 +1034,11 @@
            String auctionIds = auctionIdBuf.toString();
            String ids = auctionIds.substring(0, auctionIds.length() - 1);
            goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids);
            try {
               goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids);
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
         List<Map<String, Object>> listResult = new ArrayList<Map<String, Object>>();
@@ -1060,7 +1089,7 @@
      } catch (Exception e) {
         e.printStackTrace();
         out.print(JsonUtil.loadFalseResult(e.getMessage()));
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
      }
   }
@@ -1263,7 +1292,7 @@
      } catch (Exception e) {
         e.printStackTrace();
         out.print(JsonUtil.loadFalseResult(e.getMessage()));
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
      }
   }
@@ -1394,4 +1423,185 @@
      }
   }
   /**
    * 统计审核次数
    * @param callback
    * @param state 审核状态:所有-空值或者不传  通过-1  拒绝- 2
    * @param type 统计类型  1-24小时  2-所有
    * @param dateType 类型  1日  2月  3年
    * @param year 2018
    * @param startTime 2018-12-01
    * @param endTime   2018-12-01
    * @param out
    */
   @RequestMapping(value = "getAuditTotal")
   public void getAuditTotal(String callback,Integer state, Integer shwoType, String year,
         String startTime, String endTime, PrintWriter out) {
      String validateMsg = validateParams(shwoType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
         startTime = null;
         endTime = null;
      }
      try {
         List<Map<String, Object>> resultList = extractAuditRecordService.countAuditTotal(state, shwoType,
               year, startTime, endTime);
         JSONObject data = new JSONObject();
         data.put("result_list", resultList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 统计提现申请总额
    * @param callback
    * @param state 所有-空值或者不传   待审核-0 通过-1  拒绝- 2
    * @param type 统计类型  1-24小时  2-所有
    * @param dateType 类型  1日  2月  3年
    * @param year 2018
    * @param startTime 2018-12-01
    * @param endTime   2018-12-01
    * @param out
    */
   @RequestMapping(value = "getExtractMoney")
   public void getExtractMoney(String callback,Integer state, Integer shwoType, String year,
         String startTime, String endTime, PrintWriter out) {
      String validateMsg = validateParams(shwoType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
         startTime = null;
         endTime = null;
      }
      try {
         List<Map<String, Object>> resultList = extractAuditRecordService.countExtractMoney(state, shwoType,
               year, startTime, endTime);
         JSONObject data = new JSONObject();
         data.put("result_list", resultList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 统计提现申请总次数
    * @param callback
    * @param state 所有-空值或者不传   待审核-0 通过-1  拒绝- 2
    * @param type 统计类型  1-24小时  2-所有
    * @param dateType 类型  1日  2月  3年
    * @param year 2018
    * @param startTime 2018-12-01
    * @param endTime   2018-12-01
    * @param out
    */
   @RequestMapping(value = "getExtractApplyNumber")
   public void getExtractApplyNumber(String callback,Integer state, Integer shwoType, String year,
         String startTime, String endTime, PrintWriter out) {
      String validateMsg = validateParams(shwoType, startTime, endTime);
      if (validateMsg != null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
         return;
      }
      if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
         startTime = null;
         endTime = null;
      }
      try {
         List<Map<String, Object>> resultList = extractAuditRecordService.countExtractApplyNumber(state, shwoType,
               year, startTime, endTime);
         JSONObject data = new JSONObject();
         data.put("result_list", resultList);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
         e.printStackTrace();
      }
   }
   /**
    * 统计资金信息
    *
    * @param out
    */
   @RequestMapping(value = "getMoneynfo")
   public void getHistoryInfo(String callback, PrintWriter out) {
      // 累计已提现金额总计:已提现成功的总额
      Map<String, Object> resultData = extractCountService.countTotalSuccess();
      // 当前用户余额总计:所有用户总余额
      BigDecimal amountMoney = userInfoCountService.countAllMoney(null);
      // 可提现金额限制
      String minMoney = configService.get(Constant.EXTRACT_MIN_MONEY);
      if (minMoney == null){
         minMoney = "0";
      }
      // 当前可提现金额总计: 超过最低提现金额---计入统计
      BigDecimal extractApply = userInfoCountService.countAllMoney(Double.parseDouble(minMoney));
      JSONObject data = new JSONObject();
      data.put("amountMoney", amountMoney);
      data.put("extractApply", extractApply);
      data.put("extractMoney", resultData.get("totalmoney"));
      out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
   }
   public String validateParams(Integer shwoType,  String startTime, String endTime) {
      if (shwoType == null) {
         return "请选择视图类型";
      }
      if (shwoType == 1 && (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime))) {
         return "请选择时间区间";
      }
      if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
         return "请选结束日期";
      }
      if (StringUtil.isNullOrEmpty(startTime) && !StringUtil.isNullOrEmpty(endTime)) {
         return "请选起始日期";
      }
      return null;
   }
}