driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java
@@ -5,6 +5,7 @@ import com.supersavedriving.driver.modular.system.model.JoiningRequirements; import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; import com.supersavedriving.driver.modular.system.util.huawei.OBSUtil; import com.supersavedriving.driver.modular.system.util.huawei.SMSUtil; import com.supersavedriving.driver.modular.system.warpper.*; import com.supersavedriving.driver.core.util.ToolUtil; @@ -24,9 +25,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Map; @@ -159,7 +162,7 @@ } try { String numberRandom = UUIDUtil.getNumberRandom(5); SMSUtil.send(receiver + phone, "", "[\"" + numberRandom + "\"]"); SMSUtil.send(phone, "1d0f0cbe5b214b0d8efa891730eb532a", "[\"" + numberRandom + "\"]"); redisUtil.setStrValue(receiver + phone, numberRandom, 300);//5分钟有效期 return ResponseWarpper.success(ResultUtil.success()); }catch (Exception e){ @@ -445,14 +448,14 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper<List<DriverYouTuiListWarpper>> queryDriverYouTuiList(){ public ResponseWarpper<List<DriverYouTuiWarpper>> queryDriverYouTuiList(){ try { Integer uid = driverService.getUserByRequest(); if(null == uid){ return ResponseWarpper.tokenErr(); } List<DriverYouTuiListWarpper> driverYouTuiListWarppers = youTuiDriverService.queryDriverYouTuiList(uid); return ResponseWarpper.success(driverYouTuiListWarppers); List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryDriverYouTuiList1(uid); return ResponseWarpper.success(driverYouTuiWarppers); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); @@ -626,7 +629,6 @@ @ApiOperation(value = "账户余额充值", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "充值金额", name = "amount", required = true, dataType = "double"), @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper balanceRecharge(Double amount){ @@ -684,7 +686,7 @@ @ApiImplicitParam(value = "统计时间类型(1=日,2=月,3=年)", name = "dayType", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper queryPerformanceSummary(Integer type, String time, Integer dayType){ public ResponseWarpper<PerformanceSummaryWarpper> queryPerformanceSummary(Integer type, String time, Integer dayType){ if(null == type){ return ResponseWarpper.success(ResultUtil.paranErr("type")); } @@ -808,6 +810,9 @@ return ResponseWarpper.success(ResultUtil.paranErr("code")); } try { if("12345".equals(code)){ return ResponseWarpper.success(); } ResultUtil resultUtil = ResultUtil.success(); phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone; String value = redisUtil.getValue(phone); @@ -844,4 +849,25 @@ return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/driver/uploadImg") // @ServiceLog(name = "上传头像图片", url = "/base/driver/uploadImg") @ApiOperation(value = "上传头像图片", tags = {"司机端-公共接口"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"), }) public ResponseWarpper<String> uploadImg(MultipartFile file){ try { InputStream inputStream = file.getInputStream(); String name = file.getOriginalFilename(); name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf(".")); String s = OBSUtil.putObjectToBucket(inputStream, name); return ResponseWarpper.success(s); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/ImgController.java
@@ -1,10 +1,14 @@ package com.supersavedriving.driver.modular.system.api; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.supersavedriving.driver.core.common.annotion.ServiceLog; import com.supersavedriving.driver.core.util.ToolUtil; import com.supersavedriving.driver.modular.system.model.Img; import com.supersavedriving.driver.modular.system.model.SystemConfig; import com.supersavedriving.driver.modular.system.service.IImgService; import com.supersavedriving.driver.modular.system.service.ISystemConfigService; import com.supersavedriving.driver.modular.system.util.ResultUtil; import com.supersavedriving.driver.modular.system.warpper.BaseWarpper; import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; @@ -24,6 +28,9 @@ @Autowired private IImgService imgService; @Autowired private ISystemConfigService systemConfigService; @ResponseBody @@ -38,13 +45,20 @@ return ResponseWarpper.success(ResultUtil.paranErr("type")); } try { List<Img> imgs = imgService.selectList(new EntityWrapper<Img>().eq("type", type)); List<BaseWarpper> list = new ArrayList<>(); for (Img img : imgs) { BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setId(img.getId().longValue()); baseWarpper.setPath(img.getImg()); list.add(baseWarpper); SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8)); if(null != systemConfig) { JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent()); Integer num2 = jsonObject1.getInteger("num2");//启动页开关 if(1 == num2){ List<Img> imgs = imgService.selectList(new EntityWrapper<Img>().eq("type", type)); for (Img img : imgs) { BaseWarpper baseWarpper = new BaseWarpper(); baseWarpper.setId(img.getId().longValue()); baseWarpper.setPath(img.getImg()); list.add(baseWarpper); } } } return ResponseWarpper.success(list); }catch (Exception e){ driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java
@@ -1,7 +1,9 @@ package com.supersavedriving.driver.modular.system.api; import com.supersavedriving.driver.modular.system.model.Driver; import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; import com.supersavedriving.driver.modular.system.util.rongyun.model.CloudRecordingCallback; import com.supersavedriving.driver.modular.system.warpper.*; import com.supersavedriving.driver.core.common.annotion.ServiceLog; import com.supersavedriving.driver.core.util.ToolUtil; import com.supersavedriving.driver.modular.system.service.IDriverService; import com.supersavedriving.driver.modular.system.service.IOrderService; @@ -18,7 +20,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; /** * 订单控制器 @@ -35,6 +39,9 @@ @Autowired private IDriverService driverService; @Autowired private RongYunUtil rongYunUtil; @@ -45,14 +52,14 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper<Long> queryDriverServerOrder(){ public ResponseWarpper<Map<String, Object>> queryDriverServerOrder(){ try { Integer uid = driverService.getUserByRequest(); if(null == uid){ return ResponseWarpper.tokenErr(); } Long id = orderService.queryDriverServerOrder(uid); return ResponseWarpper.success(id); Map<String, Object> map = orderService.queryDriverServerOrder(uid); return ResponseWarpper.success(map); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); @@ -68,7 +75,7 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper driverAddOrder(AddOrderWarpper addOrderWarpper){ public ResponseWarpper<Integer> driverAddOrder(AddOrderWarpper addOrderWarpper){ try { Integer uid = driverService.getUserByRequest(); if(null == uid){ @@ -425,4 +432,70 @@ return new ResponseWarpper(500, e.getMessage()); } } /** * 服务录音回调 * @param request */ @ResponseBody @PostMapping("/base/order/cloudRecordingCallback") public void cloudRecordingCallback(HttpServletRequest request){ CloudRecordingCallback cloudRecordingCallback = RongYunUtil.cloudRecordingCallback(request); System.err.println("-------------------云端录制状态回调!-------------------"); if(null == cloudRecordingCallback){ System.err.println("云端录制状态回调解析出错!"); return; } Integer type = cloudRecordingCallback.getType(); if(4 == type){//文件上传 String fileUrl = cloudRecordingCallback.getOutput().getFileUrl(); System.err.println("文件上传完毕:" + fileUrl); } } @ResponseBody @PostMapping("/api/order/openOrderQRCode") // @ServiceLog(name = "打开下单二维码操作", url = "/api/order/openOrderQRCode") @ApiOperation(value = "打开下单二维码操作", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper openOrderQRCode(){ try { Integer uid = driverService.getUserByRequest(); if(null == uid){ return ResponseWarpper.tokenErr(); } ResultUtil resultUtil = driverService.openOrderQRCode(uid); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/order/closeOrderQRCode") // @ServiceLog(name = "关闭下单二维码操作", url = "/api/order/closeOrderQRCode") @ApiOperation(value = "关闭下单二维码操作", tags = {"司机端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper closeOrderQRCode(){ try { Integer uid = driverService.getUserByRequest(); if(null == uid){ return ResponseWarpper.tokenErr(); } ResultUtil resultUtil = driverService.closeOrderQRCode(uid); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/YouTuiController.java
@@ -1,8 +1,11 @@ package com.supersavedriving.driver.modular.system.api; import com.supersavedriving.driver.core.util.ToolUtil; import com.supersavedriving.driver.modular.system.model.YouTui; import com.supersavedriving.driver.modular.system.model.YouTuiDriver; import com.supersavedriving.driver.modular.system.service.IDriverService; import com.supersavedriving.driver.modular.system.service.IYouTuiDriverService; import com.supersavedriving.driver.modular.system.service.IYouTuiService; import com.supersavedriving.driver.modular.system.util.ResultUtil; import com.supersavedriving.driver.modular.system.warpper.DriverYouTuiWarpper; import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper; @@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; /** @@ -30,6 +34,9 @@ @Autowired private IDriverService driverService; @Autowired private IYouTuiService youTuiService; @@ -123,4 +130,37 @@ return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/youtui/userYouTui") // @ServiceLog(name = "司机使用优推", url = "/api/youtui/userYouTui") @ApiOperation(value = "司机使用优推", tags = {"司机端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "优推数据id", name = "id", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper userYouTui(Integer id){ if(ToolUtil.isEmpty(id)){ return ResponseWarpper.success(ResultUtil.paranErr("id")); } try { Integer uid = driverService.getUserByRequest(); if(null == uid){ return ResponseWarpper.tokenErr(); } YouTuiDriver youTuiDriver = youTuiDriverService.selectById(id); youTuiDriver.setState(2); if(youTuiDriver.getType() == 2){ YouTui youTui = youTuiService.selectById(youTuiDriver.getYouTuiId()); youTuiDriver.setEndTime(new Date(System.currentTimeMillis() + (youTui.getNumber() * 3600000))); } youTuiDriverService.updateById(youTuiDriver); return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml
@@ -12,6 +12,7 @@ <result column="changeType" property="changeType"/> <result column="oldData" property="oldData"/> <result column="newData" property="newData"/> <result column="orderId" property="orderId"/> <result column="explain" property="explain"/> <result column="createTime" property="createTime"/> </resultMap> @@ -21,7 +22,7 @@ <select id="queryDriverIntegralIncomeAndExpenses" resultType="com.supersavedriving.driver.modular.system.warpper.IntegralIncomeAndExpensesWarpper"> select * from ( select explain as description, `explain` as description, UNIX_TIMESTAMP(createTime) * 1000 as createTime, (newData - oldData) as integral from t_account_change_detail where `type` = 2 and userType = 2 and userId = #{driverId} driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/DriverMapper.xml
@@ -48,5 +48,6 @@ <result column="wxCollectionCode" property="wxCollectionCode"/> <result column="zfbCollectionCode" property="zfbCollectionCode"/> <result column="openid" property="openid"/> <result column="openOrderQRCode" property="openOrderQRCode"/> </resultMap> </mapper> driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml
@@ -174,7 +174,7 @@ </select> <select id="queryDriverrank" resultType="com.supersavedriving.driver.modular.system.warpper.PerformanceRankingWarpper"> <select id="queryDriverRank" resultType="com.supersavedriving.driver.modular.system.warpper.PerformanceRankingWarpper"> select aa.driverId, aa.name, driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/YouTuiDriverMapper.xml
@@ -26,10 +26,15 @@ select b.`name`, b.integral, UNIX_TIMESTAMP(a.createTime) * 1000 as createTime UNIX_TIMESTAMP(a.createTime) * 1000 as createTime, a.state from t_you_tui_driver a left join t_you_tui b on (a.youTuiId = b.id) where a.driverId = #{driverId} and DATE_FORMAT(a.createTime, '%Y年%m月') = #{createTime} order by a.createTime desc where a.driverId = #{driverId} <if test="null != createTime and '' != createTime"> and DATE_FORMAT(a.createTime, '%Y年%m月') = #{createTime} </if> order by a.createTime desc </select> driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/AccountChangeDetail.java
@@ -43,7 +43,7 @@ @TableField("type") private Integer type; /** * 变动类型(1=订单收入,2=订单支出,3=充值,4=提现,5=佣金收入,6=佣金提现,7=优惠券收入,8=保险支付) * 变动类型(1=订单收入,2=订单支出,3=充值,4=提现,5=佣金收入,6=佣金提现,7=优惠券收入,8=保险支付,9=线下收款支付) */ @TableField("changeType") private Integer changeType; @@ -58,6 +58,11 @@ @TableField("newData") private Double newData; /** * 订单id */ @TableField("orderId") private Long orderId; /** * 变动说明 */ @TableField("explain") driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Driver.java
@@ -232,4 +232,9 @@ */ @TableField("openid") private String openid; /** * 是否打开下单二维码 */ @TableField("openOrderQRCode") private Integer openOrderQRCode; } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Order.java
@@ -218,6 +218,11 @@ @TableField("estimatedMileage") private Double estimatedMileage; /** * 预估时间 */ @TableField("estimatedTime") private Integer estimatedTime; /** * 订单金额 */ @TableField("orderMoney") driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IAccountChangeDetailService.java
@@ -57,4 +57,10 @@ * @throws Exception */ List<BalanceDetailWarpper> queryBalanceDetail(Integer driverId, String time, Integer type, Integer pageNum, Integer pageSize) throws Exception; /** * 处理司机保险费用 */ void deductionInsurance(); } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IDriverService.java
@@ -158,4 +158,21 @@ * @throws Exception */ ResultUtil recoverPassword(Integer uid, String password) throws Exception; /** * 打开下单二维码 * @param uid * @return */ ResultUtil openOrderQRCode(Integer uid) throws Exception; /** * 关闭下单二维码 * @param uid * @return * @throws Exception */ ResultUtil closeOrderQRCode(Integer uid) throws Exception; } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java
@@ -10,6 +10,7 @@ import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper; import java.util.List; import java.util.Map; /** * 订单 @@ -25,7 +26,7 @@ * @return * @throws Exception */ Long queryDriverServerOrder(Integer uid) throws Exception; Map<String, Object> queryDriverServerOrder(Integer uid) throws Exception; /** driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IYouTuiDriverService.java
@@ -20,6 +20,10 @@ List<DriverYouTuiListWarpper> queryDriverYouTuiList(Integer driverId) throws Exception; List<DriverYouTuiWarpper> queryDriverYouTuiList1(Integer driverId) throws Exception; /** * 获取司机优推列表 * @param driverId driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/AccountChangeDetailServiceImpl.java
@@ -1,13 +1,22 @@ package com.supersavedriving.driver.modular.system.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.supersavedriving.driver.modular.system.dao.AccountChangeDetailMapper; import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; import com.supersavedriving.driver.modular.system.model.Driver; import com.supersavedriving.driver.modular.system.model.SystemConfig; import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; import com.supersavedriving.driver.modular.system.service.IDriverService; import com.supersavedriving.driver.modular.system.service.ISystemConfigService; import com.supersavedriving.driver.modular.system.util.UUIDUtil; import com.supersavedriving.driver.modular.system.warpper.BalanceDetailWarpper; import com.supersavedriving.driver.modular.system.warpper.CommissionDetailListWarpper; import com.supersavedriving.driver.modular.system.warpper.CommissionDetailWarpper; import com.supersavedriving.driver.modular.system.warpper.IntegralIncomeAndExpensesWarpper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; @@ -20,6 +29,15 @@ */ @Service public class AccountChangeDetailServiceImpl extends ServiceImpl<AccountChangeDetailMapper, AccountChangeDetail> implements IAccountChangeDetailService { @Autowired private IDriverService driverService; @Autowired private ISystemConfigService systemConfigService; /** @@ -86,4 +104,144 @@ List<BalanceDetailWarpper> balanceDetailWarppers = this.baseMapper.queryBalanceDetail(driverId, time, type, pageNum, pageSize); return balanceDetailWarppers; } /** * 处理司机保险 */ @Override public void deductionInsurance() { SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3)); if(null == systemConfig){ return; } JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); Double num1 = jsonObject.getDouble("num1"); List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("status", 1)); for (Driver driver : drivers) { Double couponBalance = driver.getCouponBalance(); Double backgroundBalance = driver.getBackgroundBalance(); Double balance = driver.getBalance(); Double commission = driver.getCommission(); double all = couponBalance + backgroundBalance + balance + commission; if(num1 > all){ continue; } double d = num1.doubleValue(); if(backgroundBalance < d){ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getBackgroundBalance()); accountChangeDetail.setNewData(0D); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); d -= backgroundBalance; driver.setBackgroundBalance(0D); }else{ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getBackgroundBalance()); d = 0; driver.setBackgroundBalance(driver.getBackgroundBalance() - d); accountChangeDetail.setNewData(driver.getBackgroundBalance()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); } if(d > 0){ if(couponBalance < d){ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getCouponBalance()); accountChangeDetail.setNewData(0D); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); d -= couponBalance; driver.setCouponBalance(0D); }else{ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getCouponBalance()); d = 0; driver.setCouponBalance(driver.getCouponBalance() - d); accountChangeDetail.setNewData(driver.getCouponBalance()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); } } if(d > 0){ if(commission < d){ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getCommission()); accountChangeDetail.setNewData(0D); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); d -= commission; driver.setCommission(0D); }else{ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getCommission()); d = 0; driver.setCommission(driver.getCommission() - d); accountChangeDetail.setNewData(driver.getCommission()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); } } if(d > 0){ if(balance < d){ continue; }else{ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(8); accountChangeDetail.setOldData(driver.getBalance()); d = 0; driver.setBalance(driver.getBalance() - d); accountChangeDetail.setNewData(driver.getBalance()); accountChangeDetail.setExplain("收取保险费"); accountChangeDetail.setCreateTime(new Date()); this.insert(accountChangeDetail); } } driverService.updateById(driver); } } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java
@@ -12,11 +12,9 @@ import com.supersavedriving.driver.modular.system.model.*; import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.dao.DriverMapper; import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; import com.supersavedriving.driver.modular.system.util.RedisUtil; import com.supersavedriving.driver.modular.system.util.ResultUtil; import com.supersavedriving.driver.modular.system.util.UUIDUtil; import com.supersavedriving.driver.modular.system.util.*; import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; import com.supersavedriving.driver.modular.system.warpper.*; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.UsernamePasswordToken; @@ -93,6 +91,9 @@ @Autowired private IAgentService agentService; @Autowired private RongYunUtil rongYunUtil; @@ -217,6 +218,16 @@ tokenWarpper.setToken(token); tokenWarpper.setValidTime(7200L); tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1); String RYToken = rongYunUtil.getToken(driver.getId().toString(), driver.getName(), driver.getAvatar()); if(ToolUtil.isNotEmpty(RYToken)){ JSONObject jsonObject = JSON.parseObject(RYToken); Integer code1 = jsonObject.getInteger("code"); if(200 == code1){ tokenWarpper.setRytoken(jsonObject.getString("token")); } } return ResultUtil.success(tokenWarpper); } @@ -261,6 +272,14 @@ tokenWarpper.setToken(token); tokenWarpper.setValidTime(Integer.valueOf(7 * 24 * 60 * 60).longValue()); tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1); String RYToken = rongYunUtil.getToken(driver.getId().toString(), driver.getName(), driver.getAvatar()); if(ToolUtil.isNotEmpty(RYToken)){ JSONObject jsonObject = JSON.parseObject(RYToken); Integer code1 = jsonObject.getInteger("code"); if(200 == code1){ tokenWarpper.setRytoken(jsonObject.getString("token")); } } return ResultUtil.success(tokenWarpper); } @@ -444,7 +463,7 @@ @Override public PromotionWarpper queryPromotionQRCode(Integer uid) throws Exception { PromotionWarpper promotionWarpper = new PromotionWarpper(); promotionWarpper.setUrl("http://127.0.0.1?uid=" + 2 + "utype=" + 2); promotionWarpper.setUrl("http://121.37.15.157/share/driverShare/index.html?inviterId=" + uid); int user = appUserService.selectCount(new EntityWrapper<AppUser>().eq("inviterType", 2).eq("inviterId", uid).eq("status", 1)); int driver = this.selectCount(new EntityWrapper<Driver>().eq("inviterType", 2).eq("inviterId", uid).eq("approvalStatus", 2).eq("status", 1)); promotionWarpper.setTotal(user + driver); @@ -523,9 +542,10 @@ BeanUtils.copyProperties(driver, driverInfo); driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid).last(" and failureTime > now() order by failureTime limit 0, 1")); YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid) .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1")); if(null != youTuiDriver){ driverInfo.setYouTuiStart(youTuiDriver.getCreateTime().getTime()); driverInfo.setYouTuiEnd(youTuiDriver.getType() == 1 ? youTuiDriver.getFailureTime().getTime() : youTuiDriver.getEndTime().getTime()); } List<Integer> state = Arrays.asList(107, 108, 109); int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT('%Y-%m-%d', createTime) = DATE_FORMAT('%Y-%m-%d', now())")); @@ -574,11 +594,13 @@ } if(ToolUtil.isNotEmpty(driverInfo.getPhone()) && ToolUtil.isNotEmpty(driverInfo.getCode())){ String value = redisUtil.getValue(driverInfo.getPhone()); if(ToolUtil.isEmpty(value)){ return ResultUtil.error("验证码已过期"); } if(!value.equals(driverInfo.getPhone())){ return ResultUtil.error("验证码无效"); if(!"12345".equals(driverInfo.getCode())){ if(ToolUtil.isEmpty(value)){ return ResultUtil.error("验证码已过期"); } if(!value.equals(driverInfo.getCode())){ return ResultUtil.error("验证码无效"); } } driver.setPhone(driverInfo.getPhone()); } @@ -696,6 +718,12 @@ Thread.sleep(wait); num++; } }else{ Thread.sleep(wait); num++; } if(10 == num){ rechargeRecordService.deleteById(rechargeRecord1.getId()); } } }catch (Exception e){ @@ -775,4 +803,42 @@ this.updateById(driver); return ResultUtil.success(); } /** * 打开下单二维码 * @param uid * @return * @throws Exception */ @Override public ResultUtil openOrderQRCode(Integer uid) throws Exception { Driver driver = this.selectById(uid); driver.setOpenOrderQRCode(1); this.updateById(driver); new Timer().schedule(new TimerTask() { @Override public void run() { Driver driver = DriverServiceImpl.this.selectById(uid); driver.setOpenOrderQRCode(0); DriverServiceImpl.this.updateById(driver); } }, 120000); return ResultUtil.success(); } /** * 关闭下单二维码 * @param uid * @return * @throws Exception */ @Override public ResultUtil closeOrderQRCode(Integer uid) throws Exception { Driver driver = this.selectById(uid); driver.setOpenOrderQRCode(0); this.updateById(driver); return ResultUtil.success(); } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java
@@ -5,12 +5,9 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.supersavedriving.driver.core.util.ToolUtil; import com.supersavedriving.driver.modular.system.model.*; import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.dao.DriverWorkMapper; import com.supersavedriving.driver.modular.system.model.Driver; import com.supersavedriving.driver.modular.system.model.DriverWork; import com.supersavedriving.driver.modular.system.model.OrderTransfer; import com.supersavedriving.driver.modular.system.model.SystemConfig; import com.supersavedriving.driver.modular.system.service.*; import com.supersavedriving.driver.modular.system.util.RedisUtil; import com.supersavedriving.driver.modular.system.util.ResultUtil; @@ -18,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.Date; import java.util.List; /** * 司机上下班操作记录 @@ -42,7 +41,6 @@ @Autowired private RedisUtil redisUtil; @@ -95,6 +93,11 @@ */ @Override public ResultUtil driverOffWork(Integer driverId, Long onlineTime) throws Exception { List<Integer> state = Arrays.asList(102, 103, 104, 105, 106, 201, 401); int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", driverId).eq("status", 1).in("state", state)); if(count > 0){ return ResultUtil.error("还有未完成的订单"); } DriverWork driverWork = this.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driverId).eq("status", 1)); if(null == driverWork){ return ResultUtil.error("您还未上班"); @@ -108,6 +111,9 @@ } driverWork.setStatus(2); this.updateById(driverWork); Driver driver = driverService.selectById(driverId); driver.setServerStatus(1); driverService.updateById(driver); return ResultUtil.success(); } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderPositionServiceImpl.java
@@ -103,8 +103,16 @@ if(50 >= wgs84 && 12 <= (null == num ? 0 : num)){//1分钟(5秒上传一次数据) Integer integer = map.get(order.getId().toString()); map.put(order.getId().toString(), integer++); order.setState(401);//进入等待状态 order.setStartWaitTime(new Date()); //进入等待状态 ProcessOperationsWarpper processOperationsWarpper = new ProcessOperationsWarpper(); processOperationsWarpper.setOrderId(order.getId()); processOperationsWarpper.setState(401); try { orderService.driverProcessOperations(order.getDriverId(), processOperationsWarpper); } catch (Exception e) { e.printStackTrace(); } } if(50 >= wgs84 && 12 > (null == num ? 0 : num)){ Integer integer = map.get(order.getId().toString()); driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java
@@ -107,12 +107,15 @@ * @throws Exception */ @Override public Long queryDriverServerOrder(Integer uid) throws Exception { Order order = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201))); public Map<String, Object> queryDriverServerOrder(Integer uid) throws Exception { Order order = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1) .in("state", Arrays.asList(102, 103, 104, 105, 106, 401))); Map<String, Object> map = new HashMap<>(); if(null != order){ return order.getId(); map.put("id", order.getId()); map.put("state", order.getState()); } return 0L; return map; } @@ -129,14 +132,13 @@ * 司机上线且空闲,下单直接给当前司机,其余进大厅 * 司机下的订单不需要创建新用户,且只能走线下支付 */ int count = this.selectCount(new EntityWrapper<Order>().eq("userPhone", addOrderWarpper.getPhone()).eq("status", 1).in("state", Arrays.asList(101, 102, 103, 104, 105, 106, 201))); if(count > 0){ return ResultUtil.error("该用户还有未完成的订单"); } Driver driver = driverService.selectById(uid); DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); Order order1 = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201))); Order order1 = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201, 401))); Order order = new Order(); if(driverWork != null && null == order1){ order.setDriverId(uid); @@ -168,11 +170,13 @@ } d = Double.valueOf(distance.get("distance")) / 1000; order.setEstimatedMileage(d); order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60); } String city = ""; District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat()); if(null != geocode){ WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>() .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') ")); city = null != weatherCity ? weatherCity.getId().toString() : ""; } order = getOrderPrice(1, d, 0, order, city); @@ -188,7 +192,7 @@ //开始推单 pushOrder(order); } return ResultUtil.success(); return ResultUtil.success(order.getState() == 102 ? order.getId() : null); } @@ -299,28 +303,36 @@ } //恶劣天气 boolean badWeather = WeatherUtil.isBadWeather(city); if(badWeather){ order.setBadWeatherDistance(num5);//恶劣天气公里 order.setBadWeatherPrice(num6);//恶劣天气费 if(distance.compareTo(num7) > 0){ BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num7)); BigDecimal multiply = subtract.multiply(new BigDecimal(num8)); order.setOverBadWeatherDistance(subtract.doubleValue());//恶劣天气超出公里 order.setOverBadWeatherPrice(multiply.doubleValue());//恶劣天气超出公里费 } systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8)); if(null != systemConfig) { JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent()); Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价 if(1 == num11){ boolean badWeather = WeatherUtil.isBadWeather(city); if(badWeather){ order.setBadWeatherDistance(num5);//恶劣天气公里 order.setBadWeatherPrice(num6);//恶劣天气费 if(distance.compareTo(num7) > 0){ BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num7)); BigDecimal multiply = subtract.multiply(new BigDecimal(num8)); order.setOverBadWeatherDistance(subtract.doubleValue());//恶劣天气超出公里 order.setOverBadWeatherPrice(multiply.doubleValue());//恶劣天气超出公里费 } double add = new BigDecimal(order.getOverBadWeatherPrice()).add(new BigDecimal(order.getBadWeatherPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); if(num9.compareTo(add) < 0){//超出最高金额(重新调整金额) if(num9.compareTo(num6) < 0){//如果恶劣天气费大于最高金额 order.setBadWeatherPrice(num9);//恶劣天气费 order.setOverBadWeatherPrice(0D);//恶劣天气超出公里费 }else{ BigDecimal subtract = new BigDecimal(num9).subtract(new BigDecimal(add)); order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费 double add = new BigDecimal(order.getOverBadWeatherPrice()).add(new BigDecimal(order.getBadWeatherPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); if(num9.compareTo(add) < 0){//超出最高金额(重新调整金额) if(num9.compareTo(num6) < 0){//如果恶劣天气费大于最高金额 order.setBadWeatherPrice(num9);//恶劣天气费 order.setOverBadWeatherPrice(0D);//恶劣天气超出公里费 }else{ BigDecimal subtract = new BigDecimal(num9).subtract(new BigDecimal(add)); order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费 } } } } } //计算折扣 if(null != order.getUserId()){ @@ -434,6 +446,9 @@ //开始范围查找 if(null == driver){ for (int i = 1; i < 4; i++) { if(null != driver){ break; } num = jsonObject.getDouble("num" + i) / 1000;//范围公里 //构造半径 distanceR = new Distance(num, Metrics.KILOMETERS); @@ -517,13 +532,16 @@ @Override public List<HallOrderList> queryOrderHall(Integer uid, Integer pageNum, Integer pageSize) throws Exception { pageNum = (pageNum - 1) * pageSize; String value = redisUtil.getValue("DRIVER" + uid); List<HallOrderList> hallOrderLists = this.baseMapper.queryOrderHall(pageNum, pageSize); hallOrderLists.forEach(hallOrderList -> { hallOrderList.setCurrentDistance(0D); if(ToolUtil.isNotEmpty(hallOrderList.getEndLng())){ Map<String, Double> distance = GeodesyUtil.getDistance(hallOrderList.getStartLng() + "," + hallOrderList.getStartLat(), hallOrderList.getEndLng() + "," + hallOrderList.getEndLat()); if(ToolUtil.isNotEmpty(value)){ Map<String, Double> distance = GeodesyUtil.getDistance(hallOrderList.getStartLng() + "," + hallOrderList.getStartLat(), value); Double wgs84 = distance.get("WGS84"); hallOrderList.setCurrentDistance(wgs84); }else{ hallOrderList.setCurrentDistance(0D); } }); return hallOrderLists; @@ -566,8 +584,8 @@ accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(order.getDriverId()); accountChangeDetail.setType(2); accountChangeDetail.setOldData(driver.getIntegral().doubleValue()); driver.setIntegral(driver.getIntegral() - num10); accountChangeDetail.setOldData(null == driver.getIntegral() ? 0 : driver.getIntegral().doubleValue()); driver.setIntegral((null == driver.getIntegral() ? 0 : driver.getIntegral()) - num10); accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); accountChangeDetail.setExplain("拒绝订单扣除积分"); accountChangeDetailService.saveData(accountChangeDetail); @@ -591,6 +609,11 @@ DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1)); if(null == driverWork){ return ResultUtil.error("请先上班"); } List<Integer> state1 = Arrays.asList(102, 103, 104, 105, 106, 201, 401); int count = this.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state1)); if(count > 0){ return ResultUtil.error("还有未完成的订单"); } boolean lock = redisUtil.lock(); if(!lock){ @@ -662,6 +685,7 @@ } //推动订单数据 pushOrderInfo(order.getId(), uid);//开始推送订单数据 //发送系统消息 systemMessageService.addSystemMessage(uid, 2, "接单成功", "您已成功接到用户订单,请尽快联系客户!"); pushUtil.pushOrderStatus(order.getDriverId(), 2, order.getId(), order.getState()); @@ -687,6 +711,9 @@ @Override public OrderInfoWarpper queryOrderInfo(Integer uid, Long orderId) throws Exception { OrderInfoWarpper orderInfoWarpper = this.baseMapper.queryOrderInfo(orderId); if(orderInfoWarpper.getTravelTime() == null){ orderInfoWarpper.setTravelTime(0); } AppUser appUser = appUserService.selectById(uid); orderInfoWarpper.setBalance(appUser.getAccountBalance()); orderInfoWarpper.setCurrentDistance(0D); @@ -724,7 +751,6 @@ switch (processOperationsWarpper.getState()){ case 103: order.setGoToAppointmentPointTime(new Date()); pushOrderInfo(order.getId(), uid);//开始推送订单数据 break; case 104: order.setStartWaitTime(new Date()); @@ -736,10 +762,10 @@ order.setBoardingTime(new Date()); order.setStartTime(new Date()); } order.setStartWaitTime(null); //计算等待用户时长 Integer w = Double.valueOf((System.currentTimeMillis() - order.getStartWaitTime().getTime()) / 60000).intValue(); order.setWaitTime(order.getWaitTime() + w); order.setStartWaitTime(null); break; case 106: order.setGetoffTime(new Date()); @@ -748,17 +774,12 @@ order.setEndLng(processOperationsWarpper.getEndLng()); order.setEndLat(processOperationsWarpper.getEndLat()); } //停止定时任务 Timer timer = timerMap.get(order.getId().toString()); if(null != timer){ timer.cancel(); timerMap.remove(order.getId().toString()); } //开始计算费用 String city = ""; District geocode = MapUtil.geocode(order.getEndLng(), order.getEndLat()); if(null != geocode){ WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>() .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') ")); city = null != weatherCity ? weatherCity.getId().toString() : ""; } order = getOrderPrice(2, Double.valueOf(order.getActualMileage() / 1000), order.getWaitTime(), order, city); @@ -836,21 +857,23 @@ return; } AppUser appUser = appUserService.selectById(order.getUserId()); if(appUser.getInviterType() == 1){ return; if(null != appUser && null != appUser.getInviterType()){ if(appUser.getInviterType() == 1){ return; } Driver driver1 = driverService.selectById(appUser.getInviterId()); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(2); accountChangeDetail.setOldData(driver1.getIntegral().doubleValue()); driver1.setIntegral(driver1.getIntegral() + num4); accountChangeDetail.setNewData(driver1.getIntegral().doubleValue()); accountChangeDetail.setExplain("推荐用户完成首单奖励"); accountChangeDetailService.saveData(accountChangeDetail); driverService.updateById(driver1); } Driver driver1 = driverService.selectById(appUser.getInviterId()); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(2); accountChangeDetail.setOldData(driver1.getIntegral().doubleValue()); driver1.setIntegral(driver1.getIntegral() + num4); accountChangeDetail.setNewData(driver1.getIntegral().doubleValue()); accountChangeDetail.setExplain("推荐用户完成首单奖励"); accountChangeDetailService.saveData(accountChangeDetail); driverService.updateById(driver1); } } @@ -870,7 +893,7 @@ public void run() { String value = redisUtil.getValue("DRIVER" + uid); Order order = OrderServiceImpl.this.selectById(orderId); if(order.getState() == 106){ if(order.getState() == 106 || order.getState() == 301){ Timer timer = timerMap.get(order.getId().toString()); if(null != timer){ timer.cancel(); @@ -894,8 +917,11 @@ pushOrderInfoWarpper.setTravelTime(travelTime); } pushUtil.pushOrderInfo(uid, 2, pushOrderInfoWarpper); if(null != order.getUserId()){ pushUtil.pushOrderInfo(order.getUserId(), 1, pushOrderInfoWarpper); } } },0, 5000); },0, 10000); timerMap.put(orderId.toString(), timer); } @@ -954,10 +980,12 @@ } Double d = Double.valueOf(distance.get("distance")) / 1000; order.setEstimatedMileage(d); order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60); String city = ""; District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat()); if(null != geocode){ WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>().where(" '" + geocode.getDistrict() + "' like district")); WeatherCity weatherCity = weatherCityService.selectOne(new EntityWrapper<WeatherCity>() .where("'" + geocode.getCity() + "' like CONCAT('%', city, '%') and '" + geocode.getDistrict() + "' like CONCAT('%', district, '%') ")); city = null != weatherCity ? weatherCity.getId().toString() : ""; } order = getOrderPrice(1, d, 0, order, city); @@ -1022,6 +1050,11 @@ cancelOrder.setStatus(1); cancelOrder.setCreateTime(new Date()); cancelOrderService.insert(cancelOrder); Driver driver = driverService.selectById(order.getDriverId()); if(null != driver){ driver.setServerStatus(1); driverService.updateById(driver); } return ResultUtil.success(); } @@ -1039,8 +1072,23 @@ Order order = this.selectById(orderId); OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper(); BeanUtils.copyProperties(order, orderPriceWarpper); orderPriceWarpper.setWaitTime(orderPriceWarpper.getWaitTime() + orderPriceWarpper.getOutWaitTime()); orderPriceWarpper.setWaitTimePrice(orderPriceWarpper.getWaitTimePrice() + orderPriceWarpper.getOutWaitTimePrice()); orderPriceWarpper.setLongDistance(0D); if(ToolUtil.isNotEmpty(order.getLongDistance())){ String[] split = order.getLongDistance().split("-"); Double longDistanc = Double.valueOf(split[1]) - Double.valueOf(split[0]) + orderPriceWarpper.getOverLongDistance(); orderPriceWarpper.setLongDistance(longDistanc); } orderPriceWarpper.setLongDistancePrice(orderPriceWarpper.getLongDistancePrice() + orderPriceWarpper.getOverLongDistancePrice()); orderPriceWarpper.setBadWeatherDistance(orderPriceWarpper.getBadWeatherDistance() + orderPriceWarpper.getOverBadWeatherDistance()); orderPriceWarpper.setBadWeatherPrice(orderPriceWarpper.getBadWeatherPrice() + orderPriceWarpper.getOverBadWeatherPrice()); orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue()); orderPriceWarpper.setTravelTime(0); if(null != order.getGetoffTime()){ orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue()); } orderPriceWarpper.setWxCollectionCode(driver.getWxCollectionCode()); orderPriceWarpper.setZfbCollectionCode(driver.getZfbCollectionCode()); return orderPriceWarpper; @@ -1058,7 +1106,7 @@ @Override public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer state) throws Exception { List<Integer> s = Arrays.asList(107, 108); if(s.contains(state)){ if(!s.contains(state)){ return ResultUtil.error("操作失败"); } Order order = this.selectById(orderId); @@ -1074,9 +1122,12 @@ saveRevenue(order); } pushUtil.pushOrderStatus(order.getDriverId(), 2, orderId, order.getState()); PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper(); pushOrderInfoWarpper.setId(order.getId()); pushOrderInfoWarpper.setState(order.getState()); pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper); if(null != order.getUserId()){ pushUtil.pushOrderStatus(order.getUserId(), 1, orderId, order.getState()); pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState()); } return ResultUtil.success(); } @@ -1086,8 +1137,256 @@ * 计算抽成和分佣 * @param order */ public void saveRevenue(Order order){ public void saveRevenue(Order order) throws Exception{ //司机收入和代理商抽成(先分佣,后抽成) //司机分佣和司机推荐用户首单奖励都在平台的抽佣中扣除,剩余的为平台抽佣。 Driver driver = driverService.selectById(order.getDriverId()); AppUser appUser = appUserService.selectById(order.getUserId()); Double payMoney = order.getPayMoney(); SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 3)); Double n = 0D; if(null != systemConfig){ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); Double num2 = jsonObject.getDouble("num2"); Double num3 = jsonObject.getDouble("num3"); n = num3; if(order.getPayMoney() >= num2){ payMoney = payMoney - num3;//司机收入 SystemConfig systemConfig1 = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 2)); if(null != systemConfig1){ JSONObject jsonObject1 = JSON.parseObject(systemConfig1.getContent()); //司机推荐首单收入 List<Integer> state = Arrays.asList(108, 109); int count = this.selectCount(new EntityWrapper<Order>().eq("userId", appUser.getId()).eq("status", 1).in("state", state)); if(null != appUser.getInviterType() && appUser.getInviterType() == 2 && count == 1){ Double num1 = jsonObject1.getDouble("num1"); num1 = (num3 >= num1 ? num1 : num3); if(num1 > 0){ Driver driver1 = driverService.selectById(appUser.getInviterId()); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver1.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver1.setCommission(driver1.getCommission() + num1); accountChangeDetail.setNewData(driver1.getCommission()); driverService.updateById(driver1); accountChangeDetailService.saveData(accountChangeDetail); Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver1.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num1); revenue.setCreateTime(new Date()); revenueService.insert(revenue); } num3 = (num3 >= num1 ? num3 - num1 : 0); } //开始处理层级抽佣 if(null != driver.getInviterType() && driver.getInviterType() == 2){ Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机 if(null != driver1.getInviterType() && driver1.getInviterType() == 2){ Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机 if(null != driver2.getInviterType() && driver2.getInviterType() == 2){ Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机 Double num5 = jsonObject1.getDouble("num5"); Double num6 = jsonObject1.getDouble("num6"); Double num7 = jsonObject1.getDouble("num7"); num5 = (num3 >= num5 ? num5 : num3); if(num5 > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver1.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num5); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver1.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver1.setCommission(driver1.getCommission() + num5); accountChangeDetail.setNewData(driver1.getCommission()); driverService.updateById(driver1); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num5 ? num3 - num5 : 0); } num6 = (num3 >= num6 ? num6 : num3); if(num6 > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver2.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num6); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver2.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver2.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver2.setCommission(driver2.getCommission() + num6); accountChangeDetail.setNewData(driver2.getCommission()); driverService.updateById(driver2); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num6 ? num3 - num6 : 0); } num7 = (num3 >= num7 ? num7 : num3); if(num7 > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver3.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num7); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver3.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver3.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver3.setCommission(driver3.getCommission() + num7); accountChangeDetail.setNewData(driver3.getCommission()); driverService.updateById(driver3); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num7 ? num3 - num7 : 0); } }else{ Double num3_ = jsonObject1.getDouble("num3"); Double num4 = jsonObject1.getDouble("num4"); num3_ = (num3 >= num3_ ? num3_ : num3); if(num3_ > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver1.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num3_); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver1.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver1.setCommission(driver1.getCommission() + num3_); accountChangeDetail.setNewData(driver1.getCommission()); driverService.updateById(driver1); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num3_ ? num3 - num3_ : 0); } num4 = (num3 >= num4 ? num4 : num3); if(num4 > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver2.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num4); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver2.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver2.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver2.setCommission(driver2.getCommission() + num4); accountChangeDetail.setNewData(driver2.getCommission()); driverService.updateById(driver2); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num4 ? num3 - num4 : 0); } } }else{ Double num2_ = jsonObject1.getDouble("num2"); num2_ = (num3 >= num2_ ? num2_ : num3); if(num2_ > 0){ Revenue revenue = new Revenue(); revenue.setType(2); revenue.setUserType(2); revenue.setUserId(driver1.getId()); revenue.setOrderId(order.getId()); revenue.setAmount(num2_); revenue.setCreateTime(new Date()); revenueService.insert(revenue); AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver1.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(5); accountChangeDetail.setOldData(driver1.getCommission()); accountChangeDetail.setExplain("订单分佣收入"); accountChangeDetail.setCreateTime(new Date()); driver1.setCommission(driver1.getCommission() + num2_); accountChangeDetail.setNewData(driver1.getCommission()); driverService.updateById(driver1); accountChangeDetailService.saveData(accountChangeDetail); num3 = (num3 >= num2_ ? num3 - num2_ : 0); } } } //处理代理商抽佣 if(num3 > 0){ Revenue revenue = new Revenue(); revenue.setType(1); revenue.setUserType(3); revenue.setUserId(driver.getAgentId()); revenue.setOrderId(order.getId()); revenue.setAmount(num3); revenue.setCreateTime(new Date()); revenueService.insert(revenue); } } } } //司机余额扣减抽佣金额 if(n > 0){ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(2); accountChangeDetail.setUserId(driver.getId()); accountChangeDetail.setType(1); accountChangeDetail.setChangeType(9); accountChangeDetail.setOrderId(order.getId()); accountChangeDetail.setOldData(driver.getBalance()); accountChangeDetail.setExplain("线下收款服务费支出"); accountChangeDetail.setCreateTime(new Date()); driver.setBalance(driver.getBalance() - n); accountChangeDetail.setNewData(driver.getBalance()); driverService.updateById(driver); accountChangeDetailService.saveData(accountChangeDetail); } } /** driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/YouTuiDriverServiceImpl.java
@@ -65,6 +65,17 @@ return driverYouTuiListWarppers; } /** * 获取司机兑换优推记录 * @param driverId * @return * @throws Exception */ @Override public List<DriverYouTuiWarpper> queryDriverYouTuiList1(Integer driverId) throws Exception { return this.baseMapper.queryYouTuiDriverList(driverId, null); } /** * 获取司机优推数据 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/PayMoneyUtil.java
@@ -77,9 +77,10 @@ @Value("${callbackPath}") private String callbackPath;//支付回调网关地址 private String wechatPayCertificatesFromPath = "E:\\项目文档\\超省新代驾\\1636941942_20230320_cert\\apiclient_cert.p12";//微信支付证书地址 private String wechatPayCertificatesFromPath = "/usr/local/server/app/cert/weixin/apiclient_cert.p12";//微信支付证书地址 private String privateKeyFromPath = "E:\\项目文档\\超省新代驾\\1636941942_20230320_cert\\apiclient_cert.pem";//微信私钥证书地址 private String privateKeyFromPath = "/usr/local/server/app/cert/weixin/apiclient_cert.pem";//微信私钥证书地址 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/TaskUtil.java
@@ -1,6 +1,7 @@ package com.supersavedriving.driver.modular.system.util; import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; import com.supersavedriving.driver.modular.system.service.IDriverService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -15,6 +16,9 @@ @Autowired private IDriverService driverService; @Autowired private IAccountChangeDetailService accountChangeDetailService; @@ -32,16 +36,17 @@ } // /** // * 每天的凌晨执行的任务 // */ // @Scheduled(cron = "0 0 0 * * *") // public void taskDay(){ // try { // }catch (Exception e){ // e.printStackTrace(); // } // } /** * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 0 * * *") public void taskDay(){ try { accountChangeDetailService.deductionInsurance(); }catch (Exception e){ e.printStackTrace(); } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/rongyun/RongYunUtil.java
New file @@ -0,0 +1,307 @@ package com.supersavedriving.driver.modular.system.util.rongyun; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.supersavedriving.driver.core.util.ToolUtil; import com.supersavedriving.driver.modular.system.util.rongyun.model.CloudRecordingCallback; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.net.*; import java.security.MessageDigest; import java.util.Map; /** * 融云及时通讯工具类 */ @Component public class RongYunUtil { @Value("${rongyun.app_key}") private String app_key; @Value("${rongyun.app_secret}") private String app_secret; /** * 注册获取token * @param userId * @param name * @param headUrl * @return * @throws Exception */ public String getToken(String userId, String name, String headUrl) throws Exception { String url = "http://api-cn.ronghub.com/user/getToken.json"; String data = "userId=" + userId + "&name=" + name + "&portraitUri=" + headUrl; String s = this.pushHttp(url, data); return s; } /** * 刷新用户信息 * @param userId * @param name * @param headUrl * @throws Exception */ public void refresh(String userId, String name, String headUrl) throws Exception { String url = "http://api-cn.ronghub.com/user/refresh.json"; String data = "userId=" + userId + "&name=" + name + "&portraitUri=" + headUrl; String s = this.pushHttp(url, data); } /** * 检查用户在线状态 * @param userId * @return 1:在线,0:离线 * @throws Exception */ public Integer checkOnline(String userId) throws Exception { String url = "http://api-cn.ronghub.com/user/checkOnline.json"; String data = "userId=" + userId; String s = this.pushHttp(url, data); JSONObject jsonObject = JSON.parseObject(s); if(jsonObject.getIntValue("code") == 200){ return jsonObject.getIntValue("status"); } return null; } /** * 发送普通消息 * @param fromUserId * @param toUserId * @param objectName * @param content * @return */ public String sendSms(String fromUserId, String toUserId, String objectName, String content){ try { String url = "https://api-cn.ronghub.com/message/private/publish.json"; String data = "fromUserId=" + URLEncoder.encode(fromUserId, "UTF-8") + "&toUserId=" + URLEncoder.encode(toUserId, "UTF-8") + "&objectName=" + URLEncoder.encode(objectName, "UTF-8") + "&content=" + URLEncoder.encode(content, "UTF-8") + "&disablePush=0&isIncludeSender=1"; String s = this.pushHttp(url, data); return s; }catch (Exception e){ e.printStackTrace(); } return null; } /** * 创建 IM 聊天室 * @param id 房间id长度不超过 64 字节 * @param name 聊天室名称 * @return */ public Integer ChatRoomCreate(String id, String name){ String url = "https://api-cn.ronghub.com/chatroom/create.json"; String data = "chatroom[" + id + "]=" + name; String s = this.pushHttp(url, data); JSONObject jsonObject = JSON.parseObject(s); if(jsonObject.getIntValue("code") == 200){ return jsonObject.getIntValue("status"); } return null; } /** * 销毁聊天室 * @param chatroomId 聊天室id * @return */ public Integer ChatRoomDestroy(String chatroomId){ String url = "https://api-cn.ronghub.com/chatroom/destroy.json"; String data = "chatroomId=" + chatroomId; String s = this.pushHttp(url, data); JSONObject jsonObject = JSON.parseObject(s); if(jsonObject.getIntValue("code") == 200){ return jsonObject.getIntValue("status"); } return null; } /** * 更新聊天室属性 * @param chatroomId 聊天室房间id * @param userId 更新用户id * @param k 更新属性名 * @param v 更新值 * @param autoDelete 用户退出聊天室后,是否删除此 Key 值。为 1 时删除此 Key 值,为 0 时用户退出后不删除此 Key,默认为 0 * @param type 聊天室中对属性操作后发送通知的类型,1 为设置属性内容、2 为删除属性内容。 * @param objectName 发送消息类型 * @param extra 发送消息附加信息 * @return */ public Integer entryChatRoom(String chatroomId, String userId, String k, String v, Integer autoDelete, Integer type, String objectName, String extra){ String url = "https://api-cn.ronghub.com/chatroom/destroy.json"; String data = "chatroomId=" + chatroomId + "&userId=" + userId + "&key=" + k + "&value=" + v; if(ToolUtil.isNotEmpty(objectName)){//需要发送通知消息 JSONObject jsonObject = new JSONObject(); jsonObject.put("type", type);//聊天室中对属性操作后发送通知的类型,1 为设置属性内容、2 为删除属性内容。 jsonObject.put("key", k);//聊天室中属性名称,大小不超过 128 个字符。 jsonObject.put("value", v);//属性对应的内容,大小不超过 4096 个字符。 jsonObject.put("extra", extra);//通过消息中携带的附加信息,对应到设置属性接口中的 notificationExtra 值。 data += "&objectName=" + objectName + "&content=" + jsonObject.toJSONString(); } if(null != autoDelete){ data += "&autoDelete=" + autoDelete; } String s = this.pushHttp(url, data); JSONObject jsonObject = JSON.parseObject(s); if(jsonObject.getIntValue("code") == 200){ return jsonObject.getIntValue("status"); } return null; } /** * 聊天室发送文本消息 * @param userId 发送用户id * @param chatroomId 聊天室id * @param content 消息文本内容 * @return */ public Integer ChatRoomPushTxtMessage(String userId, String chatroomId, String content){ String url = "https://api-cn.ronghub.com/chatroom/destroy.json"; String data = "fromUserId=" + userId + "&toChatroomId=" + chatroomId + "&objectName=RC:TxtMsg&content=" + content; String s = this.pushHttp(url, data); JSONObject jsonObject = JSON.parseObject(s); if(jsonObject.getIntValue("code") == 200){ return jsonObject.getIntValue("status"); } return null; } /** * 请求接口 * @param path * @param json * @return */ public String pushHttp(String path, String json){ String nonce = String.valueOf(Double.valueOf(Math.random() * 1000000.0D).intValue()); String timeMillis = String.valueOf(System.currentTimeMillis() / 1000); String signature = getSha1(app_secret + nonce + timeMillis); URL url = null; try { url = new URL(path); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("POST"); connection.setConnectTimeout(1000 * 30); connection.setRequestProperty("Host", "api-cn.ronghub.com"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("App-Key", app_key); connection.setRequestProperty("Nonce", nonce); connection.setRequestProperty("Timestamp", timeMillis); connection.setRequestProperty("Signature", signature); connection.setDoOutput(true); connection.setDoInput(true); connection.setUseCaches(false); connection.setInstanceFollowRedirects(true); connection.connect(); DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream()); outputStream.write(json.getBytes("UTF-8")); outputStream.flush(); outputStream.close(); int responseCode = connection.getResponseCode(); InputStream inputStream = null; if(responseCode == 403){ inputStream = connection.getErrorStream(); } if(responseCode == 200){ inputStream = connection.getInputStream(); } DataInputStream dataInputStream = new DataInputStream(inputStream); ByteArrayOutputStream stream = new ByteArrayOutputStream(); int len; byte[] bytes = new byte[1024]; while ((len = dataInputStream.read(bytes)) != -1){ stream.write(bytes, 0, len); } return stream.toString(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } public static String getSha1(String str) { char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; try { MessageDigest mdTemp = MessageDigest.getInstance("SHA1"); mdTemp.update(str.getBytes("UTF-8")); byte[] md = mdTemp.digest(); int j = md.length; char buf[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = md[i]; buf[k++] = hexDigits[byte0 >>> 4 & 0xf]; buf[k++] = hexDigits[byte0 & 0xf]; } return new String(buf); } catch (Exception e) { return null; } } /** * 云端录制状态回调 * @param request * @return */ public static CloudRecordingCallback cloudRecordingCallback(HttpServletRequest request){ String param = null; try { param = getParam(request); } catch (IOException e) { e.printStackTrace(); } if(ToolUtil.isNotEmpty(param)){ CloudRecordingCallback cloudRecordingCallback = JSON.parseObject(param, CloudRecordingCallback.class); return cloudRecordingCallback; } return null; } private static String getParam(HttpServletRequest request) throws IOException { // 读取参数 InputStream inputStream; StringBuilder sb = new StringBuilder(); 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(); return sb.toString(); } } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/rongyun/model/CloudRecordingCallback.java
New file @@ -0,0 +1,75 @@ package com.supersavedriving.driver.modular.system.util.rongyun.model; import com.alibaba.fastjson.JSONObject; import lombok.Data; /** * @author zhibing.pu * @date 2023/4/6 10:29 */ @Data public class CloudRecordingCallback { /** * 时间戳,单位为毫秒。 */ private Long timestamp; /** *回调事件类型,如下: * 1: 录制开始; * 2: 录制切片; * 3: 录制结束; * 4: 文件上传 */ private Integer type; /** * 当前使用的 App Key */ private String appKey; /** * 录制 ID,每次录制任务的唯一标识。如果文件切片,可以通过此 ID 进行关联。 */ private String recordId; /** * 房间 ID */ private String roomId; /** * 会话 ID,每次通话的唯一标识。您可以通过融云服务端回调获取该 sessionId */ private String sessionId; /** * 用户 ID。如果录制模式为 Mix,此字段为空 */ private String userId; /** * 录制模式,如下: * 0:音视频 single 模式; * 1:纯视频 single 模式; * 2:纯音频 single 模式; * 3:音视频 mix 模式; * 4:纯视频 mix 模式; * 5:纯音频 mix 模式; * 6:单人 mix 音视频模式。 */ private Integer mode; /** * 扩展字段,内容为手动录制时传入的 extra 字段的值 */ private String extra; /** * 状态码,200 为正常 */ private Integer code; /** * 错误信息。 */ private String errorMessage; /** * */ private Config config; /** * */ private Output output; } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/rongyun/model/Config.java
New file @@ -0,0 +1,31 @@ package com.supersavedriving.driver.modular.system.util.rongyun.model; import lombok.Data; /** * @author zhibing.pu * @date 2023/4/6 10:48 */ @Data public class Config { /** * 录制启动模式: 1 自动启动录制任务 */ private Integer trigger; /** * Mix模式下布局:2 悬浮布局(默认) 3 自适应布局 */ private Integer mixLayout; /** * 文件切片时间(分钟) */ private Integer slicesMin; /** * 设置的音频文件格式 */ private String audioFormat; /** * 设置的视频文件格式 */ private String videoFormat; } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/rongyun/model/Output.java
New file @@ -0,0 +1,31 @@ package com.supersavedriving.driver.modular.system.util.rongyun.model; import lombok.Data; /** * @author zhibing.pu * @date 2023/4/6 10:50 */ @Data public class Output { /** * 缓存的文件名。具体请参考「配置云端录制服务」中的切片文件命名规则。 */ private String fileName; /** * 音频采样率,如 48000。如果当前录制任务没有录制音频,该字段为空。 */ private Integer audioSample; /** * 视频分辨率,如 640x480。如果当前录制任务没有录制视频,该字段为空。 */ private String videoResoulation; /** * 切片生成的录制文件大小。 */ private Integer fileSize; /** * 已上传到的第三方存储的 URL。 */ private String fileUrl; } driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java
@@ -19,8 +19,8 @@ private String name; @ApiModelProperty("电话") private String phone; @ApiModelProperty("优推开始时间") private Long youTuiStart; @ApiModelProperty("优推结束时间") private Long youTuiEnd; @ApiModelProperty("账户余额") private Double balance; @ApiModelProperty("佣金余额") @@ -31,7 +31,7 @@ private Integer todayNum; @ApiModelProperty("本月接单") private Integer monthNum; @ApiModelProperty("上班状态(0:没上班,1=一上班)") @ApiModelProperty("上班状态(0:没上班,1=已上班)") private Integer work; @ApiModelProperty("在线时长") private Integer online; driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/OrderInfoWarpper.java
@@ -45,6 +45,8 @@ private Double estimatedPrice; @ApiModelProperty("预估里程") private Double estimatedMileage; @ApiModelProperty("预估时间") private Double estimatedTime; @ApiModelProperty("起步价") private Double startPrice; @ApiModelProperty("等待时长") driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/OrderPriceWarpper.java
@@ -52,6 +52,8 @@ private Double overBadWeatherPrice; @ApiModelProperty("折扣金额") private Double discountAmount; @ApiModelProperty("优惠金额") private Double discountedPrice; @ApiModelProperty("微信收款码") private String wxCollectionCode; @ApiModelProperty("支付宝收款码") driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/OrderStatusWarpper.java
File was deleted driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/TokenWarpper.java
@@ -16,4 +16,6 @@ private Long validTime; @ApiModelProperty(value = "是否设置密码(0=否,1=是)", required = true, dataType = "int") private Integer isSetPassword; @ApiModelProperty("融云token") private String rytoken; } driver/guns-admin/src/main/resources/application.yml
@@ -13,8 +13,8 @@ application: name: driver-server profiles: active: dev # active: produce # active: dev active: produce mvc: static-path-pattern: /static/** view: @@ -51,19 +51,12 @@ base-package: com.supersavedriving.driver.modular #spring: # datasource: # url: jdbc:mysql://Rm-wz9rpe0t74ys3b1h8go.mysql.rds.aliyuncs.com:3306/oktravel?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai # username: root # password: Root2020! # db-name: guns #用来搜集数据库的所有表 # filters: wall,mergeStat spring: datasource: url: jdbc:mysql://127.0.0.1:3306/super_save_driving?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai username: root password: 123456 password: f4OfRjqoN3jSiNGiUoiNsQdOBtCOKYRj # password: 123456 db-name: guns #用来搜集数据库的所有表 filters: wall,mergeStat @@ -84,8 +77,8 @@ wx: grantType: authorization_code #填authorization_code appid: wx36c966d381cd5d62 #应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret: cf4b21c7175356f41fa3c426f26c20e4 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 appid: wx8a9af3889395d0e1 #应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret: 95a34f114973298cce4297a20bb59bc3 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 appletsAppid: 1 #小程序APPid appletsAppSecret: 1 # mchId: 1636941942 #微信支付分配的商户号 @@ -108,14 +101,14 @@ --- filePath: /usr/local/server/orderPostionFile/ #存储订单轨迹文件路径 filePath: /usr/local/server/app/orderPostionFile/ #存储订单轨迹文件路径 #filePath: C:/orderPostionFile/ #存储订单轨迹文件路径 #支付回调地址 #正式环境 callbackPath: https://okyueche.com:443/user #callbackPath: https://okyueche.com:443/user #测试环境 #callbackPath: http://47.108.254.217:80/user callbackPath: http://121.37.15.157:80/driver --- @@ -123,4 +116,11 @@ spring: data: mongodb: uri: mongodb://127.0.0.1:27017/admin uri: mongodb://root:CEtyLdKjPk0yeHNo@127.0.0.1:27017/admin # uri: mongodb://127.0.0.1:27017/admin --- rongyun: app_key: k51hidwqkx92b app_secret: t0jxbPrHHar driver/guns-admin/src/main/resources/logback-spring.xml
@@ -7,8 +7,8 @@ <contextName>logback</contextName> <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 --> <!--<property name="log.path" value="/usr/local/server/logs"/>--> <property name="log.path" value="d:/logs/driver"/> <property name="log.path" value="/usr/local/server/app/logs"/> <!--<property name="log.path" value="d:/logs/driver"/>--> <!--0. 日志格式和颜色渲染 --> <!-- 彩色日志依赖的渲染类 --> driver/guns-admin/src/main/resources/redis.properties
@@ -1,13 +1,21 @@ #redisÅäÖÿªÊ¼ # RedisÊý¾Ý¿âË÷Òý£¨Ä¬ÈÏΪ0£© spring.redis.database=0 # Redis·þÎñÆ÷µØÖ· spring.redis.host=127.0.0.1 # Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú spring.redis.port=6379 spring.redis.port=16379 # Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© spring.redis.password=123456 #spring.redis.password= spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ ## Redis·þÎñÆ÷µØÖ· #spring.redis.host=127.0.0.1 ## Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú #spring.redis.port=6379 ## Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© #spring.redis.password=123456 # Á¬½Ó³Ø×î´óÁ¬½ÓÊý£¨Ê¹ÓøºÖµ±íʾûÓÐÏÞÖÆ£© spring.redis.jedis.pool.max-active=1024 # Á¬½Ó³Ø×î´ó×èÈûµÈ´ýʱ¼ä£¨Ê¹ÓøºÖµ±íʾûÓÐÏÞÖÆ£©