1. 优惠券

This commit is contained in:
邱贞招 2024-08-09 22:18:23 +08:00
parent e335afc9a3
commit aa7821bfa9
14 changed files with 280 additions and 111 deletions

View File

@ -1,14 +1,12 @@
package com.ruoyi.web.controller.IndexController;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.EtOperatingArea;
import com.ruoyi.system.domain.vo.IndexAdminVo;
import com.ruoyi.system.domain.vo.IndexVo;
import com.ruoyi.system.domain.vo.LeaderboardVo;
import com.ruoyi.system.service.IEtOperatingAreaService;
import com.ruoyi.system.service.IEtOrderService;
import org.springframework.beans.factory.annotation.Autowired;
@ -74,4 +72,18 @@ public class IndexController extends BaseController
return success(indexAdminVo);
}
/**
* 首页统计-排行榜
* type1-根据订单数排序2-根据订单金额排序
* timeLimit1-今天2-本周
*/
@GetMapping(value = "/admim/leaderboard")
public AjaxResult leaderboard(String type,String timeLimit)
{
logger.info("【首页统计】排行榜");
List<LeaderboardVo> leaderboard = etOrderService.leaderboard(type, timeLimit);
return success(leaderboard);
}
}

View File

@ -207,13 +207,13 @@ public class AppController extends BaseController
* 根据经纬度查询附近500米的所有车辆
*/
@GetMapping(value = "/vehicleLocalization")
public AjaxResult vehicleLocalization(String longitude,String latitude)
public AjaxResult vehicleLocalization(String longitude,String latitude,String deptId)
{
if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
logger.info("没有经纬度参数【longitude={}】【latitude={}】",longitude,latitude);
return error("请传经纬度参数"+"【longitude="+longitude+"【latitude="+latitude+"");
}
List<AsDevice> asDevices = asDeviceService.vehicleLocalization(longitude,latitude);
List<AsDevice> asDevices = asDeviceService.vehicleLocalization(longitude,latitude,deptId);
return success(asDevices);
}

View File

@ -342,6 +342,10 @@ public class AppVerifyController extends BaseController
if(inOrder.size()>0){
throw new ServiceException("提现失败,用户还有未完成订单");
}
List<EtOrder> inAuditOrder = etOrderService.isInAuditOrder(etOrder.getUserId(), null);
if(inAuditOrder.size()>0){
throw new ServiceException("提现失败,用户还有未审核完成的订单");
}
if(etOrders.size()>1){
logger.info("有多条status="+ServiceConstants.ORDER_STATUS_ORDER_END+"(已完成),paid="+ServiceConstants.ORDER_PAY_STATUS_PAID+"(已支付)的押金订单");
logger.info("获取最后一条押金充值记录");
@ -1002,6 +1006,9 @@ public class AppVerifyController extends BaseController
{
logger.info("还车审核通过请求:【{}】", orderNo);
EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo);
if(!order.getStatus().equals(ServiceConstants.ORDER_STATUS_TO_BE_AUDIT)){
throw new ServiceException("该订单用户未支付!");
}
if(ObjectUtil.isNotNull(order)){
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
return toAjax(etOrderService.passAudit(order));

View File

@ -104,6 +104,7 @@ public class ReceiveController {
/*************明文模式 start****************/
BodyObj obj = Util.resolveBody(body, false);
log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj));
log.info("接收到receive方法时间: " + System.currentTimeMillis());
// 起一个异步线程处理数据
scheduledExecutorService.schedule(() -> {
new Thread(() -> {
@ -300,7 +301,9 @@ public class ReceiveController {
optimizeRoute(jsonArray, newPoint,lon,lat,etOrder);
}else{
if(ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())){
long difference = System.currentTimeMillis() - logEntry.getAt();
log.info("当前时间戳:【"+System.currentTimeMillis()+"】,消息时间:【"+logEntry.getAt()+"】,时间差:【"+difference+"");
if (difference < 60 * 1000 && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) {
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "车辆锁同步关锁", null, null, msg);
}
}

View File

@ -56,7 +56,7 @@ public class AsDevice extends BaseEntityPlus implements Serializable {
/** 运营商id */
@Excel(name = "运营商id")
@TableField(exist = false)
// @TableField(exist = false)
private Long deptId;
/** 分区 */
@ -200,4 +200,10 @@ public class AsDevice extends BaseEntityPlus implements Serializable {
@TableField(exist = false)
private String unBand;
/** appId*/
public String appid;
/** 小程序名称*/
public String appName;
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.system.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 排行榜
*
* @author 邱贞招
* @date 2024-08-09
*/
@Data
public class LeaderboardVo {
/** 运营区id */
private Long areaId;
/** 运营区 */
private String areaName;
/** 订单数 */
private Integer orderCount=0;
/** 订单金额 */
private BigDecimal orderFee= BigDecimal.ZERO;
}

View File

@ -155,7 +155,7 @@ public interface IAsDeviceService extends IService<AsDevice>
* @param latitude 纬度
* @return 结果
*/
List<AsDevice> vehicleLocalization(String longitude, String latitude);
List<AsDevice> vehicleLocalization(String longitude, String latitude,String deptId);
/**
* 所有车辆定位

View File

@ -238,4 +238,9 @@ public interface IEtOrderService
* 首页统计-总管理
*/
IndexAdminVo admimStatistics();
/**
* 首页统计-排行榜
*/
List<LeaderboardVo> leaderboard(String type,String timeLimit);
}

View File

@ -307,8 +307,19 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int insertAsDevice(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setCreateTime(DateUtils.getNowDate());
// asDevice.setAreaId();
return asDeviceMapper.insertAsDevice(asDevice);
}
@ -321,6 +332,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int updateAsDevice(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setUpdateTime(DateUtils.getNowDate());
int i = asDeviceMapper.updateAsDevice(asDevice);
//预约后开始计费
@ -337,6 +360,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int updateAsDevice2(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setUpdateTime(DateUtils.getNowDate());
if(asDevice.getAreaId() == null){
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NOT_BAND);
@ -526,9 +561,10 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* @return 结果
*/
@Override
public List<AsDevice> vehicleLocalization(String longitude, String latitude) {
public List<AsDevice> vehicleLocalization(String longitude, String latitude,String deptId) {
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
wrapper.eq("status", "1"); // 设备状态正常
wrapper.eq("dept_id", deptId);
// 查询所有设备
List<AsDevice> allDevices = asDeviceMapper.selectList(wrapper);
@ -1642,15 +1678,15 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 5. 更新骑行订单状态为已支付支付方式为 押金抵扣
* 6. 更新用户余额
* */
String isDepositDeduction = area.getIsDepositDeduction();
/** 1. 判断是否开启押金抵扣*/
if(ObjectUtil.isNotNull(isDepositDeduction) && "1".equals(isDepositDeduction)){
if(ServiceConstants.RETURN_VERIFY_NO.equals(area.getReturnVerify())){//关闭还车审核订单直接用押金支付
depositDeduction(order);
}else{
throw new ServiceException("拍照审核和押金点开不能同时开启");
}
}
// String isDepositDeduction = area.getIsDepositDeduction();
// /** 1. 判断是否开启押金抵扣*/
// if(ObjectUtil.isNotNull(isDepositDeduction) && "1".equals(isDepositDeduction)){
// if(ServiceConstants.RETURN_VERIFY_NO.equals(area.getReturnVerify())){//关闭还车审核订单直接用押金支付
// depositDeduction(order);
// }else{
// throw new ServiceException("拍照审核和押金点开不能同时开启");
// }
// }
int i = etOrderService.updateEtOrder(order);
if(i==0){
throw new ServiceException("更新订单状态失败");
@ -1670,73 +1706,73 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
}
/** 押金抵扣 */
private void depositDeduction(EtOrder order) {
EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
Integer autoRefundDeposit = rule.getAutoRefundDeposit();
log.info("【还车关锁】进入押金抵扣环节--------"+autoRefundDeposit+"个小时后退还押金");
/** 2. 获取最后一次押金*/
EtOrder depositOrder = etOrderService.getDepositOrder(order.getUserId());
BigDecimal deposit = depositOrder.getTotalFee();
BigDecimal ridingFee = order.getTotalFee();
BigDecimal afterDeductionFee;
String mark;
if(deposit.compareTo(ridingFee) <= 0){// 骑行费大于押金订单为未支付, 抵扣后的金额 = 骑行费 - 押金
afterDeductionFee = BigDecimal.ZERO;
mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"";
order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
order.setPayFee(deposit);
}else{
// 押金大于订单金额 扣除后
afterDeductionFee = deposit.subtract(ridingFee);
mark = "押金抵扣成功,骑行费【"+ridingFee+"】小于押金【"+deposit+"】,扣除后金额【"+afterDeductionFee+"";
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
}
/** 更新骑行订单*/
order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
order.setPayTime(DateUtils.getNowDate());
order.setPayType(ServiceConstants.PAY_TYPE_YJ);
order.setMark(mark);
order.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
/** 更新押金订单*/
depositOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
int updateEtOrder1 = etOrderMapper.updateEtOrder(depositOrder);
if(updateEtOrder1 == 0){
throw new ServiceException("押金抵扣失败,更新押金订单失败");
}
/** 押金抵扣后生成资金流水记录 */
callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
//创建一个定时器计算出退还时间后执行退款操作
// 往后推autoRefundDeposit小时执行
if(autoRefundDeposit!=null){
scheduledExecutorService.schedule(() -> {
if(afterDeductionFee.compareTo(BigDecimal.ZERO) > 0){
/** 退款剩余押金*/
Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
/** 2.记录退款表 创建退款对象*/
depositOrder.setReason("押金抵扣退款");
EtRefund refund1= etOrderService.createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
int i = etRefundService.insertEtRefund(refund1);
if(i == 0){
log.info("【押金抵扣】保存退款对象失败");
throw new ServiceException("【押金抵扣】,保存退款对象失败");
}
/** 更新用户余额*/
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
if(asUser!=null){
// 更新用户并更新缓存
asUser.setBalance(BigDecimal.ZERO);
if (asUserService.updateUserProfile(asUser) > 0)
{
log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
}else{
throw new ServiceException("【押金抵扣】,更新用户信息失败");
}
}
}
}, autoRefundDeposit , TimeUnit.HOURS);
}
}
// /** 押金抵扣 */
// private void depositDeduction(EtOrder order) {
//// EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
//// Integer autoRefundDeposit = rule.getAutoRefundDeposit();
//// log.info("【还车关锁】进入押金抵扣环节--------"+autoRefundDeposit+"个小时后退还押金");
// /** 2. 获取最后一次押金*/
// EtOrder depositOrder = etOrderService.getDepositOrder(order.getUserId());
// BigDecimal deposit = depositOrder.getTotalFee();
// BigDecimal ridingFee = order.getTotalFee();
// BigDecimal afterDeductionFee;
// String mark;
// if(deposit.compareTo(ridingFee) <= 0){// 骑行费大于押金订单为未支付, 抵扣后的金额 = 骑行费 - 押金
// afterDeductionFee = BigDecimal.ZERO;
// mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"";
// order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
// order.setPayFee(deposit);
// }else{
// // 押金大于订单金额 扣除后
// afterDeductionFee = deposit.subtract(ridingFee);
// mark = "押金抵扣成功,骑行费【"+ridingFee+"】小于押金【"+deposit+"】,扣除后金额【"+afterDeductionFee+"";
// order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
// }
// /** 更新骑行订单*/
// order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
// order.setPayTime(DateUtils.getNowDate());
// order.setPayType(ServiceConstants.PAY_TYPE_YJ);
// order.setMark(mark);
// order.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
// /** 更新押金订单*/
// depositOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
// int updateEtOrder1 = etOrderMapper.updateEtOrder(depositOrder);
// if(updateEtOrder1 == 0){
// throw new ServiceException("押金抵扣失败,更新押金订单失败");
// }
// /** 押金抵扣后生成资金流水记录 */
// callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
// //创建一个定时器计算出退还时间后执行退款操作
// // 往后推autoRefundDeposit小时执行
//// if(autoRefundDeposit!=null){
//// scheduledExecutorService.schedule(() -> {
// if(afterDeductionFee.compareTo(BigDecimal.ZERO) > 0){
// /** 退款剩余押金*/
// Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
// /** 2.记录退款表 创建退款对象*/
// depositOrder.setReason("押金抵扣退款");
// EtRefund refund1= etOrderService.createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
// int i = etRefundService.insertEtRefund(refund1);
// if(i == 0){
// log.info("【押金抵扣】保存退款对象失败");
// throw new ServiceException("【押金抵扣】,保存退款对象失败");
// }
// /** 更新用户余额*/
// AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
// if(asUser!=null){
// // 更新用户并更新缓存
// asUser.setBalance(BigDecimal.ZERO);
// if (asUserService.updateUserProfile(asUser) > 0)
// {
// log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
// }else{
// throw new ServiceException("【押金抵扣】,更新用户信息失败");
// }
// }
// }
//// }, autoRefundDeposit , TimeUnit.HOURS);
//// }
// }
/**
* 计算订单费用

View File

@ -92,14 +92,14 @@ public class AsUserServiceImpl implements IAsUserService
/** 获取设备绑定数量*/
List<AsUser> users = asUserMapper.selectUserList(user);
for(AsUser u:users){
EtOrder etOrder = new EtOrder();
etOrder.setUserId(u.getUserId());
EtOrder order = etOrderService.latestOrder(etOrder);
if(ObjectUtil.isNotNull(order)){
EtOrderDto etOrderVo = new EtOrderDto();
BeanUtils.copyBeanProp(etOrderVo,order);
u.setLatestOrder(etOrderVo);
}
// EtOrder etOrder = new EtOrder();
// etOrder.setUserId(u.getUserId());
// EtOrder order = etOrderService.latestOrder(etOrder);
// if(ObjectUtil.isNotNull(order)){
// EtOrderDto etOrderVo = new EtOrderDto();
// BeanUtils.copyBeanProp(etOrderVo,order);
// u.setLatestOrder(etOrderVo);
// }
if(ObjectUtil.isNotNull(u.getSysUserId())){
Long sysUserId = u.getSysUserId();
SysUser sysUser = userMapper.selectUserById(sysUserId);

View File

@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.AdminOrderVo;
import com.ruoyi.system.mapper.AsDeviceMapper;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,8 +48,8 @@ public class EtAdminOrderServiceImpl implements IEtAdminOrderService
@Autowired
private IEtAdminOrderHistoryService etAdminOrderHistoryService;
@Autowired
private IAsDeviceService asDeviceService;
@Resource
private AsDeviceMapper asDeviceMapper;
/**
* 查询系统工单
@ -60,7 +61,7 @@ public class EtAdminOrderServiceImpl implements IEtAdminOrderService
public EtAdminOrder selectEtAdminOrderById(Long id)
{
EtAdminOrder adminOrder = etAdminOrderMapper.selectEtAdminOrderById(id);
AsDevice asDevice = asDeviceService.selectAsDeviceBySn(adminOrder.getSn());
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(adminOrder.getSn());
if(ObjectUtil.isNotNull(asDevice)){
adminOrder.setDevice(asDevice);
}
@ -91,18 +92,18 @@ public class EtAdminOrderServiceImpl implements IEtAdminOrderService
{
List<EtAdminOrder> etAdminOrders = etAdminOrderMapper.selectEtAdminOrderList(etAdminOrder);
for (EtAdminOrder adminOrder : etAdminOrders){
SysUser sysUser = userService.selectUserById(adminOrder.getAdminId());
if(ObjectUtil.isNotNull(sysUser)){
adminOrder.setAdminName(sysUser.getUserName());
adminOrder.setPhone(sysUser.getPhonenumber());
}
// SysUser sysUser = userService.selectUserById(adminOrder.getAdminId());
// if(ObjectUtil.isNotNull(sysUser)){
// adminOrder.setAdminName(sysUser.getUserName());
// adminOrder.setPhone(sysUser.getPhonenumber());
// }
EtFault etFault = etFaultService.selectEtFaultByFaultId(adminOrder.getFaultId());
if(ObjectUtil.isNotNull(etFault)){
adminOrder.setFaultType(etFault.getType());
adminOrder.setFaultTypes(etFault.getTypes());
adminOrder.setFaultTypeStr(etFault.getTypeStr());
}
AsDevice asDevice = asDeviceService.selectAsDeviceBySn(adminOrder.getSn());
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(adminOrder.getSn());
adminOrder.setLatitude(asDevice.getLatitude());
adminOrder.setLongitude(asDevice.getLongitude());
}

View File

@ -8,11 +8,11 @@ import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CommonUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.AsDeviceMapper;
import com.ruoyi.system.mapper.AsUserMapper;
import com.ruoyi.system.mapper.EtFaultMapper;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
@ -40,7 +40,7 @@ public class EtFaultServiceImpl implements IEtFaultService
private EtFaultMapper etFaultMapper;
@Resource
private IAsUserService asUserService;
private AsUserMapper asUserMapper;
@Resource
private ISysDictDataService sysDictDataService;
@ -113,7 +113,7 @@ public class EtFaultServiceImpl implements IEtFaultService
{
List<EtFault> etFaults = etFaultMapper.selectEtFaultList(etFault);
for(EtFault etFault1:etFaults){
AsUser asUser = asUserService.selectUserById(etFault1.getUserId());
AsUser asUser = asUserMapper.selectUserById(etFault1.getUserId());
if(ObjectUtils.isNotEmpty(asUser)){
etFault1.setUserName(asUser.getUserName());
}

View File

@ -436,8 +436,6 @@ public class EtOrderServiceImpl implements IEtOrderService
throw new ServiceException("押金抵扣失败,更新骑行订单失败");
}
/** 更新押金订单*/
// depositOrder.setPayFee(afterDeductionFee);
// depositOrder.setTotalFee(afterDeductionFee);
depositOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
int updateEtOrder1 = etOrderMapper.updateEtOrder(depositOrder);
if(updateEtOrder1 == 0){
@ -821,6 +819,58 @@ public class EtOrderServiceImpl implements IEtOrderService
return indexAdminVo;
}
/**
* 首页统计-总管理
*/
@Override
public List<LeaderboardVo> leaderboard(String type,String timeLimit) {
List<EtOperatingArea> etOperatingAreas = etOperatingAreaService.selectAreaAll();
ArrayList<LeaderboardVo> leaderboardVos = new ArrayList<>();
String startDateStr = null;
String endDateStr = null;
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtils.getNowDate());
if("1".equals(timeLimit)) {//1-今日
String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND;
endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND;
}else if("2".equals(timeLimit)){// 一周
// 设置结束日期为现在
endDateStr = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime()) + " " + Constants.DATE_FORMAT_END_PEREND;
// 设置开始日期为7天前
calendar.add(Calendar.DAY_OF_YEAR, -7);
startDateStr = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime()) + " " + Constants.DATE_FORMAT_START_PEREND;
}
for (EtOperatingArea area : etOperatingAreas) {
Long areaId = area.getAreaId();
LeaderboardVo leaderboardVo = new LeaderboardVo();
leaderboardVo.setOrderCount(etOrderMapper.getOrderNum(startDateStr, endDateStr, areaId));//订单数
leaderboardVo.setOrderFee(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId));//订单金额
leaderboardVo.setAreaId(areaId);
leaderboardVo.setAreaName(area.getAreaName());
leaderboardVos.add(leaderboardVo);
}
if("1".equals(type)){//1-根据订单数排序
Collections.sort(leaderboardVos, new Comparator<LeaderboardVo>() {
@Override
public int compare(LeaderboardVo o1, LeaderboardVo o2) {
// 降序排列订单数最多的排在最前面
return o2.getOrderCount().compareTo(o1.getOrderCount());
}
});
}else{// 2-根据订单金额排序
Collections.sort(leaderboardVos, new Comparator<LeaderboardVo>() {
@Override
public int compare(LeaderboardVo o1, LeaderboardVo o2) {
// 降序排列订单金额最多的排在最前面
return o2.getOrderFee().compareTo(o1.getOrderFee());
}
});
}
return leaderboardVos;
}
private IndexAdminVo createIndexAdminVo() {
IndexAdminVo indexAdminVo = new IndexAdminVo();
Calendar calendar = Calendar.getInstance();

View File

@ -35,17 +35,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="latitude" column="latitude" />
<result property="isAreaOutOutage" column="is_area_out_outage" />
<result property="isAdminUnlocking" column="is_admin_unlocking" />
<result property="appid" column="appid" />
<result property="appName" column="app_name" />
<result property="deptId" column="dept_id" />
</resultMap>
<sql id="selectAsDeviceVo">
select device_id, picture, device_name, mac, sn, model_id, hardware_version_id, vehicle_num, area_id, activation_time, online_status, create_by, create_time, update_by, update_time, last_time, last_location_time, gps, remark, status, lock_status, location, remaining_power, voltage, qrcode, longitude, latitude, is_area_out_outage, is_admin_unlocking from et_device
select device_id, picture, device_name, mac, sn, model_id, hardware_version_id, vehicle_num, area_id, activation_time,
online_status, create_by, create_time, update_by, update_time, last_time, last_location_time, gps, remark, status,
lock_status, location, remaining_power, voltage, qrcode, longitude, latitude, is_area_out_outage, is_admin_unlocking,appid, app_name, dept_id from et_device
</sql>
<select id="selectAsDeviceList" parameterType="AsDevice" resultMap="AsDeviceResult">
select de.device_id, de.picture, de.device_name, de.mac, de.sn, de.model_id, de.hardware_version_id, de.vehicle_num, de.area_id,
de.activation_time, de.online_status, de.create_by, de.create_time, de.update_by,
de.update_time, de.last_time, de.last_location_time, de.gps, de.remark, de.status, de.lock_status, de.location,
de.remaining_power, de.voltage, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking from et_device de
de.remaining_power, de.voltage, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking,appid, app_name, dept_id from et_device de
left join et_area_dept ad on ad.area_id = de.area_id
left join sys_dept d on d.dept_id = ad.dept_id
where 1 = 1
@ -67,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select de.device_id, de.picture, de.device_name, de.mac, de.sn, de.model_id, de.hardware_version_id, de.vehicle_num, de.area_id,
de.activation_time, de.online_status, de.create_by, de.create_time, de.update_by,
de.update_time, de.last_time, de.last_location_time, de.gps, de.remark, de.status, de.lock_status, de.location,
de.remaining_power, de.voltage, de.version, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking, de.signal_strength, de.satellites, de.quality from et_device de
de.remaining_power, de.voltage, de.version, de.qrcode, de.longitude, de.latitude, de.is_area_out_outage, de.is_admin_unlocking, de.signal_strength, de.satellites, de.quality,de.appid, de.app_name from et_device de
left join et_area_dept ad on ad.area_id = de.area_id
left join sys_dept d on d.dept_id = ad.dept_id
left join et_hardware_version hv on hv.id = de.hardware_version_id
@ -189,6 +194,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="isAreaOutOutage != null">is_area_out_outage,</if>
<if test="appid != null">appid,</if>
<if test="appName != null">app_name,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="picture != null">#{picture},</if>
@ -219,6 +227,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="isAreaOutOutage != null">#{isAreaOutOutage},</if>
<if test="appid != null">#{appid},</if>
<if test="appName != null">#{appName},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
@ -254,6 +265,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
<if test="appid != null">appid = #{appid},</if>
<if test="appName != null">app_name = #{appName},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
</trim>
where device_id = #{deviceId}
</update>
@ -290,6 +304,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
<if test="appid != null">appid = #{appid},</if>
<if test="appName != null">app_name = #{appName},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
</trim>
where device_id = #{deviceId}
</update>
@ -325,6 +342,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="latitude != null">latitude = #{latitude},</if>
<if test="isAreaOutOutage != null">is_area_out_outage = #{isAreaOutOutage},</if>
<if test="isAdminUnlocking != null">is_admin_unlocking = #{isAdminUnlocking},</if>
<if test="appid != null">appid = #{appid},</if>
<if test="appName != null">app_name = #{appName},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
</trim>
where sn = #{sn}
</update>