1. 优惠券调整

This commit is contained in:
邱贞招 2024-09-03 15:54:11 +08:00
parent 91da8794ed
commit b046963a42
17 changed files with 281 additions and 95 deletions

View File

@ -686,6 +686,11 @@ public class AppController extends BaseController
@GetMapping("/couponList")
public AjaxResult list(EtCoupon etCoupon)
{
if(etCoupon.getType().contains(",")){
String[] typeList = etCoupon.getType().split(",");
etCoupon.setTypeList(typeList);
etCoupon.setType(null);
}
List<EtCoupon> list = etCouponService.selectEtCouponList(etCoupon);
return success(list);
}

View File

@ -1299,31 +1299,45 @@ public class AppVerifyController extends BaseController
}
/**
* 根据用户搜索优惠券
* 我的骑行卡(未使用)
*/
@GetMapping("/getCouponListByUserId")
public AjaxResult list(Long userId)
public AjaxResult getCouponListByUserId(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);
EtCouponUserLog etCouponUserLog = new EtCouponUserLog();
etCouponUserLog.setUserId(userId);
etCouponUserLog.setStatus(ServiceConstants.COUPON_STATUS_UNUSED);
etCouponUserLog.setStatusList(new String[]{ServiceConstants.COUPON_STATUS_UNUSED, ServiceConstants.COUPON_STATUS_EXPIRED});
List<EtCouponUserLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponUserLog);
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);
logger.info("【优惠券使用记录已使用【userId="+userId+"");
EtCouponUserLog etCouponUserLog = new EtCouponUserLog();
etCouponUserLog.setUserId(userId);
etCouponUserLog.setStatus(ServiceConstants.COUPON_STATUS_USED);
List<EtCouponUserLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponUserLog);
return success(list);
}
/**
* 优惠券购买记录
*/
@GetMapping("/couponBuyRecord")
public AjaxResult couponBuyRecord(Long userId)
{
logger.info("【优惠券购买记录】【userId="+userId+"");
EtCouponUserLog etCouponUserLog = new EtCouponUserLog();
etCouponUserLog.setUserId(userId);
etCouponUserLog.setGainMethod(ServiceConstants.COUPON_GAIN_METHOD_BUY);
List<EtCouponUserLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponUserLog);
return success(list);
}

View File

@ -16,7 +16,7 @@ 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.domain.EtCouponUserLog;
import com.ruoyi.system.service.IEtCouponClaimLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@ -39,10 +39,10 @@ public class EtCouponClaimLogController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:claimLog:list')")
@GetMapping("/list")
public TableDataInfo list(EtCouponClaimLog etCouponClaimLog)
public TableDataInfo list(EtCouponUserLog etCouponUserLog)
{
startPage();
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
List<EtCouponUserLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponUserLog);
return getDataTable(list);
}
@ -52,10 +52,10 @@ public class EtCouponClaimLogController extends BaseController
@PreAuthorize("@ss.hasPermi('system:claimLog:export')")
@Log(title = "优惠券领取记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EtCouponClaimLog etCouponClaimLog)
public void export(HttpServletResponse response, EtCouponUserLog etCouponUserLog)
{
List<EtCouponClaimLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponClaimLog);
ExcelUtil<EtCouponClaimLog> util = new ExcelUtil<EtCouponClaimLog>(EtCouponClaimLog.class);
List<EtCouponUserLog> list = etCouponClaimLogService.selectEtCouponClaimLogList(etCouponUserLog);
ExcelUtil<EtCouponUserLog> util = new ExcelUtil<EtCouponUserLog>(EtCouponUserLog.class);
util.exportExcel(response, list, "优惠券领取记录数据");
}
@ -75,9 +75,9 @@ public class EtCouponClaimLogController extends BaseController
@PreAuthorize("@ss.hasPermi('system:claimLog:add')")
@Log(title = "优惠券领取记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtCouponClaimLog etCouponClaimLog)
public AjaxResult add(@RequestBody EtCouponUserLog etCouponUserLog)
{
return toAjax(etCouponClaimLogService.insertEtCouponClaimLog(etCouponClaimLog));
return toAjax(etCouponClaimLogService.insertEtCouponClaimLog(etCouponUserLog));
}
/**
@ -86,9 +86,9 @@ public class EtCouponClaimLogController extends BaseController
@PreAuthorize("@ss.hasPermi('system:claimLog:edit')")
@Log(title = "优惠券领取记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtCouponClaimLog etCouponClaimLog)
public AjaxResult edit(@RequestBody EtCouponUserLog etCouponUserLog)
{
return toAjax(etCouponClaimLogService.updateEtCouponClaimLog(etCouponClaimLog));
return toAjax(etCouponClaimLogService.updateEtCouponClaimLog(etCouponUserLog));
}
/**

View File

@ -16,6 +16,7 @@ import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.system.mapper.AsUserMapper;
import com.ruoyi.system.service.IAsUserService;
import com.ruoyi.system.service.IEtCouponClaimLogService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysMenuService;
import lombok.extern.slf4j.Slf4j;
@ -56,6 +57,9 @@ public class SysLoginController
@Resource
private AsUserMapper asUserMapper;
@Autowired
private IEtCouponClaimLogService etCouponClaimLogService;
/**
* 登录方法

View File

@ -718,5 +718,26 @@ public class ServiceConstants {
/**----------------------------优惠券状态end----------------------------*/
/**----------------------------优惠券类型start----------------------------*/
/** 类型1-时间卡2-贵宾卡3-折扣卡4-抵用券
/**
* 1-时间卡
*/
public static final String COUPON_TYPE_TIME_CARD = "1";
/**
* 2-贵宾卡
*/
public static final String COUPON_TYPE_VIP_CARD = "2";
/**
* 3-折扣卡
*/
public static final String COUPON_TYPE_DISCOUNT_CARD = "3";
/**
* 4-抵用券
*/
public static final String COUPON_TYPE_VOUCHER = "4";
/**----------------------------优惠券类型end----------------------------*/
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.core.domain.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
@ -118,6 +119,28 @@ public class AsUser extends BaseEntity
/** appId*/
public String appId;
/** 会员类型 0-无会员1-普通会员2-贵宾会员 */
public String vipType;
/** 有效时间 */
private Date expirationTime;
public String getVipType() {
return vipType;
}
public void setVipType(String vipType) {
this.vipType = vipType;
}
public Date getExpirationTime() {
return expirationTime;
}
public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}
public String getAppId() {
return appId;
}

View File

@ -334,4 +334,38 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
// 判断是否大于 60,000 毫秒1 分钟
return difference > 60_000;
}
/**
* 根据有效期单位和有效期值返回一个加上固定多少单位的时间
*
* @param startDate 起始日期
* @param validityUnit 有效期单位day-week-month-quarter-季度year-
* @param validityValue 有效期值
* @return 加上有效期后的时间
*/
public static Date addValidity(Date startDate, String validityUnit, Integer validityValue) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
switch (validityUnit.toLowerCase()) {
case "day": //
calendar.add(Calendar.DAY_OF_MONTH, validityValue);
break;
case "week": //
calendar.add(Calendar.WEEK_OF_YEAR, validityValue);
break;
case "month": //
calendar.add(Calendar.MONTH, validityValue);
break;
case "quarter": // 季度
calendar.add(Calendar.MONTH, validityValue * 3);
break;
case "year": //
calendar.add(Calendar.YEAR, validityValue);
break;
default:
throw new IllegalArgumentException("无效的有效期单位: " + validityUnit);
}
return calendar.getTime(); // 返回新的时间
}
}

View File

@ -23,6 +23,9 @@ public class EtCoupon extends BaseEntity
/** 优惠券id */
private Long couponId;
/** 名称 */
private String name;
/** 类型 */
@Excel(name = "类型")
private String type;
@ -63,9 +66,9 @@ public class EtCoupon extends BaseEntity
@Excel(name = "描述")
private String desc;
/** 零价 */
@Excel(name = "")
private BigDecimal snackPrice;
/** 零价 */
@Excel(name = "")
private BigDecimal retailPrice;
/** 有效期值 */
@Excel(name = "有效期值")
@ -74,4 +77,10 @@ public class EtCoupon extends BaseEntity
/** 有效期单位 */
@Excel(name = "有效期单位")
private String validityUnit;
/** 类型列表 */
private String[] typeList;
/** 是否热门0-非热门1-热门 */
private String isHot;
}

View File

@ -6,16 +6,17 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 优惠券领取记录对象 et_coupon_user_log
* 我的优惠券对象 et_coupon_user_log
*
* @author qzz
* @date 2024-08-08
*/
@Data
public class EtCouponClaimLog extends BaseEntity
public class EtCouponUserLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -42,6 +43,14 @@ public class EtCouponClaimLog extends BaseEntity
@Excel(name = "优惠券")
private Long couponId;
/** 优惠券名称 */
@Excel(name = "优惠券名称")
private String couponName;
/** 零售价 */
@Excel(name = "零售价")
private BigDecimal retailPrice;
/** 获取方式claim-领取buy-购买issue-下发 */
@Excel(name = "获取方式claim-领取buy-购买issue-下发")
private String gainMethod;

View File

@ -1,7 +1,7 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.EtCouponClaimLog;
import com.ruoyi.system.domain.EtCouponUserLog;
/**
* 优惠券领取记录Mapper接口
@ -17,31 +17,31 @@ public interface EtCouponClaimLogMapper
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId);
public EtCouponUserLog selectEtCouponClaimLogByLogId(Long claimId);
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog);
public List<EtCouponUserLog> selectEtCouponClaimLogList(EtCouponUserLog etCouponUserLog);
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
public int insertEtCouponClaimLog(EtCouponUserLog etCouponUserLog);
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
public int updateEtCouponClaimLog(EtCouponUserLog etCouponUserLog);
/**
* 删除优惠券领取记录

View File

@ -1,7 +1,7 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.EtCouponClaimLog;
import com.ruoyi.system.domain.EtCouponUserLog;
/**
* 优惠券领取记录Service接口
@ -17,31 +17,31 @@ public interface IEtCouponClaimLogService
* @param claimId 优惠券领取记录主键
* @return 优惠券领取记录
*/
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId);
public EtCouponUserLog selectEtCouponClaimLogByLogId(Long claimId);
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 优惠券领取记录集合
*/
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog);
public List<EtCouponUserLog> selectEtCouponClaimLogList(EtCouponUserLog etCouponUserLog);
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
public int insertEtCouponClaimLog(EtCouponUserLog etCouponUserLog);
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog);
public int updateEtCouponClaimLog(EtCouponUserLog etCouponUserLog);
/**
* 批量删除优惠券领取记录

View File

@ -5,7 +5,7 @@ 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.domain.EtCouponUserLog;
import com.ruoyi.system.service.IEtCouponClaimLogService;
/**
@ -27,7 +27,7 @@ public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
* @return 优惠券领取记录
*/
@Override
public EtCouponClaimLog selectEtCouponClaimLogByLogId(Long claimId)
public EtCouponUserLog selectEtCouponClaimLogByLogId(Long claimId)
{
return etCouponClaimLogMapper.selectEtCouponClaimLogByLogId(claimId);
}
@ -35,38 +35,38 @@ public class EtCouponClaimLogServiceImpl implements IEtCouponClaimLogService
/**
* 查询优惠券领取记录列表
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 优惠券领取记录
*/
@Override
public List<EtCouponClaimLog> selectEtCouponClaimLogList(EtCouponClaimLog etCouponClaimLog)
public List<EtCouponUserLog> selectEtCouponClaimLogList(EtCouponUserLog etCouponUserLog)
{
return etCouponClaimLogMapper.selectEtCouponClaimLogList(etCouponClaimLog);
return etCouponClaimLogMapper.selectEtCouponClaimLogList(etCouponUserLog);
}
/**
* 新增优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
@Override
public int insertEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog)
public int insertEtCouponClaimLog(EtCouponUserLog etCouponUserLog)
{
etCouponClaimLog.setCreateTime(DateUtils.getNowDate());
return etCouponClaimLogMapper.insertEtCouponClaimLog(etCouponClaimLog);
etCouponUserLog.setCreateTime(DateUtils.getNowDate());
return etCouponClaimLogMapper.insertEtCouponClaimLog(etCouponUserLog);
}
/**
* 修改优惠券领取记录
*
* @param etCouponClaimLog 优惠券领取记录
* @param etCouponUserLog 优惠券领取记录
* @return 结果
*/
@Override
public int updateEtCouponClaimLog(EtCouponClaimLog etCouponClaimLog)
public int updateEtCouponClaimLog(EtCouponUserLog etCouponUserLog)
{
return etCouponClaimLogMapper.updateEtCouponClaimLog(etCouponClaimLog);
return etCouponClaimLogMapper.updateEtCouponClaimLog(etCouponUserLog);
}
/**

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
@ -135,16 +136,35 @@ public class EtCouponServiceImpl implements IEtCouponService
* */
// 1. 插入一条记录et_coupon_user_log 获取方式是购买
AsUser asUser = userMapper.selectUserById(userId);
if(ObjectUtil.isNull(asUser)){
throw new ServiceException("用户【"+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(ObjectUtil.isNull(etCoupon)){
throw new ServiceException("优惠券【"+couponId+"】不存在");
}
EtCouponUserLog etCouponUserLog = new EtCouponUserLog();
etCouponUserLog.setCouponId(couponId);
etCouponUserLog.setUserId(userId);
etCouponUserLog.setUserName(asUser.getUserName());
etCouponUserLog.setCreateTime(DateUtils.getNowDate());
etCouponUserLog.setGainMethod(ServiceConstants.COUPON_GAIN_METHOD_BUY);
etCouponUserLog.setAreaId(etCoupon.getAreaId());
etCouponUserLog.setAreaName(etCoupon.getAreaName());
etCouponUserLog.setExpirationTime(DateUtils.addValidity(new Date(),etCoupon.getValidityUnit(),etCoupon.getValidityValue()));
if(ServiceConstants.COUPON_TYPE_TIME_CARD.equals(etCoupon.getType()) || ServiceConstants.COUPON_TYPE_VIP_CARD.equals(etCoupon.getType())){
AsUser asUser1 = new AsUser(userId);
asUser1.setVipType(etCoupon.getType());
Date expirationTime;
if(ObjectUtil.isNull(asUser.getExpirationTime())){
expirationTime = DateUtils.getNowDate();
}else{
expirationTime = asUser.getExpirationTime();
}
asUser1.setExpirationTime(DateUtils.addValidity(expirationTime,etCoupon.getValidityUnit(),etCoupon.getValidityValue()));
int updateUser = userMapper.updateUser(asUser1);
}
int i1 = etCouponClaimLogMapper.insertEtCouponClaimLog(etCouponUserLog);
if(i1 == 0){
throw new ServiceException("保存优惠券领取记录失败");
}
@ -175,8 +195,8 @@ public class EtCouponServiceImpl implements IEtCouponService
/** 订单类型 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());
etOrder.setTotalFee(etCoupon.getRetailPrice());
etOrder.setPayFee(etCoupon.getRetailPrice());
return etOrder;
}
}

View File

@ -94,6 +94,9 @@ public class EtTask {
@Autowired
private IEtModelService etModelService;
@Autowired
private EtCouponClaimLogMapper etCouponClaimLogMapper;
/**
* 1.启动时判断是否有未取消预约的订单
@ -692,4 +695,34 @@ public class EtTask {
return parts;
}
/**
* 判断优惠券是否过期
*
*/
public void couponIsExpires(){
log.info("-------------------【定时任务】判断优惠券是否过期---开始----------------");
EtCouponUserLog etCouponUserLog = new EtCouponUserLog();
etCouponUserLog.setStatus(ServiceConstants.COUPON_STATUS_UNUSED);
List<EtCouponUserLog> couponUserLogs = etCouponClaimLogMapper.selectEtCouponClaimLogList(etCouponUserLog);
// 获取当前时间
Date currentTime = new Date();
for(EtCouponUserLog couponLog :couponUserLogs){
// 获取优惠券的过期时间
Date expirationTime = couponLog.getExpirationTime();
// 判断优惠券是否过期
if (expirationTime != null && expirationTime.before(currentTime)) {
// 如果过期更新状态为已过期
couponLog.setStatus(ServiceConstants.COUPON_STATUS_EXPIRED);
// 更新到数据库
int result = etCouponClaimLogMapper.updateEtCouponClaimLog(couponLog);
if (result > 0) {
log.info("优惠券ID: {} 已过期,状态已更新为 EXPIRED", couponLog.getCouponId());
} else {
log.warn("优惠券ID: {} 更新状态失败", couponLog.getCouponId());
}
}
}
log.info("-------------------【定时任务】判断优惠券是否过期---结束----------------");
}
}

View File

@ -35,13 +35,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isAuthentication" column="is_authentication" />
<result property="appName" column="app_name" />
<result property="appId" column="appid" />
<result property="vipType" column="vip_type" />
<result property="expirationTime" column="expiration_time" />
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar,
u.phonenumber, u.balance, u.birthday, u.password, u.pay_password, u.sex, u.status,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,
u.is_sign,u.role,u.sys_user_id,u.area_id,u.is_authentication,u.app_name,u.appid
u.is_sign,u.role,u.sys_user_id,u.area_id,u.is_authentication,u.app_name,u.appid,u.vip_type,u.expiration_time
from et_user u
</sql>
@ -200,6 +202,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isAuthentication != null">is_authentication,</if>
<if test="appName != null and appName != ''">app_name,</if>
<if test="appId != null and appId != ''">appid,</if>
<if test="vipType != null and vipType != ''">vip_type,</if>
<if test="expirationTime != null and expirationTime != ''">expiration_time,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
@ -224,6 +228,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isAuthentication != null">#{isAuthentication},</if>
<if test="appName != null and appName != ''">#{appName},</if>
<if test="appId != null and appId != ''">#{appId},</if>
<if test="vipType != null and vipType != ''">#{vipType},</if>
<if test="expirationTime != null and expirationTime != ''">#{expirationTime},</if>
sysdate()
)
</insert>
@ -254,6 +260,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isAuthentication != null">is_authentication = #{isAuthentication},</if>
<if test="appName != null">app_name = #{appName},</if>
<if test="appId != null">appid = #{appId},</if>
<if test="vipType != null">vip_type = #{vipType},</if>
<if test="expirationTime != null">expiration_time = #{expirationTime},</if>
update_time = sysdate()
</set>
where user_id = #{userId}

View File

@ -4,7 +4,7 @@ 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">
<resultMap type="EtCouponUserLog" id="EtCouponClaimLogResult">
<result property="logId" column="log_id" />
<result property="areaId" column="area_id" />
<result property="userId" column="user_id" />
@ -19,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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 id="selectEtCouponClaimLogList" parameterType="EtCouponUserLog" resultMap="EtCouponClaimLogResult">
select
l.log_id,
l.area_id,
@ -30,24 +30,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
l.coupon_id,
l.create_time,
l.gain_method,
l.expiration_time
l.expiration_time,
c.name couponName,
c.type,
c.retail_price retailPrice
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
left join et_coupon c on c.coupon_id = l.coupon_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 = #{userId}</if>
<if test="userName != null "> and u.user_name = #{userName}</if>
<if test="gainMethod != null "> and u.gain_method = #{gainMethod}</if>
<if test="gainMethod != null "> and l.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>
@ -56,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where log_id = #{logId}
</select>
<insert id="insertEtCouponClaimLog" parameterType="EtCouponClaimLog" useGeneratedKeys="true" keyProperty="logId">
<insert id="insertEtCouponClaimLog" parameterType="EtCouponUserLog" useGeneratedKeys="true" keyProperty="logId">
insert into et_coupon_user_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">area_id,</if>
@ -78,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="updateEtCouponClaimLog" parameterType="EtCouponClaimLog">
<update id="updateEtCouponClaimLog" parameterType="EtCouponUserLog">
update et_coupon_user_log
<trim prefix="SET" suffixOverrides=",">
<if test="areaId != null">area_id = #{areaId},</if>

View File

@ -6,10 +6,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="EtCoupon" id="EtCouponResult">
<result property="couponId" column="coupon_id" />
<result property="name" column="name" />
<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="validityValue" column="validity_value" />
@ -17,22 +17,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
<result property="limitNum" column="limit_num" />
<result property="desc" column="desc" />
<result property="snackPrice" column="snack_price" />
<result property="retailPrice" column="retail_price" />
<result property="isHot" column="is_hot" />
</resultMap>
<sql id="selectEtCouponVo">
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
select coupon_id, name, type, discount_percent, area_id, discount_amount, create_time, validity_value, validity_unit, status, limit_num, `desc`, retail_price, is_hot from et_coupon
</sql>
<select id="selectEtCouponList" parameterType="EtCoupon" resultMap="EtCouponResult">
SELECT
c.coupon_id,
c.name,
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.validity_value,
@ -40,21 +40,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.status,
c.limit_num,
c.desc,
c.snack_price
c.retail_price,
c.is_hot
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="name != null "> and c.name like concat('%', #{name}, '%')</if>
<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="status != null and status != ''"> and c.status = #{status}</if>
<if test="limitNum != null and limitNum != ''"> and c.limit_num = #{limitNum}</if>
<if test="typeList != null">
AND c.type IN
<foreach item="item" index="index" collection="typeList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
@ -66,10 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertEtCoupon" parameterType="EtCoupon" useGeneratedKeys="true" keyProperty="couponId">
insert into et_coupon
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<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="validityValue != null">validity_value,</if>
@ -77,13 +82,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<if test="retailPrice != null">retail_price,</if>
<if test="isHot != null">is_hot,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<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="validityValue != null">#{validityValue},</if>
@ -91,17 +97,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="limitNum != null">#{limitNum},</if>
<if test="desc != null">#{desc},</if>
<if test="snackPrice != null">#{snackPrice},</if>
<if test="retailPrice != null">#{retailPrice},</if>
<if test="isHot != null">#{isHot},</if>
</trim>
</insert>
<update id="updateEtCoupon" parameterType="EtCoupon">
update et_coupon
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<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="validityValue != null">validity_value = #{validityValue},</if>
@ -109,7 +116,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<if test="retailPrice != null">retail_price = #{retailPrice},</if>
<if test="isHot != null">is_hot = #{isHot},</if>
</trim>
where coupon_id = #{couponId}
</update>