excel导入铺货
This commit is contained in:
parent
d1a4e5acdf
commit
e3dc0985bd
@ -4,6 +4,7 @@ namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
|
||||
use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic;
|
||||
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\CeshiCopy;
|
||||
@ -16,6 +17,8 @@ use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||
use app\common\model\StoreProductPriceList;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use support\exception\BusinessException;
|
||||
use support\Redis;
|
||||
@ -25,8 +28,8 @@ class LocalController extends BaseAdminController
|
||||
{
|
||||
|
||||
public $notNeedLogin = ['activityPrice', 'searchProduct', 'setPrice', 'index', 'updateProductPriceList', 'importOrder', 'warehousing', 'outbound'];
|
||||
|
||||
public $ids = [1829,1828,1827,1826,1825,1824,1823,1821,1820,1814,1813,1811,1810,1809,1808,1807,1806,1800,1799,1798,1796,1795,1794,1793,1792,1791,1790,1789,1788,1787,1786,1785,1784,1783,1782,1781,1780,1779,1778,1777,1776,1775,1774,1773,1772,1771,1770,1768,1765,1764,1763,1762,1761,1760,1759,1758,1757,1756,1755,1754,1753,1752,1751,1750,1749,1748,1747,1746,1745,1744,1743,1742,1741,1740,1739,1738,1737,1736,1735,1733,1732,1731,1730,1729,1728,1727,1726,1725,1724,1723,1722,1720,1719,1718,1717,1716,1715,1714,1713,1712,1711,1710,1709,1708,1707,1706,1705,1704,1703,1701,1700,1699,1698,1697,1696,1695,1694,1693,1692,1691,1690,1689,1688,1687,1686,1685,1684,1683,1682,1681,1680,1679,1678,1677,1676,1675,1674,1673,1672,1671,1670,1668,1667,1666,1665,1664,1663,1660,1659,1658,1657,1656,1655,1654,1652,1651,1650,1649,1648,1647,1646,1645,1644,1643,1642,1641,1640,1639,1638,1637,1636,1635,1634,1633,1632,1631,1630,1629,1628,1627,1626,1623,1622];
|
||||
|
||||
public $ids = [1829, 1828, 1827, 1826, 1825, 1824, 1823, 1821, 1820, 1814, 1813, 1811, 1810, 1809, 1808, 1807, 1806, 1800, 1799, 1798, 1796, 1795, 1794, 1793, 1792, 1791, 1790, 1789, 1788, 1787, 1786, 1785, 1784, 1783, 1782, 1781, 1780, 1779, 1778, 1777, 1776, 1775, 1774, 1773, 1772, 1771, 1770, 1768, 1765, 1764, 1763, 1762, 1761, 1760, 1759, 1758, 1757, 1756, 1755, 1754, 1753, 1752, 1751, 1750, 1749, 1748, 1747, 1746, 1745, 1744, 1743, 1742, 1741, 1740, 1739, 1738, 1737, 1736, 1735, 1733, 1732, 1731, 1730, 1729, 1728, 1727, 1726, 1725, 1724, 1723, 1722, 1720, 1719, 1718, 1717, 1716, 1715, 1714, 1713, 1712, 1711, 1710, 1709, 1708, 1707, 1706, 1705, 1704, 1703, 1701, 1700, 1699, 1698, 1697, 1696, 1695, 1694, 1693, 1692, 1691, 1690, 1689, 1688, 1687, 1686, 1685, 1684, 1683, 1682, 1681, 1680, 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, 1671, 1670, 1668, 1667, 1666, 1665, 1664, 1663, 1660, 1659, 1658, 1657, 1656, 1655, 1654, 1652, 1651, 1650, 1649, 1648, 1647, 1646, 1645, 1644, 1643, 1642, 1641, 1640, 1639, 1638, 1637, 1636, 1635, 1634, 1633, 1632, 1631, 1630, 1629, 1628, 1627, 1626, 1623, 1622];
|
||||
|
||||
public function warehousing()
|
||||
{
|
||||
@ -513,5 +516,62 @@ class LocalController extends BaseAdminController
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
public function importStorege()
|
||||
{
|
||||
$file = $this->request->file('file');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($file->getRealPath());
|
||||
$sheets = $spreadsheet->getAllSheets();
|
||||
$new_params = [];
|
||||
foreach ($sheets as $sheetIndex => $sheet) {
|
||||
$rows = $sheet->toArray();
|
||||
foreach ($rows as $k => $row) {
|
||||
if ($k < 1 || empty($row[0])) {
|
||||
continue;
|
||||
}
|
||||
$system_store_id = SystemStore::where('name', $row[1])->value('id');
|
||||
$product = StoreBranchProduct::where('product_id', $row[0])->where('store_id', $system_store_id)->field('id,product_id,stock')->findOrEmpty();
|
||||
if ($row[10] == $product->stock && $product->stock != 0) {
|
||||
// 生成铺货单
|
||||
$params = [];
|
||||
$params['after_nums'] = '';
|
||||
$params['before_nums'] = '';
|
||||
$params['id'] = $row[0];
|
||||
$params['mark'] = "门店铺货-excel导入";
|
||||
$params['nums'] = $row[2];
|
||||
$params['one_id'] = $system_store_id; //门店id
|
||||
$params['one_name'] = "";
|
||||
$params['one_type'] = 1; //1门店2仓库
|
||||
$params['product_arr'] = [
|
||||
[
|
||||
'nums' => $row[10],
|
||||
'product_id' => $product->product_id,
|
||||
'purchase' => 0,
|
||||
'total_price' => $product->total_price,
|
||||
]
|
||||
];
|
||||
$params['product_id'] = $row[0];
|
||||
$params['product_name'] = "";
|
||||
$params['two_id'] = 1; //1海吉星仓库
|
||||
$params['two_name'] = "";
|
||||
$params['two_type'] = 2; //1门店2仓库
|
||||
$params['types'] = 1; //0减库存 1不减库存
|
||||
$params['warehouse_name'] = "";
|
||||
$params['warehouse_name_two'] = "";
|
||||
InventoryTransferOrderLogic::add($params, $this->adminId);
|
||||
} else {
|
||||
|
||||
}
|
||||
$arr = [];
|
||||
$arr['product_id'] = $row[0];
|
||||
$arr['store_id'] = $system_store_id;
|
||||
$arr['nums'] = $row[10] ?? 0;
|
||||
$arr['stock'] = $product['stock'] ?? 0;
|
||||
$new_params[] = $arr;
|
||||
}
|
||||
}
|
||||
$dataArray = json_encode($new_params, true);
|
||||
file_put_contents(public_path() . '/output.text', $dataArray);
|
||||
}
|
||||
return $this->success('导入成功');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user