package com.dsh.guns.modular.system.controller.general; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dsh.course.feignClient.account.TPubWithdrawalClient; import com.dsh.course.feignClient.account.model.QueryWithdrawalReq; import com.dsh.course.util.midtrans.Payouts; import com.dsh.guns.config.UserExt; import com.dsh.guns.core.base.controller.BaseController; import com.dsh.guns.core.common.constant.factory.PageFactory; import com.dsh.guns.core.support.HttpKit; import com.dsh.guns.core.util.SinataUtil; import com.dsh.guns.modular.system.model.TPubWithdrawal; import com.dsh.guns.modular.system.model.TSystemNotice; import com.dsh.guns.modular.system.service.ITSystemNoticeService; import com.dsh.guns.modular.system.util.ResultUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.Map; /** * 提现列表控制器 * * @author fengshuonan * @Date 2020-06-09 09:30:59 */ @Controller @RequestMapping("/tPubWithdrawal") public class TPubWithdrawalController extends BaseController { private String PREFIX = "/system/tPubWithdrawal/"; @Autowired private TPubWithdrawalClient tPubWithdrawalClient; @Autowired private ITSystemNoticeService tSystemNoticeService; /** * 跳转到提现列表首页 */ @RequestMapping("") public String index(Model model) { model.addAttribute("language",UserExt.getLanguage()); return PREFIX + "tPubWithdrawal.html"; } /** * 跳转到查看详情 */ @RequestMapping("/lookDetail/{id}/{type}") public String lookDetail(@PathVariable Integer id, @PathVariable Integer type, Model model) { TPubWithdrawal tPubWithdrawal = tPubWithdrawalClient.queryTPubWithdrawalId(id); String str = ""; if (1 == type){ str = tPubWithdrawal.getRemark(); } model.addAttribute("str",str); return "/system/tComplaint/lookDetail.html"; } /** * 跳转到立即处理页面 */ @RequestMapping("/tPubWithdrawal_immediately/{tPubWithdrawalId}") public String tPubWithdrawalUpdate(@PathVariable Integer tPubWithdrawalId, Model model) { model.addAttribute("tPubWithdrawalId",tPubWithdrawalId); model.addAttribute("language",UserExt.getLanguage()); return PREFIX + "tPubWithdrawal_immediately.html"; } /** * 获取提现列表列表 */ @RequestMapping(value = "/list") @ResponseBody public Object list(String insertTime, String name, Integer withdrawalType) { String beginTime = null; String endTime = null; if (SinataUtil.isNotEmpty(insertTime)){ String[] timeArray = insertTime.split(" - "); beginTime = timeArray[0]; endTime = timeArray[1]; } Page> page = new PageFactory>().defaultPage(); HttpServletRequest request = HttpKit.getRequest(); int limit = Integer.valueOf(request.getParameter("limit")); //每页多少条数据 int offset = Integer.valueOf(request.getParameter("offset")); if (UserExt.getUser().getObjectId() != 1){ page.setRecords(null); return super.packForBT(page); }else{ return super.packForBT(tPubWithdrawalClient.queryTPubWithdrawalList(new QueryWithdrawalReq(limit,offset,beginTime,endTime,name,withdrawalType))); } } /** * 新增提现列表 */ @RequestMapping(value = "/add") @ResponseBody public Object add(TPubWithdrawal tPubWithdrawal) { tPubWithdrawalClient.add(tPubWithdrawal); return SUCCESS_TIP; } /** * 立即处理操作 */ @RequestMapping(value = "/immediately") @ResponseBody public ResultUtil immediately(@RequestParam Integer id,@RequestParam Integer state,@RequestParam String remark) { TPubWithdrawal tPubWithdrawal = tPubWithdrawalClient.queryTPubWithdrawalId(id); if (SinataUtil.isNotEmpty(tPubWithdrawal)){ if(state == 3){ tPubWithdrawal.setState(state); //调用接口修改状态 } tPubWithdrawal.setRemark(remark); tPubWithdrawal.setHandleTime(new Date()); if(state == 2){//同意 ResultUtil payout = Payouts.payout(tPubWithdrawal.getName(), tPubWithdrawal.getCode(), tPubWithdrawal.getCode(), tPubWithdrawal.getBankCode(), "", tPubWithdrawal.getMoney().doubleValue(), remark); if(payout.getCode() == 200){ tPubWithdrawalClient.update(tPubWithdrawal); } return payout; } tPubWithdrawalClient.update(tPubWithdrawal); // Map map = new HashMap<>(); // map.put("id", String.valueOf(tPubWithdrawal.getId())); // map.put("state", String.valueOf(stateObj)); // String result = HttpRequestUtil.postRequest(PushURL.withdraw_auth_url, map); // System.out.println("提现审核接口 :【recordId="+tPubWithdrawal.getId().toString()+"】,调用接口:"+result); //增加系统消息 TSystemNotice notice = new TSystemNotice(); notice.setType(2); notice.setUserType(tPubWithdrawal.getUserType()); Integer language = UserExt.getLanguage(); notice.setContent("提现处理结果:【"+remark+"】。"); if(language==2){ notice.setContent("Withdrawal processing results:【"+remark+"】。"); } if(language==3){ notice.setContent("Hasil pemrosesan penarikan:【"+remark+"】。"); } notice.setUserId(tPubWithdrawal.getUserId()); notice.setInsertTime(new Date()); notice.setRead(1); notice.setLanguage(1); try { tSystemNoticeService.save1(notice); }catch (Exception e){ e.printStackTrace(); } } return ResultUtil.success(); } /** * 修改提现列表 */ @RequestMapping(value = "/update") @ResponseBody public Object update(TPubWithdrawal tPubWithdrawal) { tPubWithdrawalClient.update(tPubWithdrawal); return SUCCESS_TIP; } /** * 提现列表详情 */ @RequestMapping(value = "/detail/{tPubWithdrawalId}") @ResponseBody public Object detail(@PathVariable("tPubWithdrawalId") Integer tPubWithdrawalId) { return tPubWithdrawalClient.queryTPubWithdrawalId(tPubWithdrawalId); } /** * 确认付款操作 * @param id * @param reference_no * @param otp * @return */ @RequestMapping(value = "/confirmationPayment") @ResponseBody public ResultUtil confirmationPayment(Integer id, String reference_no, String otp){ TPubWithdrawal tPubWithdrawal = tPubWithdrawalClient.queryTPubWithdrawalId(id); if(null != tPubWithdrawal){ ResultUtil approve = Payouts.approve(reference_no, otp); if(approve.getCode() != 200){ return approve; } tPubWithdrawal.setState(2); tPubWithdrawalClient.update(tPubWithdrawal); //增加系统消息 TSystemNotice notice = new TSystemNotice(); notice.setType(2); notice.setUserType(tPubWithdrawal.getUserType()); Integer language = UserExt.getLanguage(); notice.setContent("提现处理结果:【"+tPubWithdrawal.getRemark()+"】。"); if(language==2){ notice.setContent("Withdrawal processing results:【"+tPubWithdrawal.getRemark()+"】。"); } if(language==3){ notice.setContent("Hasil pemrosesan penarikan:【"+tPubWithdrawal.getRemark()+"】。"); } notice.setUserId(tPubWithdrawal.getUserId()); notice.setInsertTime(new Date()); notice.setRead(1); notice.setLanguage(1); try { tSystemNoticeService.save1(notice); }catch (Exception e){ e.printStackTrace(); } } return ResultUtil.success(); } }