| | |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //创建行程数据 |
| | | fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public ResultUtil payLogisticsOrder(Integer payType, Integer bankCardId, Integer orderId,Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() != 7){ |
| | | if(orderLogistics.getState() == 8 || orderLogistics.getState() == 9){ |
| | | return ResultUtil.error(language == 1 ? "订单已完成支付,不允许重复支付" : language == 2 ? "The order has been paid, recurring payments is not allowed." : "La commande a été payée, les paiements récurrents ne sont pas autorisés.", ""); |
| | | } |
| | | if(orderLogistics.getState() != 7){ |
| | | return ResultUtil.error(language == 1 ? "订单不在待支付状态,不允许支付" : language == 2 ? "The order is no longer with Pending Payment, making payments is not allowed." : "La commande n’est plus en attente de paiement, il n’est pas permis d’effectuer des paiements.", ""); |
| | | } |
| | | Integer uid = orderLogistics.getUserId(); |
| | | BigDecimal orderMoney = new BigDecimal(orderLogistics.getOrderMoney()); |
| | |
| | | //计算优惠券 |
| | | UserCouponRecord userCouponRecord = null; |
| | | if(null != couponId){ |
| | | //TODO 待翻译 |
| | | if(null != redDeduction && 1 == redDeduction){ |
| | | return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "Coupons and lucky-promo cannot be used at the same time." : "Les coupons et les bonus ne peuvent pas être utilisés en même temps", ""); |
| | | } |
| | |
| | | |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "余额支付"; |
| | | payTypeEnglish = "I-GO Wallet"; |
| | | payTypeFrench = "Portefeuille I-GO"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text("余额支付"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text("I-GO Wallet"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text("Portefeuille I-GO"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "现金"; |
| | | payTypeEnglish = "Cash"; |
| | | payTypeFrench = "En espèces"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text("现金"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text("Cash"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text("En espèces"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | 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); |
| | | } |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 1){ |
| | | payTypeChinese = "手机支付"; |
| | | payTypeEnglish = "Mobile money"; |
| | | payTypeFrench = "Argent mobile"; |
| | | } |
| | | if(orderLogistics.getPayType() == 2){ |
| | | payTypeChinese = "银行卡支付"; |
| | | payTypeEnglish = "Bank card"; |
| | | payTypeFrench = "Carte bancaire"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | pay_type_chinese.text(orderLogistics.getPayType() == 1 ? "手机支付" : (orderLogistics.getPayType() == 2?"银行卡支付":(orderLogistics.getPayType() == 3?"余额支付":"现金支付"))); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_chinese = document.getElementById("dispute_chinese"); |
| | |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | pay_type_english.text(orderLogistics.getPayType() == 1 ? "Mobile money" :(orderLogistics.getPayType() == 2?"Bank card":(orderLogistics.getPayType() == 3?"I-GO Wallet":"Cash"))); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_english = document.getElementById("dispute_english"); |
| | |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | pay_type_french.text(orderLogistics.getPayType() == 1 ? "Argent mobile" : (orderLogistics.getPayType() == 2?"Carte bancaire":(orderLogistics.getPayType() == 3?"Portefeuille I-GO":"En espèces"))); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element dispute_french = document.getElementById("dispute_french"); |
| | |
| | | |
| | | if((orderLogistics.getState() == 10 || orderLogistics.getState() == 12) && null != orderLogistics.getDriverId()){ |
| | | //修改行程信息 |
| | | fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderLogistics.getTrackId()); |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderLogistics.getTripId()); |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO " |
| | | : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |