Compare commits

...

4 Commits

Author SHA1 Message Date
aa7821bfa9 1. 优惠券 2024-08-09 22:18:23 +08:00
e335afc9a3 Merge branch 'coupon' 2024-08-08 23:06:40 +08:00
e782f4183d 1. 优惠券 2024-08-08 23:06:11 +08:00
6386b46b36 1. 优惠券 2024-08-05 22:23:21 +08:00
29 changed files with 1368 additions and 201 deletions

View File

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

View File

@ -203,20 +203,19 @@ public class AppController extends BaseController
}
// /**
// * 根据定位获取运营区信息并返回所有车辆定位
// */
// @GetMapping(value = "/vehicleLocalization")
// public AjaxResult vehicleLocalization(String longitude,String latitude)
// {
// if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
// logger.info("没有经纬度参数【longitude={}】【latitude={}】",longitude,latitude);
// return error("请传经纬度参数"+"【longitude="+longitude+"【latitude="+latitude+"");
// }
//// webSocket.SendMessage("需要发送的消息", "识别唯一session");
// List<AsDevice> asDevices = asDeviceService.vehicleLocalization(longitude,latitude);
// return success(asDevices);
// }
/**
* 根据经纬度查询附近500米的所有车辆
*/
@GetMapping(value = "/vehicleLocalization")
public AjaxResult vehicleLocalization(String longitude,String latitude,String deptId)
{
if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
logger.info("没有经纬度参数【longitude={}】【latitude={}】",longitude,latitude);
return error("请传经纬度参数"+"【longitude="+longitude+"【latitude="+latitude+"");
}
List<AsDevice> asDevices = asDeviceService.vehicleLocalization(longitude,latitude,deptId);
return success(asDevices);
}
/**
* 根据运营区id获取所有车辆

View File

@ -24,9 +24,7 @@ import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.response.FaultResponse;
import com.ruoyi.system.domain.response.OrderResponse;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.mapper.AsDeviceMapper;
import com.ruoyi.system.mapper.AsUserMapper;
import com.ruoyi.system.mapper.EtOrderMapper;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.*;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import org.jetbrains.annotations.NotNull;
@ -36,10 +34,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* app接口需要登录校验的
@ -104,6 +100,13 @@ public class AppVerifyController extends BaseController
@Autowired
private IWxPayService wxPayService;
@Resource
private EtCapitalFlowMapper etCapitalFlowMapper;
@Resource
private EtOperatingAreaMapper etOperatingAreaMapper;
/**
* 故障上报
@ -339,6 +342,10 @@ public class AppVerifyController extends BaseController
if(inOrder.size()>0){
throw new ServiceException("提现失败,用户还有未完成订单");
}
List<EtOrder> inAuditOrder = etOrderService.isInAuditOrder(etOrder.getUserId(), null);
if(inAuditOrder.size()>0){
throw new ServiceException("提现失败,用户还有未审核完成的订单");
}
if(etOrders.size()>1){
logger.info("有多条status="+ServiceConstants.ORDER_STATUS_ORDER_END+"(已完成),paid="+ServiceConstants.ORDER_PAY_STATUS_PAID+"(已支付)的押金订单");
logger.info("获取最后一条押金充值记录");
@ -890,9 +897,43 @@ public class AppVerifyController extends BaseController
{
logger.info("【获取运营商信息】获取到areaId【{}】", areaId);
SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId);
BigDecimal todayOrderAmount = getTodayOrderAmount(sysDept);
// 更新 sysDept 的余额字段
if (sysDept.getBalance() != null) {
sysDept.setBalance(sysDept.getBalance().subtract(todayOrderAmount));
}
return success(sysDept);
}
/** 获取今日订单金额 */
@NotNull
private BigDecimal getTodayOrderAmount(SysDept sysDept) {
// 获取今天的日期字符串
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startDateStr = dateFormat.format(new Date()) + " 00:00:00";
String endDateStr = dateFormat.format(new Date()) + " 23:59:59";
//今日订单金额
BigDecimal todayOrderAmount = BigDecimal.ZERO;
List<Long> longs = etOperatingAreaMapper.selectAreaListByDeptId(sysDept.getDeptId());
for (Long id:longs) {
BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, id), BigDecimal.ZERO);//新增
BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, id), BigDecimal.ZERO);//退款
BigDecimal serviceFee = etCapitalFlowMapper.getHandlingFee(startDateStr, endDateStr, null, id);//手续费,扣除掉退款部分的
BigDecimal platformServiceFee = etCapitalFlowMapper.getServiceFee(startDateStr, endDateStr, null,id);//平台服务费 ,扣除掉退款部分的
BigDecimal areaOrderAmount = defaultIfNull(payFee.subtract(serviceFee).subtract(refundFee).subtract(platformServiceFee), BigDecimal.ZERO);//营收 = 新增 - 手续费 - 退款 - 平台服务费
if (areaOrderAmount != null) {
todayOrderAmount = todayOrderAmount.add(areaOrderAmount);
}
}
return todayOrderAmount;
}
private BigDecimal defaultIfNull(BigDecimal value, BigDecimal defaultValue) {
return value != null ? value : defaultValue;
}
/**
* 绑定APP用户
*/
@ -965,6 +1006,9 @@ public class AppVerifyController extends BaseController
{
logger.info("还车审核通过请求:【{}】", orderNo);
EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo);
if(!order.getStatus().equals(ServiceConstants.ORDER_STATUS_TO_BE_AUDIT)){
throw new ServiceException("该订单用户未支付!");
}
if(ObjectUtil.isNotNull(order)){
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
return toAjax(etOrderService.passAudit(order));

View File

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

View File

@ -0,0 +1,104 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EtCouponClaimLog;
import com.ruoyi.system.service.IEtCouponClaimLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 优惠券领取记录Controller
*
* @author qzz
* @date 2024-08-08
*/
@RestController
@RequestMapping("/system/claimLog")
public class EtCouponClaimLogController extends BaseController
{
@Autowired
private IEtCouponClaimLogService etCouponClaimLogService;
/**
* 查询优惠券领取记录列表
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:list')")
@GetMapping("/list")
public TableDataInfo list(EtCouponClaimLog etCouponClaimLog)
{
startPage();
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
return getDataTable(list);
}
/**
* 导出优惠券领取记录列表
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:export')")
@Log(title = "优惠券领取记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EtCouponClaimLog etCouponClaimLog)
{
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
ExcelUtil<EtCouponClaimLog> util = new ExcelUtil<EtCouponClaimLog>(EtCouponClaimLog.class);
util.exportExcel(response, list, "优惠券领取记录数据");
}
/**
* 获取优惠券领取记录详细信息
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:query')")
@GetMapping(value = "/{claimId}")
public AjaxResult getInfo(@PathVariable("claimId") Long claimId)
{
return success(etCouponClaimLogService.selectEtCouponClaimLogByClaimId(claimId));
}
/**
* 新增优惠券领取记录
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:add')")
@Log(title = "优惠券领取记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtCouponClaimLog etCouponClaimLog)
{
return toAjax(etCouponClaimLogService.insertEtCouponClaimLog(etCouponClaimLog));
}
/**
* 修改优惠券领取记录
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:edit')")
@Log(title = "优惠券领取记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtCouponClaimLog etCouponClaimLog)
{
return toAjax(etCouponClaimLogService.updateEtCouponClaimLog(etCouponClaimLog));
}
/**
* 删除优惠券领取记录
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:remove')")
@Log(title = "优惠券领取记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{claimIds}")
public AjaxResult remove(@PathVariable Long[] claimIds)
{
return toAjax(etCouponClaimLogService.deleteEtCouponClaimLogByClaimIds(claimIds));
}
}

View File

@ -0,0 +1,104 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EtCoupon;
import com.ruoyi.system.service.IEtCouponService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 优惠券Controller
*
* @author 邱贞招
* @date 2024-08-05
*/
@RestController
@RequestMapping("/system/coupon")
public class EtCouponController extends BaseController
{
@Autowired
private IEtCouponService etCouponService;
/**
* 查询优惠券列表
*/
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/list")
public TableDataInfo list(EtCoupon etCoupon)
{
startPage();
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
return getDataTable(list);
}
/**
* 导出优惠券列表
*/
@PreAuthorize("@ss.hasPermi('system:coupon:export')")
@Log(title = "优惠券", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EtCoupon etCoupon)
{
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
ExcelUtil<EtCoupon> util = new ExcelUtil<EtCoupon>(EtCoupon.class);
util.exportExcel(response, list, "优惠券数据");
}
/**
* 获取优惠券详细信息
*/
@PreAuthorize("@ss.hasPermi('system:coupon:query')")
@GetMapping(value = "/{couponId}")
public AjaxResult getInfo(@PathVariable("couponId") Long couponId)
{
return success(etCouponService.selectEtCouponByCouponId(couponId));
}
/**
* 新增优惠券
*/
@PreAuthorize("@ss.hasPermi('system:coupon:add')")
@Log(title = "优惠券", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtCoupon etCoupon)
{
return toAjax(etCouponService.insertEtCoupon(etCoupon));
}
/**
* 修改优惠券
*/
@PreAuthorize("@ss.hasPermi('system:coupon:edit')")
@Log(title = "优惠券", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtCoupon etCoupon)
{
return toAjax(etCouponService.updateEtCoupon(etCoupon));
}
/**
* 删除优惠券
*/
@PreAuthorize("@ss.hasPermi('system:coupon:remove')")
@Log(title = "优惠券", businessType = BusinessType.DELETE)
@DeleteMapping("/{couponIds}")
public AjaxResult remove(@PathVariable Long[] couponIds)
{
return toAjax(etCouponService.deleteEtCouponByCouponIds(couponIds));
}
}

View File

@ -19,6 +19,7 @@ import com.ruoyi.system.mapper.EtOrderMapper;
import com.ruoyi.system.service.IEtOperatingAreaService;
import com.ruoyi.system.service.ISysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -103,11 +104,42 @@ public class SysDeptController extends BaseController
{
AjaxResult ajax = AjaxResult.success();
deptService.checkDeptDataScope(deptId);
ajax.put(AjaxResult.DATA_TAG,deptService.selectDeptById(deptId));
SysDept sysDept = deptService.selectDeptById(deptId);
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);
// 更新 sysDept 的余额字段
if (sysDept.getBalance() != null) {
sysDept.setBalance(sysDept.getBalance().subtract(todayOrderAmount));
}
ajax.put(AjaxResult.DATA_TAG,sysDept);
ajax.put("areaIds", etOperatingAreaService.selectAreaListByDeptId(deptId));
return ajax;
}
@NotNull
private BigDecimal getTodayOrderAmount(@PathVariable Long deptId) {
// 获取今天的日期字符串
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startDateStr = dateFormat.format(new Date()) + " 00:00:00";
String endDateStr = dateFormat.format(new Date()) + " 23:59:59";
//今日订单金额
BigDecimal todayOrderAmount = BigDecimal.ZERO;
List<Long> longs = etOperatingAreaMapper.selectAreaListByDeptId(deptId);
for (Long areaId:longs) {
BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//新增
BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//退款
BigDecimal serviceFee = etCapitalFlowMapper.getHandlingFee(startDateStr, endDateStr, null, areaId);//手续费,扣除掉退款部分的
BigDecimal platformServiceFee = etCapitalFlowMapper.getServiceFee(startDateStr, endDateStr, null,areaId);//平台服务费 ,扣除掉退款部分的
BigDecimal areaOrderAmount = defaultIfNull(payFee.subtract(serviceFee).subtract(refundFee).subtract(platformServiceFee), BigDecimal.ZERO);//营收 = 新增 - 手续费 - 退款 - 平台服务费
if (areaOrderAmount != null) {
todayOrderAmount = todayOrderAmount.add(areaOrderAmount);
}
}
return todayOrderAmount;
}
/**
* 新增运营商
*/
@ -216,25 +248,7 @@ public class SysDeptController extends BaseController
}
AjaxResult ajax = AjaxResult.success();
SysDept sysDept = deptService.selectDeptById(deptId);
// 获取今天的日期字符串
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startDateStr = dateFormat.format(new Date()) + " 00:00:00";
String endDateStr = dateFormat.format(new Date()) + " 23:59:59";
//今日订单金额
BigDecimal todayOrderAmount = BigDecimal.ZERO;
List<Long> longs = etOperatingAreaMapper.selectAreaListByDeptId(deptId);
for (Long areaId:longs) {
BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//新增
BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//退款
BigDecimal serviceFee = etCapitalFlowMapper.getHandlingFee(startDateStr, endDateStr, null, areaId);//手续费,扣除掉退款部分的
BigDecimal platformServiceFee = etCapitalFlowMapper.getServiceFee(startDateStr, endDateStr, null,areaId);//平台服务费 ,扣除掉退款部分的
BigDecimal areaOrderAmount = defaultIfNull(payFee.subtract(serviceFee).subtract(refundFee).subtract(platformServiceFee), BigDecimal.ZERO);//营收 = 新增 - 手续费 - 退款 - 平台服务费
if (areaOrderAmount != null) {
todayOrderAmount = todayOrderAmount.add(areaOrderAmount);
}
}
BigDecimal todayOrderAmount = getTodayOrderAmount(deptId);//获取今日金额
// 更新 sysDept 的余额字段
if (sysDept.getBalance() != null) {
sysDept.setBalance(sysDept.getBalance().subtract(todayOrderAmount));

View File

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

View File

@ -0,0 +1,66 @@
package com.ruoyi.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 优惠券对象 et_coupon
*
* @author 邱贞招
* @date 2024-08-05
*/
@Data
public class EtCoupon extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 优惠券id */
private Long couponId;
/** 类型 */
@Excel(name = "类型")
private String type;
/** 折扣比例 */
@Excel(name = "折扣比例")
private BigDecimal discountPercent;
/** 区域 */
@Excel(name = "区域")
private Long areaId;
/** 区域名称 */
@Excel(name = "区域名称")
private String areaName;
/** 用户 */
@Excel(name = "用户")
private Long userId;
/** 用户名 */
@Excel(name = "用户名")
private String userName;
/** 抵扣金额 */
@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;
/** 限制次数: 0无限制 */
@Excel(name = "限制次数:0无限制")
private String limitNum;
}

View File

@ -0,0 +1,43 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 优惠券领取记录对象 et_coupon_claim_log
*
* @author qzz
* @date 2024-08-08
*/
@Data
public class EtCouponClaimLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 领取id */
private Long claimId;
/** 区域 */
@Excel(name = "区域")
private Long areaId;
/** 区域名称 */
@Excel(name = "区域名称")
private String areaName;
/** 用户 */
@Excel(name = "用户")
private Long userId;
/** 用户名 */
@Excel(name = "用户名")
private String userName;
/** 优惠券 */
@Excel(name = "优惠券")
private Long couponId;
}

View File

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

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.EtCouponClaimLog;
/**
* 优惠券领取记录Mapper接口
*
* @author qzz
* @date 2024-08-08
*/
public interface EtCouponClaimLogMapper
{
/**
* 查询优惠券领取记录
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId);
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog);
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
/**
* 删除优惠券领取记录
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimId(Long claimId);
/**
* 批量删除优惠券领取记录
*
* @param claimIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.EtCoupon;
/**
* 优惠券Mapper接口
*
* @author 邱贞招
* @date 2024-08-05
*/
public interface EtCouponMapper
{
/**
* 查询优惠券
*
* @param couponId 优惠券主键
* @return 优惠券
*/
public EtCoupon selectEtCouponByCouponId(Long couponId);
/**
* 查询优惠券列表
*
* @param etCoupon 优惠券
* @return 优惠券集合
*/
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon);
/**
* 新增优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
public int insertEtCoupon(EtCoupon etCoupon);
/**
* 修改优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
public int updateEtCoupon(EtCoupon etCoupon);
/**
* 删除优惠券
*
* @param couponId 优惠券主键
* @return 结果
*/
public int deleteEtCouponByCouponId(Long couponId);
/**
* 批量删除优惠券
*
* @param couponIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteEtCouponByCouponIds(Long[] couponIds);
}

View File

@ -149,13 +149,13 @@ public interface IAsDeviceService extends IService<AsDevice>
public int deleteAsDeviceByDeviceId(Long deviceId);
/**
* 根据定位获取运营区信息并返回所有车辆定位
* 根据经纬度查询附近500米的所有车辆
*
* @param longitude 经度
* @param latitude 纬度
* @return 结果
*/
List<AsDevice> vehicleLocalization(String longitude, String latitude);
List<AsDevice> vehicleLocalization(String longitude, String latitude,String deptId);
/**
* 所有车辆定位

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.EtCouponClaimLog;
/**
* 优惠券领取记录Service接口
*
* @author qzz
* @date 2024-08-08
*/
public interface IEtCouponClaimLogService
{
/**
* 查询优惠券领取记录
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId);
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog);
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
/**
* 批量删除优惠券领取记录
*
* @param claimIds 需要删除的优惠券领取记录主键集合
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds);
/**
* 删除优惠券领取记录信息
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
public int deleteEtCouponClaimLogByClaimId(Long claimId);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.EtCoupon;
/**
* 优惠券Service接口
*
* @author 邱贞招
* @date 2024-08-05
*/
public interface IEtCouponService
{
/**
* 查询优惠券
*
* @param couponId 优惠券主键
* @return 优惠券
*/
public EtCoupon selectEtCouponByCouponId(Long couponId);
/**
* 查询优惠券列表
*
* @param etCoupon 优惠券
* @return 优惠券集合
*/
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon);
/**
* 新增优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
public int insertEtCoupon(EtCoupon etCoupon);
/**
* 修改优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
public int updateEtCoupon(EtCoupon etCoupon);
/**
* 批量删除优惠券
*
* @param couponIds 需要删除的优惠券主键集合
* @return 结果
*/
public int deleteEtCouponByCouponIds(Long[] couponIds);
/**
* 删除优惠券信息
*
* @param couponId 优惠券主键
* @return 结果
*/
public int deleteEtCouponByCouponId(Long couponId);
}

View File

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

View File

@ -111,6 +111,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Autowired
private CallbackService callbackService;
@Autowired
private ISysConfigService sysConfigService;
@Value(value = "${iot.iotUrl}")
private String iotUrl;
@ -304,8 +307,19 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int insertAsDevice(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setCreateTime(DateUtils.getNowDate());
// asDevice.setAreaId();
return asDeviceMapper.insertAsDevice(asDevice);
}
@ -318,6 +332,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int updateAsDevice(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setUpdateTime(DateUtils.getNowDate());
int i = asDeviceMapper.updateAsDevice(asDevice);
//预约后开始计费
@ -334,6 +360,18 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override
public int updateAsDevice2(AsDevice asDevice)
{
if(ObjectUtil.isNotNull(asDevice.getAreaId())){
SysDept sysDept = wxPayService.getDeptObjByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(sysDept)){
asDevice.setAppid(sysDept.getAppid());
asDevice.setAppName(sysDept.getAppName());
if(sysDept.getIsUsePlatformApp().equals("true")){
asDevice.setDeptId(100L);
}else{
asDevice.setDeptId(sysDept.getDeptId());
}
}
}
asDevice.setUpdateTime(DateUtils.getNowDate());
if(asDevice.getAreaId() == null){
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NOT_BAND);
@ -517,39 +555,39 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
/**
* 根据定位获取运营区信息并返回所有车辆定位
* a. 将前端的边界值获取后转成geometry格式
* b. 模拟gps定位根据定位计算在哪个运营区内
* c. 获取到运营区信息查询出该运营区下所有的车辆信息并获取所有车辆的定位返回前端
* 根据经纬度查询附近500米的所有车辆
* @param longitude 经度
* @param latitude 纬度
* @return 结果
*/
@Override
public List<AsDevice> vehicleLocalization(String longitude, String latitude) {
List<EtOperatingArea> etOperatingAreas = etOperatingAreaService.selectEtOperatingAreaList(new EtOperatingArea());
EtOperatingArea area = null;
for(EtOperatingArea etOperatingArea:etOperatingAreas){
Geometry geometry = GeoUtils.fromWkt(etOperatingArea.getBoundary());
Boolean inCircle = GeoUtils.isInCircle(longitude, latitude, geometry);
if(inCircle){
area = etOperatingArea;
break;
public List<AsDevice> vehicleLocalization(String longitude, String latitude,String deptId) {
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
wrapper.eq("status", "1"); // 设备状态正常
wrapper.eq("dept_id", deptId);
// 查询所有设备
List<AsDevice> allDevices = asDeviceMapper.selectList(wrapper);
List<AsDevice> nearbyDevices = new ArrayList<>();
double targetLon = Double.parseDouble(longitude);
double targetLat = Double.parseDouble(latitude);
int nearbyVehicle = 500;// 默认距离小于等于 500
String nearbyVehicles = sysConfigService.selectConfigByKey("nearby.vehicles");
if(StrUtil.isNotBlank(nearbyVehicles)){
nearbyVehicle = Integer.parseInt(nearbyVehicles);
}
for (AsDevice device : allDevices) {
double deviceLon = Double.parseDouble(device.getLongitude());
double deviceLat = Double.parseDouble(device.getLatitude());
double distance = GeoUtils.calculateDistance(targetLat, targetLon, deviceLat, deviceLon);
if (distance <= nearbyVehicle) {
nearbyDevices.add(device);
}
}
List<AsDevice> asDevices = new ArrayList<>();
if(ObjectUtil.isNotNull(area)){
/** c. 获取到运营区信息,查询出该运营区下所有的车辆信息并获取所有车辆的定位返回前端*/
log.info("在【{}】运营区内",area.getAreaName());
QueryWrapper<AsDevice> wrapper = new QueryWrapper<>();
wrapper.eq("area_id", area.getAreaId());
wrapper.in("status","1");//0 未上架1-正常
asDevices = asDeviceMapper.selectList(wrapper);
return asDevices;
}else{
log.info("不在任何运营区内");
return asDevices;
}
return nearbyDevices;
}
/**
@ -1640,15 +1678,15 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 5. 更新骑行订单状态为已支付支付方式为 押金抵扣
* 6. 更新用户余额
* */
String isDepositDeduction = area.getIsDepositDeduction();
/** 1. 判断是否开启押金抵扣*/
if(ObjectUtil.isNotNull(isDepositDeduction) && "1".equals(isDepositDeduction)){
if(ServiceConstants.RETURN_VERIFY_NO.equals(area.getReturnVerify())){//关闭还车审核订单直接用押金支付
depositDeduction(order);
}else{
throw new ServiceException("拍照审核和押金点开不能同时开启");
}
}
// String isDepositDeduction = area.getIsDepositDeduction();
// /** 1. 判断是否开启押金抵扣*/
// if(ObjectUtil.isNotNull(isDepositDeduction) && "1".equals(isDepositDeduction)){
// if(ServiceConstants.RETURN_VERIFY_NO.equals(area.getReturnVerify())){//关闭还车审核订单直接用押金支付
// depositDeduction(order);
// }else{
// throw new ServiceException("拍照审核和押金点开不能同时开启");
// }
// }
int i = etOrderService.updateEtOrder(order);
if(i==0){
throw new ServiceException("更新订单状态失败");
@ -1668,74 +1706,73 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
}
/** 押金抵扣 */
private void depositDeduction(EtOrder order) {
EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
Integer autoRefundDeposit = rule.getAutoRefundDeposit();
log.info("【还车关锁】进入押金抵扣环节--------"+autoRefundDeposit+"个小时后退还押金");
if(autoRefundDeposit!=null){
//创建一个定时器计算出退还时间后执行退款操作
// 往后推autoRefundDeposit小时执行
EtOrder finalOrder = order;
scheduledExecutorService.schedule(() -> {
/** 2. 获取最后一次押金*/
EtOrder depositOrder = etOrderService.getDepositOrder(finalOrder.getUserId());
BigDecimal deposit = depositOrder.getTotalFee();
BigDecimal ridingFee = finalOrder.getTotalFee();
BigDecimal afterDeductionFee;
String mark;
if(deposit.compareTo(ridingFee) <= 0){// 骑行费大于押金订单为未支付, 抵扣后的金额 = 骑行费 - 押金
afterDeductionFee = BigDecimal.ZERO;
mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"";
finalOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
finalOrder.setPayFee(deposit);
}else{
// 押金大于订单金额 扣除后
afterDeductionFee = deposit.subtract(ridingFee);
mark = "押金抵扣成功,骑行费【"+ridingFee+"】小于押金【"+deposit+"】,扣除后金额【"+afterDeductionFee+"";
finalOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
}
/** 更新骑行订单*/
finalOrder.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
finalOrder.setPayTime(DateUtils.getNowDate());
finalOrder.setPayType(ServiceConstants.PAY_TYPE_YJ);
finalOrder.setMark(mark);
finalOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
/** 更新押金订单*/
depositOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
int updateEtOrder1 = etOrderMapper.updateEtOrder(depositOrder);
if(updateEtOrder1 == 0){
throw new ServiceException("押金抵扣失败,更新押金订单失败");
}
if(afterDeductionFee.compareTo(BigDecimal.ZERO) > 0){
/** 退款剩余押金*/
Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
/** 2.记录退款表 创建退款对象*/
depositOrder.setReason("押金抵扣退款");
EtRefund refund1= etOrderService.createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
int i = etRefundService.insertEtRefund(refund1);
if(i == 0){
log.info("【押金抵扣】保存退款对象失败");
throw new ServiceException("【押金抵扣】,保存退款对象失败");
}
/** 更新用户余额*/
AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
if(asUser!=null){
// 更新用户并更新缓存
asUser.setBalance(BigDecimal.ZERO);
if (asUserService.updateUserProfile(asUser) > 0)
{
log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
}else{
throw new ServiceException("【押金抵扣】,更新用户信息失败");
}
}
}
/** 押金抵扣后生成资金流水记录 */
callbackService.capitalFlowRecords(finalOrder,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
}, autoRefundDeposit , TimeUnit.HOURS);
}
}
// /** 押金抵扣 */
// private void depositDeduction(EtOrder order) {
//// EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
//// Integer autoRefundDeposit = rule.getAutoRefundDeposit();
//// log.info("【还车关锁】进入押金抵扣环节--------"+autoRefundDeposit+"个小时后退还押金");
// /** 2. 获取最后一次押金*/
// EtOrder depositOrder = etOrderService.getDepositOrder(order.getUserId());
// BigDecimal deposit = depositOrder.getTotalFee();
// BigDecimal ridingFee = order.getTotalFee();
// BigDecimal afterDeductionFee;
// String mark;
// if(deposit.compareTo(ridingFee) <= 0){// 骑行费大于押金订单为未支付, 抵扣后的金额 = 骑行费 - 押金
// afterDeductionFee = BigDecimal.ZERO;
// mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"";
// order.setStatus(ServiceConstants.ORDER_STATUS_RIDING_END);
// order.setPayFee(deposit);
// }else{
// // 押金大于订单金额 扣除后
// afterDeductionFee = deposit.subtract(ridingFee);
// mark = "押金抵扣成功,骑行费【"+ridingFee+"】小于押金【"+deposit+"】,扣除后金额【"+afterDeductionFee+"";
// order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
// }
// /** 更新骑行订单*/
// order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
// order.setPayTime(DateUtils.getNowDate());
// order.setPayType(ServiceConstants.PAY_TYPE_YJ);
// order.setMark(mark);
// order.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
// /** 更新押金订单*/
// depositOrder.setDepositDeduction(ServiceConstants.IS_DEPOSIT_DEDUCTION);
// int updateEtOrder1 = etOrderMapper.updateEtOrder(depositOrder);
// if(updateEtOrder1 == 0){
// throw new ServiceException("押金抵扣失败,更新押金订单失败");
// }
// /** 押金抵扣后生成资金流水记录 */
// callbackService.capitalFlowRecords(order,ServiceConstants.FLOW_TYPE_INCOME,ServiceConstants.ORDER_TYPE_RIDING,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_YJ);
// //创建一个定时器计算出退还时间后执行退款操作
// // 往后推autoRefundDeposit小时执行
//// if(autoRefundDeposit!=null){
//// scheduledExecutorService.schedule(() -> {
// if(afterDeductionFee.compareTo(BigDecimal.ZERO) > 0){
// /** 退款剩余押金*/
// Refund refund = wxPayService.refund(depositOrder, "押金抵扣退款",afterDeductionFee,IdUtils.getOrderNo("ref"));
// /** 2.记录退款表 创建退款对象*/
// depositOrder.setReason("押金抵扣退款");
// EtRefund refund1= etOrderService.createRefund(depositOrder, afterDeductionFee, null, null, null, null, refund.getOutRefundNo(),ServiceConstants.REFUND_TYPE_DEPOSIT);
// int i = etRefundService.insertEtRefund(refund1);
// if(i == 0){
// log.info("【押金抵扣】保存退款对象失败");
// throw new ServiceException("【押金抵扣】,保存退款对象失败");
// }
// /** 更新用户余额*/
// AsUser asUser = asUserService.selectUserById(depositOrder.getUserId());
// if(asUser!=null){
// // 更新用户并更新缓存
// asUser.setBalance(BigDecimal.ZERO);
// if (asUserService.updateUserProfile(asUser) > 0)
// {
// log.info("【押金抵扣成功】更新用户信息成功:"+ JSON.toJSON(asUser));
// }else{
// throw new ServiceException("【押金抵扣】,更新用户信息失败");
// }
// }
// }
//// }, autoRefundDeposit , TimeUnit.HOURS);
//// }
// }
/**
* 计算订单费用

View File

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

View File

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

View File

@ -0,0 +1,95 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EtCouponClaimLogMapper;
import com.ruoyi.system.domain.EtCouponClaimLog;
import com.ruoyi.system.service.IEtCouponClaimLogService;
/**
* 优惠券领取记录Service业务层处理
*
* @author qzz
* @date 2024-08-08
*/
@Service
public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
{
@Autowired
private EtCouponClaimLogMapper etCouponClaimLogMapper;
/**
* 查询优惠券领取记录
*
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
@Override
public EtCouponClaimLog selectEtCouponClaimLogByClaimId(Long claimId)
{
return etCouponClaimLogMapper.selectEtCouponClaimLogByClaimId(claimId);
}
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @return 优惠券领取记录
*/
@Override
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog)
{
return etCouponClaimLogMapper.selectEtCouponClaimLogList(etCouponClaimLog);
}
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@Override
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog)
{
etCouponClaimLog.setCreateTime(DateUtils.getNowDate());
return etCouponClaimLogMapper.insertEtCouponClaimLog(etCouponClaimLog);
}
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @return 结果
*/
@Override
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog)
{
return etCouponClaimLogMapper.updateEtCouponClaimLog(etCouponClaimLog);
}
/**
* 批量删除优惠券领取记录
*
* @param claimIds 需要删除的优惠券领取记录主键
* @return 结果
*/
@Override
public int deleteEtCouponClaimLogByClaimIds(Long[] claimIds)
{
return etCouponClaimLogMapper.deleteEtCouponClaimLogByClaimIds(claimIds);
}
/**
* 删除优惠券领取记录信息
*
* @param claimId 优惠券领取记录主键
* @return 结果
*/
@Override
public int deleteEtCouponClaimLogByClaimId(Long claimId)
{
return etCouponClaimLogMapper.deleteEtCouponClaimLogByClaimId(claimId);
}
}

View File

@ -0,0 +1,95 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
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;
/**
* 优惠券Service业务层处理
*
* @author 邱贞招
* @date 2024-08-05
*/
@Service
public class EtCouponServiceImpl implements IEtCouponService
{
@Autowired
private EtCouponMapper etCouponMapper;
/**
* 查询优惠券
*
* @param couponId 优惠券主键
* @return 优惠券
*/
@Override
public EtCoupon selectEtCouponByCouponId(Long couponId)
{
return etCouponMapper.selectEtCouponByCouponId(couponId);
}
/**
* 查询优惠券列表
*
* @param etCoupon 优惠券
* @return 优惠券
*/
@Override
public List<EtCoupon> selectEtCouponList(EtCoupon etCoupon)
{
return etCouponMapper.selectEtCouponList(etCoupon);
}
/**
* 新增优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
@Override
public int insertEtCoupon(EtCoupon etCoupon)
{
etCoupon.setCreateTime(DateUtils.getNowDate());
return etCouponMapper.insertEtCoupon(etCoupon);
}
/**
* 修改优惠券
*
* @param etCoupon 优惠券
* @return 结果
*/
@Override
public int updateEtCoupon(EtCoupon etCoupon)
{
return etCouponMapper.updateEtCoupon(etCoupon);
}
/**
* 批量删除优惠券
*
* @param couponIds 需要删除的优惠券主键
* @return 结果
*/
@Override
public int deleteEtCouponByCouponIds(Long[] couponIds)
{
return etCouponMapper.deleteEtCouponByCouponIds(couponIds);
}
/**
* 删除优惠券信息
*
* @param couponId 优惠券主键
* @return 结果
*/
@Override
public int deleteEtCouponByCouponId(Long couponId)
{
return etCouponMapper.deleteEtCouponByCouponId(couponId);
}
}

View File

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

View File

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

View File

@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysRoleService;
/**
* 角色 业务层处理
*
*
* @author ruoyi
*/
@Service
@ -47,12 +47,12 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 根据条件分页查询角色数据
*
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope(deptAlias = "d")
// @DataScope(deptAlias = "d")
public List<SysRole> selectRoleList(SysRole role)
{
return roleMapper.selectRoleList(role);
@ -60,7 +60,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 根据用户ID查询角色
*
*
* @param userId 用户ID
* @return 角色列表
*/
@ -85,7 +85,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 根据用户ID查询权限
*
*
* @param userId 用户ID
* @return 权限列表
*/
@ -106,7 +106,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 查询所有角色
*
*
* @return 角色列表
*/
@Override
@ -117,7 +117,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 根据用户ID获取角色选择框列表
*
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
@ -129,7 +129,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 通过角色ID查询角色
*
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@ -141,7 +141,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色名称是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@ -159,7 +159,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色权限是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@ -177,7 +177,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色是否允许操作
*
*
* @param role 角色信息
*/
@Override
@ -191,7 +191,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色是否有数据权限
*
*
* @param roleId 角色id
*/
@Override
@ -211,7 +211,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 通过角色ID查询角色使用数量
*
*
* @param roleId 角色ID
* @return 结果
*/
@ -223,7 +223,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 新增保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@ -238,7 +238,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 修改保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@ -255,7 +255,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 修改角色状态
*
*
* @param role 角色信息
* @return 结果
*/
@ -267,7 +267,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 修改数据权限信息
*
*
* @param role 角色信息
* @return 结果
*/
@ -285,7 +285,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 新增角色菜单信息
*
*
* @param role 角色对象
*/
public int insertRoleMenu(SysRole role)
@ -333,7 +333,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 通过角色ID删除角色
*
*
* @param roleId 角色ID
* @return 结果
*/
@ -350,7 +350,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 批量删除角色信息
*
*
* @param roleIds 需要删除的角色ID
* @return 结果
*/
@ -377,7 +377,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 取消授权用户角色
*
*
* @param userRole 用户和角色关联信息
* @return 结果
*/
@ -389,7 +389,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 批量取消授权用户角色
*
*
* @param roleId 角色ID
* @param userIds 需要取消授权的用户数据ID
* @return 结果
@ -402,7 +402,7 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 批量选择授权用户角色
*
*
* @param roleId 角色ID
* @param userIds 需要授权的用户数据ID
* @return 结果

View File

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

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EtCouponClaimLogMapper">
<resultMap type="EtCouponClaimLog" id="EtCouponClaimLogResult">
<result property="claimId" column="claim_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" />
</resultMap>
<sql id="selectEtCouponClaimLogVo">
select claim_id, area_id, user_id, coupon_id, create_time from et_coupon_claim_log
</sql>
<select id="selectEtCouponClaimLogList" parameterType="EtCouponClaimLog" resultMap="EtCouponClaimLogResult">
select
l.claim_id,
l.area_id,
a.area_name areaName,
l.user_id,
u.user_name userName,
l.coupon_id,
l.create_time
from et_coupon_claim_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="userName != null "> and u.user_name = #{userName}</if>
<if test="couponId != null "> and l.coupon_id like concat('%', #{couponId}, '%')</if>
</where>
</select>
<select id="selectEtCouponClaimLogByClaimId" parameterType="Long" resultMap="EtCouponClaimLogResult">
<include refid="selectEtCouponClaimLogVo"/>
where claim_id = #{claimId}
</select>
<insert id="insertEtCouponClaimLog" parameterType="EtCouponClaimLog" useGeneratedKeys="true" keyProperty="claimId">
insert into et_coupon_claim_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>
</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>
</trim>
</insert>
<update id="updateEtCouponClaimLog" parameterType="EtCouponClaimLog">
update et_coupon_claim_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>
</trim>
where claim_id = #{claimId}
</update>
<delete id="deleteEtCouponClaimLogByClaimId" parameterType="Long">
delete from et_coupon_claim_log where claim_id = #{claimId}
</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}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EtCouponMapper">
<resultMap type="EtCoupon" id="EtCouponResult">
<result property="couponId" column="coupon_id" />
<result property="type" column="type" />
<result property="discountPercent" column="discount_percent" />
<result property="areaId" column="area_id" />
<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="status" column="status" />
<result property="limitNum" column="limit_num" />
</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
</sql>
<select id="selectEtCouponList" parameterType="EtCoupon" resultMap="EtCouponResult">
SELECT
c.coupon_id,
c.type,
c.discount_percent,
c.area_id,
a.area_name areaName,
c.user_id,
u.user_name userName,
c.discount_amount,
c.create_time,
c.expiration_time,
c.STATUS,
c.limit_num
FROM
et_coupon c
left join et_operating_area a on a.area_id = c.area_id
left join et_user u on u.user_id = c.user_id
<where>
<if test="type != null and type != ''"> and c.type = #{type}</if>
<if test="discountPercent != null "> and c.discount_percent = #{discountPercent}</if>
<if test="areaId != null "> and c.area_id = #{areaId}</if>
<if test="areaName != null "> and a.area_name like concat('%', #{areaName}, '%')</if>
<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>
</select>
<select id="selectEtCouponByCouponId" parameterType="Long" resultMap="EtCouponResult">
<include refid="selectEtCouponVo"/>
where coupon_id = #{couponId}
</select>
<insert id="insertEtCoupon" parameterType="EtCoupon" useGeneratedKeys="true" keyProperty="couponId">
insert into et_coupon
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null">type,</if>
<if test="discountPercent != null">discount_percent,</if>
<if test="areaId != null">area_id,</if>
<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="status != null">status,</if>
<if test="limitNum != null">limit_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">#{type},</if>
<if test="discountPercent != null">#{discountPercent},</if>
<if test="areaId != null">#{areaId},</if>
<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="status != null">#{status},</if>
<if test="limitNum != null">#{limitNum},</if>
</trim>
</insert>
<update id="updateEtCoupon" parameterType="EtCoupon">
update et_coupon
<trim prefix="SET" suffixOverrides=",">
<if test="type != null">type = #{type},</if>
<if test="discountPercent != null">discount_percent = #{discountPercent},</if>
<if test="areaId != null">area_id = #{areaId},</if>
<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="status != null">status = #{status},</if>
<if test="limitNum != null">limit_num = #{limitNum},</if>
</trim>
where coupon_id = #{couponId}
</update>
<delete id="deleteEtCouponByCouponId" parameterType="Long">
delete from et_coupon where coupon_id = #{couponId}
</delete>
<delete id="deleteEtCouponByCouponIds" parameterType="String">
delete from et_coupon where coupon_id in
<foreach item="couponId" collection="array" open="(" separator="," close=")">
#{couponId}
</foreach>
</delete>
</mapper>

View File

@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where 1 = 1
<if test="userId != null "> and f.user_id = #{userId}</if>
<if test="type != null and type != ''"> and f.type = #{type}</if>
<if test="sn != null and sn != ''"> and f.sn = #{sn}</if>
<if test="status != null and status != ''"> and f.status = #{status}</if>
<!-- 数据范围过滤 -->
${params.dataScope}