修改耗材消耗

This commit is contained in:
牛叉闪闪
2024-07-15 11:05:22 +08:00
parent 7a6de2388c
commit d042b14c6a
2 changed files with 26 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
@Slf4j @Slf4j
@@ -76,32 +77,46 @@ public class ConsService {
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())); amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
flow.setAmount(amount); flow.setAmount(amount);
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("createCart"); flow.setBizCode("createCart");
flow.setBizName("销售扣除"); flow.setBizName("销售扣除");
flow.setBizType("-"); flow.setBizType("-");
tbConsInfo.setStockConsume(tbConsInfo.getStockConsume().add(amount));
flow.setBalance(tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
}else if("delete".equals(type)){ }else if("delete".equals(type)){
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate(); amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
flow.setAmount(amount.abs()); flow.setAmount(amount.abs());
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
flow.setBizCode("cancelCart"); flow.setBizCode("cancelCart");
flow.setBizName("退单返还"); flow.setBizName("退单返还");
flow.setBizType("+"); flow.setBizType("+");
tbConsInfo.setStockConsume(tbConsInfo.getStockConsume().add(amount));
flow.setBalance(tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()));
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
} }
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount); // ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
consInfoPOS.add(consInfoPO); // consInfoPOS.add(consInfoPO);
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
flow.setUpdateTime(new Date()); // flow.setUpdateTime(new Date());
consInfoFlows.add(flow); // consInfoFlows.add(flow);
tbConsInfoMapper.updateByPrimaryKey(tbConsInfo);
tbConsInfoFlowMapper.insert(flow);
} }
} }
//更新耗材信息 //更新耗材信息
tbConsInfoMapper.batchStock(consInfoPOS); // tbConsInfoMapper.batchStock(consInfoPOS);
//记录更新日志 // //记录更新日志
tbConsInfoFlowMapper.insertBatch(consInfoFlows); // tbConsInfoFlowMapper.insertBatch(consInfoFlows);
} }
} }
} }

View File

@@ -174,7 +174,8 @@
laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, laster_in_stock = #{lasterInStock,jdbcType=DECIMAL},
con_warning = #{conWarning,jdbcType=DECIMAL}, con_warning = #{conWarning,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP},
stock_consume=#{stockConsume,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>