|  |  |  | 
|---|
|  |  |  | package com.supersavedriving.driver.modular.system.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.supersavedriving.driver.core.util.ToolUtil; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.dao.CashWithdrawalMapper; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.model.CashWithdrawal; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.model.Driver; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.service.ICashWithdrawalService; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.service.IDriverService; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.model.*; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.service.*; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.util.MallBook.model.*; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.util.ResultUtil; | 
|---|
|  |  |  | import com.supersavedriving.driver.modular.system.util.UUIDUtil; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author zhibing.pu | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IAccountChangeDetailService accountChangeDetailService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IRechargeRecordService rechargeRecordService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IDivisionRecordService divisionRecordService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${callbackPath}") | 
|---|
|  |  |  | private String callbackPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 司机提现操作 | 
|---|
|  |  |  | * @param driverId | 
|---|
|  |  |  | * @param type | 
|---|
|  |  |  | * @param bankId | 
|---|
|  |  |  | * @param money | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public ResultUtil withdrawCash(Integer driverId, Integer type, Double money) throws Exception { | 
|---|
|  |  |  | public ResultUtil withdrawCash(Integer driverId, Integer type, Integer bankId, Double money) throws Exception { | 
|---|
|  |  |  | Driver driver = driverService.selectById(driverId); | 
|---|
|  |  |  | if(type == 1 && (null == driver.getBalance() || driver.getBalance() < money)){ | 
|---|
|  |  |  | return ResultUtil.error("账户余额不足"); | 
|---|
|  |  |  | if(type == 1 && null == driver.getBalance() || driver.getBalance() < money){ | 
|---|
|  |  |  | return ResultUtil.error("余额不足"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(type == 2 && (null == driver.getCommission() || driver.getCommission() < money)){ | 
|---|
|  |  |  | return ResultUtil.error("佣金余额不足"); | 
|---|
|  |  |  | if(type == 2 && null == driver.getCommission() || driver.getCommission() < money){ | 
|---|
|  |  |  | return ResultUtil.error("收入余额不足"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(ToolUtil.isEmpty(driver.getMerchantNumber())){ | 
|---|
|  |  |  | return ResultUtil.error("请先注册商户号"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CashWithdrawal cashWithdrawal = new CashWithdrawal(); | 
|---|
|  |  |  | cashWithdrawal.setType(2); | 
|---|
|  |  |  | cashWithdrawal.setUserDriverId(driverId); | 
|---|
|  |  |  | cashWithdrawal.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); | 
|---|
|  |  |  | cashWithdrawal.setBusinessType(type == 1 ? 12 : 11); | 
|---|
|  |  |  | cashWithdrawal.setBusinessType(type == 2 ? 11 : 12); | 
|---|
|  |  |  | cashWithdrawal.setBankId(bankId); | 
|---|
|  |  |  | cashWithdrawal.setAmount(money); | 
|---|
|  |  |  | cashWithdrawal.setState(1); | 
|---|
|  |  |  | cashWithdrawal.setCreateTime(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | accountChangeDetail.setUserId(driver.getId()); | 
|---|
|  |  |  | accountChangeDetail.setType(1); | 
|---|
|  |  |  | accountChangeDetail.setChangeType(type == 1 ? 4 : 6); | 
|---|
|  |  |  | accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | if(type == 1){ | 
|---|
|  |  |  | accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | driver.setBalance(driver.getBalance() - money); | 
|---|
|  |  |  | accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | accountChangeDetail.setExplain("账户余额提现"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(type == 2){ | 
|---|
|  |  |  | accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | driver.setCommission(driver.getCommission() - money); | 
|---|
|  |  |  | accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | accountChangeDetail.setExplain("佣金余额提现"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); | 
|---|
|  |  |  | accountChangeDetail.setExplain(type == 1 ? "账户余额提现" : "佣金余额提现"); | 
|---|
|  |  |  | driverService.updateById(driver); | 
|---|
|  |  |  | accountChangeDetailService.saveData(accountChangeDetail); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); | 
|---|
|  |  |  | String outDetailNo = sdf.format(new Date()) + cashWithdrawal.getId(); | 
|---|
|  |  |  | String s = payMoneyUtil.weixinTransferMoney(outDetailNo, money, driver.getOpenid(), driver.getName(), "【超省新代驾】提现付款!"); | 
|---|
|  |  |  | if(ToolUtil.isEmpty(s)){ | 
|---|
|  |  |  | return ResultUtil.error("提现异常,请联系管理员"); | 
|---|
|  |  |  | if(type == 1){//余额提现,调用分账接口 -->确认收货--->提现 | 
|---|
|  |  |  | fenzhang(driver, money, cashWithdrawal, 1); | 
|---|
|  |  |  | }else{//佣金提现,调用充值接口数据进行分账 | 
|---|
|  |  |  | fenzhang(driver, money, cashWithdrawal, 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cashWithdrawal.setState(2); | 
|---|
|  |  |  | cashWithdrawal.setOrderNumber(s); | 
|---|
|  |  |  | this.updateById(cashWithdrawal); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); | 
|---|
|  |  |  | //        String outDetailNo = sdf.format(new Date()) + cashWithdrawal.getId(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        String s = payMoneyUtil.weixinTransferMoney(outDetailNo, money, driver.getOpenid(), driver.getName(), "【超省新代驾】提现付款!"); | 
|---|
|  |  |  | //        if(ToolUtil.isEmpty(s)){ | 
|---|
|  |  |  | //            return ResultUtil.error("提现异常,请联系管理员"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        cashWithdrawal.setState(2); | 
|---|
|  |  |  | //        cashWithdrawal.setOrderNumber(s); | 
|---|
|  |  |  | //        this.updateById(cashWithdrawal); | 
|---|
|  |  |  | return ResultUtil.success(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 司机提现,现将支付的订单进行分账 | 
|---|
|  |  |  | * @param driver | 
|---|
|  |  |  | * @param amount | 
|---|
|  |  |  | * @param cashWithdrawal | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public ResultUtil fenzhang(Driver driver, Double amount, CashWithdrawal cashWithdrawal, Integer payType){ | 
|---|
|  |  |  | List<RechargeRecord> rechargeRecords = new ArrayList<>(); | 
|---|
|  |  |  | if(payType == 1){//司机充值 | 
|---|
|  |  |  | rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 2) | 
|---|
|  |  |  | .eq("userId", driver.getId()).eq("payType", 1).eq("payStatus", 2).gt("surplusDividedAmount", 0)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(payType == 2){//平台充值(补贴金额) | 
|---|
|  |  |  | rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>() | 
|---|
|  |  |  | .eq("payType", 2).eq("payStatus", 2).gt("surplusDividedAmount", 0)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (RechargeRecord rechargeRecord : rechargeRecords) { | 
|---|
|  |  |  | Double surplusDividedAmount = rechargeRecord.getSurplusDividedAmount(); | 
|---|
|  |  |  | if(surplusDividedAmount.compareTo(amount) >= 0){//够分账 | 
|---|
|  |  |  | DivisionRecord divisionRecord = new DivisionRecord(); | 
|---|
|  |  |  | divisionRecord.setUserType(1); | 
|---|
|  |  |  | divisionRecord.setUserId(driver.getId()); | 
|---|
|  |  |  | divisionRecord.setOrderId(rechargeRecord.getId().longValue()); | 
|---|
|  |  |  | divisionRecord.setSourceType(payType == 1 ? 3 : 2); | 
|---|
|  |  |  | divisionRecord.setAmount(surplusDividedAmount); | 
|---|
|  |  |  | divisionRecord.setMerchantNumber(driver.getMerchantNumber()); | 
|---|
|  |  |  | divisionRecord.setState(1); | 
|---|
|  |  |  | divisionRecord.setCreateTime(new Date()); | 
|---|
|  |  |  | divisionRecordService.insert(divisionRecord); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Complete complete = new Complete(); | 
|---|
|  |  |  | complete.setOriginalMerOrderId(rechargeRecord.getOrderNumber()); | 
|---|
|  |  |  | complete.setNotifyUrl(callbackPath + "/base/driver/withdrawCashFZCallback"); | 
|---|
|  |  |  | complete.setParameter1(divisionRecord.getId().toString()); | 
|---|
|  |  |  | complete.setParameter2(rechargeRecord.getId() + "_" + cashWithdrawal.getId()); | 
|---|
|  |  |  | //分账方列表 | 
|---|
|  |  |  | List<PamentOrderUser> splitList = new ArrayList<>(); | 
|---|
|  |  |  | PamentOrderUser pamentOrderUser = new PamentOrderUser(); | 
|---|
|  |  |  | pamentOrderUser.setSplitUserId(driver.getMerchantNumber()); | 
|---|
|  |  |  | pamentOrderUser.setSplitAmount(amount.toString()); | 
|---|
|  |  |  | pamentOrderUser.setSplitType("1"); | 
|---|
|  |  |  | splitList.add(pamentOrderUser); | 
|---|
|  |  |  | complete.setSplitList(splitList); | 
|---|
|  |  |  | TrhRequest<Complete> request = new TrhRequest(); | 
|---|
|  |  |  | InterfaceResponse execute = request.execute(complete, Complete.SERVICE_CODE);//分账操作 | 
|---|
|  |  |  | if("0000".equals(execute.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(execute.getResult()); | 
|---|
|  |  |  | Integer status = jsonObject.getInteger("status");//0:待处理 1:成功 2:失败 | 
|---|
|  |  |  | String merOrderId = jsonObject.getString("merOrderId"); | 
|---|
|  |  |  | if(2 == status){ | 
|---|
|  |  |  | System.err.println("司机提现分账失败:" + execute.getMsg()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(1 == status){ | 
|---|
|  |  |  | divisionRecord.setMerOrderId(merOrderId); | 
|---|
|  |  |  | divisionRecord.setPayTime(new Date()); | 
|---|
|  |  |  | divisionRecord.setState(2); | 
|---|
|  |  |  | divisionRecordService.updateById(divisionRecord); | 
|---|
|  |  |  | //间隔10秒开始调用确认收货后开始提现 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | new Timer().schedule(new TimerTask() {//确认收货和提现 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | confirmReceipt(driver, rechargeRecord, divisionRecord, cashWithdrawal); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, 15000); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("司机提现分账异常:" + execute.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | }else{//不够分账 | 
|---|
|  |  |  | DivisionRecord divisionRecord = new DivisionRecord(); | 
|---|
|  |  |  | divisionRecord.setUserType(1); | 
|---|
|  |  |  | divisionRecord.setUserId(driver.getId()); | 
|---|
|  |  |  | divisionRecord.setOrderId(rechargeRecord.getId().longValue()); | 
|---|
|  |  |  | divisionRecord.setSourceType(payType == 1 ? 3 : 2); | 
|---|
|  |  |  | divisionRecord.setAmount(surplusDividedAmount); | 
|---|
|  |  |  | divisionRecord.setMerchantNumber(driver.getMerchantNumber()); | 
|---|
|  |  |  | divisionRecord.setState(1); | 
|---|
|  |  |  | divisionRecord.setCreateTime(new Date()); | 
|---|
|  |  |  | divisionRecordService.insert(divisionRecord); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Complete complete = new Complete(); | 
|---|
|  |  |  | complete.setOriginalMerOrderId(rechargeRecord.getOrderNumber()); | 
|---|
|  |  |  | complete.setNotifyUrl(callbackPath + "/base/driver/withdrawCashFZCallback"); | 
|---|
|  |  |  | complete.setParameter1(divisionRecord.getId().toString()); | 
|---|
|  |  |  | //分账方列表 | 
|---|
|  |  |  | List<PamentOrderUser> splitList = new ArrayList<>(); | 
|---|
|  |  |  | PamentOrderUser pamentOrderUser = new PamentOrderUser(); | 
|---|
|  |  |  | pamentOrderUser.setSplitUserId(driver.getMerchantNumber()); | 
|---|
|  |  |  | pamentOrderUser.setSplitAmount(surplusDividedAmount.toString()); | 
|---|
|  |  |  | pamentOrderUser.setSplitType("1"); | 
|---|
|  |  |  | splitList.add(pamentOrderUser); | 
|---|
|  |  |  | complete.setSplitList(splitList); | 
|---|
|  |  |  | TrhRequest<Complete> request = new TrhRequest(); | 
|---|
|  |  |  | InterfaceResponse execute = request.execute(complete, Complete.SERVICE_CODE);//分账操作 | 
|---|
|  |  |  | if("0000".equals(execute.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(execute.getResult()); | 
|---|
|  |  |  | Integer status = jsonObject.getInteger("status");//0:待处理 1:成功 2:失败 | 
|---|
|  |  |  | String merOrderId = jsonObject.getString("merOrderId"); | 
|---|
|  |  |  | if(2 == status){ | 
|---|
|  |  |  | System.err.println("司机提现分账失败:" + execute.getMsg()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(1 == status){ | 
|---|
|  |  |  | divisionRecord.setMerOrderId(merOrderId); | 
|---|
|  |  |  | divisionRecord.setPayTime(new Date()); | 
|---|
|  |  |  | divisionRecord.setState(2); | 
|---|
|  |  |  | divisionRecordService.updateById(divisionRecord); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //间隔10秒开始调用确认收货后开始提现 | 
|---|
|  |  |  | new Timer().schedule(new TimerTask() {//确认收货和提现 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | confirmReceipt(driver, rechargeRecord, divisionRecord, cashWithdrawal); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, 15000); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("司机提现分账异常:" + execute.getMsg()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | amount -= surplusDividedAmount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultUtil.success(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分账后的确认收货和提现操作 | 
|---|
|  |  |  | * @param driver | 
|---|
|  |  |  | * @param rechargeRecord | 
|---|
|  |  |  | * @param divisionRecord | 
|---|
|  |  |  | * @param cashWithdrawal | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void confirmReceipt(Driver driver, RechargeRecord rechargeRecord, DivisionRecord divisionRecord, CashWithdrawal cashWithdrawal){ | 
|---|
|  |  |  | Receive receive = new Receive(); | 
|---|
|  |  |  | receive.setOriginalMerOrderId(rechargeRecord.getOrderNumber()); | 
|---|
|  |  |  | receive.setAsynMerOrderId(divisionRecord.getMerOrderId()); | 
|---|
|  |  |  | receive.setRcvAmount(divisionRecord.getAmount().toString()); | 
|---|
|  |  |  | List<ReceiveUser> splitList = new ArrayList<>(); | 
|---|
|  |  |  | ReceiveUser receiveUser = new ReceiveUser(); | 
|---|
|  |  |  | receiveUser.setSplitUserId(driver.getMerchantNumber()); | 
|---|
|  |  |  | receiveUser.setRcvSplitAmount(divisionRecord.getAmount().toString()); | 
|---|
|  |  |  | splitList.add(receiveUser); | 
|---|
|  |  |  | receive.setSplitList(splitList); | 
|---|
|  |  |  | TrhRequest<Receive> request = new TrhRequest(); | 
|---|
|  |  |  | InterfaceResponse execute1 = request.execute(receive, Receive.SERVICE_CODE);//确认收货 | 
|---|
|  |  |  | if("0000".equals(execute1.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(execute1.getResult()); | 
|---|
|  |  |  | String merOrderId = jsonObject.getString("merOrderId"); | 
|---|
|  |  |  | if(ToolUtil.isNotEmpty(merOrderId)){ | 
|---|
|  |  |  | Withdraw withdraw = new Withdraw(); | 
|---|
|  |  |  | withdraw.setUserId(driver.getMerchantNumber()); | 
|---|
|  |  |  | withdraw.setAmount(divisionRecord.getAmount().toString()); | 
|---|
|  |  |  | withdraw.setOrderName("账户余额提现"); | 
|---|
|  |  |  | withdraw.setRemark("账户余额提现"); | 
|---|
|  |  |  | withdraw.setNotifyUrl(callbackPath + "/base/driver/withdrawCashCallback"); | 
|---|
|  |  |  | withdraw.setParameter1(cashWithdrawal.getId().toString()); | 
|---|
|  |  |  | TrhRequest<Withdraw> request1 = new TrhRequest(); | 
|---|
|  |  |  | InterfaceResponse execute = request1.execute(withdraw, Withdraw.SERVICE_CODE);//结算(提现) | 
|---|
|  |  |  | if("0000".equals(execute.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject1 = JSON.parseObject(execute.getResult()); | 
|---|
|  |  |  | String merOrderId1 = jsonObject1.getString("merOrderId"); | 
|---|
|  |  |  | Integer status = jsonObject1.getInteger("status");//0:待处理;1:成功;2:失败 | 
|---|
|  |  |  | if(1 == status){ | 
|---|
|  |  |  | cashWithdrawal.setOrderNumber(merOrderId1); | 
|---|
|  |  |  | cashWithdrawal.setState(2); | 
|---|
|  |  |  | this.updateById(cashWithdrawal); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(2 == status){ | 
|---|
|  |  |  | System.err.println("结算接口异常【提现】:" + jsonObject1.getString("statusMsg")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("结算接口异常【提现】:" + execute.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("分账确认收货异常【提现】:" + execute1.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 提现分账的异步回调 | 
|---|
|  |  |  | * @param interfaceResponse | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void withdrawCashFZCallback(InterfaceResponse interfaceResponse) { | 
|---|
|  |  |  | if("0000".equals(interfaceResponse.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult()); | 
|---|
|  |  |  | Integer status = jsonObject.getInteger("status");//0:待处理 1:成功 2:失败 | 
|---|
|  |  |  | String merOrderId = jsonObject.getString("merOrderId"); | 
|---|
|  |  |  | if(2 == status){ | 
|---|
|  |  |  | System.err.println("司机提现分账失败:" + interfaceResponse.getMsg()); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(1 == status){ | 
|---|
|  |  |  | String parameter1 = jsonObject.getString("parameter1"); | 
|---|
|  |  |  | String parameter2 = jsonObject.getString("parameter2"); | 
|---|
|  |  |  | DivisionRecord divisionRecord = divisionRecordService.selectById(parameter1); | 
|---|
|  |  |  | divisionRecord.setMerOrderId(merOrderId); | 
|---|
|  |  |  | divisionRecord.setPayTime(new Date()); | 
|---|
|  |  |  | divisionRecord.setState(2); | 
|---|
|  |  |  | divisionRecordService.updateById(divisionRecord); | 
|---|
|  |  |  | Driver driver = driverService.selectById(divisionRecord.getUserId()); | 
|---|
|  |  |  | String[] s = parameter2.split("_"); | 
|---|
|  |  |  | RechargeRecord rechargeRecord = rechargeRecordService.selectById(s[0]); | 
|---|
|  |  |  | CashWithdrawal cashWithdrawal = this.selectById(s[1]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //间隔10秒开始调用确认收货后开始提现 | 
|---|
|  |  |  | new Timer().schedule(new TimerTask() {//确认收货和提现 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | confirmReceipt(driver, rechargeRecord, divisionRecord, cashWithdrawal); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, 15000); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("司机提现分账异常:" + interfaceResponse.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 提现确认收货后的结算回调 | 
|---|
|  |  |  | * @param interfaceResponse | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void withdrawCashCallback(InterfaceResponse interfaceResponse) { | 
|---|
|  |  |  | if("0000".equals(interfaceResponse.getCode())){ | 
|---|
|  |  |  | JSONObject jsonObject1 = JSON.parseObject(interfaceResponse.getResult()); | 
|---|
|  |  |  | String merOrderId1 = jsonObject1.getString("merOrderId"); | 
|---|
|  |  |  | Integer status = jsonObject1.getInteger("status");//0:待处理;1:成功;2:失败 | 
|---|
|  |  |  | if(1 == status){ | 
|---|
|  |  |  | String parameter1 = jsonObject1.getString("parameter1"); | 
|---|
|  |  |  | CashWithdrawal cashWithdrawal = this.selectById(parameter1); | 
|---|
|  |  |  | cashWithdrawal.setOrderNumber(merOrderId1); | 
|---|
|  |  |  | cashWithdrawal.setState(2); | 
|---|
|  |  |  | this.updateById(cashWithdrawal); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(2 == status){ | 
|---|
|  |  |  | System.err.println("结算接口异常【提现】:" + jsonObject1.getString("statusMsg")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | System.err.println("结算接口异常【提现】:" + interfaceResponse.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|