Administrator
2018-11-30 2c479a66e7cb1df74f50ed798a2c3e2a0bc15322
修复提现验证问题
1个文件已修改
1001 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java 1001 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -65,7 +65,7 @@
    @Resource
    private ExtractService extractService;
    @Resource
    private ExtractCountService extractCountService;
@@ -86,39 +86,32 @@
    @Resource
    private AdminUserService adminUserService;
    @Resource
    private OrderItemServcie orderItemServcie;
    @Resource
    private PidOrderService pidOrderService;
    @Resource
    private RedisManager redisManager;
    @Resource
    private TaoBaoOrderService taoBaoOrderService;
    @Resource
    private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
    private final static String TODAY = "1";
    private final static String THREE = "2";
    private final static String AWEEK = "3";
    @RequestMapping(value = "getExtractList", method = RequestMethod.POST)
    public void getExtractList(int pageIndex, PrintWriter out) {
        List<Extract> extractList = extractService
                .getExtractList(pageIndex - 1);
        List<Extract> extractList = extractService.getExtractList(pageIndex - 1);
        int count = extractService.getCount();
        int totalPage = count % Constant.PAGE_SIZE == 0 ? count
                / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
        PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count,
                totalPage);
        int totalPage = count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
        PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count, totalPage);
        JSONObject data = new JSONObject();
        data.put("pe", pe);
        data.put("extractList", extractList);
@@ -136,99 +129,96 @@
     */
    @RequestMapping(value = "passExtract", method = RequestMethod.POST)
    public void passExtract(String callback, long id, PrintWriter out, HttpServletRequest request) {
        //TODO 需要邮箱发送短信验证
        AdminUser admin = (AdminUser) request.getSession().getAttribute(
                Constant.SESSION_ADMIN);
        // TODO 需要邮箱发送短信验证
        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
        Integer integer = extractService.passExtract(id, admin);
        Extract extract = extractService.getExtractById(id);
        long uid = extract.getUserInfo().getId();
        if (integer == null) {
            out.print(JsonUtil.loadTrueResult("通过"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]"
                    + admin.getName() + "通过了[id=" + id + "]的提现申请!"); // 同意之后成功
            LogHelper
                    .userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "通过了[id=" + id + "]的提现申请!"); // 同意之后成功
        } else if (integer == 1) {
            out.print(JsonUtil.loadFalseResult("不存在该对象")); // 同意之后失败
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 同意提现id=" + id + "的提现申请不存在");
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 同意提现id=" + id + "的提现申请不存在");
            String title = "你的提现申请被驳回";
            String content = "非常遗憾,你的提现申请被驳回。我们通过核对发现你的账目明细有误,我们会在审计完成之后给你发通知消息。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        } else {
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 同意提现id=" + id + "的提现申请状态异常");
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 同意提现id=" + id + "的提现申请状态异常");
            out.print(JsonUtil.loadFalseResult("该状态不等于不为初始状态"));
            String title = "你的提现申请不成功";
            String content = "请确保你的提现账户的隐私设置为 允许邮箱、手机号、会员名找到我。否则无法成功完成转账。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        }
    }
    /**
     * 
     * 方法说明: 通过提现请求  可jsonP方式
     * 方法说明: 通过提现请求 可jsonP方式
     * 
     * @param id
     * @param code 验证码
     * @param code
     *            验证码
     * @param out
     * @param request
     */
    @RequestMapping(value = "passExtractJP")
    public void passExtractJP(String callback, Long id, String code,PrintWriter out, HttpServletRequest request) {
        /* 检验是否登陆  */
    public void passExtractJP(String callback, Long id, String code, PrintWriter out, HttpServletRequest request) {
        /* 检验是否登陆 */
        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
        if (admin == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"));
            return;
        }
        /* 检验是否通过验证  */
        String codeType = (String)request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
        }
        /* 检验是否通过验证 */
        String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
        if (!"1".equals(codeType)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3,"邮箱验证未通过"));
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
            return;
        }
        /* 允许提现 操作  */
        /* 允许提现 操作 */
        Integer integer = extractService.passExtract(id, admin);
        Extract extract = extractService.getExtractById(id);
        long uid = extract.getUserInfo().getId();
        if (integer == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("通过"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]"
                    + admin.getName() + "通过了[id=" + id + "]的提现申请!"); // 同意之后成功
            LogHelper
                    .userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "通过了[id=" + id + "]的提现申请!"); // 同意之后成功
        } else if (integer == 1) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("不存在该对象"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 同意提现id=" + id + "的提现申请不存在");
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 同意提现id=" + id + "的提现申请不存在");
            String title = "你的提现申请被驳回";
            String content = "非常遗憾,你的提现申请被驳回。我们通过核对发现你的账目明细有误,我们会在审计完成之后给你发通知消息。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        } else {
            JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("该状态不等于不为初始状态"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 同意提现id=" + id + "的提现申请状态异常");
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该状态不等于不为初始状态"));
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 同意提现id=" + id + "的提现申请状态异常");
            String title = "你的提现申请不成功";
            String content = "请确保你的提现账户的隐私设置为 允许邮箱、手机号、会员名找到我。否则无法成功完成转账。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        }
    }
    /**
     * 
     * 方法说明: 拒绝提现请求
@@ -240,40 +230,37 @@
     * @param request
     */
    @RequestMapping(value = "rejectExtract", method = RequestMethod.POST)
    public void rejectExtract(String callback ,long id, String reason, PrintWriter out,
            HttpServletRequest request) {
        AdminUser admin = (AdminUser) request.getSession().getAttribute(
                Constant.SESSION_ADMIN);
    public void rejectExtract(String callback, long id, String reason, PrintWriter out, HttpServletRequest request) {
        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
        Extract extract = extractService.getExtractById(id);
        long uid = extract.getUserInfo().getId();
        long extractTime = extract.getExtractTime();
        try {
            extractService.rejectExtract(id, reason, extractTime, admin);// 提现失败
            // 调用推送站内信给用户
            out.print(JsonUtil.loadTrueResult("拒绝"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]"
                    + admin.getName() + "拒绝了[id=" + id + "]的提现申请!拒绝原因是"
                    + reason);
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "拒绝了[id=" + id
                    + "]的提现申请!拒绝原因是" + reason);
            String title = "你的提现申请被驳回";
            String content = "非常遗憾,你的提现申请被驳回。我们通过核对发现你的账目明细有误,我们会在审计完成之后给你发通知消息。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        } catch (ObjectStateException e) {
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 拒绝提现id=" + id + "的提现申请状态异常!"); //
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的提现申请状态异常!"); //
            out.print(JsonUtil.loadFalseResult(e.getMessage()));
        } catch (NotExistObjectException e) {
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 拒绝提现id=" + id + "的提现申请不存在!");
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的提现申请不存在!");
            out.print(JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    /**
     * 
     * 方法说明: 拒绝提现请求jsonP
@@ -285,54 +272,52 @@
     * @param request
     */
    @RequestMapping(value = "rejectExtractJP")
    public void rejectExtractJP(String callback ,Long id,String code, String reason, PrintWriter out,
    public void rejectExtractJP(String callback, Long id, String code, String reason, PrintWriter out,
            HttpServletRequest request) {
        /* 检验是否登陆  */
        /* 检验是否登陆 */
        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
        if (admin == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆"));
            return;
        }
        /* 检验是否通过验证  */
        String codeType = (String)request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
        }
        /* 检验是否通过验证 */
        String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
        if (!"1".equals(codeType)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3,"邮箱验证未通过"));
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
            return;
        }
        /* 拒绝提现 操作  */
        /* 拒绝提现 操作 */
        try {
            Extract extract = extractService.getExtractById(id);
            long extractTime = extract.getExtractTime();
            extractService.rejectExtract(id, reason, extractTime, admin);// 提现失败
            JsonUtil.printMode(out, callback,JsonUtil.loadTrueResult("拒绝"));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("拒绝"));
            // 调用推送站内信给用户
            //out.print(JsonUtil.loadTrueResult("拒绝"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]"+ admin.getName() +
                    "拒绝了[id=" + id + "]的提现申请!拒绝原因是"    + reason);
            // out.print(JsonUtil.loadTrueResult("拒绝"));
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "]" + admin.getName() + "拒绝了[id=" + id
                    + "]的提现申请!拒绝原因是" + reason);
            String title = "你的提现申请被驳回";
            String content = "非常遗憾,你的提现申请被驳回。我们通过核对发现你的账目明细有误,我们会在审计完成之后给你发通知消息。如有疑问请联系客服。";
            // xingePushController.pushSystemZnx(uid, title, content, out);
        } catch (ObjectStateException e) {
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 拒绝提现id=" + id + "的提现申请状态异常!"); //
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的提现申请状态异常!"); //
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
        } catch (NotExistObjectException e) {
            LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "][管理员:"
                    + admin.getName() + "] 拒绝提现id=" + id + "的提现申请不存在!");
            LogHelper.userInfo(
                    "[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的提现申请不存在!");
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    /**
@@ -345,6 +330,14 @@
    public void checkExtract(String uid, PrintWriter out) {
        JSONObject data = new JSONObject();
        // 已到账的红包
        int count = hongBaoService.getCount(HongBao.STATE_YILINGQU);
        if (count == 0) {
            data.put("code", "1");
            out.print(data);
            return;
        }
        List<Integer> checked = extractService.checkExtract(uid);
        if (checked != null && checked.size() > 0) {
@@ -394,8 +387,8 @@
     * @param out
     */
    @RequestMapping(value = "getFinishRecordList")
    public void getFinishRecordList(String callback, Integer pageIndex,
            String key, String startTime, String endTime, PrintWriter out) {
    public void getFinishRecordList(String callback, Integer pageIndex, String key, String startTime, String endTime,
            PrintWriter out) {
        try {
@@ -418,23 +411,23 @@
            endTime = sdf.format(c.getTime());
            if (pageIndex == null)
            if (pageIndex == null)
                pageIndex = 1;
            int pageSize = Constant.PAGE_SIZE;
            List<ExtractAuditRecord> auditList = extractAuditRecordService.getList(pageIndex,
                    pageSize, key, startTime, endTime);
            List<ExtractAuditRecord> auditList = extractAuditRecordService.getList(pageIndex, pageSize, key, startTime,
                    endTime);
            int count = extractAuditRecordService.getCount(key, startTime, endTime);
            int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            if (auditList == null || auditList.size() == 0) {
                out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("暂无数据")));
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无数据")));
            } else {
                for (ExtractAuditRecord extractAuditRecord: auditList) {
                for (ExtractAuditRecord extractAuditRecord : auditList) {
                    int countByUid = 0;
                    int countCancel = 0;
                    Extract extract = extractAuditRecord.getExtract();
@@ -444,31 +437,26 @@
                        countByUid = hongBaoService.getCountByUid(id);
                        countCancel = hongBaoService.getCountCancelByUid(id);
                    }
                    extractAuditRecord.setCancelOrderNum((long)countCancel);
                    extractAuditRecord.setOrderNum((long)countByUid);
                    extractAuditRecord.setCancelOrderNum((long) countCancel);
                    extractAuditRecord.setOrderNum((long) countByUid);
                }
                JSONObject data = new JSONObject();
                GsonBuilder gsonBuilder = new GsonBuilder();
                gsonBuilder.serializeNulls(); //重点
                GsonBuilder gsonBuilder = new GsonBuilder();
                gsonBuilder.serializeNulls(); // 重点
                Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
                data.put("pe", pe);
                data.put("auditList", gson.toJson(auditList));
                out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult(data)));
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
            }
        } catch (Exception e) {
            e.printStackTrace();
            out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadFalseResult("操作异常")));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
        }
    }
    /**
     * 查询客服个人提现审批记录信息
@@ -486,17 +474,18 @@
     * @param request
     */
    @RequestMapping(value = "getMyAuditedList")
    public void getMyAuditedList(String callback, Integer pageIndex,String key, String timeSlot, Integer state,
            PrintWriter out,HttpServletRequest request) {
    public void getMyAuditedList(String callback, Integer pageIndex, String key, String timeSlot, Integer state,
            PrintWriter out, HttpServletRequest request) {
        try {
            //AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
            //if (admin == null) {
            //    JsonUtil.printMode(out, callback,  JsonUtil.loadFalseResult("当前账户失效,请重新登陆"));
            //    return;
            //}
            // AdminUser admin = (AdminUser)
            // request.getSession().getAttribute(Constant.SESSION_ADMIN);
            // if (admin == null) {
            // JsonUtil.printMode(out, callback,
            // JsonUtil.loadFalseResult("当前账户失效,请重新登陆"));
            // return;
            // }
            int pageSize = Constant.PAGE_SIZE;
@@ -505,49 +494,49 @@
                days = 0; // 今日
            } else if (THREE.equals(timeSlot)) {
                days = 3; // 前3天
            }else if (AWEEK.equals(timeSlot)) {
            } else if (AWEEK.equals(timeSlot)) {
                days = 7; // 前7天
            }
            if (state != null && state != 0 && state != 1 && state != 2 ) {
            }
            if (state != null && state != 0 && state != 1 && state != 2) {
                state = null;
            }
            // 查询当前人员的审核列表信息
            //Long adminId = admin.getId();
            //auditList = extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, pageSize, key,state, adminId, days);
            //count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, adminId,days);
            // Long adminId = admin.getId();
            // auditList =
            // extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex,
            // pageSize, key,state, adminId, days);
            // count = extractAuditRecordService.getMyAuditedTimeSlotCount(key,
            // state, adminId,days);
            // 暂不区分账号,默认所有
             List<ExtractAuditRecord> auditList = extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex,
                     pageSize, key,state, null, days);
            List<ExtractAuditRecord> auditList = extractAuditRecordService.getMyAuditedTimeSlotList(pageIndex, pageSize,
                    key, state, null, days);
            if (auditList == null || auditList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            for (ExtractAuditRecord record : auditList) {
                AdminUser adminUser = record.getAdminUser();
                if (adminUser == null) {
                    record.setAdminUser(new AdminUser());
                }
            }
            int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days);
            int count = extractAuditRecordService.getMyAuditedTimeSlotCount(key, state, null, days);
            int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
            PageEntity pe = new PageEntity(pageIndex, pageSize, count,totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("list", gson.toJson(auditList));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
@@ -562,27 +551,25 @@
     * @param out
     */
    @RequestMapping(value = "getMyAuditedCount")
    public void getMyAuditedCount(String callback, HttpServletRequest request,
            PrintWriter out) {
    public void getMyAuditedCount(String callback, HttpServletRequest request, PrintWriter out) {
        AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
        if (admin == null) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
        } else {
            Long adminId = admin.getId();
            int taskToday = extractCountService.countTodayApply();
            //int countTodayComplete = extractService.countTodayComplete();
            // int countTodayComplete = extractService.countTodayComplete();
            // 今日累计处理数据
            int countToday = extractAuditRecordService.getMyAuditedCountToday(adminId);
            // 本周累计处理数据
            int countWeek = extractAuditRecordService.getMyAuditedCountWeek(adminId);
            // 本月累计处理数据
            int countMonth = extractAuditRecordService.getMyAuditedCountMonth(adminId);
            JSONObject data = new JSONObject();
            data.put("adminUser", admin);
            data.put("taskToday", taskToday);
@@ -593,20 +580,21 @@
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        }
    }
    /**
     * 客服任务页面展示数据:传入提现申请id 则显示当前申请,若无id则显示客服任务下第一个申请数据
     *
     * @param callback
     * @param extractId 提现id
     * @param extractId
     *            提现id
     * @param request
     * @param out
     */
    @RequestMapping(value = "getIaskInfo")
    public void getIaskInfo(String callback, Long extractId, HttpServletRequest request, PrintWriter out) {
        try {
            String surplusTime = "";
            JSONObject data = new JSONObject();
            Extract extract = new Extract();
@@ -615,30 +603,31 @@
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
                return;
            }
            if (extractId != null) {
                /*   传入提现申请id 查询前客服任务数据  */
                /* 传入提现申请id 查询前客服任务数据 */
                extract = extractService.selectByPrimaryKey(extractId);
                if (extract == null) {
                    out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前申请已不存在")));
                    return;
                }
                // 当前任务指定为该账户处理
                /*extract.setAdminId(admin.getId());
                extractService.updateByPrimaryKeySelective(extract);*/
                /*
                 * extract.setAdminId(admin.getId());
                 * extractService.updateByPrimaryKeySelective(extract);
                 */
                BigDecimal beforeMoney = null;
                List<ExtractAuditRecord>  records = extractAuditRecordService.getbyExtractId(extract.getId());
                List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId());
                if (records != null && records.size() > 0) {
                    ExtractAuditRecord extractAuditRecord = records.get(0);
                    if (extractAuditRecord != null) {
                        beforeMoney = extractAuditRecord.getBeforeMoney();
                    }
                }
                Long extractTime = extract.getExtractTime();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date date = new Date(extractTime);
@@ -648,203 +637,206 @@
                Date todayTime = new Date();
                String formattodayTime = sdf.format(todayTime);
                String formatTime = sdf.format(c.getTime());
                long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime();
                if (diff <= 0) {
                    surplusTime = "已超时";
                }  else {
                    surplusTime = DateUtil.dateDiff(formattodayTime,formatTime);
                } else {
                    surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
                }
                data.put("extract", extract);
                data.put("beforeMoney", beforeMoney);
                data.put("surplusTime", surplusTime);
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
            } else {
                /*   未传入提现申请id  查询当前客服任务 中的第一个 数据  */
                /* 未传入提现申请id 查询当前客服任务 中的第一个 数据 */
                boolean newTask = false;
                // 查询之前未处理完的任务
                extract = extractService.getMyTaskInfo(admin.getId());
                if (extract == null) {
                    // 新任务
                    extract = extractService.getNewTaskInfo();
                    if (extract != null)
                    if (extract != null)
                        newTask = true;
                }
                if (extract == null) {
                    out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无用户提现申请")));
                } else {
                    if (newTask) {
                        // 当前任务指定为该账户处理
                        /*extract.setAdminId(admin.getId());
                        extractService.updateByPrimaryKeySelective(extract);*/
                        /*
                         * extract.setAdminId(admin.getId());
                         *
                         * extractService.updateByPrimaryKeySelective(extract);
                         */
                    }
                    BigDecimal beforeMoney = null;
                    List<ExtractAuditRecord>  records = extractAuditRecordService.getbyExtractId(extract.getId());
                    List<ExtractAuditRecord> records = extractAuditRecordService.getbyExtractId(extract.getId());
                    if (records != null && records.size() > 0) {
                        ExtractAuditRecord extractAuditRecord = records.get(0);
                        if (extractAuditRecord != null) {
                            beforeMoney = extractAuditRecord.getBeforeMoney();
                        }
                    }
                    Long extractTime = extract.getExtractTime();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date date = new Date(extractTime);
                    Calendar c = Calendar.getInstance();
                    c.setTime(date);
                    c.add(Calendar.DAY_OF_MONTH, 3);// 今天+3天
                    Date todayTime = new Date();
                    String formattodayTime = sdf.format(todayTime);
                    String formatTime = sdf.format(c.getTime());
                    long diff = sdf.parse(formatTime).getTime() - sdf.parse(formattodayTime).getTime();
                    if (diff <= 0) {
                        surplusTime = "已超时";
                    }  else {
                        surplusTime = DateUtil.dateDiff(formattodayTime,formatTime);
                    } else {
                        surplusTime = DateUtil.dateDiff(formattodayTime, formatTime);
                    }
                    data.put("extract", extract);
                    data.put("beforeMoney", beforeMoney);
                    data.put("surplusTime", surplusTime);
                    out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
                }
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    /**
     * 查询用户历史提现记录
     *
     * @param callback
     * @param pageIndex 页码
     * @param key 用户id
     * @param pageIndex
     *            页码
     * @param key
     *            用户id
     * @param request
     * @param out
     */
    @RequestMapping(value = "getByUidList")
    public void getByUidList(String callback, Integer pageIndex, Long uid, HttpServletRequest request, PrintWriter out) {
    public void getByUidList(String callback, Integer pageIndex, Long uid, HttpServletRequest request,
            PrintWriter out) {
        try {
            if (uid == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
                return;
            }
            if (pageIndex == null)
            if (pageIndex == null)
                pageIndex = 1;
            int pageSize = Constant.PAGE_SIZE;
            List<ExtractAuditRecord> list = extractAuditRecordService.getByUidList(pageIndex, pageSize, uid);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无提现记录"));
                return;
            }
            int count = extractAuditRecordService.getByUidCount(uid);
            int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls(); //重点
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls(); // 重点
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            // TODO: handle exception
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 数量统计
     *
     * @param callback
     * @param uid 用户id
     * @param uid
     *            用户id
     * @param request
     * @param out
     */
    @RequestMapping(value = "countByUid")
    public void countByUid(String callback, Long uid, HttpServletRequest request, PrintWriter out) {
        try {
            // 统计已领取金额  账户历史总收益
            // 统计已领取金额 账户历史总收益
            double receiveMoneys = hongBaoService.countReceiveMoneysByUid(uid);
            // 历史提现成功金额
            double successMoneys = extractCountService.countSuccessMoneysByUid(uid);
            // 历史提现总次数、成功次数、失败次数
            Map<String, Object> map  = extractCountService.countRecordsByUid(uid);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Map<String, Object> map = extractCountService.countRecordsByUid(uid);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("map", gson.toJson(map));
            data.put("successMoneys", gson.toJson(successMoneys));
            data.put("receiveMoneys", gson.toJson(receiveMoneys));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            // TODO: handle exception
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 根据用户id查询相应订单列表
     * 
     * @param callback
     * @param pageIndex
     * @param key  用户id
     * @param key
     *            用户id
     * @param out
     */
    @RequestMapping(value = "getOrderRecordList")
    public void getOrderRecordList(String callback, Integer pageIndex,  Integer pageSize, Long key,
            String startTime, String endTime, PrintWriter out) {
    public void getOrderRecordList(String callback, Integer pageIndex, Integer pageSize, Long key, String startTime,
            String endTime, PrintWriter out) {
        try {
            if (key == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未获取到用户id"));
                return;
            }
            if (!StringUtil.isNullOrEmpty(endTime)) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date enddate = sdf.parse(endTime);
@@ -854,147 +846,134 @@
                endTime = sdf.format(c.getTime());
            }
            if(pageIndex == null)
            if (pageIndex == null)
                pageIndex = 1;
            if(pageSize == null)
            if (pageSize == null)
                pageSize = Constant.PAGE_SIZE;
            List<HongBao> list = hongBaoService.selectOrderByUid(pageIndex, pageSize, key, startTime, endTime);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该用户无订单记录"));
                return;
            }
            }
            Map<String, List<TaoBaoWeiQuanOrder>> wq = new HashMap<String, List<TaoBaoWeiQuanOrder>>();
            for (HongBao hongBao :list) {
            for (HongBao hongBao : list) {
                String orderId = hongBao.getOrderId();
                List<TaoBaoWeiQuanOrder> weiQuanList = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
                if (weiQuanList != null && weiQuanList.size() > 0) {
                    wq.put(orderId, weiQuanList);
                }
            }
            /*  验证网络:   */
            /* 验证网络: */
            StringBuffer auctionIdBuf = new StringBuffer();
            List<Map<String,Object>> listmap = new ArrayList<Map<String,Object>>();
            List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
            for (HongBao hongBao : list) {
                Map<String,Object> map = new HashMap<String,Object>();
                Map<String, Object> map = new HashMap<String, Object>();
                Long preGettime = hongBao.getPreGettime();
                Long getTime = hongBao.getGetTime();
                Integer state = hongBao.getState();
                Integer type = hongBao.getType();
                String orderId = hongBao.getOrderId();
                // 单笔收益金额
                BigDecimal money = hongBao.getMoney();
                map.put("getTime",getTime);
                map.put("getTime", getTime);
                // 子订单号
                String orderItemId = "";
                map.put("orderItemId",orderItemId);
                /*  订单状态判断:1 订单已付款   2、订单已结算   4、订单失效    */
                map.put("orderItemId", orderItemId);
                /* 订单状态判断:1 订单已付款 2、订单已结算 4、订单失效 */
                if (state == HongBao.STATE_SHIXIAO) {
                    map.put("orderState",4); // 订单失效
                    map.put("orderState", 4); // 订单失效
                } else if (state == HongBao.STATE_BUKELINGQU) {
                    Integer orderState = null;
                    if (type == HongBao.TYPE_SHARE_GOODS) {
                        // 分享订单
                        // 分享订单
                        Long hongbaoId = hongBao.getId();
                        PidOrder pidOrder = pidOrderService.getPidOrderByHongBaoId(hongbaoId);
                        String pidstate = pidOrder.getState();
                        if ("订单付款".equals(pidstate)) {
                            orderState = 1;
                        } else if ("订单结算".equals(pidstate)) {
                            orderState = 2;
                            orderState = 2;
                        } else if ("订单失效".equals(pidstate)) {
                            orderState = 4;
                        }
                    } else {
                        if (preGettime != null && preGettime > 0) {
                        if (preGettime != null && preGettime > 0) {
                            orderState = 2; // 订单结算
                        } else {
                            orderState = 1; // 订单已付款
                        }
                    }
                    map.put("orderState",orderState);
                    map.put("orderState", orderState);
                } else if (state == HongBao.STATE_KELINGQU || state == HongBao.STATE_YILINGQU) {
                    map.put("orderState",2); // 订单结算
                    map.put("orderState", 2); // 订单结算
                }
                /* 订单返利状态: 2未到账  3已到账   4已失效  */
                if (HongBao.STATE_YILINGQU == state ) {
                    map.put("moneyState",3);  //已到账
                /* 订单返利状态: 2未到账 3已到账 4已失效 */
                if (HongBao.STATE_YILINGQU == state) {
                    map.put("moneyState", 3); // 已到账
                } else if (HongBao.STATE_BUKELINGQU == state || HongBao.STATE_KELINGQU == state) {
                    map.put("moneyState",2);  // 未到账
                    map.put("moneyState", 2); // 未到账
                } else {
                    map.put("moneyState",4);  // 已失效
                    map.put("moneyState", 4); // 已失效
                }
                /* 订单类型:1系统红包  2、自购订单  3、邀请订单  4 分享订单  */
                /* 订单类型:1系统红包 2、自购订单 3、邀请订单 4 分享订单 */
                int rebateSource = 0;
                if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN ) {
                    // 3-活动红包 4-新人红包
                    rebateSource = 1;
                } else if(type == HongBao.TYPE_JINGDONG ||type == HongBao.TYPE_TAOBAO) {
                    //  自购订单
                if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN) {
                    // 3-活动红包 4-新人红包
                    rebateSource = 1;
                } else if (type == HongBao.TYPE_JINGDONG || type == HongBao.TYPE_TAOBAO) {
                    // 自购订单
                    rebateSource = 2;
                } else if (type == HongBao.TYPE_YAOQING ||  type == HongBao.TYPE_YIJI ||
                           type == HongBao.TYPE_ERJI || type == HongBao.TYPE_SHARE_ERJI ||
                           type == HongBao.TYPE_SHARE_YIJI) {
                } else if (type == HongBao.TYPE_YAOQING || type == HongBao.TYPE_YIJI || type == HongBao.TYPE_ERJI
                        || type == HongBao.TYPE_SHARE_ERJI || type == HongBao.TYPE_SHARE_YIJI) {
                    // 邀请人自购订单+邀请人分享订单
                    rebateSource = 3;
                } else if (type == HongBao.TYPE_SHARE_GOODS) {
                    // 分享订单
                    // 分享订单
                    rebateSource = 4;
                }
                map.put("rebateSource",rebateSource);
                map.put("rebateSource", rebateSource);
                // 获取订单信息
                Map<String, Object> inMap = getOrderItem(hongBao);
                OrderItem orderItem = (OrderItem) inMap.get("orderItem");
                Long endtime =  (Long) inMap.get("endtime");
                Long endtime = (Long) inMap.get("endtime");
                Long thirdCreateTime = (Long) inMap.get("thirdCreateTime");
                /* 初始化  空值*/
                /* 初始化 空值 */
                if (orderItem == null) {
                    orderItem = new OrderItem();
                    map.put("goodsStae","-1");
                }
                // 订单来源  0 无   1淘宝 2 京东
                map.put("orderSource",1);
                    map.put("goodsStae", "-1");
                }
                // 订单来源 0 无 1淘宝 2 京东
                map.put("orderSource", 1);
                // 当前实际返利金额
                orderItem.setFanMoney(money);
                String itemOrderId = orderItem.getOrderId();
                // 红包对应订单号
                if (StringUtil.isNullOrEmpty(itemOrderId))
                    orderItem.setOrderId(orderId);
                Long auctionId = orderItem.getAuctionId();
                if (auctionId != null) {
                    auctionIdBuf.append(auctionId + ",");
@@ -1006,126 +985,120 @@
                            Long auctionId2 = taoBaoOrder.getAuctionId();
                            orderItem.setAuctionId(auctionId2);
                            auctionIdBuf.append(auctionId + ",");
                            orderItem.setPayMoney(taoBaoOrder.getPayment());
                            orderItem.setTitle(taoBaoOrder.getTitle());
                            String settlementTime = taoBaoOrder.getSettlementTime();
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            if (!StringUtil.isNullOrEmpty(settlementTime)){
                            if (!StringUtil.isNullOrEmpty(settlementTime)) {
                                Date settleDate = sdf.parse(settlementTime);
                                endtime =settleDate.getTime();
                                endtime = settleDate.getTime();
                            }
                            String createTime = taoBaoOrder.getCreateTime();
                            if (!StringUtil.isNullOrEmpty(createTime)){
                            if (!StringUtil.isNullOrEmpty(createTime)) {
                                Date createDate = sdf.parse(createTime);
                                thirdCreateTime =createDate.getTime();
                                thirdCreateTime = createDate.getTime();
                            }
                        }
                    }
                }
                map.put("orderItem",orderItem);
                map.put("orderItem", orderItem);
                // 收货时间
                map.put("endtime",endtime);
                map.put("endtime", endtime);
                // 下单时间
                map.put("thirdCreateTime",thirdCreateTime);
                map.put("thirdCreateTime", thirdCreateTime);
                listmap.add(map);
            }
            /*  验证网络: 获取商品链接 图片链接   */
            /* 验证网络: 获取商品链接 图片链接 */
            List<TaoBaoGoodsBrief> goodsBriefList = null;
            if (auctionIdBuf != null && auctionIdBuf.length() > 0) {
                String auctionIds = auctionIdBuf.toString();
                String ids = auctionIds.substring(0, auctionIds.length() -1);
                String ids = auctionIds.substring(0, auctionIds.length() - 1);
                goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids);
            }
            List<Map<String,Object>> listResult = new ArrayList<Map<String,Object>>();
            Iterator<Map<String,Object>> iterator = listmap.iterator();
            List<Map<String, Object>> listResult = new ArrayList<Map<String, Object>>();
            Iterator<Map<String, Object>> iterator = listmap.iterator();
            while (iterator.hasNext()) {
                Map<String,Object> map = iterator.next();
                Map<String, Object> map = iterator.next();
                int goodsStae = 1;
                String auctionUrl = ""; // 商品链接
                OrderItem orderItem = (OrderItem) map.get("orderItem");
                Long auctionId = orderItem.getAuctionId();
                if (auctionId != null){
                if (auctionId != null) {
                    if (goodsBriefList != null && goodsBriefList.size() > 0) {
                        for (TaoBaoGoodsBrief taoBaoGoodsBrief :goodsBriefList) {
                        for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsBriefList) {
                            Long auctionIdTB = taoBaoGoodsBrief.getAuctionId();
                            if (auctionId.equals(auctionIdTB)) {
                                goodsStae=0;// 在售
                                goodsStae = 0;// 在售
                                auctionUrl = taoBaoGoodsBrief.getAuctionUrl();
                                String pictUrl = taoBaoGoodsBrief.getPictUrl();
                                orderItem.setPicture(pictUrl);
                            }
                        }
                    }
                    }
                }
                map.put("goodsStae",goodsStae); //
                map.put("auctionUrl",auctionUrl); // 商品链接
                map.put("goodsStae", goodsStae); //
                map.put("auctionUrl", auctionUrl); // 商品链接
                listResult.add(map);
            }
            int count = hongBaoService.countOrderByUid(key, startTime, endTime);
            int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            // 该期间的总收益
            double countProfit = hongBaoService.countProfitByUid(key, startTime, endTime);
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("countProfit", countProfit);
            data.put("listmap", listResult);
            out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult(data)));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (Exception e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    /**
     * 根据用户id查询相应订单列表
     * 
     * @param callback
     * @param pageIndex
     * @param key  用户id
     * @param key
     *            用户id
     * @param out
     */
    @RequestMapping(value = "getOrderList")
    public void getOrderList(String callback, Integer pageIndex,  Integer pageSize, Long key,
            String startTime, String endTime, PrintWriter out) {
    public void getOrderList(String callback, Integer pageIndex, Integer pageSize, Long key, String startTime,
            String endTime, PrintWriter out) {
        try {
            if (key == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未获取到用户id"));
                return;
            }
            if (!StringUtil.isNullOrEmpty(endTime)) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date enddate = sdf.parse(endTime);
@@ -1135,124 +1108,118 @@
                endTime = sdf.format(c.getTime());
            }
            if(pageIndex == null)
            if (pageIndex == null)
                pageIndex = 1;
            if(pageSize == null)
            if (pageSize == null)
                pageSize = Constant.PAGE_SIZE;
            List<HongBao> list = hongBaoService.selectOrderByUid(pageIndex, pageSize, key, startTime, endTime);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该用户无订单记录"));
                return;
            }
            /*  验证网络:   */
            }
            /* 验证网络: */
            StringBuffer auctionIdBuf = new StringBuffer();
            List<Map<String,Object>> listmap = new ArrayList<Map<String,Object>>();
            List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
            for (HongBao hongBao : list) {
                Map<String,Object> map = new HashMap<String,Object>();
                Map<String, Object> map = new HashMap<String, Object>();
                Long preGettime = hongBao.getPreGettime();
                Long getTime = hongBao.getGetTime();
                Integer state = hongBao.getState();
                Integer type = hongBao.getType();
                String orderId = hongBao.getOrderId();
                Date balanceTime = hongBao.getBalanceTime();
                // 自购订单id
                Long orderItemId = hongBao.getOrderItemId();
                // 单笔收益金额
                BigDecimal money = hongBao.getMoney();
                map.put("getTime",getTime);
                map.put("orderItemId",orderItemId);
                map.put("getTime", getTime);
                map.put("orderItemId", orderItemId);
                if (state == HongBao.STATE_SHIXIAO) {
                    if (balanceTime != null) {
                        map.put("orderState",1); //维权成功
                        map.put("orderState", 1); // 维权成功
                    } else {
                        map.put("orderState",2); //订单失效
                        map.put("orderState", 2); // 订单失效
                    }
                } else if (state == HongBao.STATE_BUKELINGQU || state == HongBao.STATE_KELINGQU) {
                    if (preGettime != null && preGettime > 0) {
                        map.put("orderState",0); //订单结算
                    if (preGettime != null && preGettime > 0) {
                        map.put("orderState", 0); // 订单结算
                    } else {
                        map.put("orderState",3); //订单付款中 未结算
                        map.put("orderState", 3); // 订单付款中 未结算
                    }
                } else {
                    map.put("orderState",0); //订单已付款-已结算
                    map.put("orderState", 0); // 订单已付款-已结算
                }
                if (HongBao.STATE_YILINGQU == state ) {
                    map.put("moneyState",3);  //已到账
                if (HongBao.STATE_YILINGQU == state) {
                    map.put("moneyState", 3); // 已到账
                } else if (HongBao.STATE_BUKELINGQU == state || HongBao.STATE_KELINGQU == state) {
                    map.put("moneyState",2);  // 未到账
                    map.put("moneyState", 2); // 未到账
                } else {
                    map.put("moneyState",4);  // 已失效
                    map.put("moneyState", 4); // 已失效
                }
                /* 1-淘宝订单 2-京东订单 3-活动红包 4-新人红包 5.邀请好友红包(布心街的) 6.一级分销红包
                    7.二级分销红包 20-分享商品订单 */
                /*
                 * 1-淘宝订单 2-京东订单 3-活动红包 4-新人红包 5.邀请好友红包(布心街的) 6.一级分销红包 7.二级分销红包
                 * 20-分享商品订单
                 */
                int rebateSource = 0;
                if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN ) {
                if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN) {
                    /* 3-活动红包 4-新人红包 */
                    rebateSource = 1;
                } else if(type == HongBao.TYPE_JINGDONG ||type == HongBao.TYPE_TAOBAO) {
                    /*   自购订单      */
                    rebateSource = 1;
                } else if (type == HongBao.TYPE_JINGDONG || type == HongBao.TYPE_TAOBAO) {
                    /* 自购订单 */
                    rebateSource = 2;
                } else if (type == HongBao.TYPE_YIJI || type == HongBao.TYPE_ERJI || type == HongBao.TYPE_YAOQING
                        || type == HongBao.TYPE_SHARE_ERJI || type == HongBao.TYPE_SHARE_YIJI) {
                    /*  邀请订单    分销红包对应的最上级红包  */
                    /* 邀请订单 分销红包对应的最上级红包 */
                    rebateSource = 3;
                } else if (type == HongBao.TYPE_SHARE_GOODS) {
                    /*    分享订单      */
                    /* 分享订单 */
                    rebateSource = 4;
                }
                map.put("rebateSource",rebateSource);
                map.put("rebateSource", rebateSource);
                // 获取订单信息
                Map<String, Object> inMap = getOrderItem(hongBao);
                OrderItem orderItem = (OrderItem) inMap.get("orderItem");
                Long endtime =  (Long) inMap.get("endtime");
                Long endtime = (Long) inMap.get("endtime");
                Long thirdCreateTime = (Long) inMap.get("thirdCreateTime");
                /* 初始化  空值*/
                /* 初始化 空值 */
                if (orderItem == null) {
                    orderItem = new OrderItem();
                    map.put("goodsStae","-1");
                }
                // 订单来源  0 无   1淘宝 2 京东
                map.put("orderSource",1);
                    map.put("goodsStae", "-1");
                }
                // 订单来源 0 无 1淘宝 2 京东
                map.put("orderSource", 1);
                // 当前实际返利金额
                orderItem.setFanMoney(money);
                String itemOrderId = orderItem.getOrderId();
                // 红包对应订单号
                if (StringUtil.isNullOrEmpty(itemOrderId))
                    orderItem.setOrderId(orderId);
                Long auctionId = orderItem.getAuctionId();
                if (auctionId == null) {
                    if (!StringUtil.isNullOrEmpty(orderId)) {
@@ -1262,174 +1229,164 @@
                            Long auctionId2 = taoBaoOrder.getAuctionId();
                            orderItem.setAuctionId(auctionId2);
                            auctionIdBuf.append(auctionId + ",");
                            orderItem.setPayMoney(taoBaoOrder.getPayment());
                            orderItem.setTitle(taoBaoOrder.getTitle());
                            String settlementTime = taoBaoOrder.getSettlementTime();
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            if (!StringUtil.isNullOrEmpty(settlementTime)){
                            if (!StringUtil.isNullOrEmpty(settlementTime)) {
                                Date settleDate = sdf.parse(settlementTime);
                                endtime =settleDate.getTime();
                                endtime = settleDate.getTime();
                            }
                            String createTime = taoBaoOrder.getCreateTime();
                            if (!StringUtil.isNullOrEmpty(createTime)){
                            if (!StringUtil.isNullOrEmpty(createTime)) {
                                Date createDate = sdf.parse(createTime);
                                thirdCreateTime =createDate.getTime();
                                thirdCreateTime = createDate.getTime();
                            }
                        }
                    }
                }
                map.put("orderItem",orderItem);
                map.put("orderItem", orderItem);
                // 收货时间
                map.put("endtime",endtime);
                map.put("endtime", endtime);
                // 下单时间
                map.put("thirdCreateTime",thirdCreateTime);
                map.put("thirdCreateTime", thirdCreateTime);
                listmap.add(map);
            }
            int count = hongBaoService.countOrderByUid(key, startTime, endTime);
            int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            // 该期间的总收益
            double countProfit = hongBaoService.countProfitByUid(key, startTime, endTime);
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("countProfit", countProfit);
            data.put("listmap", listmap);
            out.print(JsonUtil.loadJSONP(callback,JsonUtil.loadTrueResult(data)));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (Exception e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult(e.getMessage()));
        }
    }
    public Map<String,Object> getOrderItem(HongBao hongBao) {
    public Map<String, Object> getOrderItem(HongBao hongBao) {
        OrderItem orderItem = null;
        Long endtime = new Long(0);
        Long thirdCreateTime = new Long(0);
        Map<String,Object> map = new HashMap<String,Object>();
        Map<String, Object> map = new HashMap<String, Object>();
        Integer type = hongBao.getType();
        if (type == null) {
            return map;
        }
        if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN ) {
        if (type == HongBao.TYPE_HUODONG || type == HongBao.TYPE_XINREN) {
            /* 3-活动红包 4-新人红包 */
        } else if(type == HongBao.TYPE_JINGDONG ||type == HongBao.TYPE_TAOBAO) {
            /*   自购订单      */
        } else if (type == HongBao.TYPE_JINGDONG || type == HongBao.TYPE_TAOBAO) {
            /* 自购订单 */
            Long orderItemId = hongBao.getOrderItemId();
            orderItem = orderItemServcie.selectByPrimaryKey(orderItemId);
            // 下单时间
            Order order = hongBao.getOrder();
            if (order != null) {
                Date thirdCreateTime2 = order.getThirdCreateTime();
                if (thirdCreateTime2 != null)  {
                if (thirdCreateTime2 != null) {
                    thirdCreateTime = thirdCreateTime2.getTime();
                }
            }
            if (orderItem != null){
            if (orderItem != null) {
                // 结束时间
                Long settlementTime = orderItem.getSettlementTime();
                if (settlementTime != 0) {
                    endtime = settlementTime;
                }
                // 退款时间不为空  则已退款时间为结束时间
                }
                // 退款时间不为空 则已退款时间为结束时间
                Long refundTime = orderItem.getRefundTime();
                if (refundTime != 0) {
                    endtime = refundTime;
                }
                }
            }
        } else if (type == HongBao.TYPE_YIJI || type == HongBao.TYPE_ERJI || type == HongBao.TYPE_YAOQING
                || type == HongBao.TYPE_SHARE_ERJI || type == HongBao.TYPE_SHARE_YIJI) {
            /*    邀请订单    分销红包对应的最上级红包  */
            /* 邀请订单 分销红包对应的最上级红包 */
            HongBao parent = hongBao.getParent();
            if (parent != null) {
                Long pid = parent.getId();
                HongBao phongbao = hongBaoService.selectByPrimaryKey(pid);
                Map<String, Object> map2 = getOrderItem(phongbao);
                return map2;
            }
        } else if (type == HongBao.TYPE_SHARE_GOODS) {
            /*    分享订单      */
            /* 分享订单 */
            Long hongbaoId = hongBao.getId();
            PidOrder pidOrder = pidOrderService.getPidOrderByHongBaoId(hongbaoId);
            if (pidOrder != null) {
                orderItem = new OrderItem();
                orderItem.setOrderId(pidOrder.getOrderId());
                orderItem.setTitle(pidOrder.getGoodsTitle());
                orderItem.setPayMoney(pidOrder.getPayMoney());
                orderItem.setAuctionId(pidOrder.getAuctionId());
                // 下单时间
                Date createTime = pidOrder.getCreateTime();
                if (createTime != null ) {
                if (createTime != null) {
                    thirdCreateTime = createTime.getTime();
                }
                // 结算时间
                Date balanceTime = pidOrder.getBalanceTime();
                if (balanceTime != null ) {
                if (balanceTime != null) {
                    endtime = balanceTime.getTime();
                }
                String param = hongBao.getParam();
                if (!StringUtil.isNullOrEmpty(param)) {
                    String picture = param.substring(11,param.length());
                    String picture = param.substring(11, param.length());
                    if (!StringUtil.isNullOrEmpty(picture)) {
                        orderItem.setPicture(picture.substring(0, picture.length()-1));
                        orderItem.setPicture(picture.substring(0, picture.length() - 1));
                    }
                }
            }
        }
        map.put("orderItem", orderItem);
        map.put("endtime", endtime);
        map.put("thirdCreateTime", thirdCreateTime);
        return map;
    }
    /**
     * 校验用户资金是否异常
     * 
@@ -1443,14 +1400,14 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("UID不能为空"));
            return;
        }
        List<Integer> listChecked = extractService.checkExtract(uid);
        if (listChecked == null || listChecked.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("资金异常"));
            return;
        }
        Integer diversity = listChecked.get(0);
        if (diversity == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("资金正常"));
@@ -1458,5 +1415,5 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("资金异常"));
        }
    }
}