|
|
@@ -104,18 +104,18 @@ class SystemStoreStock extends BaseModel
|
|
|
$info = self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->find();
|
|
|
if ($info) {
|
|
|
if ($data['type'] == 1) {
|
|
|
- $add = bcsub($data['in_stock'], $info['repair_sales']);
|
|
|
+ $add = bcsub($data['in_stock'], $info['repair_sales'], 3);
|
|
|
if ($add > 0) {
|
|
|
- self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['in_stock' => bcadd($info['in_stock'], $add), 'repair_sales' => 0]);
|
|
|
+ self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['in_stock' => bcadd($info['in_stock'], $add, 3), 'repair_sales' => 0]);
|
|
|
} else {
|
|
|
- self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['repair_sales' => bcsub($info['repair_sales'], $data['in_stock'])]);
|
|
|
+ self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['repair_sales' => bcsub($info['repair_sales'], $data['in_stock'], 3)]);
|
|
|
}
|
|
|
@file_put_contents("stock.txt", self::getlastsql());
|
|
|
} else {
|
|
|
if ($info['in_stock'] < $data['in_stock']) {
|
|
|
return self::setErrorInfo('库存不足');
|
|
|
}
|
|
|
- self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['in_stock' => bcsub($info['in_stock'], $data['in_stock'])]);
|
|
|
+ self::where(['store_id' => $store_id, 'product_id' => $data['product_id'], 'bar_code' => $data['bar_code']])->update(['in_stock' => bcsub($info['in_stock'], $data['in_stock'], 3)]);
|
|
|
@file_put_contents("stock.txt", self::getlastsql());
|
|
|
}
|
|
|
return true;
|