Commit 11a95ac7 authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-db]: 订单表增加售后状态字段

parent 62921c2e
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -106,7 +106,7 @@ CREATE TABLE `litemall_aftersale` (
`amount` decimal(10,2) DEFAULT '0.00' COMMENT '退款金额',
`pictures` varchar(1023) DEFAULT '[]' COMMENT '退款凭证图片链接数组',
`comment` varchar(511) DEFAULT '' COMMENT '退款说明',
`status` smallint(6) DEFAULT '0' COMMENT '状态,0是用户初始申请,1是管理员接收申请处理中,2是管理员处理成功完成申请,3是管理员拒绝申请',
`status` smallint(6) DEFAULT '0' COMMENT '售后状态,0是申请,1是用户已申请,2是管理员审核通过,3是管理员退款成功,4是管理员审核拒绝,5是用户已取消',
`handle_time` datetime DEFAULT NULL COMMENT '管理员操作时间',
`add_time` datetime DEFAULT NULL COMMENT '添加时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
......@@ -593,6 +593,7 @@ CREATE TABLE `litemall_order` (
`user_id` int(11) NOT NULL COMMENT '用户表的用户ID',
`order_sn` varchar(63) NOT NULL COMMENT '订单编号',
`order_status` smallint(6) NOT NULL COMMENT '订单状态',
`aftersale_status` smallint(6) DEFAULT '0' COMMENT '售后状态,0是可申请,1是用户已申请,2是管理员审核通过,3是管理员退款成功,4是管理员审核拒绝,5是用户已取消',
`consignee` varchar(63) NOT NULL COMMENT '收货人名称',
`mobile` varchar(63) NOT NULL COMMENT '收货人手机号',
`address` varchar(127) NOT NULL COMMENT '收货具体地址',
......
......@@ -58,6 +58,15 @@ public class LitemallOrder {
*/
private Short orderStatus;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_order.aftersale_status
*
* @mbg.generated
*/
private Short aftersaleStatus;
/**
*
* This field was generated by MyBatis Generator.
......@@ -388,6 +397,30 @@ public class LitemallOrder {
this.orderStatus = orderStatus;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.aftersale_status
*
* @return the value of litemall_order.aftersale_status
*
* @mbg.generated
*/
public Short getAftersaleStatus() {
return aftersaleStatus;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_order.aftersale_status
*
* @param aftersaleStatus the value for litemall_order.aftersale_status
*
* @mbg.generated
*/
public void setAftersaleStatus(Short aftersaleStatus) {
this.aftersaleStatus = aftersaleStatus;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_order.consignee
......@@ -1040,6 +1073,7 @@ public class LitemallOrder {
sb.append(", userId=").append(userId);
sb.append(", orderSn=").append(orderSn);
sb.append(", orderStatus=").append(orderStatus);
sb.append(", aftersaleStatus=").append(aftersaleStatus);
sb.append(", consignee=").append(consignee);
sb.append(", mobile=").append(mobile);
sb.append(", address=").append(address);
......@@ -1092,6 +1126,7 @@ public class LitemallOrder {
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getOrderSn() == null ? other.getOrderSn() == null : this.getOrderSn().equals(other.getOrderSn()))
&& (this.getOrderStatus() == null ? other.getOrderStatus() == null : this.getOrderStatus().equals(other.getOrderStatus()))
&& (this.getAftersaleStatus() == null ? other.getAftersaleStatus() == null : this.getAftersaleStatus().equals(other.getAftersaleStatus()))
&& (this.getConsignee() == null ? other.getConsignee() == null : this.getConsignee().equals(other.getConsignee()))
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
&& (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress()))
......@@ -1134,6 +1169,7 @@ public class LitemallOrder {
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getOrderSn() == null) ? 0 : getOrderSn().hashCode());
result = prime * result + ((getOrderStatus() == null) ? 0 : getOrderStatus().hashCode());
result = prime * result + ((getAftersaleStatus() == null) ? 0 : getAftersaleStatus().hashCode());
result = prime * result + ((getConsignee() == null) ? 0 : getConsignee().hashCode());
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode());
......@@ -1242,6 +1278,7 @@ public class LitemallOrder {
userId("user_id", "userId", "INTEGER", false),
orderSn("order_sn", "orderSn", "VARCHAR", false),
orderStatus("order_status", "orderStatus", "SMALLINT", false),
aftersaleStatus("aftersale_status", "aftersaleStatus", "SMALLINT", false),
consignee("consignee", "consignee", "VARCHAR", false),
mobile("mobile", "mobile", "VARCHAR", false),
address("address", "address", "VARCHAR", false),
......
......@@ -778,6 +778,132 @@ public class LitemallOrderExample {
return (Criteria) this;
}
public Criteria andAftersaleStatusIsNull() {
addCriterion("aftersale_status is null");
return (Criteria) this;
}
public Criteria andAftersaleStatusIsNotNull() {
addCriterion("aftersale_status is not null");
return (Criteria) this;
}
public Criteria andAftersaleStatusEqualTo(Short value) {
addCriterion("aftersale_status =", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusEqualToColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusNotEqualTo(Short value) {
addCriterion("aftersale_status <>", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusNotEqualToColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusGreaterThan(Short value) {
addCriterion("aftersale_status >", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusGreaterThanColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusGreaterThanOrEqualTo(Short value) {
addCriterion("aftersale_status >=", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusGreaterThanOrEqualToColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusLessThan(Short value) {
addCriterion("aftersale_status <", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusLessThanColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusLessThanOrEqualTo(Short value) {
addCriterion("aftersale_status <=", value, "aftersaleStatus");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_order
*
* @mbg.generated
*/
public Criteria andAftersaleStatusLessThanOrEqualToColumn(LitemallOrder.Column column) {
addCriterion(new StringBuilder("aftersale_status <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAftersaleStatusIn(List<Short> values) {
addCriterion("aftersale_status in", values, "aftersaleStatus");
return (Criteria) this;
}
public Criteria andAftersaleStatusNotIn(List<Short> values) {
addCriterion("aftersale_status not in", values, "aftersaleStatus");
return (Criteria) this;
}
public Criteria andAftersaleStatusBetween(Short value1, Short value2) {
addCriterion("aftersale_status between", value1, value2, "aftersaleStatus");
return (Criteria) this;
}
public Criteria andAftersaleStatusNotBetween(Short value1, Short value2) {
addCriterion("aftersale_status not between", value1, value2, "aftersaleStatus");
return (Criteria) this;
}
public Criteria andConsigneeIsNull() {
addCriterion("consignee is null");
return (Criteria) this;
......
......@@ -39,8 +39,10 @@ public class LitemallAddressService {
return addressMapper.updateByPrimaryKeySelective(address);
}
public void delete(Integer id) {
addressMapper.logicalDeleteByPrimaryKey(id);
public void delete(Integer userId, Integer id) {
LitemallAddressExample example = new LitemallAddressExample();
example.or().andUserIdEqualTo(userId).andIdEqualTo(id).andDeletedEqualTo(false);
addressMapper.logicalDeleteByExample(example);
}
public LitemallAddress findDefault(Integer userId) {
......
......@@ -42,7 +42,7 @@ public class LitemallAftersaleService {
return aftersaleMapper.selectByExample(example);
}
public List<LitemallAftersale> querySelective(Integer orderId, String aftersaleSn, Integer page, Integer limit, String sort, String order) {
public List<LitemallAftersale> querySelective(Integer orderId, String aftersaleSn, Short status, Integer page, Integer limit, String sort, String order) {
LitemallAftersaleExample example = new LitemallAftersaleExample();
LitemallAftersaleExample.Criteria criteria = example.or();
if (orderId != null) {
......@@ -51,6 +51,9 @@ public class LitemallAftersaleService {
if (!StringUtils.isEmpty(aftersaleSn)) {
criteria.andAftersaleSnEqualTo(aftersaleSn);
}
if (status != null) {
criteria.andStatusEqualTo(status);
}
criteria.andDeletedEqualTo(false);
if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
example.setOrderByClause(sort + " " + order);
......@@ -80,12 +83,6 @@ public class LitemallAftersaleService {
return (int) aftersaleMapper.countByExample(example);
}
public int countByOrderIdWithoutReject(Integer userId, Integer orderId) {
LitemallAftersaleExample example = new LitemallAftersaleExample();
example.or().andUserIdEqualTo(userId).andOrderIdEqualTo(orderId).andStatusNotEqualTo(AftersaleConstant.STATUS_REJECT).andDeletedEqualTo(false);
return (int) aftersaleMapper.countByExample(example);
}
// TODO 这里应该产生一个唯一的编号,但是实际上这里仍然存在两个售后编号相同的可能性
public String generateAftersaleSn(Integer userId) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
......@@ -115,4 +112,24 @@ public class LitemallAftersaleService {
public void deleteById(Integer id) {
aftersaleMapper.logicalDeleteByPrimaryKey(id);
}
public void deleteByOrderId(Integer userId, Integer orderId) {
LitemallAftersaleExample example = new LitemallAftersaleExample();
example.or().andOrderIdEqualTo(orderId).andUserIdEqualTo(userId).andDeletedEqualTo(false);
LitemallAftersale aftersale = new LitemallAftersale();
aftersale.setUpdateTime(LocalDateTime.now());
aftersale.setDeleted(true);
aftersaleMapper.updateByExampleSelective(aftersale, example);
}
public void updateById(LitemallAftersale aftersale) {
aftersale.setUpdateTime(LocalDateTime.now());
aftersaleMapper.updateByPrimaryKeySelective(aftersale);
}
public LitemallAftersale findByOrderId(Integer userId, Integer orderId) {
LitemallAftersaleExample example = new LitemallAftersaleExample();
example.or().andOrderIdEqualTo(orderId).andUserIdEqualTo(userId).andDeletedEqualTo(false);
return aftersaleMapper.selectOneByExample(example);
}
}
......@@ -41,6 +41,12 @@ public class LitemallOrderService {
return litemallOrderMapper.selectByPrimaryKey(orderId);
}
public LitemallOrder findById(Integer userId, Integer orderId) {
LitemallOrderExample example = new LitemallOrderExample();
example.or().andIdEqualTo(orderId).andUserIdEqualTo(userId).andDeletedEqualTo(false);
return litemallOrderMapper.selectOneByExample(example);
}
private String getRandomNum(Integer num) {
String base = "0123456789";
Random random = new Random();
......@@ -184,4 +190,12 @@ public class LitemallOrderService {
example.or().andCommentsGreaterThan((short) 0).andConfirmTimeLessThan(expired).andDeletedEqualTo(false);
return litemallOrderMapper.selectByExample(example);
}
public void updateAftersaleStatus(Integer orderId, Short statusReject) {
LitemallOrder order = new LitemallOrder();
order.setId(orderId);
order.setAftersaleStatus(statusReject);
order.setUpdateTime(LocalDateTime.now());
litemallOrderMapper.updateByPrimaryKeySelective(order);
}
}
package org.linlinjava.litemall.db.util;
public class AftersaleConstant {
public static final Short STATUS_REQUEST = 0;
public static final Short STATUS_HANDLE = 1;
public static final Short STATUS_FINISH = 2;
public static final Short STATUS_REJECT = 3;
public static final Short STATUS_INIT = 0;
public static final Short STATUS_REQUEST = 1;
public static final Short STATUS_RECEPT = 2;
public static final Short STATUS_REFUND = 3;
public static final Short STATUS_REJECT = 4;
public static final Short STATUS_CANCEL = 5;
public static final Short TYPE_GOODS_MISS = 0;
public static final Short TYPE_GOODS_NEEDLESS = 1;
public static final Short TYPE_GOODS_REQUIRED = 2;
}
......@@ -10,6 +10,7 @@
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="order_sn" jdbcType="VARCHAR" property="orderSn" />
<result column="order_status" jdbcType="SMALLINT" property="orderStatus" />
<result column="aftersale_status" jdbcType="SMALLINT" property="aftersaleStatus" />
<result column="consignee" jdbcType="VARCHAR" property="consignee" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="address" jdbcType="VARCHAR" property="address" />
......@@ -108,10 +109,11 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, order_sn, order_status, consignee, mobile, address, message, goods_price,
freight_price, coupon_price, integral_price, groupon_price, order_price, actual_price,
pay_id, pay_time, ship_sn, ship_channel, ship_time, refund_amount, refund_type, refund_content,
refund_time, confirm_time, comments, end_time, add_time, update_time, deleted
id, user_id, order_sn, order_status, aftersale_status, consignee, mobile, address,
message, goods_price, freight_price, coupon_price, integral_price, groupon_price,
order_price, actual_price, pay_id, pay_time, ship_sn, ship_channel, ship_time, refund_amount,
refund_type, refund_content, refund_time, confirm_time, comments, end_time, add_time,
update_time, deleted
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallOrderExample" resultMap="BaseResultMap">
<!--
......@@ -233,25 +235,27 @@
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_order (user_id, order_sn, order_status,
consignee, mobile, address,
message, goods_price, freight_price,
coupon_price, integral_price, groupon_price,
order_price, actual_price, pay_id,
pay_time, ship_sn, ship_channel,
ship_time, refund_amount, refund_type,
refund_content, refund_time, confirm_time,
comments, end_time, add_time,
update_time, deleted)
aftersale_status, consignee, mobile,
address, message, goods_price,
freight_price, coupon_price, integral_price,
groupon_price, order_price, actual_price,
pay_id, pay_time, ship_sn,
ship_channel, ship_time, refund_amount,
refund_type, refund_content, refund_time,
confirm_time, comments, end_time,
add_time, update_time, deleted
)
values (#{userId,jdbcType=INTEGER}, #{orderSn,jdbcType=VARCHAR}, #{orderStatus,jdbcType=SMALLINT},
#{consignee,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR}, #{goodsPrice,jdbcType=DECIMAL}, #{freightPrice,jdbcType=DECIMAL},
#{couponPrice,jdbcType=DECIMAL}, #{integralPrice,jdbcType=DECIMAL}, #{grouponPrice,jdbcType=DECIMAL},
#{orderPrice,jdbcType=DECIMAL}, #{actualPrice,jdbcType=DECIMAL}, #{payId,jdbcType=VARCHAR},
#{payTime,jdbcType=TIMESTAMP}, #{shipSn,jdbcType=VARCHAR}, #{shipChannel,jdbcType=VARCHAR},
#{shipTime,jdbcType=TIMESTAMP}, #{refundAmount,jdbcType=DECIMAL}, #{refundType,jdbcType=VARCHAR},
#{refundContent,jdbcType=VARCHAR}, #{refundTime,jdbcType=TIMESTAMP}, #{confirmTime,jdbcType=TIMESTAMP},
#{comments,jdbcType=SMALLINT}, #{endTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT})
#{aftersaleStatus,jdbcType=SMALLINT}, #{consignee,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{address,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR}, #{goodsPrice,jdbcType=DECIMAL},
#{freightPrice,jdbcType=DECIMAL}, #{couponPrice,jdbcType=DECIMAL}, #{integralPrice,jdbcType=DECIMAL},
#{grouponPrice,jdbcType=DECIMAL}, #{orderPrice,jdbcType=DECIMAL}, #{actualPrice,jdbcType=DECIMAL},
#{payId,jdbcType=VARCHAR}, #{payTime,jdbcType=TIMESTAMP}, #{shipSn,jdbcType=VARCHAR},
#{shipChannel,jdbcType=VARCHAR}, #{shipTime,jdbcType=TIMESTAMP}, #{refundAmount,jdbcType=DECIMAL},
#{refundType,jdbcType=VARCHAR}, #{refundContent,jdbcType=VARCHAR}, #{refundTime,jdbcType=TIMESTAMP},
#{confirmTime,jdbcType=TIMESTAMP}, #{comments,jdbcType=SMALLINT}, #{endTime,jdbcType=TIMESTAMP},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}
)
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallOrder">
<!--
......@@ -272,6 +276,9 @@
<if test="orderStatus != null">
order_status,
</if>
<if test="aftersaleStatus != null">
aftersale_status,
</if>
<if test="consignee != null">
consignee,
</if>
......@@ -361,6 +368,9 @@
<if test="orderStatus != null">
#{orderStatus,jdbcType=SMALLINT},
</if>
<if test="aftersaleStatus != null">
#{aftersaleStatus,jdbcType=SMALLINT},
</if>
<if test="consignee != null">
#{consignee,jdbcType=VARCHAR},
</if>
......@@ -470,6 +480,9 @@
<if test="record.orderStatus != null">
order_status = #{record.orderStatus,jdbcType=SMALLINT},
</if>
<if test="record.aftersaleStatus != null">
aftersale_status = #{record.aftersaleStatus,jdbcType=SMALLINT},
</if>
<if test="record.consignee != null">
consignee = #{record.consignee,jdbcType=VARCHAR},
</if>
......@@ -563,6 +576,7 @@
user_id = #{record.userId,jdbcType=INTEGER},
order_sn = #{record.orderSn,jdbcType=VARCHAR},
order_status = #{record.orderStatus,jdbcType=SMALLINT},
aftersale_status = #{record.aftersaleStatus,jdbcType=SMALLINT},
consignee = #{record.consignee,jdbcType=VARCHAR},
mobile = #{record.mobile,jdbcType=VARCHAR},
address = #{record.address,jdbcType=VARCHAR},
......@@ -609,6 +623,9 @@
<if test="orderStatus != null">
order_status = #{orderStatus,jdbcType=SMALLINT},
</if>
<if test="aftersaleStatus != null">
aftersale_status = #{aftersaleStatus,jdbcType=SMALLINT},
</if>
<if test="consignee != null">
consignee = #{consignee,jdbcType=VARCHAR},
</if>
......@@ -699,6 +716,7 @@
set user_id = #{userId,jdbcType=INTEGER},
order_sn = #{orderSn,jdbcType=VARCHAR},
order_status = #{orderStatus,jdbcType=SMALLINT},
aftersale_status = #{aftersaleStatus,jdbcType=SMALLINT},
consignee = #{consignee,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
......
......@@ -16,6 +16,9 @@
<if test="order.orderStatus != null">
order_status = #{order.orderStatus,jdbcType=SMALLINT},
</if>
<if test="order.aftersaleStatus != null">
aftersale_status = #{order.aftersaleStatus,jdbcType=SMALLINT},
</if>
<if test="order.consignee != null">
consignee = #{order.consignee,jdbcType=VARCHAR},
</if>
......
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