Commit 80ffb92f authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-db, litemall-wx-api]: 小商城后端支持优惠券

parent d5abf50c
......@@ -158,5 +158,11 @@
<table tableName="litemall_groupon">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_coupon">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_coupon_user">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallCoupon;
import org.linlinjava.litemall.db.domain.LitemallCouponExample;
public interface LitemallCouponMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
long countByExample(LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int deleteByExample(LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int insert(LitemallCoupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int insertSelective(LitemallCoupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCoupon selectOneByExample(LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCoupon selectOneByExampleSelective(@Param("example") LitemallCouponExample example, @Param("selective") LitemallCoupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallCoupon> selectByExampleSelective(@Param("example") LitemallCouponExample example, @Param("selective") LitemallCoupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
List<LitemallCoupon> selectByExample(LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCoupon selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallCoupon.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
LitemallCoupon selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCoupon selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallCoupon record, @Param("example") LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallCoupon record, @Param("example") LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallCoupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallCoupon record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallCouponExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallCouponUser;
import org.linlinjava.litemall.db.domain.LitemallCouponUserExample;
public interface LitemallCouponUserMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
long countByExample(LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int deleteByExample(LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int insert(LitemallCouponUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int insertSelective(LitemallCouponUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCouponUser selectOneByExample(LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCouponUser selectOneByExampleSelective(@Param("example") LitemallCouponUserExample example, @Param("selective") LitemallCouponUser.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallCouponUser> selectByExampleSelective(@Param("example") LitemallCouponUserExample example, @Param("selective") LitemallCouponUser.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
List<LitemallCouponUser> selectByExample(LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCouponUser selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallCouponUser.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
LitemallCouponUser selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallCouponUser selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallCouponUser record, @Param("example") LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallCouponUser record, @Param("example") LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallCouponUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallCouponUser record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallCouponUserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
package org.linlinjava.litemall.db.domain;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
public class LitemallCouponUser {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean NOT_DELETED = false;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static final Boolean IS_DELETED = true;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.user_id
*
* @mbg.generated
*/
private Integer userId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.coupon_id
*
* @mbg.generated
*/
private Integer couponId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.status
*
* @mbg.generated
*/
private Short status;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.used_time
*
* @mbg.generated
*/
private LocalDateTime usedTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.order_id
*
* @mbg.generated
*/
private Integer orderId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.add_time
*
* @mbg.generated
*/
private LocalDateTime addTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.update_time
*
* @mbg.generated
*/
private LocalDateTime updateTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.deleted
*
* @mbg.generated
*/
private Boolean deleted;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.id
*
* @return the value of litemall_coupon_user.id
*
* @mbg.generated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.id
*
* @param id the value for litemall_coupon_user.id
*
* @mbg.generated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.user_id
*
* @return the value of litemall_coupon_user.user_id
*
* @mbg.generated
*/
public Integer getUserId() {
return userId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.user_id
*
* @param userId the value for litemall_coupon_user.user_id
*
* @mbg.generated
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.coupon_id
*
* @return the value of litemall_coupon_user.coupon_id
*
* @mbg.generated
*/
public Integer getCouponId() {
return couponId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.coupon_id
*
* @param couponId the value for litemall_coupon_user.coupon_id
*
* @mbg.generated
*/
public void setCouponId(Integer couponId) {
this.couponId = couponId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.status
*
* @return the value of litemall_coupon_user.status
*
* @mbg.generated
*/
public Short getStatus() {
return status;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.status
*
* @param status the value for litemall_coupon_user.status
*
* @mbg.generated
*/
public void setStatus(Short status) {
this.status = status;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.used_time
*
* @return the value of litemall_coupon_user.used_time
*
* @mbg.generated
*/
public LocalDateTime getUsedTime() {
return usedTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.used_time
*
* @param usedTime the value for litemall_coupon_user.used_time
*
* @mbg.generated
*/
public void setUsedTime(LocalDateTime usedTime) {
this.usedTime = usedTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.order_id
*
* @return the value of litemall_coupon_user.order_id
*
* @mbg.generated
*/
public Integer getOrderId() {
return orderId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.order_id
*
* @param orderId the value for litemall_coupon_user.order_id
*
* @mbg.generated
*/
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.add_time
*
* @return the value of litemall_coupon_user.add_time
*
* @mbg.generated
*/
public LocalDateTime getAddTime() {
return addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.add_time
*
* @param addTime the value for litemall_coupon_user.add_time
*
* @mbg.generated
*/
public void setAddTime(LocalDateTime addTime) {
this.addTime = addTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.update_time
*
* @return the value of litemall_coupon_user.update_time
*
* @mbg.generated
*/
public LocalDateTime getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.update_time
*
* @param updateTime the value for litemall_coupon_user.update_time
*
* @mbg.generated
*/
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.deleted
*
* @return the value of litemall_coupon_user.deleted
*
* @mbg.generated
*/
public Boolean getDeleted() {
return deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.deleted
*
* @param deleted the value for litemall_coupon_user.deleted
*
* @mbg.generated
*/
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", couponId=").append(couponId);
sb.append(", status=").append(status);
sb.append(", usedTime=").append(usedTime);
sb.append(", orderId=").append(orderId);
sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", deleted=").append(deleted);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
LitemallCouponUser other = (LitemallCouponUser) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getUsedTime() == null ? other.getUsedTime() == null : this.getUsedTime().equals(other.getUsedTime()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getUsedTime() == null) ? 0 : getUsedTime().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
return result;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public void andLogicalDeleted(boolean deleted) {
setDeleted(deleted ? IS_DELETED : NOT_DELETED);
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER", false),
userId("user_id", "userId", "INTEGER", false),
couponId("coupon_id", "couponId", "INTEGER", false),
status("status", "status", "SMALLINT", true),
usedTime("used_time", "usedTime", "TIMESTAMP", false),
orderId("order_id", "orderId", "INTEGER", false),
addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
deleted("deleted", "deleted", "BIT", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_coupon_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package org.linlinjava.litemall.db.service;
import org.linlinjava.litemall.db.domain.LitemallCoupon;
import org.linlinjava.litemall.db.domain.LitemallCouponUser;
import org.linlinjava.litemall.db.util.CouponConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class CouponAssignService {
@Autowired
private LitemallCouponUserService couponUserService;
@Autowired
private LitemallCouponService couponService;
/**
* 分发注册优惠券
*
* @param userId
* @return
*/
public void assignForRegister(Integer userId) {
List<LitemallCoupon> couponList = couponService.queryRegister();
for(LitemallCoupon coupon : couponList){
Integer couponId = coupon.getId();
Integer count = couponUserService.countUserAndCoupon(userId, couponId);
if (count > 0) {
continue;
}
Short limit = coupon.getLimit();
while(limit > 0){
LitemallCouponUser couponUser = new LitemallCouponUser();
couponUser.setCouponId(couponId);
couponUser.setUserId(userId);
couponUserService.add(couponUser);
limit--;
}
}
}
}
\ No newline at end of file
package org.linlinjava.litemall.db.service;
import org.linlinjava.litemall.db.domain.LitemallCoupon;
import org.linlinjava.litemall.db.domain.LitemallCouponUser;
import org.linlinjava.litemall.db.util.CouponConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Service
public class CouponVerifyService {
@Autowired
private LitemallCouponUserService couponUserService;
@Autowired
private LitemallCouponService couponService;
/**
* 检测优惠券是否适合
*
* @param userId
* @param couponId
* @param checkedGoodsPrice
* @return
*/
public LitemallCoupon checkCoupon(Integer userId, Integer couponId, BigDecimal checkedGoodsPrice) {
LitemallCoupon coupon = couponService.findById(couponId);
LitemallCouponUser couponUser = couponUserService.queryOne(userId, couponId);
if (coupon == null || couponUser == null) {
return null;
}
// 检查是否超期
Short days = coupon.getDays();
LocalDateTime now = LocalDateTime.now();
if (days == 0) {
if (now.isBefore(coupon.getStartTime()) || now.isAfter(coupon.getEndTime())) {
return null;
}
} else {
LocalDateTime expired = couponUser.getAddTime().plusDays(days);
if (now.isAfter(expired)) {
return null;
}
}
// 检测商品是否符合
// TODO 目前仅支持全平台商品,所以不需要检测
Short goodType = coupon.getGoodsType();
if (!goodType.equals(CouponConstant.GOODS_TYPE_ALL)) {
return null;
}
// 检测订单状态
Short status = coupon.getStatus();
if (!status.equals(CouponConstant.STATUS_NORMAL)) {
return null;
}
// 检测是否满足最低消费
if (checkedGoodsPrice.compareTo(coupon.getMin()) == -1) {
return null;
}
return coupon;
}
}
\ No newline at end of file
......@@ -75,5 +75,4 @@ public class LitemallAdminService {
public LitemallAdmin findById(Integer id) {
return adminMapper.selectByPrimaryKeySelective(id, result);
}
}
package org.linlinjava.litemall.db.service;
import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallCouponMapper;
import org.linlinjava.litemall.db.domain.LitemallCoupon;
import org.linlinjava.litemall.db.domain.LitemallCoupon.Column;
import org.linlinjava.litemall.db.domain.LitemallCouponExample;
import org.linlinjava.litemall.db.domain.LitemallCouponUser;
import org.linlinjava.litemall.db.util.CouponConstant;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class LitemallCouponService {
@Resource
private LitemallCouponMapper couponMapper;
private Column[] result = new Column[]{Column.id, Column.name, Column.desc, Column.tag,
Column.days, Column.startTime, Column.endTime,
Column.discount, Column.min};
/**
* 查询
*
* @param offset
* @param limit
* @param sort
* @param order
* @return
*/
public List<LitemallCoupon> queryList(int offset, int limit, String sort, String order) {
LitemallCouponExample example = new LitemallCouponExample();
example.or().andTypeEqualTo(CouponConstant.TYPE_COMMON).andStatusEqualTo(CouponConstant.STATUS_NORMAL).andDeletedEqualTo(false);
example.setOrderByClause(sort + " " + order);
PageHelper.startPage(offset, limit);
return couponMapper.selectByExampleSelective(example, result);
}
public int queryTotal() {
LitemallCouponExample example = new LitemallCouponExample();
example.or().andTypeEqualTo(CouponConstant.TYPE_COMMON).andStatusEqualTo(CouponConstant.STATUS_NORMAL).andDeletedEqualTo(false);
return (int) couponMapper.countByExample(example);
}
public List<LitemallCoupon> queryList(int offset, int limit) {
return queryList(offset, limit, "add_time", "desc");
}
public LitemallCoupon findById(Integer id) {
return couponMapper.selectByPrimaryKey(id);
}
/**
* 查询新用户注册优惠券
*
* @return
*/
public List<LitemallCoupon> queryRegister() {
LitemallCouponExample example = new LitemallCouponExample();
example.or().andTypeEqualTo(CouponConstant.TYPE_REGISTER).andStatusEqualTo(CouponConstant.STATUS_NORMAL).andDeletedEqualTo(false);
return couponMapper.selectByExample(example);
}
}
package org.linlinjava.litemall.db.service;
import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.LitemallCouponUserMapper;
import org.linlinjava.litemall.db.domain.LitemallCouponUser;
import org.linlinjava.litemall.db.domain.LitemallCouponUserExample;
import org.linlinjava.litemall.db.util.CouponUserConstant;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class LitemallCouponUserService {
@Resource
private LitemallCouponUserMapper couponUserMapper;
public Integer countCoupon(Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public Integer countUserAndCoupon(Integer userId, Integer couponId) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId).andDeletedEqualTo(false);
return (int)couponUserMapper.countByExample(example);
}
public void add(LitemallCouponUser couponUser) {
couponUser.setAddTime(LocalDateTime.now());
couponUser.setUpdateTime(LocalDateTime.now());
couponUserMapper.insertSelective(couponUser);
}
public List<LitemallCouponUser> queryList(Integer userId, Integer couponId, Short status, Integer page, Integer size, String sort, String order) {
LitemallCouponUserExample example = new LitemallCouponUserExample();
LitemallCouponUserExample.Criteria criteria = example.createCriteria();
if (userId != null) {
criteria.andUserIdEqualTo(userId);
}
if(couponId != null){
criteria.andCouponIdEqualTo(couponId);
}
if (status != null) {
criteria.andStatusEqualTo(status);
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
}
if (!StringUtils.isEmpty(page) && !StringUtils.isEmpty(size)) {
PageHelper.startPage(page, size);
}
return couponUserMapper.selectByExample(example);
}
public List<LitemallCouponUser> queryAll(Integer userId, Integer couponId) {
return queryList(userId, couponId, CouponUserConstant.STATUS_USABLE, null, null, "add_time", "desc");
}
public List<LitemallCouponUser> queryAll(Integer userId) {
return queryList(userId, null, CouponUserConstant.STATUS_USABLE, null, null, "add_time", "desc");
}
public LitemallCouponUser queryOne(Integer userId, Integer couponId) {
List<LitemallCouponUser> couponUserList = queryList(userId, couponId, CouponUserConstant.STATUS_USABLE, 1, 1, "add_time", "desc");
if(couponUserList.size() == 0){
return null;
}
return couponUserList.get(0);
}
public LitemallCouponUser findById(Integer id) {
return couponUserMapper.selectByPrimaryKey(id);
}
public int update(LitemallCouponUser couponUser) {
couponUser.setUpdateTime(LocalDateTime.now());
return couponUserMapper.updateByPrimaryKeySelective(couponUser);
}
}
package org.linlinjava.litemall.db.util;
public class CouponConstant {
public static final Short TYPE_COMMON = 0;
public static final Short TYPE_REGISTER = 1;
public static final Short GOODS_TYPE_ALL = 0;
public static final Short GOODS_TYPE_CATEGORY = 1;
public static final Short GOODS_TYPE_ARRAY = 2;
public static final Short STATUS_NORMAL = 0;
public static final Short STATUS_EXPIRED = 1;
public static final Short STATUS_OUT = 2;
}
package org.linlinjava.litemall.db.util;
public class CouponUserConstant {
public static final Short STATUS_USABLE = 0;
public static final Short STATUS_USED = 1;
public static final Short STATUS_EXPIRED = 2;
public static final Short STATUS_OUT = 3;
}
......@@ -28,4 +28,8 @@ public class WxResponseCode {
public static final Integer ORDER_COMMENT_EXPIRED = 727;
public static final Integer GROUPON_EXPIRED = 730;
public static final int COUPON_EXCEED_LIMIT = 740;
public static final int COUPON_RECEIVE_FAIL= 741;
}
Supports Markdown
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