Commit a831c948 authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-db, litemall-wx-api]: 字段调整,更新代码

parent bb48ab91
...@@ -68,6 +68,24 @@ public class LitemallCouponUser { ...@@ -68,6 +68,24 @@ public class LitemallCouponUser {
*/ */
private LocalDateTime usedTime; private LocalDateTime usedTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.start_time
*
* @mbg.generated
*/
private LocalDateTime startTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_coupon_user.end_time
*
* @mbg.generated
*/
private LocalDateTime endTime;
/** /**
* *
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
...@@ -224,6 +242,54 @@ public class LitemallCouponUser { ...@@ -224,6 +242,54 @@ public class LitemallCouponUser {
this.usedTime = usedTime; this.usedTime = usedTime;
} }
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.start_time
*
* @return the value of litemall_coupon_user.start_time
*
* @mbg.generated
*/
public LocalDateTime getStartTime() {
return startTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.start_time
*
* @param startTime the value for litemall_coupon_user.start_time
*
* @mbg.generated
*/
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.end_time
*
* @return the value of litemall_coupon_user.end_time
*
* @mbg.generated
*/
public LocalDateTime getEndTime() {
return endTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_coupon_user.end_time
*
* @param endTime the value for litemall_coupon_user.end_time
*
* @mbg.generated
*/
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_coupon_user.order_id * This method returns the value of the database column litemall_coupon_user.order_id
...@@ -337,6 +403,8 @@ public class LitemallCouponUser { ...@@ -337,6 +403,8 @@ public class LitemallCouponUser {
sb.append(", couponId=").append(couponId); sb.append(", couponId=").append(couponId);
sb.append(", status=").append(status); sb.append(", status=").append(status);
sb.append(", usedTime=").append(usedTime); sb.append(", usedTime=").append(usedTime);
sb.append(", startTime=").append(startTime);
sb.append(", endTime=").append(endTime);
sb.append(", orderId=").append(orderId); sb.append(", orderId=").append(orderId);
sb.append(", addTime=").append(addTime); sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
...@@ -368,6 +436,8 @@ public class LitemallCouponUser { ...@@ -368,6 +436,8 @@ public class LitemallCouponUser {
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getUsedTime() == null ? other.getUsedTime() == null : this.getUsedTime().equals(other.getUsedTime())) && (this.getUsedTime() == null ? other.getUsedTime() == null : this.getUsedTime().equals(other.getUsedTime()))
&& (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
&& (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime())) && (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
...@@ -389,6 +459,8 @@ public class LitemallCouponUser { ...@@ -389,6 +459,8 @@ public class LitemallCouponUser {
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getUsedTime() == null) ? 0 : getUsedTime().hashCode()); result = prime * result + ((getUsedTime() == null) ? 0 : getUsedTime().hashCode());
result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode()); result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
...@@ -420,6 +492,8 @@ public class LitemallCouponUser { ...@@ -420,6 +492,8 @@ public class LitemallCouponUser {
couponId("coupon_id", "couponId", "INTEGER", false), couponId("coupon_id", "couponId", "INTEGER", false),
status("status", "status", "SMALLINT", true), status("status", "status", "SMALLINT", true),
usedTime("used_time", "usedTime", "TIMESTAMP", false), usedTime("used_time", "usedTime", "TIMESTAMP", false),
startTime("start_time", "startTime", "TIMESTAMP", false),
endTime("end_time", "endTime", "TIMESTAMP", false),
orderId("order_id", "orderId", "INTEGER", false), orderId("order_id", "orderId", "INTEGER", false),
addTime("add_time", "addTime", "TIMESTAMP", false), addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false), updateTime("update_time", "updateTime", "TIMESTAMP", false),
......
...@@ -898,6 +898,270 @@ public class LitemallCouponUserExample { ...@@ -898,6 +898,270 @@ public class LitemallCouponUserExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andStartTimeIsNull() {
addCriterion("start_time is null");
return (Criteria) this;
}
public Criteria andStartTimeIsNotNull() {
addCriterion("start_time is not null");
return (Criteria) this;
}
public Criteria andStartTimeEqualTo(LocalDateTime value) {
addCriterion("start_time =", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeNotEqualTo(LocalDateTime value) {
addCriterion("start_time <>", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeNotEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeGreaterThan(LocalDateTime value) {
addCriterion("start_time >", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeGreaterThanColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("start_time >=", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeGreaterThanOrEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeLessThan(LocalDateTime value) {
addCriterion("start_time <", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeLessThanColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("start_time <=", value, "startTime");
return (Criteria) this;
}
/**
* 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 Criteria andStartTimeLessThanOrEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("start_time <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andStartTimeIn(List<LocalDateTime> values) {
addCriterion("start_time in", values, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeNotIn(List<LocalDateTime> values) {
addCriterion("start_time not in", values, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("start_time between", value1, value2, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("start_time not between", value1, value2, "startTime");
return (Criteria) this;
}
public Criteria andEndTimeIsNull() {
addCriterion("end_time is null");
return (Criteria) this;
}
public Criteria andEndTimeIsNotNull() {
addCriterion("end_time is not null");
return (Criteria) this;
}
public Criteria andEndTimeEqualTo(LocalDateTime value) {
addCriterion("end_time =", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeNotEqualTo(LocalDateTime value) {
addCriterion("end_time <>", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeNotEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeGreaterThan(LocalDateTime value) {
addCriterion("end_time >", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeGreaterThanColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeGreaterThanOrEqualTo(LocalDateTime value) {
addCriterion("end_time >=", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeGreaterThanOrEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeLessThan(LocalDateTime value) {
addCriterion("end_time <", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeLessThanColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeLessThanOrEqualTo(LocalDateTime value) {
addCriterion("end_time <=", value, "endTime");
return (Criteria) this;
}
/**
* 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 Criteria andEndTimeLessThanOrEqualToColumn(LitemallCouponUser.Column column) {
addCriterion(new StringBuilder("end_time <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andEndTimeIn(List<LocalDateTime> values) {
addCriterion("end_time in", values, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeNotIn(List<LocalDateTime> values) {
addCriterion("end_time not in", values, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("end_time between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andOrderIdIsNull() { public Criteria andOrderIdIsNull() {
addCriterion("order_id is null"); addCriterion("order_id is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -39,6 +39,16 @@ public class CouponAssignService { ...@@ -39,6 +39,16 @@ public class CouponAssignService {
LitemallCouponUser couponUser = new LitemallCouponUser(); LitemallCouponUser couponUser = new LitemallCouponUser();
couponUser.setCouponId(couponId); couponUser.setCouponId(couponId);
couponUser.setUserId(userId); couponUser.setUserId(userId);
Short timeType = coupon.getTimeType();
if (timeType.equals(CouponConstant.TIME_TYPE_TIME)) {
couponUser.setStartTime(coupon.getStartTime());
couponUser.setEndTime(coupon.getEndTime());
}
else{
LocalDateTime now = LocalDateTime.now();
couponUser.setStartTime(now);
couponUser.setEndTime(now.plusDays(coupon.getDays()));
}
couponUserService.add(couponUser); couponUserService.add(couponUser);
limit--; limit--;
......
...@@ -167,4 +167,16 @@ public class LitemallCouponService { ...@@ -167,4 +167,16 @@ public class LitemallCouponService {
} }
return code; return code;
} }
/**
* 查询过期的优惠券:
* 注意:如果timeType=0, 即基于领取时间有效期的优惠券,则优惠券不会过期
*
* @return
*/
public List<LitemallCoupon> queryExpired() {
LitemallCouponExample example = new LitemallCouponExample();
example.or().andStatusEqualTo(CouponConstant.STATUS_NORMAL).andTimeTypeEqualTo(CouponConstant.TIME_TYPE_TIME).andEndTimeLessThan(LocalDateTime.now()).andDeletedEqualTo(false);
return couponMapper.selectByExample(example);
}
} }
...@@ -111,4 +111,10 @@ public class LitemallCouponUserService { ...@@ -111,4 +111,10 @@ public class LitemallCouponUserService {
couponUser.setUpdateTime(LocalDateTime.now()); couponUser.setUpdateTime(LocalDateTime.now());
return couponUserMapper.updateByPrimaryKeySelective(couponUser); return couponUserMapper.updateByPrimaryKeySelective(couponUser);
} }
public List<LitemallCouponUser> queryExpired() {
LitemallCouponUserExample example = new LitemallCouponUserExample();
example.or().andStatusEqualTo(CouponUserConstant.STATUS_USABLE).andEndTimeLessThan(LocalDateTime.now()).andDeletedEqualTo(false);
return couponUserMapper.selectByExample(example);
}
} }
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<result column="coupon_id" jdbcType="INTEGER" property="couponId" /> <result column="coupon_id" jdbcType="INTEGER" property="couponId" />
<result column="status" jdbcType="SMALLINT" property="status" /> <result column="status" jdbcType="SMALLINT" property="status" />
<result column="used_time" jdbcType="TIMESTAMP" property="usedTime" /> <result column="used_time" jdbcType="TIMESTAMP" property="usedTime" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="order_id" jdbcType="INTEGER" property="orderId" /> <result column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" /> <result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
...@@ -87,7 +89,8 @@ ...@@ -87,7 +89,8 @@
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
id, user_id, coupon_id, `status`, used_time, order_id, add_time, update_time, deleted id, user_id, coupon_id, `status`, used_time, start_time, end_time, order_id, add_time,
update_time, deleted
</sql> </sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallCouponUserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallCouponUserExample" resultMap="BaseResultMap">
<!-- <!--
...@@ -124,8 +127,8 @@ ...@@ -124,8 +127,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coupon_id, `status`, used_time, order_id, add_time, update_time, deleted id, user_id, coupon_id, `status`, used_time, start_time, end_time, order_id, add_time,
update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_coupon_user from litemall_coupon_user
...@@ -184,8 +187,8 @@ ...@@ -184,8 +187,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coupon_id, `status`, used_time, order_id, add_time, update_time, deleted id, user_id, coupon_id, `status`, used_time, start_time, end_time, order_id, add_time,
update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_coupon_user from litemall_coupon_user
...@@ -218,11 +221,13 @@ ...@@ -218,11 +221,13 @@
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into litemall_coupon_user (user_id, coupon_id, `status`, insert into litemall_coupon_user (user_id, coupon_id, `status`,
used_time, order_id, add_time, used_time, start_time, end_time,
update_time, deleted) order_id, add_time, update_time,
deleted)
values (#{userId,jdbcType=INTEGER}, #{couponId,jdbcType=INTEGER}, #{status,jdbcType=SMALLINT}, values (#{userId,jdbcType=INTEGER}, #{couponId,jdbcType=INTEGER}, #{status,jdbcType=SMALLINT},
#{usedTime,jdbcType=TIMESTAMP}, #{orderId,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP}, #{usedTime,jdbcType=TIMESTAMP}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}) #{orderId,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallCouponUser"> <insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallCouponUser">
<!-- <!--
...@@ -246,6 +251,12 @@ ...@@ -246,6 +251,12 @@
<if test="usedTime != null"> <if test="usedTime != null">
used_time, used_time,
</if> </if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="orderId != null"> <if test="orderId != null">
order_id, order_id,
</if> </if>
...@@ -272,6 +283,12 @@ ...@@ -272,6 +283,12 @@
<if test="usedTime != null"> <if test="usedTime != null">
#{usedTime,jdbcType=TIMESTAMP}, #{usedTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="startTime != null">
#{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
<if test="orderId != null"> <if test="orderId != null">
#{orderId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER},
</if> </if>
...@@ -318,6 +335,12 @@ ...@@ -318,6 +335,12 @@
<if test="record.usedTime != null"> <if test="record.usedTime != null">
used_time = #{record.usedTime,jdbcType=TIMESTAMP}, used_time = #{record.usedTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.startTime != null">
start_time = #{record.startTime,jdbcType=TIMESTAMP},
</if>
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=TIMESTAMP},
</if>
<if test="record.orderId != null"> <if test="record.orderId != null">
order_id = #{record.orderId,jdbcType=INTEGER}, order_id = #{record.orderId,jdbcType=INTEGER},
</if> </if>
...@@ -346,6 +369,8 @@ ...@@ -346,6 +369,8 @@
coupon_id = #{record.couponId,jdbcType=INTEGER}, coupon_id = #{record.couponId,jdbcType=INTEGER},
`status` = #{record.status,jdbcType=SMALLINT}, `status` = #{record.status,jdbcType=SMALLINT},
used_time = #{record.usedTime,jdbcType=TIMESTAMP}, used_time = #{record.usedTime,jdbcType=TIMESTAMP},
start_time = #{record.startTime,jdbcType=TIMESTAMP},
end_time = #{record.endTime,jdbcType=TIMESTAMP},
order_id = #{record.orderId,jdbcType=INTEGER}, order_id = #{record.orderId,jdbcType=INTEGER},
add_time = #{record.addTime,jdbcType=TIMESTAMP}, add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
...@@ -373,6 +398,12 @@ ...@@ -373,6 +398,12 @@
<if test="usedTime != null"> <if test="usedTime != null">
used_time = #{usedTime,jdbcType=TIMESTAMP}, used_time = #{usedTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="orderId != null"> <if test="orderId != null">
order_id = #{orderId,jdbcType=INTEGER}, order_id = #{orderId,jdbcType=INTEGER},
</if> </if>
...@@ -398,6 +429,8 @@ ...@@ -398,6 +429,8 @@
coupon_id = #{couponId,jdbcType=INTEGER}, coupon_id = #{couponId,jdbcType=INTEGER},
`status` = #{status,jdbcType=SMALLINT}, `status` = #{status,jdbcType=SMALLINT},
used_time = #{usedTime,jdbcType=TIMESTAMP}, used_time = #{usedTime,jdbcType=TIMESTAMP},
start_time = #{startTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP},
order_id = #{orderId,jdbcType=INTEGER}, order_id = #{orderId,jdbcType=INTEGER},
add_time = #{addTime,jdbcType=TIMESTAMP}, add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
...@@ -435,8 +468,8 @@ ...@@ -435,8 +468,8 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coupon_id, `status`, used_time, order_id, add_time, update_time, deleted id, user_id, coupon_id, `status`, used_time, start_time, end_time, order_id, add_time,
update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from litemall_coupon_user from litemall_coupon_user
......
...@@ -113,16 +113,9 @@ public class WxCouponController { ...@@ -113,16 +113,9 @@ public class WxCouponController {
couponVo.setTag(coupon.getTag()); couponVo.setTag(coupon.getTag());
couponVo.setMin(coupon.getMin().toPlainString()); couponVo.setMin(coupon.getMin().toPlainString());
couponVo.setDiscount(coupon.getDiscount().toPlainString()); couponVo.setDiscount(coupon.getDiscount().toPlainString());
couponVo.setStartTime(couponUser.getStartTime());
couponVo.setEndTime(couponUser.getEndTime());
Short timeType = coupon.getTimeType();
if (timeType.equals(CouponConstant.TIME_TYPE_TIME)) {
couponVo.setStartTime(coupon.getStartTime());
couponVo.setEndTime(coupon.getEndTime());
}
else{
couponVo.setStartTime(coupon.getAddTime());
couponVo.setEndTime(coupon.getAddTime().plusDays(coupon.getDays()));
}
couponVoList.add(couponVo); couponVoList.add(couponVo);
} }
...@@ -252,7 +245,16 @@ public class WxCouponController { ...@@ -252,7 +245,16 @@ public class WxCouponController {
LitemallCouponUser couponUser = new LitemallCouponUser(); LitemallCouponUser couponUser = new LitemallCouponUser();
couponUser.setCouponId(couponId); couponUser.setCouponId(couponId);
couponUser.setUserId(userId); couponUser.setUserId(userId);
Short timeType = coupon.getTimeType();
if (timeType.equals(CouponConstant.TIME_TYPE_TIME)) {
couponUser.setStartTime(coupon.getStartTime());
couponUser.setEndTime(coupon.getEndTime());
}
else{
LocalDateTime now = LocalDateTime.now();
couponUser.setStartTime(now);
couponUser.setEndTime(now.plusDays(coupon.getDays()));
}
couponUserService.add(couponUser); couponUserService.add(couponUser);
return ResponseUtil.ok(); return ResponseUtil.ok();
...@@ -322,7 +324,16 @@ public class WxCouponController { ...@@ -322,7 +324,16 @@ public class WxCouponController {
LitemallCouponUser couponUser = new LitemallCouponUser(); LitemallCouponUser couponUser = new LitemallCouponUser();
couponUser.setCouponId(couponId); couponUser.setCouponId(couponId);
couponUser.setUserId(userId); couponUser.setUserId(userId);
Short timeType = coupon.getTimeType();
if (timeType.equals(CouponConstant.TIME_TYPE_TIME)) {
couponUser.setStartTime(coupon.getStartTime());
couponUser.setEndTime(coupon.getEndTime());
}
else{
LocalDateTime now = LocalDateTime.now();
couponUser.setStartTime(now);
couponUser.setEndTime(now.plusDays(coupon.getDays()));
}
couponUserService.add(couponUser); couponUserService.add(couponUser);
return ResponseUtil.ok(); return ResponseUtil.ok();
......
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