采购入库修复
This commit is contained in:
parent
fdf697e1f4
commit
3f1546e7b2
@ -2325,19 +2325,20 @@ class ProductRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function stockIn($merId, $params)
|
public function stockIn($merId, $params)
|
||||||
{
|
{
|
||||||
/**感觉有问题 最好在优化一下结构 */
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$supplierMerId = 0;
|
$supplierMerId = 0;
|
||||||
$model = new PurchaseRecord();
|
$model = new PurchaseRecord();
|
||||||
|
$stockIn = $params['number'] ?? 0;
|
||||||
|
$price = $params['price'] ?? 0;
|
||||||
|
if($stockIn==0){
|
||||||
|
$stockIn=1;
|
||||||
|
}
|
||||||
if (empty($params['product_id']) && !empty($params['order_product_id'])) {
|
if (empty($params['product_id']) && !empty($params['order_product_id'])) {
|
||||||
//有商品无规格或者无商品无规格,导入商品和规格
|
//有商品无规格或者无商品无规格,导入商品和规格
|
||||||
$product = $this->getWhere(['source_product_id' => $params['order_product_id'], 'mer_id' => $merId]);
|
$product = $this->getWhere(['source_product_id' => $params['order_product_id'], 'mer_id' => $merId]);
|
||||||
$sku = ProductAttrValue::where('product_id', $params['order_product_id'])->where('unique', $params['order_unique'])->value('sku');
|
|
||||||
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $product['product_id'])->where('sku', $sku)->find();
|
|
||||||
if (!empty($product)) {
|
if (!empty($product)) {
|
||||||
$stockIn = $params['number'] ?? 0;
|
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $product['product_id'])->find();
|
||||||
$price = $params['price'] ?? 0;
|
|
||||||
if (!empty($params['order_id'])) {
|
if (!empty($params['order_id'])) {
|
||||||
//采购、委托订单导入
|
//采购、委托订单导入
|
||||||
$orderMerId = StoreOrder::where('order_id', $params['order_id'])->value('mer_id');
|
$orderMerId = StoreOrder::where('order_id', $params['order_id'])->value('mer_id');
|
||||||
@ -2349,9 +2350,7 @@ class ProductRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( $orderProduct->is_imported == 1){
|
if( $orderProduct->is_imported == 1){
|
||||||
if($stockIn==0){
|
|
||||||
$stockIn=1;
|
|
||||||
}
|
|
||||||
ProductAttrValue::where('mer_id', $merId)
|
ProductAttrValue::where('mer_id', $merId)
|
||||||
->where('product_id', $product['product_id'])
|
->where('product_id', $product['product_id'])
|
||||||
->update(['stock'=>$attrValue->stock + $stockIn]);
|
->update(['stock'=>$attrValue->stock + $stockIn]);
|
||||||
@ -2383,6 +2382,8 @@ class ProductRepository extends BaseRepository
|
|||||||
} else {
|
} else {
|
||||||
$productId = $this->import($params['order_product_id'], request()->userInfo());
|
$productId = $this->import($params['order_product_id'], request()->userInfo());
|
||||||
$product = $this->get($productId);
|
$product = $this->get($productId);
|
||||||
|
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $productId)->find();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//有商品有规格
|
//有商品有规格
|
||||||
|
Loading…
x
Reference in New Issue
Block a user