Commit 49f8f452 authored by hezhen's avatar hezhen

减库存

parent 1a48b14a
......@@ -172,6 +172,9 @@ public class ResultCode {
// 未绑定社保卡
public static int NOT_BIND_SOCIAL_CARD = Integer.valueOf(SystemProperty.getResultConfig("NOT_BIND_SOCIAL_CARD"));
// 操作失败
public static int STOCK_CODE = Integer.valueOf(SystemProperty.getResultConfig("STOCK_CODE"));
public static String getMsg(int code) {
return SystemProperty.getResultConfig(String.valueOf(code));
......
......@@ -178,4 +178,6 @@ SCRM_RESULTINFO_SUCCESS_CODE=10344
#市接口无数据返回
NO_SELECT_BY_RS=1010
#还未绑定社保卡
NOT_BIND_SOCIAL_CARD=3010
\ No newline at end of file
NOT_BIND_SOCIAL_CARD=3010
#库存不足
STOCK_CODE=201
\ No newline at end of file
......@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value = "xx-tour")
public interface TourFeign {
@RequestMapping(value = "/spe/user/prices", method = RequestMethod.POST)
public ObjectRestResponse<TourSpePriceVo> refund(@RequestBody TourSpePriceDto spePriceDto);
public ObjectRestResponse<TourSpePriceVo> prices(@RequestBody TourSpePriceDto spePriceDto);
@RequestMapping(value = "/spe/stock", method = RequestMethod.GET)
public ObjectRestResponse<TourSpePriceVo> stock(Integer speId,Integer number);
}
......@@ -42,6 +42,10 @@ public class TourSpePriceVo {
@ApiModelProperty(value = "儿童总价")
private BigDecimal totaiChildPrice;
//库存
@ApiModelProperty(value = "库存")
private Integer stock;
......
......@@ -42,6 +42,7 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
Integer level = priceDto.getLevel();
priceVo.setUserId(priceDto.getUserId());
priceVo.setLevel(priceDto.getLevel());
priceVo.setStock(spePrice.getStock());
BigDecimal price = spePrice.getPrice();
BigDecimal childPrice = spePrice.getChildPrice();
if (level != null && level > 0) {
......@@ -74,5 +75,16 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
}
//减库存
public ObjectRestResponse cutStock(Integer speId,Integer number) {
TourGoodSpePrice spePrice = mapper.selectByPrimaryKey(speId);
if (spePrice != null && spePrice.getStock() > 0 && spePrice.getStock() >= number) {
mapper.updStockById(speId, number);
return ObjectRestResponse.succ();
} else {
return ObjectRestResponse.createFailedResult(ResultCode.STOCK_CODE, "库存不足");
}
}
}
\ No newline at end of file
......@@ -18,6 +18,9 @@ public interface TourGoodSpePriceMapper extends Mapper<TourGoodSpePrice> {
List<TourDepartTimeVo> getAllByGoodId(@Param("goodId") Integer goodId);
//减库存
int updStockById(@Param("id") Integer id,@Param("number") Integer number);
}
......@@ -18,9 +18,18 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
//获取商品详情
@RequestMapping(value = "/user/prices", method = RequestMethod.GET)
public ObjectRestResponse<TourSpePriceVo> user(@RequestBody TourSpePriceDto priceDto) {
@RequestMapping(value = "/user/prices", method = RequestMethod.POST)
public ObjectRestResponse<TourSpePriceVo> prices(@RequestBody TourSpePriceDto priceDto) {
return baseBiz.getPricesByuserid(priceDto);
}
//减库存
@RequestMapping(value = "/stock", method = RequestMethod.GET)
public ObjectRestResponse<TourSpePriceVo> stock(
@RequestParam(value = "speId",defaultValue = "0")Integer speId,
@RequestParam(value = "number",defaultValue = "0") Integer number){
return baseBiz.cutStock(speId,number);
}
}
\ No newline at end of file
......@@ -40,6 +40,11 @@
FROM tour_good_spe_price WHERE good_id=#{goodId} and is_del=0
</select>
<!-- 减库存-->
<update id="updStockById">
update tour_good_spe_price set stock=stock-#{number} where id=#{id}
</update>
</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