From 0001861cc63fc670646a103284b9eaefb193e91f Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 10 八月 2024 17:31:48 +0800 Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel into 2.0 --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 206 +++++++------ DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java | 1 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java | 10 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java | 35 +- ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TIntegralOrderController.java | 15 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java | 18 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java | 155 +++++++-- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/DriverMapper.xml | 2 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java | 18 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/RedEnvelopeController.java | 7 ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java | 6 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java | 34 ++ UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java | 290 +++++++++--------- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java | 33 ++ DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/SettlementRecordController.java | 17 15 files changed, 506 insertions(+), 341 deletions(-) diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java index ace0daa..e2a1ec1 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.mchange.util.FailSuppressedMessageLogger; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; @@ -22,6 +23,8 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -30,7 +33,10 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.text.SimpleDateFormat; import java.util.*; @@ -42,6 +48,8 @@ @RestController @RequestMapping("") public class DriverController { + + private Logger log = LoggerFactory.getLogger(DriverController.class); @Autowired private IDriverService driverService; @@ -1821,4 +1829,29 @@ throw new RuntimeException(e); } } + + + + /** + * 短信回调通知 + * @param request + */ + @ResponseBody + @PostMapping("/base/sendCellulantMessageCallback") + public void sendCellulantMessageCallback(HttpServletRequest request){ + try { + StringBuilder sb = new StringBuilder(); + InputStream inputStream = request.getInputStream(); + String s; + BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + while ((s = in.readLine()) != null) { + sb.append(s); + } + in.close(); + inputStream.close(); + log.info("短信通知回调:" + sb.toString()); + }catch (Exception e){ + e.printStackTrace(); + } + } } diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/SettlementRecordController.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/SettlementRecordController.java index 956b9ce..f9111eb 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/SettlementRecordController.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/SettlementRecordController.java @@ -1,5 +1,6 @@ package com.stylefeng.guns.modular.api; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.model.SettlementRecord; import com.stylefeng.guns.modular.system.service.IDriverService; @@ -137,7 +138,7 @@ * @return */ @ResponseBody - @PostMapping("/base/settlementRecord/querySettlementAmount") + @PostMapping("/base/settlementRecord/paymentSettlementAmountCallback") public CallbackResponse paymentSettlementAmountCallback(@RequestBody CallbackRequest callbackRequest){ CallbackResponse callbackResponse = new CallbackResponse(); try { @@ -161,12 +162,14 @@ Integer payType = Integer.valueOf(out_trade_no.substring(18, 19)); Integer id = Integer.valueOf(out_trade_no.substring(19)); - SettlementRecord settlementRecord = settlementRecordService.selectById(id); - settlementRecord.setPayType(payType); - settlementRecord.setPaymentStatus(2); - settlementRecord.setPayTime(new Date()); - settlementRecord.setCode(order_id); - settlementRecordService.updateById(settlementRecord); + List<SettlementRecord> settlementRecords = settlementRecordService.selectList(new EntityWrapper<SettlementRecord>().eq("driverId", id).eq("paymentStatus", 1)); + for (SettlementRecord settlementRecord : settlementRecords) { + settlementRecord.setPayType(payType); + settlementRecord.setPaymentStatus(2); + settlementRecord.setPayTime(new Date()); + settlementRecord.setCode(order_id); + settlementRecordService.updateById(settlementRecord); + } callbackResponse.setCheckout_request_id(order_id); callbackResponse.setMerchant_transaction_id(out_trade_no); diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/DriverMapper.xml b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/DriverMapper.xml index 1ea3ead..75c57bb 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/DriverMapper.xml +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/DriverMapper.xml @@ -177,7 +177,7 @@ b.carLicensePlate as licensePlate, b.carColor as carColor, b.vehicleId, - CONCAT(d.`name`, c.`name`) as brand, + CONCAT(d.`name`, ' ', c.`name`) as brand, ( (select count(id) from t_order_private_car where driverId = a.id and state in (7, 8, 9)) + (select count(id) from t_order_taxi where driverId = a.id and state in (7, 8, 9)) + diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java index 9059077..6fa8d1c 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java @@ -1469,7 +1469,6 @@ driver.setQrCode(QrCodeUtil.getQrCode(uid)); driverMapper.updateById(driver); } - //减去本周的收入 return map; } diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java index ff48b02..4acac24 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/SettlementRecordServiceImpl.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.dao.SettlementRecordMapper; @@ -25,6 +26,7 @@ import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; /** * @author zhibing.pu @@ -64,11 +66,26 @@ @Override public QuerySettlementAmount querySettlementAmount(Integer language, Integer driverId) { QuerySettlementAmount querySettlementAmount = new QuerySettlementAmount(); - SettlementRecord settlementRecord = this.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1)); - if(null != settlementRecord){ - querySettlementAmount.setType(settlementRecord.getType()); - querySettlementAmount.setAmount(settlementRecord.getPayMoney()); - List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("settlementRecordId", settlementRecord.getId()).orderBy("createTime desc")); + SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); + if(null != settlementAllocation) { + JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); + Double maxPrice = jsonObject.getDouble("maxPrice"); + Integer type = jsonObject.getInteger("type"); + querySettlementAmount.setType(null != maxPrice ? 1 : type); + List<SettlementRecord> settlementRecords = this.selectList(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1)); + double sum = settlementRecords.stream().mapToDouble(SettlementRecord::getPayMoney).sum(); + List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driverId).isNull("settlementRecordId")); + double sum1 = settlementDetailList.stream().mapToDouble(SettlementDetail::getPrice).sum(); + querySettlementAmount.setAmount(new BigDecimal(sum).add(new BigDecimal(sum1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); + + List<Integer> collect = settlementRecords.stream().map(SettlementRecord::getId).collect(Collectors.toList()); + Wrapper<SettlementDetail> wrapper = new EntityWrapper<SettlementDetail>(); + if(collect.size() > 0){ + wrapper.in("settlementRecordId", collect).or().isNull("settlementRecordId"); + }else{ + wrapper.isNull("settlementRecordId"); + } + settlementDetailList = settlementDetailService.selectList(wrapper.orderBy("createTime desc")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); List<QuerySettlementAmountDetails> list = new ArrayList<>(); settlementDetailList.forEach(s -> { @@ -97,15 +114,46 @@ @Override public ResultUtil paymentSettlementAmount(Integer driverId, Integer payType, Integer bankCardId, Integer language) throws Exception { Driver driver1 = driverService.selectById(driverId); - SettlementRecord settlementRecord = this.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1)); - if(null == settlementRecord){ + QuerySettlementAmount querySettlementAmount = querySettlementAmount(language, driverId); + if(querySettlementAmount.getAmount() == 0){ return ResultUtil.error(language == 1 ? "暂无需支付" : language == 2 ? "No payment is required" : "Aucun paiement n’est requis"); } - Double payMoney = settlementRecord.getPayMoney(); + + Double payMoney = 0D; + //主动生成结算主数据 + SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); + if(null == settlementAllocation){ + JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); + Double maxPrice = jsonObject.getDouble("maxPrice"); + Integer type = jsonObject.getInteger("type"); + + List<SettlementDetail> settlementDetails = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driverId).isNull("settlementRecordId")); + double sum = settlementDetails.stream().mapToDouble(SettlementDetail::getPrice).sum(); + if(sum > 0){ + SettlementRecord settlementRecord = new SettlementRecord(); + settlementRecord.setDay(new Date()); + settlementRecord.setDriverId(driverId); + settlementRecord.setType(null != maxPrice ? 1 : type); + settlementRecord.setPaymentStatus(1); + settlementRecord.setPayMoney(new BigDecimal(sum).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); + settlementRecord.setInsertTime(new Date()); + this.insert(settlementRecord); + + settlementDetails.forEach(s -> { + s.setSettlementRecordId(settlementRecord.getId()); + }); + settlementDetailService.updateBatchById(settlementDetails); + } + } + List<SettlementRecord> settlementRecords = this.selectList(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1)); + payMoney = settlementRecords.stream().mapToDouble(SettlementRecord::getPayMoney).sum(); + if(payMoney == 0){ + return ResultUtil.error(language == 1 ? "暂无需支付" : language == 2 ? "No payment is required" : "Aucun paiement n’est requis"); + } ResultUtil resultUtil = ResultUtil.success(""); if(payType == 1){//手机支付 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); - String merchantTransactionId = sdf.format(new Date()) + language + payType + settlementRecord.getId(); + String merchantTransactionId = sdf.format(new Date()) + language + payType + driver1; CheckoutRequest checkoutRequest = new CheckoutRequest(); checkoutRequest.setMsisdn(Long.valueOf(driver1.getPhone())); checkoutRequest.setCustomerEmail(driver1.getEmail()); @@ -115,7 +163,7 @@ checkoutRequest.setRequestAmount(payMoney); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Settlement cost"); - checkoutRequest.setCallbackUrl(callbackPath + "/base/settlementRecord/querySettlementAmount"); + checkoutRequest.setCallbackUrl(callbackPath + "/base/settlementRecord/paymentSettlementAmountCallback"); checkoutRequest.setPendingRedirectUrl(""); checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html"); checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html"); @@ -129,7 +177,7 @@ if(payType == 2){//银行卡支付 BankCard bankCard = bankCardService.selectById(bankCardId); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); - String merchantTransactionId = sdf.format(new Date()) + language + payType + settlementRecord.getId(); + String merchantTransactionId = sdf.format(new Date()) + language + payType + driver1; CheckoutRequest checkoutRequest = new CheckoutRequest(); checkoutRequest.setMsisdn(Long.valueOf(bankCard.getCode())); checkoutRequest.setCustomerEmail(driver1.getEmail()); @@ -139,7 +187,7 @@ checkoutRequest.setRequestAmount(payMoney); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Settlement cost"); - checkoutRequest.setCallbackUrl(callbackPath + "/base/settlementRecord/querySettlementAmount"); + checkoutRequest.setCallbackUrl(callbackPath + "/base/settlementRecord/paymentSettlementAmountCallback"); checkoutRequest.setPendingRedirectUrl(""); checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html"); checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html"); @@ -160,49 +208,72 @@ //活动余额小于结算金额 if(null != laveActivityMoney && 0 < laveActivityMoney && laveActivityMoney.compareTo(payMoney) < 0){ driver1.setLaveActivityMoney(0D); - BigDecimal m = new BigDecimal(payMoney).subtract(new BigDecimal(laveActivityMoney)).setScale(2, RoundingMode.HALF_EVEN); - driver1.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(m).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - settlementRecord.setPayMoney(laveActivityMoney); - settlementRecord.setPaymentStatus(2); - settlementRecord.setPayType(payType); - settlementRecord.setBalanceType(1); - settlementRecord.setPayTime(new Date()); - this.updateById(settlementRecord); - balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, laveActivityMoney, settlementRecord.getType() + 2); - balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 2, m.doubleValue(), settlementRecord.getType() + 2); - - SettlementRecord settlementRecord1 = new SettlementRecord(); - BeanUtils.copyProperties(settlementRecord, settlementRecord1); - settlementRecord1.setId(null); - settlementRecord1.setPayMoney(m.doubleValue()); - settlementRecord1.setBalanceType(2); - this.insert(settlementRecord1); + for (SettlementRecord settlementRecord : settlementRecords) { + Double payMoney1 = settlementRecord.getPayMoney(); + if(laveActivityMoney >= payMoney1){ + settlementRecord.setPayMoney(payMoney1); + settlementRecord.setPaymentStatus(2); + settlementRecord.setPayType(payType); + settlementRecord.setBalanceType(1); + settlementRecord.setPayTime(new Date()); + this.updateById(settlementRecord); + balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, payMoney1, settlementRecord.getType() + 2); + laveActivityMoney = new BigDecimal(laveActivityMoney).subtract(new BigDecimal(payMoney1)).doubleValue(); + }else{ + Double m = payMoney1; + if(laveActivityMoney > 0){ + settlementRecord.setPayMoney(laveActivityMoney); + settlementRecord.setPaymentStatus(2); + settlementRecord.setPayType(payType); + settlementRecord.setBalanceType(1); + settlementRecord.setPayTime(new Date()); + this.updateById(settlementRecord); + balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, laveActivityMoney, settlementRecord.getType() + 2); + laveActivityMoney = 0D; + m = new BigDecimal(payMoney1).subtract(new BigDecimal(laveActivityMoney)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + } + + SettlementRecord settlementRecord1 = new SettlementRecord(); + BeanUtils.copyProperties(settlementRecord, settlementRecord1); + settlementRecord1.setId(null); + settlementRecord1.setPayMoney(m.doubleValue()); + settlementRecord1.setBalanceType(2); + this.insert(settlementRecord1); + balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 2, m.doubleValue(), settlementRecord.getType() + 2); + laveBusinessMoney = new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(m)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); + } + } + driver1.setLaveBusinessMoney(laveBusinessMoney); } //活动余额大于结算金额 if(null != laveActivityMoney && 0 < laveActivityMoney && laveActivityMoney.compareTo(payMoney) >= 0){ driver1.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - settlementRecord.setPaymentStatus(2); - settlementRecord.setPayType(payType); - settlementRecord.setBalanceType(1); - settlementRecord.setPayTime(new Date()); - this.updateById(settlementRecord); - balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, payMoney, settlementRecord.getType() + 2); + for (SettlementRecord settlementRecord : settlementRecords) { + settlementRecord.setPaymentStatus(2); + settlementRecord.setPayType(payType); + settlementRecord.setBalanceType(1); + settlementRecord.setPayTime(new Date()); + this.updateById(settlementRecord); + balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 1, payMoney, settlementRecord.getType() + 2); + } } if(null == laveActivityMoney || 0 == laveActivityMoney){ driver1.setLaveActivityMoney(0D); driver1.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - settlementRecord.setPaymentStatus(2); - settlementRecord.setPayType(payType); - settlementRecord.setBalanceType(2); - settlementRecord.setPayTime(new Date()); - this.updateById(settlementRecord); - balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 2, payMoney, settlementRecord.getType() + 2); + for (SettlementRecord settlementRecord : settlementRecords) { + settlementRecord.setPaymentStatus(2); + settlementRecord.setPayType(payType); + settlementRecord.setBalanceType(1); + settlementRecord.setPayTime(new Date()); + this.updateById(settlementRecord); + balanceUsageRecordService.saveBalanceUsageRecord(settlementRecord.getDriverId(), 2, payMoney, settlementRecord.getType() + 2); + } } driver1.setBalance(new BigDecimal(driver1.getBalance()).subtract(new BigDecimal(payMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); //添加交易明细 - transactionDetailsService.saveData(driverId, "线下结算", payMoney, 2, 1, 2, null, null); + transactionDetailsService.saveData(driverId, "支付结算费用", payMoney, 2, 1, 2, null, null); driverService.updateById(driver1); return ResultUtil.success(""); } diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java index 2042cf8..b384d21 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java @@ -281,19 +281,23 @@ public boolean sendCellulantMessage(String toPhone, String msg){ - String url = "https://sms.nalosolutions.com/smsbackend/clientapi/Cell_resl/send-message/"; + String url = "https://sms.nalosolutions.com/smsbackend/Cell_resl/send-message/"; HttpRequest post = HttpUtil.createPost(url); post.contentType(ContentType.JSON.toString()); JSONObject params = new JSONObject(); - params.put("key", "ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf"); + params.put("key", "c_x7x5!v_1mhg(l34p05g2b@teheq)ex9mk1jj(u@nlfx_w5(rdx)tb_ttx22b3o"); + params.put("username", "I-GO"); + params.put("password", "abcd1234"); params.put("msisdn", toPhone); params.put("message", msg); params.put("sender_id", "I-GO"); + params.put("callback_url", "http://182.160.16.251:80/driver/base/sendCellulantMessageCallback"); post.body(params.toJSONString()); + System.err.println("短信请求:\n请求地址:" + url + "\n请求参数:" + params.toJSONString()); HttpResponse execute = post.execute(); String body = execute.body(); execute.close(); - System.err.println("短信:" + body); + System.err.println("短信响应:" + body); JSONObject jsonObject = JSON.parseObject(body); Integer status = jsonObject.getInteger("status"); if(null != status && 1701 == status){ diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java index 7c9f484..d788977 100644 --- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java +++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TPubWithdrawalController.java @@ -144,6 +144,8 @@ public Object immediately(@RequestParam Integer id,@RequestParam Integer state,@RequestParam String remark) { TPubWithdrawal tPubWithdrawal = tPubWithdrawalService.selectById(id); if (SinataUtil.isNotEmpty(tPubWithdrawal)){ + TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); + Integer language = tDriver.getLanguage(); tPubWithdrawal.setRemark(remark); String serviceCode = ""; @@ -153,7 +155,6 @@ serviceCode = tUser.getPhoneOperator(); phone = tUser.getPhone(); }else{ - TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); serviceCode = tDriver.getPhoneOperator(); phone = tDriver.getPhone(); } @@ -180,7 +181,6 @@ tUser.setBalance(tUser.getBalance().add(tPubWithdrawal.getMoney())); userService.updateById(tUser); }else{ - TDriver tDriver = driverService.selectById(tPubWithdrawal.getUserId()); tDriver.setBalance(tDriver.getBalance().add(tPubWithdrawal.getMoney())); if(tPubWithdrawal.getType() == 1){//活动提现 tDriver.setLaveActivityMoney(new BigDecimal(tDriver.getLaveActivityMoney()).add(tPubWithdrawal.getMoney()).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); @@ -197,7 +197,7 @@ TSystemNotice notice = new TSystemNotice(); notice.setType(2); notice.setUserType(tPubWithdrawal.getUserType()); - notice.setContent("提现处理结果:【"+remark+"】。"); + notice.setContent((language == 1 ? "提现申请反馈" : language == 2 ? "Feedback on withdrawal requests" : "Réponse à la demande de retrait") + ":【" +remark +"】。"); notice.setUserId(tPubWithdrawal.getUserId()); notice.setInsertTime(new Date()); notice.setRead(1); diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TIntegralOrderController.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TIntegralOrderController.java index 2c0b66c..b2ba489 100644 --- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TIntegralOrderController.java +++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TIntegralOrderController.java @@ -6,9 +6,7 @@ import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; -import com.stylefeng.guns.modular.system.model.TEmail; -import com.stylefeng.guns.modular.system.model.TOrderCharter; -import com.stylefeng.guns.modular.system.model.TUser; +import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.util.EmailUtil; import org.jsoup.Jsoup; @@ -23,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; import com.stylefeng.guns.core.log.LogObjectHolder; import org.springframework.web.bind.annotation.RequestParam; -import com.stylefeng.guns.modular.system.model.TIntegralOrder; import javax.annotation.Resource; import java.io.File; @@ -57,6 +54,9 @@ @Resource private ITSystemNoticeService systemNoticeService; + + @Resource + private ITIntegralGoodsService integralGoodsService; @@ -124,11 +124,12 @@ tIntegralOrderService.updateById(tIntegralOrder); TIntegralOrder tIntegralOrder1 = tIntegralOrderService.selectById(tIntegralOrder.getId()); TUser tUser = userService.selectById(tIntegralOrder1.getUserId()); + TIntegralGoods tIntegralGoods = integralGoodsService.selectById(tIntegralOrder.getGoodsId()); try { Integer language = tUser.getLanguage(); - systemNoticeService.addSystemNotice(1, language == 1 ? "您的积分兑换请求已通过审核,平台客服将会联系您,请耐心等待!" : - language == 2 ? "Your points redemption request has been approved, and I-GO customer service will contact you. Please be patient!" : - "Votre demande d’échange de points a été approuvée et le service client d’I-GO vous contactera. Soyez patient !", tIntegralOrder.getUserId()); + systemNoticeService.addSystemNotice(1, language == 1 ? "您使用" + tIntegralOrder.getIntegral() + "积分成功兑换" + tIntegralGoods.getName() : + language == 2 ? "You redeemed " + tIntegralOrder.getIntegral() + " points for the " + tIntegralGoods.getName() + " successfully" : + "Vous avez échangé " + tIntegralOrder.getIntegral() + " points avec succès contre le " + tIntegralGoods.getName() + "", tIntegralOrder.getUserId()); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java index 43aa8b6..7a4acac 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java @@ -924,20 +924,24 @@ if(null == uid){ return ResultUtil.tokenErr(); } - reason = reason.replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #39;", "'") - .replaceAll("& lt;", "<") - .replaceAll("& gt;", ">"); - remark = remark.replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #39;", "'") - .replaceAll("& lt;", "<") - .replaceAll("& gt;", ">"); + if(ToolUtil.isNotEmpty(reason)){ + reason = reason.replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #39;", "'") + .replaceAll("& lt;", "<") + .replaceAll("& gt;", ">"); + } + if(ToolUtil.isNotEmpty(remark)){ + remark = remark.replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #39;", "'") + .replaceAll("& lt;", "<") + .replaceAll("& gt;", ">"); + } switch (orderType){ case 1: return orderPrivateCarService.addCancle(id, reason, remark, uid, lon, lat, address, language); @@ -1752,7 +1756,6 @@ return ResultUtil.tokenErr(); } Double payMoney = 0D; - Integer companyId = 1; switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); @@ -1776,7 +1779,7 @@ if(null != query1){ Integer orderNum=orderLogisticsService.selectCount(new EntityWrapper<OrderLogistics>().eq("userId", uid).eq("activityId",query1.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query1.getDistance()*1000>orderLogistics.getMileage() && query1.getOrderNum()>orderNum){ - Double special = query1.getSpecial(); + Double special = query1.getLogistics(); if(null != special){ double v = new BigDecimal(orderMoney1).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); payMoney = v; diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/RedEnvelopeController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/RedEnvelopeController.java index 5f733f0..f8b2e81 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/RedEnvelopeController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/RedEnvelopeController.java @@ -8,6 +8,7 @@ import com.stylefeng.guns.modular.system.model.UserRedPacketRecord; import com.stylefeng.guns.modular.system.service.IUserInfoService; import com.stylefeng.guns.modular.system.service.IUserRedPacketRecordService; +import com.stylefeng.guns.modular.system.util.DateUtil; import com.stylefeng.guns.modular.system.util.ResultUtil; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.MyRedEnvelope; @@ -93,7 +94,7 @@ baseWarpper.setId(null != map.get("id") ? Integer.valueOf(String.valueOf(map.get("id"))) : 0); baseWarpper.setAmount(null != map.get("money") ? Double.valueOf(String.valueOf(map.get("money"))) : 0); baseWarpper.setName(null != map.get("name") ? String.valueOf(map.get("name")) : (language == 1 ? "指定发放" : language == 2 ? "Designated distribution" : "Distribution désignée")); - baseWarpper.setContent(null != map.get("insertTime") ? String.valueOf(map.get("insertTime")) : ""); + baseWarpper.setContent(null != map.get("insertTime") ? DateUtil.conversionFormat(language, String.valueOf(map.get("insertTime"))) : ""); baseWarpper.setTotalAmount(sum); baseWarpper.setRemainingAmount(sum1); baseWarppers.add(baseWarpper); @@ -129,10 +130,6 @@ } pageNum = (pageNum - 1) * size; List<Map<String, Object>> list = orderPrivateCarService.queryRedEnvelope(language, uid);//专车 -// List<Map<String, Object>> list1 = orderTaxiService.queryRedEnvelope(language, uid);//出租车 -// List<Map<String, Object>> list2 = orderCrossCityService.queryRedEnvelope(language, uid);//跨城 -// list.addAll(list1); -// list.addAll(list2); List<Map<String, Object>> list1 = orderLogisticsService.queryRedEnvelope(language, uid); list.addAll(list1); diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java index 2fc2388..45b01c4 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java @@ -26,6 +26,8 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -51,6 +53,8 @@ @RestController @RequestMapping("") public class UserInfoController { + + Logger log = LoggerFactory.getLogger(UserInfoController.class); @Autowired private IUserInfoService userInfoService; @@ -197,7 +201,32 @@ return ResultUtil.paranErr(); } } - + + + /** + * 短信回调通知 + * @param request + */ + @ResponseBody + @PostMapping("/base/sendCellulantMessageCallback") + public void sendCellulantMessageCallback(HttpServletRequest request){ + try { + StringBuilder sb = new StringBuilder(); + InputStream inputStream = request.getInputStream(); + String s; + BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + while ((s = in.readLine()) != null) { + sb.append(s); + } + in.close(); + inputStream.close(); + log.info("短信通知回调:" + sb.toString()); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @ResponseBody @PostMapping("/base/sedEmail") @ApiOperation(value = "获取邮箱验证码【1.0】", tags = {"用户端-登录"}, notes = "") @@ -717,8 +746,9 @@ Map<String, Object> map = userInfoService.queryUser(language, phone); if(null != map){ return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map)); + }else{ + return ResultUtil.error(language == 1 ? "此账号不存在" : language == 2 ? "The account does not exist" : "Ce compte n’existe pas"); } - return ResultUtil.success(new JSONObject()); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java index 66ee3c6..29e067b 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java @@ -208,6 +208,9 @@ @Autowired private ICarService carService; + @Resource + private DriverWorkMapper driverWorkMapper; + @Value("${filePath}") private String filePath; @@ -559,6 +562,13 @@ if(bo){ continue; } + + Driver driver1 = driverService.selectById(driver.getId()); + DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()) + .eq("state", 1).like("type", "4").getEntity()); + if(null == driverWork || driver1.getState() != 2){ + continue; + } String text = ""; Integer language1 = driver.getLanguage(); switch (language1){ @@ -879,63 +889,68 @@ dr = drivers.get(0); } - orderLogistics.setDriverId(dr.getId()); - orderLogistics.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : ( - dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1)); - orderLogistics.setState(2); - orderLogistics.setCarId(dr.getCarId()); - CarService query1 = carServiceMapper.query(1, dr.getCarId()); - orderLogistics.setServerCarModelId(query1.getServerCarModelId()); - orderLogistics.setSnatchOrderTime(new Date()); - - dr.setState(3); - driverService.updateById(dr); - this.updateById(orderLogistics); + Driver driver1 = driverService.selectById(dr.getId()); + DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()) + .eq("state", 1).like("type", "4").getEntity()); + if(driver1.getState() == 2 || null != driverWork){ + orderLogistics.setDriverId(dr.getId()); + orderLogistics.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : ( + dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1)); + orderLogistics.setState(2); + orderLogistics.setCarId(dr.getCarId()); + CarService query1 = carServiceMapper.query(1, dr.getCarId()); + orderLogistics.setServerCarModelId(query1.getServerCarModelId()); + orderLogistics.setSnatchOrderTime(new Date()); - String text = ""; - Integer language1 = dr.getLanguage(); - switch (language1){ - case 1: - text = "收到新的包裹订单,从" + orderLogistics.getStartAddress() + "出发,全程约" + orderLogistics.getEstimatedMileage() + "公里"; - break; - case 2: - text = "Received a new delivery order, starting from " + orderLogistics.getStartAddress() + ", the whole journey is about " + orderLogistics.getEstimatedMileage() + "kilometre"; - break; - case 3: - text = "J'ai reçu une nouvelle commande de livraison, à partir de " + orderLogistics.getStartAddress() + ", le trajet complet est d’environ " + orderLogistics.getEstimatedMileage() + "kilométrage"; - break; + dr.setState(3); + driverService.updateById(dr); + this.updateById(orderLogistics); + + String text = ""; + Integer language1 = dr.getLanguage(); + switch (language1){ + case 1: + text = "收到新的包裹订单,从" + orderLogistics.getStartAddress() + "出发,全程约" + orderLogistics.getEstimatedMileage() + "公里"; + break; + case 2: + text = "Received a new delivery order, starting from " + orderLogistics.getStartAddress() + ", the whole journey is about " + orderLogistics.getEstimatedMileage() + "kilometre"; + break; + case 3: + text = "J'ai reçu une nouvelle commande de livraison, à partir de " + orderLogistics.getStartAddress() + ", le trajet complet est d’environ " + orderLogistics.getEstimatedMileage() + "kilométrage"; + break; - } - String audioUrl = ""; - String fileName = "pushOrder" + orderLogistics.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; - try { - audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); - } catch (Exception e) { - throw new RuntimeException(e); - } - //定时任务删除语音文件 - new Timer().schedule(new TimerTask() { - @Override - public void run() { - Process process = null; - try { - process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (process != null) { - process.destroy(); - } } - }, 30000); - String finalAudioUrl = audioUrl; - new Thread(new Runnable() { - @Override - public void run() { - pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, ""); - pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl); + String audioUrl = ""; + String fileName = "pushOrder" + orderLogistics.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; + try { + audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); + } catch (Exception e) { + throw new RuntimeException(e); } - }).start(); + //定时任务删除语音文件 + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Process process = null; + try { + process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (process != null) { + process.destroy(); + } + } + }, 30000); + String finalAudioUrl = audioUrl; + new Thread(new Runnable() { + @Override + public void run() { + pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, ""); + pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl); + } + }).start(); + } } } } @@ -944,22 +959,6 @@ //推单操作 if(orderLogistics.getState() == 1){ this.pushOrder(orderLogistics); - }else{ -// //接单后定时任务判断司机是否去接乘客,没有则推送提醒 -// CancleOrder cancleOrder = cancleOrderService.query(orderLogistics.getCompanyId()); -// if(null != cancleOrder){ -// JSONObject object = JSON.parseObject(cancleOrder.getContent()); -// long time = object.getInteger("driverTimeout") * 60000L; -// new Timer().schedule(new TimerTask() { -// @Override -// public void run() { -// OrderLogistics orderLogistics1 = OrderLogisticsServiceImpl.this.selectById(orderLogistics.getId()); -// if(orderLogistics1.getState() == 2){ -// pushUtil.pushDriverTimeOut(1, orderLogistics1.getUserId(), orderLogistics1.getId(), 4); -// } -// } -// }, time); -// } } @@ -990,7 +989,7 @@ 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.", ""); } Integer uid = orderLogistics.getUserId(); - Double orderMoney = orderLogistics.getOrderMoney(); + BigDecimal orderMoney = new BigDecimal(orderLogistics.getOrderMoney()); if(orderLogistics.getUrgent() == 2){ // orderMoney += null != orderLogistics.getTipMoney() ? orderLogistics.getTipMoney() : 0; } @@ -1004,9 +1003,9 @@ Double special = query2.getLogistics(); if(null != special){ orderLogistics.setDiscount(special); - double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); + BigDecimal v = orderMoney.multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN); if(orderMoney.compareTo(v) > 0){ - orderLogistics.setDiscountMoney(orderMoney - v); + orderLogistics.setDiscountMoney(orderMoney.subtract(v).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderLogistics.setActivityId(query2.getId()); orderMoney = v; } @@ -1034,10 +1033,10 @@ if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 4){ return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); } - if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){ + if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(new BigDecimal(userCouponRecord.getFullMoney())) < 0){ return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); } - orderMoney = orderMoney - userCouponRecord.getMoney(); + orderMoney = orderMoney.subtract(new BigDecimal(userCouponRecord.getMoney())).setScale(2, RoundingMode.HALF_EVEN); orderLogistics.setCouponMoney(userCouponRecord.getMoney()); orderLogistics.setCouponId(couponId); } @@ -1051,10 +1050,10 @@ .eq("state", 1).eq("companyId", orderLogistics.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false)); BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio(); - BigDecimal multiply1 = new BigDecimal(orderMoney).multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); - if(total.compareTo(multiply1.doubleValue()) >= 0){ + BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); + if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){ orderLogistics.setRedPacketMoney(multiply1.doubleValue()); - orderMoney = orderMoney - multiply1.doubleValue(); + orderMoney = orderMoney.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN); //获取红包id JSONArray jsonArray = new JSONArray(); @@ -1062,6 +1061,9 @@ JSONObject jsonObject = new JSONObject(); jsonObject.put("id", userRedPacketRecord.getId()); BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); + if(multiply1.compareTo(BigDecimal.ZERO) == 0){ + break; + } if(multiply1.compareTo(remainingAmount) >= 0){ userRedPacketRecord.setRemainingAmount(0D); userRedPacketRecord.setEndTime(new Date()); @@ -1070,18 +1072,19 @@ jsonObject.put("money", remainingAmount); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - }else{ + }else if(remainingAmount.compareTo(multiply1) > 0){ userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); jsonObject.put("money", multiply1); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - break; + multiply1 = BigDecimal.ZERO; } } orderLogistics.setRedPacketId(jsonArray.toJSONString()); - }else{ + } + if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){ orderLogistics.setRedPacketMoney(total); - orderMoney = orderMoney - total; + orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN); //获取红包id JSONArray jsonArray = new JSONArray(); BigDecimal multiply = new BigDecimal(total); @@ -1089,6 +1092,9 @@ JSONObject jsonObject = new JSONObject(); jsonObject.put("id", userRedPacketRecord.getId()); BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); + if(multiply.compareTo(BigDecimal.ZERO) == 0){ + break; + } if(multiply.compareTo(remainingAmount) >= 0){ userRedPacketRecord.setRemainingAmount(0D); userRedPacketRecord.setEndTime(new Date()); @@ -1097,12 +1103,12 @@ jsonObject.put("money", remainingAmount); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - }else{ + }else if(remainingAmount.compareTo(multiply) > 0){ userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); jsonObject.put("money", multiply); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - break; + multiply = BigDecimal.ZERO; } } orderLogistics.setRedPacketId(jsonArray.toJSONString()); @@ -1110,8 +1116,6 @@ } } - orderMoney=new BigDecimal(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); - if(payType == 1) {//手机支付 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String merchantTransactionId = sdf.format(new Date()) + "4" + language + orderId; @@ -1121,7 +1125,7 @@ checkoutRequest.setAccountNumber(userInfo.getPhone()); checkoutRequest.setCustomerFirstName(userInfo.getFirstName()); checkoutRequest.setCustomerLastName(userInfo.getLastName()); - checkoutRequest.setRequestAmount(orderMoney); + checkoutRequest.setRequestAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Travel completion payment"); checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi"); @@ -1130,7 +1134,8 @@ checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html"); resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); if(resultUtil.getCode()==200){ - paymentRecordService.saveData(1, null, null, orderId, 4, 1, orderMoney, null, 1);//添加预支付数据 + paymentRecordService.saveData(1, null, null, orderId, 4, 1, + orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 }else{ resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); } @@ -1147,7 +1152,7 @@ checkoutRequest.setAccountNumber(bankCard.getCode()); checkoutRequest.setCustomerFirstName(bankCard.getFirstName()); checkoutRequest.setCustomerLastName(bankCard.getLastName()); - checkoutRequest.setRequestAmount(orderMoney); + checkoutRequest.setRequestAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Travel completion payment"); checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi"); @@ -1157,7 +1162,8 @@ resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); if(resultUtil.getCode()==200){ - paymentRecordService.saveData(1, null, null, orderId, 4, 2, orderMoney, null, 1);//添加预支付数据 + paymentRecordService.saveData(1, null, null, orderId, 4, 2, + orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 }else{ resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); } @@ -1165,11 +1171,11 @@ } if(payType == 3){//余额支付 - if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ + 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(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); + userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId()); userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 @@ -1182,12 +1188,13 @@ } //添加交易明细 - transactionDetailsService.saveData(uid, "包裹下单支付", orderMoney, 2, 1, 1, 4, orderId); + transactionDetailsService.saveData(uid, "包裹下单支付", + orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), 2, 1, 1, 4, orderId); userInfoService.updateById(userInfo); orderLogistics.setState(8); orderLogistics.setPayType(3); - orderLogistics.setPayMoney(orderMoney); + orderLogistics.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); //处理优惠券和红包 if(null != userCouponRecord){ @@ -1638,13 +1645,14 @@ userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 //添加交易明细 - transactionDetailsService.saveData(uid, "包裹下单支付", orderMoney, 2, 1, 1, 4, orderId); + transactionDetailsService.saveData(uid, "包裹下单支付", + orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), 2, 1, 1, 4, orderId); userInfoService.updateById(userInfo); orderLogistics.setState(8);//小件物流先支付后司机抢单 orderLogistics.setDriverPay(1); orderLogistics.setPayType(4); - orderLogistics.setPayMoney(orderMoney); + orderLogistics.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); //处理优惠券和红包 if(null != userCouponRecord){ @@ -1737,7 +1745,7 @@ settlementRecord.setInsertTime(new Date()); settlementRecordService.insert(settlementRecord); }else{ - settlementRecord.setPayMoney(total.doubleValue()); + settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); settlementRecordService.updateById(settlementRecord); } for (SettlementDetail detail : settlementDetailList) { @@ -3642,7 +3650,7 @@ Element user_chinese = document.getElementById("user_chinese"); user_chinese.text("您好 " + userInfo.getNickName() + ","); Element time_chinese = document.getElementById("time_chinese"); - time_chinese.text("此活动有效期在 " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " 至 " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",详情请查看I-GO平台"); + time_chinese.text("此活动有效期在 " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " 至 " + DateUtil.conversionFormat(language, sdf.format(id.getEndTime())) + ",详情请查看I-GO平台"); } if(2 == language){ document.getElementById("chinese").remove(); @@ -3651,7 +3659,7 @@ Element user_english = document.getElementById("user_english"); user_english.text("Hello " + userInfo.getNickName() + ","); Element time_english = document.getElementById("time_english"); - time_english.text("You could use it from " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " to " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",check more details on the app."); + time_english.text("You could use it from " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " to " + DateUtil.conversionFormat(language, sdf.format(id.getEndTime())) + ",check more details on the app."); } if(3 == language){ document.getElementById("chinese").remove(); @@ -3660,7 +3668,7 @@ Element user_french = document.getElementById("user_french"); user_french.text("Bonjour " + userInfo.getNickName() + ","); Element time_french = document.getElementById("time_french"); - time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ". Veuillez consulter la plateforme i-go pour plus de détails."); + time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEndTime())) + ". Veuillez consulter la plateforme i-go pour plus de détails."); } EmailUtil.send(userInfo.getEmail(), language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus", document.html()); diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java index a72144f..3bbc7cf 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper; -import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl; import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; @@ -28,7 +27,6 @@ import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; import com.stylefeng.guns.modular.system.warpper.BaseWarpper; import com.stylefeng.guns.modular.system.warpper.EndPushWarpper; -import com.stylefeng.guns.modular.system.warpper.OrderInfoWarpper; import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper; import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; @@ -39,7 +37,6 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.jsoup.nodes.FormElement; import org.jsoup.select.Elements; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -88,92 +85,92 @@ @Resource private RegionMapper regionMapper; - @Autowired + @Resource private DateUtil dateUtil; - @Autowired + @Resource private IUserInfoService userInfoService; - @Autowired + @Resource private IDriverService driverService; - @Autowired + @Resource private IDriverServiceService driverServiceService; - @Autowired + @Resource private PushUtil pushUtil; - @Autowired + @Resource private ICompanyCityService companyCityService; - @Autowired + @Resource private IPushOrderService pushOrderService; - @Autowired + @Resource private ISystemNoticeService systemNoticeService; - @Autowired + @Resource private ICancleOrderService cancleOrderService; - @Autowired + @Resource private IOrderCancelService orderCancelService; - @Autowired + @Resource private RestTemplate internalRestTemplate; - @Autowired + @Resource private IPaymentRecordService paymentRecordService; - @Autowired + @Resource private ITransactionDetailsService transactionDetailsService; - @Autowired + @Resource private ChinaMobileUtil chinaMobileUtil; - @Autowired + @Resource private IIncomeService incomeService; - @Autowired + @Resource private IUserCouponRecordService userCouponRecordService; - @Autowired + @Resource private IUserRedPacketRecordService userRedPacketRecordService; - @Autowired + @Resource private ICompanyService companyService; - @Autowired + @Resource private IUserActivityRedenvelopeService userActivityRedenvelopeService; - @Autowired + @Resource private RedisUtil redisUtil; - @Autowired + @Resource private IOrderPositionService orderPositionService; - @Autowired + @Resource private IOrderCrossCityService orderCrossCityService; - @Autowired + @Resource private IAssignOrderService assignOrderService; @Resource private CarMapper carMapper; - @Autowired + @Resource private IOrderEvaluateService orderEvaluateService; - @Autowired + @Resource private IOrderLogisticsService orderLogisticsService; - @Autowired + @Resource private IBankCardService bankCardService; @Value("${filePath}") private String filePath; - @Autowired + @Resource private IOrderTaxiService orderTaxiService; public static List<Integer> orderIds = new ArrayList<>(); @@ -184,32 +181,35 @@ @Value("${spring.mail.template-path}") private String templatePath; - @Autowired + @Resource private ISettlementDetailService settlementDetailService; - @Autowired + @Resource private ISettlementRecordService settlementRecordService; - @Autowired + @Resource private ISettlementAllocationService settlementAllocationService; - @Autowired + @Resource private TEmailService emailService; - @Autowired + @Resource private IPhoneService phoneService; - @Autowired + @Resource private IRedEnvelopePaymentSettingsService redEnvelopePaymentSettingsService; - @Autowired + @Resource private FleetEngineUtil fleetEngineUtil; @Resource private CarModelMapper carModelMapper; - @Autowired + @Resource private ICarService carService; + + @Resource + private DriverWorkMapper driverWorkMapper; @@ -371,7 +371,6 @@ new Thread(() -> { try { - String vehicleId = null; if(null != orderPrivateCar.getDriverId()){ Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); Car car = carMapper.selectById(driver.getCarId()); @@ -379,6 +378,7 @@ car.setVehicleId(UUIDUtil.getRandomCode()); carMapper.updateById(car); } + String vehicleId = car.getVehicleId(); //查询车辆信息,没有则创建信息 String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); if(ToolUtil.isEmpty(vehicles)){ @@ -386,10 +386,12 @@ fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); } + + //创建行程数据 + fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), + orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); } - //创建行程数据 - fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), - orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); + }catch (Exception e){ e.printStackTrace(); } @@ -497,65 +499,70 @@ }else{ dr = drivers.get(0); } - - orderPrivateCar.setDriverId(dr.getId()); - orderPrivateCar.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : ( - dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1)); - orderPrivateCar.setState(2); - orderPrivateCar.setCarId(dr.getCarId()); - CarService query1 = carServiceMapper.query(1, dr.getCarId()); - orderPrivateCar.setServerCarModelId(query1.getServerCarModelId()); - orderPrivateCar.setSnatchOrderTime(new Date()); - - dr.setState(3); - driverService.updateById(dr); - this.updateById(orderPrivateCar); - Integer language1 = dr.getLanguage(); - String text = ""; - switch (language1){ - case 1: - text = "收到新的打车订单,从" + orderPrivateCar.getStartAddress() + "出发,全程约" + orderPrivateCar.getEstimatedMileage() + "公里"; - break; - case 2: - text = "Received a new ride order, starting from " + orderPrivateCar.getStartAddress() + ", the whole journey is about " + orderPrivateCar.getEstimatedMileage() + "kilometre"; - break; - case 3: - text = "J'ai reçu une nouvelle commande de course, à partir de " + orderPrivateCar.getStartAddress() + ", le trajet complet est d’environ " + orderPrivateCar.getEstimatedMileage() + "kilométrage"; - break; + Driver driver = driverService.selectById(dr.getId()); + DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", dr.getId()) + .eq("state", 1).like("type", "1").getEntity()); + if(driver.getState() == 2 && null != driverWork){ + orderPrivateCar.setDriverId(dr.getId()); + orderPrivateCar.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : ( + dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1)); + orderPrivateCar.setState(2); + orderPrivateCar.setCarId(dr.getCarId()); + CarService query1 = carServiceMapper.query(1, dr.getCarId()); + orderPrivateCar.setServerCarModelId(query1.getServerCarModelId()); + orderPrivateCar.setSnatchOrderTime(new Date()); + + dr.setState(3); + driverService.updateById(dr); + this.updateById(orderPrivateCar); + + Integer language1 = dr.getLanguage(); + String text = ""; + switch (language1){ + case 1: + text = "收到新的打车订单,从" + orderPrivateCar.getStartAddress() + "出发,全程约" + orderPrivateCar.getEstimatedMileage() + "公里"; + break; + case 2: + text = "Received a new ride order, starting from " + orderPrivateCar.getStartAddress() + ", the whole journey is about " + orderPrivateCar.getEstimatedMileage() + "kilometre"; + break; + case 3: + text = "J'ai reçu une nouvelle commande de course, à partir de " + orderPrivateCar.getStartAddress() + ", le trajet complet est d’environ " + orderPrivateCar.getEstimatedMileage() + "kilométrage"; + break; - } - String audioUrl = ""; - String fileName = "pushOrder" + orderPrivateCar.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; - try { - audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); - } catch (Exception e) { - throw new RuntimeException(e); - } - //定时任务删除语音文件 - new Timer().schedule(new TimerTask() { - @Override - public void run() { - Process process = null; - try { - process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (process != null) { - process.destroy(); - } } - }, 30000); + String audioUrl = ""; + String fileName = "pushOrder" + orderPrivateCar.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; + try { + audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); + } catch (Exception e) { + throw new RuntimeException(e); + } + //定时任务删除语音文件 + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Process process = null; + try { + process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (process != null) { + process.destroy(); + } + } + }, 30000); - String finalAudioUrl = audioUrl; - new Thread(new Runnable() { - @Override - public void run() { - pushUtil.pushOrderState(1, uid, orderPrivateCar.getId(), 1, 2, 0, ""); - pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 2, 0, finalAudioUrl); - } - }).start(); + String finalAudioUrl = audioUrl; + new Thread(new Runnable() { + @Override + public void run() { + pushUtil.pushOrderState(1, uid, orderPrivateCar.getId(), 1, 2, 0, ""); + pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 2, 0, finalAudioUrl); + } + }).start(); + } } } } @@ -564,22 +571,6 @@ //推单操作 if(orderPrivateCar.getState() == 1){ this.pushOrder(orderPrivateCar); - }else{ -// //接单后定时任务判断司机是否去接乘客,没有则推送提醒 -// CancleOrder cancleOrder = cancleOrderService.query(orderPrivateCar.getCompanyId()); -// if(null != cancleOrder){ -// JSONObject object = JSON.parseObject(cancleOrder.getContent()); -// long time = object.getInteger("driverTimeout") * 60000L; -// new Timer().schedule(new TimerTask() { -// @Override -// public void run() { -// OrderPrivateCar orderPrivateCar1 = OrderPrivateCarServiceImpl.this.selectById(orderPrivateCar.getId()); -// if(orderPrivateCar1.getState() == 2){ -// pushUtil.pushDriverTimeOut(1, orderPrivateCar1.getUserId(), orderPrivateCar1.getId(), 1); -// } -// } -// }, time); -// } } @@ -1048,6 +1039,13 @@ continue; } + Driver driver1 = driverService.selectById(driver.getId()); + DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId()) + .eq("state", 1).like("type", "1").getEntity()); + if(driver1.getState() != 2 || null == driverWork){ + continue; + } + String text = ""; Integer language = driver.getLanguage(); switch (language){ @@ -1192,7 +1190,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 = orderPrivateCar.getUserId(); - Double orderMoney = orderPrivateCar.getOrderMoney(); + BigDecimal orderMoney = new BigDecimal(orderPrivateCar.getOrderMoney()); UserInfo userInfo = userInfoService.selectById(uid); ResultUtil resultUtil = ResultUtil.success(""); orderPrivateCar.setCouponMoney(0D);//初始化历史数据 @@ -1206,9 +1204,9 @@ Double special = query2.getSpecial(); if(null != special){ orderPrivateCar.setDiscount(special); - double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); + BigDecimal v = orderMoney.multiply(new BigDecimal(special / 10)).setScale(2, RoundingMode.HALF_EVEN); if(orderMoney.compareTo(v) > 0){ - orderPrivateCar.setDiscountMoney(orderMoney - v); + orderPrivateCar.setDiscountMoney(orderMoney.subtract(v).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setActivityId(query2.getId()); orderMoney = v; } @@ -1235,14 +1233,13 @@ if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 1){ return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); } - if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){ + if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(new BigDecimal(userCouponRecord.getFullMoney())) < 0){ return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); } - orderMoney = orderMoney - userCouponRecord.getMoney(); + orderMoney = orderMoney.subtract(new BigDecimal(userCouponRecord.getMoney())).setScale(2, RoundingMode.HALF_EVEN); orderPrivateCar.setCouponMoney(userCouponRecord.getMoney()); orderPrivateCar.setCouponId(couponId); } - orderMoney=new BigDecimal(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); //计算红包 if(null != redDeduction && 1 == redDeduction && null == orderPrivateCar.getRedPacketId()){ @@ -1253,10 +1250,10 @@ .eq("state", 1).eq("companyId", orderPrivateCar.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false)); BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio(); - BigDecimal multiply1 = new BigDecimal(orderMoney).multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); - if(total.compareTo(multiply1.doubleValue()) >= 0){ + BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); + if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){ orderPrivateCar.setRedPacketMoney(multiply1.doubleValue()); - orderMoney = orderMoney - multiply1.doubleValue(); + orderMoney = orderMoney.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN); //获取红包id JSONArray jsonArray = new JSONArray(); @@ -1264,6 +1261,9 @@ JSONObject jsonObject = new JSONObject(); jsonObject.put("id", userRedPacketRecord.getId()); BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); + if(multiply1.compareTo(BigDecimal.ZERO) == 0){ + break; + } if(multiply1.compareTo(remainingAmount) >= 0){ userRedPacketRecord.setRemainingAmount(0D); userRedPacketRecord.setEndTime(new Date()); @@ -1272,25 +1272,29 @@ jsonObject.put("money", remainingAmount); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - }else{ + }else if(remainingAmount.compareTo(multiply1) > 0){ userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); jsonObject.put("money", multiply1); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - break; + multiply1 = BigDecimal.ZERO; } } orderPrivateCar.setRedPacketId(jsonArray.toJSONString()); - }else{ + } + if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){ orderPrivateCar.setRedPacketMoney(total); - orderMoney = orderMoney - total; + orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN); //获取红包id JSONArray jsonArray = new JSONArray(); BigDecimal multiply = new BigDecimal(total); for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { JSONObject jsonObject = new JSONObject(); jsonObject.put("id", userRedPacketRecord.getId()); - BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); + BigDecimal remainingAmount = BigDecimal.valueOf(userRedPacketRecord.getRemainingAmount()); + if(multiply.compareTo(BigDecimal.ZERO) == 0){ + break; + } if(multiply.compareTo(remainingAmount) >= 0){ userRedPacketRecord.setRemainingAmount(0D); userRedPacketRecord.setEndTime(new Date()); @@ -1299,12 +1303,12 @@ jsonObject.put("money", remainingAmount); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - }else{ + }else if(remainingAmount.compareTo(multiply) > 0){ userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); jsonObject.put("money", multiply); jsonArray.add(jsonObject); userRedPacketRecordService.updateById(userRedPacketRecord); - break; + multiply = BigDecimal.ZERO; } } orderPrivateCar.setRedPacketId(jsonArray.toJSONString()); @@ -1322,7 +1326,7 @@ checkoutRequest.setAccountNumber(userInfo.getPhone()); checkoutRequest.setCustomerFirstName(userInfo.getFirstName()); checkoutRequest.setCustomerLastName(userInfo.getLastName()); - checkoutRequest.setRequestAmount(orderMoney); + checkoutRequest.setRequestAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Travel completion payment"); checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi"); @@ -1332,7 +1336,8 @@ resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); if(resultUtil.getCode()==200){ - paymentRecordService.saveData(1, null, null, orderId, 1, 1, orderMoney, null, 1);//添加预支付数据 + 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é", ""); } @@ -1348,7 +1353,7 @@ checkoutRequest.setAccountNumber(bankCard.getCode()); checkoutRequest.setCustomerFirstName(bankCard.getFirstName()); checkoutRequest.setCustomerLastName(bankCard.getLastName()); - checkoutRequest.setRequestAmount(orderMoney); + checkoutRequest.setRequestAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); checkoutRequest.setMerchantTransactionId(merchantTransactionId); checkoutRequest.setRequestDescription("Travel completion payment"); checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi"); @@ -1358,28 +1363,30 @@ resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); if(resultUtil.getCode()==200){ - paymentRecordService.saveData(1, null, null, orderId, 1, 2, orderMoney, null, 1);//添加预支付数据 + paymentRecordService.saveData(1, null, null, orderId, 1, 2, + orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 }else{ resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); } } if(payType == 3){//余额支付 - if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ + 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(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); + 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, 2, 1, 1, 1, orderId); + 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); + orderPrivateCar.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); //处理优惠券和红包 if(null != userCouponRecord){ @@ -1813,13 +1820,14 @@ userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 //添加交易明细 - transactionDetailsService.saveData(uid, "完成订单", orderMoney, 2, 1, 1, 1, orderId); + 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); + orderPrivateCar.setPayMoney(orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue()); Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); @@ -1916,7 +1924,7 @@ settlementRecord.setInsertTime(new Date()); settlementRecordService.insert(settlementRecord); }else{ - settlementRecord.setPayMoney(total.doubleValue()); + settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); settlementRecordService.updateById(settlementRecord); } for (SettlementDetail detail : settlementDetailList) { @@ -3173,7 +3181,7 @@ //读取文件(字符流) BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8")); //循环取出数据 - String str = null; + String str; StringBuffer sb = new StringBuffer(); while ((str = in.readLine()) != null) { sb.append(str); diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java index 80bb72f..e5fbae1 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserInfoServiceImpl.java @@ -34,13 +34,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; +import java.io.*; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; @@ -160,6 +158,11 @@ return ResultUtil.success(); } + + + + + /** * 校验短信验证码 @@ -1692,6 +1695,9 @@ @Override public Map<String, Object> queryUser(Integer language, String phone) throws Exception { Map<String, Object> map = userInfoMapper.queryUserInfo(null, phone); + if(null == map){ + return null; + } if(null != map.get("birthday")){ String birthday = map.get("birthday").toString(); map.put("birthday", DateUtil.conversionFormat(language, birthday)); @@ -1975,13 +1981,9 @@ String endTime = ""; if(null != map.get("startTime")){ startTime = map.get("startTime").toString(); - map.put("startTime", DateUtil.conversionFormat(language, startTime)); - startTime = DateUtil.conversionFormat(language, startTime); } if(null != map.get("endTime")){ endTime = map.get("endTime").toString(); - map.put("endTime", DateUtil.conversionFormat(language, endTime)); - endTime = DateUtil.conversionFormat(language, endTime); } double fullMoney = 0; if(null != map.get("bcompanyId")){ diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java index 656d303..0451d04 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java @@ -277,27 +277,30 @@ /** - * 短信 : https://www.nalosolutions.com/ + * 短信 : https://sms.mymailcentre.com/smsportal/cellulant * @param toPhone * @param msg * @return */ public boolean sendCellulantMessage(String toPhone, String msg){ - String url = "https://sms.nalosolutions.com/smsbackend/clientapi/Cell_resl/send-message/"; + String url = "https://sms.nalosolutions.com/smsbackend/Cell_resl/send-message/"; HttpRequest post = HttpUtil.createPost(url); post.contentType(ContentType.JSON.toString()); JSONObject params = new JSONObject(); - params.put("key", "ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf"); + params.put("key", "c_x7x5!v_1mhg(l34p05g2b@teheq)ex9mk1jj(u@nlfx_w5(rdx)tb_ttx22b3o"); + params.put("username", "I-GO"); + params.put("password", "abcd1234"); params.put("msisdn", toPhone); params.put("message", msg); params.put("sender_id", "I-GO"); - System.err.println(params.toJSONString()); + params.put("callback_url", "http://182.160.16.251:80/user/base/sendCellulantMessageCallback"); post.body(params.toJSONString()); + System.err.println("短信请求:\n请求地址:" + url + "\n请求参数:" + params.toJSONString()); HttpResponse execute = post.execute(); String body = execute.body(); execute.close(); JSONObject jsonObject = JSON.parseObject(body); - System.err.println(body); + System.err.println("短信响应:" + body); Integer status = jsonObject.getInteger("status"); if(null != status && 1701 == status){ return true; @@ -305,10 +308,13 @@ System.err.println("短信发送失败:" + jsonObject.toJSONString()); return false; } + + } public static void main(String[] ages){ + //{"callback_url":"http://182.160.16.251:80/user/base/sendCellulantMessageCallback","msisdn":"233244915521","message":"Your verification code is 2358,it is valid within 5 minutes, please do not reveal it to others.","key":"ru#0flkf3993qh!!rg!@y4)nhwi08c#tg_vasek!ja)kvfnfjyoljoz(@nai(jkf","sender_id":"I-GO"} SMSUtil smsUtil = new SMSUtil(); - smsUtil.sendCellulantMessage("233244915521", "Votre code de validation est 123456 et il est valide pendant 5 minutes. Veuillez ne pas le révéler à d’autres personnes."); + smsUtil.sendCellulantMessage("233244915521", "Your verification code is 2358,it is valid within 5 minutes, please do not reveal it to others."); } } -- Gitblit v1.7.1