|
@@ -499,6 +499,35 @@ public class BusinessServiceImpl implements BusinessService{
|
|
|
log.info("JposPrinterDemo finished.:"+workCode);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void knivesSave(Map<String, Object> map) {
|
|
|
+ long parentId = Long.parseLong(map.get("parentId").toString());
|
|
|
+ int recordType = Integer.parseInt(map.get("recordType").toString());
|
|
|
+ long amount = Long.parseLong(map.get("amount").toString());
|
|
|
+
|
|
|
+ jdbcService.insert("INSERT INTO a_knives_record ( `parent_id`, `record_type`, `created_by`, `created_at`, `amount`) VALUES ( ?, ?, ?, ?, ?)",parentId,recordType,getUserId(),new Date(),amount);
|
|
|
+ Map<String, Object> one = jdbcService.findOne("select * from a_knives_store where parent_id=?", parentId);
|
|
|
+ //0 接 -> 出库 1 -> 还 入库
|
|
|
+ if(recordType == 0){
|
|
|
+ if(one == null){
|
|
|
+ throw new RuntimeException("该刀具无库存");
|
|
|
+ }
|
|
|
+ long storeAmount = Long.parseLong(one.get("storeAmount").toString());
|
|
|
+ if(storeAmount-amount<0){
|
|
|
+ throw new RuntimeException("该刀具库存数量不足");
|
|
|
+ }
|
|
|
+ jdbcService.update("update a_knives_store set store_amount=store_amount - ? where parent_id=?",amount,parentId);
|
|
|
+ }else{
|
|
|
+ if(one == null){
|
|
|
+ jdbcService.insert("INSERT INTO a_knives_store ( `parent_id`, `store_amount`) VALUES ( ?, ?)",parentId,amount);
|
|
|
+ }else{
|
|
|
+ jdbcService.update("update a_knives_store set store_amount=store_amount + ? where parent_id=?",amount,parentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 销售订单id
|
|
|
* @param id
|