| | |
| | | package com.stylefeng.guns.modular.specialTrain.server.impl; |
| | | |
| | | import cn.hutool.db.nosql.redis.RedisDS; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | |
| | | @Resource |
| | | private IUserActivityRedenvelopeService userActivityRedenvelopeService; |
| | | |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | |
| | | ResultUtil resultUtil = ResultUtil.success(""); |
| | | orderPrivateCar.setCouponMoney(0D);//初始化历史数据 |
| | | orderPrivateCar.setCouponId(null); |
| | | |
| | | |
| | | //计算折扣 |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderPrivateCar.getCompanyId()); |
| | | if(null != query2){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //计算优惠券 |
| | | UserCouponRecord userCouponRecord = null; |
| | | if(null != couponId){ |
| | |
| | | orderPrivateCar.setCouponMoney(userCouponRecord.getMoney()); |
| | | orderPrivateCar.setCouponId(couponId); |
| | | } |
| | | |
| | | |
| | | //计算红包 |
| | | if(null != redDeduction && 1 == redDeduction && null == orderPrivateCar.getRedPacketId()){ |
| | | RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings(); |
| | |
| | | if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){ |
| | | orderPrivateCar.setRedPacketMoney(multiply1.doubleValue()); |
| | | orderMoney = orderMoney.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN); |
| | | |
| | | |
| | | //获取红包id |
| | | JSONArray jsonArray = new JSONArray(); |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("id", userRedPacketRecord.getId()); |
| | | BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); |
| | | |
| | | |
| | | if(multiply1.compareTo(remainingAmount) >= 0){ |
| | | userRedPacketRecord.setRemainingAmount(0D); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | |
| | | jsonObject.put("id", userRedPacketRecord.getId()); |
| | | jsonObject.put("money", userRedPacketRecord.getRemainingAmount()); |
| | | jsonArray.add(jsonObject); |
| | | |
| | | |
| | | userRedPacketRecord.setRemainingAmount(0D); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | userRedPacketRecord.setState(2); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if(payType == 1){//手机支付 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String merchantTransactionId = sdf.format(new Date()) + "1" + language + orderId; |
| | |
| | | checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html"); |
| | | checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html"); |
| | | resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | |
| | | |
| | | if(resultUtil.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, orderId, 1, 1, |
| | | orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 |
| | | }else{ |
| | | resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); |
| | | } |
| | | |
| | | |
| | | } |
| | | if(payType == 2){//银行卡支付 |
| | | BankCard bankCard = bankCardService.selectById(bankCardId); |
| | |
| | | checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html"); |
| | | checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html"); |
| | | resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | |
| | | |
| | | if(resultUtil.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, orderId, 1, 2, |
| | | orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 |
| | |
| | | if(userInfo.getBalance() == null || new BigDecimal(userInfo.getBalance()).compareTo(orderMoney) < 0){ |
| | | return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant", ""); |
| | | } |
| | | |
| | | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | |
| | | |
| | | SysIntegral query1 = sysIntegralMapper.query(orderPrivateCar.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | | |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "完成订单", orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), |
| | | 2, 1, 1, 1, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | |
| | | orderPrivateCar.setState(8); |
| | | orderPrivateCar.setPayType(3); |
| | | orderPrivateCar.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != userCouponRecord){ |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | } |
| | | |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "打车收据" : language == 2 ? "Ride receipt" : "Reçu de course", document.html()); |
| | | |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/home/igotechgh/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | |
| | | File file1 = new File("/home/igotechgh/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | |
| | | e.printStackTrace(); |
| | | System.out.println("html转pdf异常"); |
| | | } |
| | | |
| | | |
| | | String link ="https://igo.i-go.group/files/html/ride_receipt_" + orderId + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), 0, ""); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成出行订单支付,谢谢使用!" : language == 2 |
| | | ? "You've paid for the ride order successfully, thank you for using I-GO" |
| | | : "Vous avez payé la commande de course avec succès, merci d’utiliser I-GO", orderPrivateCar.getUserId(), 1); |
| | |
| | | if(payType == 4){//现金支付 |
| | | SysIntegral query1 = sysIntegralMapper.query(orderPrivateCar.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | | |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "完成订单", orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), |
| | | 2, 1, 1, 1, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | |
| | | orderPrivateCar.setState(8); |
| | | orderPrivateCar.setPayType(4); |
| | | orderPrivateCar.setDriverPay(2); |
| | | orderPrivateCar.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | |
| | | |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != userCouponRecord){ |
| | | userCouponRecord.setState(2); |
| | |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | if(null != orderPrivateCar.getRedPacketId()){ |
| | | Double money = orderPrivateCar.getRedPacketMoney(); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 7, orderPrivateCar.getId(), 1, money); |
| | |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | if(null != orderPrivateCar.getDiscountMoney() && 0 < orderPrivateCar.getDiscountMoney()){ |
| | | Double money = orderPrivateCar.getDiscountMoney(); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 6, orderPrivateCar.getId(), 1, money); |
| | |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | |
| | | // driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driverService.updateById(driver); |
| | | |
| | | |
| | | |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | |
| | | |
| | | //司机下班,修改谷歌上的车辆信息 |
| | | new Thread(()->{ |
| | | try { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | Element server_tel_french = document.getElementById("server_tel_french"); |
| | | server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "打车收据" : language == 2 ? "Ride receipt" : "Reçu de course", document.html()); |
| | | |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/home/igotechgh/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | |
| | | File file1 = new File("/home/igotechgh/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | |
| | | |
| | | |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | case 3: |
| | | text = "Le client a choisi de payer en espèces, vous devez donc encaisser le paiement.Confirmez si vous avez reçu les frais pour cette commande : Espèces GHS " + orderPrivateCar.getPayMoney(); |
| | | break; |
| | | |
| | | |
| | | } |
| | | String audioUrl = ""; |
| | | String fileName = "offlinePayment" + orderPrivateCar.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; |
| | |
| | | pushUtil.pushOfflinePayment(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getPayMoney(), audioUrl); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成出行订单支付,谢谢使用!" : language == 2 |
| | | ? "You've paid for the ride order successfully, thank you for using I-GO" |
| | | : "Vous avez payé la commande de course avec succès, merci d’utiliser I-GO", orderPrivateCar.getUserId(), 1); |
| | | } |
| | | |
| | | |
| | | this.updateAllColumnById(orderPrivateCar); |
| | | return resultUtil; |
| | | } |