1. 优惠券

2. 运营数据
3. 优化轨迹,先存入轨迹日志
This commit is contained in:
邱贞招 2024-08-25 17:27:02 +08:00
parent 3da837e925
commit 381fd389ad
26 changed files with 713 additions and 181 deletions

View File

@ -91,7 +91,7 @@ public class IndexController extends BaseController
/**
* 首页统计-排行榜
* type1-根据订单数排序2-根据订单金额排序
* type1-根据订单数排序2-根据订单金额排序; 3-进行中的订单
* timeLimit1-今天2-本周
*/
@GetMapping(value = "/admim/leaderboard")

View File

@ -30,6 +30,7 @@ import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.model.Refund;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -88,6 +89,9 @@ public class AppController extends BaseController
@Autowired
private IEtHardwareVersionService etHardwareVersionService;
@Autowired
private IEtCouponService etCouponService;
@Value("${aliyun.accessKeyId}")
private String accessKeyId;
@ -447,6 +451,7 @@ public class AppController extends BaseController
double[][] doubles = GeoUtils.parseJsonTrack(tripRouteStr);
double v = GeoUtils.calculateTotalDistance(doubles);
etOrder.setDistance((int)Math.round(v));
logger.info("【计算订单距离】,更新订单信息,{}",JSON.toJSON(etOrder));
int updateEtOrder = etOrderService.updateEtOrder(etOrder);
if(updateEtOrder>0){
logger.info("计算订单距离成功【orderNo="+etOrder.getOrderNo()+"");
@ -669,4 +674,14 @@ public class AppController extends BaseController
return parts;
}
/**
* 查询优惠券列表
*/
@GetMapping("/couponList")
public AjaxResult list(EtCoupon etCoupon)
{
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
return success(list);
}
}

View File

@ -106,6 +106,11 @@ public class AppVerifyController extends BaseController
@Resource
private EtOperatingAreaMapper etOperatingAreaMapper;
@Autowired
private IEtCouponService etCouponService;
@Autowired
private IEtCouponClaimLogService etCouponClaimLogService;
/**
@ -696,26 +701,26 @@ public class AppVerifyController extends BaseController
List<EtParkingArea> etParkingAreas = etParkingAreaService.allParkingArea();
return success(etParkingAreas);
}
//
// /**
// * 运营数据
// */
// @GetMapping(value = "/operatingData")
// public AjaxResult operatingData(String timeStart,String timeEnd,String areaId)
// {
// logger.info("【运营数据】请求参数timeStart={},timeEnd={},areaId={}", timeStart,timeEnd,areaId);
// OperatingDataVo operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId);
// return success(operatingDataVo);
// }
/**
* 运营数据
*/
@GetMapping(value = "/operatingData")
public AjaxResult operatingData(String timeStart,String timeEnd,String areaId)
{
logger.info("【运营数据】请求参数timeStart={},timeEnd={},areaId={}", timeStart,timeEnd,areaId);
OperatingDataVo operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId);
return success(operatingDataVo);
}
/**
* 运营数据2
*/
@GetMapping(value = "/operatingData2")
public AjaxResult operatingData2(String timeStart,String timeEnd,String areaId)
{
logger.info("【运营数据】请求参数timeStart={},timeEnd={},areaId={}", timeStart,timeEnd,areaId);
OperatingDataVo2 operatingDataVo = etOrderService.getOperatingData(timeStart,timeEnd,areaId);
OperatingDataVo2 operatingDataVo = etOrderService.getOperatingData2(timeStart,timeEnd,areaId);
return success(operatingDataVo);
}
@ -1278,4 +1283,58 @@ public class AppVerifyController extends BaseController
return AjaxResult.success(aBoolean);
}
/**
* 优惠券购买
*/
@GetMapping("/coupon/buy")
public AjaxResult couponBuy(Long userId, Long couponId)
{
logger.info("优惠券购买【userId="+userId+"】,【couponId="+couponId+"");
Boolean result =etCouponService.couponBuy(userId, couponId);
return success(result);
}
/**
* 根据用户搜索优惠券
*/
@GetMapping("/getCouponListByUserId")
public AjaxResult list(Long userId)
{
logger.info("根据用户搜索优惠券【userId="+userId+"");
EtCouponClaimLog etCouponClaimLog = new EtCouponClaimLog();
etCouponClaimLog.setUserId(userId);
etCouponClaimLog.setStatus(ServiceConstants.COUPON_STATUS_UNUSED);
etCouponClaimLog.setStatusList(new String[]{ServiceConstants.COUPON_STATUS_UNUSED, ServiceConstants.COUPON_STATUS_EXPIRED});
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
return success(list);
}
/**
* 优惠券使用记录
*/
@GetMapping("/getCouponUsageRecord")
public AjaxResult getCouponUsageRecord(Long userId)
{
logger.info("优惠券使用记录【userId="+userId+"");
EtCouponClaimLog etCouponClaimLog = new EtCouponClaimLog();
etCouponClaimLog.setUserId(userId);
etCouponClaimLog.setStatus(ServiceConstants.COUPON_STATUS_USED);
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
return success(list);
}
/**
* 撤销审核
*/
@Log(title = "撤销审核", businessType = BusinessType.UPDATE)
@PostMapping("/cancelAudit")
public AjaxResult cancelAudit(@RequestBody EtOrder etOrder)
{
logger.info("撤销审核【etOrder="+etOrder+"");
EtOrder order = etOrderService.selectEtOrderByOrderNo(etOrder.getOrderNo());
if (Integer.parseInt(order.getStatus())<5){
throw new ServiceException("订单状态不对,不能撤销审核");
}
return toAjax(etOrderService.updateEtOrderByOrderNo(etOrder));
}
}

View File

@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CommonUtil;
import com.ruoyi.common.utils.DateUtils;
@ -23,7 +24,6 @@ import com.ruoyi.web.controller.iot.domain.LogEntry;
import com.ruoyi.web.controller.iot.util.Util;
import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import org.locationtech.jts.geom.Geometry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -75,9 +75,6 @@ public class ReceiveController {
@Autowired
private IEtOrderService etOrderService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@ -89,6 +86,9 @@ public class ReceiveController {
private final Object lock = new Object();
@Autowired
private RedisCache redisCache;
// 用于记录上次发送命令的时间
private static AtomicLong lastCommandTime = new AtomicLong(0);
private static final long COMMAND_COOLDOWN_MS = 5 * 60 * 1000; // 5分钟
@ -143,6 +143,14 @@ public class ReceiveController {
private void handleBody(BodyObj obj) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
if (obj != null){
boolean dataRight = Util.checkSignature(obj, token);
// elec_device_设备id_info:{ccccccc}
// 1. handleBody中的所有保存数据库的操作全部保存在redis中
// 2. 定时任务更新设备的在线状态, 5秒一次
// 3. 定时任务更新设备的定位和电压, 5秒一次
// 4. 定时任务插入onenet定位信息, 5秒一次
// 5. 获取最新的定位从redis中获取
if (dataRight){
log.info("receive方法验证签名正确: content" + JSON.toJSONString(obj));
String msg = (String) obj.getMsg();
@ -189,8 +197,8 @@ public class ReceiveController {
boolean noRidingArea = isNoRidingArea(value, device, area, isAdminUnlocking);
/** 3.超出运营区外断电*/
outAreaOutage(value, device, lon, lat, area, isAdminUnlocking, noRidingArea);
/** 4.优化线路和锁同步关锁 */
optimizeRouteAndLockSynchronization(msg, asDevice, logEntry, value, device, lon, lat);
/** 4.锁同步关锁 */
lockSynchronization(msg, asDevice, logEntry, value, device, lon, lat);
/** 5.低电量 生成换电工单*/
replacementOrder(device, area);
}
@ -296,15 +304,15 @@ public class ReceiveController {
private double[] coordinateConvert(LogEntry.LocationValue value) {
BigDecimal lon = new BigDecimal(value.getLon());
BigDecimal lat = new BigDecimal(value.getLat());
log.info("WGS84经纬度未计算" + lon + "---" + lat);
// log.info("WGS84经纬度未计算" + lon + "---" + lat);
// 除以100
lon = lon.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP);
lat = lat.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP);
log.info("WGS84经纬度除以100后" + lon + "---" + lat);
// log.info("WGS84经纬度除以100后" + lon + "---" + lat);
// 取出lon中后面的小数点
String[] lonStr = getDecimalPart(lon);
String[] latStr = getDecimalPart(lat);
log.info("WGS84经纬度截取小数点" + lonStr[0] + "---" + lonStr[1] + "---"+ latStr[0]+"---"+ latStr[1]);
// log.info("WGS84经纬度截取小数点" + lonStr[0] + "---" + lonStr[1] + "---"+ latStr[0]+"---"+ latStr[1]);
// 再将结果乘以5/3
String lon2 = "0."+ lonStr[1];
String lat2 = "0."+ latStr[1];
@ -312,10 +320,10 @@ public class ReceiveController {
BigDecimal lats = new BigDecimal(lat2).multiply(new BigDecimal(5).divide(new BigDecimal(3), 8, RoundingMode.HALF_UP));
BigDecimal lo = new BigDecimal(lonStr[0]).add(lons);
BigDecimal la = new BigDecimal(latStr[0]).add(lats);
log.info("WGS84经纬度计算后" + lo + "---" + la);
// log.info("WGS84经纬度计算后" + lo + "---" + la);
lo = lo.setScale(8, RoundingMode.HALF_UP);
la = la.setScale(8, RoundingMode.HALF_UP);
log.info("WGS84经纬度保留8为小数" + lo + "---" + la);
// log.info("WGS84经纬度保留8为小数" + lo + "---" + la);
double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(la.doubleValue(), lo.doubleValue());
return doubles;
}
@ -389,35 +397,29 @@ public class ReceiveController {
return noRidingArea;
}
private void optimizeRouteAndLockSynchronization(String msg, AsDevice asDevice, LogEntry logEntry, LogEntry.LocationValue value, AsDevice device, BigDecimal lon, BigDecimal lat) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
private void lockSynchronization(String msg, AsDevice asDevice, LogEntry logEntry, LogEntry.LocationValue value, AsDevice device, BigDecimal lon, BigDecimal lat) {
Integer status = value.getStatus();
if(status == 1){//上电运行
log.info("上电运行:" + logEntry.getDevName());
if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){
//获取当前正在骑行中的订单
EtOrder etOrder = etOrderService.getCurrentOrder(device.getSn());
if(ObjectUtil.isNotNull(etOrder)){
JSONArray jsonArray;
if(StrUtil.isNotBlank(etOrder.getTripRouteStr())){
jsonArray = JSON.parseArray(etOrder.getTripRouteStr());
}else{
jsonArray = new JSONArray();
}
JSONArray newPoint = new JSONArray();
newPoint.add(lon);
newPoint.add(lat);
// 优化轨迹如果获取到的定位与最后一个定位相同则不添加
optimizeRoute(jsonArray, newPoint, lon, lat,etOrder);
}else{
boolean currentOrderNum = etOrderService.isInOrderBySn(device.getSn());
if(!currentOrderNum){
long currentTime = System.currentTimeMillis();
long lastTime = lastCommandTime.get();// 上一次命令时间5分账内不再执行 车辆锁同步关锁 命令
long difference = System.currentTimeMillis() - logEntry.getAt();
log.info("当前时间戳:【"+System.currentTimeMillis()+"】,消息时间:【"+ logEntry.getAt()+"】,时间差:【"+difference+"");
if (difference < 60 * 1000 && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) {// 消息时间和当前时间时间差在1分钟内且锁状态为关闭则发送命令
if (currentTime - lastTime >= COMMAND_COOLDOWN_MS) {
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "车辆锁同步关锁", null, null, msg);
try {
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "车辆锁同步关锁", null, null, msg);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
}
}
}
@ -496,31 +498,27 @@ public class ReceiveController {
return false;
}
public void optimizeRoute(JSONArray jsonArray, JSONArray newPoint, BigDecimal lon, BigDecimal lat, EtOrder etOrder) {
if (isLastPointSame(jsonArray, lon, lat)) {
log.info("获取到的定位与最后一个定位相同,不添加线路");
} else {
jsonArray.add(newPoint);
String tripRouteStr = jsonArray.toJSONString();
// log.info("更新行程jsonArray" + tripRouteStr);
etOrder.setTripRouteStr(tripRouteStr);
Geometry geometry = GeoUtils.toGeometryByLinearRing(tripRouteStr);
String wkt = GeoUtils.wkt(geometry);
etOrder.setTripRoute(wkt);
// todo 放在还车的接口计算
// double[][] doubles = GeoUtils.parseJsonTrack(tripRouteStr);
// double v = GeoUtils.calculateTotalDistance(doubles);
// etOrder.setDistance((int)Math.round(v));
int updateEtOrderResult = etOrderService.updateEtOrder(etOrder);
if (updateEtOrderResult > 0) {
log.info("更新行程线路成功==========================>" + etOrder.getSn());
} else {
log.info("更新行程线路失败==========================>" + etOrder.getSn());
}
}
}
// public void optimizeRoute(JSONArray jsonArray, JSONArray newPoint, BigDecimal lon, BigDecimal lat, EtOrder etOrder) {
// if (isLastPointSame(jsonArray, lon, lat)) {
// log.info("获取到的定位与最后一个定位相同,不添加线路");
// } else {
// jsonArray.add(newPoint);
// String tripRouteStr = jsonArray.toJSONString();
//// log.info("更新行程jsonArray" + tripRouteStr);
// etOrder.setTripRouteStr(tripRouteStr);
//
// Geometry geometry = GeoUtils.toGeometryByLinearRing(tripRouteStr);
// String wkt = GeoUtils.wkt(geometry);
// etOrder.setTripRoute(wkt);
//
// int updateEtOrderResult = etOrderService.updateEtOrder(etOrder);
// if (updateEtOrderResult > 0) {
// log.info("更新行程线路成功==========================>" + etOrder.getSn());
// } else {
// log.info("更新行程线路失败==========================>" + etOrder.getSn());
// }
// }
// }
/**

View File

@ -66,7 +66,7 @@ public class EtCouponClaimLogController extends BaseController
@GetMapping(value = "/{claimId}")
public AjaxResult getInfo(@PathVariable("claimId") Long claimId)
{
return success(etCouponClaimLogService.selectEtCouponClaimLogByClaimId(claimId));
return success(etCouponClaimLogService.selectEtCouponClaimLogByLogId(claimId));
}
/**
@ -99,6 +99,6 @@ public class EtCouponClaimLogController extends BaseController
@DeleteMapping("/{claimIds}")
public AjaxResult remove(@PathVariable Long[] claimIds)
{
return toAjax(etCouponClaimLogService.deleteEtCouponClaimLogByClaimIds(claimIds));
return toAjax(etCouponClaimLogService.deleteEtCouponClaimLogByLogIds(claimIds));
}
}

View File

@ -20,6 +20,12 @@ public class ServiceConstants {
*/
public static final String ORDER_TYPE_DEPOSIT = "2";
/**
* 订单类型: 3-优惠券
*/
public static final String ORDER_TYPE_COUPON = "3";
/**----------------------------订单类型end----------------------------*/
/**
* 订单类型: 3-押金退款
*/
@ -50,6 +56,11 @@ public class ServiceConstants {
*/
public static final String ORDER_TYPE_MSG = "8";
/**
* 订单类型: 9-优惠券收入
*/
public static final String ORDER_TYPE_COUPON_INCOME = "9";
/**----------------------------订单类型end----------------------------*/
/**----------------------------支付场景start----------------------------*/
/** 支付场景: 1-骑行支付,2-取消预约支付,3-套餐支付,4-押金支付 */
@ -75,7 +86,7 @@ public class ServiceConstants {
/**----------------------------支付场景end----------------------------*/
/**----------------------------订单状态start----------------------------*/
/** 订单状态:0-预约中1-取消预约2-开始骑行3-结束 4-订单结束 5-待审核 6-车辆有损坏 */
/** 订单状态:0-预约中1-取消预约2-开始骑行3-结束 4-订单结束 5-待审核 6-车辆有损坏 7-待官方审核*/
/**
* 订单状态:0-预约中
*/
@ -607,6 +618,10 @@ public class ServiceConstants {
* 所属人类型:2-合伙人
*/
public static final String OWNER_TYPE_PARTNER = "2";
/**
* 所属人类型:3-app用户
*/
public static final String OWNER_TYPE_APP_USER = "3";
/**----------------------------所属人类型end----------------------------*/
/**----------------------------还车是否拍照审核start----------------------------*/
@ -669,4 +684,39 @@ public class ServiceConstants {
/**----------------------------提现手续费类型end----------------------------*/
/**----------------------------优惠券获取方式start----------------------------*/
/** 获取方式claim-领取buy-购买issue-下发 */
/**
* claim-领取
*/
public static final String COUPON_GAIN_METHOD_CLAIM = "claim";
/**
* buy-购买
*/
public static final String COUPON_GAIN_METHOD_BUY = "buy";
/**
* issue-下发
*/
public static final String COUPON_GAIN_METHOD_ISSUE = "issue";
/**----------------------------优惠券获取方式end----------------------------*/
/**----------------------------优惠券状态start----------------------------*/
/** 状态1-未使用2-已使用3-已过期
/**
* 1-未使用
*/
public static final String COUPON_STATUS_UNUSED = "1";
/**
* 2-已使用
*/
public static final String COUPON_STATUS_USED = "2";
/**
* 3-已过期
*/
public static final String COUPON_STATUS_EXPIRED = "3";
/**----------------------------优惠券状态end----------------------------*/
}

View File

@ -248,9 +248,9 @@ public class GeoUtils {
Coordinate[] coordinates = polygon.getCoordinates();
for (Coordinate coord : coordinates) {
double distance = calculateDistance(lat, lon, coord.y, coord.x);
log.info("距离----distance:{}",distance);
// log.info("距离----distance:{}",distance);
if (distance <= tolerance) {
log.info("最小距离----distance:{}",distance);
// log.info("最小距离----distance:{}",distance);
return true;
}
}
@ -274,9 +274,9 @@ public class GeoUtils {
Coordinate[] coordinates = polygon.getCoordinates();
for (Coordinate coord : coordinates) {
double distance = calculateDistance(lat, lon, coord.y, coord.x);
log.info("距离----distance:{}",distance);
// log.info("距离----distance:{}",distance);
if (shortenDistance >= distance) {
log.info("最小距离----distance:{}",distance);
// log.info("最小距离----distance:{}",distance);
return false;
}
}

View File

@ -51,11 +51,6 @@ public class EtCoupon extends BaseEntity
@Excel(name = "抵扣金额")
private BigDecimal discountAmount;
/** 有效时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "有效时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date expirationTime;
/** 状态 */
@Excel(name = "状态")
private String status;
@ -63,4 +58,20 @@ public class EtCoupon extends BaseEntity
/** 限制次数: 0无限制 */
@Excel(name = "限制次数:0无限制")
private String limitNum;
/** 描述 */
@Excel(name = "描述")
private String desc;
/** 零食价 */
@Excel(name = "零食价")
private BigDecimal snackPrice;
/** 有效期值 */
@Excel(name = "有效期值")
private Integer validityValue;
/** 有效期单位 */
@Excel(name = "有效期单位")
private String validityUnit;
}

View File

@ -1,11 +1,15 @@
package com.ruoyi.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* 优惠券领取记录对象 et_coupon_claim_log
* 优惠券领取记录对象 et_coupon_user_log
*
* @author qzz
* @date 2024-08-08
@ -15,8 +19,8 @@ public class EtCouponClaimLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 领取id */
private Long claimId;
/** 日志id */
private Long logId;
/** 区域 */
@Excel(name = "区域")
@ -38,6 +42,21 @@ public class EtCouponClaimLog extends BaseEntity
@Excel(name = "优惠券")
private Long couponId;
/** 获取方式claim-领取buy-购买issue-下发 */
@Excel(name = "获取方式claim-领取buy-购买issue-下发")
private String gainMethod;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 状态列表 */
@TableField(exist = false)
private String[] statusList;
/** 有效时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "有效时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date expirationTime;
}

View File

@ -26,4 +26,7 @@ public class LeaderboardVo {
/** 订单金额 */
private BigDecimal orderFee= BigDecimal.ZERO;
/** 进行中的订单 */
private Integer inProgressOrderCount=0;
}

View File

@ -32,6 +32,9 @@ public class OperatingDataVo2 {
//押金余额
private BigDecimal depositBalance;
//押金收入手续费
private BigDecimal depositHandlingCharge;
//账户盈余
private BigDecimal accountSurplus;
@ -47,6 +50,9 @@ public class OperatingDataVo2 {
//押金抵扣金额
private BigDecimal deductionAmount;
//主营业务成本
private BigDecimal businessCost;
//总支出

View File

@ -5,23 +5,23 @@ import com.ruoyi.system.domain.EtCouponClaimLog;
/**
* 优惠券领取记录Mapper接口
*
*
* @author qzz
* @date 2024-08-08
*/
public interface EtCouponClaimLogMapper
public interface EtCouponClaimLogMapper
{
/**
* 查询优惠券领取记录
*
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId);
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId);
/**
* 查询优惠券领取记录列表
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
@ -29,7 +29,7 @@ public interface EtCouponClaimLogMapper
/**
* 新增优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -37,7 +37,7 @@ public interface EtCouponClaimLogMapper
/**
* 修改优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -45,17 +45,17 @@ public interface EtCouponClaimLogMapper
/**
* 删除优惠券领取记录
*
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimId(Long claimId);
public int deleteEtCouponClaimLogByLogId(Long claimId);
/**
* 批量删除优惠券领取记录
*
*
* @param claimIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds);
public int deleteEtCouponClaimLogByLogIds(Long[] claimIds);
}

View File

@ -109,7 +109,7 @@ public interface EtOrderMapper
* @param sn 用户id
* @return 结果
*/
public List<EtOrder> isInOrderBySn(@Param("sn") String sn);
public int isInOrderBySn(@Param("sn") String sn);
/**
* 检验预约订单只能有一个
@ -302,4 +302,9 @@ public interface EtOrderMapper
// Integer getAppCount();
List<EtOrder> selectDeductionList(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr,@Param("areaId") Long areaId);
// /**
// * 判断当前是否有正在骑行中的订单
// */
// int getCurrentOrderNum(String sn);
}

View File

@ -63,6 +63,18 @@ public interface CallbackService {
*/
public int capitalFlowRecords2(EtOrder order, String type, String busType, String ownerType, SysDept sysDept);
/**
* 新增资金流水记录(app用户)
* @param order 订单
* @param type 类型
* @param busType 业务类型
* @param ownerType 所属人类型
* @param user 合伙人对象
* @param payType 支付方式
* @return void
*/
public int capitalFlowRecordsByAppUser(EtOrder order, String type, String busType, String ownerType, SysDept sysDept);
/**
* 分红处理
* @param transactionId 订单号

View File

@ -5,23 +5,23 @@ import com.ruoyi.system.domain.EtCouponClaimLog;
/**
* 优惠券领取记录Service接口
*
*
* @author qzz
* @date 2024-08-08
*/
public interface IEtCouponClaimLogService
public interface IEtCouponClaimLogService
{
/**
* 查询优惠券领取记录
*
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId);
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId);
/**
* 查询优惠券领取记录列表
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
@ -29,7 +29,7 @@ public interface IEtCouponClaimLogService
/**
* 新增优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -37,7 +37,7 @@ public interface IEtCouponClaimLogService
/**
* 修改优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -45,17 +45,17 @@ public interface IEtCouponClaimLogService
/**
* 批量删除优惠券领取记录
*
*
* @param claimIds 需要删除的优惠券领取记录主键集合
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds);
public int deleteEtCouponClaimLogByLogIds(Long[] claimIds);
/**
* 删除优惠券领取记录信息
*
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimId(Long claimId);
public int deleteEtCouponClaimLogByLogId(Long claimId);
}

View File

@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtCoupon;
/**
* 优惠券Service接口
*
*
* @author 邱贞招
* @date 2024-08-05
*/
public interface IEtCouponService
public interface IEtCouponService
{
/**
* 查询优惠券
*
*
* @param couponId 优惠券主键
* @return 优惠券
*/
@ -21,7 +21,7 @@ public interface IEtCouponService
/**
* 查询优惠券列表
*
*
* @param etCoupon 优惠券
* @return 优惠券集合
*/
@ -29,7 +29,7 @@ public interface IEtCouponService
/**
* 新增优惠券
*
*
* @param etCoupon 优惠券
* @return 结果
*/
@ -37,7 +37,7 @@ public interface IEtCouponService
/**
* 修改优惠券
*
*
* @param etCoupon 优惠券
* @return 结果
*/
@ -45,7 +45,7 @@ public interface IEtCouponService
/**
* 批量删除优惠券
*
*
* @param couponIds 需要删除的优惠券主键集合
* @return 结果
*/
@ -53,9 +53,17 @@ public interface IEtCouponService
/**
* 删除优惠券信息
*
*
* @param couponId 优惠券主键
* @return 结果
*/
public int deleteEtCouponByCouponId(Long couponId);
/**
* 优惠券购买
* @param userId
* @param couponId
* @return
*/
Boolean couponBuy(Long userId, Long couponId);
}

View File

@ -142,7 +142,12 @@ public interface IEtOrderService
/**
* 运营数据
*/
OperatingDataVo2 getOperatingData(String timeStart,String timeEnd,String areaId);
OperatingDataVo getOperatingData(String timeStart,String timeEnd,String areaId);
/**
* 运营数据
*/
OperatingDataVo2 getOperatingData2(String timeStart,String timeEnd,String areaId);
/**
* 收入对账
@ -180,6 +185,11 @@ public interface IEtOrderService
*/
EtOrder getCurrentOrder(String sn);
// /**
// * 判断当前是否有正在骑行中的订单
// */
// boolean getCurrentOrderNum(String sn);
/**
* 根据userId获取当前正在骑行中的订单
*/

View File

@ -26,7 +26,6 @@ import com.ruoyi.system.mapper.EtCommandLogMapper;
import com.ruoyi.system.mapper.EtLocationLogMapper;
import com.ruoyi.system.mapper.EtOrderMapper;
import com.ruoyi.system.service.*;
import com.wechat.pay.java.service.refund.model.Refund;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@ -834,6 +833,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
calculateAppointmentFee(order);
order.setTotalFee(order.getAppointmentFee());
order.setPayFee(order.getAppointmentFee());
log.info("【扫码/编号开锁骑行--】,更新订单信息,{}",JSON.toJSON(order));
int update = etOrderService.updateEtOrder(order);
if(update==0){
log.info("【扫码/编号开锁骑行】更新订单失败");
@ -1547,6 +1547,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
order.setAppointmentFee(fee);
order.setTotalFee(fee);
order.setPayFee(fee);
log.info("【车辆超时预约】,更新订单信息,{}",JSON.toJSON(order));
int update = etOrderService.updateEtOrder(order);
if(update==0){
throw new ServiceException("【车辆超时预约】:更新订单状态失败");
@ -1589,6 +1590,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
order.setTotalFee(order.getAppointmentFee());
order.setPayFee(order.getAppointmentFee());
order.setStatus(ServiceConstants.ORDER_STATUS_CANCEL_APPOINTMENT);
log.info("【取消预约】更新订单信息,{}",JSON.toJSON(order));
int i = etOrderService.updateEtOrder(order);
if(i==0){
throw new ServiceException("【取消预约】:更新订单失败");
@ -1763,6 +1765,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
// throw new ServiceException("拍照审核和押金点开不能同时开启");
// }
// }
log.info("【还车】,更新订单状态和还车时间,{}",JSON.toJSON(order));
int i = etOrderService.updateEtOrder(order);
if(i==0){
throw new ServiceException("更新订单状态失败");
@ -2274,11 +2277,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary());
isNoRiding = GeoUtils.isInCircle(longitude, latitude, geometry);
if(isNoRiding){
log.info("车辆【{}】在禁行区【{}】内",sn,etParkingArea.getParkingName());
// log.info("车辆【{}】在禁行区【{}】内",sn,etParkingArea.getParkingName());
isNoRiding = true;
break;
}else{
log.info("车辆【{}】不在禁行区【{}】内",sn,etParkingArea.getParkingName());
// log.info("车辆【{}】不在禁行区【{}】内",sn,etParkingArea.getParkingName());
}
}
}

View File

@ -958,6 +958,63 @@ public class CallbackServiceImpl implements CallbackService {
return i;
}
/**
* 资金流水记录
* */
@Override
public int capitalFlowRecordsByAppUser(EtOrder order,String type,String busType,String ownerType,SysDept sysDept) {
EtCapitalFlow capitalFlow = new EtCapitalFlow();
capitalFlow.setAreaId(order.getAreaId());
capitalFlow.setOrderNo(order.getOrderNo());
capitalFlow.setOutTradeNo(order.getOutTradeNo());
capitalFlow.setType(type);
capitalFlow.setBusType(busType);
capitalFlow.setOwnerType(ownerType);
capitalFlow.setOwnerId(sysDept.getDeptId());
capitalFlow.setOwner(sysDept.getDeptName());
String handlingChargeType = sysDept.getHandlingChargeType();
String handlingCharge1 = sysDept.getWithdrawHandlingCharge();
BigDecimal handlingCharge;
logger.info("【保存资金流水记录】 获取到配置手续费==============handlingCharge====================="+handlingCharge1);
if(handlingChargeType.equals(ServiceConstants.HANDLING_CHARGE_TYPE_PERCENT)){
BigDecimal bigDecimal = new BigDecimal(handlingCharge1).divide(new BigDecimal(1000), 6, BigDecimal.ROUND_HALF_UP);
logger.info("【保存资金流水记录】 按千分比--转换后手续费==============bigDecimal====================="+bigDecimal);
handlingCharge = bigDecimal.multiply(order.getPayFee()).setScale(2, BigDecimal.ROUND_HALF_UP);
logger.info("【保存资金流水记录】 按千分比--计算出的手续费==============handlingCharge====================="+handlingCharge);
}else{
handlingCharge = new BigDecimal(handlingCharge1);
logger.info("【保存资金流水记录】 按每笔--计算出的手续费==============handlingCharge====================="+handlingCharge);
}
BigDecimal serviceFeeScale = new BigDecimal(sysDept.getPlatformServiceFee()).divide(new BigDecimal(100), 6, BigDecimal.ROUND_HALF_UP);
BigDecimal platformServiceFee = serviceFeeScale.multiply(order.getPayFee());
logger.info("【保存资金流水记录】 计算出的平台服务费==============platformServiceFee====================="+platformServiceFee);
capitalFlow.setPlatformServiceFee(platformServiceFee);
capitalFlow.setHandlingCharge(handlingCharge);//手续费
capitalFlow.setAmount(order.getPayFee().subtract(handlingCharge));
BigDecimal separateAccountFee = order.getPayFee();
capitalFlow.setPartnerDividend(BigDecimal.ZERO);
capitalFlow.setPlatformServiceFee(BigDecimal.ZERO);
if(type.equals(ServiceConstants.FLOW_TYPE_INCOME)){
capitalFlow.setStatus(ServiceConstants.FLOW_STATUS_REJECT);
capitalFlow.setOperatorDividend(separateAccountFee);
capitalFlow.setOperatorBalance(sysDept.getBalance().add(separateAccountFee));
deptService.changeDeptBalance(separateAccountFee,sysDept.getDeptId());
logger.info("【保存资金流水记录】 ==============收入=====================");
}else{
capitalFlow.setStatus(ServiceConstants.FLOW_STATUS_APPLY);
capitalFlow.setOperatorDividend(separateAccountFee.negate());
capitalFlow.setOperatorBalance(sysDept.getBalance().subtract(separateAccountFee));
deptService.changeDeptBalance(separateAccountFee.negate(),sysDept.getDeptId());
logger.info("【保存资金流水记录】 ==============支出=====================");
}
capitalFlow.setPayType(ServiceConstants.PAY_TYPE_WX);
capitalFlow.setCreateTime(DateUtils.getNowDate());
logger.info("【保存资金流水】保存资金流水记录对象 : " + JSON.toJSONString(capitalFlow));
int i = etCapitalFlowService.insertEtCapitalFlow(capitalFlow);
return i;
}
/**
* 微信退款回调
*/

View File

@ -10,31 +10,31 @@ import com.ruoyi.system.service.IEtCouponClaimLogService;
/**
* 优惠券领取记录Service业务层处理
*
*
* @author qzz
* @date 2024-08-08
*/
@Service
public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
{
@Autowired
private EtCouponClaimLogMapper etCouponClaimLogMapper;
/**
* 查询优惠券领取记录
*
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
@Override
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId)
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId)
{
return etCouponClaimLogMapper.selectEtCouponClaimLogByClaimId(claimId);
return etCouponClaimLogMapper.selectEtCouponClaimLogByLogId(claimId);
}
/**
* 查询优惠券领取记录列表
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录
*/
@ -46,7 +46,7 @@ public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
/**
* 新增优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -59,7 +59,7 @@ public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
/**
* 修改优惠券领取记录
*
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@ -71,25 +71,25 @@ public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
/**
* 批量删除优惠券领取记录
*
*
* @param claimIds 需要删除的优惠券领取记录主键
* @return 结果
*/
@Override
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds)
public int deleteEtCouponClaimLogByLogIds(Long[] claimIds)
{
return etCouponClaimLogMapper.deleteEtCouponClaimLogByClaimIds(claimIds);
return etCouponClaimLogMapper.deleteEtCouponClaimLogByLogIds(claimIds);
}
/**
* 删除优惠券领取记录信息
*
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
@Override
public int deleteEtCouponClaimLogByClaimId(Long claimId)
public int deleteEtCouponClaimLogByLogId(Long claimId)
{
return etCouponClaimLogMapper.deleteEtCouponClaimLogByClaimId(claimId);
return etCouponClaimLogMapper.deleteEtCouponClaimLogByLogId(claimId);
}
}

View File

@ -1,28 +1,53 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.AsUserMapper;
import com.ruoyi.system.mapper.EtCouponClaimLogMapper;
import com.ruoyi.system.mapper.EtOrderMapper;
import com.ruoyi.system.service.CallbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EtCouponMapper;
import com.ruoyi.system.domain.EtCoupon;
import com.ruoyi.system.service.IEtCouponService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* 优惠券Service业务层处理
*
*
* @author 邱贞招
* @date 2024-08-05
*/
@Service
public class EtCouponServiceImpl implements IEtCouponService
public class EtCouponServiceImpl implements IEtCouponService
{
@Autowired
@Resource
private EtCouponMapper etCouponMapper;
@Resource
private EtCouponClaimLogMapper etCouponClaimLogMapper;
@Resource
private AsUserMapper userMapper;
@Resource
private EtOrderMapper etOrderMapper;
@Autowired
private CallbackService callbackService;
/**
* 查询优惠券
*
*
* @param couponId 优惠券主键
* @return 优惠券
*/
@ -34,7 +59,7 @@ public class EtCouponServiceImpl implements IEtCouponService
/**
* 查询优惠券列表
*
*
* @param etCoupon 优惠券
* @return 优惠券
*/
@ -46,7 +71,7 @@ public class EtCouponServiceImpl implements IEtCouponService
/**
* 新增优惠券
*
*
* @param etCoupon 优惠券
* @return 结果
*/
@ -59,7 +84,7 @@ public class EtCouponServiceImpl implements IEtCouponService
/**
* 修改优惠券
*
*
* @param etCoupon 优惠券
* @return 结果
*/
@ -71,7 +96,7 @@ public class EtCouponServiceImpl implements IEtCouponService
/**
* 批量删除优惠券
*
*
* @param couponIds 需要删除的优惠券主键
* @return 结果
*/
@ -83,7 +108,7 @@ public class EtCouponServiceImpl implements IEtCouponService
/**
* 删除优惠券信息
*
*
* @param couponId 优惠券主键
* @return 结果
*/
@ -92,4 +117,66 @@ public class EtCouponServiceImpl implements IEtCouponService
{
return etCouponMapper.deleteEtCouponByCouponId(couponId);
}
/**
* 优惠券购买
* @param userId
* @param couponId
* @return
*/
@Override
@Transactional
public Boolean couponBuy(Long userId, Long couponId) {
/**
* 购买分为抵用券订单会员卡订单折扣卡订单
* 1. 插入一条记录et_coupon_user_log 获取方式是购买
* 2. 增加订单记录类型是优惠券订单
* 3. 增加账变, 所属人为运营商
* */
// 1. 插入一条记录et_coupon_user_log 获取方式是购买
AsUser asUser = userMapper.selectUserById(userId);
EtCoupon etCoupon = etCouponMapper.selectEtCouponByCouponId(couponId);
EtCouponClaimLog etCouponClaimLog = new EtCouponClaimLog();
etCouponClaimLog.setCouponId(couponId);
etCouponClaimLog.setUserId(userId);
etCouponClaimLog.setUserName(asUser.getUserName());
etCouponClaimLog.setCreateTime(DateUtils.getNowDate());
etCouponClaimLog.setGainMethod(ServiceConstants.COUPON_GAIN_METHOD_BUY);
etCouponClaimLog.setAreaId(etCoupon.getAreaId());
etCouponClaimLog.setAreaName(etCoupon.getAreaName());
int i1 = etCouponClaimLogMapper.insertEtCouponClaimLog(etCouponClaimLog);
if(i1 == 0){
throw new ServiceException("保存优惠券领取记录失败");
}
// 2. 增加订单记录类型是优惠券订单
EtOrder order = createOrder(etCoupon, asUser);
if(ObjectUtil.isNotNull(order)){
int i = etOrderMapper.insertEtOrder(order);
if(i > 0){
// 账变是针对账户而言的优惠券充值后的入账是进入到那个账户 有效期 季度 quarter
callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,
ServiceConstants.ORDER_TYPE_COUPON_INCOME,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_WX);
return true;
}
}
return false;
}
private EtOrder createOrder(EtCoupon etCoupon,AsUser user) {
EtOrder etOrder = new EtOrder();
etOrder.setOrderNo(IdUtils.getOrderNo("wx"));
etOrder.setUserId(user.getUserId());
etOrder.setUserName(user.getUserName());
etOrder.setMark("优惠券购买");
etOrder.setCreateTime(DateUtils.getNowDate());
etOrder.setAreaId(etCoupon.getAreaId());
/** 订单类型 1骑行 2预约 3套餐 4押金 根据类型不同下单的参数也不同,不同的参数有: 金额、类型、rule_id套餐id*/
etOrder.setArea(etCoupon.getAreaName());
etOrder.setType(ServiceConstants.ORDER_TYPE_COUPON);
etOrder.setTotalFee(etCoupon.getSnackPrice());
etOrder.setPayFee(etCoupon.getSnackPrice());
return etOrder;
}
}

View File

@ -360,6 +360,22 @@ public class EtOrderServiceImpl implements IEtOrderService
return null;
}
// /**
// * 获取当前正在骑行中的订单数量
// * @param sn
// * @return
// */
// @Override
// public boolean getCurrentOrderNum(String sn) {
// if(ObjectUtil.isNotNull(asDeviceMapper.selectAsDeviceBySn(sn))){
// int currentOrderNum = etOrderMapper.getCurrentOrderNum(sn);
// if(currentOrderNum > 0){
// return true;
// }
// }
// return false;
// }
/**
* 根据userId获取当前正在骑行中的订单
* @param userId
@ -847,6 +863,8 @@ public class EtOrderServiceImpl implements IEtOrderService
LeaderboardVo leaderboardVo = new LeaderboardVo();
leaderboardVo.setOrderCount(etOrderMapper.getOrderNum(startDateStr, endDateStr, areaId));//订单数
leaderboardVo.setOrderFee(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId));//订单金额
String inOrderCount = etOrderMapper.getRidingOrder(startDateStr, endDateStr,areaId+"");
leaderboardVo.setInProgressOrderCount(Integer.parseInt(inOrderCount));
leaderboardVo.setAreaId(areaId);
leaderboardVo.setAreaName(area.getAreaName());
leaderboardVos.add(leaderboardVo);
@ -859,7 +877,7 @@ public class EtOrderServiceImpl implements IEtOrderService
return o2.getOrderCount().compareTo(o1.getOrderCount());
}
});
}else{// 2-根据订单金额排序
}else if("2".equals(type)){// 2-根据订单金额排序
Collections.sort(leaderboardVos, new Comparator<LeaderboardVo>() {
@Override
public int compare(LeaderboardVo o1, LeaderboardVo o2) {
@ -867,6 +885,20 @@ public class EtOrderServiceImpl implements IEtOrderService
return o2.getOrderFee().compareTo(o1.getOrderFee());
}
});
}else if("3".equals(type)){// 3-进行中的订单排序
Collections.sort(leaderboardVos, new Comparator<LeaderboardVo>() {
@Override
public int compare(LeaderboardVo o1, LeaderboardVo o2) {
// 降序排列订单金额最多的排在最前面
return o2.getInProgressOrderCount().compareTo(o1.getInProgressOrderCount());
}
});
}else{
throw new RuntimeException("type参数错误");
}
// 保留前20个元素
if (leaderboardVos.size() > 20) {
leaderboardVos = new ArrayList<>(leaderboardVos.subList(0, 20));
}
return leaderboardVos;
}
@ -1148,11 +1180,76 @@ public class EtOrderServiceImpl implements IEtOrderService
return i>0;
}
/**
* 运营数据
*/
@Override
public OperatingDataVo2 getOperatingData(String timeStart,String timeEnd,String areaId) {
public OperatingDataVo getOperatingData(String timeStart,String timeEnd,String areaId) {
OperatingDataVo operatingDataVo = new OperatingDataVo();
if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){
/*收入相关*/
OperatingDataVo.Income income = new OperatingDataVo.Income();
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 * 已支付金额
SysDept sysDept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId));
String handlingCharge = sysDept.getHandlingCharge();
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));//调度费已支付
income.setTotalDispatchRefund(etOrderMapper.getTotalDispatchRefund(timeStart,timeEnd,areaId));//调度费已退款
income.setTotalAppointmentFee(etOrderMapper.getTotalAppointmentFee(timeStart,timeEnd,areaId));//预约费已支付
income.setTotalAppointmentRefund(etOrderMapper.getTotalAppointmentRefund(timeStart,timeEnd,areaId));//预约费已退款
income.setTotalManageFee(etOrderMapper.getTotalManageFee(timeStart,timeEnd,areaId));//停车点外调度费已支付
income.setTotalManageRefund(etOrderMapper.getTotalManageRefund(timeStart,timeEnd,areaId));//停车点外调度费已退款
operatingDataVo.setIncome(income);
/*订单相关*/
OperatingDataVo.OrderVo orderVo = new OperatingDataVo.OrderVo();
orderVo.setPaidOrder(etOrderMapper.getPaidOrder(timeStart,timeEnd,areaId));//已支付订单
orderVo.setRidingOrder(etOrderMapper.getRidingOrder(timeStart,timeEnd,areaId));//骑行中订单
orderVo.setRefundOrder(etOrderMapper.getRefundOrder(timeStart,timeEnd,areaId));//退款订单
orderVo.setUnpaidOrder(etOrderMapper.getUnpaidOrder(timeStart,timeEnd,areaId));//待支付订单
operatingDataVo.setOrder(orderVo);
/*设备相关*/
OperatingDataVo.DeviceVo deviceVo = new OperatingDataVo.DeviceVo();
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(areaId));//总用户
userVo.setNewUser(asUserService.getNewUser(timeStart,timeEnd,areaId));//新增用户
userVo.setLeaseUser(asUserService.getLeaseUser(timeStart,timeEnd,areaId));//租赁用户
operatingDataVo.setUser(userVo);
return operatingDataVo;
}else{
throw new ServiceException("请选择时间");
}
}
/**
* 运营数据
*/
@Override
public OperatingDataVo2 getOperatingData2(String timeStart,String timeEnd,String areaId) {
long aLong = Long.parseLong(areaId);
OperatingDataVo2 operatingDataVo = new OperatingDataVo2();
if(StrUtil.isNotBlank(timeStart) && StrUtil.isNotBlank(timeEnd)){
@ -1165,7 +1262,7 @@ public class EtOrderServiceImpl implements IEtOrderService
BigDecimal totalFlowAmount = totalAmount.add(depositAmount).add(deductionAmount);// 总流水
income.setTotalFlowAmount(totalFlowAmount);
income.setDeductionAmount(deductionAmount);
income.setOrderPaid(totalAmount.add(deductionAmount));//订单支付
income.setOrderPaid(totalAmount.add(deductionAmount).add(deductionAmount));//订单支付
income.setDepositPaid(depositAmount);
/** 总支出*/
@ -1185,8 +1282,13 @@ public class EtOrderServiceImpl implements IEtOrderService
BigDecimal depositBalance = depositAmount.subtract(depositRefundFee).subtract(deductionAmount);
income.setOperatingIncome(totalFlowAmount.subtract(totalExpenditure).subtract(depositBalance));
income.setOperatingIncome2(totalAmount.add(deductionAmount).subtract(refundFee).subtract(serviceFee).subtract(platformServiceFee).add(deductionAmount));
income.setDepositBalance(depositBalance);// 押金余额
income.setAccountSurplus(totalFlowAmount.subtract(totalExpenditure));// 账户盈余=总流水-总支出 = 营业收入+押金余额
BigDecimal depositHandlingCharge = depositBalance.multiply(new BigDecimal(0.0054));// 押金手续费
depositHandlingCharge = depositHandlingCharge.setScale(2, RoundingMode.HALF_UP);
income.setDepositBalance(depositBalance.subtract(depositHandlingCharge));// 押金余额
income.setDepositHandlingCharge(depositHandlingCharge);// 押金手续费
income.setAccountSurplus(depositBalance.add(totalFlowAmount.subtract(totalExpenditure).subtract(depositBalance)).subtract(depositHandlingCharge));// 账户盈余=总流水-总支出 = 营业收入+押金余额 depositBalance+operatingIncome
BigDecimal businessCost = defaultIfNull(refundFee.add(serviceFee).add(platformServiceFee), BigDecimal.ZERO);//主营业务成本
income.setBusinessCost(businessCost);
/*订单相关*/
OperatingDataVo2.OrderVo orderVo = new OperatingDataVo2.OrderVo();
@ -1647,8 +1749,8 @@ public class EtOrderServiceImpl implements IEtOrderService
*/
@Override
public Boolean isInOrderBySn(String sn) {
List<EtOrder> inOrder = etOrderMapper.isInOrderBySn(sn);
return inOrder.size() > 0;
int inOrder = etOrderMapper.isInOrderBySn(sn);
return inOrder > 0;
}
/**

View File

@ -5,78 +5,101 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.system.mapper.EtCouponClaimLogMapper">
<resultMap type="EtCouponClaimLog" id="EtCouponClaimLogResult">
<result property="claimId" column="claim_id" />
<result property="logId" column="log_id" />
<result property="areaId" column="area_id" />
<result property="userId" column="user_id" />
<result property="couponId" column="coupon_id" />
<result property="createTime" column="create_time" />
<result property="gainMethod" column="gain_method" />
<result property="status" column="status" />
<result property="expirationTime" column="expiration_time" />
</resultMap>
<sql id="selectEtCouponClaimLogVo">
select claim_id, area_id, user_id, coupon_id, create_time from et_coupon_claim_log
select log_id, area_id, user_id, coupon_id, create_time, gain_method, status, expiration_time from et_coupon_user_log
</sql>
<select id="selectEtCouponClaimLogList" parameterType="EtCouponClaimLog" resultMap="EtCouponClaimLogResult">
select
l.claim_id,
l.log_id,
l.area_id,
a.area_name areaName,
l.user_id,
l.`status`,
u.user_name userName,
l.coupon_id,
l.create_time
from et_coupon_claim_log l
l.create_time,
l.gain_method,
l.expiration_time
from et_coupon_user_log l
left join et_operating_area a on a.area_id = l.area_id
left join et_user u on u.user_id = l.user_id
<where>
<if test="areaId != null "> and l.area_id like concat('%', #{areaId}, '%')</if>
<if test="areaName != null "> and a.area_name like concat('%', #{areaName}, '%')</if>
<if test="userId != null "> and l.user_id like concat('%', #{userId}, '%')</if>
<if test="userId != null "> and l.user_id = #{userId}</if>
<if test="userName != null "> and u.user_name = #{userName}</if>
<if test="gainMethod != null "> and u.gain_method = #{gainMethod}</if>
<if test="status != null and status != ''"> and l.status = #{status}</if>
<if test="couponId != null "> and l.coupon_id like concat('%', #{couponId}, '%')</if>
<if test="statusList != null">
AND o.status IN
<foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectEtCouponClaimLogByClaimId" parameterType="Long" resultMap="EtCouponClaimLogResult">
<select id="selectEtCouponClaimLogByLogId" parameterType="Long" resultMap="EtCouponClaimLogResult">
<include refid="selectEtCouponClaimLogVo"/>
where claim_id = #{claimId}
where log_id = #{logId}
</select>
<insert id="insertEtCouponClaimLog" parameterType="EtCouponClaimLog" useGeneratedKeys="true" keyProperty="claimId">
insert into et_coupon_claim_log
<insert id="insertEtCouponClaimLog" parameterType="EtCouponClaimLog" useGeneratedKeys="true" keyProperty="logId">
insert into et_coupon_user_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">area_id,</if>
<if test="userId != null">user_id,</if>
<if test="couponId != null">coupon_id,</if>
<if test="createTime != null">create_time,</if>
<if test="gainMethod != null">gain_method,</if>
<if test="status != null">status,</if>
<if test="expirationTime != null">expiration_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaId != null">#{areaId},</if>
<if test="userId != null">#{userId},</if>
<if test="couponId != null">#{couponId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="gainMethod != null">#{gainMethod},</if>
<if test="status != null">#{status},</if>
<if test="expirationTime != null">#{expirationTime},</if>
</trim>
</insert>
<update id="updateEtCouponClaimLog" parameterType="EtCouponClaimLog">
update et_coupon_claim_log
update et_coupon_user_log
<trim prefix="SET" suffixOverrides=",">
<if test="areaId != null">area_id = #{areaId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="gainMethod != null">gain_method = #{gainMethod},</if>
<if test="status != null">status = #{status},</if>
<if test="expirationTime != null">expiration_time = #{expirationTime},</if>
</trim>
where claim_id = #{claimId}
where log_id = #{logId}
</update>
<delete id="deleteEtCouponClaimLogByClaimId" parameterType="Long">
delete from et_coupon_claim_log where claim_id = #{claimId}
<delete id="deleteEtCouponClaimLogByLogId" parameterType="Long">
delete from et_coupon_user_log where log_id = #{logId}
</delete>
<delete id="deleteEtCouponClaimLogByClaimIds" parameterType="String">
delete from et_coupon_claim_log where claim_id in
<foreach item="claimId" collection="array" open="(" separator="," close=")">
#{claimId}
<delete id="deleteEtCouponClaimLogByLogIds" parameterType="String">
delete from et_coupon_user_log where log_id in
<foreach item="logId" collection="array" open="(" separator="," close=")">
#{logId}
</foreach>
</delete>
</mapper>

View File

@ -12,13 +12,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userId" column="user_id" />
<result property="discountAmount" column="discount_amount" />
<result property="createTime" column="create_time" />
<result property="expirationTime" column="expiration_time" />
<result property="validityValue" column="validity_value" />
<result property="validityUnit" column="validity_unit" />
<result property="status" column="status" />
<result property="limitNum" column="limit_num" />
<result property="desc" column="desc" />
<result property="snackPrice" column="snack_price" />
</resultMap>
<sql id="selectEtCouponVo">
select coupon_id, type, discount_percent, area_id, user_id, discount_amount, create_time, expiration_time, status, limit_num from et_coupon
select coupon_id, type, discount_percent, area_id, user_id, discount_amount, create_time, validity_value, validity_unit, status, limit_num, `desc`, snack_price from et_coupon
</sql>
<select id="selectEtCouponList" parameterType="EtCoupon" resultMap="EtCouponResult">
@ -32,9 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.user_name userName,
c.discount_amount,
c.create_time,
c.expiration_time,
c.STATUS,
c.limit_num
c.validity_value,
c.validity_unit,
c.status,
c.limit_num,
c.desc,
c.snack_price
FROM
et_coupon c
left join et_operating_area a on a.area_id = c.area_id
@ -47,7 +53,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null "> and c.user_id = like concat('%', #{userId}, '%')</if>
<if test="userName != null "> and u.user_name = #{userName}</if>
<if test="discountAmount != null "> and c.discount_amount = #{discountAmount}</if>
<if test="expirationTime != null "> and c.expiration_time = #{expirationTime}</if>
<if test="status != null and status != ''"> and c.status = #{status}</if>
<if test="limitNum != null and limitNum != ''"> and c.limit_num = #{limitNum}</if>
</where>
@ -67,9 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null">user_id,</if>
<if test="discountAmount != null">discount_amount,</if>
<if test="createTime != null">create_time,</if>
<if test="expirationTime != null">expiration_time,</if>
<if test="validityValue != null">validity_value,</if>
<if test="validityUnit != null">validity_unit,</if>
<if test="status != null">status,</if>
<if test="limitNum != null">limit_num,</if>
<if test="desc != null">desc,</if>
<if test="snackPrice != null">snack_price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">#{type},</if>
@ -78,9 +86,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null">#{userId},</if>
<if test="discountAmount != null">#{discountAmount},</if>
<if test="createTime != null">#{createTime},</if>
<if test="expirationTime != null">#{expirationTime},</if>
<if test="validityValue != null">#{validityValue},</if>
<if test="validityUnit != null">#{validityUnit},</if>
<if test="status != null">#{status},</if>
<if test="limitNum != null">#{limitNum},</if>
<if test="desc != null">#{desc},</if>
<if test="snackPrice != null">#{snackPrice},</if>
</trim>
</insert>
@ -93,9 +104,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userId != null">user_id = #{userId},</if>
<if test="discountAmount != null">discount_amount = #{discountAmount},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="expirationTime != null">expiration_time = #{expirationTime},</if>
<if test="validityValue != null">validity_value = #{validityValue},</if>
<if test="validityUnit != null">validity_unit = #{validityUnit},</if>
<if test="status != null">status = #{status},</if>
<if test="limitNum != null">limit_num = #{limitNum},</if>
<if test="desc != null">desc = #{desc},</if>
<if test="snackPrice != null">snack_price = #{snackPrice},</if>
</trim>
where coupon_id = #{couponId}
</update>

View File

@ -37,10 +37,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="mac != null and mac != ''"> and mac = #{mac}</if>
<if test="startTime != null and startTime != ''">
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
AND date_format(create_time,'%Y%m%d%H%i%s') &gt;= date_format(#{startTime},'%Y%m%d%H%i%s')
</if>
<if test="endTime != null and endTime != ''">
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
AND date_format(create_time,'%Y%m%d%H%i%s') &lt;= date_format(#{endTime},'%Y%m%d%H%i%s')
</if>
</where>
</select>

View File

@ -57,6 +57,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
rule_end_time, return_type, AsText(trip_route) trip_route,trip_route_str,cycle,deposit_deduction,video_url,upload_time,deduction_amount,audio_files,used_sn,change_reason,locking from et_order
</sql>
<sql id="selectEtOrderVoNoRoute">
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, cycle,deposit_deduction,video_url,upload_time,deduction_amount,audio_files,used_sn,change_reason,locking from et_order
</sql>
<select id="selectEtOrderList" parameterType="EtOrder" resultMap="EtOrderResult">
SELECT
o.order_id,
@ -220,8 +228,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="isInOrderBySn" resultMap="EtOrderResult" parameterType="String">
<include refid="selectEtOrderVo"/>
<select id="isInOrderBySn" resultType="Integer" parameterType="String">
select count(1) from et_order
where sn = #{sn} and status =2 and type = 1
</select>
@ -601,11 +609,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 1
</select>
<select id="selectAppointmentUnfinished" resultType="com.ruoyi.system.domain.EtOrder">
select * from et_order where appointment_start_time is not null and appointment_start_time != '' AND appointment_end_time IS NULL
<include refid="selectEtOrderVoNoRoute"/>
where appointment_start_time is not null and appointment_start_time != '' AND appointment_end_time IS NULL
</select>
<select id="selectUnrefundableDepositOrder" resultMap="EtOrderResult">
select * from et_order o
select o.order_id,
o.area_id,
o.order_no,
o.out_trade_no,
o.user_id,
o.rule_id,
o.device_mac,
o.sn,
o.pay_time,
o.paid,
o.pay_type,
o.type,
o.total_fee,
o.pay_fee,
o.dispatch_fee,
o.manage_fee,
o.riding_fee,
o.appointment_fee,
o.mark,
o.duration,
o.distance,
o.status,
o.create_time,
o.appointment_start_time,
o.appointment_end_time,
o.appointment_timeout,
o.unlock_time,return_time,
o.rule_end_time,
o.return_type,
o.cycle,
o.deposit_deduction,
o.video_url,
o.upload_time,
o.deduction_amount,
o.audio_files,
o.used_sn,
o.change_reason,
o.locking from et_order o
left JOIN et_refund r on r.order_no = o.order_no
where o.status ='4' and o.paid = '1' and o.type = 2 and r.refund_result IS NULL
</select>
@ -819,5 +865,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from et_order where order_no = #{orderNo}
</delete>
<!-- <select id="getCurrentOrderNum" resultType="java.lang.Integer">-->
<!-- select count(1) from et_order where sn = #{sn} and status = 2-->
<!-- </select>-->
</mapper>