package com.yeshi.fanli.controller.admin;
|
|
import java.io.PrintWriter;
|
import java.math.BigDecimal;
|
import java.net.URLDecoder;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.Calendar;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.yeshi.utils.DateUtil;
|
import org.yeshi.utils.IPUtil;
|
import org.yeshi.utils.JsonUtil;
|
|
import com.google.gson.Gson;
|
import com.google.gson.GsonBuilder;
|
import com.google.gson.reflect.TypeToken;
|
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
|
import com.yeshi.fanli.entity.bus.user.Extract;
|
import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
|
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
import com.yeshi.fanli.entity.bus.user.UserInfo;
|
import com.yeshi.fanli.entity.common.AdminUser;
|
import com.yeshi.fanli.exception.ExtractException;
|
import com.yeshi.fanli.exception.NotExistObjectException;
|
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.HongBaoV2CountService;
|
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
|
import com.yeshi.fanli.service.inter.push.PushRecordService;
|
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService;
|
import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
import com.yeshi.fanli.service.inter.user.ExtractAuditRecordService;
|
import com.yeshi.fanli.service.inter.user.ExtractService;
|
import com.yeshi.fanli.tag.PageEntity;
|
import com.yeshi.fanli.util.Constant;
|
import com.yeshi.fanli.util.RedisManager;
|
import com.yeshi.fanli.util.StringUtil;
|
import com.yeshi.fanli.util.TimeUtil;
|
|
import net.sf.json.JSONArray;
|
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;
|
|
@Resource
|
private AccountMessageService accountMessageService;
|
|
@Resource
|
private PushRecordService pushRecordService;
|
|
@Resource
|
private PushController xingePushController;
|
|
@Resource
|
private ExtractAuditRecordService extractAuditRecordService;
|
|
@Resource
|
private HongBaoV2CountService hongBaoV2CountService;
|
|
@Resource
|
private AdminUserService adminUserService;
|
|
@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);
|
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);
|
JSONObject data = new JSONObject();
|
data.put("pe", pe);
|
data.put("extractList", extractList);
|
out.print(JsonUtil.loadTrueResult(data));
|
}
|
|
/**
|
*
|
* 方法说明: 通过提现请求
|
*
|
* @author mawurui createTime 2018年3月14日 下午3:15:42
|
* @param id
|
* @param out
|
* @param request
|
*/
|
@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);
|
|
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 + "]的提现申请!"); // 同意之后成功
|
} else if (integer == 1) {
|
|
out.print(JsonUtil.loadFalseResult("不存在该对象")); // 同意之后失败
|
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 + "的提现申请状态异常");
|
out.print(JsonUtil.loadFalseResult("该状态不等于不为初始状态"));
|
String title = "你的提现申请不成功";
|
String content = "请确保你的提现账户的隐私设置为 允许邮箱、手机号、会员名找到我。否则无法成功完成转账。如有疑问请联系客服。";
|
// xingePushController.pushSystemZnx(uid, title, content, out);
|
}
|
}
|
|
/**
|
*
|
* 方法说明: 通过提现请求 可jsonP方式
|
*
|
* @param id
|
* @param code
|
* 验证码
|
* @param out
|
* @param request
|
*/
|
@RequestMapping(value = "passExtractJP")
|
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);
|
if (!"1".equals(codeType)) {
|
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 + "]的提现申请!"); // 同意之后成功
|
} else if (integer == 1) {
|
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);
|
} else {
|
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);
|
}
|
|
}
|
|
/**
|
*
|
* 方法说明: 拒绝提现请求
|
*
|
* @author mawurui createTime 2018年3月14日 下午3:15:55
|
* @param id
|
* @param reason
|
* @param out
|
* @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);
|
|
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);
|
|
String title = "你的提现申请被驳回";
|
String content = "非常遗憾,你的提现申请被驳回。我们通过核对发现你的账目明细有误,我们会在审计完成之后给你发通知消息。如有疑问请联系客服。";
|
// xingePushController.pushSystemZnx(uid, title, content, out);
|
} catch (ObjectStateException e) {
|
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 + "的提现申请不存在!");
|
|
out.print(JsonUtil.loadFalseResult(e.getMessage()));
|
}
|
}
|
|
/**
|
*
|
* 方法说明: 拒绝提现请求jsonP
|
*
|
* @author mawurui createTime 2018年3月14日 下午3:15:55
|
* @param id
|
* @param reason
|
* @param out
|
* @param request
|
*/
|
@RequestMapping(value = "rejectExtractJP")
|
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);
|
if (!"1".equals(codeType)) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
|
return;
|
}
|
|
/* 拒绝提现 操作 */
|
|
try {
|
reason = URLDecoder.decode(reason, "UTF-8");
|
} catch (Exception e1) {
|
e1.printStackTrace();
|
}
|
|
try {
|
Extract extract = extractService.getExtractById(id);
|
long extractTime = extract.getExtractTime();
|
extractService.rejectExtract(id, reason, extractTime, admin);// 提现失败
|
|
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("拒绝"));
|
|
// 调用推送站内信给用户
|
// 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 + "的提现申请状态异常!"); //
|
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
|
|
} catch (NotExistObjectException e) {
|
LogHelper.userInfo(
|
"[ip:" + IPUtil.getRemotIP(request) + "][管理员:" + admin.getName() + "] 拒绝提现id=" + id + "的提现申请不存在!");
|
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
|
}
|
|
}
|
|
/**
|
* 资金校验是否异常
|
*
|
* @param uid
|
* @param out
|
*/
|
@RequestMapping(value = "checkExtract", method = RequestMethod.POST)
|
public void checkExtract(String uid, PrintWriter out) {
|
JSONObject data = new JSONObject();
|
try {
|
extractService.checkExtract(uid);
|
data.put("code", "1"); // 正常
|
} catch (ExtractException e) {
|
data.put("code", "0");// 异常
|
}
|
out.print(data);
|
}
|
|
/**
|
* 获取今日提现记录:今日总额、总次数、成功次数、失败次数 获取系统提现记录:总额、总次数
|
*
|
* @param out
|
*/
|
@RequestMapping(value = "countExtract")
|
public void countExtract(String callback, PrintWriter out) {
|
|
Map<String, Object> totalcount = extractCountService.getTodayCount();
|
|
// 今日提现成功金额
|
BigDecimal todayextractMoney = extractCountService.getTodayTotalSuccessMoney();
|
|
// 当前用户余额总计:所有用户总余额
|
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));
|
|
// 累计已提现金额总计:已提现成功的总额/ 次数
|
Map<String, Object> resultData = extractCountService.countTotalSuccess();
|
|
JSONObject data = new JSONObject();
|
data.put("todayCount", totalcount);
|
data.put("todayextractMoney", todayextractMoney);
|
|
data.put("amountMoney", amountMoney); // 所有用户总余额
|
data.put("extractApply", extractApply); // 可提现金额总计
|
data.put("extractNumber", resultData.get("totalamount")); // 提现成功次数
|
data.put("extractMoney", resultData.get("totalmoney")); // 提现成功金额
|
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
}
|
|
/**
|
* 查询所有审核记录信息
|
*
|
* @param callback
|
* @param pageIndex
|
* @param key
|
* @param startTime
|
* @param endTime
|
* @param out
|
*/
|
@RequestMapping(value = "getFinishRecordList")
|
public void getFinishRecordList(String callback, Integer pageIndex, String key, String startTime, String endTime,
|
PrintWriter out) {
|
|
try {
|
|
// 起始时间 为空设置默认值:
|
if (StringUtil.isNullOrEmpty(startTime)) {
|
startTime = "1970-01-01";
|
}
|
|
// 结束时间 为空设置默认值当前日期
|
if (StringUtil.isNullOrEmpty(endTime)) {
|
Date curDate = new Date();
|
endTime = TimeUtil.getSimpleDate(curDate);
|
}
|
|
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());
|
|
if (pageIndex == null)
|
pageIndex = 1;
|
|
int pageSize = Constant.PAGE_SIZE;
|
|
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("暂无数据")));
|
} else {
|
|
for (ExtractAuditRecord extractAuditRecord : auditList) {
|
int countByUid = 0;
|
int countCancel = 0;
|
Extract extract = extractAuditRecord.getExtract();
|
if (extract != null) {
|
UserInfo userInfo = extract.getUserInfo();
|
Long id = userInfo.getId();
|
countByUid = hongBaoV2CountService.countNumberByUid(id);
|
countCancel = hongBaoV2CountService.countNumberByUidAndState(id, HongBaoV2.STATE_SHIXIAO);
|
}
|
extractAuditRecord.setCancelOrderNum((long) countCancel);
|
extractAuditRecord.setOrderNum((long) countByUid);
|
}
|
|
JSONObject data = new JSONObject();
|
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)));
|
}
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
|
}
|
}
|
|
/**
|
* 查询客服个人提现审批记录信息
|
*
|
* @param callback
|
* @param pageIndex
|
* 页码
|
* @param key
|
* 筛选条件
|
* @param timeSlot
|
* 查询时间段
|
* @param state
|
* 查看审核状态
|
* @param out
|
* @param request
|
*/
|
@RequestMapping(value = "getMyAuditedList")
|
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;
|
// }
|
|
int pageSize = Constant.PAGE_SIZE;
|
|
Integer days = null;
|
if (TODAY.equals(timeSlot)) {
|
days = 0; // 今日
|
} else if (THREE.equals(timeSlot)) {
|
days = 3; // 前3天
|
} else if (AWEEK.equals(timeSlot)) {
|
days = 7; // 前7天
|
}
|
|
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);
|
|
// 暂不区分账号,默认所有
|
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 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);
|
int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
|
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) {
|
e.printStackTrace();
|
out.print(JsonUtil.loadFalseResult(e.getMessage()));
|
}
|
}
|
|
/**
|
* 获取今日提现记录:今日总额、总次数、成功次数、失败次数 获取系统提现记录:总额、总次数
|
*
|
* @param out
|
*/
|
@RequestMapping(value = "getMyAuditedCount")
|
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 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);
|
data.put("countToday", countToday);
|
data.put("countWeek", countWeek);
|
data.put("countMonth", countMonth);
|
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
}
|
|
}
|
|
/**
|
* 客服任务页面展示数据:传入提现申请id 则显示当前申请,若无id则显示客服任务下第一个申请数据
|
*
|
* @param callback
|
* @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();
|
AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
if (admin == null) {
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
|
return;
|
}
|
|
if (extractId != null) {
|
/* 传入提现申请id 查询前客服任务数据 */
|
|
extract = extractService.selectByPrimaryKey(extractId);
|
if (extract == null) {
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前申请已不存在")));
|
return;
|
}
|
|
// 当前任务指定为该账户处理
|
/*
|
* extract.setAdminId(admin.getId());
|
* extractService.updateByPrimaryKeySelective(extract);
|
*/
|
|
BigDecimal beforeMoney = null;
|
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);
|
}
|
|
data.put("extract", extract);
|
data.put("beforeMoney", beforeMoney);
|
data.put("surplusTime", surplusTime);
|
|
out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
|
} else {
|
/* 未传入提现申请id 查询当前客服任务 中的第一个 数据 */
|
|
boolean newTask = false;
|
|
// 查询之前未处理完的任务
|
extract = extractService.getMyTaskInfo(admin.getId());
|
|
if (extract == null) {
|
// 新任务
|
extract = extractService.getNewTaskInfo();
|
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);
|
*/
|
}
|
|
BigDecimal beforeMoney = null;
|
|
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);
|
}
|
|
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 request
|
* @param out
|
*/
|
@RequestMapping(value = "getByUidList")
|
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)
|
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(); // 重点
|
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 request
|
* @param out
|
*/
|
@RequestMapping(value = "countByUid")
|
public void countByUid(String callback, Long uid, HttpServletRequest request, PrintWriter out) {
|
|
try {
|
|
// 统计已领取金额 账户历史总收益
|
BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU);
|
if (receiveMoneys == null) {
|
receiveMoneys = new BigDecimal(0);
|
}
|
|
// 历史提现成功金额
|
double successMoneys = extractCountService.countSuccessMoneysByUid(uid);
|
|
// 历史提现总次数、成功次数、失败次数
|
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) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 校验用户资金是否异常
|
*
|
* @param uid
|
* @param out
|
*/
|
@RequestMapping(value = "checkMoney")
|
public void checkMoney(String callback, String uid, PrintWriter out) {
|
|
if (StringUtil.isNullOrEmpty(uid)) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("UID不能为空"));
|
return;
|
}
|
|
try {
|
extractService.checkExtract(uid);
|
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("资金正常"));
|
} catch (ExtractException e) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
}
|
}
|
|
/**
|
* 统计审核次数
|
*
|
* @param callback
|
* @param state
|
* 审核状态:所有-3 通过-1 拒绝- 2
|
* @param type
|
* 统计类型 1-24小时 2-所有3
|
* @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, String stateArray, Integer dateType, String year, String startTime,
|
String endTime, PrintWriter out) {
|
|
String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
if (validateMsg != null) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
return;
|
}
|
|
if (dateType == 1 && year != null) {
|
year = null; // 设置为空
|
} else if (dateType == 2) {
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
|
} else if (dateType == 3) {
|
if (year != null)
|
year = null;
|
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
}
|
|
try {
|
Object objectDate = null;
|
List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
|
Gson gson = new Gson();
|
List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {
|
}.getType());
|
|
JSONArray line_list = new JSONArray();
|
for (Integer state : stateList) {
|
JSONObject innerList = new JSONObject();
|
if (state == null || state == 3) {
|
innerList.put("name", "总计");
|
} else if (state == 1) {
|
innerList.put("name", "通过数");
|
} else if (state == 2) {
|
innerList.put("name", "驳回数");
|
}
|
|
List<Map<String, Object>> list = extractAuditRecordService.countAuditTotal(state, dateType, year,
|
startTime, endTime);
|
|
if (dateType != 3) {
|
innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
} else {
|
// 年视图
|
Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
|
if (objectDate == null) {
|
objectDate = map.get("date");
|
}
|
innerList.put("data", gson.toJson(map.get("value")));
|
}
|
|
line_list.add(innerList);
|
}
|
|
JSONObject data = new JSONObject();
|
if (objectDate != null) {
|
data.put("xAxis_list", gson.toJson(objectDate));
|
} else {
|
data.put("xAxis_list", gson.toJson(dateList));
|
}
|
|
data.put("line_list", line_list);
|
|
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
|
} catch (Exception e) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 统计提现申请总额
|
*
|
* @param callback
|
* @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 = "getExtractApplyMoney")
|
public void getExtractApplyMoney(String callback, Integer dateType, String year, String startTime, String endTime,
|
PrintWriter out) {
|
|
String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
if (validateMsg != null) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
return;
|
}
|
|
if (dateType == 1 && year != null) {
|
year = null; // 设置为空
|
} else if (dateType == 2) {
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
|
} else if (dateType == 3) {
|
if (year != null)
|
year = null;
|
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
}
|
|
try {
|
|
Object objectDate = null;
|
List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
|
Gson gson = new Gson();
|
JSONArray line_list = new JSONArray();
|
|
JSONObject innerList = new JSONObject();
|
innerList.put("name", "总计");
|
|
List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyMoney(null, dateType, year,
|
startTime, endTime);
|
|
if (dateType != 3) {
|
innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
} else {
|
// 年视图
|
Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
|
if (objectDate == null) {
|
objectDate = map.get("date");
|
}
|
innerList.put("data", gson.toJson(map.get("value")));
|
}
|
|
line_list.add(innerList);
|
|
JSONObject data = new JSONObject();
|
if (objectDate != null) {
|
data.put("xAxis_list", gson.toJson(objectDate));
|
} else {
|
data.put("xAxis_list", gson.toJson(dateList));
|
}
|
|
data.put("line_list", line_list);
|
|
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 dateType, String year, String startTime,
|
String endTime, PrintWriter out) {
|
|
String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
if (validateMsg != null) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
return;
|
}
|
|
if (dateType == 1 && year != null) {
|
year = null; // 设置为空
|
} else if (dateType == 2) {
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
|
} else if (dateType == 3) {
|
if (year != null)
|
year = null;
|
|
if (startTime != null)
|
startTime = null;
|
|
if (endTime != null)
|
endTime = null;
|
}
|
|
try {
|
|
Object objectDate = null;
|
List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
|
Gson gson = new Gson();
|
JSONArray line_list = new JSONArray();
|
|
JSONObject innerList = new JSONObject();
|
innerList.put("name", "总计");
|
|
List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyNumber(null, dateType, year,
|
startTime, endTime);
|
|
if (dateType != 3) {
|
innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
|
} else {
|
// 年视图
|
Map<String, Object> map = AdminUtils.yearsDataFactory(list);
|
|
if (objectDate == null) {
|
objectDate = map.get("date");
|
}
|
innerList.put("data", gson.toJson(map.get("value")));
|
}
|
|
line_list.add(innerList);
|
|
JSONObject data = new JSONObject();
|
if (objectDate != null) {
|
data.put("xAxis_list", gson.toJson(objectDate));
|
} else {
|
data.put("xAxis_list", gson.toJson(dateList));
|
}
|
|
data.put("line_list", line_list);
|
|
JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
|
} catch (Exception e) {
|
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
e.printStackTrace();
|
}
|
}
|
|
}
|