Commit 2729e34e authored by hezhen's avatar hezhen

修改减库存

parent 153b3c43
......@@ -36,7 +36,7 @@ public interface TourFeign {
public ObjectRestResponse<TourSpePriceVo> refund(@RequestBody TourSpePriceDTO spePriceDto);
@RequestMapping(value = "/spe/stock", method = RequestMethod.GET)
public ObjectRestResponse<TourSpePriceVo> stock(@RequestParam Integer speId, @RequestParam Integer number);
public ObjectRestResponse<TourSpePriceVo> stock(@RequestParam Integer speId, @RequestParam Integer number, @RequestParam Integer type);
@RequestMapping(value = "/tourGood/app/unauth/usable/{id}", method = RequestMethod.GET)
......
......@@ -83,14 +83,18 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
}
//减库存
public ObjectRestResponse cutStock(Integer speId,Integer number) {
public ObjectRestResponse cutStock(Integer speId,Integer number,Integer type) {
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, "库存不足");
if(type==1){
if (spePrice != null && spePrice.getStock() > 0 && spePrice.getStock() >= number) {
mapper.updStockById(speId, number,type);
} else {
return ObjectRestResponse.createFailedResult(ResultCode.STOCK_CODE, "库存不足");
}
}else {
mapper.updStockById(speId, number,type);
}
return ObjectRestResponse.succ();
}
//删除
......
......@@ -19,7 +19,7 @@ public interface TourGoodSpePriceMapper extends Mapper<TourGoodSpePrice> {
List<TourDepartTimeVo> getAllByGoodId(@Param("goodId") Integer goodId);
//减库存
int updStockById(@Param("id") Integer id,@Param("number") Integer number);
int updStockById(@Param("id") Integer id,@Param("number") Integer number,@Param("type") Integer type);
//删除站点
public int delSpe(@Param("goodId")Integer goodId,@Param("list")List<Integer> ids);
......
......@@ -26,8 +26,10 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
@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);
@RequestParam(value = "number",defaultValue = "0") Integer number,
@RequestParam(value = "type",defaultValue = "1") Integer type
){
return baseBiz.cutStock(speId,number,type);
}
}
\ No newline at end of file
......@@ -43,7 +43,14 @@
<!-- 减库存-->
<update id="updStockById">
update tour_good_spe_price set stock=stock-#{number} where id=#{id}
update tour_good_spe_price set
<if test="type==1">
stock=stock-#{number}
</if>
<if test="type==2">
stock=stock+#{number}
</if>
where id=#{id}
</update>
<update id="delSpe">
......
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