This commit is contained in:
邱贞招 2024-07-03 21:18:16 +08:00
parent 1250c504b3
commit d748a8cbe9
33 changed files with 505 additions and 99 deletions

View File

@ -130,6 +130,7 @@ public class AppController extends BaseController
@GetMapping("/parking/list")
public TableDataInfo list(EtParkingArea etParkingArea)
{
etParkingArea.setStatus("0");
startPage();
List<EtParkingArea> list = etParkingAreaService.selectEtParkingAreaList(etParkingArea);
return getDataTable(list);

View File

@ -287,6 +287,17 @@ public class AppVerifyController extends BaseController
return toAjax(etOrderService.refund(etOrder));
}
/**
* 押金抵扣
*/
@Log(title = "押金抵扣", businessType = BusinessType.DEDUCTION)
@PutMapping("/order/deduction")
public AjaxResult deduction(@RequestBody EtOrder etOrder)
{
logger.info("【押金抵扣请求】:{}", JSON.toJSON(etOrder));
return toAjax(etOrderService.deduction(etOrder));
}
/**
* 提现
*/
@ -433,10 +444,10 @@ public class AppVerifyController extends BaseController
*/
@Log(title = "还车", businessType = BusinessType.RETURN_VEHICLE)
@PostMapping("/device/return")
public AjaxResult returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage)
public AjaxResult returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage,String isInParkingArea)
{
logger.info("【接收还车请求参数】:{},是否辅助还车:{},是否蓝牙控制:{},电压:{}", orderNo,returnType,isBluetooth,lon,lat,voltage);
Boolean aBoolean = asDeviceService.returnVehicle(orderNo,returnType,isBluetooth,lon,lat,voltage);
logger.info("【接收还车请求参数】:{},是否辅助还车:{},是否蓝牙控制:{},电压:{},是否在停车点内:{}", orderNo,returnType,isBluetooth,lon,lat,voltage,isInParkingArea);
Boolean aBoolean = asDeviceService.returnVehicle(orderNo,returnType,isBluetooth,lon,lat,voltage,isInParkingArea);
return success(aBoolean);
}
@ -599,9 +610,9 @@ public class AppVerifyController extends BaseController
* 所有车辆定位
*/
@GetMapping(value = "/allVehicleInfo")
public AjaxResult allVehicleInfo(String powerStart,String powerEnd, String status,String sort,String areaId)
public AjaxResult allVehicleInfo(String powerStart,String powerEnd, String status,String sort,String areaId,String onlineStatus)
{
List<AsDevice> asDevices = asDeviceService.allVehicleInfo(powerStart,powerEnd,status,sort,areaId);
List<AsDevice> asDevices = asDeviceService.allVehicleInfo(powerStart,powerEnd,status,sort,areaId,onlineStatus);
return success(asDevices);
}
@ -809,13 +820,13 @@ public class AppVerifyController extends BaseController
* 根据经纬度判断是否在停车区
*/
@GetMapping("/isInParkingArea")
public AjaxResult isInParkingArea(String longitude,String latitude,String areaId)
public AjaxResult isInParkingArea(String longitude,String latitude,String areaId,String sn)
{
if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
logger.info("没有经纬度参数【longitude={}】【latitude={}】",longitude,latitude);
logger.info("没有经纬度参数【longitude={}】【latitude={}】【areaId={}】,【sn={}】",longitude,latitude,areaId,sn);
return error("请传经纬度参数"+"【longitude="+longitude+"【latitude="+latitude+"");
}
IsInParkingAreaVo isInParkingAreaVo = asDeviceService.isInParkingArea(longitude,latitude,areaId);
IsInParkingAreaVo isInParkingAreaVo = asDeviceService.isInParkingArea(longitude,latitude,areaId,sn);
return success(isInParkingAreaVo);
}

View File

@ -132,7 +132,10 @@ public class ReceiveController {
String devName = (String)jsonObject.get("dev_name");
/*异步更新在线状态*/
AsDevice asDevice = asDeviceService.selectAsDeviceByMac(devName);
Object ver = jsonObject.get("VER");
String ver = null;
if(IotConstants.ONENET_VER.equals(jsonObject.get("ds_id")) && ObjectUtil.isNotNull(jsonObject.get("value"))){
ver = (String)jsonObject.get("value");
}
asynchronousUpdateOnlineStatus(asDevice,ver);
if(IotConstants.ONENET_LOCATION.equals(jsonObject.get("ds_id")) && ObjectUtil.isNotNull(jsonObject.get("value"))){
LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class);
@ -197,6 +200,8 @@ public class ReceiveController {
device.setRemainingMileage(remainingMileage);
device.setRemainingPower(electricQuantity.toString());
device.setLastTime(DateUtils.getNowDate());
// 信号强度
device.setSignalStrength(value.getCsq());
int i = asDeviceService.updateLocation(device);
if(i>0){
log.info("更新定位成功==========================>" +logEntry.getDevName());
@ -215,6 +220,13 @@ public class ReceiveController {
log.info("禁行区内断电--更新设备锁状态成功SN" + device.getSn());
}
}
}else{
//是否在禁行区20米范围内
boolean inPolygon = asDeviceService.isNoRidingAreaWithTolerance(device.getSn(), device.getAreaId(),20);
if (inPolygon) {
log.info("距离禁行区20米内发送警告命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "距离禁行区20米内");
}
}
/** 3.超出运营区外断电*/
boolean isAreaZone = asDeviceService.isAreaZone(device.getSn(), area);
@ -339,6 +351,7 @@ public class ReceiveController {
device.setRemainingMileage(remainingMileage);
device.setRemainingPower(electricQuantity.toString());
device.setLastTime(DateUtils.getNowDate());
device.setSignalStrength(value.getCsq());
int i = asDeviceService.updateLocation(device);
if(i>0){
log.info("未获取到定位===============保存电压等数值成功===========>" +logEntry.getDevName());
@ -361,9 +374,9 @@ public class ReceiveController {
/**
* 异步更新在线状态
*/
private void asynchronousUpdateOnlineStatus(AsDevice device,Object verStr) {
if(StrUtil.isBlank(device.getVersion()) && ObjectUtil.isNotNull(verStr)){
device.setVersion((String)verStr);
private void asynchronousUpdateOnlineStatus(AsDevice device,String verStr) {
if(StrUtil.isNotBlank(verStr)){
device.setVersion(verStr);
}
//开异步线程保存回调参数
scheduledExecutorService.schedule(() -> {

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.AsUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -66,7 +68,7 @@ public class EtParkingAreaController extends BaseController
@GetMapping(value = "/{parkingId}")
public AjaxResult getInfo(@PathVariable("parkingId") Long parkingId)
{
return success(etParkingAreaService.selectEtParkingAreaByParkingId(parkingId));
return success(etParkingAreaService.selectEtParkingAreaByParkingId2(parkingId));
}
/**
@ -109,4 +111,14 @@ public class EtParkingAreaController extends BaseController
{
return toAjax(etParkingAreaService.deleteEtParkingAreaByParkingIds(parkingIds));
}
/**
* 状态修改
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeParkingStatus")
public AjaxResult changeStatus(@RequestBody EtParkingArea area)
{
return toAjax(etParkingAreaService.updateParkingStatus(area));
}
}

View File

@ -140,4 +140,9 @@ public class IotConstants {
*/
public static final String ONENET_LOCATION = "sys";
/**
* ONENET版本号
*/
public static final String ONENET_VER = "VER";
}

View File

@ -115,6 +115,11 @@ public class ServiceConstants {
*/
public static final String PAY_TYPE_ALIPAY = "alipay";
/**
* 支付方式: yj-押金抵扣
*/
public static final String PAY_TYPE_YJ = "yj";
/**----------------------------支付类型end----------------------------*/
/**----------------------------车辆状态start----------------------------*/

View File

@ -72,6 +72,11 @@ public enum BusinessType
*/
REFUND,
/**
* 押金抵扣
*/
DEDUCTION,
/**
* 提现
*/

View File

@ -85,7 +85,7 @@ public class IdUtils
* @return 生成的随机码
*/
public static String getOrderNo(String payType){
return payType + randomCount(11111, 99999) + System.currentTimeMillis() + randomCount(11111, 99999);
return payType + System.currentTimeMillis();
}
/**

View File

@ -165,4 +165,7 @@ public class AsDevice extends BaseEntityPlus implements Serializable {
@TableField(exist = false)
private List<EtOrder> etOrders;
/** 信号强度 */
private Integer signalStrength;
}

View File

@ -107,6 +107,34 @@ public class EtOperatingArea extends BaseEntityPlus implements Serializable
@Excel(name = "客服电话")
private String servicePhone;
/** 客服1 */
@Excel(name = "客服1")
private String serviceName1;
/** 客服电话1 */
@Excel(name = "客服电话1")
private String servicePhone1;
/** 客服2 */
@Excel(name = "客服2")
private String serviceName2;
/** 客服电话2 */
@Excel(name = "客服电话2")
private String servicePhone2;
/** 客服3 */
@Excel(name = "客服3")
private String serviceName3;
/** 客服电话3 */
@Excel(name = "客服电话3")
private String servicePhone3;
/** 是否自定义客服 */
@Excel(name = "是否自定义客服")
private String customService;
/** 运营个性化标语 */
@Excel(name = "运营个性化标语")
private String slogan;

View File

@ -74,4 +74,7 @@ public class EtParkingArea implements Serializable
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 分类状态:0正常,1停用 */
private String status;
}

View File

@ -24,12 +24,19 @@ public class OperatingDataVo {
*/
@Data
public static class Income {
//总收入
private String totalFee;
//总收入
private String totalIncome;
//累计待支付
private String totalUnpaid;
//手续费
private String handlingFee;
//已支付
private String totalPaid;

View File

@ -145,7 +145,7 @@ public interface AsUserMapper
/**
* 总用户
*/
String getTotalUser(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId);
String getTotalUser(@Param("areaId") String areaId);
/**
* 租赁用户

View File

@ -209,7 +209,7 @@ public interface EtOrderMapper
/**
* 收入
*/
BigDecimal getIncome(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn);
BigDecimal getIncome(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("sn") String sn, @Param("areaId") Long areaId);
/**
* 最近一笔订单

View File

@ -21,6 +21,14 @@ public interface EtParkingAreaMapper extends BaseMapper<EtParkingArea>
*/
public EtParkingArea selectEtParkingAreaByParkingId(Long parkingId);
/**
* 查询停车区
*
* @param parkingId 停车区主键
* @return 停车区
*/
public EtParkingArea selectEtParkingAreaByParkingId2(Long parkingId);
/**
* 查询停车区列表
*

View File

@ -127,7 +127,7 @@ public interface IAsDeviceService extends IService<AsDevice>
/**
* 所有车辆定位
*/
List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId);
List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus);
/**
* 查询车辆数量
@ -192,7 +192,7 @@ public interface IAsDeviceService extends IService<AsDevice>
/**
* 还车
*/
Boolean returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage);
Boolean returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage,String isInParkingArea);
/**
* 管理员开锁
@ -255,6 +255,11 @@ public interface IAsDeviceService extends IService<AsDevice>
*/
public boolean isNoRidingArea(String sn,Long areaId);
/**
* 判断是否在禁行区内
*/
public boolean isNoRidingAreaWithTolerance(String sn,Long areaId,int tolerance);
/**
* 低电量不得骑行判断
*/
@ -302,7 +307,7 @@ public interface IAsDeviceService extends IService<AsDevice>
/**
* 判断是否在停车区内
*/
IsInParkingAreaVo isInParkingArea(String longitude, String latitude,String areaId);
IsInParkingAreaVo isInParkingArea(String longitude, String latitude,String areaId,String sn);
// /**
// * 是否靠近运营区边界

View File

@ -201,7 +201,7 @@ public interface IAsUserService
/**
* 总用户
*/
String getTotalUser(String powerStart, String powerEnd, String areaId);
String getTotalUser(String areaId);
/**
* 租赁用户

View File

@ -186,4 +186,9 @@ public interface IEtOrderService
* @return 结果
*/
int deleteEtOrderByOrderNo(String orderNo);
/**
* 押金抵扣
*/
int deduction(EtOrder etOrder);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.system.domain.EtOperatingArea;
import com.ruoyi.system.domain.EtParkingArea;
@ -22,6 +23,14 @@ public interface IEtParkingAreaService extends IService<EtParkingArea>
*/
public EtParkingArea selectEtParkingAreaByParkingId(Long parkingId);
/**
* 查询停车区
*
* @param parkingId 停车区主键
* @return 停车区
*/
public EtParkingArea selectEtParkingAreaByParkingId2(Long parkingId);
/**
* 查询停车区列表
*
@ -74,4 +83,12 @@ public interface IEtParkingAreaService extends IService<EtParkingArea>
* 所有停车点
*/
List<EtParkingArea> allParkingArea();
/**
* 修改停车区状态
*
* @param area 停车区信息
* @return 结果
*/
public int updateParkingStatus(EtParkingArea area);
}

View File

@ -61,14 +61,15 @@ public interface IWxPayService {
/**
* 发起商家转账
* @param areaId 区域id
* @param sysDept 运营商对象
* @param batchNo 批次号
* @param batchName 批次名称
* @param batchRemark 转账说明
* @param totalAmount 转账总金额
* @param totalNum 转账总笔数
* @param transferDetailInputs 转账明细列表
*/
InitiateBatchTransferResponse transfer(Long areaId,String batchName,String batchRemark,BigDecimal totalAmount,Integer totalNum,List<TransferDetailInput> transferDetailInputs);
InitiateBatchTransferResponse transfer(SysDept sysDept,String batchNo,String batchName,String batchRemark,BigDecimal totalAmount,Integer totalNum,List<TransferDetailInput> transferDetailInputs);
/**
* 根据退款单号查询退款信息

View File

@ -1,16 +1,22 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.AsArticleClassify;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.EtArticle;
import com.ruoyi.system.mapper.AsArticleClassifyMapper;
import com.ruoyi.system.mapper.AsArticleMapper;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.service.IAsArticleClassifyService;
import com.ruoyi.system.service.IAsArticleService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 文章Service业务层处理
@ -25,7 +31,7 @@ public class AsArticleServiceImpl implements IAsArticleService
private AsArticleMapper asArticleMapper;
@Resource
private SysDictDataMapper dictDataMapper;
private AsArticleClassifyMapper articleClassifyMapper;
/**
* 查询文章
@ -86,9 +92,32 @@ public class AsArticleServiceImpl implements IAsArticleService
public List<EtArticle> selectAsArticleListByApp(EtArticle etArticle)
{
List<EtArticle> etArticles = asArticleMapper.selectAsArticleListByApp(etArticle);
List<EtArticle> mergedArticles = new ArrayList<>();
Set<String> seenArticleIds = new HashSet<>();
for (EtArticle etArticle1 : etArticles) {
etArticle.setFormatCreateTime(DateUtils.getYYYY_MM_DD(etArticle1.getCreateTime()));
etArticle1.setFormatCreateTime(DateUtils.getYYYY_MM_DD(etArticle1.getCreateTime()));
if (seenArticleIds.add(etArticle1.getArticleId().toString())) {
mergedArticles.add(etArticle1);
}
}
for (EtArticle etArticle1 : etArticles) {
if (etArticle1.getClassifyId().equals("111")) {
List<AsArticleClassify> classifies = articleClassifyMapper.selectChildrenClassifyById(Long.parseLong(etArticle1.getClassifyId()));
for (AsArticleClassify classify : classifies) {
EtArticle etArticle2 = new EtArticle();
etArticle2.setClassifyId(classify.getClassifyId().toString());
List<EtArticle> etArticles1 = asArticleMapper.selectAsArticleList(etArticle2);
for (EtArticle etArticle2Item : etArticles1) {
if (seenArticleIds.add(etArticle2Item.getArticleId().toString())) {
mergedArticles.add(etArticle2Item);
}
}
}
}
}
etArticles = mergedArticles;
return etArticles;
}

View File

@ -415,7 +415,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 所有车辆定位
*/
@Override
public List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId) {
public List<AsDevice> allVehicleInfo(String powerStart, String powerEnd, String status,String sort,String areaId,String onlineStatus) {
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
if(StrUtil.isNotBlank(areaId)){
wrapper.eq("area_id",areaId);
@ -426,6 +426,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(StrUtil.isNotBlank(status)){
wrapper.in("status",status);
}
if(StrUtil.isNotBlank(onlineStatus)){
wrapper.in("online_status",onlineStatus);
}
if(StrUtil.isNotBlank(sort)){
wrapper.orderBy(true,!StrUtil.equals(sort, "desc"),"remaining_power");
}
@ -539,7 +542,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
/** 2.发送命令*/
ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁");
if(responseVo.getCode() != 0){
asynchronousUpdateOnlineStatus(asDevice.getMac());
// asynchronousUpdateOnlineStatus(asDevice.getMac());
throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败");
}
}else{
@ -717,7 +720,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public String getInOperationDevice(String timeStart, String timeEnd,String areaId) {
if(ObjectUtil.isNotEmpty(timeStart)&&ObjectUtil.isNotEmpty(timeEnd)){
QueryWrapper<AsDevice> wrapper = new QueryWrapper<AsDevice>().eq("status", ServiceConstants.VEHICLE_STATUS_IN_USING);
QueryWrapper<AsDevice> wrapper = new QueryWrapper<AsDevice>().in("status", "1", "2", "3", "4");
wrapper.eq("area_id", areaId);
return asDeviceMapper.selectCount(wrapper)+"";
}
@ -810,6 +813,10 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
log.info(""+type+"】===>IOT请求调用结果:【{}】",result);
ResponseVo responseVo = JSON.parseObject(result, ResponseVo.class);
if(responseVo.getCode() != 0){
asynchronousUpdateOnlineStatus(mac);
}
return JSON.parseObject(result,ResponseVo.class);
}
@ -1130,7 +1137,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@SneakyThrows
@Override
@Transactional
public Boolean returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage) {
public Boolean returnVehicle(String orderNo,String returnType,String isBluetooth,String lon,String lat,String voltage,String isInParkingArea) {
if(StrUtil.isNotBlank(orderNo)){
EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo);
if(ObjectUtil.isNull(order)){
@ -1148,9 +1155,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(isNoParkingArea(order.getSn(), order.getAreaId())){
throw new ServiceException("在禁停区内,不能还车");
}
// 停车点还车
// 停车点还车 todo
if(area.getParkingReturn().equals("1")){
if(!isParkingZone(order.getSn(), order.getAreaId())){
if(StrUtil.isNotBlank(isInParkingArea) && !"true".equals(isInParkingArea)){
throw new ServiceException("不在停车点内,不能还车");
}
}
@ -1209,7 +1216,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
throw new ServiceException("【还车关锁】更新车辆状态失败");
}
/** 3. 计算订单费用,保存订单总金额*/
order = calculateOrderFee(order);
order = calculateOrderFee(order,isInParkingArea);
/** 6.计算行车距离*/
String tripRouteStr = order.getTripRouteStr();
if(StrUtil.isNotBlank(tripRouteStr)){
@ -1237,7 +1244,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
/**
* 计算订单费用
*/
private EtOrder calculateOrderFee(EtOrder order) {
private EtOrder calculateOrderFee(EtOrder order,String isInParkingArea) {
String type = order.getType();
if(type.equals("1")){//骑行订单,正常骑行包含预约费计时收费根据开锁时间起步价和起步时长时长费和时长分钟等参数如果有预约还要加上预约费计算费用,还要判断封顶费用根据开锁时间
Long ruleId = order.getRuleId();
@ -1261,18 +1268,20 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
order.setCycle(1);//在第几个计费周期内
ridingFee = calculateRidingFee(order.getUnlockTime(), order, rule, rule.getRidingRuleJson(), rentalUnit);
}else {
// 骑行费 = (第几个周期 - 1) * 封顶费用 + 骑行费
// 算出最后一个周期的开始时间
// 判断一个计费周期是否超过封顶费用如果超出 骑行费 = (第几个周期 - 1) * 封顶费用 + 骑行费
// 如果不超出骑行费 = 骑行费
Date oneCycleAfter = DateUtils.getTimeAfterXHours(order.getUnlockTime(), Integer.parseInt(chargingCycleValue));
if(isFeeExceedingCap(order.getUnlockTime(),oneCycleAfter, rule,rentalUnit)){
// 如果超出 骑行费 = (第几个周期 - 1) * 封顶费用 + 骑行费
order.setCycle(cycle);
Date afterXHours = DateUtils.getTimeAfterXHours(order.getUnlockTime(), Integer.parseInt(chargingCycleValue)*(cycle-1));
ridingFee = calculateRidingFee(afterXHours, order, rule, rule.getRidingRuleJson(),rentalUnit);
}
Boolean comparisonResult = ridingFee.compareTo(rule.getCappedAmount()) >= 0;//比较订单的骑行费+预约费是否大于等于封顶费用
if(comparisonResult){//超出封顶费用按封顶费用计算
order.setRidingFee(rule.getCappedAmount());
BigDecimal remainingFee = calculateRidingFee(afterXHours, order, rule, rule.getRidingRuleJson(),rentalUnit);
ridingFee = new BigDecimal(cycle - 1).multiply(rule.getCappedAmount()).add(remainingFee);
}else{
order.setRidingFee(ridingFee);
ridingFee = calculateRidingFee(order.getUnlockTime(), order, rule, rule.getRidingRuleJson(), rentalUnit);
}
}
order.setRidingFee(ridingFee);
}else if(ServiceConstants.CHARGING_CYCLE_CUSTOM.equals(chargingCycle)){//自定义时刻
// todo 自定义计费周期时刻 获取到自定义时刻判断骑行的这段时间是否在自定义时刻里 ____.___.___|___________|
// 如果不在
@ -1282,9 +1291,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
/** 停车点外调度费*/
// 根据车辆的定位判断是否在停车区内
if(!isParkingZone(order.getSn(), order.getAreaId())){
if(StrUtil.isNotBlank(isInParkingArea) && !"true".equals(isInParkingArea)){
BigDecimal vehicleManagementFee = area.getVehicleManagementFee();//车辆停车点外调度费
order.setManageFee(vehicleManagementFee);
}else{
order.setManageFee(BigDecimal.ZERO);
}
/** 调度费*/
//判断是否在运营区内
@ -1309,7 +1320,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
order.setRidingFee(BigDecimal.ZERO);
totalFee = BigDecimal.ZERO;//如果骑行费是0说明在免费骑行时间内那订单的总金额也是0
}else{
ridingFee = new BigDecimal(cycle - 1).multiply(rule.getCappedAmount()).add(order.getRidingFee());
ridingFee = order.getRidingFee();
totalFee = ridingFee.add(order.getManageFee()).add(order.getDispatchFee()).add(order.getAppointmentFee());
}
}
@ -1323,6 +1334,26 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
/**
* 判断一个计费周期是否超过封顶费用
*/
@NotNull
private Boolean isFeeExceedingCap(Date startTime, Date endTime, EtFeeRule rule, String rentalUnit) {
Integer minutes = DateUtils.timeDifferenceInMinutes(endTime,startTime);//计算相隔多少分钟
StartingRuleVo startingRule = JSONObject.parseObject(rule.getRidingRuleJson(), StartingRuleVo.class);
String timeoutPrice = startingRule.getTimeoutPrice();//超时价格
Integer timeoutTime = Integer.parseInt(startingRule.getTimeoutTime());//超时时间
if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){//租赁单位hours-小时
timeoutTime = timeoutTime*60;
}else if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_DAY)){//租赁单位day-
timeoutTime = timeoutTime*60*24;
}
double ceil = Math.ceil(minutes / timeoutTime) +1 ;
BigDecimal ridingFee = new BigDecimal(ceil * Double.parseDouble(timeoutPrice));
return ridingFee.compareTo(rule.getCappedAmount())>0;
}
/**
* 计算骑行费
@ -1593,6 +1624,38 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
return isNoRiding;
}
/**
* 是否禁行区内
*/
@Override
public boolean isNoRidingAreaWithTolerance(String sn,Long areaId,int tolerance) {
Boolean isNoRiding = false;
EtParkingArea parkingArea = new EtParkingArea();
parkingArea.setAreaId(areaId);
List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea);
if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){
log.info("运营区【{}】没有禁行区,",areaId);
throw new ServiceException("运营区【{}】没有禁行区"+areaId.toString());
}
for (EtParkingArea etParkingArea : parkingAreas) {
if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_BANNED_RIDING)){
AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn);
String latitude = device.getLatitude();
String longitude = device.getLongitude();
Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary());
isNoRiding = GeoUtils.isInPolygonWithTolerance(longitude, latitude, geometry,tolerance);
if(isNoRiding){
log.info("车辆【{}】在禁行区({}米)【{}】内",sn,tolerance,etParkingArea.getParkingName());
isNoRiding = true;
break;
}else{
log.info("车辆【{}】不在禁行区({}米)【{}】内",sn,tolerance,etParkingArea.getParkingName());
}
}
}
return isNoRiding;
}
/**
* 是否低电量
*/
@ -1646,7 +1709,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
.set("latitude",device.getLatitude())
.set("remaining_power",device.getRemainingPower())
.set("last_time",device.getLastTime())
.set("voltage",device.getVoltage());
.set("voltage",device.getVoltage())
.set("signal_strength",device.getSignalStrength());
return asDeviceMapper.update(null,wrapper);
}
@ -1710,9 +1774,20 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 判断是否在停车区申请人
*/
@Override
public IsInParkingAreaVo isInParkingArea(String longitude, String latitude,String areaId){
public IsInParkingAreaVo isInParkingArea(String longitude, String latitude,String areaId,String sn){
// 线判断车的定位是否在停车区内如果在停车区内则直接返回如果不在拿手机的定位再判断是否在停车区内
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(Long.parseLong(areaId));
IsInParkingAreaVo isInParkingAreaVo = new IsInParkingAreaVo();
if(StringUtils.isNotEmpty(sn)){
AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn);
String longitude1 = device.getLongitude();
String latitude1 = device.getLatitude();
Boolean parkingZoneByLocation = isParkingZoneByLocation(longitude1, latitude1, Long.parseLong(areaId));
if(parkingZoneByLocation){
isInParkingAreaVo.setParkingReturn("1".equals(area.getParkingReturn()));
return isInParkingAreaVo;
}
}
Boolean parkingZoneByLocation = isParkingZoneByLocation(longitude, latitude, Long.parseLong(areaId));
isInParkingAreaVo.setIsInParkingArea(parkingZoneByLocation);
//停车点还车0-关闭1-开启

View File

@ -492,11 +492,8 @@ public class AsUserServiceImpl implements IAsUserService
* 总用户
*/
@Override
public String getTotalUser(String powerStart, String powerEnd,String areaId) {
if(StringUtils.isNotEmpty(powerStart) && StringUtils.isNotEmpty(powerEnd)){
return asUserMapper.getTotalUser(powerStart,powerEnd,areaId);
}
return null;
public String getTotalUser(String areaId) {
return asUserMapper.getTotalUser(areaId);
}
/**

View File

@ -469,9 +469,9 @@ public class CallbackServiceImpl implements CallbackService {
capitalFlow.setBusType(busType);
capitalFlow.setAmount(order.getPayFee());
logger.info("【微信支付回调--保存资金流水记录】 获取到配置手续费==============handlingCharge====================="+handlingCharge);
BigDecimal bigDecimal = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal bigDecimal = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 6, BigDecimal.ROUND_HALF_UP);
logger.info("【微信支付回调--保存资金流水记录】 转换后手续费==============bigDecimal====================="+bigDecimal);
BigDecimal multiply = bigDecimal.multiply(order.getTotalFee());
BigDecimal multiply = bigDecimal.multiply(order.getTotalFee()).setScale(2, BigDecimal.ROUND_HALF_UP);
logger.info("【微信支付回调--保存资金流水记录】 计算出的手续费==============multiply====================="+multiply);
if(busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT) || busType.equals(ServiceConstants.ORDER_TYPE_DEPOSIT_REFUND)){
capitalFlow.setOperatorDividend(BigDecimal.ZERO);

View File

@ -336,6 +336,67 @@ public class EtOrderServiceImpl implements IEtOrderService
return 1;
}
/**
* 押金抵扣
* 1. 校验订单状态为待支付不是待支付则返回false
* 2. 根据当前订单号查询订单信息
* 3. 获取用户最后一次押金充值订单
* 4. 将抵扣后的金额 = 押金-骑行订单金额
* 如果金额大于0
* 如果金额小于0押金订单金额 = 0更新骑行订单状态为未支付
* 5. 更新押金订单金额做一个押金抵扣的标记
* 6. 更新骑行订单状态为已支付支付方式为 押金抵扣
* 7. 更新车辆信息
*/
@Override
@Transactional
public int deduction(EtOrder etOrder) {
EtOrder order = etOrderMapper.selectEtOrderByOrderNo(etOrder.getOrderNo());
if(!ServiceConstants.ORDER_STATUS_RIDING_END.equals(order.getStatus())){
throw new ServiceException("押金抵扣失败,订单非待支付状态,订单状态:"+order.getStatus());
}
EtOrder depositOrder = getDepositOrder(order.getUserId());
BigDecimal deposit = depositOrder.getTotalFee();
BigDecimal ridingFee = order.getTotalFee();
if(deposit.compareTo(ridingFee) > 0){
// 押金大于订单金额 扣除后
BigDecimal afterDeductionFee = deposit.subtract(ridingFee);
order.setTotalFee(afterDeductionFee);
order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
order.setPayTime(DateUtils.getNowDate());
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
order.setPayType(ServiceConstants.PAY_TYPE_YJ);
order.setMark("押金抵扣");
int updateEtOrder = etOrderMapper.updateEtOrder(order);
if(updateEtOrder == 0){
throw new ServiceException("押金抵扣失败,更新订单失败");
}
}else{
throw new ServiceException("押金抵扣失败,骑行费用大于押金");
}
return 0;
}
private EtOrder getDepositOrder(Long userId) {
EtOrder depositOrder = new EtOrder();
depositOrder.setUserId(userId);
depositOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
depositOrder.setType(ServiceConstants.ORDER_TYPE_DEPOSIT);
depositOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(depositOrder);
if (etOrders.size() == 0 || ObjectUtil.isNull(etOrders) ) {
throw new ServiceException("押金充值记录不存在");
}
Optional<EtOrder> latestOrder = etOrders.stream()
.max(Comparator.comparing(EtOrder::getPayTime));
if (latestOrder.isPresent()) {
EtOrder newestOrder = latestOrder.get();
log.info("【押金抵扣】最后一次押金充值记录 : " + JSON.toJSONString(newestOrder));
return newestOrder;
}
throw new ServiceException("押金充值记录不存在");
}
private boolean toBePaid(String[] statusList) {
boolean hasOne = false;
boolean hasThree = false;
@ -570,10 +631,19 @@ public class EtOrderServiceImpl implements IEtOrderService
if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){
/*收入相关*/
OperatingDataVo.Income income = new OperatingDataVo.Income();
income.setTotalIncome(etOrderMapper.getTotalIncome(timeStart,timeEnd,areaId));//总收入
income.setTotalUnpaid(etOrderMapper.getTotalUnpaid(timeStart,timeEnd,areaId));//累计待支付
income.setTotalPaid(etOrderMapper.getTotalPaid(timeStart,timeEnd,areaId));//已支付
income.setTotalRefund(etOrderMapper.getTotalRefund(timeStart,timeEnd,areaId));//已退款
String totalUnpaid = etOrderMapper.getTotalUnpaid(timeStart, timeEnd, areaId);
income.setTotalUnpaid(totalUnpaid);//累计待支付
String totalPaid = etOrderMapper.getTotalPaid(timeStart, timeEnd, areaId);
String totalRefund = etOrderMapper.getTotalRefund(timeStart, timeEnd, areaId);//已退款
income.setTotalPaid(totalPaid);//已支付
//handlingFee 手续费 = 0.0054 * 已支付金额
BigDecimal divide = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 4, RoundingMode.HALF_UP);
BigDecimal handlingFee = new BigDecimal(totalPaid).multiply(divide);
income.setHandlingFee(handlingFee.setScale(2, RoundingMode.HALF_UP).toString());
// 总营收 = 已支付 - 已退款 - 手续费
income.setTotalIncome(new BigDecimal(totalPaid).subtract(new BigDecimal(totalRefund)).subtract(handlingFee).setScale(2, RoundingMode.HALF_UP).toString());//总收入 etOrderMapper.getTotalIncome(timeStart,timeEnd,areaId)
income.setTotalRefund(totalRefund);//已退款
income.setTotalFee(new BigDecimal(totalUnpaid).add(new BigDecimal(totalPaid)).toString());// 订单总金额 = 已支付+待支付
income.setTotalRidingFee(etOrderMapper.getTotalRidingFee(timeStart,timeEnd,areaId));//骑行已支付
income.setTotalRidingRefund(etOrderMapper.getTotalRidingRefund(timeStart,timeEnd,areaId));//骑行已退款
income.setTotalDispatchFee(etOrderMapper.getTotalDispatchFee(timeStart,timeEnd,areaId));//调度费已支付
@ -594,14 +664,17 @@ public class EtOrderServiceImpl implements IEtOrderService
/*设备相关*/
OperatingDataVo.DeviceVo deviceVo = new OperatingDataVo.DeviceVo();
deviceVo.setInOperationDevice(deviceService.getInOperationDevice(timeStart,timeEnd,areaId));//运营中车辆
deviceVo.setInOrderDevice(deviceService.getInOrderDevice(timeStart,timeEnd,areaId));//有订单车辆
deviceVo.setNoOrderDevice(deviceService.getNoOrderDevice(timeStart,timeEnd,areaId));//无订单车辆
String inOperationDevice = deviceService.getInOperationDevice(timeStart, timeEnd, areaId);
String inOrderDevice = deviceService.getInOrderDevice(timeStart, timeEnd, areaId);
deviceVo.setInOperationDevice(inOperationDevice);//运营中车辆
deviceVo.setInOrderDevice(inOrderDevice);//有订单车辆
int i = Integer.parseInt(inOperationDevice) - Integer.parseInt(inOrderDevice);
deviceVo.setNoOrderDevice( i+"");//无订单车辆
operatingDataVo.setDevice(deviceVo);
/*用户相关*/
OperatingDataVo.UserVo userVo = new OperatingDataVo.UserVo();
userVo.setTotalUser(asUserService.getTotalUser(timeStart,timeEnd,areaId));//总用户
userVo.setTotalUser(asUserService.getTotalUser(areaId));//总用户
userVo.setNewUser(asUserService.getNewUser(timeStart,timeEnd,areaId));//新增用户
userVo.setLeaseUser(asUserService.getLeaseUser(timeStart,timeEnd,areaId));//租赁用户
operatingDataVo.setUser(userVo);
@ -811,8 +884,9 @@ public class EtOrderServiceImpl implements IEtOrderService
BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//新增
BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//退款
BigDecimal incomeFee = defaultIfNull(etOrderMapper.getIncome(startDateStr, endDateStr, null), BigDecimal.ZERO);//营收
BigDecimal serviceFee = payFee.multiply(new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP));//手续费
BigDecimal incomeFee = defaultIfNull(etOrderMapper.getIncome(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//营收
BigDecimal divide = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 6, RoundingMode.HALF_UP);
BigDecimal serviceFee = payFee.multiply(divide).setScale(2, RoundingMode.HALF_UP);//手续费
reconciliation.setPayFee(payFee);
reconciliation.setRefundFee(refundFee);
@ -842,7 +916,7 @@ public class EtOrderServiceImpl implements IEtOrderService
reconciliation.setSn(sn);
reconciliation.setPayFee(etOrderMapper.getPayFee(timeStart, timeEnd, sn, null));
reconciliation.setRefundFee(etOrderMapper.getRefundFee(timeStart, timeEnd, sn, null));
reconciliation.setIncome(etOrderMapper.getIncome(timeStart, timeEnd, sn));
reconciliation.setIncome(etOrderMapper.getIncome(timeStart, timeEnd, sn, null));
return reconciliation;
}

View File

@ -3,7 +3,11 @@ package com.ruoyi.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.map.GeoUtils;
@ -16,6 +20,8 @@ import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EtParkingAreaMapper;
import com.ruoyi.system.domain.EtParkingArea;
import com.ruoyi.system.service.IEtParkingAreaService;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
@ -44,6 +50,18 @@ public class EtParkingAreaServiceImpl extends ServiceImpl<EtParkingAreaMapper, E
return etParkingAreaMapper.selectEtParkingAreaByParkingId(parkingId);
}
/**
* 查询停车区
*
* @param parkingId 停车区主键
* @return 停车区
*/
@Override
public EtParkingArea selectEtParkingAreaByParkingId2(Long parkingId)
{
return etParkingAreaMapper.selectEtParkingAreaByParkingId2(parkingId);
}
/**
* 查询停车区列表
*
@ -133,9 +151,22 @@ public class EtParkingAreaServiceImpl extends ServiceImpl<EtParkingAreaMapper, E
*/
@Override
public List<EtParkingArea> allParkingArea(){
List<EtParkingArea> etParkingAreas = etParkingAreaMapper.selectEtParkingAreaList(new EtParkingArea());
EtParkingArea parkingArea = new EtParkingArea();
parkingArea.setStatus("0");
List<EtParkingArea> etParkingAreas = etParkingAreaMapper.selectEtParkingAreaList(parkingArea);
return etParkingAreas;
}
/**
* 修改停车区状态
*
* @param area 停车区信息
* @return 结果
*/
@Override
public int updateParkingStatus(EtParkingArea area) {
return etParkingAreaMapper.updateEtParkingArea(area);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
@ -14,10 +15,16 @@ import com.ruoyi.system.mapper.AsUserMapper;
import com.ruoyi.system.mapper.EtWithdrawMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.IEtWithdrawService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.IWxPayService;
import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -40,6 +47,12 @@ public class EtWithdrawServiceImpl implements IEtWithdrawService
@Resource
private SysUserMapper userMapper;
@Autowired
private IWxPayService wxPayService;
@Autowired
private ISysDeptService deptService;
/**
* 查询提现记录
*
@ -98,6 +111,20 @@ public class EtWithdrawServiceImpl implements IEtWithdrawService
@Override
public int updateEtWithdraw(EtWithdraw etWithdraw)
{
//如果提现是通过则发起商户转账到零钱
if(etWithdraw.getStatus().equals(ServiceConstants.WITHDRAW_STATUS_PASS)){
SysDept sysDept = deptService.selectDeptById(etWithdraw.getDeptId());
String batchName= sysDept.getDeptName()+"发起提现";
List<TransferDetailInput> transferDetailInputs = new ArrayList<>();
TransferDetailInput transferDetailInput = new TransferDetailInput();
transferDetailInput.setOutDetailNo(IdUtils.getOrderNo("txd"));//明细订单号
transferDetailInput.setTransferAmount(etWithdraw.getAmount().multiply(new BigDecimal(100)).longValue());
transferDetailInput.setTransferRemark("创特共享电动车提现");
transferDetailInput.setOpenid(etWithdraw.getWxopenid());
transferDetailInputs.add(transferDetailInput);
log.info("【审核通过】发起转账到零钱:{}",JSON.toJSONString(transferDetailInputs));
wxPayService.transfer(sysDept,etWithdraw.getWithdrawNo(),batchName,batchName,etWithdraw.getAmount(),1,transferDetailInputs);
}
return etWithdrawMapper.updateEtWithdraw(etWithdraw);
}

View File

@ -229,7 +229,8 @@ public class WxPayService implements IWxPayService {
/**
* 发起商家转账
* @param areaId 区域id
* @param sysDept 运营商对象
* @param batchNo 批次号
* @param batchName 批次名称
* @param batchRemark 转账说明
* @param totalAmount 转账总金额
@ -237,11 +238,11 @@ public class WxPayService implements IWxPayService {
* @param transferDetailInputs 转账明细列表
*/
@Override
public InitiateBatchTransferResponse transfer(Long areaId,String batchName,String batchRemark,BigDecimal totalAmount,Integer totalNum,List<TransferDetailInput> transferDetailInputs) {
SysDept sysDept = getDeptObjByAreaId(areaId);
public InitiateBatchTransferResponse transfer(SysDept sysDept,String batchNo,String batchName,String batchRemark,BigDecimal totalAmount,Integer totalNum,List<TransferDetailInput> transferDetailInputs) {
// SysDept sysDept = getDeptObjByAreaId(areaId);
InitiateBatchTransferRequest request = new InitiateBatchTransferRequest();
request.setAppid(sysDept.getAppid());
request.setOutBatchNo(IdUtils.getOrderNo("tx"));//
request.setOutBatchNo(batchNo);
request.setBatchName(batchName);
request.setBatchRemark(batchRemark);
request.setTotalAmount(totalAmount.multiply(new BigDecimal(100)).longValue());

View File

@ -64,14 +64,14 @@ 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.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.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 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 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
<if test="deviceName != null and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
<if test="mac != null and mac != ''"> and de.mac like concat('%', #{mac}, '%')</if>
<if test="sn != null and sn != ''"> and de.sn like concat('%', #{sn}, '%')</if>
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num = #{vehicleNum}</if>
<if test="vehicleNum != null and vehicleNum != ''"> and de.vehicle_num like concat('%', #{vehicleNum}, '%')</if>
<if test="areaId != null "> and de.area_id = #{areaId}</if>
<if test="deptId != null "> and d.dept_id = #{deptId}</if>
<if test="modelId != null and modelId != ''"> and de.model_id = #{modelId}</if>

View File

@ -138,8 +138,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getLeaseUser" resultType="java.lang.String">
SELECT COUNT(DISTINCT o.user_id) from et_order o LEFT JOIN et_user u on o.user_id = u.user_id
where date_format(u.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
and date_format(u.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
where date_format(o.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
and date_format(o.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
and type = 1
<if test="areaId != null and areaId != ''">
and o.area_id = #{areaId}
</if>
@ -147,9 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTotalUser" resultType="java.lang.String">
select count(1) from et_user
where date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
and date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
and status = '0'
where status = '0'
<if test="areaId != null and areaId != ''">
and area_id = #{areaId}
</if>

View File

@ -43,6 +43,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="autoReplacementOrder" column="auto_replacement_order" />
<result property="parkingReturn" column="parking_return" />
<result property="areaOutReturn" column="area_out_return" />
<result property="serviceName1" column="service_name1" />
<result property="serviceName2" column="service_name2" />
<result property="serviceName3" column="service_name3" />
<result property="servicePhone1" column="service_phone1" />
<result property="servicePhone2" column="service_phone2" />
<result property="servicePhone3" column="service_phone3" />
<result property="customService" column="custom_service" />
</resultMap>
<sql id="selectEtOperatingAreaVo">
@ -52,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
county, area_out_outage, parking_out_dispatch, area_out_dispatch,
no_riding_outage, authentication, msg_switch, undercharge, error, cast(agreement as char) as agreement, deposit,
outage, appointment_service_fee, dispatch_fee, vehicle_management_fee, timeout_minutes,
auto_replacement_order, area_time_start, area_time_end, area_out_return, parking_return from et_operating_area
auto_replacement_order, area_time_start, area_time_end, area_out_return, parking_return, service_name1, service_name2, service_name3, service_phone1, service_phone2, service_phone3, custom_service from et_operating_area
</sql>
<select id="selectEtOperatingAreaList" parameterType="EtOperatingArea" resultMap="EtOperatingAreaResult">
@ -62,7 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.county, a.area_out_outage, a.parking_out_dispatch, a.area_out_dispatch,
a.no_riding_outage, a.authentication, a.msg_switch, a.undercharge, a.error, a.agreement, a.deposit,
a.outage, a.appointment_service_fee, a.dispatch_fee, a.vehicle_management_fee, a.timeout_minutes,
a.auto_replacement_order, a.area_time_start, a.area_time_end, a.area_out_return, a.parking_return from et_operating_area a
a.auto_replacement_order, a.area_time_start, a.area_time_end, a.area_out_return, a.parking_return,
a.service_name1, a.service_name2, a.service_name3, a.service_phone1, a.service_phone2, a.service_phone3, a.custom_service from et_operating_area a
left join et_area_dept ad on ad.area_id = a.area_id
left join sys_dept d on d.dept_id = ad.dept_id
where 1 = 1

View File

@ -38,13 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="returnType" column="return_type" />
<result property="tripRoute" column="trip_route" />
<result property="tripRouteStr" column="trip_route_str" />
<result property="cycle" column="cycle" />
</resultMap>
<sql id="selectEtOrderVo">
select order_id, area_id, order_no, out_trade_no, user_id, rule_id,
device_mac, sn, pay_time, paid, pay_type, type, total_fee, pay_fee, dispatch_fee,
manage_fee, riding_fee, appointment_fee, mark, duration, distance, status,
create_time, appointment_start_time, appointment_end_time,appointment_timeout, unlock_time,return_time, rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str from et_order
create_time, appointment_start_time, appointment_end_time,appointment_timeout, unlock_time,return_time, rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str,cycle from et_order
</sql>
<select id="selectEtOrderList" parameterType="EtOrder" resultMap="EtOrderResult">
@ -205,92 +206,113 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getTotalUnpaid" resultType="java.lang.String" parameterType="String">
select COALESCE(SUM(total_fee), 0) from et_order where status = 4 and type = 1 and paid = 0
select COALESCE(SUM(total_fee), 0) from et_order where status = 3 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalPaid" resultType="java.lang.String">
select COALESCE(SUM(total_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalRefund" resultType="java.lang.String">
select COALESCE(SUM(amount), 0) from et_refund where type = 1 AND refund_result = 'SUCCESS'
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
select COALESCE(SUM(r.amount), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getTotalRidingFee" resultType="java.lang.String">
select COALESCE(SUM(riding_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalRidingRefund" resultType="java.lang.String">
select COALESCE(SUM(riding_fee), 0) from et_order where status = 4 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
select COALESCE(SUM(r.riding_fee), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getTotalDispatchFee" resultType="java.lang.String">
select COALESCE(SUM(dispatch_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalDispatchRefund" resultType="java.lang.String">
select COALESCE(SUM(dispatch_fee), 0) from et_order where status = 4 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
select COALESCE(SUM(r.dispatch_fee), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getTotalAppointmentFee" resultType="java.lang.String">
select COALESCE(SUM(appointment_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalAppointmentRefund" resultType="java.lang.String">
select COALESCE(SUM(appointment_fee), 0) from et_order where status = 4 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
select COALESCE(SUM(r.appointment_fee), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getTotalManageFee" resultType="java.lang.String">
select COALESCE(SUM(manage_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getTotalManageRefund" resultType="java.lang.String">
select COALESCE(SUM(manage_fee), 0) from et_order where status = 4 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
select COALESCE(SUM(r.manage_fee), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getPaidOrder" resultType="java.lang.String">
select COALESCE(count(1), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getRidingOrder" resultType="java.lang.String">
select COALESCE(count(1), 0) from et_order where status = 2 and type = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getRefundOrder" resultType="java.lang.String">
select COALESCE(count(1), 0) from et_order where status = 4 and type = 1 and paid = 0
select COALESCE(count(1), 0) from et_refund r left join et_order o on o.order_no = r.order_no where r.type = 1 AND refund_result = 'SUCCESS'
AND date_format(r.create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(r.create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and o.area_id = #{areaId}</if>
</select>
<select id="getUnpaidOrder" resultType="java.lang.String">
select COALESCE(count(1), 0) from et_order where status = 4 and type = 1 and paid = 0
select COALESCE(count(1), 0) from et_order where status = 3 and type = 1 and paid = 0
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getServiceFee" resultType="java.math.BigDecimal">
select COALESCE(SUM(total_fee), 0) from et_order where status = 4 and type = 1 and paid = 1
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{timeStart},'%y%m%d')
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{timeEnd},'%y%m%d')
<if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
</select>
<select id="getPayFee" resultType="java.math.BigDecimal">
@ -460,6 +482,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="returnType != null">return_type,</if>
<if test="tripRoute != null">trip_route,</if>
<if test="tripRouteStr != null">trip_route_str,</if>
<if test="cycle != null">cycle,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
@ -493,6 +516,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="returnType != null">#{returnType},</if>
<if test="tripRoute != null">GeomFromText(#{tripRoute}),</if>
<if test="tripRouteStr != null">#{tripRouteStr},</if>
<if test="cycle != null">#{cycle},</if>
</trim>
</insert>
@ -528,6 +552,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="returnType != null">return_type = #{returnType},</if>
<if test="tripRoute != null">trip_route = GeomFromText(#{tripRoute}),</if>
<if test="tripRouteStr != null">trip_route_str = #{tripRouteStr},</if>
<if test="cycle != null">cycle = #{cycle},</if>
</trim>
where order_id = #{orderId}
</update>
@ -564,6 +589,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="returnType != null">return_type = #{returnType},</if>
<if test="tripRoute != null">trip_route = GeomFromText(#{tripRoute}),</if>
<if test="tripRouteStr != null">trip_route_str = #{tripRouteStr},</if>
<if test="cycle != null">cycle = #{cycle},</if>
</trim>
where order_no = #{orderNo}
</update>

View File

@ -18,10 +18,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="status" column="status" />
</resultMap>
<sql id="selectEtParkingAreaVo">
select parking_id, parking_name, type, area_id, AsText(boundary) boundary, boundary_str, error, longitude, latitude, picture, remark, create_by, create_time from et_parking_area
select parking_id, parking_name, type, area_id, AsText(boundary) boundary, boundary_str, error, longitude, latitude, picture, remark, create_by, create_time,status from et_parking_area
</sql>
<select id="selectEtParkingAreaList" parameterType="EtParkingArea" resultMap="EtParkingAreaResult">
@ -30,10 +31,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="parkingName != null and parkingName != ''"> and parking_name like concat('%', #{parkingName}, '%')</if>
<if test="areaId != null "> and area_id = #{areaId}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectEtParkingAreaByParkingId" parameterType="Long" resultMap="EtParkingAreaResult">
<include refid="selectEtParkingAreaVo"/>
where status = '0' and parking_id = #{parkingId}
</select>
<select id="selectEtParkingAreaByParkingId2" parameterType="Long" resultMap="EtParkingAreaResult">
<include refid="selectEtParkingAreaVo"/>
where parking_id = #{parkingId}
</select>
@ -57,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parkingId != null">#{parkingId},</if>
@ -71,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
@ -88,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="status != null">status = #{status},</if>
</trim>
where parking_id = #{parkingId}
</update>