Commit 82361745 by 吕明尚

添加优惠卷日志

parent 561dfd83
package share.common.enums;
public enum ConsumerCouponStatusEnum {
CONTROLLER("1", "控制层"),
WECHAT("2", "微信回调"),
SERVICE("3", "SERVICE回调"),
ORDER("4", "订单下单"),
;
ConsumerCouponStatusEnum() {
}
ConsumerCouponStatusEnum(String code, String name) {
this.code = code;
this.name = name;
}
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -8,8 +8,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public enum YesNoEnum {
yes(1,true,"是","激活","","","","","","",""),
no(0,false,"否","冻结","","","","","","","");
yes(1, true, "是", "激活", "正常", "", "", "", "", "", ""),
no(0, false, "否", "冻结", "异常", "", "", "", "", "", "");
private Integer index;
......
package share.framework.aspectj;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import share.common.enums.YesNoEnum;
import share.system.domain.CouponLog;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SStore;
import share.system.service.CouponLogService;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISStoreService;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.*;
@Aspect
@Component
public class QPServiceImplAspect {
@Autowired
private CouponLogService couponLogService;
@Autowired
private ISConsumerCouponService sConsumerCouponService;
@Autowired
private ISStoreService sStoreService;
/**
* 切点函数,用于标识需要记录操作日志的方法。
* 切点表达式为:execution(* share.system.service.impl.QPServiceImpl.*(..)),表示匹配所有在share.system.service.impl.QPServiceImpl类中定义的方法。
*/
@Pointcut("execution(* share.system.service.impl.QPServiceImpl.*(..))")
public void operLogPoinCut() {
}
@Before("operLogPoinCut()")
public void beforMethod(JoinPoint point) {
}
@Pointcut("execution(* share.system.service.impl.QPServiceImpl.*(..))")
public void operExceptionLogPoinCut() {
}
/**
* 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行
*
* @param joinPoint 切入点
* @param result 返回结果
*/
@AfterReturning(value = "operLogPoinCut()", returning = "result")
public void saveOperLog(JoinPoint joinPoint, Object result) {
// 获取RequestAttributes
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 从获取RequestAttributes中获取HttpServletRequest的信息
HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST);
try {
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// 获取切入点所在的方法
Method method = signature.getMethod();
//获得方法名
String methodName = method.getName();
// 获取操作
CouponLog couponLog = new CouponLog();
// 将入参转换成json // 请求参数
//获得请求参数名称
String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();
String params = argsArrayToString(paramNames, joinPoint.getArgs());
//转JSON
JSONObject jsonObject = JSON.parseObject(params);
//获得出参
String outParams = JSON.toJSONString(result);
// if(methodName.equals("consume")){
saveLog(couponLog, jsonObject);
couponLog.setStatus(YesNoEnum.yes.getDisplay_3());
couponLog.setMessage(outParams);
couponLog.setCreateTime(new Date());
couponLogService.insertCouponLog(couponLog);
// }
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
*/
@AfterThrowing(pointcut = "operExceptionLogPoinCut()", throwing = "e")
public void saveExceptionLog(JoinPoint joinPoint, Throwable e) {
try {
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// 获取切入点所在的方法
Method method = signature.getMethod();
//获得方法名
String methodName = method.getName();
CouponLog couponLog = new CouponLog();
// 将入参转换成json // 请求参数
String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();
String params = argsArrayToString(paramNames, joinPoint.getArgs());
//转JSON
JSONObject jsonObject = JSON.parseObject(params);
// if(methodName.equals("consume")) {
saveLog(couponLog, jsonObject);
couponLog.setStatus(YesNoEnum.no.getDisplay_3());
couponLog.setMessage(stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace()));
couponLog.setCreateTime(new Date());
couponLogService.insertCouponLog(couponLog);
// }
} catch (Exception e2) {
e2.printStackTrace();
}
}
private void saveLog(CouponLog couponLog, JSONObject jsonObject) {
couponLog.setCode(jsonObject.getString("code"));
LambdaQueryWrapper<SConsumerCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SConsumerCoupon::getCouponCode, couponLog.getCode());
SConsumerCoupon one = sConsumerCouponService.getOne(lambdaQueryWrapper);
couponLog.setConsumerId(one.getConsumerId());
couponLog.setCouponId(one.getId());
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
sStoreLambdaQueryWrapper.eq(SStore::getOpenShopUuid, jsonObject.getString("openShopUuid"));
SStore sStore = sStoreService.getOne(sStoreLambdaQueryWrapper);
couponLog.setStoreId(sStore.getId());
couponLog.setCouponName(one.getName());
couponLog.setCouponValue(one.getSubPrice());
couponLog.setCouponType(jsonObject.getString("status"));
}
/**
* 参数拼装
*/
private String argsArrayToString(String[] paramNames, Object[] paramsArray) {
Map<String, Object> map = new HashMap<>();
if (paramsArray != null && paramsArray.length > 0) {
for (int i = 0; i < paramsArray.length; i++) {
if (paramsArray[i] != null) {
try {
map.put(paramNames[i], paramsArray[i]);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return JSONUtil.toJsonStr(map);
}
/**
* 转换异常信息为字符串
*/
public String stackTraceToString(String exceptionName, String exceptionMessage, StackTraceElement[] elements) {
StringBuffer strbuff = new StringBuffer();
for (StackTraceElement stet : elements) {
strbuff.append(stet + "\n");
}
String message = exceptionName + ":" + exceptionMessage + "\n\t" + strbuff.toString();
message = substring(message, 0, 2000);
return message;
}
//字符串截取
public static String substring(String str, int start, int end) {
if (str == null) {
return null;
} else {
if (end < 0) {
end += str.length();
}
if (start < 0) {
start += str.length();
}
if (end > str.length()) {
end = str.length();
}
if (start > end) {
return "";
} else {
if (start < 0) {
start = 0;
}
if (end < 0) {
end = 0;
}
return str.substring(start, end);
}
}
}
}
......@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.domain.R;
import share.common.enums.ConsumerCouponStatusEnum;
import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import share.system.service.QPService;
......@@ -24,13 +25,13 @@ public class QPController {
//输码验券校验接口
@GetMapping("/prepare")
public R<TuangouReceiptPrepareResponseEntity> prepare(String code, String openShopUuid) {
return R.ok(qpService.prepare(code, openShopUuid));
return R.ok(qpService.prepare(code, openShopUuid, ConsumerCouponStatusEnum.CONTROLLER.getCode()));
}
//验券接口
@GetMapping("/consume")
public R<List<TuangouReceiptConsumeResponseEntity>> consume(String code, int count, String openShopUuid) {
return R.ok(qpService.consume(code, count, openShopUuid));
return R.ok(qpService.consume(code, count, openShopUuid, ConsumerCouponStatusEnum.CONTROLLER.getCode()));
}
//撤销验券接口
......@@ -48,7 +49,7 @@ public class QPController {
//用户验券接口
@GetMapping("/consumeByUser")
public R<TuangouReceiptPrepareResponseEntityVo> consumeByUser(String code, String openShopUuid) {
TuangouReceiptPrepareResponseEntityVo tuangouReceiptPrepareResponseEntityVo = qpService.consumeByUser(code, openShopUuid);
TuangouReceiptPrepareResponseEntityVo tuangouReceiptPrepareResponseEntityVo = qpService.consumeByUser(code, openShopUuid, ConsumerCouponStatusEnum.CONTROLLER.getCode());
if (ObjectUtils.isEmpty(tuangouReceiptPrepareResponseEntityVo)) {
return R.fail(tuangouReceiptPrepareResponseEntityVo, "该券码已被使用");
} else {
......
package share.system.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
/**
* 优惠卷操作日志对象 s_coupon_log
*
* @author wuwenlong
* @date 2024-01-06
*/
@Data
@TableName(value = "s_coupon_log")
public class CouponLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private Long id;
/**
* 优惠券码
*/
@Excel(name = "优惠券码")
private String code;
/**
* 用户ID
*/
@Excel(name = "用户ID")
private Long consumerId;
/**
* 门店ID
*/
@Excel(name = "门店ID")
private Long storeId;
/**
* 优惠券ID
*/
@Excel(name = "优惠券ID")
private Long couponId;
/**
* 优惠券名称
*/
@Excel(name = "优惠券名称")
private String couponName;
/**
* 优惠券类型
*/
@Excel(name = "优惠券类型")
private String couponType;
/**
* 优惠券面值
*/
@Excel(name = "优惠券面值")
private BigDecimal couponValue;
/**
* 状态
*/
@Excel(name = "状态")
private String status;
/**
* 消息
*/
@Excel(name = "消息")
private String message;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("code", getCode())
.append("consumerId", getConsumerId())
.append("storeId", getStoreId())
.append("couponId", getCouponId())
.append("couponName", getCouponName())
.append("couponType", getCouponType())
.append("couponValue", getCouponValue())
.append("status", getStatus())
.append("message", getMessage())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.CouponLog;
/**
* 优惠卷操作日志Mapper接口
*
* @author wuwenlong
* @date 2024-01-06
*/
public interface CouponLogMapper extends BaseMapper<CouponLog> {
/**
* 查询优惠卷操作日志
*
* @param id 优惠卷操作日志主键
* @return 优惠卷操作日志
*/
public CouponLog selectCouponLogById(Long id);
/**
* 查询优惠卷操作日志列表
*
* @param couponLog 优惠卷操作日志
* @return 优惠卷操作日志集合
*/
public List<CouponLog> selectCouponLogList(CouponLog couponLog);
/**
* 新增优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
public int insertCouponLog(CouponLog couponLog);
/**
* 修改优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
public int updateCouponLog(CouponLog couponLog);
/**
* 删除优惠卷操作日志
*
* @param id 优惠卷操作日志主键
* @return 结果
*/
public int deleteCouponLogById(Long id);
/**
* 批量删除优惠卷操作日志
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCouponLogByIds(Long[] ids);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.CouponLog;
/**
* 优惠卷操作日志Service接口
*
* @author wuwenlong
* @date 2024-01-06
*/
public interface CouponLogService extends IService<CouponLog> {
/**
* 查询优惠卷操作日志
*
* @param id 优惠卷操作日志主键
* @return 优惠卷操作日志
*/
public CouponLog selectCouponLogById(Long id);
/**
* 查询优惠卷操作日志列表
*
* @param couponLog 优惠卷操作日志
* @return 优惠卷操作日志集合
*/
public List<CouponLog> selectCouponLogList(CouponLog couponLog);
/**
* 新增优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
public int insertCouponLog(CouponLog couponLog);
/**
* 修改优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
public int updateCouponLog(CouponLog couponLog);
/**
* 批量删除优惠卷操作日志
*
* @param ids 需要删除的优惠卷操作日志主键集合
* @return 结果
*/
public int deleteCouponLogByIds(Long[] ids);
/**
* 删除优惠卷操作日志信息
*
* @param id 优惠卷操作日志主键
* @return 结果
*/
public int deleteCouponLogById(Long id);
}
......@@ -9,15 +9,15 @@ import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import java.util.List;
public interface QPService {
TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid);
TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid, String status);
List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid);
List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid, String status);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume(String code, Long appDealId, String openShopUuid);
TuangouReceiptGetConsumedReponseEntity getconsumed(String code, String openShopUuid);
TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid);
TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid, String status);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsumeByUser(Long id);
......
package share.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.mapper.CouponLogMapper;
import share.system.domain.CouponLog;
import share.system.service.CouponLogService;
/**
* 优惠卷操作日志Service业务层处理
*
* @author wuwenlong
* @date 2024-01-06
*/
@Service
public class CouponLogServiceImpl extends ServiceImpl<CouponLogMapper, CouponLog> implements CouponLogService {
@Autowired
private CouponLogMapper couponLogMapper;
/**
* 查询优惠卷操作日志
*
* @param id 优惠卷操作日志主键
* @return 优惠卷操作日志
*/
@Override
public CouponLog selectCouponLogById(Long id) {
return couponLogMapper.selectCouponLogById(id);
}
/**
* 查询优惠卷操作日志列表
*
* @param couponLog 优惠卷操作日志
* @return 优惠卷操作日志
*/
@Override
public List<CouponLog> selectCouponLogList(CouponLog couponLog) {
return couponLogMapper.selectCouponLogList(couponLog);
}
/**
* 新增优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
@Override
public int insertCouponLog(CouponLog couponLog) {
couponLog.setCreateTime(DateUtils.getNowDate());
return couponLogMapper.insertCouponLog(couponLog);
}
/**
* 修改优惠卷操作日志
*
* @param couponLog 优惠卷操作日志
* @return 结果
*/
@Override
public int updateCouponLog(CouponLog couponLog) {
couponLog.setUpdateTime(DateUtils.getNowDate());
return couponLogMapper.updateCouponLog(couponLog);
}
/**
* 批量删除优惠卷操作日志
*
* @param ids 需要删除的优惠卷操作日志主键
* @return 结果
*/
@Override
public int deleteCouponLogByIds(Long[] ids) {
return couponLogMapper.deleteCouponLogByIds(ids);
}
/**
* 删除优惠卷操作日志信息
*
* @param id 优惠卷操作日志主键
* @return 结果
*/
@Override
public int deleteCouponLogById(Long id) {
return couponLogMapper.deleteCouponLogById(id);
}
}
......@@ -79,9 +79,9 @@ public class QPServiceImpl implements QPService {
* 用户验卷接口
*/
@Override
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid) {
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid, String status) {
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code, openShopUuid);
TuangouReceiptPrepareResponseEntity prepare = prepare(code, openShopUuid, status);
//获取用户信息
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//查询领取记录表
......@@ -205,7 +205,7 @@ public class QPServiceImpl implements QPService {
* 根据团购券码,查询券码对应的dealid下,该用户可使用的券数据量
*/
@Override
public TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid) {
public TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid, String status) {
Boolean b = redisUtil.exists(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
if (Boolean.FALSE.equals(b)) {
throw new RuntimeException("请联系管理员");
......@@ -232,7 +232,7 @@ public class QPServiceImpl implements QPService {
* 根据团购券码,一次性验证同一订单下的若干团购券 同一个用户,同一个dealid下的券码
*/
@Override
public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid) {
public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid, String status) {
String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
logger.info("code:{}", code);
logger.info("验卷开始");
......
......@@ -329,7 +329,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (Objects.nonNull(request.getCouponId()) && request.getCouponId() != 0) {
SConsumerCoupon byId = consumerCouponService.getById(request.getCouponId());
//验劵
qpService.consume(byId.getCouponCode(), 1, sStore.getOpenShopUuid());
qpService.consume(byId.getCouponCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.ORDER.getCode());
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(request.getCouponId());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
......@@ -724,7 +724,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId);
if (ObjectUtil.isNotEmpty(consumerCoupon)) {
if (consumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
qpService.consume(consumerCoupon.getCouponCode(), 1, sStore.getOpenShopUuid());
qpService.consume(consumerCoupon.getCouponCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.WECHAT.getCode());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
}
......
package share.system.util;
import share.common.enums.AvailableEnum;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.utils.DateUtils;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent;
import share.system.request.CouponRequest;
import java.text.SimpleDateFormat;
import java.util.List;
public class CouponValidator {
private CouponRequest couponRequest;
private SConsumerCoupon sConsumerCoupon;
private List<SConsumerCoupon> sConsumerCoupons;
private List<SStore> sStores;
private List<SRoom> sRooms;
public CouponValidator(CouponRequest couponRequest, List<SConsumerCoupon> sConsumerCoupons, List<SStore> sStores, List<SRoom> sRooms) {
this.couponRequest = couponRequest;
this.sConsumerCoupons = sConsumerCoupons;
this.sStores = sStores;
this.sRooms = sRooms;
this.sConsumerCoupon = new SConsumerCoupon();
this.sConsumerCoupon.setUseStatus(ConsumerCouponUseStatusEnum.WAIT_USE.getCode());
this.sConsumerCoupon.setConsumerId(FrontTokenComponent.getWxSConsumerEntry().getId());
}
public void validate() {
for (SConsumerCoupon item : sConsumerCoupons) {
item.setIsAvailable(AvailableEnum.UNAVAILABLE.getCode()); // 默认不可用
item.setReason("无效的优惠券");
//验证有效时间
//验证有效时段
//验证优惠卷类型
//验证门槛金额
//验证门槛时长
//验证适用门店
//验证适用房间
}
}
}
<?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="share.system.mapper.CouponLogMapper">
<resultMap type="CouponLog" id="CouponLogResult">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="consumerId" column="consumer_id"/>
<result property="storeId" column="store_id"/>
<result property="couponId" column="coupon_id"/>
<result property="couponName" column="coupon_name"/>
<result property="couponType" column="coupon_type"/>
<result property="couponValue" column="coupon_value"/>
<result property="status" column="status"/>
<result property="message" column="message"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectCouponLogVo">
select id,
code,
consumer_id,
store_id,
coupon_id,
coupon_name,
coupon_type,
coupon_value,
status,
message,
create_by,
create_time,
update_by,
update_time,
remark
from s_coupon_log
</sql>
<select id="selectCouponLogList" parameterType="CouponLog" resultMap="CouponLogResult">
<include refid="selectCouponLogVo"/>
<where>
<if test="code != null and code != ''">and code = #{code}</if>
<if test="consumerId != null ">and consumer_id = #{consumerId}</if>
<if test="storeId != null ">and store_id = #{storeId}</if>
<if test="couponId != null ">and coupon_id = #{couponId}</if>
<if test="couponName != null and couponName != ''">and coupon_name like concat('%', #{couponName}, '%')
</if>
<if test="couponType != null and couponType != ''">and coupon_type = #{couponType}</if>
<if test="couponValue != null ">and coupon_value = #{couponValue}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="message != null and message != ''">and message = #{message}</if>
</where>
</select>
<select id="selectCouponLogById" parameterType="Long" resultMap="CouponLogResult">
<include refid="selectCouponLogVo"/>
where id = #{id}
</select>
<insert id="insertCouponLog" parameterType="CouponLog" useGeneratedKeys="true" keyProperty="id">
insert into s_coupon_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">code,</if>
<if test="consumerId != null">consumer_id,</if>
<if test="storeId != null">store_id,</if>
<if test="couponId != null">coupon_id,</if>
<if test="couponName != null and couponName != ''">coupon_name,</if>
<if test="couponType != null and couponType != ''">coupon_type,</if>
<if test="couponValue != null">coupon_value,</if>
<if test="status != null and status != ''">status,</if>
<if test="message != null and message != ''">message,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="consumerId != null">#{consumerId},</if>
<if test="storeId != null">#{storeId},</if>
<if test="couponId != null">#{couponId},</if>
<if test="couponName != null and couponName != ''">#{couponName},</if>
<if test="couponType != null and couponType != ''">#{couponType},</if>
<if test="couponValue != null">#{couponValue},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="message != null and message != ''">#{message},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCouponLog" parameterType="CouponLog">
update s_coupon_log
<trim prefix="SET" suffixOverrides=",">
<if test="code != null">code = #{code},</if>
<if test="consumerId != null">consumer_id = #{consumerId},</if>
<if test="storeId != null">store_id = #{storeId},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="couponName != null and couponName != ''">coupon_name = #{couponName},</if>
<if test="couponType != null and couponType != ''">coupon_type = #{couponType},</if>
<if test="couponValue != null">coupon_value = #{couponValue},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="message != null and message != ''">message = #{message},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCouponLogById" parameterType="Long">
delete
from s_coupon_log
where id = #{id}
</delete>
<delete id="deleteCouponLogByIds" parameterType="String">
delete from s_coupon_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment