| | |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; |
| | | import com.supersavedriving.driver.modular.system.util.RedisUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | |
| | | |
| | | @Autowired |
| | | private IOrderService orderService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IRechargeRecordService rechargeRecordService; |
| | | |
| | | |
| | | |
| | |
| | | if(h > 0 && h > time){ |
| | | Driver driver = this.selectById(driverId); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driverId); |
| | | accountChangeDetail.setType(2); |
| | |
| | | Integer second = Integer.valueOf(value.split("_")[0]); |
| | | driverInfo.setOnline(second); |
| | | } |
| | | driverInfo.setWechatAuthorization(driver.getOpenid() == null ? 0 : 1); |
| | | return driverInfo; |
| | | } |
| | | |
| | |
| | | } |
| | | driver.setPhone(driverInfo.getPhone()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(driverInfo.getOpenid())){ |
| | | driver.setOpenid(driverInfo.getOpenid()); |
| | | } |
| | | this.updateById(driver); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | | * 清空司机积分 |
| | | */ |
| | | @Override |
| | | public void emptyIntegral() { |
| | | List<Driver> drivers = this.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("status", 1)); |
| | | List<AccountChangeDetail> list = new ArrayList<>(); |
| | | for (Driver driver : drivers) { |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver.getId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil balanceRecharge(Integer uid, Double amount) throws Exception { |
| | | Driver driver = this.selectById(uid); |
| | | //调起微信 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3); |
| | | RechargeRecord rechargeRecord = new RechargeRecord(); |
| | | rechargeRecord.setType(2); |
| | | rechargeRecord.setUserId(uid); |
| | | rechargeRecord.setCode(out_trade_no); |
| | | rechargeRecord.setAmount(amount); |
| | | rechargeRecord.setPayType(1); |
| | | rechargeRecord.setPayStatus(1); |
| | | rechargeRecord.setCreateTime(new Date()); |
| | | rechargeRecord.setAgentId(driver.getAgentId()); |
| | | rechargeRecordService.insert(rechargeRecord); |
| | | |
| | | |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("余额充值", "", out_trade_no, amount.toString(), "/base/driver/balanceRechargeCallback", "APP"); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | RechargeRecord rechargeRecord1 = rechargeRecordService.selectOne(new EntityWrapper<RechargeRecord>().eq("code", out_trade_no)); |
| | | if(rechargeRecord1.getPayStatus() != 1){ |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * SUCCESS--支付成功 |
| | | * REFUND--转入退款 |
| | | * NOTPAY--未支付 |
| | | * CLOSED--已关闭 |
| | | * REVOKED--已撤销(刷卡支付) |
| | | * USERPAYING--用户支付中 |
| | | * PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | * ACCEPT--已接收,等待扣款 |
| | | */ |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(out_trade_no, ""); |
| | | if(resultUtil.getCode() == 200){ |
| | | Map<String, String> map = resultUtil.getData(); |
| | | String trade_type = map.get("trade_type"); |
| | | String trade_state = map.get("trade_state"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | if("REFUND".equals(trade_state) || "NOTPAY".equals(trade_state) || "CLOSED".equals(trade_state) || "REVOKED".equals(trade_state) || "PAYERROR".equals(trade_state)){ |
| | | rechargeRecordService.deleteById(rechargeRecord1.getId()); |
| | | return; |
| | | } |
| | | if("SUCCESS".equals(trade_state)){ |
| | | Driver driver1 = DriverServiceImpl.this.selectById(uid); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(uid); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("余额充值"); |
| | | accountChangeDetail.setOldData(driver1.getBalance()); |
| | | driver1.setBalance(driver1.getBalance() + amount); |
| | | accountChangeDetail.setNewData(driver1.getBalance()); |
| | | DriverServiceImpl.this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | rechargeRecord1.setPayTime(new Date()); |
| | | rechargeRecord1.setPayStatus(2); |
| | | rechargeRecord1.setOrderNumber(transaction_id); |
| | | rechargeRecordService.updateById(rechargeRecord1); |
| | | return; |
| | | } |
| | | if("USERPAYING".equals(trade_state) || "ACCEPT".equals(trade_state)){ |
| | | Thread.sleep(wait); |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | return weixinpay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充值回调通知逻辑处理 |
| | | * @param out_trade_no |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void balanceRechargeCallback(String out_trade_no, String transaction_id) throws Exception { |
| | | RechargeRecord rechargeRecord1 = rechargeRecordService.selectOne(new EntityWrapper<RechargeRecord>().eq("code", out_trade_no)); |
| | | if(rechargeRecord1.getPayStatus() != 1){ |
| | | return; |
| | | } |
| | | Driver driver1 = this.selectById(rechargeRecord1.getUserId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(rechargeRecord1.getUserId()); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("余额充值"); |
| | | accountChangeDetail.setOldData(driver1.getBalance()); |
| | | driver1.setBalance(driver1.getBalance() + rechargeRecord1.getAmount()); |
| | | accountChangeDetail.setNewData(driver1.getBalance()); |
| | | this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | rechargeRecord1.setPayTime(new Date()); |
| | | rechargeRecord1.setPayStatus(2); |
| | | rechargeRecord1.setOrderNumber(transaction_id); |
| | | rechargeRecordService.updateById(rechargeRecord1); |
| | | } |
| | | } |