|
@@ -36,7 +36,7 @@ class SystemStoreProductStockLog extends BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改库存减少库存记录
|
|
//修改库存减少库存记录
|
|
|
- public static function expend($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1)
|
|
|
|
|
|
|
+ public static function expend($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1, $price = 0)
|
|
|
{
|
|
{
|
|
|
$info = StoreProductAttrValue::where(['unique' => $unique])->find();
|
|
$info = StoreProductAttrValue::where(['unique' => $unique])->find();
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
@@ -50,7 +50,7 @@ class SystemStoreProductStockLog extends BaseModel
|
|
|
}
|
|
}
|
|
|
$stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
|
|
$stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
|
|
|
if (!$stock) {
|
|
if (!$stock) {
|
|
|
- $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 0]);
|
|
|
|
|
|
|
+ $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 0, 'price' => $price]);
|
|
|
}
|
|
}
|
|
|
if (!$stock['in_use']) return self::setErrorInfo('所选门店未上架' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']');
|
|
if (!$stock['in_use']) return self::setErrorInfo('所选门店未上架' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']');
|
|
|
if ($number > 0) {
|
|
if ($number > 0) {
|
|
@@ -58,7 +58,7 @@ class SystemStoreProductStockLog extends BaseModel
|
|
|
if ($balance < 0) {
|
|
if ($balance < 0) {
|
|
|
return self::setErrorInfo('所选门店' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']库存不足');
|
|
return self::setErrorInfo('所选门店' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']库存不足');
|
|
|
}
|
|
}
|
|
|
- SystemStoreProductStock::where('id', $stock['id'])->dec('stock', $number)->update();
|
|
|
|
|
|
|
+ SystemStoreProductStock::where('id', $stock['id'])->dec('stock', $number)->update(['price' => $price]);
|
|
|
$pm = 0;
|
|
$pm = 0;
|
|
|
$add_time = time();
|
|
$add_time = time();
|
|
|
$stock_id = $stock['id'];
|
|
$stock_id = $stock['id'];
|
|
@@ -69,7 +69,7 @@ class SystemStoreProductStockLog extends BaseModel
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//修改库存增加库存记录
|
|
//修改库存增加库存记录
|
|
|
- public static function income($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1)
|
|
|
|
|
|
|
+ public static function income($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1, $price = 0)
|
|
|
{
|
|
{
|
|
|
$info = StoreProductAttrValue::where(['unique' => $unique])->find();
|
|
$info = StoreProductAttrValue::where(['unique' => $unique])->find();
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
@@ -83,11 +83,11 @@ class SystemStoreProductStockLog extends BaseModel
|
|
|
}
|
|
}
|
|
|
$stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
|
|
$stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
|
|
|
if (!$stock) {
|
|
if (!$stock) {
|
|
|
- $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 1]);
|
|
|
|
|
|
|
+ $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 1, 'price' => $price]);
|
|
|
}
|
|
}
|
|
|
if ($number > 0) {
|
|
if ($number > 0) {
|
|
|
$balance = $stock['stock'] + $number;
|
|
$balance = $stock['stock'] + $number;
|
|
|
- SystemStoreProductStock::where('id', $stock['id'])->inc('stock', $number)->update(['in_use' => 1]);
|
|
|
|
|
|
|
+ SystemStoreProductStock::where('id', $stock['id'])->inc('stock', $number)->update(['in_use' => 1, 'price' => $price]);
|
|
|
$pm = 1;
|
|
$pm = 1;
|
|
|
$add_time = time();
|
|
$add_time = time();
|
|
|
$stock_id = $stock['id'];
|
|
$stock_id = $stock['id'];
|