Merge pull request 'dev' (#464) from dev into main
Reviewed-on: https://gitea.lihaink.cn/mkm/multi-store/pulls/464
This commit is contained in:
commit
1f9d9db187
@ -341,4 +341,12 @@ class BeforehandOrderController extends BaseAdminController
|
||||
return $this->success('确认成功');
|
||||
}
|
||||
|
||||
public function copy()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
BeforehandOrderLogic::copy($params);
|
||||
return $this->success('复制成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,5 +94,13 @@ class SystemStoreStorageController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 批量确认入库
|
||||
*/
|
||||
public function batchConfirm()
|
||||
{
|
||||
SystemStoreStorageLogic::editAll([], $this->adminId);
|
||||
return $this->success('操作成功',[]);
|
||||
}
|
||||
|
||||
}
|
@ -45,14 +45,17 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if (!empty($this->params['product_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', '%' . $this->params['product_name'] . '%')->column('id');
|
||||
$this->searchWhere[] = ['product_id', 'in', $productIds];
|
||||
}
|
||||
return SystemStoreStorage::where($this->searchWhere)
|
||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status'])
|
||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
|
||||
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
|
||||
$item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name');
|
||||
if ($item['staff_id'] > 0) {
|
||||
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
|
||||
} else {
|
||||
|
@ -1037,4 +1037,43 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function copy($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
if (empty($order)) {
|
||||
throw new BusinessException('订单不存在');
|
||||
}
|
||||
if ($order['order_type'] != 1) {
|
||||
throw new BusinessException('只能复制铺货订单');
|
||||
}
|
||||
$orderCartInfo = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray();
|
||||
unset($order['id'], $order['create_time'], $order['update_time']);
|
||||
$newOrder = new BeforehandOrder();
|
||||
$newOrder->setAttrs($order->toArray());
|
||||
$newOrder->admin_id = $params['admin_id'];
|
||||
$newOrder->store_id = $params['store_id'];
|
||||
$newOrder->order_id = getNewOrderId('YG');
|
||||
if (!empty($params['mark'])) {
|
||||
$newOrder->mark = $params['mark'];
|
||||
} else {
|
||||
$newOrder->mark = "复制订单,原订单id:{$params['id']}";
|
||||
}
|
||||
$newOrder->save();
|
||||
$insert = [];
|
||||
foreach ($orderCartInfo as $v) {
|
||||
unset($v['id'], $v['create_time'], $v['update_time']);
|
||||
$v['bhoid'] = $newOrder->id;
|
||||
$insert[] = $v;
|
||||
}
|
||||
(new BeforehandOrderCartInfo())->saveAll($insert);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class StoreBranchProductLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray();
|
||||
StoreBranchProduct::update(['stock' => $params['stock'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]);
|
||||
StoreBranchProduct::update(['stock' => $params['stock'], 'sales' => $params['sales'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]);
|
||||
SqlChannelLog('StoreBranchProduct', $params['id'], $params['stock'], 0, Request()->url(), $admin_id);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -73,7 +73,7 @@ class SystemStoreStorageLogic extends BaseLogic
|
||||
$branch_product->save();
|
||||
SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id);
|
||||
}else{
|
||||
$storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty();
|
||||
$storeProduct = StoreProduct::where('id', $find['product_id'])->withTrashed()->findOrEmpty();
|
||||
$storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct);
|
||||
$storeBranchProduct->stock = $find['nums'];
|
||||
$storeBranchProduct->save();
|
||||
@ -93,12 +93,16 @@ class SystemStoreStorageLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public static function editAll(array $params): bool
|
||||
public static function editAll(array $params, $adminId = 0): bool
|
||||
{
|
||||
$list = SystemStoreStorage::where(['store_id' => $params['store_id'], 'status' => 0])->column('id');
|
||||
$where = ['status' => 0];
|
||||
if (isset($params['store_id'])) {
|
||||
$where['store_id'] = $params['store_id'];
|
||||
}
|
||||
$list = SystemStoreStorage::where($where)->column('id');
|
||||
foreach ($list as $item) {
|
||||
$params['id'] = $item;
|
||||
self::edit($params);
|
||||
self::edit($params, $adminId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user