| | |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | | import com.supersavedriving.driver.core.util.JwtTokenUtil; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.DriverMapper; |
| | | 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.*; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.InterfaceResponse; |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.model.Register; |
| | | 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.*; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.WeChatUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.model.Code2Session; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import org.apache.shiro.authc.SimpleAuthenticationInfo; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @Autowired |
| | | private IDriverOnlineTimeService driverOnlineTimeService; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | @Value("${wx.appletsAppid}") |
| | | private String appletsAppid; |
| | | |
| | | @Value("${alipay.appid}") |
| | | private String appid; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | //新账号 |
| | | if(null == driver){ |
| | | driver = new Driver(); |
| | | driver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | driver.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | try { |
| | | driver = setDriverParamete(driver, driverRegisterWarpper); |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | driver.setCreateTime(new Date()); |
| | | this.insert(driver); |
| | | |
| | | //司机邀请注册奖励 |
| | | if(null != driver.getInviterId()){ |
| | | Driver driver1 = this.selectById(driver.getInviterId()); |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig){ |
| | | Integer num7 = JSON.parseObject(systemConfig.getContent()).getInteger("num7"); |
| | | if(num7 > 0){ |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setChangeType(5); |
| | | accountChangeDetail.setOldData(driver1.getIntegral().doubleValue()); |
| | | driver1.setIntegral(driver1.getIntegral() + num7); |
| | | accountChangeDetail.setNewData(driver1.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("邀请司机注册奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | this.updateById(driver1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | driver.setIdcardBack(driverRegisterWarpper.getIdcardBack()); |
| | | driver.setIdcardFront(driverRegisterWarpper.getIdcardFront()); |
| | | driver.setDriverLicense(driverRegisterWarpper.getDriverLicense()); |
| | | if(ToolUtil.isNotEmpty(driverRegisterWarpper.getFirstCertificateTime())){ |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | driver.setFirstCertificateTime(sdf.parse(driverRegisterWarpper.getFirstCertificateTime())); |
| | | } |
| | | //注册地 |
| | | String code = driverRegisterWarpper.getCode(); |
| | | BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("districtCode", code).eq("status", 1)); |
| | |
| | | driver.setCityCode(branchOffice.getCityCode()); |
| | | driver.setAreaCode(branchOffice.getDistrictCode()); |
| | | driver.setAreaName(branchOffice.getDistrictName()); |
| | | driver.setInviterType(driverRegisterWarpper.getInviterType()); |
| | | driver.setInviterId(driverRegisterWarpper.getInviterId()); |
| | | if(null != driverRegisterWarpper.getInviterId()){ |
| | | driver.setInviterType(driverRegisterWarpper.getInviterType()); |
| | | driver.setInviterId(driverRegisterWarpper.getInviterId()); |
| | | } |
| | | driver.setApprovalStatus(1); |
| | | driver.setApprovalNotes(""); |
| | | driver.setApprovalTime(null); |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil<TokenWarpper> driverLogin(String receiver, String phone, String code) throws Exception { |
| | | if(ToolUtil.isEmpty(receiver)){ |
| | | receiver = "+86"; |
| | | } |
| | | String value = redisUtil.getValue(receiver + phone); |
| | | if(!"12345".equals(code) && ToolUtil.isEmpty(value)){ |
| | | return ResultUtil.error("短信验证码无效"); |
| | |
| | | if(token.length() > 16){ |
| | | key = token.substring(token.length() - 16); |
| | | } |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 7 * 24 * 60 * 60);//7天 |
| | | redisUtil.setStrValue("DRIVER_" + phone, key, 7 * 24 * 60 * 60);//7天 |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 94608000);//7天 |
| | | redisUtil.setStrValue("DRIVER_" + phone, key, 94608000);//7天 |
| | | |
| | | //下线 |
| | | for (int i = 0; i < 5; i++) { |
| | |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(lon), Double.valueOf(lat)); |
| | | //构造半径 |
| | | Distance distanceR = new Distance(5D, Metrics.KILOMETERS); |
| | | Distance distanceR = new Distance(10D, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | |
| | | @Override |
| | | public PromotionWarpper queryPromotionQRCode(Integer uid) throws Exception { |
| | | PromotionWarpper promotionWarpper = new PromotionWarpper(); |
| | | promotionWarpper.setUrl("http://121.37.15.157/share/driverShare/index.html?inviterId=" + uid); |
| | | promotionWarpper.setUrl("https://chaoshengdaijia.com/share/driverShare/index.html?inviterId=" + uid); |
| | | int user = appUserService.selectCount(new EntityWrapper<AppUser>().eq("inviterType", 2).eq("inviterId", uid).eq("status", 1)); |
| | | int driver = this.selectCount(new EntityWrapper<Driver>().eq("inviterType", 2).eq("inviterId", uid).eq("approvalStatus", 2).eq("status", 1)); |
| | | promotionWarpper.setTotal(user + driver); |
| | |
| | | */ |
| | | public void addDurationCredits(Integer driverId) throws Exception { |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | String today = sdf1.format(new Date()); |
| | | String[] s = value.split("_"); |
| | | if(!today.equals(s[1])){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | Integer second = Integer.valueOf(s[0]) + 5; |
| | | Integer time = Integer.valueOf(s[2]); |
| | | |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null == systemConfig){ |
| | | return; |
| | |
| | | long end = sdf.parse(sdf1.format(new Date()) + " " + num2 + ":00").getTime(); |
| | | long l = System.currentTimeMillis(); |
| | | if(start <= l && end > l){ |
| | | Driver driver = this.selectById(driverId); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | String today = sdf1.format(new Date()); |
| | | String[] s = value.split("_"); |
| | | if(!today.equals(s[1])){ |
| | | //修改在线时长记录 |
| | | DriverOnlineTime driverOnlineTime = driverOnlineTimeService.selectOne(new EntityWrapper<DriverOnlineTime>().eq("driverId", driverId).eq("DATE_FORMAT(`day`, '%Y-%m-%d')", s[1])); |
| | | if(null != driverOnlineTime){ |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.updateById(driverOnlineTime); |
| | | }else{ |
| | | driverOnlineTime = new DriverOnlineTime(); |
| | | driverOnlineTime.setDriverId(driverId); |
| | | driverOnlineTime.setDay(sdf1.parse(s[1])); |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.insert(driverOnlineTime); |
| | | } |
| | | driver.setOnlineTime(new BigInteger(s[0])); |
| | | this.updateById(driver); |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | Integer second = Integer.valueOf(s[0]) + 5; |
| | | Integer time = Integer.valueOf(s[2]); |
| | | |
| | | int h = Double.valueOf(second / 3600).intValue(); |
| | | if(h > 0 && h > time){ |
| | | Driver driver = this.selectById(driverId); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driverId); |
| | | accountChangeDetail.setType(2); |
| | |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("在线时长奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | driver.setOnlineTime(new BigInteger(s[0])); |
| | | this.updateById(driver); |
| | | time++; |
| | | |
| | | //修改在线时长记录 |
| | | DriverOnlineTime driverOnlineTime = driverOnlineTimeService.selectOne(new EntityWrapper<DriverOnlineTime>().eq("driverId", driverId).eq("DATE_FORMAT(`day`, '%Y-%m-%d')", s[1])); |
| | | if(null != driverOnlineTime){ |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.updateById(driverOnlineTime); |
| | | }else{ |
| | | driverOnlineTime = new DriverOnlineTime(); |
| | | driverOnlineTime.setDriverId(driverId); |
| | | driverOnlineTime.setDay(sdf1.parse(s[1])); |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.insert(driverOnlineTime); |
| | | } |
| | | } |
| | | redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time); |
| | | } |
| | | redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | DriverInfoWarpper driverInfo = new DriverInfoWarpper(); |
| | | BeanUtils.copyProperties(driver, driverInfo); |
| | | driverInfo.setWithdrawBalance(driver.getBalance()); |
| | | driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); |
| | | driverInfo.setBalance(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());//司机充值+平台充值 |
| | | driverInfo.setCommission(new BigDecimal(driver.getCommission()).add(new BigDecimal(driver.getCouponBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());//司机订单收入+司机佣金收入+司机优惠券收入+司机折扣收入 |
| | | YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid) |
| | | .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1")); |
| | | if(null != youTuiDriver){ |
| | |
| | | List<AccountChangeDetail> list = new ArrayList<>(); |
| | | for (Driver driver : drivers) { |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver.getId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | |
| | | Driver driver = this.selectById(uid); |
| | | //调起微信 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | RechargeRecord rechargeRecord = new RechargeRecord(); |
| | | rechargeRecord.setType(2); |
| | | rechargeRecord.setUserId(uid); |
| | |
| | | rechargeRecord.setAgentId(driver.getAgentId()); |
| | | rechargeRecordService.insert(rechargeRecord); |
| | | |
| | | PaymentOrder paymentOrder = new PaymentOrder(); |
| | | paymentOrder.setBizOrderId(out_trade_no); |
| | | paymentOrder.setAmount(new BigDecimal(amount).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); |
| | | paymentOrder.setOrderName("账户充值"); |
| | | paymentOrder.setPayType("WX_MINI"); |
| | | paymentOrder.setTransferType("0"); |
| | | paymentOrder.setAsynSplitFlag("1"); |
| | | paymentOrder.setAppid(appletsAppid); |
| | | paymentOrder.setOpenid(driver.getOpenid()); |
| | | paymentOrder.setTerminalIp(InetAddress.getLocalHost().getHostAddress()); |
| | | List<PaymentOrderGood> goodsDetail = new ArrayList<>(); |
| | | PaymentOrderGood paymentOrderGood = new PaymentOrderGood(); |
| | | paymentOrderGood.setGoodsName("充值"); |
| | | goodsDetail.add(paymentOrderGood); |
| | | paymentOrder.setGoodsDetail(goodsDetail); |
| | | paymentOrder.setFrontUrl(callbackPath + "/base/driver/balanceRechargeCallback");//前端回调地址 |
| | | paymentOrder.setNotifyUrl(callbackPath + "/base/driver/balanceRechargeCallback"); |
| | | paymentOrder.setParameter1(out_trade_no); |
| | | |
| | | 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()); |
| | | TrhRequest<PaymentOrder> request = new TrhRequest(); |
| | | InterfaceResponse execute = request.execute(paymentOrder, PaymentOrder.SERVICE_CODE); |
| | | if(!"0000".equals(execute.getCode())){ |
| | | return ResultUtil.error(execute.getMsg()); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | | String status = jsonObject.getString("status"); |
| | | if("2".equals(status)){ |
| | | return ResultUtil.error("失败"); |
| | | } |
| | | String merOrderId = jsonObject.getString("merOrderId"); |
| | | String payCode = jsonObject.getString("payCode"); |
| | | if(ToolUtil.isNotEmpty(payCode)){ |
| | | 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; |
| | | } |
| | | 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.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driver1.setBalance(driver1.getBalance() + amount); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | DriverServiceImpl.this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | QueryOrder queryOrder = new QueryOrder(); |
| | | queryOrder.setOriginalMerOrderId(merOrderId); |
| | | queryOrder.setQueryType("1"); |
| | | TrhRequest<QueryOrder> request = new TrhRequest(); |
| | | InterfaceResponse execute1 = request.execute(queryOrder, QueryOrder.SERVICE_CODE); |
| | | if("0000".equals(execute1.getCode())){ |
| | | JSONObject jsonObject1 = JSON.parseObject(execute1.getResult()); |
| | | String status1 = jsonObject1.getString("status"); |
| | | if("0".equals(status1)){//待处理 |
| | | Thread.sleep(wait); |
| | | num++; |
| | | } |
| | | if("1".equals(status1)){//成功 |
| | | String merOrderId = jsonObject1.getString("merOrderId"); |
| | | Driver driver1 = DriverServiceImpl.this.selectById(rechargeRecord1.getUserId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("账户充值"); |
| | | accountChangeDetail.setOldData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | driver1.setBalance(new BigDecimal(driver1.getBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | accountChangeDetail.setNewData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | 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)){ |
| | | rechargeRecord1.setPayTime(new Date()); |
| | | rechargeRecord1.setPayStatus(2); |
| | | rechargeRecord1.setOrderNumber(merOrderId); |
| | | rechargeRecord1.setSurplusDividedAmount(rechargeRecord1.getAmount()); |
| | | rechargeRecordService.updateById(rechargeRecord1); |
| | | break; |
| | | } |
| | | if("2".equals(status1) || 10 == num){//失败 |
| | | rechargeRecordService.deleteById(rechargeRecord1.getId()); |
| | | break; |
| | | } |
| | | }else{ |
| | | Thread.sleep(wait); |
| | | num++; |
| | | } |
| | | }else{ |
| | | Thread.sleep(wait); |
| | | num++; |
| | | } |
| | | if(10 == num){ |
| | | rechargeRecordService.deleteById(rechargeRecord1.getId()); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | return weixinpay; |
| | | }).start(); |
| | | } |
| | | return ResultUtil.success(payCode); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 司机端跳小程序支付 |
| | | * @param driverId |
| | | * @param jscode |
| | | * @param amount |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil balanceRecharge1(Integer driverId, String jscode, Double amount) throws Exception { |
| | | Code2Session code2Session = weChatUtil.code2Session(jscode); |
| | | if(null != code2Session.getErrcode() && code2Session.getErrcode() != 0){ |
| | | return ResultUtil.error(code2Session.getErrmsg()); |
| | | } |
| | | String openid = code2Session.getOpenid(); |
| | | Driver driver = this.selectById(driverId); |
| | | driver.setOpenid(openid); |
| | | this.updateById(driver); |
| | | return balanceRecharge(driverId, amount); |
| | | } |
| | | |
| | | /** |
| | | * 充值回调通知逻辑处理 |
| | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(rechargeRecord1.getUserId()); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("余额充值"); |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | driver1.setBalance(driver1.getBalance() + rechargeRecord1.getAmount()); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission()); |
| | | accountChangeDetail.setExplain("账户充值"); |
| | | accountChangeDetail.setOldData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | driver1.setBalance(new BigDecimal(driver1.getBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | accountChangeDetail.setNewData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | rechargeRecord1.setPayTime(new Date()); |
| | | rechargeRecord1.setPayStatus(2); |
| | | rechargeRecord1.setOrderNumber(transaction_id); |
| | | rechargeRecord1.setSurplusDividedAmount(rechargeRecord1.getAmount()); |
| | | rechargeRecordService.updateById(rechargeRecord1); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil microenterprise(Integer uid, String name, String number, String phone) throws Exception { |
| | | public ResultUtil microenterprise(Integer uid, String name, String number, String phone, String notifyUrl) throws Exception { |
| | | Driver driver = this.selectById(uid); |
| | | Register registerVO = new Register(); |
| | | registerVO.setMerUserId("driver_" + uid); |
| | | registerVO.setMerUserId(driver.getCode());//"driver_" + uid |
| | | registerVO.setPhone(phone); |
| | | registerVO.setUserType("0"); |
| | | registerVO.setUserName(name); |
| | | registerVO.setCertId(number); |
| | | registerVO.setNotifyUrl(""); |
| | | registerVO.setNotifyUrl(callbackPath + notifyUrl); |
| | | registerVO.setParameter1(uid.toString()); |
| | | TrhRequest<Register> request = new TrhRequest(); |
| | | InterfaceResponse execute = request.execute(registerVO, Register.SERVICE_CODE); |
| | | if(!"0000".equals(execute.getResult())){ |
| | | if(!"0000".equals(execute.getCode())){ |
| | | return ResultUtil.error(execute.getMsg()); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(execute.getResult()); |
| | |
| | | return ResultUtil.error("失败"); |
| | | } |
| | | if("0".equals(status)){ |
| | | driver.setMerchantIDCode(number); |
| | | driver.setMerchantName(name); |
| | | driver.setMerchantPhone(phone); |
| | | this.updateById(driver); |
| | | return ResultUtil.error("处理中"); |
| | | } |
| | | String userId = jsonObject.getString("userId"); |