feat(inventory_transfer): 添加删除功能暂未开放提示
This commit is contained in:
parent
5f007b5b1d
commit
86235aed08
@ -72,6 +72,7 @@ class InventoryTransferController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
return $this->fail('删除功能暂未开放');
|
||||||
$params = (new InventoryTransferValidate())->post()->goCheck('delete');
|
$params = (new InventoryTransferValidate())->post()->goCheck('delete');
|
||||||
InventoryTransferLogic::delete($params);
|
InventoryTransferLogic::delete($params);
|
||||||
return $this->success('删除成功', [], 1, 1);
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
@ -70,20 +70,27 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
return InventoryTransfer::where($this->searchWhere)
|
return InventoryTransfer::where($this->searchWhere)
|
||||||
->field(['id', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'type', 'one_id', 'two_id', 'create_time'])
|
->field(['id', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'one_type','two_type', 'one_id', 'two_id', 'create_time'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item){
|
||||||
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||||
if($item->type==1){
|
$type_name='';
|
||||||
$item->type_name='商户';
|
if($item->one_type==1){
|
||||||
$item->one_name=SystemStore::where('id',$item->one_id)->value('name');
|
$item->one_name=SystemStore::where('id',$item->one_id)->value('name');
|
||||||
|
$type_name='门店转';
|
||||||
|
}else{
|
||||||
|
$item->one_name=Warehouse::where('id',$item->one_id)->value('name');
|
||||||
|
$type_name='仓库转';
|
||||||
|
}
|
||||||
|
if($item->two_type==1){
|
||||||
|
$type_name.='门店';
|
||||||
$item->two_name=SystemStore::where('id',$item->two_id)->value('name');
|
$item->two_name=SystemStore::where('id',$item->two_id)->value('name');
|
||||||
}else{
|
}else{
|
||||||
$item->type_name='仓库';
|
$type_name.='仓库';
|
||||||
$item->one_name=Warehouse::where('id',$item->one_id)->value('name');
|
|
||||||
$item->two_name=Warehouse::where('id',$item->two_id)->value('name');
|
$item->two_name=Warehouse::where('id',$item->two_id)->value('name');
|
||||||
}
|
}
|
||||||
|
$item->type_name=$type_name;
|
||||||
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace app\admin\logic\inventory_transfer;
|
namespace app\admin\logic\inventory_transfer;
|
||||||
|
|
||||||
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
@ -32,33 +32,43 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
$one_after_nums = 0;
|
$one_after_nums = 0;
|
||||||
$two_before_nums = 0;
|
$two_before_nums = 0;
|
||||||
$two_after_nums = 0;
|
$two_after_nums = 0;
|
||||||
if ($params['type'] == 1) {
|
if($params['one_type']==1){
|
||||||
$stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock');
|
$stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock');
|
||||||
$stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock');
|
|
||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前门店库存');
|
self::setError('调拨数量不能大于当前门店库存');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
$one_before_nums = $stock;
|
|
||||||
$one_after_nums = bcsub($stock, $params['nums']);
|
|
||||||
|
|
||||||
$two_before_nums = $stock_two;
|
|
||||||
$two_after_nums = bcadd($stock_two, $params['nums']);
|
|
||||||
}
|
}
|
||||||
} elseif ($params['type'] == 2) {
|
if($params['two_type']==1){
|
||||||
|
$stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock');
|
||||||
|
}elseif($params['two_type']==2){
|
||||||
|
$stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums');
|
||||||
|
}
|
||||||
|
$one_before_nums = $stock;
|
||||||
|
$one_after_nums = bcsub($stock, $params['nums']);
|
||||||
|
|
||||||
|
$two_before_nums = $stock_two;
|
||||||
|
$two_after_nums = bcadd($stock_two, $params['nums']);
|
||||||
|
}elseif($params['one_type']==2){
|
||||||
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
||||||
$stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums');
|
|
||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前仓库库存');
|
self::setError('调拨数量不能大于当前仓库库存');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
$one_before_nums = $stock;
|
|
||||||
$one_after_nums = bcsub($stock, $params['nums']);
|
|
||||||
|
|
||||||
$two_before_nums = $stock_two;
|
|
||||||
$two_after_nums = bcadd($stock_two, $params['nums']);
|
|
||||||
}
|
}
|
||||||
|
if($params['two_type']==1){
|
||||||
|
$stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock');
|
||||||
|
}elseif($params['two_type']==2){
|
||||||
|
$stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums');
|
||||||
|
}
|
||||||
|
$one_before_nums = $stock;
|
||||||
|
$one_after_nums = bcsub($stock, $params['nums']);
|
||||||
|
|
||||||
|
$two_before_nums = $stock_two;
|
||||||
|
$two_after_nums = bcadd($stock_two, $params['nums']);
|
||||||
|
}else{
|
||||||
|
self::setError('调拨类型错误');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
InventoryTransfer::create([
|
InventoryTransfer::create([
|
||||||
@ -68,20 +78,24 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
'one_after_nums' => $one_after_nums,
|
'one_after_nums' => $one_after_nums,
|
||||||
'two_before_nums' => $two_before_nums,
|
'two_before_nums' => $two_before_nums,
|
||||||
'two_after_nums' => $two_after_nums,
|
'two_after_nums' => $two_after_nums,
|
||||||
'type' => $params['type'],
|
'one_type' => $params['one_type'],
|
||||||
|
'two_type' => $params['two_type'],
|
||||||
'one_id' => $params['one_id'],
|
'one_id' => $params['one_id'],
|
||||||
'two_id' => $params['two_id']
|
'two_id' => $params['two_id']
|
||||||
]);
|
]);
|
||||||
if ($params['type'] == 1) {
|
if($params['one_type']==1){
|
||||||
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update();
|
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update();
|
||||||
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update();
|
} elseif ($params['one_type'] == 2) {
|
||||||
} elseif ($params['type'] == 2) {
|
|
||||||
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update();
|
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update();
|
||||||
|
}
|
||||||
|
if($params['two_type']==1){
|
||||||
|
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update();
|
||||||
|
} elseif ($params['two_type'] == 2) {
|
||||||
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update();
|
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update();
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,6 +5,7 @@ namespace app\admin\logic\purchase_product_offer;
|
|||||||
|
|
||||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\delivery_service\DeliveryService;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
@ -103,15 +104,17 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function buyer($params)
|
public static function buyer($params)
|
||||||
{
|
{
|
||||||
|
if($params['is_buyer']==1){
|
||||||
|
if($params['buyer_id']==''){
|
||||||
|
self::setError('采购人不能为空');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$data['buyer_id']=$params['buyer_id'];
|
||||||
|
$data['buyer_nums']=$params['buyer_nums'];
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$data=[
|
$data['is_buyer']=$params['is_buyer'];
|
||||||
'is_buyer' => $params['is_buyer'],
|
|
||||||
];
|
|
||||||
if($params['is_buyer']==1){
|
|
||||||
$data['buyer_id']=$params['buyer_id'];
|
|
||||||
$data['buyer_nums']=$params['buyer_nums'];
|
|
||||||
}
|
|
||||||
PurchaseProductOffer::where('id', $params['id'])->update($data);
|
PurchaseProductOffer::where('id', $params['id'])->update($data);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -50,7 +50,7 @@ class InventoryTransferValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['product_id','nums','type','one_id','two_id']);
|
return $this->only(['product_id','nums','one_id','two_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user