| | |
| | | import com.google.gson.stream.JsonReader; |
| | | import com.google.gson.stream.JsonWriter; |
| | | import com.taoke.autopay.dao.KeyOrderMapper; |
| | | import com.taoke.autopay.dao.agent.ChannelAgentMapper; |
| | | import com.taoke.autopay.dao.agent.ChannelAgentSettleRecordMapper; |
| | | import com.taoke.autopay.dto.ChannelOrderStatistic; |
| | | import com.taoke.autopay.entity.KeyOrder; |
| | | import com.taoke.autopay.entity.OrderChannelEnum; |
| | | import com.taoke.autopay.entity.SystemConfigKeyEnum; |
| | | import com.taoke.autopay.entity.agent.ChannelAgent; |
| | | import com.taoke.autopay.entity.agent.ChannelAgentSettings; |
| | | import com.taoke.autopay.entity.agent.ChannelAgentSharingRatio; |
| | | import com.taoke.autopay.entity.agent.ChannelAgentSettleDetail; |
| | | import com.taoke.autopay.entity.agent.ChannelAgentSettleRecord; |
| | | import com.taoke.autopay.exception.ChannelAgentException; |
| | | import com.taoke.autopay.factory.AgentFactory; |
| | | import com.taoke.autopay.exception.ChannelAgentSettleException; |
| | | import com.taoke.autopay.factory.OrderFactory; |
| | | import com.taoke.autopay.service.KeyOrderService; |
| | | import com.taoke.autopay.service.SystemConfigService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentSettingService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentSettleService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentSharingRatioService; |
| | | import com.taoke.autopay.utils.AgentUtil; |
| | | import com.taoke.autopay.utils.Constant; |
| | | import com.taoke.autopay.utils.StringUtil; |
| | | import com.taoke.autopay.utils.TimeUtil; |
| | | import com.taoke.autopay.vo.AgentOrderFilter; |
| | | import com.taoke.autopay.vo.AgentOrderVO; |
| | | import com.taoke.autopay.vo.OrderFilter; |
| | | import com.taoke.autopay.vo.admin.AdminChannelAgentVO; |
| | | import com.taoke.autopay.vo.admin.AgentSearchVO; |
| | | import net.sf.json.JSONArray; |
| | | import com.taoke.autopay.vo.AgentWithdrawVO; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | @Resource |
| | | private ChannelAgentSharingRatioService channelAgentSharingRatioService; |
| | | |
| | | @Resource |
| | | private ChannelAgentSettleService channelAgentSettleService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | query.oMinCreateTime = new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now - 24 * 60 * 60 * 1000L, "yyyy-MM-dd"), "yyyy-MM-dd")); |
| | | break; |
| | | case 2: |
| | | query.oMaxCreateTime = new Date(TimeUtil.convertToTimeTemp(nowDay, "yyyy-MM-dd")); |
| | | query.oMinCreateTime = new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now - 24 * 60 * 60 * 1000L * 3, "yyyy-MM-dd"), "yyyy-MM-dd")); |
| | | break; |
| | | case 3: |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date(now)); |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getConfig") |
| | | public String getConfig(HttpSession session) { |
| | | ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT); |
| | | if (agent == null) { |
| | | return JsonUtil.loadFalseResult("尚未登录"); |
| | | } |
| | | String baseSubmitKeyLink = systemConfigService.getValueCache(SystemConfigKeyEnum.AGENT_SUBMIT_KEY_LINK); |
| | | String submitKeyUrl = AgentUtil.getSubmitKeyUrl(baseSubmitKeyLink, agent.getAlias()); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("submitKeyUrl", submitKeyUrl); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("withdrawList") |
| | | public String withdrawList(int page, HttpSession session) { |
| | | ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT); |
| | | if (agent == null) { |
| | | return JsonUtil.loadFalseResult("尚未登录"); |
| | | } |
| | | |
| | | ChannelAgentSettleRecordMapper.DaoQuery daoQuery = new ChannelAgentSettleRecordMapper.DaoQuery(); |
| | | daoQuery.agentId = agent.getId(); |
| | | daoQuery.statusList = Arrays.asList(new Integer[]{ChannelAgentSettleRecord.STATUS_SETTLED, ChannelAgentSettleRecord.STATUS_WITHDRAWING, ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS, ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED}); |
| | | daoQuery.sortList = Arrays.asList(new String[]{"_update_time desc"}); |
| | | daoQuery.count = 20; |
| | | daoQuery.start = (page - 1) * 20; |
| | | List<ChannelAgentSettleRecord> recordList = channelAgentSettleService.list(daoQuery); |
| | | long count = channelAgentSettleService.count(daoQuery); |
| | | List<AgentWithdrawVO> voList = new ArrayList<>(); |
| | | for (ChannelAgentSettleRecord record : recordList) { |
| | | long totalOrderCount = 0; |
| | | for (ChannelAgentSettleDetail d : record.getDetailList()) { |
| | | totalOrderCount += d.getPayOrderCount(); |
| | | } |
| | | String statusDesc = ""; |
| | | switch (record.getStatus()) { |
| | | case ChannelAgentSettleRecord.STATUS_SETTLED: |
| | | statusDesc = "未提现"; |
| | | break; |
| | | case ChannelAgentSettleRecord.STATUS_WITHDRAWING: |
| | | statusDesc = "正在审核"; |
| | | break; |
| | | case ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS: |
| | | statusDesc = "提现成功"; |
| | | break; |
| | | case ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED: |
| | | statusDesc = "提现失败"; |
| | | break; |
| | | } |
| | | |
| | | voList.add(AgentWithdrawVO.builder() |
| | | .id(record.getId()) |
| | | .money(record.getActualSettleMoney().toString()) |
| | | .month(TimeUtil.getGernalTime(record.getSettleTime().getTime(), "yyyy年MM月")) |
| | | .status(record.getStatus()) |
| | | .statusDesc(statusDesc) |
| | | .orderCount(totalOrderCount) |
| | | .settleTime(TimeUtil.getGernalTime(record.getSettleTime().getTime(), "yyyy.MM.dd HH:mm:ss")) |
| | | .build()); |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", voList); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("withdraw") |
| | | public String withdraw(Long id, HttpSession session) { |
| | | ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT); |
| | | if (agent == null) { |
| | | return JsonUtil.loadFalseResult("尚未登录"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(agent.getAlipayName()) || StringUtil.isNullOrEmpty(agent.getAlipayAccount())) { |
| | | return JsonUtil.loadFalseResult("尚未设置支付宝信息"); |
| | | } |
| | | |
| | | try { |
| | | channelAgentSettleService.applyWithdraw(id); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (ChannelAgentSettleException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult("尚未登录"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |