Commit 2729e34e authored by hezhen's avatar hezhen

修改减库存

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