mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-09-13 07:21:38 +08:00
抢购3-promoItemPrice拼写错误就整;前端页面;修Bug
This commit is contained in:
@@ -5,12 +5,15 @@ import com.cxyxiaomo.flashsale.error.BusinessException;
|
||||
import com.cxyxiaomo.flashsale.response.CommonReturnType;
|
||||
import com.cxyxiaomo.flashsale.service.ItemService;
|
||||
import com.cxyxiaomo.flashsale.service.model.ItemModel;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -80,7 +83,7 @@ public class ItemController extends BaseController {
|
||||
// 有正在进行或即将进行的秒杀活动
|
||||
itemVO.setPromoStatus(itemModel.getPromoModel().getStatus());
|
||||
itemVO.setPromoId(itemModel.getId());
|
||||
itemVO.setStartDate(itemModel.getPromoModel().getStartDate());
|
||||
itemVO.setStartDate(itemModel.getPromoModel().getStartDate().toString(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
itemVO.setPromoPrice(itemModel.getPromoModel().getPromoPrice());
|
||||
} else {
|
||||
itemVO.setPromoStatus(0);
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package com.cxyxiaomo.flashsale.controller.viewobject;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ItemVO {
|
||||
@@ -37,7 +35,7 @@ public class ItemVO {
|
||||
private Integer promoId;
|
||||
|
||||
// 秒杀活动开始时间
|
||||
private DateTime startDate;
|
||||
private String startDate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
@@ -119,11 +117,11 @@ public class ItemVO {
|
||||
this.promoId = promoId;
|
||||
}
|
||||
|
||||
public DateTime getStartDate() {
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(DateTime startDate) {
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
}
|
||||
|
@@ -52,11 +52,11 @@ public class PromoDO {
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column promo_info.prome_item_price
|
||||
* This field corresponds to the database column promo_info.promo_item_price
|
||||
*
|
||||
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||
*/
|
||||
private BigDecimal promeItemPrice;
|
||||
private BigDecimal promoItemPrice;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
@@ -180,25 +180,25 @@ public class PromoDO {
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column promo_info.prome_item_price
|
||||
* This method returns the value of the database column promo_info.promo_item_price
|
||||
*
|
||||
* @return the value of promo_info.prome_item_price
|
||||
* @return the value of promo_info.promo_item_price
|
||||
*
|
||||
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||
*/
|
||||
public BigDecimal getPromeItemPrice() {
|
||||
return promeItemPrice;
|
||||
public BigDecimal getPromoItemPrice() {
|
||||
return promoItemPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column promo_info.prome_item_price
|
||||
* This method sets the value of the database column promo_info.promo_item_price
|
||||
*
|
||||
* @param promeItemPrice the value for promo_info.prome_item_price
|
||||
* @param promoItemPrice the value for promo_info.promo_item_price
|
||||
*
|
||||
* @mbg.generated Sat Mar 05 12:55:23 CST 2022
|
||||
*/
|
||||
public void setPromeItemPrice(BigDecimal promeItemPrice) {
|
||||
this.promeItemPrice = promeItemPrice;
|
||||
public void setPromoItemPrice(BigDecimal promoItemPrice) {
|
||||
this.promoItemPrice = promoItemPrice;
|
||||
}
|
||||
}
|
@@ -7,7 +7,9 @@ import com.cxyxiaomo.flashsale.service.model.PromoModel;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PromoServiceImpl implements PromoService {
|
||||
|
||||
@Autowired
|
||||
@@ -16,11 +18,15 @@ public class PromoServiceImpl implements PromoService {
|
||||
@Override
|
||||
public PromoModel getPromoByItemId(Integer itemId) {
|
||||
// 获取对应商品的秒杀活动信息
|
||||
PromoDO promoDO = promoDOMapper.selectByPrimaryKey(itemId);
|
||||
PromoDO promoDO = promoDOMapper.selectByItemId(itemId);
|
||||
|
||||
// Data Object -> Model
|
||||
PromoModel promoModel = convertFromDataObject(promoDO);
|
||||
|
||||
if (promoModel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 判断秒杀活动是否即将开始或正在进行
|
||||
if (promoModel.getStartDate().isAfterNow()) {
|
||||
promoModel.setStatus(1); // 还未开始
|
||||
@@ -39,6 +45,7 @@ public class PromoServiceImpl implements PromoService {
|
||||
}
|
||||
PromoModel promoModel = new PromoModel();
|
||||
BeanUtils.copyProperties(promoDO, promoModel);
|
||||
promoModel.setPromoPrice(promoDO.getPromoItemPrice());
|
||||
promoModel.setStartDate(new DateTime(promoDO.getStartDate()));
|
||||
promoModel.setEndDate(new DateTime(promoDO.getEndDate()));
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
<result column="start_date" jdbcType="TIMESTAMP" property="startDate" />
|
||||
<result column="end_date" jdbcType="TIMESTAMP" property="endDate" />
|
||||
<result column="item_id" jdbcType="INTEGER" property="itemId" />
|
||||
<result column="prome_item_price" jdbcType="DECIMAL" property="promeItemPrice" />
|
||||
<result column="promo_item_price" jdbcType="DECIMAL" property="promoItemPrice" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--
|
||||
@@ -20,7 +20,7 @@
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||
-->
|
||||
id, promo_name, start_date, end_date, item_id, prome_item_price
|
||||
id, promo_name, start_date, end_date, item_id, promo_item_price
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
<!--
|
||||
@@ -49,10 +49,10 @@
|
||||
This element was generated on Sat Mar 05 12:55:23 CST 2022.
|
||||
-->
|
||||
insert into promo_info (id, promo_name, start_date,
|
||||
end_date, item_id, prome_item_price
|
||||
end_date, item_id, promo_item_price
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{promoName,jdbcType=VARCHAR}, #{startDate,jdbcType=TIMESTAMP},
|
||||
#{endDate,jdbcType=TIMESTAMP}, #{itemId,jdbcType=INTEGER}, #{promeItemPrice,jdbcType=DECIMAL}
|
||||
#{endDate,jdbcType=TIMESTAMP}, #{itemId,jdbcType=INTEGER}, #{promoItemPrice,jdbcType=DECIMAL}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.cxyxiaomo.flashsale.dataobject.PromoDO">
|
||||
@@ -78,8 +78,8 @@
|
||||
<if test="itemId != null">
|
||||
item_id,
|
||||
</if>
|
||||
<if test="promeItemPrice != null">
|
||||
prome_item_price,
|
||||
<if test="promoItemPrice != null">
|
||||
promo_item_price,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@@ -98,8 +98,8 @@
|
||||
<if test="itemId != null">
|
||||
#{itemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="promeItemPrice != null">
|
||||
#{promeItemPrice,jdbcType=DECIMAL},
|
||||
<if test="promoItemPrice != null">
|
||||
#{promoItemPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
@@ -123,8 +123,8 @@
|
||||
<if test="itemId != null">
|
||||
item_id = #{itemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="promeItemPrice != null">
|
||||
prome_item_price = #{promeItemPrice,jdbcType=DECIMAL},
|
||||
<if test="promoItemPrice != null">
|
||||
promo_item_price = #{promoItemPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
@@ -140,10 +140,10 @@
|
||||
start_date = #{startDate,jdbcType=TIMESTAMP},
|
||||
end_date = #{endDate,jdbcType=TIMESTAMP},
|
||||
item_id = #{itemId,jdbcType=INTEGER},
|
||||
prome_item_price = #{promeItemPrice,jdbcType=DECIMAL}
|
||||
promo_item_price = #{promoItemPrice,jdbcType=DECIMAL}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<select id="selectByItemId" resultMap="BaseResultMap">
|
||||
<select id="selectByItemId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from promo_info
|
||||
|
Reference in New Issue
Block a user