已销售数量根据实际下单调整
This commit is contained in:
parent
1d53ad5a51
commit
f7c61f6696
|
|
@ -52,4 +52,7 @@ public interface GoodsStandardMapper {
|
|||
* @param goodsId 商品ID
|
||||
*/
|
||||
int deleteByGoodsId(Long goodsId);
|
||||
|
||||
int updateSaleNum(GoodsStandard goodsStandard);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ghy.goods.service;
|
||||
|
||||
import com.ghy.goods.domain.Goods;
|
||||
import com.ghy.goods.domain.GoodsStandard;
|
||||
import com.ghy.goods.request.AppGoodsRequest;
|
||||
|
||||
|
|
@ -50,4 +51,7 @@ public interface GoodsStandardService {
|
|||
* 全量保存
|
||||
*/
|
||||
int save(List<GoodsStandard> goodsStandardList);
|
||||
|
||||
int updateSaleNum(GoodsStandard goodsStandard);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|||
for (AppGoodsRequest appGoodsRequest : goodsList) {
|
||||
GoodsStandard goodsStandard = goodsStandardService.selectById(appGoodsRequest.getGoodsStandardId());
|
||||
totalPay = totalPay.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(appGoodsRequest.getNum())));
|
||||
//修改已售数量
|
||||
goodsStandard.setSaleNum(goodsStandard.getSaleNum() + appGoodsRequest.getNum());
|
||||
goodsStandardService.updateSaleNum(goodsStandard);
|
||||
}
|
||||
return totalPay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,8 @@ public class GoodsStandardServiceImpl implements GoodsStandardService {
|
|||
return goodsStandardMapper.batchInsert(goodsStandardList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSaleNum(GoodsStandard goodsStandard) {
|
||||
return goodsStandardMapper.updateSaleNum(goodsStandard);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,4 +102,14 @@
|
|||
DELETE FROM goods_standard
|
||||
WHERE goods_id = #{goodsId}
|
||||
</delete>
|
||||
|
||||
<update id="updateSaleNum">
|
||||
update
|
||||
goods_standard
|
||||
set
|
||||
sale_num = #{saleNum}
|
||||
where
|
||||
goods_standard_id = #{goodsStandardId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue