Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
42afe19d91 | |||
07e1f331ce | |||
d2ecc8a166 | |||
dadeb89d09 | |||
5f3e18fe83 | |||
60ee9295c6 | |||
9fc4095563 | |||
188904a63b | |||
cbfcfb70cd | |||
bc385e3c2f | |||
93969124e2 | |||
f120ad28be | |||
b7ea08c41c | |||
4e9857d9f5 | |||
57997f4a19 | |||
e36c9416c4 | |||
37c9cbd064 | |||
4711643bb8 | |||
af6e8e2387 | |||
55daad5815 | |||
a54adbd928 | |||
bc40d950aa | |||
14d1ca8c11 | |||
f451525aa9 | |||
17464ff077 | |||
522af410cd | |||
27f424be34 | |||
1f336cc6e2 | |||
db336e476f | |||
f55d444799 | |||
665f56cee9 | |||
c4e69f99f7 | |||
a89a555f7c | |||
0d86926915 | |||
b48ed7d80e | |||
c3d1de3671 | |||
a790577276 | |||
3cc738e6c3 | |||
8e2e9c0fa8 | |||
9117e3eb89 | |||
6ddcab62b6 | |||
58423f1b01 | |||
b5e2707c3c | |||
fcf6efe6ae | |||
8056fce1da | |||
8d0b39c8e0 | |||
46fdf20b47 | |||
665c8e89d2 | |||
527dd756ec | |||
b141ac8fad | |||
ac6d03f7b5 | |||
1a884b691e | |||
227de2fe30 | |||
518d9fe064 | |||
99dc835cb1 | |||
c1a0b6adec | |||
81072d2859 | |||
af37f15da3 | |||
f8806b8ada | |||
49f7e50644 | |||
953b7db733 | |||
eae37a1142 | |||
ddc9a82766 | |||
279cc7d903 | |||
9bc69d71fe | |||
6d6374db71 | |||
a92f33d490 | |||
83f81a3974 | |||
5cf7dd76b9 | |||
0d10483162 | |||
30230df638 | |||
1ffd1193c1 | |||
78aa37bb3b |
.gitignoreREADME.md
app
ExceptionHandler.phpMyBusinessException.php
admin
controller
ActivityZoneController.phpActivityZoneFormController.phpChangeLogController.phpIndexController.phpLocalController.phpPurchaseFundsController.phpWorkbenchController.php
accounts_receivable
beforehand_order
beforehand_order_cart_info
delivery_service
inventory_store
inventory_transfer
inventory_transfer_order
inventory_warehouse
product_source_link
product_source_link_info
purchase_order
purchase_order_info
purchase_product_offer
store_branch_product
store_extract
store_finance_flow
store_order
store_order_cart_info
store_product
store_product_group_price
store_product_low_stock
store_product_price
supplier
system_store
system_store_storage
user
warehouse_order
warehouse_product
warehouse_product_return
warehouse_product_storege
lists
AccountsReceivableInfoLists.phpAccountsReceivableLists.phpActivityZoneFormLists.phpActivityZoneLists.phpChangeLogLists.phpPurchaseFundsLists.php
beforehand_order
beforehand_order_cart_info
delivery_service
inventory_store
inventory_transfer
inventory_transfer_order
inventory_warehouse
product_source_link
product_source_link_info
purchase_order_info
purchase_product_offer
statistics
store_branch_product exchange
store_branch_product
store_cash_finance_flow
store_category
store_extract
store_finance_flow
store_order
store_order_cart_info
StoreOrderCartInfoGroupLists.phpStoreOrderCartInfoGroupMonthLists.phpStoreOrderCartInfoLists.phpStoreOrderCartInfoTwoLists.php
store_product
store_product_group_price
store_product_low_stock
store_product_price
supplier
system_store_storage
user
user_recharge
warehouse_order
warehouse_product
warehouse_product_return
warehouse_product_storege
logic
AccountsReceivableLogic.phpActivityZoneFormLogic.phpActivityZoneLogic.phpChangeLogLogic.phpConfigLogic.phpPurchaseFundsLogic.php
app_update
auth
beforehand_order
beforehand_order_cart_info
delivery_service
dept
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,5 +6,4 @@
|
||||
/tests/.phpunit.result.cache
|
||||
public/uploads
|
||||
public/image/barcode
|
||||
public/image
|
||||
public/export
|
||||
public/image
|
23
README.md
23
README.md
@ -1,5 +1,20 @@
|
||||
# webman
|
||||
|
||||
source
|
||||
0 小程序
|
||||
1 收银台
|
||||
4 批发
|
||||
High performance HTTP Service Framework for PHP based on [Workerman](https://github.com/walkor/workerman).
|
||||
|
||||
# Manual (文档)
|
||||
|
||||
https://www.workerman.net/doc/webman
|
||||
|
||||
# Home page (主页)
|
||||
https://www.workerman.net/webman
|
||||
|
||||
|
||||
# Benchmarks (压测)
|
||||
|
||||
https://www.techempower.com/benchmarks/#section=test&runid=9716e3cd-9e53-433c-b6c5-d2c48c9593c1&hw=ph&test=db&l=zg24n3-1r&a=2
|
||||

|
||||
|
||||
## LICENSE
|
||||
|
||||
MIT
|
||||
|
@ -7,7 +7,6 @@ use Next\VarDumper\Dumper;
|
||||
use Next\VarDumper\DumperHandler;
|
||||
use support\exception\BusinessException;
|
||||
use support\exception\Handler;
|
||||
use support\Log;
|
||||
use Throwable;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
@ -22,10 +21,6 @@ class ExceptionHandler extends Handler
|
||||
if ($exception instanceof Dumper) {
|
||||
return \response(self::convertToHtml($exception));
|
||||
}elseif ($exception instanceof BusinessException) {
|
||||
if ($request->expectsJson()) {
|
||||
Log::error('BusinessException:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
return json(['code' => 0, 'msg' => $exception->getMessage(),'show'=>1]);
|
||||
}
|
||||
return response($exception->getMessage());
|
||||
} elseif ($exception instanceof \Exception) {
|
||||
$isDebug = config('app.debug');
|
||||
@ -37,12 +32,9 @@ class ExceptionHandler extends Handler
|
||||
$error['file'] = $exception->getFile();
|
||||
$error['line'] = $exception->getLine();
|
||||
}
|
||||
Log::error('Exception:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
return response(json_encode($error, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
// 非json请求则返回一个页面
|
||||
Log::error('other:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]);
|
||||
|
||||
return new Response(200, [], 'msg:'.$exception->getMessage().'。line:'.$exception->getLine().'。file:'.$exception->getFile());
|
||||
}
|
||||
}
|
||||
|
20
app/MyBusinessException.php
Normal file
20
app/MyBusinessException.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app;
|
||||
|
||||
use support\exception\BusinessException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class MyBusinessException extends BusinessException
|
||||
{
|
||||
public function render(Request $request): ?Response
|
||||
{
|
||||
// json请求返回json数据
|
||||
if ($request->expectsJson()) {
|
||||
return json(['code' => $this->getCode() ?: 500, 'msg' => $this->getMessage(),'show'=>1]);
|
||||
}
|
||||
// 非json请求则返回一个页面
|
||||
return new Response(200, [], $this->getMessage());
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\ActivityZoneLists;
|
||||
use app\admin\logic\ActivityZoneLogic;
|
||||
use app\admin\validate\ActivityZoneValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityZone控制器
|
||||
* Class ActivityZoneController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class ActivityZoneController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ActivityZoneLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ActivityZoneValidate())->post()->goCheck('add');
|
||||
$result = ActivityZoneLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ActivityZoneLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ActivityZoneValidate())->post()->goCheck('edit');
|
||||
$result = ActivityZoneLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ActivityZoneLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ActivityZoneValidate())->post()->goCheck('delete');
|
||||
ActivityZoneLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ActivityZoneValidate())->goCheck('detail');
|
||||
$result = ActivityZoneLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\lists\ActivityZoneFormLists;
|
||||
use app\admin\logic\ActivityZoneFormLogic;
|
||||
use app\admin\validate\ActivityZoneFormValidate;
|
||||
|
||||
/**
|
||||
* ActivityZoneFormController控制器
|
||||
* Class ActivityZoneFormController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class ActivityZoneFormController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ActivityZoneFormLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ActivityZoneFormValidate())->post()->goCheck('add');
|
||||
$result = ActivityZoneFormLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ActivityZoneFormLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ActivityZoneFormValidate())->post()->goCheck('edit');
|
||||
$result = ActivityZoneFormLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ActivityZoneFormLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ActivityZoneFormValidate())->post()->goCheck('delete');
|
||||
ActivityZoneFormLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ActivityZoneFormValidate())->goCheck('detail');
|
||||
$result = ActivityZoneFormLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$file_path = ActivityZoneFormLogic::export($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\ChangeLogLists;
|
||||
use app\admin\logic\ChangeLogLogic;
|
||||
use app\admin\validate\ChangeLogValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ChangeLog控制器
|
||||
* Class ChangeLogController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class ChangeLogController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ChangeLogLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ChangeLogValidate())->post()->goCheck('add');
|
||||
$result = ChangeLogLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ChangeLogLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ChangeLogValidate())->post()->goCheck('edit');
|
||||
$result = ChangeLogLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ChangeLogLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ChangeLogValidate())->post()->goCheck('delete');
|
||||
ChangeLogLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ChangeLogValidate())->goCheck('detail');
|
||||
$result = ChangeLogLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\api\logic\DemoLogic;
|
||||
use app\common\service\pay\PayService;
|
||||
|
||||
class IndexController extends BaseAdminController
|
||||
@ -25,24 +24,4 @@ class IndexController extends BaseAdminController
|
||||
return $this->fail($e->extra['message']);
|
||||
}
|
||||
}
|
||||
public function demo2()
|
||||
{
|
||||
$res=DemoLogic::test();
|
||||
return $this->success('成功');
|
||||
}
|
||||
public function demo3()
|
||||
{
|
||||
$id=$this->request->get('id');
|
||||
$warehouse_id=$this->request->get('warehouse_id',1);
|
||||
$res=DemoLogic::test3($id,$warehouse_id);
|
||||
return $this->success('成功');
|
||||
}
|
||||
|
||||
public function demo4()
|
||||
{
|
||||
$params=$this->request->get();
|
||||
$is_vip=$this->request->get('is_vip',0);
|
||||
$res=DemoLogic::syncPrice($params,$is_vip);
|
||||
return $this->success('成功');
|
||||
}
|
||||
}
|
@ -1,517 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
|
||||
use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\CeshiCopy;
|
||||
use app\common\model\product_source_link\ProductSourceLink;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
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 PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use support\exception\BusinessException;
|
||||
use support\Redis;
|
||||
use think\facade\Db;
|
||||
|
||||
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 function warehousing()
|
||||
{
|
||||
$warehousingIds = BeforehandOrder::whereIn('id', $this->ids)->where('warehousing_id', '>', 0)->column('warehousing_id');
|
||||
$warehouseOrders = WarehouseOrder::field('id,warehouse_id')->whereIn('id', $warehousingIds)->where('financial_pm', 1)->select()->toArray();
|
||||
$productSourceLinkInfo = [];
|
||||
foreach ($warehouseOrders as $order) {
|
||||
$products = WarehouseProduct::field('id,product_id,nums,purchase,create_time')->where('oid', $order['id'])->select()->toArray();
|
||||
foreach ($products as $product) {
|
||||
$productSourceLink = ProductSourceLink::where('product_id', $product['product_id'])->where('purchase_uid', 20)->where('warehouse_id', $order['warehouse_id'])->find();
|
||||
if (empty($productSourceLink)) {
|
||||
$productSourceLink = new ProductSourceLink();
|
||||
$productSourceLink->product_id = $product['product_id'];
|
||||
$productSourceLink->purchase_uid = 20;
|
||||
$productSourceLink->warehouse_id = $order['warehouse_id'];
|
||||
$productSourceLink->save();
|
||||
}
|
||||
|
||||
$productSourceLinkInfo[] = [
|
||||
'oid' => $productSourceLink['id'],
|
||||
'product_id' => $product['product_id'],
|
||||
'warehouse_id' => $order['warehouse_id'],
|
||||
'nums' => $product['nums'],
|
||||
'current_nums' => $product['nums'],
|
||||
'types' => ProductSourceLinkInfo::TypeIn,
|
||||
'link_id' => $product['id'],
|
||||
'price' => $product['purchase'],
|
||||
'total_price' => bcmul($product['purchase'], $product['nums'], 2),
|
||||
'create_time' => strtotime($product['create_time']),
|
||||
];
|
||||
}
|
||||
}
|
||||
(new ProductSourceLinkInfo())->insertAll($productSourceLinkInfo);
|
||||
}
|
||||
|
||||
public function outbound()
|
||||
{
|
||||
$outboundIds = BeforehandOrder::whereIn('id', $this->ids)->where('outbound_id', '>', 0)->column('outbound_id');
|
||||
$outboundOrders = WarehouseOrder::field('id,warehouse_id,store_id')->whereIn('id', $outboundIds)->where('financial_pm', 0)->select()->toArray();
|
||||
foreach ($outboundOrders as $order) {
|
||||
$products = WarehouseProduct::field('id,product_id,nums,purchase,create_time')->where('oid', $order['id'])->select()->toArray();
|
||||
foreach ($products as $product) {
|
||||
$productSourceLinkInfoLogic = new ProductSourceLinkInfoLogic();
|
||||
$productSourceLinkInfoLogic->warehouseProduct = $product;
|
||||
$productSourceLinkInfoLogic->setInfo([
|
||||
'warehouse_id' => $order['warehouse_id'],
|
||||
'store_id' => $order['store_id'],
|
||||
'link_id' => $product['id'],
|
||||
'create_time' => strtotime($product['create_time']),
|
||||
]);
|
||||
$productSourceLinkInfoLogic->outbound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function activityPrice()
|
||||
{
|
||||
$product = Db::table('la_ceshi_copy_copy')->select()->toArray();
|
||||
$userShip = 43;
|
||||
$insert = [];
|
||||
foreach ($product as $k => $v) {
|
||||
$rate = bcdiv($v['price'], $v['price_two'], 2);
|
||||
$rate = $rate * 100;
|
||||
$insert[] = [
|
||||
'product_id' => $v['product_id'],
|
||||
'group_id' => $userShip,
|
||||
'price_type' => 3,
|
||||
'base_rate' => $rate,
|
||||
'price' => $v['price'],
|
||||
];
|
||||
}
|
||||
StoreProductGroupPrice::insertAll($insert);
|
||||
return $this->data($insert);
|
||||
}
|
||||
|
||||
public function searchProduct()
|
||||
{
|
||||
$product = Db::table('la_ceshi')->select()->toArray();
|
||||
$product = reset_index($product, 'name');
|
||||
$product2 = Db::table('la_ceshi_copy_copy')->select()->toArray();
|
||||
$update = [];
|
||||
foreach ($product2 as $v) {
|
||||
if (isset($product[$v['name']])) {
|
||||
$update[] = [
|
||||
'id' => $v['id'],
|
||||
'product_id' => $product[$v['name']]['product_id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$result = (new CeshiCopy())->saveAll($update);
|
||||
return $this->data($update);
|
||||
}
|
||||
|
||||
public function setPrice()
|
||||
{
|
||||
$file = $this->request->file('file');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($file->getRealPath());
|
||||
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||
$insert = [];
|
||||
$update = [];
|
||||
$productIds = [];
|
||||
foreach ($data as $k => $row) {
|
||||
if ($k < 2) {
|
||||
continue;
|
||||
}
|
||||
if (empty($row[0])) {
|
||||
continue;
|
||||
}
|
||||
$productId = intval($row[0]);
|
||||
if (empty($productId)) {
|
||||
continue;
|
||||
}
|
||||
$productIds[] = $productId;
|
||||
}
|
||||
$products = StoreProduct::whereIn('id', $productIds)->field('id,store_name,purchase')->select()->toArray();
|
||||
$products = reset_index($products, 'id');
|
||||
foreach ($data as $k => $row) {
|
||||
if ($k < 2) {
|
||||
continue;
|
||||
}
|
||||
if (empty($row[0])) {
|
||||
continue;
|
||||
}
|
||||
$productId = intval($row[0]);
|
||||
if (empty($productId)) {
|
||||
continue;
|
||||
}
|
||||
$product = $products[$productId] ?? [];
|
||||
if (empty($product)) {
|
||||
continue;
|
||||
}
|
||||
$groupIds = [
|
||||
5 => 23,
|
||||
7 => 24,
|
||||
9 => 25,
|
||||
11 => 26,
|
||||
13 => 27,
|
||||
15 => 28,
|
||||
17 => 29,
|
||||
19 => 30,
|
||||
21 => 31,
|
||||
23 => 32,
|
||||
25 => 33,
|
||||
27 => 34,
|
||||
29 => 35,
|
||||
31 => 36,
|
||||
33 => 37,
|
||||
35 => 1,
|
||||
37 => 18,
|
||||
39 => 22,
|
||||
];
|
||||
for ($i = 5; $i < 35; $i = $i + 2) {
|
||||
$rate = intval(rtrim($row[$i] ?? 0, '%'));
|
||||
if (empty($rate)) {
|
||||
continue;
|
||||
}
|
||||
$price = $row[$i + 1] ?? 0;
|
||||
if (empty($price)) {
|
||||
$price = $product['purchase'] * (1 + $rate / 100);
|
||||
}
|
||||
$item = [
|
||||
'product_id' => $productId,
|
||||
'group_id' => $groupIds[$i],
|
||||
'price_type' => 3,
|
||||
'base_rate' => 100 + $rate,
|
||||
'price' => $price
|
||||
];
|
||||
$insert[] = $item;
|
||||
}
|
||||
$productGroupPrices = StoreProductGroupPrice::where('product_id', $productId)->whereIn('group_id', [1, 18, 22])->select()->toArray();
|
||||
$groupIds = array_flip($groupIds);
|
||||
foreach ($productGroupPrices as $productGroupPrice) {
|
||||
$cellId = $groupIds[$productGroupPrice['group_id']] ?? 0;
|
||||
$rate = intval(rtrim($row[$cellId] ?? 0, '%'));
|
||||
if (empty($rate)) {
|
||||
continue;
|
||||
}
|
||||
$price = $row[$cellId + 1] ?? 0;
|
||||
if (empty($price)) {
|
||||
$price = $product['purchase'] * (1 + $rate / 100);
|
||||
}
|
||||
if ($price != $productGroupPrice['price']) {
|
||||
$update[] = [
|
||||
'id' => $productGroupPrice['id'],
|
||||
'base_rate' => $rate,
|
||||
'price' => $price,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($insert) > 0) {
|
||||
StoreProductGroupPrice::insertAll($insert);
|
||||
}
|
||||
if (count($update) > 0) {
|
||||
(new StoreProductGroupPrice())->saveAll($update);
|
||||
}
|
||||
return $this->success('插入成功:' . count($insert) . '条,更新成功:' . count($update) . '条');
|
||||
}
|
||||
|
||||
public function fixCategory()
|
||||
{
|
||||
$topCate = StoreCategory::where('pid', 0)->field('id,name,pid')->order('name')->select()->toArray();
|
||||
$topCate = reset_index($topCate, 'name');
|
||||
$sql = [];
|
||||
$time = time();
|
||||
foreach ($topCate as $item) {
|
||||
if (isset($topCate[$item['name'] . '类'])) {
|
||||
$target = $topCate[$item['name'] . '类'];
|
||||
$sql[] = "##原分类id:{$item['id']},原分类名:{$item['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||
$sql[] = "update la_store_product set top_cate_id={$target['id']} where top_cate_id={$item['id']};";
|
||||
$sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item['id']};";
|
||||
$sql[] = "update la_store_category set delete_time=$time where id={$item['id']};";
|
||||
}
|
||||
$secondCate = StoreCategory::where('pid', $item['id'])->field('id,name,pid')->order('name')->select()->toArray();
|
||||
$secondCate = reset_index($secondCate, 'name');
|
||||
foreach ($secondCate as $item2) {
|
||||
if (isset($secondCate[$item2['name'] . '类'])) {
|
||||
$target = $secondCate[$item2['name'] . '类'];
|
||||
$sql[] = "##原分类id:{$item2['id']},原分类名:{$item2['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||
$sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item2['id']};";
|
||||
$sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item2['id']};";
|
||||
$sql[] = "update la_store_category set delete_time=$time where id={$item2['id']};";
|
||||
}
|
||||
$thirdCate = StoreCategory::where('pid', $item2['id'])->field('id,name,pid')->order('name')->select()->toArray();
|
||||
$thirdCate = reset_index($thirdCate, 'name');
|
||||
foreach ($thirdCate as $item3) {
|
||||
if (isset($thirdCate[$item3['name'] . '类'])) {
|
||||
$target = $thirdCate[$item3['name'] . '类'];
|
||||
$sql[] = "##原分类id:{$item3['id']},原分类名:{$item3['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||
$sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item3['id']};";
|
||||
$sql[] = "update la_store_category set delete_time=$time where id={$item3['id']};";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file_put_contents(public_path() . '/update.sql', implode(PHP_EOL, $sql));
|
||||
return $this->success('数据已更新完成', $sql);
|
||||
}
|
||||
|
||||
public function updateProductPriceList()
|
||||
{
|
||||
$file = $this->request->file('file');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($file->getRealPath());
|
||||
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||
$updateCount = 0;
|
||||
$insert = [];
|
||||
$time = time();
|
||||
foreach ($data as $k => $row) {
|
||||
if ($k < 1 || empty($row[0])) {
|
||||
continue;
|
||||
}
|
||||
$product = StoreProduct::where('id', $row[0])->value('id');
|
||||
if (empty($product)) {
|
||||
continue;
|
||||
}
|
||||
for ($i = 1; $i < 5; $i++) {
|
||||
if (empty($row[1 + $i])) {
|
||||
continue;
|
||||
}
|
||||
$insert[] = [
|
||||
'product_id' => $row[0],
|
||||
'price_type' => $i,
|
||||
'rate' => intval(rtrim($row[1 + $i], '%')) + 100,
|
||||
'create_time' => $time,
|
||||
];
|
||||
}
|
||||
}
|
||||
StoreProductPriceList::insertAll($insert);
|
||||
return $this->success('更新成功:' . $updateCount . '条');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$file = $this->request->file('file');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($file->getRealPath());
|
||||
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||
$updateCount = 0;
|
||||
$finishCount = Redis::get('updateFinishCount');
|
||||
$finishCount = empty($finishCount) ? 0 : $finishCount;
|
||||
if ($finishCount >= count($data)) {
|
||||
return $this->success('数据已更新完成');
|
||||
}
|
||||
$max = $finishCount + 100;
|
||||
foreach ($data as $k => $row) {
|
||||
if ($k < (1 + $finishCount) || empty($row[0])) {
|
||||
continue;
|
||||
}
|
||||
if ($k > $max) {
|
||||
break;
|
||||
}
|
||||
$product = StoreProduct::where('id', $row[0])->field('id,store_name,top_cate_id,two_cate_id,cate_id')->findOrEmpty()->toArray();
|
||||
if (empty($product)) {
|
||||
continue;
|
||||
}
|
||||
$result = $this->updateProduct($product, $row);
|
||||
if ($result) {
|
||||
$updateCount++;
|
||||
}
|
||||
}
|
||||
Redis::set('updateFinishCount', 100 + $finishCount);
|
||||
return $this->success('更新成功:' . $updateCount . '条');
|
||||
}
|
||||
|
||||
public function updateProduct($product, $row)
|
||||
{
|
||||
$topCateName = $row[1];
|
||||
$secondCateName = $row[2];
|
||||
$cateName = $row[3];
|
||||
$topCate = StoreCategory::where('name', $topCateName)->value('id');
|
||||
$updateData = [];
|
||||
if (!empty($topCate) && $topCate != $product['top_cate_id']) {
|
||||
$updateData['top_cate_id'] = $topCate;
|
||||
}
|
||||
$secondCateId = StoreCategory::where('pid', $topCate)->where('name', $secondCateName)->value('id');
|
||||
if (empty($secondCateId)) {
|
||||
$secondCate = new StoreCategory();
|
||||
$secondCate->name = $secondCateName;
|
||||
$secondCate->pid = $topCate;
|
||||
$secondCate->save();
|
||||
$secondCateId = $secondCate->id;
|
||||
}
|
||||
if ($secondCateId != $product['two_cate_id']) {
|
||||
$updateData['two_cate_id'] = $secondCateId;
|
||||
}
|
||||
$cateId = StoreCategory::where('pid', $secondCateId)->where('name', $cateName)->value('id');
|
||||
if (empty($cateId)) {
|
||||
$cate = new StoreCategory();
|
||||
$cate->name = $cateName;
|
||||
$cate->pid = $secondCateId;
|
||||
$cate->save();
|
||||
$cateId = $cate->id;
|
||||
}
|
||||
if ($cateId != $product['cate_id']) {
|
||||
$updateData['cate_id'] = $cateId;
|
||||
}
|
||||
if (!empty($updateData)) {
|
||||
StoreProduct::where('id', $row[0])->update($updateData);
|
||||
echo '更新成功ID:' . $row[0] . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function importOrder()
|
||||
{
|
||||
$file = $this->request->file('file');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($file->getRealPath());
|
||||
$sheets = $spreadsheet->getAllSheets();
|
||||
foreach ($sheets as $sheetIndex => $sheet) {
|
||||
$params['is_buyer'] = -1;
|
||||
$params['buyer_id'] = 20;
|
||||
$params['admin_id'] = 1;
|
||||
$params['chef'] = '厨师';
|
||||
$params['chef_phone'] = '13513513513';
|
||||
$params['distribution_personnel'] = '余友"';
|
||||
$params['days'] = 0;
|
||||
$params['mark'] = '内部备注';
|
||||
$params['merchandiser'] = 0;
|
||||
$params['purpose'] = '备注';
|
||||
$params['store_id'] = 4;
|
||||
$params['splitting_officer'] = '分单员';
|
||||
$params['regional_manager'] = '张波';
|
||||
$params['system_store_name'] = '门店员';
|
||||
$params['transporter'] = '运输员';
|
||||
$params['pay_price'] = 0;
|
||||
$params['total_price'] = 0;
|
||||
$params['arrival_time'] = date('Y-m-d H:i:s');
|
||||
$rows = $sheet->toArray();
|
||||
foreach ($rows as $k => $row) {
|
||||
if ($k < 1 || empty($row[2])) {
|
||||
continue;
|
||||
}
|
||||
$product = StoreProduct::where('id', $row[0])->withTrashed()->field('id,package,store_info,marques,unit,price,purchase,after_sales')->findOrEmpty()->toArray();
|
||||
if (empty($product)) {
|
||||
continue;
|
||||
}
|
||||
$totalPrice = bcmul($product['price'], $row[2], 2);
|
||||
$params['total_price'] = bcadd($params['total_price'], $totalPrice, 2);
|
||||
$params['pay_price'] = $params['total_price'];
|
||||
$params['product_arr'][] = [
|
||||
'product_id' => $product['id'],
|
||||
'nums' => $row[2],
|
||||
'package' => $product['package'],
|
||||
'store_info' => $product['store_info'],
|
||||
'marques' => $product['marques'],
|
||||
'unit' => $product['unit'],
|
||||
'price' => $product['price'],
|
||||
'purchase' => $product['purchase'],
|
||||
'after_sales' => $product['after_sales'],
|
||||
'total_price' => $totalPrice,
|
||||
'purchase_total' => $row[3],
|
||||
];
|
||||
}
|
||||
$beforeOrderId = $this->batchCreate($params);
|
||||
$purchaseOffer = PurchaseProductOffer::where('order_id', $beforeOrderId)->field('id,product_id,buyer_nums')->select()->toArray();
|
||||
foreach ($purchaseOffer as $v) {
|
||||
$inStorageParams = [
|
||||
'admin_id' => 0,
|
||||
'bhoid' => $beforeOrderId,
|
||||
'buyer_nums' => $v['buyer_nums'],
|
||||
'id' => $v['id'],
|
||||
'product_id' => $v['product_id'],
|
||||
'warehouse_id' => 1,
|
||||
'warehouse_num' => $v['buyer_nums'],
|
||||
];
|
||||
BeforehandOrderCartInfoLogic::putInStorage($inStorageParams);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success('导入成功');
|
||||
}
|
||||
|
||||
public function batchCreate($params)
|
||||
{
|
||||
if (empty($params['buyer_id'])) {
|
||||
throw new BusinessException('请选择采购员');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$procurementOrder = new BeforehandOrder();
|
||||
$procurementOrder->order_id = getNewOrderId('CG');
|
||||
$procurementOrder->buyer_id = $params['buyer_id'];
|
||||
$procurementOrder->admin_id = $params['admin_id'];
|
||||
$procurementOrder->order_type = 9;
|
||||
$procurementOrder->total_price = $params['total_price'];
|
||||
$procurementOrder->pay_price = $params['pay_price'];
|
||||
$procurementOrder->save();
|
||||
$purchaseOffer = [];
|
||||
$cartInfo = [];
|
||||
foreach ($params['product_arr'] as $product) {
|
||||
if ($product['product_id'] <= 0) {
|
||||
continue;
|
||||
}
|
||||
$cartInfo[] = [
|
||||
'bhoid' => $procurementOrder['id'],
|
||||
'product_id' => $product['product_id'],
|
||||
'unit' => $product['unit'],
|
||||
'cart_num' => $product['nums'],
|
||||
'accept_num' => $product['nums'],
|
||||
'mark' => $product['mark'] ?? '',
|
||||
'is_buyer' => 1,
|
||||
'procurement_order_id' => $procurementOrder['id'],
|
||||
'total_price' => bcmul($product['price'], $product['nums'], 2),
|
||||
'pay_price' => bcmul($product['price'], $product['nums'], 2),
|
||||
'purchase' => $product['purchase'],
|
||||
'uid' => $params['uid'] ?? 0,
|
||||
'price' => $product['price'],
|
||||
'package' => $product['package'],
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
];
|
||||
$purchaseOffer[] = [
|
||||
'order_id' => $procurementOrder['id'],
|
||||
'product_id' => $product['product_id'],
|
||||
'unit' => $product['unit'],
|
||||
'is_buyer' => 1,
|
||||
'need_num' => $product['nums'],
|
||||
'mark' => $product['mark'] ?? '',
|
||||
'buyer_id' => $params['buyer_id'],
|
||||
'buyer_confirm' => 1,
|
||||
'buyer_nums' => $product['nums'],
|
||||
'total_price' => $product['purchase_total'],
|
||||
'status' => 0,
|
||||
'source_order_info' => [
|
||||
[
|
||||
'source_order_id' => $procurementOrder['id'],
|
||||
'product_id' => $product['product_id'],
|
||||
'need_num' => $product['nums'],
|
||||
'mark' => $product['mark'] ?? '',
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
PurchaseProductOffer::insertAll($purchaseOffer);
|
||||
BeforehandOrderCartInfo::insertAll($cartInfo);
|
||||
Db::commit();
|
||||
return $procurementOrder->id;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\PurchaseFundsLists;
|
||||
use app\admin\logic\PurchaseFundsLogic;
|
||||
use app\admin\validate\PurchaseFundsValidate;
|
||||
|
||||
|
||||
/**
|
||||
* PurchaseFunds控制器
|
||||
* Class PurchaseFundsController
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class PurchaseFundsController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new PurchaseFundsLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->post()->goCheck('add');
|
||||
$result = PurchaseFundsLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(PurchaseFundsLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->post()->goCheck('edit');
|
||||
$result = PurchaseFundsLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(PurchaseFundsLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->post()->goCheck('delete');
|
||||
PurchaseFundsLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->goCheck('detail');
|
||||
$result = PurchaseFundsLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->post()->goCheck('delete');
|
||||
$params['approve_uid'] = $this->adminId;
|
||||
PurchaseFundsLogic::audit($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 补充
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function replenish()
|
||||
{
|
||||
$params = (new PurchaseFundsValidate())->post()->goCheck('delete');
|
||||
$params['approve_uid'] = $this->adminId;
|
||||
PurchaseFundsLogic::replenish($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -14,14 +14,11 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\lists\statistics\StoreProductLists;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupLists;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupMonthLists;
|
||||
use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeTwoLists;
|
||||
use app\admin\logic\statistic\ProductStatisticLogic;
|
||||
use app\admin\logic\statistic\TradeStatisticLogic;
|
||||
use app\admin\logic\statistic\UserStatisticLogic;
|
||||
use app\admin\logic\statistic\WarehouseLogic;
|
||||
use app\admin\logic\WorkbenchLogic;
|
||||
use app\store\logic\WorkbenchLogic as LogicWorkbenchLogic;
|
||||
use DateInterval;
|
||||
@ -53,13 +50,13 @@ class WorkbenchController extends BaseAdminController
|
||||
public function store_index()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
if (!isset($params['store_id']) || $params['store_id'] == '') {
|
||||
$params['store_id'] = 0;
|
||||
if(!isset($params['store_id']) ||$params['store_id']==''){
|
||||
$params['store_id'] =0;
|
||||
}
|
||||
if (!isset($params['start_time']) || $params['start_time'] == '') {
|
||||
$time = explode('-', $this->getDay(''));
|
||||
$params['start_time'] = $time[0];
|
||||
$params['end_time'] = $time[1];
|
||||
if(!isset($params['start_time']) ||$params['start_time']==''){
|
||||
$time=explode('-', $this->getDay(''));
|
||||
$params['start_time'] =$time[0];
|
||||
$params['end_time'] =$time[1];
|
||||
}
|
||||
|
||||
$result = LogicWorkbenchLogic::index($params);
|
||||
@ -103,24 +100,24 @@ class WorkbenchController extends BaseAdminController
|
||||
public function get_trend()
|
||||
{
|
||||
$dates = [];
|
||||
$date = $this->request->get('date', '');
|
||||
$days = 31;
|
||||
if ($date) {
|
||||
$arr = explode('-', $date);
|
||||
if ($arr[0] == $arr[1]) {
|
||||
$date = new DateTime($arr[0]);
|
||||
$dates[] = $date->format("Y-m-d");
|
||||
} else {
|
||||
$datetime_start = new DateTime($arr[0]);
|
||||
$datetime_end = new DateTime($arr[1]);
|
||||
$days = $datetime_start->diff($datetime_end)->days;
|
||||
for ($i = 0; $i <= $days; $i++) {
|
||||
$date = new DateTime($datetime_start->format('Y-m-d'));
|
||||
$date->modify('+' . $i . ' days');
|
||||
$dates[] = $date->format('Y-m-d');
|
||||
}
|
||||
$date=$this->request->get('date','');
|
||||
$days=31;
|
||||
if($date){
|
||||
$arr=explode('-', $date);
|
||||
if($arr[0]==$arr[1]){
|
||||
$date = new DateTime($arr[0]);
|
||||
$dates[] = $date->format("Y-m-d");
|
||||
}else{
|
||||
$datetime_start = new DateTime($arr[0]);
|
||||
$datetime_end = new DateTime($arr[1]);
|
||||
$days = $datetime_start->diff($datetime_end)->days;
|
||||
for ($i = 0; $i <= $days; $i++) {
|
||||
$date = new DateTime($datetime_start->format('Y-m-d'));
|
||||
$date->modify('+' . $i . ' days');
|
||||
$dates[] = $date->format('Y-m-d');
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}else{
|
||||
$today = new DateTime();
|
||||
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
|
||||
$thirtyDaysAgo->modify('-30 days');
|
||||
@ -167,10 +164,10 @@ class WorkbenchController extends BaseAdminController
|
||||
*/
|
||||
public function get_product_ranking()
|
||||
{
|
||||
$date = $this->request->get('date', '');
|
||||
$date=$this->request->get('date','');
|
||||
$where['create_time'] = $this->getDay($date);
|
||||
$data = (new ProductStatisticLogic())->get_product_ranking($where);
|
||||
return $this->success('', $data);
|
||||
$data=(new ProductStatisticLogic())->get_product_ranking($where);
|
||||
return $this->success('',$data);
|
||||
}
|
||||
|
||||
//-------------------------------用户统计---------------------------------------//
|
||||
@ -180,13 +177,13 @@ class WorkbenchController extends BaseAdminController
|
||||
*/
|
||||
public function get_user_basic()
|
||||
{
|
||||
$date = $this->request->get('date', '');
|
||||
$store_id = $this->request->get('store_id');
|
||||
$date=$this->request->get('date','');
|
||||
$store_id=$this->request->get('store_id');
|
||||
$where['create_time'] = $this->getDay($date);
|
||||
if ($store_id) {
|
||||
if($store_id){
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$data = (new UserStatisticLogic())->getBasic($where);
|
||||
$data=(new UserStatisticLogic())->getBasic($where);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
@ -195,13 +192,13 @@ class WorkbenchController extends BaseAdminController
|
||||
*/
|
||||
public function get_user_trend()
|
||||
{
|
||||
$date = $this->request->get('date', '');
|
||||
$store_id = $this->request->get('store_id');
|
||||
$date=$this->request->get('date','');
|
||||
$store_id=$this->request->get('store_id');
|
||||
$where['create_time'] = $this->getDay($date);
|
||||
if ($store_id) {
|
||||
if($store_id){
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$data = (new UserStatisticLogic())->getTrend($where);
|
||||
$data=(new UserStatisticLogic())->getTrend($where);
|
||||
|
||||
return $this->data($data);
|
||||
}
|
||||
@ -209,7 +206,7 @@ class WorkbenchController extends BaseAdminController
|
||||
//当日订单金额
|
||||
public function top_trade()
|
||||
{
|
||||
$logic = (new TradeStatisticLogic());
|
||||
$logic=(new TradeStatisticLogic());
|
||||
$leftToday = $logic->getTopLeftTrade(['create_time' => 'today']);
|
||||
$leftyestoday = $logic->getTopLeftTrade(['create_time' => 'yestoday']);
|
||||
$rightOne = $logic->getTopRightOneTrade();
|
||||
@ -232,27 +229,25 @@ class WorkbenchController extends BaseAdminController
|
||||
//交易趋势
|
||||
public function bottom_trade()
|
||||
{
|
||||
$date = $this->request->get('date', '');
|
||||
$data = (new TradeStatisticLogic())->getBottomTrade(['data' => $this->getDay($date)]);
|
||||
$date=$this->request->get('date','');
|
||||
$data=(new TradeStatisticLogic())->getBottomTrade(['data'=>$this->getDay($date)]);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时商品统计
|
||||
*/
|
||||
public function product_order()
|
||||
{
|
||||
public function product_order(){
|
||||
return $this->dataLists(new StoreOrderCartInfoGroupLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* 月销售商品统计
|
||||
*/
|
||||
public function product_month_order()
|
||||
{
|
||||
public function product_month_order(){
|
||||
return $this->dataLists(new StoreOrderCartInfoGroupMonthLists());
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 格式化时间
|
||||
* @param $time
|
||||
* @return string
|
||||
@ -264,9 +259,9 @@ class WorkbenchController extends BaseAdminController
|
||||
if (!$startTime && !$endTime) {
|
||||
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
|
||||
} else {
|
||||
if ($startTime == $endTime) {
|
||||
return $startTime . '-' . $endTime . ' 23:59:59';
|
||||
} else {
|
||||
if($startTime==$endTime){
|
||||
return $startTime . '-' . $endTime.' 23:59:59';
|
||||
}else{
|
||||
return $startTime . '-' . $endTime;
|
||||
}
|
||||
}
|
||||
@ -274,86 +269,4 @@ class WorkbenchController extends BaseAdminController
|
||||
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
|
||||
}
|
||||
}
|
||||
//-------------------------------统计仓库---------------------------------------//
|
||||
|
||||
/**
|
||||
* 统计仓库头
|
||||
* @return array
|
||||
*/
|
||||
public function total_warehouse()
|
||||
{
|
||||
$data = WarehouseLogic::total_warehouse();
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计仓库列表
|
||||
* @return array
|
||||
*/
|
||||
public function warehouse_list()
|
||||
{
|
||||
return $this->dataLists(new StoreProductLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计门店仓库总库存
|
||||
* @return array
|
||||
*/
|
||||
public function total_warehouse_list()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
$data = WarehouseLogic::total_warehouse_list($parmas, $parmas['type'] ?? 1);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计门店仓库总库存
|
||||
* @return array
|
||||
*/
|
||||
public function total_warehouse_product_list()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
$data = WarehouseLogic::total_warehouse_product_list($parmas, $parmas['type'] ?? 1);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 负库存检测
|
||||
*/
|
||||
public function negative_inventory()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
if($parmas['type'] == 3){
|
||||
return $this->dataLists(new WarehouseProductStoregeTwoLists());
|
||||
}
|
||||
$data = WarehouseLogic::negativeInventory($parmas);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 负库存归零
|
||||
*/
|
||||
public function update_negative_zero()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
$res = WarehouseLogic::updateNegativeZero($parmas,$this->adminId);
|
||||
if($res){
|
||||
return $this->data([], '操作成功');
|
||||
}else{
|
||||
return $this->data([], '操作失败', 400);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 更新库存和价值
|
||||
*/
|
||||
public function stock_product_price()
|
||||
{
|
||||
$parmas = $this->request->get();
|
||||
$res = WarehouseLogic::stockProductPrice($parmas);
|
||||
if($res){
|
||||
return $this->success('操作成功,请刷新页面',[],1,1);
|
||||
}else{
|
||||
return $this->fail('操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\accounts_receivable;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\AccountsReceivableInfoLists;
|
||||
use app\admin\lists\AccountsReceivableLists;
|
||||
use app\admin\logic\AccountsReceivableLogic;
|
||||
use app\admin\validate\app_update\AppUpdateValidate;
|
||||
|
||||
/**
|
||||
* Class AccountsReceivableController
|
||||
* @package app\admin\controller\accounts_receivable
|
||||
*/
|
||||
class AccountsReceivableController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AccountsReceivableLists());
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = AccountsReceivableLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AccountsReceivableLogic::getError());
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$params = (new AppUpdateValidate())->post()->goCheck('delete');
|
||||
AccountsReceivableLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$params = (new AppUpdateValidate())->goCheck('detail');
|
||||
$result = AccountsReceivableLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function record()
|
||||
{
|
||||
return $this->dataLists(new AccountsReceivableInfoLists());
|
||||
}
|
||||
|
||||
public function statistics()
|
||||
{
|
||||
$result = AccountsReceivableLogic::statistics();
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
@ -1,365 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\beforehand_order\BeforehandOrderLists;
|
||||
use app\admin\lists\beforehand_order\BeforehandOrderTwoLists;
|
||||
use app\admin\lists\beforehand_order\BeforehandOrderThreeLists;
|
||||
use app\admin\logic\beforehand_order\BeforehandOrderLogic;
|
||||
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\xlsx\Beforehand;
|
||||
|
||||
/**
|
||||
* 预订单表控制器
|
||||
* Class BeforehandOrderController
|
||||
* @package app\admin\controller\beforehand_order
|
||||
*/
|
||||
class BeforehandOrderController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderLists());
|
||||
}
|
||||
/**
|
||||
* 列表统计
|
||||
*/
|
||||
public function statistics_count()
|
||||
{
|
||||
$params=$this->request->get();
|
||||
$data=BeforehandOrderLogic::statisticsCount($params);
|
||||
return $this->data($data);
|
||||
}
|
||||
public function warehousing_lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderTwoLists());
|
||||
}
|
||||
public function outbound_lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderThreeLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加预订单表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$other_data = [
|
||||
'nickname' => $params['nickname'] ?? '',
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'address' => $params['address'] ?? '',
|
||||
'arrival_time' => $params['arrival_time'] ?? '',
|
||||
'purpose' => $params['purpose'] ?? '',
|
||||
'tables' => $params['tables'] ?? '',
|
||||
'days' => $params['days'] ?? '',
|
||||
'chef' => $params['chef'] ?? '',
|
||||
'chef_phone' => $params['chef_phone'] ?? '',
|
||||
'splitting_officer' => $params['splitting_officer'] ?? '',
|
||||
'merchandiser' => $params['merchandiser'] ?? '',
|
||||
'distribution_personnel' => $params['distribution_personnel'] ?? '',
|
||||
'transporter' => $params['transporter'] ?? '',
|
||||
'system_store_name' => $params['system_store_name'] ?? '',
|
||||
'regional_manager' => $params['regional_manager'] ?? '',
|
||||
];
|
||||
$params['other_data'] = $other_data;
|
||||
if ($params['order_type'] == 7) {
|
||||
PurchaseProductOfferLogic::batchCreate($params);
|
||||
} else {
|
||||
BeforehandOrderLogic::add($params);
|
||||
}
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 生成支付订单
|
||||
*/
|
||||
public function generateOrder()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = BeforehandOrderLogic::generateOrder($params);
|
||||
return $this->success('生成成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 一键出库
|
||||
*/
|
||||
public function createOutboundOrder()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = BeforehandOrderLogic::createOutboundOrder($params);
|
||||
|
||||
return $this->success('出库成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 一键报损出库
|
||||
*/
|
||||
public function createOutboundDamageOrder()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = BeforehandOrderLogic::createOutboundOrder($params);
|
||||
|
||||
return $this->success('出库成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 订单转预定单
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function orderTransferAdvanceOrder()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$params['mark'] = '订单转预定单';
|
||||
$result = BeforehandOrderLogic::orderTransferAdvanceOrder($params);
|
||||
return $this->success('转单成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = BeforehandOrderLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(BeforehandOrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除预订单表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = BeforehandOrderLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 确认预订单
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderLogic::confirm($params);
|
||||
return $this->success('确认成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$order = BeforehandOrder::where('id', $params['id'])->field('outbound_id,order_sn')->find();
|
||||
if (!$order) {
|
||||
return $this->fail('未生成出库单');
|
||||
}
|
||||
$warehouseOrder = WarehouseOrder::where('id', $order['outbound_id'])->field('store_id,delivery_time')->find();
|
||||
$system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('name');
|
||||
$data = WarehouseProduct::where('oid', $order['outbound_id'])->field('product_id,nums')->select()
|
||||
->each(function ($item) use ($system_store, $warehouseOrder, $order) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['nums']) . '/' . $unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if ($warehouseOrder['oid']) {
|
||||
$find = StoreOrder::where('order_id', $order['order_sn'])->field('real_name,user_address')->find();
|
||||
if ($find) {
|
||||
$item['address'] = $find['real_name'] . ' ' . $find['user_address'];
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path = (new Beforehand())->export($data, $system_store);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出订单
|
||||
*/
|
||||
public function export_order()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
|
||||
$cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select();
|
||||
|
||||
$file_path = (new Beforehand())->order($order, $cart_info);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出清单
|
||||
*/
|
||||
public function export_order_list()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::OrderList($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出分单
|
||||
*/
|
||||
public function order_allocation()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::OrderAllocation($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 采购信息
|
||||
*/
|
||||
public function order_info()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::OrderInfo($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出出库
|
||||
*/
|
||||
public function order_outbound()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
if (!empty($params['type']) && $params['type'] == 2) {
|
||||
$file_path = BeforehandOrderLogic::OrderOutbound2($params);
|
||||
} else {
|
||||
$file_path = BeforehandOrderLogic::OrderOutbound($params);
|
||||
}
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出会员出库
|
||||
*/
|
||||
public function order_outbound3()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::OrderOutbound3($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出财务出库
|
||||
*/
|
||||
public function order_outbound_finance()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::OrderOutboundFinance($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出退库
|
||||
*/
|
||||
public function stock_return()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::StockReturn($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
/**
|
||||
* 导出退供应商
|
||||
*/
|
||||
public function return_supplier()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = BeforehandOrderLogic::ReturnSupplier($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
public function settle()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderLogic::settleOrder($params);
|
||||
return $this->success('确认成功');
|
||||
}
|
||||
|
||||
public function logList()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = BeforehandOrderLogic::logList($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function saveLog()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['submit_admin_id'] = $this->adminId;
|
||||
BeforehandOrderLogic::saveLog($params);
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
|
||||
public function confirmLog()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['confirm_admin_id'] = $this->adminId;
|
||||
BeforehandOrderLogic::confirmLog($params);
|
||||
return $this->success('确认成功');
|
||||
}
|
||||
|
||||
public function copy()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
BeforehandOrderLogic::copy($params);
|
||||
return $this->success('复制成功');
|
||||
}
|
||||
|
||||
public function transfer()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
BeforehandOrderLogic::transfer($params);
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\beforehand_order_cart_info;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists;
|
||||
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
|
||||
/**
|
||||
* 预订单购物详情表控制器
|
||||
* Class BeforehandOrderCartInfoController
|
||||
* @package app\admin\controller\beforehand_order_cart_info
|
||||
*/
|
||||
class BeforehandOrderCartInfoController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单购物详情表列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderCartInfoLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加预订单购物详情表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = BeforehandOrderCartInfoLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
|
||||
}
|
||||
/**
|
||||
* @notes 添加预订单购物详情表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function append_add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = BeforehandOrderCartInfoLogic::appendAdd($params);
|
||||
return $this->success('追加成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单购物详情无需采购
|
||||
*/
|
||||
public function procurement_status(){
|
||||
$id=$this->request->post('id');
|
||||
|
||||
$res=BeforehandOrderCartInfo::where('id',$id)->find();
|
||||
$find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find();
|
||||
if (empty($find)) {
|
||||
$rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$res['bhoid']}}')";
|
||||
$find = PurchaseProductOffer::where(['product_id' => $res['product_id']])->whereRaw($rawSql)->find();
|
||||
}
|
||||
if($find){
|
||||
if($find['buyer_confirm']==1){
|
||||
return $this->fail('该商品已采购完成,无法更改状态');
|
||||
}else{
|
||||
if (!empty($find['source_order_info'])) {
|
||||
$json = $find['source_order_info'];
|
||||
foreach ($json as $key => $value) {
|
||||
if ($value['source_order_id'] == $res['bhoid']) {
|
||||
$find->need_num = $find->need_num - $value['need_num'];
|
||||
unset($json[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$find->source_order_info = array_values($json);
|
||||
}
|
||||
if ($find->need_num <= 0) {
|
||||
$find->delete_time = time();
|
||||
}
|
||||
$find->save();
|
||||
}
|
||||
}
|
||||
$res->save(['is_buyer'=>-1]);
|
||||
if($res){
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}else{
|
||||
return $this->fail('操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 一键入库
|
||||
*/
|
||||
public function one_click_storage(){
|
||||
if (time() > 1737561600) {
|
||||
return $this->fail('不允许一键入库');
|
||||
}
|
||||
$params=$this->request->post();
|
||||
$params['admin_id']=$this->adminId;
|
||||
BeforehandOrderCartInfoLogic::oneClickStorage($params);
|
||||
return $this->success('入库成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 编辑预订单购物详情表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = BeforehandOrderCartInfoLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除预订单购物详情表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderCartInfoLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单购物详情表详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = BeforehandOrderCartInfoLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
/**
|
||||
* 修改数量
|
||||
*/
|
||||
public function edit_nums()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = BeforehandOrderCartInfoLogic::editNums($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function fix()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
BeforehandOrderCartInfoLogic::fixAcceptNum($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function syncPrice()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
BeforehandOrderCartInfoLogic::syncPrice($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function setStoreSale()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderCartInfoLogic::setStoreSale($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分拣入库
|
||||
*/
|
||||
public function putInStorage()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
BeforehandOrderCartInfoLogic::putInStorage($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\delivery_service;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\delivery_service\DeliveryServiceLists;
|
||||
use app\admin\logic\delivery_service\DeliveryServiceLogic;
|
||||
use app\admin\validate\delivery_service\DeliveryServiceValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 配送员控制器
|
||||
* Class DeliveryServiceController
|
||||
* @package app\admin\controller\delivery_service
|
||||
*/
|
||||
class DeliveryServiceController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配送员列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new DeliveryServiceLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加配送员
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DeliveryServiceValidate())->post()->goCheck('add');
|
||||
$result = DeliveryServiceLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(DeliveryServiceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑配送员
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DeliveryServiceValidate())->post()->goCheck('edit');
|
||||
$result = DeliveryServiceLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(DeliveryServiceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除配送员
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DeliveryServiceValidate())->post()->goCheck('delete');
|
||||
DeliveryServiceLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配送员详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DeliveryServiceValidate())->goCheck('detail');
|
||||
$result = DeliveryServiceLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\inventory_store;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\inventory_store\InventoryStoreLists;
|
||||
use app\admin\logic\inventory_store\InventoryStoreLogic;
|
||||
use app\admin\validate\inventory_store\InventoryStoreValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 门店盘存控制器
|
||||
* Class InventoryStoreController
|
||||
* @package app\admin\controller\inventory_store
|
||||
*/
|
||||
class InventoryStoreController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店盘存列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new InventoryStoreLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加门店盘存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new InventoryStoreValidate())->post()->goCheck('add');
|
||||
$result = InventoryStoreLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryStoreLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑门店盘存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new InventoryStoreValidate())->post()->goCheck('edit');
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = InventoryStoreLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryStoreLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 门店盘存核准
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function enter_nums()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = InventoryStoreLogic::enterNums($params);
|
||||
if (true === $result) {
|
||||
return $this->success('核准成功', [], 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\inventory_transfer;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\inventory_transfer\InventoryTransferLists;
|
||||
use app\admin\logic\inventory_transfer\InventoryTransferLogic;
|
||||
use app\admin\validate\inventory_transfer\InventoryTransferValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商品调拨控制器
|
||||
* Class InventoryTransferController
|
||||
* @package app\admin\controller\inventory_transfer
|
||||
*/
|
||||
class InventoryTransferController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new InventoryTransferLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品调拨
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new InventoryTransferValidate())->post()->goCheck('add');
|
||||
$result = InventoryTransferLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryTransferLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品调拨
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new InventoryTransferValidate())->post()->goCheck('edit');
|
||||
$result = InventoryTransferLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryTransferLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品调拨
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->fail('删除功能暂未开放');
|
||||
$params = (new InventoryTransferValidate())->post()->goCheck('delete');
|
||||
InventoryTransferLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new InventoryTransferValidate())->goCheck('detail');
|
||||
$result = InventoryTransferLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\inventory_transfer_order;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\inventory_transfer_order\InventoryTransferOrderLists;
|
||||
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
|
||||
use app\admin\validate\inventory_transfer_order\InventoryTransferOrderValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商品调拨订单控制器
|
||||
* Class InventoryTransferOrderController
|
||||
* @package app\admin\controller\inventory_transfer_order
|
||||
*/
|
||||
class InventoryTransferOrderController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨订单列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new InventoryTransferOrderLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品调拨订单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = InventoryTransferOrderLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryTransferOrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品调拨订单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new InventoryTransferOrderValidate())->post()->goCheck('edit');
|
||||
$result = InventoryTransferOrderLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryTransferOrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品调拨订单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new InventoryTransferOrderValidate())->post()->goCheck('delete');
|
||||
InventoryTransferOrderLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨订单详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new InventoryTransferOrderValidate())->goCheck('detail');
|
||||
$result = InventoryTransferOrderLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核商品调拨订单
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
$params = (new InventoryTransferOrderValidate())->post()->goCheck('delete');
|
||||
$order = InventoryTransferOrderLogic::detail($params);
|
||||
InventoryTransferOrderLogic::audit($order);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\inventory_warehouse;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\inventory_warehouse\InventoryWarehouseLists;
|
||||
use app\admin\logic\inventory_warehouse\InventoryWarehouseLogic;
|
||||
use app\admin\validate\inventory_warehouse\InventoryWarehouseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 仓库盘存控制器
|
||||
* Class InventoryWarehouseController
|
||||
* @package app\admin\controller\inventory_warehouse
|
||||
*/
|
||||
class InventoryWarehouseController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库盘存列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new InventoryWarehouseLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加仓库盘存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new InventoryWarehouseValidate())->post()->goCheck('add');
|
||||
$result = InventoryWarehouseLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryWarehouseLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑仓库盘存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new InventoryWarehouseValidate())->post()->goCheck('edit');
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = InventoryWarehouseLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(InventoryWarehouseLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除仓库盘存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new InventoryWarehouseValidate())->post()->goCheck('delete');
|
||||
InventoryWarehouseLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 门店盘存核准
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function enter_nums()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['warehouse_id']=1;
|
||||
$result = InventoryWarehouseLogic::enterNums($params);
|
||||
if (true === $result) {
|
||||
return $this->success('核准成功', [], 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\product_source_link;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\product_source_link\ProductSourceLinkLists;
|
||||
use app\admin\logic\product_source_link\ProductSourceLinkLogic;
|
||||
use app\admin\validate\product_source_link\ProductSourceLinkValidate;
|
||||
use app\common\model\product_source_link\ProductSourceLink;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\xlsx\ProductSourceLinkXsl;
|
||||
|
||||
|
||||
/**
|
||||
* 商品溯源管理控制器
|
||||
* Class ProductSourceLinkController
|
||||
* @package app\admin\controller\product_source_link
|
||||
*/
|
||||
class ProductSourceLinkController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源管理列表
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ProductSourceLinkLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品溯源管理
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ProductSourceLinkValidate())->post()->goCheck('add');
|
||||
$result = ProductSourceLinkLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProductSourceLinkLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品溯源管理
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ProductSourceLinkValidate())->post()->goCheck('edit');
|
||||
$result = ProductSourceLinkLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProductSourceLinkLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品溯源管理
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProductSourceLinkValidate())->post()->goCheck('delete');
|
||||
ProductSourceLinkLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源管理详情
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ProductSourceLinkValidate())->goCheck('detail');
|
||||
$result = ProductSourceLinkLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$query = ProductSourceLink::field('id,purchase_uid,product_id,warehouse_id');
|
||||
if (!empty($params['product_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', "%{$params['product_name']}%")->column('id');
|
||||
$query->whereIn('product_id', $productIds);
|
||||
}
|
||||
if (!empty($params['purchase_uid'])) {
|
||||
$query->where('purchase_uid', $params['purchase_uid']);
|
||||
}
|
||||
if (!empty($params['warehouse_id'])) {
|
||||
$query->where('warehouse_id', $params['warehouse_id']);
|
||||
}
|
||||
$list = $query->with(['product', 'purchase'])
|
||||
->field(['id', 'purchase_uid', 'product_id'])
|
||||
->order(['id' => 'desc'])
|
||||
->group('purchase_uid,product_id')
|
||||
->select()
|
||||
->toArray();
|
||||
$linkInfos = ProductSourceLinkInfo::whereIn('oid', array_column($list, 'id'))->select()->toArray();
|
||||
$orderSnList = WarehouseProduct::field('id,code')->whereIn('id', array_unique(array_column($linkInfos, 'link_id')))->select()->toArray();
|
||||
$orderSnList = reset_index($orderSnList, 'id');
|
||||
foreach ($list as &$item) {
|
||||
$item['in_order_no'] = [];
|
||||
$item['out_order_no'] = [];
|
||||
$item['in_num'] = 0;
|
||||
$item['out_num'] = 0;
|
||||
foreach ($linkInfos as $linkInfo) {
|
||||
if ($linkInfo['oid'] == $item['id']) {
|
||||
$orderSnItem = $orderSnList[$linkInfo['link_id']] ?? [];
|
||||
if ($linkInfo['types'] == ProductSourceLinkInfo::TypeIn) {
|
||||
if (!empty($orderSnItem)) {
|
||||
$item['in_order_no'][] = $orderSnItem['code'];
|
||||
}
|
||||
$item['in_num'] = bcadd($item['in_num'], $linkInfo['nums'], 2);
|
||||
} else {
|
||||
if (!empty($orderSnItem)) {
|
||||
$item['out_order_no'][] = $orderSnItem['code'];
|
||||
}
|
||||
$item['out_num'] = bcadd($item['out_num'], $linkInfo['nums'], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['in_order_no'] = !empty($item['in_order_no']) ? implode(',', $item['in_order_no']) : '';
|
||||
$item['out_order_no'] =!empty($item['out_order_no']) ? implode(',', $item['out_order_no']) : '';
|
||||
}
|
||||
$file_path = (new ProductSourceLinkXsl())->export($list);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\product_source_link_info;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\product_source_link_info\ProductSourceLinkInfoLists;
|
||||
use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic;
|
||||
use app\admin\validate\product_source_link_info\ProductSourceLinkInfoValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商品溯源详细控制器
|
||||
* Class ProductSourceLinkInfoController
|
||||
* @package app\admin\controller\product_source_link_info
|
||||
*/
|
||||
class ProductSourceLinkInfoController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源详细列表
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ProductSourceLinkInfoLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品溯源详细
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ProductSourceLinkInfoValidate())->post()->goCheck('add');
|
||||
$result = ProductSourceLinkInfoLogic::add($params);
|
||||
if ($result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProductSourceLinkInfoLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品溯源详细
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ProductSourceLinkInfoValidate())->post()->goCheck('edit');
|
||||
$result = ProductSourceLinkInfoLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProductSourceLinkInfoLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品溯源详细
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProductSourceLinkInfoValidate())->post()->goCheck('delete');
|
||||
ProductSourceLinkInfoLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源详细详情
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ProductSourceLinkInfoValidate())->goCheck('detail');
|
||||
$result = ProductSourceLinkInfoLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,16 +1,11 @@
|
||||
<?php
|
||||
|
||||
<?php
|
||||
namespace app\admin\controller\purchase_order;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\purchase_order\PurchaseOrderLists;
|
||||
use app\admin\lists\purchase_order_info\PurchaseOrderInfoLists;
|
||||
use app\admin\lists\store_order\StoreOrderLists;
|
||||
use app\admin\logic\purchase_order\PurchaseOrderLogic;
|
||||
use app\common\model\purchase_order\PurchaseOrder;
|
||||
|
||||
class PurchaseOrderController extends BaseAdminController
|
||||
{
|
||||
class PurchaseOrderController extends BaseAdminController{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
@ -23,31 +18,24 @@ class PurchaseOrderController extends BaseAdminController
|
||||
/**
|
||||
* 合并今日商户订单
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
PurchaseOrderLogic::mergeOrder($data);
|
||||
if (PurchaseOrderLogic::hasError()) {
|
||||
return $this->fail(PurchaseOrderLogic::getError());
|
||||
}
|
||||
public function add(){
|
||||
PurchaseOrderLogic::StoreTodayOrder();
|
||||
return $this->success('合并成功');
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 合并今日平台订单
|
||||
*/
|
||||
public function platform()
|
||||
{
|
||||
public function platform(){
|
||||
PurchaseOrderLogic::platformTodayOrder();
|
||||
return $this->success('合并成功');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$res = PurchaseOrderLogic::detail($id);
|
||||
public function detail(){
|
||||
$id=$this->request->get('id');
|
||||
$res=PurchaseOrderLogic::detail($id);
|
||||
return $this->data($res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\purchase_order_info;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\logic\purchase_order_info\PurchaseOrderInfoLogic;
|
||||
|
||||
/**
|
||||
* 采购订单详情控制器
|
||||
* Class PurchaseOrderInfoController
|
||||
* @package app\admin\controller\purchase_order_info
|
||||
*/
|
||||
class PurchaseOrderInfoController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 编辑采购供应链商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
switch ($params['type']) {
|
||||
case 'buyer':
|
||||
PurchaseOrderInfoLogic::buyer($params);
|
||||
break;
|
||||
default:
|
||||
return $this->fail('参数错误');
|
||||
break;
|
||||
}
|
||||
if (PurchaseOrderInfoLogic::hasError()) {
|
||||
return $this->fail(PurchaseOrderInfoLogic::getError());
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\purchase_product_offer;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\purchase_product_offer\PurchaseProductOfferLists;
|
||||
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||
use app\admin\validate\purchase_product_offer\PurchaseProductOfferValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 采购商品控制器
|
||||
* Class PurchaseProductOfferController
|
||||
* @package app\admin\controller\purchase_product_offer
|
||||
*/
|
||||
class PurchaseProductOfferController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取采购商品列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new PurchaseProductOfferLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加采购商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PurchaseProductOfferValidate())->post()->goCheck('add');
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = PurchaseProductOfferLogic::add($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 一键添加往期采购商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function add_purchases_one_click()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = PurchaseProductOfferLogic::AddPurchasesOneClick($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑采购商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
switch ($params['type']) {
|
||||
case 'buyer':
|
||||
PurchaseProductOfferLogic::buyer($params);
|
||||
break;
|
||||
default:
|
||||
return $this->fail('参数错误');
|
||||
break;
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置采购信息
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function setProcureInfo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
if($params['supplier_id']=='' ||$params['supplier_id']<=0){
|
||||
return $this->fail('请选择供应商');
|
||||
}
|
||||
$params['admin_id']=$this->adminId;
|
||||
PurchaseProductOfferLogic::setProcureInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
public function setBatchProcureInfo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
PurchaseProductOfferLogic::setBatchProcureInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 分拣设置
|
||||
*/
|
||||
public function setStoreroomInfo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
PurchaseProductOfferLogic::setStoreroomInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
// public function setStoreroomInfoTwo()
|
||||
// {
|
||||
// $params = $this->request->post();
|
||||
// PurchaseProductOfferLogic::setStoreroomInfoTwo($params);
|
||||
// return $this->success('设置成功', [], 1, 1);
|
||||
// }
|
||||
/**
|
||||
* @notes 删除采购商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new PurchaseProductOfferValidate())->post()->goCheck('delete');
|
||||
PurchaseProductOfferLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取采购商品详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PurchaseProductOfferValidate())->goCheck('detail');
|
||||
$result = PurchaseProductOfferLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
@ -46,13 +46,18 @@ class StoreBranchProductController extends BaseAdminController
|
||||
{
|
||||
$params = (new StoreProductValidate())->post()->goCheck('add');
|
||||
$result = StoreProductLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
public function update()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
StoreBranchProductLogic::edit($params);
|
||||
if (StoreBranchProductLogic::hasError()) {
|
||||
return $this->fail(StoreBranchProductLogic::getError());
|
||||
}
|
||||
return $this->success('更新成功', [], 1, 1);
|
||||
}
|
||||
|
||||
@ -65,8 +70,13 @@ class StoreBranchProductController extends BaseAdminController
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
|
||||
return $this->fail('不能编辑');
|
||||
foreach ($params['data'] as $k => $v) {
|
||||
StoreProductLogic::stock($v);
|
||||
if (StoreProductLogic::hasError()) {
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
}
|
||||
return $this->success('操作成功,等待门店确认', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,8 +103,6 @@ class StoreBranchProductController extends BaseAdminController
|
||||
*/
|
||||
public function edit_stock()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
StoreBranchProductLogic::stock($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
|
@ -62,18 +62,7 @@ class StoreExtractController extends BaseAdminController
|
||||
}
|
||||
return $this->fail(StoreExtractLogic::getError());
|
||||
}
|
||||
/**
|
||||
* @notes 确认提现
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 17:09
|
||||
*/
|
||||
public function enter()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreExtractLogic::Enter($params);
|
||||
return $this->success('提现成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除门店提现
|
||||
|
@ -77,12 +77,5 @@ class StoreFinanceFlowController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = StoreFinanceFlowLogic::export($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -7,26 +7,11 @@ use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_order\StoreOrderLists;
|
||||
use app\admin\lists\store_order\StoreRefundOrderLists;
|
||||
use app\admin\logic\store_order\StoreOrderLogic;
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\admin\validate\store_order\StoreOrderValidate;
|
||||
use app\api\logic\order\OrderLogic;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\RefundOrderService;
|
||||
use app\common\service\xlsx\Beforehand;
|
||||
use app\common\service\xlsx\OrderDetail;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 订单列表控制器
|
||||
@ -66,14 +51,12 @@ class StoreOrderController extends BaseAdminController
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$params = (new StoreOrderValidate())->post()->goCheck('add');
|
||||
$result = StoreOrderLogic::add($params);
|
||||
if (StoreOrderLogic::hasError()) {
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
} else {
|
||||
return $this->success('添加成功,该订单不会因为系统时间而删除', [], 1, 1);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
@ -126,191 +109,18 @@ class StoreOrderController extends BaseAdminController
|
||||
* @return \support\Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function refund(RefundOrderService $refundOrderService)
|
||||
public function refund()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$detail = StoreOrder::where('order_id', $params['order_id'])->findOrEmpty();
|
||||
if (empty($detail)) {
|
||||
$params = (new StoreOrderValidate())->goCheck('refund');
|
||||
$detail = StoreOrder::where('order_id',$params['order_id'])->findOrEmpty();
|
||||
if(empty($detail)){
|
||||
return $this->fail('无该订单请检查');
|
||||
}
|
||||
$params['id'] = $detail['id'];
|
||||
if (!isset($params['product_arr'])) {
|
||||
$params['product_arr'] = StoreOrderCartInfo::where('oid', $detail['id'])->where('status', '<>', 2)->field('product_id,cart_num')->select()->toArray();
|
||||
$res=StoreOrderLogic::refund($detail,$params);
|
||||
if($res==false){
|
||||
return $this->fail('退款失败');
|
||||
}
|
||||
$refundOrderService->refund($detail['uid'], $params);
|
||||
return $this->success('退款成功',[],1,1);
|
||||
}
|
||||
/**
|
||||
* 核销
|
||||
*/
|
||||
public function writeoff_order()
|
||||
{
|
||||
$params =$this->request->post();
|
||||
if (empty($params['verify_code'])) {
|
||||
return $this->fail('核销码不存在');
|
||||
}
|
||||
if (empty($params['store_id'])) {
|
||||
return $this->fail('门店id不存在');
|
||||
}
|
||||
$params['staff_id']=0;
|
||||
$res = OrderLogic::writeOff($params);
|
||||
if ($res) {
|
||||
return $this->success('核销成功',[],1,1);
|
||||
}
|
||||
return $this->fail('核销失败');
|
||||
}
|
||||
/**
|
||||
* 设置配送员
|
||||
*/
|
||||
public function set_delivery()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$delivery_uid = $this->request->post('delivery_uid');
|
||||
$find = DeliveryService::where('id', $delivery_uid)->find();
|
||||
if (empty($find)) {
|
||||
return $this->fail('配送员不存在');
|
||||
}
|
||||
$res = StoreOrder::where('id', $id)->update(['delivery_uid' => $delivery_uid, 'delivery_name' => $find['nickname'], 'delivery_id' => $find['phone']]);
|
||||
if ($res) {
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
return $this->success('设置失败');
|
||||
return $this->success('退款成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配送表格
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$system_store = $this->request->post('system_store');
|
||||
$xlsx = new OrderDetail();
|
||||
$order = StoreOrder::where('id', $id)->findOrEmpty();
|
||||
$time = strtotime('+1 day', $order['pay_time']);
|
||||
$order['pay_time'] = date('Y-m-d H:i:s', $order['pay_time']);
|
||||
$order['delivery_time'] = date('Y-m-d', $time);
|
||||
$data = StoreOrderCartInfo::where('oid', $id)->select();
|
||||
foreach ($data as $key => &$value) {
|
||||
if (in_array($order['store_id'], [17, 18])) {
|
||||
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id', $order['store_id'])->withTrashed()->find();
|
||||
} else {
|
||||
$find = StoreProduct::where('id', $value->product_id)->find();
|
||||
}
|
||||
$value->store_name = $find['store_name'] ?? '';
|
||||
$value->store_info = $find['store_info'] ?? '';
|
||||
$value->total_price = bcmul($value['price'], $value['cart_num'], 2);
|
||||
if (!empty($find['unit'])) {
|
||||
$value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
} else {
|
||||
$value->unit_name = '';
|
||||
}
|
||||
}
|
||||
$order['total_price'] = $order['pay_price'];
|
||||
$file_path = $xlsx->export($data, $system_store, $order);
|
||||
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建出库单
|
||||
*/
|
||||
public function createOutboundOrder()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$store_id = $this->request->post('store_id');
|
||||
$warehouse_id = $this->request->post('warehouse_id');
|
||||
$delivery_time = $this->request->post('delivery_time');
|
||||
$mark = $this->request->post('mark');
|
||||
$find = WarehouseOrder::where('oid', $id)->find();
|
||||
if ($find) {
|
||||
return $this->fail('该订单已创建出库单');
|
||||
}
|
||||
$product_arr = StoreOrderCartInfo::where('oid', $id)->field('oid,product_id id,price,total_price,cart_num stock')->select();
|
||||
if (!$product_arr) {
|
||||
return $this->fail('无商品');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr = [
|
||||
'oid' => $id,
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'store_id' => $store_id,
|
||||
'supplier_id' => 0,
|
||||
'code' => getNewOrderId('CK'),
|
||||
'admin_id' => $this->adminId,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 0,
|
||||
'mark' => $mark ?? "",
|
||||
];
|
||||
$arr['delivery_time'] = strtotime($delivery_time);
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($product_arr as $key => $arr) {
|
||||
$data = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'product_id' => $arr['id'],
|
||||
'store_id' => $store_id,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 1,
|
||||
'nums' => $arr['stock'],
|
||||
'status' => 1,
|
||||
'admin_id' => $this->adminId,
|
||||
];
|
||||
$storeProduct = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||
if ($arr['stock'] == 0) {
|
||||
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $storeProduct);
|
||||
} else {
|
||||
$data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2);
|
||||
$data['purchase'] = $storeProduct['purchase'];
|
||||
$data['oid'] = $res['id'];
|
||||
$data['financial_pm'] = 0;
|
||||
WarehouseProductLogic::add($data,1,$this->adminId);
|
||||
$finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||
WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签
|
||||
*/
|
||||
public function export_tags()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$order = StoreOrder::where('id', $id)->field('store_id,uid,real_name,user_address')->find();
|
||||
|
||||
$system_store = SystemStore::where('id', $order['store_id'])->value('introduction');
|
||||
$data = StoreOrderCartInfo::where('oid', $id)->field('oid,product_id,cart_num')->select()
|
||||
->each(function ($item) use ($system_store, $order) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['cart_num']) . '/' . $unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if ($order['uid']) {
|
||||
$item['address'] = $order['real_name'] . ' ' . $order['user_address'];
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path = (new Beforehand())->export($data, $system_store);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签
|
||||
*/
|
||||
public function setSystemStore()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
StoreOrder::where('id',$params['id'])->update(['store_id'=>$params['store_id']]);
|
||||
StoreOrderCartInfo::where('oid',$params['id'])->update(['store_id'=>$params['store_id']]);
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
}
|
||||
}
|
@ -7,12 +7,6 @@ use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoLists;
|
||||
use app\admin\lists\store_order_cart_info\StoreOrderCartInfoTwoLists;
|
||||
use app\admin\logic\store_order_cart_info\StoreOrderCartInfoLogic;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\service\xlsx\OrderDetail;
|
||||
|
||||
/**
|
||||
* 订单购物详情控制器
|
||||
@ -53,85 +47,6 @@ class StoreOrderCartInfoController extends BaseAdminController
|
||||
}
|
||||
$res=(new StoreOrderCartInfoLogic())->curve($product_id,$start_time,$end_time);
|
||||
return $this->data($res);
|
||||
}
|
||||
/**
|
||||
* @notes 追加订单商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:02
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreOrderCartInfoLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 编辑订单商品
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 16:02
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreOrderCartInfoLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreOrderCartInfoLogic::del($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 导出配送表格
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$store_id = $this->request->post('store_id');
|
||||
$start_time = $this->request->post('start_time');
|
||||
$end_time = $this->request->post('end_time');
|
||||
$is_group = $this->request->post('is_group');
|
||||
$xlsx = new OrderDetail();
|
||||
$where=[];
|
||||
if(!empty($store_id)){
|
||||
$where[]=['store_id','=',$store_id];
|
||||
$system_store=SystemStore::where('id',$store_id)->value('name');
|
||||
}else{
|
||||
$system_store = '无标题';
|
||||
}
|
||||
if(!empty($start_time)){
|
||||
$where[]=['create_time','between',[strtotime($start_time),strtotime($end_time)]];
|
||||
}
|
||||
if(!empty($is_group)){
|
||||
$data = StoreOrderCartInfo::where($where)->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id'])->select();
|
||||
}else{
|
||||
$data = StoreOrderCartInfo::where($where)->select();
|
||||
|
||||
}
|
||||
$order['pay_time']='';
|
||||
$order['delivery_time']='';
|
||||
$order['order_id']='';
|
||||
|
||||
$total_num=0;
|
||||
$total_price=0;
|
||||
foreach ($data as $key => &$value) {
|
||||
$find=StoreProduct::where('id',$value->product_id)->find();
|
||||
$value->store_name=$find['store_name']??'';
|
||||
$value->store_info=$find['store_info']??'';
|
||||
if(!empty($find['unit'])){
|
||||
$value->unit_name=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
}else{
|
||||
$value->unit_name='';
|
||||
}
|
||||
$total_num+=$value->cart_num;
|
||||
$total_price+=$value->total_price;
|
||||
}
|
||||
$order['total_num']=$total_num;
|
||||
$order['total_price']=$total_price;
|
||||
$file_path = $xlsx->export($data,$system_store,$order);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
|
||||
}
|
||||
}
|
@ -6,10 +6,7 @@ namespace app\admin\controller\store_product;
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_product\StoreProductLists;
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\admin\validate\store_product\StoreProductValidate;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use Webman\RedisQueue\Redis;
|
||||
|
||||
@ -44,7 +41,10 @@ class StoreProductController extends BaseAdminController
|
||||
{
|
||||
$params = (new StoreProductValidate())->post()->goCheck('add');
|
||||
$result = StoreProductLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
@ -58,28 +58,12 @@ class StoreProductController extends BaseAdminController
|
||||
{
|
||||
$params = (new StoreProductValidate())->post()->goCheck('edit');
|
||||
$result = StoreProductLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改商品状态
|
||||
* @return \think\response\Json
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function status(){
|
||||
$params=$this->request->post();
|
||||
$admin_info=$this->adminInfo;
|
||||
if($admin_info['job_ids']){
|
||||
foreach ($admin_info['job_ids'] as $key => $job_id) {
|
||||
if($job_id==2){
|
||||
return $this->fail('无权限操作');
|
||||
}
|
||||
}
|
||||
}
|
||||
StoreProduct::where('id',$params['id'])->update(['is_show'=>$params['is_show']]);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除商品列表
|
||||
@ -108,47 +92,27 @@ class StoreProductController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 复制商品
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$find = StoreProduct::where('id', $params['product_id'])->findOrEmpty()->toArray();
|
||||
foreach ($params['store_arr'] as $key => $store_id) {
|
||||
StoreProductLogic::ordinary($find, $store_id, $this->adminId, $find);
|
||||
}
|
||||
return $this->success('复制成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 复制商品到仓库
|
||||
* @author likeadmin
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function copyWarehouse()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
StoreProductLogic::copyWarehouse($params);
|
||||
return $this->success('复制成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品导入到门店
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
return $this->fail('接口已关闭');
|
||||
$product_arr = $this->request->post('product_arr');
|
||||
$store_arr = $this->request->post('store_arr');
|
||||
$stock_type = $this->request->post('stock_type',1);
|
||||
$warehouse_id = $this->request->post('warehouse_id');
|
||||
if (count($store_arr) == 1) {
|
||||
$store_id = $store_arr[0];
|
||||
foreach ($product_arr as $key => $arr) {
|
||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
|
||||
}
|
||||
} else {
|
||||
foreach ($product_arr as $key => $arr) {
|
||||
foreach ($store_arr as $k => $store_id) {
|
||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId,'warehouse_id'=>$warehouse_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('已导入后台队列,请在门店入库记录中查看');
|
||||
}
|
||||
|
||||
public function restore()
|
||||
{
|
||||
$params = (new StoreProductValidate())->post()->goCheck('delete');
|
||||
StoreProductLogic::restore($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\store_product_group_price;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_product_group_price\StoreProductGroupPriceLists;
|
||||
use app\admin\logic\store_product_group_price\StoreProductGroupPriceLogic;
|
||||
use app\admin\validate\store_product_group_price\StoreProductGroupPriceValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 分组报价控制器
|
||||
* Class StoreProductGroupPriceController
|
||||
* @package app\admin\controller\store_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new StoreProductGroupPriceLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new StoreProductGroupPriceValidate())->post()->goCheck('add');
|
||||
$result = StoreProductGroupPriceLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductGroupPriceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreProductGroupPriceLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new StoreProductGroupPriceValidate())->post()->goCheck('delete');
|
||||
StoreProductGroupPriceLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = StoreProductGroupPriceLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\store_product_low_stock;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_product_low_stock\StoreProductLowStockLists;
|
||||
use app\admin\logic\store_product_low_stock\StoreProductLowStockLogic;
|
||||
use app\admin\validate\store_product_low_stock\StoreProductLowStockValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商品缺库存控制器
|
||||
* Class StoreProductLowStockController
|
||||
* @package app\admin\controller\store_product_low_stock
|
||||
*/
|
||||
class StoreProductLowStockController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品缺库存列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new StoreProductLowStockLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品缺库存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new StoreProductLowStockValidate())->post()->goCheck('add');
|
||||
$result = StoreProductLowStockLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductLowStockLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品缺库存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new StoreProductLowStockValidate())->post()->goCheck('edit');
|
||||
$result = StoreProductLowStockLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductLowStockLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品缺库存
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new StoreProductLowStockValidate())->post()->goCheck('delete');
|
||||
StoreProductLowStockLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品缺库存详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new StoreProductLowStockValidate())->goCheck('detail');
|
||||
$result = StoreProductLowStockLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\store_product_price;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_product_price\StoreProductPriceLists;
|
||||
use app\admin\logic\store_product_price\StoreProductPriceLogic;
|
||||
use app\admin\validate\store_product_price\StoreProductPriceValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商品价格更改控制器
|
||||
* Class StoreProductPriceController
|
||||
* @package app\admin\controller\store_product_price
|
||||
*/
|
||||
class StoreProductPriceController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品价格更改列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new StoreProductPriceLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品价格更改
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new StoreProductPriceValidate())->post()->goCheck('add');
|
||||
$result = StoreProductPriceLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductPriceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商品价格更改
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreProductPriceLogic::edit($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
|
||||
}
|
||||
/**
|
||||
* @notes 确认改价
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function enterPrice()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreProductPriceLogic::enterPrice($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商品价格更改
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new StoreProductPriceValidate())->post()->goCheck('delete');
|
||||
StoreProductPriceLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品价格更改详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new StoreProductPriceValidate())->goCheck('detail');
|
||||
$result = StoreProductPriceLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$file_path = StoreProductPriceLogic::export($params);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
public function chart()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$data = StoreProductPriceLogic::chart($params);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\supplier;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\supplier\SupplierLists;
|
||||
use app\admin\logic\supplier\SupplierLogic;
|
||||
use app\admin\validate\supplier\SupplierValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 供应链控制器
|
||||
* Class SupplierController
|
||||
* @package app\admin\controller\supplier
|
||||
*/
|
||||
class SupplierController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应链列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupplierLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加供应链
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupplierValidate())->post()->goCheck('add');
|
||||
$result = SupplierLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupplierLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑供应链
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupplierValidate())->post()->goCheck('edit');
|
||||
$result = SupplierLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupplierLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除供应链
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupplierValidate())->post()->goCheck('delete');
|
||||
SupplierLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应链详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupplierValidate())->goCheck('detail');
|
||||
$result = SupplierLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -40,6 +40,35 @@ class SystemStoreController extends BaseAdminController
|
||||
{
|
||||
return $this->dataLists(new SystemStoreSourceLists());
|
||||
}
|
||||
/**
|
||||
* @notes 根据商品源获取门店列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/05/31 17:45
|
||||
*/
|
||||
public function source_product_update_store()
|
||||
{
|
||||
$addList=$this->request->post('addList');
|
||||
$product_id=$this->request->post('product_id');
|
||||
if($addList){
|
||||
foreach ($addList as $key=>$value){
|
||||
StoreProductLogic::copy($product_id,$value);
|
||||
if(StoreProductLogic::hasError()){
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
$removeList=$this->request->post('removeList');
|
||||
if($removeList){
|
||||
foreach ($removeList as $key=>$value){
|
||||
StoreProductLogic::store_del($product_id,$value);
|
||||
if(StoreProductLogic::hasError()){
|
||||
return $this->fail(StoreProductLogic::getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加门店列表
|
||||
|
@ -5,13 +5,9 @@ namespace app\admin\controller\system_store_storage;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\system_store_storage\SystemStoreStorageLists;
|
||||
use app\admin\lists\warehouse_product\StoreWarehouseProductLists;
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\system_store_storage\SystemStoreStorageLogic;
|
||||
use app\admin\validate\system_store_storage\SystemStoreStorageValidate;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||
|
||||
|
||||
/**
|
||||
* 门店入库记录控制器
|
||||
@ -30,8 +26,7 @@ class SystemStoreStorageController extends BaseAdminController
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
// return $this->dataLists(new SystemStoreStorageLists());
|
||||
return $this->dataLists(new StoreWarehouseProductLists());
|
||||
return $this->dataLists(new SystemStoreStorageLists());
|
||||
}
|
||||
|
||||
|
||||
@ -60,12 +55,13 @@ class SystemStoreStorageController extends BaseAdminController
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$id = $this->request->post('id',0);
|
||||
if($id==0){
|
||||
return $this->fail('参数错误');
|
||||
$params = (new SystemStoreStorageValidate())->post()->goCheck('edit');
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = SystemStoreStorageLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
SystemStoreStorageLogic::edit(['id'=>$id,'admin_id'=>$this->adminId], $this->adminId);
|
||||
return $this->success('操作成功',[]);
|
||||
return $this->fail(SystemStoreStorageLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
@ -96,21 +92,5 @@ class SystemStoreStorageController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 批量确认入库
|
||||
*/
|
||||
public function batchConfirm()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
SystemStoreStorageLogic::editAll($params, $this->adminId);
|
||||
return $this->success('操作成功',[]);
|
||||
}
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
SystemStoreStorageLogic::rollback($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ class UserController extends BaseAdminController
|
||||
return $this->dataLists(new UserLists());
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @notes 添加用户列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
@ -61,17 +61,17 @@ class UserController extends BaseAdminController
|
||||
{
|
||||
// $params = (new UserValidate())->post()->goCheck('edit');
|
||||
$params = $this->request->post();
|
||||
$result = UserLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
$result = UserLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
//采购款明细、余额明细、礼品券明细、返还金明细
|
||||
public function fundList()
|
||||
{
|
||||
(new UserValidate())->get()->goCheck('fund');
|
||||
(new UserValidate())->get()->goCheck('fund');
|
||||
$page_no = (int)$this->request->get('page_no', 1);
|
||||
$page_size = (int)$this->request->get('page_size', 15);
|
||||
$params = $this->request->get();
|
||||
@ -81,6 +81,7 @@ class UserController extends BaseAdminController
|
||||
$res['page_no'] = $params['page_no'];
|
||||
$res['page_size'] = $params['page_size'];
|
||||
return $this->success('ok', $res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -90,6 +91,7 @@ class UserController extends BaseAdminController
|
||||
public function userSing()
|
||||
{
|
||||
return $this->dataLists(new UserSignLogLists());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -105,24 +107,10 @@ class UserController extends BaseAdminController
|
||||
$params['page_no'] = $page_no > 0 ? $page_no : 1;
|
||||
$params['page_size'] = $page_size > 0 ? $page_size : 15;
|
||||
$uid = $uid['id'];
|
||||
$res = UserLogic::giftList($uid, $params);
|
||||
$res = UserLogic::giftList($uid,$params);
|
||||
$res['page_no'] = $params['page_no'];
|
||||
$res['page_size'] = $params['page_size'];
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
|
||||
//设置采购款
|
||||
public function setPurchaseFunds()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$res = UserLogic::PurchaseFunds($params);
|
||||
return $this->success( '设置成功',[],1,1);
|
||||
}
|
||||
//设置余额
|
||||
public function setnowMoney()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$res = UserLogic::nowMoney($params);
|
||||
return $this->success( '设置成功',[],1,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,329 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\warehouse_order;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\warehouse_order\WarehouseOrderLists;
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_order\WarehouseOrderLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\admin\validate\warehouse_order\WarehouseOrderValidate;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\service\xlsx\Beforehand;
|
||||
use app\common\service\xlsx\OrderDetail;
|
||||
use app\common\service\xlsx\WarehouseOrdeRentry;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 仓储商品单控制器
|
||||
* Class WarehouseOrderController
|
||||
* @package app\admin\controller\warehouse_order
|
||||
*/
|
||||
class WarehouseOrderController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓储商品单列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
|
||||
return $this->dataLists(new WarehouseOrderLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加入库单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = WarehouseOrderLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 添加出库单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function outbound()
|
||||
{
|
||||
$product_arr = $this->request->post('product_arr');
|
||||
$warehouse_id = $this->request->post('warehouse_id');
|
||||
$delivery_time = $this->request->post('delivery_time');
|
||||
$mark = $this->request->post('mark');
|
||||
$type = $this->request->post('order_type', 1);
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($type==1){
|
||||
$code=getNewOrderId('TGY');
|
||||
}else{
|
||||
$code=getNewOrderId('BS');
|
||||
}
|
||||
$arr = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'store_id' => 0,
|
||||
'supplier_id' => 0,
|
||||
'code' => $code,
|
||||
'admin_id' => $this->adminId,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 0,
|
||||
'mark' => $mark ?? "",
|
||||
];
|
||||
$arr['delivery_time'] = strtotime($delivery_time);
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($product_arr as $key => $arr) {
|
||||
$data = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'product_id' => $arr['id'],
|
||||
'store_id' => 0,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 1,
|
||||
'nums' => $arr['stock'],
|
||||
'status' => 1,
|
||||
'admin_id' => $this->adminId,
|
||||
'type' => $type,
|
||||
'order_type' => 0,
|
||||
'code' => $code,
|
||||
];
|
||||
$storeProduct = StoreProduct::where('id', $arr['id'])->find();
|
||||
$data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2);
|
||||
$data['purchase'] = $storeProduct['purchase'];
|
||||
$data['oid'] = $res['id'];
|
||||
$data['financial_pm'] = 0;
|
||||
$data['price'] = $storeProduct['price'];
|
||||
WarehouseProductLogic::setOutbound($data,1,$this->adminId);
|
||||
$finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||
WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
return $this->success('出库成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑仓储商品单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = WarehouseOrderLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑仓储商品单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function update_edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = WarehouseOrderLogic::update_edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail('编辑失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除仓储商品单
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new WarehouseOrderValidate())->post()->goCheck('delete');
|
||||
WarehouseOrderLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓储商品单详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new WarehouseOrderValidate())->goCheck('detail');
|
||||
$result = WarehouseOrderLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
/**
|
||||
* 入库表格
|
||||
*/
|
||||
public function rentry_export()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$xlsx = new WarehouseOrdeRentry();
|
||||
$order = WarehouseOrder::where('id', $id)->findOrEmpty();
|
||||
$data = WarehouseProduct::where('oid', $id)->select();
|
||||
$order['total_num'] = 0;
|
||||
$credit_pay = 0;
|
||||
$cash_pay = 0;
|
||||
foreach ($data as $key => &$value) {
|
||||
$find = StoreProduct::where('id', $value->product_id)->withTrashed()->find();
|
||||
$value->store_name = $find['store_name'] ?? '';
|
||||
$value->store_info = $find['store_info'] ?? '';
|
||||
if (!empty($find['unit'])) {
|
||||
$value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
} else {
|
||||
$value->unit_name = '';
|
||||
}
|
||||
$order['total_num'] += $value->nums;
|
||||
$value->supplier_name = Supplier::where('id', $value->supplier_id)->value('mer_name');
|
||||
if ($value->pay_type == 1) {
|
||||
$credit_pay += $value->total_price;
|
||||
$value->pay_type_name = '赊账';
|
||||
} elseif ($value->pay_type == 2) {
|
||||
$cash_pay += $value->total_price;
|
||||
$value->pay_type_name = '现款';
|
||||
} else {
|
||||
$value->pay_type_name = '未设置';
|
||||
}
|
||||
}
|
||||
$order['credit_pay'] = $credit_pay;
|
||||
$order['cash_pay'] = $cash_pay;
|
||||
$file_path = $xlsx->export($data, $order);
|
||||
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库表格
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$type = $this->request->post('type');
|
||||
if (in_array($type, [2, 3])) {
|
||||
return $this->fail('暂不支持此操作');
|
||||
}
|
||||
$xlsx = new OrderDetail();
|
||||
$order = WarehouseOrder::where('id', $id)->findOrEmpty();
|
||||
$system_store = SystemStore::where('id', $order['store_id'])->value('name');
|
||||
$data = WarehouseProduct::where('oid', $id)->select();
|
||||
$order['total_num'] = 0;
|
||||
$total_price = 0;
|
||||
foreach ($data as $key => &$value) {
|
||||
if (in_array($order['store_id'], [17, 18])) {
|
||||
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id', $order['store_id'])->withTrashed()->find();
|
||||
} else {
|
||||
$find = StoreProduct::where('id', $value->product_id)->withTrashed()->find();
|
||||
}
|
||||
$value->store_name = $find['store_name'] ?? '';
|
||||
$value->store_info = $find['store_info'] ?? '';
|
||||
// if($type==2){
|
||||
// $value->price = $value['purchase'];
|
||||
// $value->total_price=bcmul($value['purchase'],$value['nums'],2);
|
||||
// $total_price+=$value->total_price;
|
||||
// }elseif($type==3){
|
||||
// $value->price = $find['cost'];
|
||||
// $value->total_price=bcmul($find['cost'],$value['nums'],2);
|
||||
// $total_price+=$value->total_price;
|
||||
// }elseif($type==4){
|
||||
// $value->price = $find['price'];
|
||||
// $value->total_price=bcmul($find['price'],$value['nums'],2);
|
||||
// $total_price+=$value->total_price;
|
||||
// }else{
|
||||
if ($type == 1) {
|
||||
$value->price = $value['purchase'];
|
||||
$value->total_price = bcmul($value['purchase'], $value['nums'], 2);
|
||||
$total_price += $value->total_price;
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
$value->cart_num = $value['nums'];
|
||||
if (!empty($find['unit'])) {
|
||||
$value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
} else {
|
||||
$value->unit_name = '';
|
||||
}
|
||||
$order['total_num'] += $value->nums;
|
||||
}
|
||||
if ($type == 2) {
|
||||
$order['total_price'] = $total_price;
|
||||
}
|
||||
$order['delivery_time'] = date('Y-m-d H:i:s', $order['delivery_time']);
|
||||
$order['pay_time'] = $order['create_time'];
|
||||
$order['order_id'] = $order['code'];
|
||||
|
||||
if ($order['oid'] > 0) {
|
||||
$orders = StoreOrder::where('id', $order['oid'])->findOrEmpty();
|
||||
$order['real_name'] = $orders['real_name'];
|
||||
$order['user_phone'] = $orders['user_phone'];
|
||||
$order['user_address'] = $orders['user_address'];
|
||||
}
|
||||
$file_path = $xlsx->export($data, $system_store, $order);
|
||||
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签
|
||||
*/
|
||||
public function export_tags()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$warehouseOrder = WarehouseOrder::where('id', $id)->field('oid,store_id,delivery_time')->find();
|
||||
$system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('introduction');
|
||||
$data = WarehouseProduct::where('oid', $id)->where('financial_pm', 0)->field('oid,product_id,nums')->select()
|
||||
->each(function ($item) use ($system_store, $warehouseOrder) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->withTrashed()->find();
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['nums']) . '/' . $unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if ($warehouseOrder['oid']) {
|
||||
$find = StoreOrder::where('id', $warehouseOrder['oid'])->field('real_name,user_address')->find();
|
||||
if ($find) {
|
||||
$item['address'] = $find['real_name'] . ' ' . $find['user_address'];
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path = (new Beforehand())->export($data, $system_store);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
}
|
@ -31,38 +31,20 @@ class WarehouseProductController extends BaseAdminController
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商品出入库信息
|
||||
* @notes 添加商品仓储信息
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/07/31 16:55
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
return $this->fail('当前接口废弃');
|
||||
|
||||
// $params = $this->request->post();
|
||||
|
||||
// foreach ($params['product_arr'] as $k => $v) {
|
||||
// $data['admin_id'] = $this->adminId;
|
||||
// $data['store_id'] = 0;
|
||||
// $data['supplier_id'] = $params['supplier_id'];
|
||||
// $data['warehouse_id'] = $params['warehouse_id'];
|
||||
// $data['code'] = $params['code'];
|
||||
// $data['product_id'] = $v['product_id'];
|
||||
// $data['nums'] = $v['nums'];
|
||||
// $data['purchase'] = $v['purchase'];
|
||||
// $data['total_price'] = $v['total_price'];
|
||||
// $data['financial_pm'] = 1;
|
||||
// if (!empty($v['manufacture'])) {
|
||||
// $data['manufacture'] = $v['manufacture'];
|
||||
// }
|
||||
// if (!empty($v['expiration_date'])) {
|
||||
// $data['expiration_date'] = $v['expiration_date'];
|
||||
// }
|
||||
// WarehouseProductLogic::add($data);
|
||||
// }
|
||||
// return $this->success('添加成功', [], 1, 1);
|
||||
|
||||
$params = (new WarehouseProductValidate())->post()->goCheck('add');
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = WarehouseProductLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(WarehouseProductLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
@ -74,10 +56,13 @@ class WarehouseProductController extends BaseAdminController
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = WarehouseProductLogic::edit($params,$this->adminId);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
$params = (new WarehouseProductValidate())->post()->goCheck('edit');
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = WarehouseProductLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(WarehouseProductLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
@ -90,9 +75,8 @@ class WarehouseProductController extends BaseAdminController
|
||||
public function delete()
|
||||
{
|
||||
$params = (new WarehouseProductValidate())->post()->goCheck('delete');
|
||||
WarehouseProductLogic::delete($params,$this->adminId);
|
||||
WarehouseProductLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -109,38 +93,16 @@ class WarehouseProductController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 结算
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/07/31 16:55
|
||||
*/
|
||||
public function settlement(){
|
||||
$id=$this->request->post('id');
|
||||
$result = WarehouseProductLogic::settlement($id);
|
||||
return $this->success('结算成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 确认操作
|
||||
*/
|
||||
public function enter()
|
||||
{
|
||||
// $id=$this->request->post('id');
|
||||
// $result = WarehouseProductLogic::enter($id);
|
||||
// if (true === $result) {
|
||||
// return $this->success('编辑成功', [], 1, 1);
|
||||
// }
|
||||
// return $this->fail(WarehouseProductLogic::getError());
|
||||
return $this->success('');
|
||||
public function enter(){
|
||||
$id=$this->request->post('id');
|
||||
$result = WarehouseProductLogic::enter($id);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(WarehouseProductLogic::getError());
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库重置出入库数量
|
||||
*/
|
||||
public function set_nums()
|
||||
{
|
||||
$params=$this->request->post();
|
||||
$result = WarehouseProductLogic::settNums($params,$this->adminId);
|
||||
return $this->success('');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\warehouse_product_return;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\warehouse_product_return\WarehouseProductReturnLists;
|
||||
use app\admin\logic\warehouse_product_return\WarehouseProductReturnLogic;
|
||||
use app\admin\validate\warehouse_product_return\WarehouseProductReturnValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 仓库商品退货处理控制器
|
||||
* Class WarehouseProductReturnController
|
||||
* @package app\admin\controller\warehouse_product_return
|
||||
*/
|
||||
class WarehouseProductReturnController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品退货处理列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new WarehouseProductReturnLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加仓库商品退货处理
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id']=$this->adminId;
|
||||
$result = WarehouseProductReturnLogic::add($params);
|
||||
return $this->success('退回成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑仓库商品退货处理
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new WarehouseProductReturnValidate())->post()->goCheck('edit');
|
||||
$result = WarehouseProductReturnLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(WarehouseProductReturnLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除仓库商品退货处理
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new WarehouseProductReturnValidate())->post()->goCheck('delete');
|
||||
WarehouseProductReturnLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品退货处理详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new WarehouseProductReturnValidate())->goCheck('detail');
|
||||
$result = WarehouseProductReturnLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeLists;
|
||||
use app\admin\logic\warehouse_product_storege\WarehouseProductStoregeLogic;
|
||||
use app\admin\validate\warehouse_product_storege\WarehouseProductStoregeValidate;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
|
||||
|
||||
/**
|
||||
* 仓库商品存储控制器
|
||||
@ -47,19 +47,21 @@ class WarehouseProductStoregeController extends BaseAdminController
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑仓库商品存储
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = WarehouseProductStoregeLogic::edit($params,$this->adminId);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
|
||||
}
|
||||
// /**
|
||||
// * @notes 编辑仓库商品存储
|
||||
// * @return \think\response\Json
|
||||
// * @author admin
|
||||
// * @date 2024/08/01 10:22
|
||||
// */
|
||||
// public function edit()
|
||||
// {
|
||||
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('edit');
|
||||
// $result = WarehouseProductStoregeLogic::edit($params);
|
||||
// if (true === $result) {
|
||||
// return $this->success('编辑成功', [], 1, 1);
|
||||
// }
|
||||
// return $this->fail(WarehouseProductStoregeLogic::getError());
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
@ -88,15 +90,6 @@ class WarehouseProductStoregeController extends BaseAdminController
|
||||
// $result = WarehouseProductStoregeLogic::detail($params);
|
||||
// return $this->data($result);
|
||||
// }
|
||||
/**
|
||||
* @notes 修改商品状态
|
||||
* @return \think\response\Json
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function verify(){
|
||||
$params=$this->request->post();
|
||||
WarehouseProductStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\finance\AccountsReceivable;
|
||||
use app\common\model\finance\AccountsReceivableInfo;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
|
||||
/**
|
||||
* AccountsReceivableInfoLists
|
||||
* Class AccountsReceivableInfoLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class AccountsReceivableInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['accounts_receivable_id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = AccountsReceivableInfo::where($this->searchWhere);
|
||||
$list = $query
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$accountReceivable = AccountsReceivable::field('id,store_id,nickname')->where('id', $this->params['accounts_receivable_id'])->findOrEmpty()->toArray();
|
||||
$store = SystemStore::where('id', $accountReceivable['store_id'])->value('name');
|
||||
$payTypeMap = [
|
||||
1 => '现金',
|
||||
2 => '微信支付',
|
||||
3 => '支付宝支付',
|
||||
4 => '对公账号',
|
||||
5 => '其他'
|
||||
];
|
||||
foreach ($list as &$item) {
|
||||
$item['store_name'] = $store;
|
||||
$item['pay_type_name'] = $payTypeMap[$item['pay_type']];
|
||||
$item['nickname'] = $accountReceivable['nickname'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = AccountsReceivableInfo::where($this->searchWhere);
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\finance\AccountsReceivable;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
|
||||
/**
|
||||
* AccountsReceivableLists
|
||||
* Class AccountsReceivableLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'user_id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = AccountsReceivable::where($this->searchWhere);
|
||||
if (!empty($this->params['order_sn'])) {
|
||||
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
|
||||
$query->whereIn('order_id', $orderIds);
|
||||
}
|
||||
$list = $query->with('info')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$stores = SystemStore::field('id,name')->whereIn('id', array_column($list, 'store_id'))->select()->toArray();
|
||||
$stores = reset_index($stores, 'id');
|
||||
$orderInfo = BeforehandOrder::field('id,order_id')->whereIn('id', array_column($list, 'order_id'))->select()->toArray();
|
||||
$orderInfo = reset_index($orderInfo, 'id');
|
||||
$orderInfo = reset_index($orderInfo, 'id');
|
||||
foreach ($list as &$item) {
|
||||
$item['store_name'] = $stores[$item['store_id']]['name'];
|
||||
$item['order_sn'] = $orderInfo[$item['order_id']]['order_id'];
|
||||
$item['debt_day'] = intval((time() - strtotime($item['create_time'])) / 86400);
|
||||
$item['deadline'] = date('Y-m-d H:i:s', $item['deadline']);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = AccountsReceivable::where($this->searchWhere);
|
||||
if (!empty($this->params['order_sn'])) {
|
||||
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
|
||||
$query->whereIn('order_id', $orderIds);
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\ActivityZoneForm;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
|
||||
/**
|
||||
* ActivityZoneFormLists列表
|
||||
* Class ActivityZoneFormLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class ActivityZoneFormLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type'],
|
||||
'%like%' => ['title'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = ActivityZoneForm::where($this->searchWhere);
|
||||
$cateIds = [];
|
||||
$list = $query
|
||||
->field(['id', 'type', 'cate_ids', 'title', 'remark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) use (&$cateIds) {
|
||||
$item['cate_ids'] = explode(',', $item['cate_ids']);
|
||||
foreach ($item['cate_ids'] as $cateId) {
|
||||
if (!empty($cateId) && !in_array($cateId, $cateIds)) {
|
||||
$cateIds[] = $cateId;
|
||||
}
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$cateList = StoreCategory::where('id', 'in', $cateIds)->field('id,name')->select()->toArray();
|
||||
$cateList = reset_index($cateList, 'id');
|
||||
foreach ($list as &$item) {
|
||||
$item['cate_names'] = [];
|
||||
foreach ($item['cate_ids'] as $cateId) {
|
||||
if (isset($cateList[$cateId])) {
|
||||
$item['cate_names'][] = $cateList[$cateId]['name'];
|
||||
}
|
||||
}
|
||||
$item['cate_names'] = implode(',', $item['cate_names']);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = ActivityZoneForm::where($this->searchWhere);
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\ActivityZone;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityZone列表
|
||||
* Class ActivityZoneLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['form_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = ActivityZone::where($this->searchWhere);
|
||||
if (!empty($this->params['store_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id');
|
||||
$query->whereIn('product_id', $productIds);
|
||||
}
|
||||
$list = $query->with('product')
|
||||
->field(['id', 'form_id', 'product_id'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
$unitIds = array_unique(array_column($list, 'unit'));
|
||||
$unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray();
|
||||
$unit = reset_index($unit, 'id');
|
||||
foreach ($list as &$item) {
|
||||
$item['unit_name'] = $unit[$item['unit']]['name'] ?? '';
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = ActivityZone::where($this->searchWhere);
|
||||
if (!empty($this->params['store_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id');
|
||||
$query->whereIn('product_id', $productIds);
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\ChangeLog;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
|
||||
/**
|
||||
* ChangeLog列表
|
||||
* Class ChangeLogLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class ChangeLogLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['model', 'link_id', 'nums', 'pm'],
|
||||
'%like%' => ['mark', 'url'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ChangeLog::where($this->searchWhere)
|
||||
->field(['id', 'admin_id', 'model', 'link_id', 'nums', 'pm', 'url', 'mark', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(
|
||||
function ($item) {
|
||||
if ($item->admin_id) {
|
||||
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||
} else {
|
||||
$item->admin_name = $item->admin_id;
|
||||
}
|
||||
}
|
||||
)
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ChangeLog::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\model\PurchaseFunds;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\user\User;
|
||||
|
||||
|
||||
/**
|
||||
* PurchaseFunds列表
|
||||
* Class PurchaseFundsLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class PurchaseFundsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['from_uid', 'approve_uid', 'status'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = PurchaseFunds::where($this->searchWhere);
|
||||
if (!empty($this->params['approve_uid'])) {
|
||||
$userIds = Admin::where('name', 'like', '%' . $this->params['approve_uid'] . '%')->column('id');
|
||||
$query->whereIn('approve_uid', $userIds);
|
||||
}
|
||||
if (!empty($this->params['order'])) {
|
||||
$query->order(['id' => 'asc']);
|
||||
} else {
|
||||
$query->order(['id' => 'desc']);
|
||||
}
|
||||
return $query
|
||||
->field(['id', 'from_uid', 'approve_uid', 'amount', 'current_amount', 'supply_price', 'status', 'create_time', 'audit_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
$item['from_name'] = User::where('id', $item['from_uid'])->value('nickname');
|
||||
$item['approve_name'] = empty($item['approve_uid']) ? '' : Admin::where('id', $item['approve_uid'])->value('name');
|
||||
$item['status_name'] = $item->getStatusName();
|
||||
if ($item['current_amount'] < 0) {
|
||||
$item['status'] = -1;
|
||||
$item['status_name'] = '已超额';
|
||||
}
|
||||
$item['audit_time'] = empty($item['audit_time']) ? '' : date('Y-m-d H:i:s', $item['audit_time']);
|
||||
$item['supply_price'] = ProductSourceLinkInfo::where('purchase_funds_id', $item['id'])->where('types', ProductSourceLinkInfo::TypeOut)->sum('total_price');
|
||||
$item['current_profit'] = ProductSourceLinkInfo::where('purchase_funds_id', $item['id'])->where('types', ProductSourceLinkInfo::TypeOrder)->sum('total_price');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return PurchaseFunds::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,287 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 预订单表列表
|
||||
* Class BeforehandOrderLists
|
||||
* @package app\admin\listsbeforehand_order
|
||||
*/
|
||||
class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['id', 'store_id', 'paid', 'status', 'order_type', 'admin_id'],
|
||||
'%like' => ['order_id','order_sn'],
|
||||
'%like%' => ['mark'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$warehouse_type = $this->request->get('warehouse_type', 0);
|
||||
$export = $this->request->get('export');
|
||||
$order_rk = $this->request->get('order_rk', '');
|
||||
$order_ck = $this->request->get('order_ck', '');
|
||||
|
||||
switch ($warehouse_type) {
|
||||
case 1:
|
||||
$this->searchWhere[] = ['is_outbound', '=', 0];
|
||||
$this->searchWhere[] = ['order_type', '<>', 5];
|
||||
break;
|
||||
case 2:
|
||||
$this->searchWhere[] = ['is_outbound', '=', 1];
|
||||
break;
|
||||
case 3:
|
||||
$this->searchWhere[] = ['is_warehousing', '=', 0];
|
||||
break;
|
||||
case 4:
|
||||
$this->searchWhere[] = ['is_warehousing', '=', 1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!empty($this->params['store_staff_id']) || !empty($this->params['is_store'])) {
|
||||
$this->searchWhere[] = ['store_staff_id', '>', 0];
|
||||
}
|
||||
// else {
|
||||
// $this->searchWhere[] = ['store_staff_id', '=', 0];
|
||||
// }
|
||||
if ($order_rk!='') {
|
||||
$oid=WarehouseOrder::where('financial_pm',1)->where('code','like','%'.$order_rk)->column('id');
|
||||
$this->searchWhere[] = ['warehousing_id','in',$oid];
|
||||
}elseif ($order_ck!='') {
|
||||
$oid=WarehouseOrder::where('financial_pm',0)->where('code','like','%'.$order_ck)->column('id');
|
||||
$this->searchWhere[] = ['outbound_id','in',$oid];
|
||||
}
|
||||
$file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data', 'audit_status', 'store_staff_id', 'is_arrears'];
|
||||
$query = BeforehandOrder::where($this->searchWhere);
|
||||
return $query
|
||||
->field($file)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item)use($export) {
|
||||
$item['outbound'] = '';
|
||||
$item['outbound_time'] = '';
|
||||
$item['order_type_name'] = '';
|
||||
if ($item->admin_id) {
|
||||
$item->admin_name = Admin::where(['id' => $item->admin_id])->value('name');
|
||||
} else {
|
||||
$item->admin_name = '';
|
||||
}
|
||||
if ($item->store_staff_id) {
|
||||
$item->admin_name = SystemStoreStaff::where(['id' => $item->store_staff_id])->value('staff_name');
|
||||
}
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type);
|
||||
if ($item->order_type == 5) {
|
||||
$item->outbound = '无须出库';
|
||||
}
|
||||
$item->msg = '';
|
||||
$count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id');
|
||||
if ($count1 > 0) {
|
||||
$item->msg = '有' . $count1 . '个商品采购中';
|
||||
} else {
|
||||
$count2 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 1)->count('id');
|
||||
if ($count2 > 0 && $item['warehousing_id'] == 0) {
|
||||
$item->msg = '商品没有入库';
|
||||
}
|
||||
}
|
||||
if ($item->msg == '') {
|
||||
$count = BeforehandOrderCartInfo::where('is_buyer', 0)->where('bhoid', $item['id'])->count('id');
|
||||
if ($count > 0) {
|
||||
$item->msg = '有' . $count . '个商品未设置';
|
||||
}
|
||||
}
|
||||
$item['warehousing'] = '';
|
||||
$item['system_store'] = '';
|
||||
if ($item['warehousing_id'] > 0) {
|
||||
$item->warehousing = '已入库|' . $item['warehousing_id'];
|
||||
}
|
||||
if ($item['outbound_id'] > 0) {
|
||||
$item->outbound = '已出库|' . $item['outbound_id'];
|
||||
$outboundTime = WarehouseOrder::where('id', $item['outbound_id'])->value('create_time');
|
||||
$item->outbound_time = date('Y-m-d H:i:s', $outboundTime);
|
||||
}
|
||||
if ($item['store_id'] > 0) {
|
||||
$item->system_store = SystemStore::where(['id' => $item['store_id']])->value('name');
|
||||
}
|
||||
$pay_type_name = '';
|
||||
$pay_status = '';
|
||||
$order_rk = '';
|
||||
$order_ck = '';
|
||||
$nickname = '';
|
||||
$phone = '';
|
||||
$address = '';
|
||||
$arrival_time = '';
|
||||
$pay_price = '';
|
||||
$warehousing_price='';
|
||||
$outbound_price='';
|
||||
if($export==2){
|
||||
if($item['order_sn']!=''){
|
||||
$find=StoreOrder::where('order_id',$item['order_sn'])->field('paid,pay_type,pay_price')->find();
|
||||
if($find){
|
||||
switch ($find['pay_type']) {
|
||||
case 3:
|
||||
$pay_type_name = '余额支付';
|
||||
break;
|
||||
case 7:
|
||||
$pay_type_name = '微信支付';
|
||||
break;
|
||||
case 9:
|
||||
$pay_type_name = '微信条码';
|
||||
break;
|
||||
case 13:
|
||||
$pay_type_name = '支付宝条码';
|
||||
break;
|
||||
case 17:
|
||||
$pay_type_name = '现金支付';
|
||||
break;
|
||||
case 18:
|
||||
$pay_type_name = '采购款支付';
|
||||
break;
|
||||
}
|
||||
$item['pay_type_name'] = $pay_type_name;
|
||||
if($find['paid']==1){
|
||||
$pay_status = '已付款';
|
||||
$pay_price = $find['pay_price'];
|
||||
}else{
|
||||
$pay_status = '未付款';
|
||||
}
|
||||
}
|
||||
}
|
||||
if($item['warehousing_id']>0){
|
||||
$warehouseOrder=WarehouseOrder::where('id',$item['warehousing_id'])->field('code,total_price')->find();
|
||||
if($warehouseOrder){
|
||||
$order_rk=$warehouseOrder['code'];
|
||||
$warehousing_price=$warehouseOrder['total_price'];
|
||||
}
|
||||
}
|
||||
if($item['outbound_id']>0){
|
||||
$order_ck=WarehouseOrder::where('id',$item['outbound_id'])->value('code');
|
||||
if($order_ck){
|
||||
$total_price=0;
|
||||
$arr= WarehouseProduct::where('oid',$item['outbound_id'])->field('nums,purchase')->select();
|
||||
foreach ($arr as $k=>$v){
|
||||
$total_price+=bcmul($v['nums'],$v['purchase'],2);
|
||||
}
|
||||
$outbound_price=$total_price;
|
||||
}
|
||||
}
|
||||
$nickname = $item->other_data?->nickname??'';
|
||||
$phone = $item->other_data?->phone??'';
|
||||
$address= $item->other_data?->address??'';
|
||||
$arrival_time = $item->other_data?->arrival_time??'';
|
||||
}
|
||||
$item['pay_status'] = $pay_status;
|
||||
$item['pay_type_name'] = $pay_type_name;
|
||||
$item['order_ck'] = $order_ck;
|
||||
$item['order_rk'] = $order_rk;
|
||||
$item['warehousing_price']=$warehousing_price;
|
||||
$item['outbound_price']=$outbound_price;
|
||||
$item['nickname'] = $nickname;
|
||||
$item['phone'] = $phone;
|
||||
$item['address'] = $address;
|
||||
$item['arrival_time'] = $arrival_time;
|
||||
$item['pay_price'] = $pay_price;
|
||||
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if (!empty($this->params['store_staff_id'])) {
|
||||
$this->searchWhere[] = ['store_staff_id', '>', 0];
|
||||
}
|
||||
return BeforehandOrder::where($this->searchWhere)->count();
|
||||
}
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
|
||||
return '预订单表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'id' => 'ID',
|
||||
'order_id' => '单号',
|
||||
'order_sn' => '支付单号',
|
||||
'order_rk' => '入库单号',
|
||||
'order_ck' => '出库单号',
|
||||
'order_type_name' => '订单类型',
|
||||
'system_store' => '门店',
|
||||
'admin_name' => '门店',
|
||||
'warehousing' => '入库',
|
||||
'warehousing_price' => '入库采购金额',
|
||||
'outbound' => '出库',
|
||||
'outbound_price' => '出库门店供货金额',
|
||||
'total_price' => '总价',
|
||||
'admin_name' => '用户',
|
||||
'mark' => '备注',
|
||||
'msg' => '通知',
|
||||
'create_time' => '时间',
|
||||
'pay_status' => '支付状态',
|
||||
'pay_type_name' => '支付方式',
|
||||
'pay_price' => '实际支付',
|
||||
'nickname' => '用户',
|
||||
'phone' => '手机',
|
||||
'address' => '地址',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 预订单表列表
|
||||
* Class BeforehandOrderThreeLists
|
||||
* @package app\admin\listsbeforehand_order
|
||||
*/
|
||||
class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
public $outbound_id;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$outbound_id=BeforehandOrder::where('id',$this->request->get('id'))->value('outbound_id');
|
||||
if(empty($outbound_id)){
|
||||
return [];
|
||||
}
|
||||
$this->outbound_id=$outbound_id;
|
||||
$this->searchWhere[]=['oid','=',$outbound_id];
|
||||
$this->searchWhere[]=['financial_pm','=',0];
|
||||
$job_ids=$this->adminInfo['job_ids']??[];
|
||||
return WarehouseProduct::where($this->searchWhere)->select()
|
||||
->each(function($item) use($job_ids){
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
if($item['unit']==0){
|
||||
$item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
}else{
|
||||
$item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name');
|
||||
}
|
||||
if($item['supplier_id']){
|
||||
$item['supplier_name']=Supplier::where('id',$item['supplier_id'])->value('mer_name');
|
||||
}else{
|
||||
$item['supplier_name']='';
|
||||
}
|
||||
foreach($job_ids as $k=>$v){
|
||||
if($v==1){
|
||||
$item->purchase='*';
|
||||
$item->total_price='*';
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if($this->outbound_id>0){
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 预订单表列表
|
||||
* Class BeforehandOrderTwoLists
|
||||
* @package app\admin\listsbeforehand_order
|
||||
*/
|
||||
class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
public $warehousing_id;
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$warehousing_id=BeforehandOrder::where('id',$this->request->get('id'))->value('warehousing_id');
|
||||
if(empty($warehousing_id)){
|
||||
return [];
|
||||
}
|
||||
$this->warehousing_id=$warehousing_id;
|
||||
$this->searchWhere[]=['oid','=',$warehousing_id];
|
||||
$this->searchWhere[]=['financial_pm','=',1];
|
||||
$job_ids=$this->adminInfo['job_ids']??[];
|
||||
return WarehouseProduct::where($this->searchWhere)->select()
|
||||
->each(function($item) use($job_ids){
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
if($item['unit']==0){
|
||||
$item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
}else{
|
||||
$item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name');
|
||||
}
|
||||
if($item['supplier_id']){
|
||||
$item['supplier_name']=Supplier::where('id',$item['supplier_id'])->value('mer_name');
|
||||
}else{
|
||||
$item['supplier_name']='';
|
||||
}
|
||||
foreach($job_ids as $k=>$v){
|
||||
if($v==1){
|
||||
$item->purchase='*';
|
||||
$item->total_price='*';
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if($this->warehousing_id>0){
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order_cart_info;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
|
||||
/**
|
||||
* 预订单购物详情表列表
|
||||
* Class BeforehandOrderCartInfoLists
|
||||
* @package app\admin\listsbeforehand_order_cart_info
|
||||
*/
|
||||
class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
public $list;
|
||||
public $fileName;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['bhoid', 'uid', 'product_id'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单购物详情表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$id = $this->request->get('bhoid');
|
||||
$system_store = '';
|
||||
$order_mark = '';
|
||||
if ($this->request->get('export') == 2 && $id) {
|
||||
$find = BeforehandOrder::where('id', $id)->field('store_id,order_id,mark')->find();
|
||||
$system_store = SystemStore::where('id', $find['store_id'])->value('name');
|
||||
$this->fileName = $system_store . '-' . $find['order_id'] . '.xlsx';
|
||||
$order_mark = $find['mark'];
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->get('top_cate')) {
|
||||
$product_id = BeforehandOrderCartInfo::where($this->searchWhere)->column('product_id');
|
||||
$ids = StoreProduct::where('id', 'in', $product_id)->where('top_cate_id', $this->request->get('top_cate'))->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
}
|
||||
}
|
||||
if ($this->request->get('store_name')) {
|
||||
$ids = StoreProduct::where('store_name', 'like', '%'.$this->request->get('store_name').'%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
}
|
||||
}
|
||||
if (!empty($this->params['store_id'])) {
|
||||
$orderIds = BeforehandOrder::where('store_id', $this->params['store_id'])->column('id');
|
||||
$this->searchWhere[] = ['bhoid', 'in', $orderIds];
|
||||
}
|
||||
$list = BeforehandOrderCartInfo::where($this->searchWhere)
|
||||
->field(['id', 'bhoid', 'package', 'store_info', 'marques', 'gross_weight', 'net_weight', 'accept_num', 'after_sales', 'loss', 'uid', 'pay_price', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'purchase', 'price', 'total_price', 'cart_num', 'mark','create_time', 'procurement_order_id', 'store_sale'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) use ($system_store, $order_mark) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,image,unit')->withTrashed()->find();
|
||||
if($find->unit>0){
|
||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||
}else{
|
||||
$item->unit_name = '';
|
||||
}
|
||||
$item['warehouse_stock'] = WarehouseProductStorege::where('product_id', $item['product_id'])->where('warehouse_id',1)->value('nums') ?? 0;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['system_store'] = $system_store;
|
||||
$item['order_mark'] = $order_mark;
|
||||
$item['image'] = $find['image'];
|
||||
$item['unit'] = $find['unit'];
|
||||
$item['top_cate_id'] = $find['top_cate_id'];
|
||||
$item['top_cate_name'] = StoreCategory::where('id', $item['top_cate_id'])->value('name');
|
||||
if ($item->bhoid) {
|
||||
$rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$item->bhoid}}')";
|
||||
$status = PurchaseProductOffer::where(['product_id' => $item->product_id])->whereRaw($rawSql)->value('status');
|
||||
if (is_null($status)) {
|
||||
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
|
||||
}
|
||||
if ($status == 1) {
|
||||
$item->status_name = '已完成';
|
||||
} else {
|
||||
$item->status_name = '采购中';
|
||||
}
|
||||
}
|
||||
$item->is_buyer_name = '';
|
||||
if ($item->is_buyer == 1) {
|
||||
$item->is_buyer_name = '采购';
|
||||
} elseif ($item->is_buyer == 0) {
|
||||
$item->status_name = '待处理';
|
||||
} elseif ($item->is_buyer == -1) {
|
||||
$item->is_buyer_name = '不采购';
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$orderTypeMap = BeforehandOrder::whereIn('id', array_unique(array_column($list, 'bhoid')))->field('id, order_type')->select()->toArray();
|
||||
$orderTypeMap = reset_index($orderTypeMap, 'id');
|
||||
foreach ($list as &$item) {
|
||||
$orderType = $orderTypeMap[$item['bhoid']]['order_type'] ?? '';
|
||||
$item['order_type_name'] = BeforehandOrder::getOrderTypeName($orderType);
|
||||
}
|
||||
$this->list = $list;
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单购物详情表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if (!empty($this->params['store_id'])) {
|
||||
$orderIds = BeforehandOrder::where('store_id', $this->params['store_id'])->column('id');
|
||||
$this->searchWhere[] = ['bhoid', 'in', $orderIds];
|
||||
}
|
||||
return BeforehandOrderCartInfo::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
if ($this->fileName != '') {
|
||||
return $this->fileName;
|
||||
} else {
|
||||
return '预订单商品列表';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
|
||||
if($this->request->get('id')){
|
||||
$data = [
|
||||
'bhoid' => '订单id',
|
||||
'store_name' => '商品名称',
|
||||
'system_store' => '门店',
|
||||
'marques' => '型号',
|
||||
'package' => '包装',
|
||||
'top_cate_name' => '分类',
|
||||
'unit_name' => '单位',
|
||||
'gross_weight' => '毛重',
|
||||
'net_weight' => '净重',
|
||||
'warehouse_stock' => '仓库数量',
|
||||
'cart_num' => '需求数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'after_sales' => '售后',
|
||||
'loss' => '损耗',
|
||||
'mark' => '备注',
|
||||
'order_mark' => '订单备注',
|
||||
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'bhoid' => '订单id',
|
||||
'store_name' => '商品名称',
|
||||
'marques' => '型号',
|
||||
'package' => '包装',
|
||||
'top_cate_name' => '分类',
|
||||
'unit_name' => '单位',
|
||||
'gross_weight' => '毛重',
|
||||
'net_weight' => '净重',
|
||||
'warehouse_stock' => '仓库数量',
|
||||
'cart_num' => '需求数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'after_sales' => '售后',
|
||||
'loss' => '损耗',
|
||||
'mark' => '备注',
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\delivery_service;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 配送员列表
|
||||
* Class DeliveryServiceLists
|
||||
* @package app\admin\listsdelivery_service
|
||||
*/
|
||||
class DeliveryServiceLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['uid', 'nickname', 'phone', 'status','type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配送员列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return DeliveryService::where($this->searchWhere)
|
||||
->field(['id', 'uid', 'nickname', 'phone', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配送员数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return DeliveryService::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\inventory_store;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_store\InventoryStore;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
/**
|
||||
* 门店盘存列表
|
||||
* Class InventoryStoreLists
|
||||
* @package app\admin\listsinventory_store
|
||||
*/
|
||||
class InventoryStoreLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'nums', 'enter_nums', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店盘存列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return InventoryStore::where($this->searchWhere)
|
||||
->field(['id', 'product_id', 'admin_id', 'staff_id', 'store_id', 'nums', 'enter_nums', 'status', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['create_time' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item->status_name = match ($item->status) {
|
||||
0 => '待盘点',
|
||||
1 => '盘点中',
|
||||
2 => '盘点完成',
|
||||
default => '未知',
|
||||
};
|
||||
if($item->admin_id){
|
||||
$item->admin_name = Admin::where('id',$item->admin_id)->value('name');
|
||||
}
|
||||
if($item->staff_id){
|
||||
$item->staff_name = SystemStoreStaff::where('id',$item->staff_id)->value('staff_name');
|
||||
}
|
||||
if($item->store_id){
|
||||
$item->store_name = SystemStore::where('id',$item->store_id)->value('name');
|
||||
}
|
||||
if($item->product_id){
|
||||
$item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店盘存数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/02/14 11:46
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return InventoryStore::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\inventory_transfer;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\inventory_transfer_order\InventoryTransferOrder;
|
||||
|
||||
/**
|
||||
* 商品调拨列表
|
||||
* Class InventoryTransferLists
|
||||
* @package app\admin\listsinventory_transfer
|
||||
*/
|
||||
class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
{
|
||||
|
||||
public $ids;
|
||||
public $store_name;
|
||||
public $bar_code;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type', 'product_id'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('store_name')) {
|
||||
$this->store_name = $this->request->get('store_name');
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if ($this->request->get('order_id')) {
|
||||
$this->store_name = $this->request->get('order_id');
|
||||
$ids = InventoryTransferOrder::where('order_id', 'like', $this->request->get('order_id') . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['oid', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$query = InventoryTransfer::where($this->searchWhere);
|
||||
if (!empty($this->params['warehouse_id'])) {
|
||||
$query->whereRaw("(one_type=2 and one_id={$this->params['warehouse_id']}) or (two_type=2 and two_id={$this->params['warehouse_id']})");
|
||||
}
|
||||
return $query
|
||||
->field(['id','oid', '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)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$find= StoreProduct::where('id',$item->product_id)->withTrashed()->field('store_name,price')->find();
|
||||
$item->order_id= InventoryTransferOrder::where('id',$item->oid)->value('order_id');
|
||||
$item->store_name=$find['store_name'];
|
||||
$item->price=$find['price'];
|
||||
$item->total_price=bcmul($find['price'],$item['nums'],2);
|
||||
$type_name='';
|
||||
if($item->one_type==1){
|
||||
$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');
|
||||
}else{
|
||||
$type_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');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/13 16:18
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if ($this->store_name||$this->bar_code) {
|
||||
if ($this->ids) {
|
||||
return InventoryTransfer::where($this->searchWhere)->count();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$query = InventoryTransfer::where($this->searchWhere);
|
||||
if (!empty($this->params['warehouse_id'])) {
|
||||
$query->whereRaw("(one_type=2 and one_id={$this->params['warehouse_id']}) or (two_type=2 and two_id={$this->params['warehouse_id']})");
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '商品调拨列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'order_id' => '订单号',
|
||||
'store_name' => '商品名称',
|
||||
'nums' => '数量',
|
||||
'one_name' => '转出方',
|
||||
'one_before_nums' => '转出前数量',
|
||||
'one_after_nums' => '转出后数量',
|
||||
'two_name' => '转入方',
|
||||
'two_before_nums' => '转入前数量',
|
||||
'two_after_nums' => '转入后数量',
|
||||
'price' => '零售价',
|
||||
'total_price' => '总价',
|
||||
'type_name' => '类型',
|
||||
'create_time' => '时间',
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\inventory_transfer_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_transfer_order\InventoryTransferOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
|
||||
/**
|
||||
* 商品调拨订单列表
|
||||
* Class InventoryTransferOrderLists
|
||||
* @package app\admin\listsinventory_transfer_order
|
||||
*/
|
||||
class InventoryTransferOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['id', 'order_id', 'one_type', 'two_type', 'types'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨订单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return InventoryTransferOrder::where($this->searchWhere)
|
||||
->field(['id', 'order_id', 'one_id', 'one_type', 'two_id', 'two_type', 'types', 'total_nums', 'total_price','mark', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$type_name='';
|
||||
if($item->one_type==1){
|
||||
$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');
|
||||
}else{
|
||||
$type_name.='仓库';
|
||||
$item->two_name=Warehouse::where('id',$item->two_id)->value('name');
|
||||
}
|
||||
$item->type_name=$type_name;
|
||||
if($item->types==0){
|
||||
$item->types_name='正常减库';
|
||||
}else{
|
||||
$item->types_name='异常数据';
|
||||
}
|
||||
})
|
||||
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品调拨订单数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/01/24 09:59
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return InventoryTransferOrder::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\inventory_warehouse;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_warehouse\InventoryWarehouse;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
|
||||
/**
|
||||
* 仓库盘存列表
|
||||
* Class InventoryWarehouseLists
|
||||
* @package app\admin\listsinventory_warehouse
|
||||
*/
|
||||
class InventoryWarehouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['product_id', 'warehouse_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库盘存列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return InventoryWarehouse::where($this->searchWhere)
|
||||
->field(['id', 'product_id', 'admin_id', 'warehouse_id', 'nums', 'enter_nums', 'status','create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item->status_name = match ($item->status) {
|
||||
0 => '待盘点',
|
||||
1 => '盘点中',
|
||||
2 => '盘点完成',
|
||||
default => '未知',
|
||||
};
|
||||
if($item->admin_id){
|
||||
$item->admin_name = Admin::where('id',$item->admin_id)->value('name');
|
||||
}
|
||||
if($item->product_id){
|
||||
$item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库盘存数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/02/14 17:24
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return InventoryWarehouse::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\product_source_link;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\product_source_link\ProductSourceLink;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 商品溯源管理列表
|
||||
* Class ProductSourceLinkLists
|
||||
* @package app\admin\listsproduct_source_link
|
||||
*/
|
||||
class ProductSourceLinkLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['purchase_uid', 'product_id', 'warehouse_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源管理列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = ProductSourceLink::where($this->searchWhere);
|
||||
if (!empty($this->params['product_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['product_name']}%")->column('id');
|
||||
$query->whereIn('product_id', $productIds);
|
||||
}
|
||||
return $query->with(['product','warehouse','purchase'])
|
||||
->field(['id', 'purchase_uid', 'product_id','warehouse_id',])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
$item->total_nums = ProductSourceLinkInfo::where('product_id', $item->product_id)->where('oid',$item->id)->where('types',1)->sum('nums');
|
||||
$item->warehouse_outbound_nums = ProductSourceLinkInfo::where('product_id', $item->product_id)->where('oid',$item->id)->where('types',2)->sum('nums');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源管理数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:03
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = ProductSourceLink::where($this->searchWhere);
|
||||
if (!empty($this->params['product_name'])) {
|
||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['product_name']}%")->column('id');
|
||||
$query->whereIn('product_id', $productIds);
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\product_source_link_info;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
|
||||
/**
|
||||
* 商品溯源详细列表
|
||||
* Class ProductSourceLinkInfoLists
|
||||
* @package app\admin\listsproduct_source_link_info
|
||||
*/
|
||||
class ProductSourceLinkInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['oid', 'types', 'purchase_funds_id', ]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源详细列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ProductSourceLinkInfo::where($this->searchWhere)
|
||||
->with(['product'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
$item['route'] = $this->getRoute($item);
|
||||
$item['type_name'] = $item->getTypeName();
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品溯源详细数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/03/12 10:08
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ProductSourceLinkInfo::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
public function getRoute($item)
|
||||
{
|
||||
if ($item['types'] == ProductSourceLinkInfo::TypeIn) {
|
||||
$path = '/procure/warehouse_product';
|
||||
$query = ['id' => $item['link_id']];
|
||||
} elseif (in_array($item['types'], [ProductSourceLinkInfo::TypeOut, ProductSourceLinkInfo::TypeStoreIn, ProductSourceLinkInfo::TypeStoreOut])) {
|
||||
$path = '/sales_inventory/outbound_list';
|
||||
$query = ['id' => $item['link_id']];
|
||||
} elseif ($item['types'] == ProductSourceLinkInfo::TypeOrder) {
|
||||
$path = '/order/store_order';
|
||||
$linkId = StoreOrderCartInfo::where('id', $item['link_id'])->value('oid');
|
||||
$query = ['id' => $linkId];
|
||||
} elseif ($item['types'] == ProductSourceLinkInfo::TypeOrderRefund) {
|
||||
$path = '/order/store_order';
|
||||
$query = ['id' => $item['link_id']];
|
||||
} elseif (in_array($item['types'], [ProductSourceLinkInfo::TypeS2W, ProductSourceLinkInfo::TypeS2S, ProductSourceLinkInfo::TypeW2W])) {
|
||||
$path = '/warehouse/inventory_transfer_order';
|
||||
$linkId = InventoryTransfer::where('id', $item['link_id'])->value('oid');
|
||||
$query = ['id' => $linkId];
|
||||
}
|
||||
return [
|
||||
'path' => $path ?? '',
|
||||
'query' => $query ?? []
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ namespace app\admin\lists\purchase_order_info;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\purchase_order_info\PurchaseOrderInfo;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
@ -49,22 +48,13 @@ class PurchaseOrderInfoLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreBranchProduct::where('product_id',$item->product_id)->where('store_id',$item->store_id)->field('store_info,stock,unit,store_name,image')->find();
|
||||
$find=StoreProduct::where('id',$item->product_id)->field('store_info,unit,store_name,image')->find();
|
||||
if($find){
|
||||
$item->store_name=$find->store_name;
|
||||
$item->unit_name=StoreProductUnit::where('id',$find->unit)->value('name');
|
||||
$item->unit=$find->unit;
|
||||
$item->stock=$find->stock;
|
||||
$item->store_info=$find->store_info;
|
||||
$item->image=$find->image;
|
||||
}
|
||||
if($item->is_buyer==1){
|
||||
$item->is_buyer_name='需采购';
|
||||
}elseif($item->is_buyer==-1){
|
||||
$item->is_buyer_name='不采购';
|
||||
}else{
|
||||
$item->is_buyer_name='未知';
|
||||
}
|
||||
switch ($item->storage) {
|
||||
case 0:
|
||||
$item->storage_name = '未入库';
|
||||
|
@ -1,179 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\purchase_product_offer;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
/**
|
||||
* 采购供应链商品列表
|
||||
* Class PurchaseProductOfferLists
|
||||
* @package app\admin\listspurchase_product_offer
|
||||
*/
|
||||
class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
{
|
||||
|
||||
public $is_ids;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id','buyer_confirm','buyer_id','is_storage'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取采购供应链商品列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$store_name=$this->request->get('store_name');
|
||||
if($store_name){
|
||||
$ids=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id');
|
||||
if($ids){
|
||||
$this->searchWhere[]=['product_id','in',$ids];
|
||||
}else{
|
||||
$this->is_ids=1;
|
||||
}
|
||||
}
|
||||
$job_ids=$this->adminInfo['job_ids']??[];
|
||||
if($this->request->get('order_sn')){
|
||||
$ids=BeforehandOrder::where('order_id','like','%'.$this->request->get('order_sn'))->column('id');
|
||||
if($ids){
|
||||
$this->searchWhere[]=['order_id','in',$ids];
|
||||
}
|
||||
}
|
||||
if(!empty($this->params['order_sn'])){
|
||||
$orderIds = BeforehandOrder::where('order_id','like','%'.$this->params['order_sn'].'%')->column('id');
|
||||
$this->searchWhere[]=['order_id','in',$orderIds];
|
||||
}
|
||||
if(!empty($this->params['product_name'])){
|
||||
$productIds = StoreProduct::where('store_name','like','%'.$this->params['product_name'].'%')->column('id');
|
||||
$this->searchWhere[]=['product_id','in',$productIds];
|
||||
}
|
||||
if(!empty($this->params['order_sort_list'])){
|
||||
$this->searchWhere[]=['is_storage','=',0];
|
||||
$this->searchWhere[]=['total_price','>',0];
|
||||
}
|
||||
return PurchaseProductOffer::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item) use($job_ids){
|
||||
$item->order_sn=BeforehandOrder::where('id',$item['order_id'])->value('order_id');
|
||||
$find=StoreProduct::where('id',$item->product_id)->withTrashed()->find();
|
||||
$item->store_info = empty($item['store_info']) ? ($find['store_info'] ?? '') : $item['store_info'];
|
||||
$item->after_sales = empty($item['after_sales']) ? ($find['after_sales'] ?? '') : $item['after_sales'];
|
||||
$item->marques = empty($item['marques']) ? ($find['marques'] ?? '') : $item['marques'];
|
||||
$item->package = empty($item['package']) ? ($find['package'] ?? '') : $item['package'];
|
||||
$item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : '';
|
||||
$item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : '';
|
||||
$item->store_name=$find->store_name;
|
||||
$item->image=$find->image;
|
||||
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||
$item->cate_name=StoreCategory::where('id',$find->cate_id)->value('name');
|
||||
$item->top_cate_name=StoreCategory::where('id',$find->top_cate_id)->value('name');
|
||||
if($item->is_buyer==1){
|
||||
$item->is_buyer_name='需要采购';
|
||||
}elseif($item->is_buyer==-1){
|
||||
$item->is_buyer_name='无须采购';
|
||||
}
|
||||
if($item->buyer_id>0){
|
||||
$item->buyer_name=DeliveryService::where('uid',$item->buyer_id)->value('nickname');
|
||||
if($item->buyer_confirm==0){
|
||||
$item->buyer_confirm_name='采购中';
|
||||
}else{
|
||||
$item->buyer_confirm_name='采购完成';
|
||||
}
|
||||
}else{
|
||||
$item->buyer_name='';
|
||||
}
|
||||
if($item->supplier_id>0){
|
||||
$item->supplier_name=Supplier::where('id',$item->supplier_id)->value('mer_name');
|
||||
}else{
|
||||
$item->supplier_name='';
|
||||
}
|
||||
if($item->is_storage==1){
|
||||
$item->is_storage_name='已入库';
|
||||
}else{
|
||||
$item->is_storage_name='未入库';
|
||||
}
|
||||
$item->pay_type_name=$item->pay_type==1?'赊账':'现金';
|
||||
foreach($job_ids as $k=>$v){
|
||||
if($v==1){
|
||||
$item->price='*';
|
||||
$item->total_price='*';
|
||||
}
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取采购供应链商品数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if($this->is_ids==1){
|
||||
return 0;
|
||||
}
|
||||
return PurchaseProductOffer::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '采购列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data=[
|
||||
'order_id' => '订单id',
|
||||
'store_name' => '商品名称',
|
||||
'unit_name' => '单位',
|
||||
'cate_name' => '分类',
|
||||
'need_num' => '数量',
|
||||
'buyer_name' => '采购人',
|
||||
'mark' => '备注',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\statistics;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
|
||||
/**
|
||||
* 商品列表列表
|
||||
* Class StoreProductLists
|
||||
* @package app\admin\listsstore_product
|
||||
*/
|
||||
class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface,ListsSortInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['cate_id', 'is_show', 'bar_code'],
|
||||
'%like%' => ['store_name'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['stock' => 'stock'];
|
||||
}
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return [ 'p.id' => 'desc','p.stock' => 'desc',];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取商品列表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$class_all = $this->request->get('class_all');
|
||||
if ($class_all) {
|
||||
//查3级别的
|
||||
$arr = Cate::where('pid', $class_all)->column('id');
|
||||
if ($arr) {
|
||||
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
||||
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
||||
} else {
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
$list = StoreProduct::where($this->searchWhere)
|
||||
->alias('p') // 为 StoreProduct 表设置别名
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->field('p.id, p.store_name, p.image,p.stock as total_stock,p.unit,p.total_price,
|
||||
(SELECT SUM(c.cart_num) FROM `la_store_order_cart_info` c WHERE c.product_id=p.id AND c.is_pay=1 AND c.delete_time IS NULL) AS sales,
|
||||
(SELECT SUM(b.stock) FROM `la_store_branch_product` b WHERE b.product_id=p.id AND b.delete_time IS NULL) AS store_stock,
|
||||
(SELECT SUM(w.nums) FROM `la_warehouse_product_storege` w WHERE w.product_id=p.id AND w.delete_time IS NULL) AS warehouse_stock,
|
||||
(SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.financial_pm=1 AND wp.delete_time IS NULL) AS total_purchase,
|
||||
(SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.financial_pm=1 AND wp.is_pay=1 AND wp.delete_time IS NULL) AS total_completed_amount,
|
||||
(SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.financial_pm=1 AND wp.is_pay=0 AND wp.delete_time IS NULL) AS total_outstanding_amount')
|
||||
->order($this->sortOrder)
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
// 计算总库存
|
||||
$unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||
if($item->total_stock){
|
||||
$item->total_stock=bcadd($item->total_stock??0,$item->warehouse_stock??0,2).'|'.$unit_name;
|
||||
}else{
|
||||
$item->total_stock='';
|
||||
}
|
||||
$item->sales=$item->sales.'|'.$unit_name;
|
||||
$item->store_stock=$item->store_stock.'|'.$unit_name;
|
||||
$item->warehouse_stock=$item->warehouse_stock.'|'.$unit_name;
|
||||
if($item->total_completed_amount){
|
||||
$item->total_completed_amount=$item->total_completed_amount.'元';
|
||||
}else{
|
||||
$item->total_completed_amount='0元';
|
||||
}
|
||||
if($item->total_outstanding_amount){
|
||||
$item->total_outstanding_amount=$item->total_outstanding_amount.'元';
|
||||
}else{
|
||||
$item->total_outstanding_amount='0元';
|
||||
}
|
||||
if($item->total_purchase){
|
||||
$item->total_purchase=$item->total_purchase.'元';
|
||||
}else{
|
||||
$item->total_purchase='0元';
|
||||
}
|
||||
if($item->total_price){
|
||||
$item->total_price=$item->total_price.'元';
|
||||
}else{
|
||||
$item->total_price='0元';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品列表数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/05/31 10:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$export=$this->request->get('export');
|
||||
if($export==1){
|
||||
$class_all = $this->request->get('class_all');
|
||||
if ($class_all) {
|
||||
//查3级别的
|
||||
$arr = Cate::where('pid', $class_all)->column('id');
|
||||
if ($arr) {
|
||||
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
||||
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
||||
} else {
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
}
|
||||
return StoreProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'store_name' => '商品名称',
|
||||
'cate_name'=>'分类',
|
||||
'unit_name'=>'单位',
|
||||
'stock' => '库存',
|
||||
'purchase' => '采购价',
|
||||
'cost' => '商户',
|
||||
'price' => '零售',
|
||||
'total_price' => '总采购价',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ class StoreBranchProductExchangeLists extends BaseAdminDataLists implements List
|
||||
}
|
||||
}
|
||||
return StoreBranchProductExchange::where($this->searchWhere)->where($where)
|
||||
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'bar_code','status'])
|
||||
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status'])
|
||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->adminInfo['store_id']);
|
||||
})
|
||||
|
@ -5,23 +5,18 @@ namespace app\admin\lists\store_branch_product;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 门店商品辅助表
|
||||
* Class StoreBranchProductLists
|
||||
* @package app\admin\listssystem_store
|
||||
*/
|
||||
class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface, ListsSortInterface
|
||||
class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -34,28 +29,14 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['product_id', 'cate_id', 'store_id', 'status','bar_code'],
|
||||
'%pipe_like%' => ['store_name_code' => 'store_name|bar_code'],
|
||||
'=' => ['product_id', 'cate_id','store_id','status'],
|
||||
'%pipe_like%' => ['store_name_code'=>'store_name|bar_code'],
|
||||
'%like%' => ['store_name'],
|
||||
'<='=> ['stock'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['stock' => 'stock'];
|
||||
}
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return [ 'id' => 'desc','stock' => 'desc',];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店列表列表
|
||||
* @return array
|
||||
@ -67,67 +48,37 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$class_all = $this->request->get('class_all');
|
||||
$export=$this->request->get('export');
|
||||
$where = [];
|
||||
if ($class_all) {
|
||||
$arr = Cate::where('pid', $class_all)->column('id');
|
||||
if ($arr) {
|
||||
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
||||
$where[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
||||
$class_all=$this->request->get('class_all');
|
||||
$where=[];
|
||||
if($class_all){
|
||||
$arr=Cate::where('pid',$class_all)->column('id');
|
||||
if($arr){
|
||||
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||
}
|
||||
}
|
||||
if (empty($where) && $class_all) {
|
||||
if(empty($where) && $class_all){
|
||||
//2或者1
|
||||
$where[] = ['cate_id', '=', $class_all];
|
||||
$where[]=['cate_id','=',$class_all];
|
||||
}
|
||||
if ($where) {
|
||||
$this->searchWhere[] = $where;
|
||||
if($where){
|
||||
$this->searchWhere[]=$where;
|
||||
}
|
||||
$query = StoreBranchProduct::where($this->searchWhere);
|
||||
if (isset($this->params['low_stock']) && $this->params['low_stock'] == 1) {
|
||||
$query->where('stock', '<=', 'low_stock');
|
||||
}
|
||||
$list = $query
|
||||
->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'low_stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information','total_price'])
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->field(['id','store_id','product_id', 'image', 'store_name','store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information'])
|
||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->adminInfo['store_id']);
|
||||
})
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->order(['sort' => 'desc','stock'=>'desc','id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) use($export) {
|
||||
$item['transfer_num'] = 0;
|
||||
$item['banquet_num'] = 0;
|
||||
$item['out_num'] = InventoryTransfer::where('one_type', 1)->where('one_id', $item['store_id'])->where('product_id', $item['product_id'])->sum('nums');
|
||||
$item['in_num'] = InventoryTransfer::where('two_type', 1)->where('two_id', $item['store_id'])->where('product_id', $item['product_id'])->sum('nums');
|
||||
$item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
|
||||
->each(function ($item) {
|
||||
$item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name');
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
||||
if($export==2){
|
||||
$item['total_price'] = bcmul($item['purchase'],$item['stock'],2);
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$productIds = array_unique(array_column($list, 'product_id'));
|
||||
$warehouseProductQuery = WarehouseProduct::whereIn('order_type', [1, 3])->whereIn('product_id', $productIds);
|
||||
if (!empty($this->params['store_id'])) {
|
||||
$warehouseProductQuery->where('store_id', $this->params['store_id']);
|
||||
}
|
||||
$warehouseProducts = $warehouseProductQuery->group('product_id,order_type')->field('product_id,order_type,sum(nums) num')->select()->toArray();
|
||||
foreach ($warehouseProducts as $warehouseProduct) {
|
||||
foreach ($list as &$item) {
|
||||
if ($item['product_id'] == $warehouseProduct['product_id']) {
|
||||
if ($warehouseProduct['order_type'] == 1) {
|
||||
$item['transfer_num'] = $warehouseProduct['num'];
|
||||
} elseif ($warehouseProduct['order_type'] == 3) {
|
||||
$item['banquet_num'] = $warehouseProduct['num'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
@ -139,61 +90,11 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = StoreBranchProduct::where($this->searchWhere);
|
||||
if (isset($this->params['low_stock']) && $this->params['low_stock'] == 1) {
|
||||
$query->where('stock', '<=', 'low_stock');
|
||||
}
|
||||
return $query
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->adminInfo['store_id']);
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
if ($this->request->get('store_id')) {
|
||||
$name = SystemStore::where('id', $this->request->get('store_id'))->value('name');
|
||||
return $name . '商品列表';
|
||||
}
|
||||
return '门店商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'product_id' => '商品ID',
|
||||
'system_store_name' => '门店',
|
||||
'store_name' => '商品名称',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'cate_name' => '分类',
|
||||
'stock' => '库存',
|
||||
'sales' => '销量',
|
||||
'transfer_num' => '铺货数量',
|
||||
'banquet_num' => '一条龙数量',
|
||||
'out_num' => '调拨出库数量',
|
||||
'in_num' => '调拨入库数量',
|
||||
'purchase' => '供货价',
|
||||
'cost' => '商户价',
|
||||
'vip_price' => '会员价',
|
||||
'price' => '零售价',
|
||||
'bar_code' => '条码',
|
||||
'total_price' => '价值',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,13 @@ use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 现金流水列表
|
||||
* Class StoreCashFinanceFlowLists
|
||||
* @package app\admin\listsstore_cash_finance_flow
|
||||
*/
|
||||
class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -28,9 +27,8 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'status', 'cash_price'],
|
||||
"between_time" => 'create_time',
|
||||
'%like%' => ['remark'],
|
||||
'=' => ['store_id','status'],
|
||||
"between_time" => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -47,18 +45,13 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreCashFinanceFlow::where($this->searchWhere)
|
||||
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'create_time', 'status','type'])
|
||||
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item->store_name = SystemStore::where('id', $item->store_id)->value('name');
|
||||
$item->admin_name='';
|
||||
if ($item->admin_id > 0) {
|
||||
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||
}
|
||||
if($item->type==1){
|
||||
$item->cash_price='-'. $item->cash_price;
|
||||
$item->receivable='-'. $item->receivable;
|
||||
$item->store_name =SystemStore::where('id', $item->store_id)->value('name');
|
||||
if($item->admin_id>0){
|
||||
$item->admin_name =Admin::where('id', $item->admin_id)->value('name');
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
@ -75,35 +68,5 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
||||
{
|
||||
return StoreCashFinanceFlow::where($this->searchWhere)->count();
|
||||
}
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
|
||||
return '现金流水';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'store_name' => '门店',
|
||||
'create_time' => '时间',
|
||||
'cash_price' => '交易金额',
|
||||
'receivable' => '应收金额',
|
||||
'receipts' => '实收金额',
|
||||
'admin_name' => '操作人员',
|
||||
'remark' => '备注',
|
||||
'status'=>'状态',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ namespace app\admin\lists\store_category;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,35 +43,11 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$userGroups = UserShip::field('id,title')->select()->toArray();
|
||||
return StoreCategory::where($this->searchWhere)
|
||||
->field(['id', 'pid', 'name', 'data', 'pic', 'sort', 'price_rate'])
|
||||
->field(['id', 'pid', 'name', 'data', 'pic', 'sort'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) use ($userGroups) {
|
||||
if (empty($item['price_rate'])) {
|
||||
$item['price_rate'] = $userGroups;
|
||||
} else {
|
||||
$priceRate = reset_index($item['price_rate'], 'id');
|
||||
unset($priceRate[100003], $priceRate[100004]);
|
||||
$temp = [];
|
||||
foreach ($userGroups as $userGroup) {
|
||||
if (!isset($priceRate[$userGroup['id']])) {
|
||||
continue;
|
||||
}
|
||||
if ($userGroup['id'] == 21 && !empty($priceRate[100001]) && empty($userGroup['rate'])) {
|
||||
$userGroup['rate'] = $priceRate[100001]['rate'];
|
||||
unset($priceRate[100001]);
|
||||
} elseif ($userGroup['id'] == 22 && !empty($priceRate[100002]) && empty($userGroup['rate'])) {
|
||||
$userGroup['rate'] = $priceRate[100002]['rate'];
|
||||
unset($priceRate[100002]);
|
||||
} else {
|
||||
$userGroup['rate'] = $priceRate[$userGroup['id']]['rate'] ?? 0;
|
||||
}
|
||||
$temp[] = $userGroup;
|
||||
}
|
||||
$item['price_rate'] = $temp;
|
||||
}
|
||||
->select()->each(function ($item) {
|
||||
$item['is_children'] = StoreCategory::where('pid', $item->id)->count(); // 判断是否有子分类
|
||||
return $item->toArray();
|
||||
})
|
||||
|
@ -6,18 +6,14 @@ namespace app\admin\lists\store_extract;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_extract\StoreExtract;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAuth;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店提现列表
|
||||
* Class StoreExtractLists
|
||||
* @package app\admin\listsstore_extract
|
||||
*/
|
||||
class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -47,28 +43,10 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreExtract::where($this->searchWhere)
|
||||
->field(['id', 'store_id','uid','extract_type', 'extract_price', 'mark', 'status', 'pay_status', 'admin_id', 'create_time'])
|
||||
->field(['id', 'store_id', 'extract_type', 'extract_price', 'mark', 'status', 'pay_status', 'admin_id', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
if($item->store_id>0){
|
||||
$item->nickname=SystemStore::where('id',$item->store_id)->value('name');
|
||||
}elseif($item->uid>0){
|
||||
$find=User::where('id',$item->uid)->find();
|
||||
if($find['real_name']!=''){
|
||||
$name=$find['real_name'];
|
||||
}else{
|
||||
$name=$find['mobile'];
|
||||
}
|
||||
$openid=UserAuth::where('user_id',$find['id'])->value('openid');
|
||||
$user_ship=UserShip::where('id',$find['user_ship'])->value('title');
|
||||
$item->nickname=$name.'('.$user_ship.')';
|
||||
$item->id_card=$find['id_card'];
|
||||
$item->openid=$openid;
|
||||
}
|
||||
$item->status_name=$item->status==1?"通过":"审核中";
|
||||
$item->pay_status_name=$item->pay_status==1?"已转账":"未转账";
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -84,33 +62,4 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
return StoreExtract::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '提现列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data=[
|
||||
'nickname' => '名称',
|
||||
'extract_price' => '提现金额',
|
||||
'id_card' => '身份证',
|
||||
'openid' => 'openid',
|
||||
'create_time' => '时间',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'user_id', 'create_time', 'staff_id','financial_type','financial_pm','order_id','order_sn'],
|
||||
'=' => ['store_id', 'user_id', 'create_time', 'staff_id','financial_type','financial_pm','order_id'],
|
||||
'between_time' => 'create_time',
|
||||
'%pipe_like%' => ['keyword' => 'order_sn'],
|
||||
];
|
||||
|
@ -6,20 +6,18 @@ namespace app\admin\lists\store_order;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\user\User;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 订单列表列表
|
||||
* Class StoreOrderLists
|
||||
* @package app\admin\listsstore_order
|
||||
*/
|
||||
class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -32,9 +30,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['id', 'store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id', 'paid', 'status', 'is_writeoff', 'is_merge', 'uid'],
|
||||
'between_time' => 'create_time',
|
||||
'%like%' => ['order_id'],
|
||||
'=' => ['order_id','store_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id','paid', 'status', 'is_writeoff'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -50,18 +47,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('is_delivery') >= 1) {
|
||||
$this->searchWhere[] = ['delivery_uid', '>', 0];
|
||||
}
|
||||
if (!empty($this->params['source'])) {
|
||||
if ($this->params['source'] < 10) {
|
||||
$this->searchWhere[] = ['source', $this->params['source']];
|
||||
} else {
|
||||
$orderType = substr($this->params['source'], 1);
|
||||
$this->searchWhere[] = ['order_type', $orderType];
|
||||
}
|
||||
}
|
||||
return StoreOrder::with(['staff', 'store'])->where($this->searchWhere)
|
||||
return StoreOrder::with(['staff','store'])->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
@ -73,65 +59,35 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$query->whereIn('status', $status);
|
||||
}
|
||||
})
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'source', 'pay_price', 'total_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'create_time', 'delivery_name', 'delivery_id', 'refund_price', 'order_type'])
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid','refund_status','create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : '';
|
||||
if ($item['status'] == -1) {
|
||||
if($item['status']==-1){
|
||||
$item['status_name'] = OrderEnum::refundStatus($item['refund_status']) ?? '';
|
||||
} else {
|
||||
}else{
|
||||
$item['status_name'] = OrderEnum::getOrderType($item['status']) ?? '';
|
||||
}
|
||||
if ($item['uid'] <= 0) {
|
||||
$item['nickname'] = '游客';
|
||||
} else {
|
||||
$id = $item['uid'];
|
||||
$user = User::where('id', $item['uid'])->field('real_name,nickname')->find();
|
||||
if ($user) {
|
||||
$item['nickname'] = $user['real_name'] != '' ? $user['real_name'] . '|' . $id : $user['nickname'] . '|' . $id;
|
||||
$user=User::where('id', $item['uid'])->field('real_name,nickname')->find();
|
||||
if($user){
|
||||
$item['nickname'] =$user['real_name']!=''?$user['real_name'].'|'.$id:$user['nickname'].'|'.$id;
|
||||
}
|
||||
}
|
||||
if ($item['paid'] == 0) {
|
||||
$item['status_name'] = '待支付';
|
||||
}
|
||||
if ($item['source'] == 4) {
|
||||
$item['source_name'] = '批发订单';
|
||||
} else {
|
||||
$item['source_name'] = '普通订单';
|
||||
}
|
||||
if (!empty($item['order_type'])) {
|
||||
$item['source_name'] = BeforehandOrder::getOrderTypeName($item['order_type']);
|
||||
}
|
||||
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
|
||||
->limit(3)->select();
|
||||
foreach ($product as &$items) {
|
||||
$items['store_name'] = $items['cart_info']['name'] ?? '';
|
||||
$items['image'] = $items['cart_info']['image'] ?? '';
|
||||
}
|
||||
foreach ($product as &$items) {
|
||||
$items['store_name'] = $items['cart_info']['name']??'';
|
||||
$items['image'] = $items['cart_info']['image']??'';
|
||||
}
|
||||
$item['product'] = $product;
|
||||
$pay_type_name = '';
|
||||
switch ($item['pay_type']) {
|
||||
case 3:
|
||||
$pay_type_name = '余额支付';
|
||||
break;
|
||||
case 7:
|
||||
$pay_type_name = '微信支付';
|
||||
break;
|
||||
case 9:
|
||||
$pay_type_name = '微信条码';
|
||||
break;
|
||||
case 13:
|
||||
$pay_type_name = '支付宝条码';
|
||||
break;
|
||||
case 17:
|
||||
$pay_type_name = '现金支付';
|
||||
break;
|
||||
case 18:
|
||||
$pay_type_name = '采购款支付';
|
||||
break;
|
||||
}
|
||||
$item['pay_type_name'] = $pay_type_name;
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
@ -160,39 +116,4 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '订单列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'id' => 'ID',
|
||||
'order_id' => '订单号',
|
||||
'store_name' => '门店',
|
||||
'nickname' => '用户',
|
||||
'total_price' => '总金额',
|
||||
'pay_price' => '实际支付',
|
||||
'status_name' => '状态',
|
||||
'refund_price' => '退款金额',
|
||||
'pay_time' => '支付时间',
|
||||
'pay_type_name' => '支付方式',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
@ -39,7 +38,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$this->searchWhere[] = ['refund_status', '>', 0];
|
||||
$this->searchWhere[] = ['refund_status','>', 0];
|
||||
return StoreOrder::with(['staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])
|
||||
@ -52,18 +51,11 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
$item['nickname'] = '游客';
|
||||
} else {
|
||||
$id = $item['uid'];
|
||||
$user = User::where('id', $item['uid'])->field('real_name,nickname')->find();
|
||||
if ($user) {
|
||||
$item['nickname'] = $user['real_name'] != '' ? $user['real_name'] . '|' . $id : $user['nickname'] . '|' . $id;
|
||||
$user=User::where('id', $item['uid'])->field('real_name,nickname')->find();
|
||||
if($user){
|
||||
$item['nickname'] =$user['real_name']!=''?$user['real_name'].'|'.$id:$user['nickname'].'|'.$id;
|
||||
}
|
||||
}
|
||||
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
|
||||
->limit(3)->select();
|
||||
foreach ($product as &$items) {
|
||||
$items['store_name'] = $items['cart_info']['name'] ?? '';
|
||||
$items['image'] = $items['cart_info']['image'] ?? '';
|
||||
}
|
||||
$item['product'] = $product;
|
||||
$item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : '';
|
||||
$item['refund_status_name'] = OrderEnum::refundStatus($item['refund_status']) ?? '';
|
||||
$item['refund_type_name'] = OrderEnum::refundType($item['refund_type']) ?? '';
|
||||
|
@ -58,7 +58,7 @@ class StoreOrderCartInfoGroupLists extends BaseAdminDataLists implements ListsSe
|
||||
->field('product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group('product_id')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find();
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find();
|
||||
if($find){
|
||||
$item['image']=$find['image'];//商品图片
|
||||
$item['store_name']=$find['store_name'];//商品名称
|
||||
|
@ -59,7 +59,7 @@ class StoreOrderCartInfoGroupMonthLists extends BaseAdminDataLists implements Li
|
||||
->order('cart_num desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,cate_id,store_name,store_info')->withTrashed()->find();
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find();
|
||||
if($find){
|
||||
$item['image']=$find['image'];//商品图片
|
||||
$item['store_name']=$find['store_name'];//商品名称
|
||||
|
@ -9,19 +9,13 @@ use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 订单购物详情列表
|
||||
* Class StoreOrderCartInfoLists
|
||||
* @package app\admin\store_order_cart_info
|
||||
*/
|
||||
class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -34,7 +28,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['oid','product_id','is_pay','store_id'],
|
||||
'=' => ['oid'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -51,41 +45,17 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreOrderCartInfo::where($this->searchWhere)
|
||||
->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time,refund_num,refund_amount')->limit($this->limitOffset, $this->limitLength)
|
||||
->field('cart_info,product_id,store_id')->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id')??"";//订单号
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->withTrashed()->find();
|
||||
$item['nickname']='无';
|
||||
$item['mobile']='';
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,store_name,store_info')->find();
|
||||
if($find){
|
||||
if($item['uid']>0){
|
||||
$user=User::where('id',$item['uid'])->field('real_name,mobile')->find();
|
||||
if($user){
|
||||
$item['mobile']=$user['mobile'];
|
||||
if($user['real_name']!=''){
|
||||
$item['nickname']=$user['real_name'];
|
||||
}else{
|
||||
$item['nickname']=$user['mobile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['image']=$find['image'];//商品图片
|
||||
$item['system_store']=SystemStore::where('id',$item['store_id'])->value('name')??"";
|
||||
$item['store_name']=$find['store_name'];//商品名称
|
||||
$item['store_info']=$find['store_info'];//商品规格
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??"";
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name')??"";
|
||||
$item['pay_price'] =$item['total_price'];
|
||||
$item['cart_info'] = $item->toArray()??[];
|
||||
}else{
|
||||
$item['image']='';//商品图片
|
||||
$item['unit_name']='';//商品图片
|
||||
$item['cate_name']='';//商品图片
|
||||
$item['store_name']='';//商品名称
|
||||
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
||||
$item['nickname']='';
|
||||
$item['system_store']='';
|
||||
$item['cart_info']=[];
|
||||
}
|
||||
return $item; //返回处理后的数据。
|
||||
})
|
||||
@ -102,47 +72,5 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function count(): int
|
||||
{
|
||||
return StoreOrderCartInfo::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
if($this->request->get('oid')){
|
||||
$order_id=StoreOrder::where('id',$this->request->get('oid'))->value('order_id');
|
||||
return '订单'.$order_id.'商品详情';
|
||||
}
|
||||
return '订单商品详情';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data=[
|
||||
'store_name' => '商品名称',
|
||||
'system_store' => '门店',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'cate_name' => '分类',
|
||||
'cart_num' => '数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'refund_num' => '退款数量',
|
||||
'refund_amount' => '退款金额',
|
||||
'nickname' => '用户',
|
||||
'mobile' => '手机',
|
||||
'create_time' => '时间',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 订单购物详情列表
|
||||
@ -24,7 +23,6 @@ use app\common\model\user\User;
|
||||
class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
public $ids;
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
@ -51,69 +49,34 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('store_name')) {
|
||||
$store_name = $this->request->get('store_name');
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $store_name . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if ($this->request->get('start_time') == '') {
|
||||
$this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
|
||||
}
|
||||
$is_group=$this->request->get('is_group');
|
||||
$export=$this->request->get('export');
|
||||
$this->searchWhere[] = ['is_pay', '=', 1];
|
||||
$this->searchWhere[] = ['status', '>=', 0];
|
||||
$this->searchWhere[]=['is_pay','=',1];
|
||||
$this->searchWhere[]=['status','>=',0];
|
||||
$query = StoreOrderCartInfo::where($this->searchWhere);
|
||||
if ($is_group == 1) {
|
||||
$query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num,SUM(refund_num) as refund_num,SUM(refund_amount) as refund_amount')->group(['store_id', 'product_id']);
|
||||
if ($this->request->get('is_group') == 1) {
|
||||
$query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']);
|
||||
} else {
|
||||
$query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid,refund_num,refund_amount');
|
||||
$query->field('store_id,product_id,price,total_price,cart_num');
|
||||
}
|
||||
return $query->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) use($is_group,$export){
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('image,unit,top_cate_id,cate_id,store_name,store_info')->withTrashed()->find();
|
||||
$item['nickname']='';
|
||||
$item['mobile']='';
|
||||
$item['order_id']='';
|
||||
if($export==2){
|
||||
$item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id');
|
||||
}
|
||||
->select()->each(function ($item) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find();
|
||||
if ($find) {
|
||||
$item['image'] = $find['image']; //商品图片
|
||||
if($is_group==1){
|
||||
$item['store_name'] = $find['store_name'].'-'.$item['create_time']; //商品名称
|
||||
}else{
|
||||
if(isset($item['uid'])&&$item['uid']>0){
|
||||
$user=User::where('id',$item['uid'])->field('real_name,mobile')->find();
|
||||
if($user){
|
||||
$item['mobile']=$user['mobile'];
|
||||
if($user['real_name']!=''){
|
||||
$item['nickname']=$user['real_name'];
|
||||
}else{
|
||||
$item['nickname']=$user['mobile'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$item['store_name'] = $find['store_name']; //商品名称
|
||||
}
|
||||
$item['store_name'] = $find['store_name']; //商品名称
|
||||
$item['store_info'] = $find['store_info']; //商品规格
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name') ?? '';
|
||||
$item['top_cate_name'] = StoreCategory::where('id', $find['top_cate_id'])->value('name') ?? '';
|
||||
$item['system_store'] = SystemStore::where('id', $item['store_id'])->value('name') ?? '';
|
||||
} else {
|
||||
$item['image'] = ''; //商品图片
|
||||
$item['store_name'] = ''; //商品名称
|
||||
$item['store_info'] = ''; //商品规格-(数据库叫商品简介)
|
||||
$item['unit_name'] = ''; //
|
||||
$item['cate_name'] = ''; //
|
||||
$item['system_store'] = ''; //
|
||||
$item['top_cate_name'] = ''; //
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??'';
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name')??'';
|
||||
$item['system_store'] = SystemStore::where('id', $item['store_id'])->value('name')??'';
|
||||
}else{
|
||||
$item['image']='';//商品图片
|
||||
$item['store_name']='';//商品名称
|
||||
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
||||
$item['unit_name']='';//
|
||||
$item['cate_name']='';//
|
||||
$item['system_store']='';//
|
||||
}
|
||||
return $item; //返回处理后的数据。
|
||||
})
|
||||
@ -156,40 +119,16 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
if ($this->request->get('is_group') == 1) {
|
||||
$data = [
|
||||
'system_store' => '门店',
|
||||
'store_name' => '商品名称',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'top_cate_name' => '顶级分类',
|
||||
'cate_name' => '分类',
|
||||
'cart_num' => '数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'refund_num' => '退款数量',
|
||||
'refund_amount' => '退款金额',
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'order_id' => '订单',
|
||||
'system_store' => '门店',
|
||||
'store_name' => '商品名称',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'top_cate_name' => '顶级分类',
|
||||
'cate_name' => '分类',
|
||||
'cart_num' => '数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'refund_num' => '退款数量',
|
||||
'refund_amount' => '退款金额',
|
||||
'nickname' => '用户',
|
||||
'mobile' => '手机',
|
||||
'create_time' => '时间',
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'system_store' => '门店',
|
||||
'store_name' => '商品名称',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'cate_name' => '分类',
|
||||
'cart_num' => '数量',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -4,25 +4,19 @@ namespace app\admin\lists\store_product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\ActivityZone;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 商品列表列表
|
||||
* Class StoreProductLists
|
||||
* @package app\admin\listsstore_product
|
||||
*/
|
||||
class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -35,9 +29,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['cate_id', 'is_show', 'bar_code', 'id'],
|
||||
'in' => ['product_type'],
|
||||
'<=' => ['stock'],
|
||||
'=' => ['cate_id','is_show'],
|
||||
'<='=> ['stock'],
|
||||
'%like%' => ['store_name'],
|
||||
];
|
||||
}
|
||||
@ -65,110 +58,15 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
$is_warehouse = $this->request->get('is_warehouse', 0);
|
||||
$order_type = $this->request->get('order_type', 0);
|
||||
$userShip = 0;
|
||||
if (!empty($this->params['user_id'])) {
|
||||
$userShip = User::where('id', $this->params['user_id'])->value('user_ship');
|
||||
}
|
||||
$query = StoreProduct::where($this->searchWhere);
|
||||
if (isset($this->params['type_filter'])) {
|
||||
$query->where('product_type', '<>', 5);
|
||||
if ($this->params['type_filter'] == 0) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('product_type', 6)->whereOr('is_show', 0);
|
||||
});
|
||||
} else {
|
||||
$query->where('is_show', 1);
|
||||
}
|
||||
}
|
||||
if (!empty($this->params['activity_zone_form_id'])) {
|
||||
$exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id');
|
||||
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
|
||||
}
|
||||
$storeId = $this->params['store_id'] ?? 0;
|
||||
$is_true = true;
|
||||
if ($storeId > 0) {
|
||||
$is_true = SystemStore::isSelfOperate($storeId);
|
||||
}
|
||||
if (!empty($this->params['product_status'])) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
$list = $query->limit($this->limitOffset, $this->limitLength)
|
||||
return StoreProduct::where($this->searchWhere)
|
||||
->field(['id', 'image', 'store_name','swap','product_type','cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) {
|
||||
$item['product_id'] = $item['id'];
|
||||
$item['bar_code_two'] = '';
|
||||
if (in_array($item['unit'], [2, 21])) {
|
||||
$item['bar_code_two'] = $item['bar_code'];
|
||||
if ($item['bar_code'] == 0) {
|
||||
$item['bar_code_two'] = '';
|
||||
}
|
||||
$item['bar_code'] = '';
|
||||
} else {
|
||||
if (strlen($item['bar_code']) < 10) {
|
||||
$item['bar_code_two'] = $item['bar_code'];
|
||||
if ($item['bar_code'] == 0) {
|
||||
$item['bar_code_two'] = '';
|
||||
}
|
||||
$item['bar_code'] = '';
|
||||
}
|
||||
}
|
||||
switch ($item['product_type']) {
|
||||
case 2:
|
||||
$item['product_type_name'] = '兑换产品';
|
||||
break;
|
||||
case 3:
|
||||
$item['product_type_name'] = '赠品';
|
||||
break;
|
||||
case 4:
|
||||
$item['product_type_name'] = '活动产品';
|
||||
break;
|
||||
case 5:
|
||||
$item['product_type_name'] = '批发产品';
|
||||
break;
|
||||
case 6:
|
||||
$item['product_type_name'] = '零采商品';
|
||||
break;
|
||||
default:
|
||||
$item['product_type_name'] = '普通商品';
|
||||
}
|
||||
->select()->each(function ($item) {
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||
$stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock');
|
||||
$category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name');
|
||||
$item['cate_name'] = implode('/', $category);
|
||||
if ($is_warehouse == 1) {
|
||||
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->where('warehouse_id', 1)->sum('nums');
|
||||
} else {
|
||||
$nums = WarehouseProductStorege::where('product_id', $item['id'])->where('warehouse_id', 1)->sum('nums');
|
||||
$item['stock'] = bcadd($nums, $stock);
|
||||
}
|
||||
if ($userShip == 4) {
|
||||
$item['price'] = $item['cost'];
|
||||
}
|
||||
if ($item['is_show'] == 1) {
|
||||
$item['status_msg'] = '上架|常用';
|
||||
} else {
|
||||
$item['status_msg'] = '下架|不常用|是否有替换';
|
||||
}
|
||||
if ($order_type == 2) {
|
||||
// $price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price');
|
||||
// if ($price > 0) {
|
||||
// $item['price'] = $price;
|
||||
// $item['store_name'] = $item['store_name'] . '|活动价';
|
||||
// }
|
||||
$item['price'] = $item['cost'];
|
||||
$item['store_name'] = $item['store_name'] . '|高级会员价';
|
||||
}elseif($is_true == true && $userShip>0){
|
||||
$item['price'] = $item['vip_price'];
|
||||
$item['store_name'] = $item['store_name'] . '|会员价';
|
||||
}
|
||||
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
||||
return $item;
|
||||
})?->toArray();
|
||||
// if ($userShip > 0 && $userShip != 4) {
|
||||
// $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
||||
// }
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
@ -180,71 +78,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$export = $this->request->get('export');
|
||||
if ($export == 1) {
|
||||
$class_all = $this->request->get('class_all');
|
||||
if ($class_all) {
|
||||
//查3级别的
|
||||
$arr = Cate::where('pid', $class_all)->column('id');
|
||||
if ($arr) {
|
||||
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
||||
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
||||
} else {
|
||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||
}
|
||||
}
|
||||
}
|
||||
$query = StoreProduct::where($this->searchWhere);
|
||||
if (isset($this->params['type_filter'])) {
|
||||
if ($this->params['type_filter'] == 0) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('product_type', 6)->whereOr('is_show', 0);
|
||||
});
|
||||
} else {
|
||||
$query->where('is_show', 1);
|
||||
}
|
||||
}
|
||||
if (!empty($this->params['product_status'])) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'id' => '商品id',
|
||||
'store_name' => '商品名称',
|
||||
'product_type_name' => '商品类型',
|
||||
'cate_name' => '分类',
|
||||
'unit_name' => '单位',
|
||||
'store_info' => '规格',
|
||||
'stock' => '库存',
|
||||
'purchase' => '供货价',
|
||||
'cost' => '商户',
|
||||
'vip_price' => '商户',
|
||||
'price' => '零售',
|
||||
'rose' => '毛利率',
|
||||
'bar_code' => '条码',
|
||||
];
|
||||
return $data;
|
||||
return StoreProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_product_group_price;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
|
||||
/**
|
||||
* 分组报价列表
|
||||
* Class StoreProductGroupPriceLists
|
||||
* @package app\admin\listsstore_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['product_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = StoreProduct::field('id,store_name,purchase,cost,vip_price,price,unit');
|
||||
$store_name=$this->request->get('store_name','');
|
||||
if ($store_name!='') {
|
||||
$query->where('store_name', 'like', '%'.$store_name.'%');
|
||||
}
|
||||
return $query->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['lists'] =StoreProductGroupPrice::where('product_id',$item['id'])->field('id,group_id,price')
|
||||
->select()->each(function ($item_two){
|
||||
if ($item_two['group_id'] == 100001) {
|
||||
$item_two['group_name'] = '供货价';
|
||||
} else if ($item_two['group_id'] == 100002) {
|
||||
$item_two['group_name'] = '零售价';
|
||||
} else {
|
||||
$item_two['group_name'] = UserShip::where('id', $item_two['group_id'])->value('title');
|
||||
}
|
||||
});
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = StoreProduct::field('id,store_name,purchase,cost,vip_price,price,unit');
|
||||
$store_name=$this->request->get('store_name','');
|
||||
if ($store_name!='') {
|
||||
$query->where('store_name', 'like', '%'.$store_name.'%');
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_product_low_stock;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_product_low_stock\StoreProductLowStock;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
|
||||
/**
|
||||
* 商品缺库存列表
|
||||
* Class StoreProductLowStockLists
|
||||
* @package app\admin\listsstore_product_low_stock
|
||||
*/
|
||||
class StoreProductLowStockLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['product_id', 'store_id', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品缺库存列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreProductLowStock::where($this->searchWhere)
|
||||
->field(['id', 'product_id', 'store_id', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$find = StoreBranchProduct::where('product_id', $item->product_id)->where('store_id', $item->store_id)->withTrashed()->find();
|
||||
$item->product_name = $find->store_name.'|'.$item->product_id;
|
||||
$item->system_store_name = SystemStore::where('id', $item->store_id)->value('name').'|'.$item->store_id;
|
||||
$item->image = $find->image;
|
||||
$item->stock = $find->stock;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品缺库存数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2025/01/07 16:39
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreProductLowStock::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_product_price;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\admin\service\ProductPriceService;
|
||||
use app\common\model\store_product_price\StoreProductPrice;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\StoreProductPriceList;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
|
||||
/**
|
||||
* 商品价格更改列表
|
||||
* Class StoreProductPriceLists
|
||||
* @package app\admin\listsstore_product_price
|
||||
*/
|
||||
class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品价格更改列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$store_name=$this->request->get('store_name');
|
||||
if($store_name){
|
||||
$store_id=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id');
|
||||
$this->searchWhere[]=['product_id','in',$store_id];
|
||||
}
|
||||
if (!empty($this->params['start_time'])) {
|
||||
$this->searchWhere[] = ['create_time', '>=', strtotime($this->params['start_time'])];
|
||||
}
|
||||
if (!empty($this->params['end_time'])) {
|
||||
$this->searchWhere[] = ['create_time', '<=', strtotime($this->params['end_time'])];
|
||||
}
|
||||
$list = StoreProductPrice::where($this->searchWhere)
|
||||
->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'vip_lv', 'vip_price', 'price_config', 'status','create_time','mark', 'warehouse_id'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,purchase,cost,price,store_name,store_info,unit')->withTrashed()->find();
|
||||
$item['warehouse'] = Warehouse::where('id', $item['warehouse_id'])->value('name');
|
||||
$item['unit_name']=$find['unitName']['name'] ?? '';
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['store_info']=$find['store_info'];
|
||||
$item['image']=$find['image'];
|
||||
$item['current_purchase']=$find['purchase'];
|
||||
$item['current_cost']=$find['cost'];
|
||||
$item['current_price']=$find['price'];
|
||||
$item['status_name']=$item['status']==0?"未设置":"已设置";
|
||||
})
|
||||
->toArray();
|
||||
$productIds = array_unique(array_column($list, 'product_id'));
|
||||
$priceList = StoreProductPriceList::whereIn('product_id', $productIds)->select()->toArray();
|
||||
$priceList = reset_index($priceList, 'product_id');
|
||||
$productService = new ProductPriceService();
|
||||
foreach ($list as &$item) {
|
||||
$productPrice = $priceList[$item['product_id']] ?? [];
|
||||
if (empty($productPrice) || $item['status'] == 1) {
|
||||
continue;
|
||||
}
|
||||
$priceArray = $productService->setProductPrice($item['purchase_price'], $productPrice);
|
||||
$item = array_merge($item, $priceArray);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品价格更改数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/10/19 11:31
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreProductPrice::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\supplier;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 供应链列表
|
||||
* Class SupplierLists
|
||||
* @package app\admin\listssupplier
|
||||
*/
|
||||
class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['phone'],
|
||||
'%like%'=>['mer_name']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应链列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Supplier::where($this->searchWhere)
|
||||
->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark'])
|
||||
->limit($this->limitOffset, 100)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price');
|
||||
$item->total_outstanding_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',0)->sum('total_price');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应链数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/15 14:10
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Supplier::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -45,17 +45,14 @@ 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', 'create_time'])
|
||||
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status'])
|
||||
->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 {
|
||||
|
@ -29,7 +29,6 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS
|
||||
'=' => ['store_id','user_ship','is_disable'],
|
||||
'%like%' => ['account','mobile'],
|
||||
'%pipe_like%' => ['nickname'=>'nickname|real_name'],
|
||||
'between_time' => 'vip_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -151,7 +150,8 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS
|
||||
'store_name' => '门店',
|
||||
'total_recharge_amount' => '累计消费',
|
||||
'purchase_funds' => '采购款',
|
||||
'format_address'=>'地址'
|
||||
'format_address'=>'地址',
|
||||
'vip_time'=>'开通时间'
|
||||
];
|
||||
}
|
||||
}
|
@ -7,14 +7,13 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\user\User;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
* Class UserRechargeLists
|
||||
* @package app\admin\listsuser_recharge
|
||||
*/
|
||||
class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
@ -89,34 +88,4 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
return UserRecharge::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '订单列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'id' => 'ID',
|
||||
'order_id'=>'订单号',
|
||||
'nickname' => '用户',
|
||||
'price' => '实际支付',
|
||||
'paid_name' => '状态',
|
||||
'pay_time' => '支付时间',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\warehouse_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 仓储商品单列表
|
||||
* Class WarehouseOrderLists
|
||||
* @package app\admin\listswarehouse_order
|
||||
*/
|
||||
class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['financial_pm', 'supplier_id', 'warehouse_id', 'store_id','id'],
|
||||
'%like'=>['code'],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓储商品单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return WarehouseOrder::where($this->searchWhere)
|
||||
->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time', 'completed_amount', 'outstanding_amount', 'oid', 'order_type'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
if ($item->financial_pm == 0) {
|
||||
$item->financial_pm_name = '出库';
|
||||
} else {
|
||||
$item->financial_pm_name = '入库';
|
||||
}
|
||||
if ($item->financial_pm == 0) {
|
||||
if ($item->store_id) {
|
||||
$item->system_store = SystemStore::where('id', $item->store_id)->value('name');
|
||||
} else {
|
||||
$item->system_store = '';
|
||||
}
|
||||
}
|
||||
if ($item->admin_id) {
|
||||
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||
} else {
|
||||
$item->admin_name = '';
|
||||
}
|
||||
if ($item->warehouse_id) {
|
||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||
} else {
|
||||
$item->warehouse_name = '';
|
||||
}
|
||||
if ($item->supplier_id) {
|
||||
$item->supplier_name = Supplier::where('id', $item->supplier_id)->value('mer_name');
|
||||
}else{
|
||||
$item->supplier_name = '';
|
||||
}
|
||||
if (!empty($item['order_type'])) {
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type);
|
||||
} else {
|
||||
$orderType = BeforehandOrder::where('id', $item['oid'])->value('order_type');
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($orderType);
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓储商品单数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/20 10:50
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseOrder::where($this->searchWhere)->count();
|
||||
}
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 0) {
|
||||
return '出库单列表';
|
||||
} else {
|
||||
return '入库单列表';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 1) {
|
||||
$data = [
|
||||
'create_time' => '操作时间',
|
||||
'warehouse_name' => '仓库',
|
||||
'supplier_name' => '供应商',
|
||||
'code' => '单号',
|
||||
'financial_pm_name' => '状态',
|
||||
'admin_name' => '填写人员',
|
||||
'completed_amount' => '已结金额',
|
||||
'outstanding_amount' => '未结金额',
|
||||
'total_price' => '总金额',
|
||||
'mark' => '备注',
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'create_time' => '操作时间',
|
||||
'warehouse_name' => '仓库',
|
||||
'supplier_name' => '供应商',
|
||||
'code' => '单号',
|
||||
'financial_pm_name' => '状态',
|
||||
'admin_name' => '填写人员',
|
||||
'total_price' => '总金额',
|
||||
'mark' => '备注',
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,184 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\warehouse_product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
/**
|
||||
* 商品仓储信息列表
|
||||
* Class StoreWarehouseProductLists
|
||||
* @package app\admin\listswarehouse_product
|
||||
*/
|
||||
class StoreWarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
public $ids;
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/07/31 16:55
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'status',],
|
||||
'between_time' => 'create_time'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品仓储信息列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/07/31 16:55
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('product_name')) {
|
||||
$product_name = $this->request->get('product_name');
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $product_name . '%')->withTrashed()->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$this->searchWhere[] = ['financial_pm', '=',0];
|
||||
$this->searchWhere[] = ['order_type', 'in',[1, 2, 3, 4, 8]];
|
||||
return WarehouseProduct::where($this->searchWhere)
|
||||
->field(['id', 'admin_id', 'store_id','product_id', 'nums', 'refund_nums', 'status', 'mark', 'create_time', 'order_type'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
// ->withTrashed()
|
||||
->select()->each(function ($item) {
|
||||
$item->store_name = '';
|
||||
$item->image = '';
|
||||
$item->unit_name = '';
|
||||
if ($item->store_id > 0) {
|
||||
$item->system_store_name = SystemStore::where('id', $item->store_id)->value('name');
|
||||
} else {
|
||||
$item->system_store_name = '';
|
||||
}
|
||||
if ($item->status == 0) {
|
||||
$item->status_name = '未确认';
|
||||
} elseif ($item->status == 1) {
|
||||
$item->status_name = '已确认';
|
||||
}
|
||||
if ($item->admin_id) {
|
||||
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||
} else {
|
||||
$item->admin_name = '';
|
||||
}
|
||||
if ($item->product_id) {
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('image,store_name,unit')->withTrashed()->find();
|
||||
if($find){
|
||||
$item->store_name = $find->store_name;
|
||||
$item->image = $find->image;
|
||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||
}
|
||||
}
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type);
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品仓储信息数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/07/31 16:55
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if ($this->ids) {
|
||||
return WarehouseProduct::whereIn('id', $this->ids)->where($this->searchWhere)->count();
|
||||
} else {
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 1) {
|
||||
return '入库列表';
|
||||
}
|
||||
return '出库列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 1) {
|
||||
$data = [
|
||||
'admin_name' => '操作人员',
|
||||
'warehouse_name' => '仓库',
|
||||
'supplier_name' => '供应商',
|
||||
'store_name' => '商品名称',
|
||||
'financial_pm_name' => '出入库',
|
||||
'code' => '入库单',
|
||||
'batch' => '批次',
|
||||
'nums' => '数量',
|
||||
'manufacture' => '生产日期',
|
||||
'expiration_date' => '保质期',
|
||||
'purchase' => '采购价',
|
||||
'price' => '零售',
|
||||
'total_price' => '总价',
|
||||
'create_time' => '操作时间',
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'id' => 'id',
|
||||
'admin_name' => '操作人员',
|
||||
'warehouse_name' => '仓库',
|
||||
'store_name' => '商品名称',
|
||||
'top_cate_name' => '分类',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'financial_pm_name' => '出入库',
|
||||
'code' => '出库单',
|
||||
'system_store_name' => '门店',
|
||||
'nums' => '数量',
|
||||
'purchase' => '供货价',
|
||||
'price' => '零售价',
|
||||
'total_price' => '供货总价',
|
||||
'create_time' => '操作时间',
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -4,29 +4,21 @@ namespace app\admin\lists\warehouse_product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
/**
|
||||
* 商品仓储信息列表
|
||||
* Class WarehouseProductLists
|
||||
* @package app\admin\listswarehouse_product
|
||||
*/
|
||||
class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
public $ids;
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
@ -37,8 +29,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['id', 'warehouse_id', 'financial_pm', 'product_id','store_id','oid','supplier_id','is_pay','code'],
|
||||
'between_time' => 'create_time'
|
||||
'=' => ['warehouse_id', 'financial_pm','store_id'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,111 +45,47 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('product_name')) {
|
||||
$product_name = $this->request->get('product_name');
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $product_name . '%')->withTrashed()->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if ($this->request->get('bar_code')) {
|
||||
$bar_code = $this->request->get('bar_code');
|
||||
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$query = WarehouseProduct::where($this->searchWhere);
|
||||
if (isset($this->params['is_group']) && $this->params['is_group'] == 1) {
|
||||
$query->group('product_id')->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'sum(nums) nums', 'price', 'purchase', 'cost', 'sum(total_price) total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type','vip_price', 'delete_time']);
|
||||
} else {
|
||||
$query->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type','vip_price', 'delete_time']);
|
||||
}
|
||||
if (!empty($this->params['product_status'])) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
return $query
|
||||
return WarehouseProduct::where($this->searchWhere)
|
||||
->field(['id', 'admin_id','store_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price','purchase','cost', 'total_price', 'manufacture','expiration_date','status','mark','create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
// ->withTrashed()
|
||||
->select()->each(function ($item) {
|
||||
$item->store_name = '';
|
||||
$item->image = '';
|
||||
$item->price = $item['price']??0;
|
||||
$item->purchase = $item['purchase']??0;
|
||||
$item->unit_name = '';
|
||||
$item->store_info = '';
|
||||
$item->top_cate_name = '';
|
||||
$item->order_type_name = '';
|
||||
if ($item->financial_pm == 0) {
|
||||
$item->financial_pm_name = '出库';
|
||||
} else {
|
||||
$item->financial_pm_name = '入库';
|
||||
}
|
||||
if ($item->store_id > 0) {
|
||||
$item->system_store_name = SystemStore::where('id', $item->store_id)->value('name');
|
||||
} else {
|
||||
$item->system_store_name = '';
|
||||
}
|
||||
if ($item->status == 0) {
|
||||
$item->status_name = '未确认';
|
||||
} elseif ($item->status == 1) {
|
||||
$item->status_name = '已确认';
|
||||
} else {
|
||||
$item->status_name = '库存不足';
|
||||
}
|
||||
if ($item->admin_id) {
|
||||
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||
} else {
|
||||
$item->admin_name = '';
|
||||
}
|
||||
if ($item->product_id) {
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('price,purchase,image,store_name,unit,store_info,top_cate_id')->withTrashed()->find();
|
||||
if($find){
|
||||
// if($item->purchase<=0){
|
||||
// $item->purchase = $find->purchase;
|
||||
// $item->total_price=bcmul($find->purchase,$item->nums,2);
|
||||
// }
|
||||
$item->store_name = $find->store_name . '|' . $item->product_id;
|
||||
$item->image = $find->image;
|
||||
// $item->price = $find->price;
|
||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||
$item->store_info =$find->store_info;
|
||||
$item->top_cate_name =StoreCategory::where('id', $find->top_cate_id)->value('name');
|
||||
}
|
||||
}
|
||||
if ($item->warehouse_id) {
|
||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||
} else {
|
||||
$item->warehouse_name = '';
|
||||
}
|
||||
if ($item->supplier_id) {
|
||||
$item->supplier_name = Supplier::where('id', $item->supplier_id)->value('mer_name');
|
||||
->select()->each(function ($item){
|
||||
if($item->financial_pm==0){
|
||||
$item->financial_pm_name='出库';
|
||||
}else{
|
||||
$item->supplier_name = '';
|
||||
$item->financial_pm_name='入库';
|
||||
}
|
||||
$item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : '';
|
||||
$item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : '';
|
||||
if($item->store_id>0){
|
||||
$item->system_store_name=SystemStore::where('id',$item->store_id)->value('name');
|
||||
}else{
|
||||
$item->system_store_name='';
|
||||
|
||||
if (!empty($item['order_type'])) {
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type);
|
||||
} else {
|
||||
$beforehandOrderId = WarehouseOrder::where('id', $item['oid'])->value('oid');
|
||||
if ($beforehandOrderId) {
|
||||
$orderType = BeforehandOrder::where('id', $beforehandOrderId)->value('order_type');
|
||||
$item->order_type_name = BeforehandOrder::getOrderTypeName($orderType);
|
||||
}
|
||||
}
|
||||
if ($item->order_type == 5) {
|
||||
$item->outbound = '无须出库';
|
||||
if($item->status==0){
|
||||
$item->status_name='未确认';
|
||||
}elseif($item->status==1){
|
||||
$item->status_name='已确认';
|
||||
}else{
|
||||
$item->status_name='库存不足';
|
||||
}
|
||||
})
|
||||
if($item->admin_id){
|
||||
$item->admin_name=Admin::where('id',$item->admin_id)->value('name');
|
||||
}else{
|
||||
$item->admin_name='';
|
||||
}
|
||||
if($item->product_id){
|
||||
$item->store_name=StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||
}else{
|
||||
$item->store_name='';
|
||||
}
|
||||
if($item->warehouse_id){
|
||||
$item->warehouse_name=Warehouse::where('id',$item->warehouse_id)->value('name');
|
||||
}else{
|
||||
$item->warehouse_name='';
|
||||
}
|
||||
$item->expiration_date=$item->expiration_date?date('Y-m-d',$item->expiration_date):'';
|
||||
$item->manufacture=$item->manufacture?date('Y-m-d',$item->manufacture):'';
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -171,80 +98,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = WarehouseProduct::where($this->searchWhere);
|
||||
if (!empty($this->params['product_status'])) {
|
||||
$query->onlyTrashed();
|
||||
}
|
||||
if ($this->ids) {
|
||||
return $query->whereIn('id', $this->ids)->count();
|
||||
} else {
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 1) {
|
||||
return '入库列表';
|
||||
}
|
||||
return '出库列表';
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$financial_pm = $this->request->get('financial_pm');
|
||||
if ($financial_pm == 1) {
|
||||
$data = [
|
||||
'admin_name' => '操作人员',
|
||||
'warehouse_name' => '仓库',
|
||||
'supplier_name' => '供应商',
|
||||
'store_name' => '商品名称',
|
||||
'financial_pm_name' => '出入库',
|
||||
'code' => '入库单',
|
||||
'batch' => '批次',
|
||||
'nums' => '数量',
|
||||
'manufacture' => '生产日期',
|
||||
'expiration_date' => '保质期',
|
||||
'purchase' => '采购价',
|
||||
'price' => '零售',
|
||||
'total_price' => '总价',
|
||||
'create_time' => '操作时间',
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'id' => 'id',
|
||||
'admin_name' => '操作人员',
|
||||
'warehouse_name' => '仓库',
|
||||
'store_name' => '商品名称',
|
||||
'top_cate_name' => '分类',
|
||||
'order_type_name' => '订单类型',
|
||||
'store_info' => '规格',
|
||||
'unit_name' => '单位',
|
||||
'financial_pm_name' => '出入库',
|
||||
'code' => '出库单',
|
||||
'system_store_name' => '门店',
|
||||
'nums' => '数量',
|
||||
'purchase' => '供货价',
|
||||
'vip_price' => '会员价',
|
||||
'price' => '零售价',
|
||||
'total_price' => '供货总价',
|
||||
'create_time' => '操作时间',
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\warehouse_product_return;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\warehouse_product_return\WarehouseProductReturn;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
|
||||
/**
|
||||
* 仓库商品退货处理列表
|
||||
* Class WarehouseProductReturnLists
|
||||
* @package app\admin\listswarehouse_product_return
|
||||
*/
|
||||
class WarehouseProductReturnLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['warehouse_id', 'supplier_id', 'store_id', 'product_id', 'return_type','bhoid'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品退货处理列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return WarehouseProductReturn::where($this->searchWhere)
|
||||
->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'product_id', 'unit', 'financial_pm', 'admin_id', 'nums', 'mark', 'price', 'total_price', 'return_type', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item){
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('unit,image,store_name')->find();
|
||||
$item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品退货处理数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/10/19 16:02
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseProductReturn::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -10,18 +10,15 @@ use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 仓库商品存储列表
|
||||
* Class WarehouseProductStoregeLists
|
||||
* @package app\admin\listswarehouse_product_storege
|
||||
*/
|
||||
class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExcelInterface
|
||||
class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
public $ids;
|
||||
public $store_name;
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
@ -32,26 +29,10 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['warehouse_id', 'product_id'],
|
||||
'=' => ['warehouse_id'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['nums' => 'nums'];
|
||||
}
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['id' => 'desc', 'nums' => 'desc',];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品存储列表
|
||||
@ -64,54 +45,28 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('store_name')) {
|
||||
$this->store_name = $this->request->get('store_name');
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if ($this->request->get('bar_code')) {
|
||||
$bar_code = $this->request->get('bar_code');
|
||||
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
$this->ids = $ids;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return WarehouseProductStorege::where($this->searchWhere)
|
||||
->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->select()->each(function ($item) {
|
||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||
$find = StoreProduct::where('id', $item->product_id)->withTrashed()->find();
|
||||
if ($find) {
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item){
|
||||
$item->warehouse_name = Warehouse::where('id',$item->warehouse_id)->value('name');
|
||||
$find= StoreProduct::where('id',$item->product_id)->find();
|
||||
if($find){
|
||||
$item->store_name = $find->store_name;
|
||||
$item->image = $find->image;
|
||||
$item->bar_code = $find->bar_code;
|
||||
$item->price = $find->price;
|
||||
$item->vip_price = $find->vip_price;
|
||||
$item->cost = $find->cost;
|
||||
$item->purchase = $find->purchase;
|
||||
$item->store_info = $find->store_info;
|
||||
$item->rose = $find->rose;
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->withTrashed()->value('name');
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->withTrashed()->value('name');
|
||||
}else{
|
||||
$item->store_name = '';
|
||||
$item->cate_name = '';
|
||||
$item->unit_name = '';
|
||||
$item->store_info = '';
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name');
|
||||
}
|
||||
$item['stock'] = $item['nums'];
|
||||
$item['stock']=$item['nums'];
|
||||
return $item;
|
||||
})
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -124,48 +79,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if ($this->store_name) {
|
||||
if ($this->ids) {
|
||||
return WarehouseProductStorege::whereIn('id', $this->ids)->where($this->searchWhere)->count();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return WarehouseProductStorege::where($this->searchWhere)->count();
|
||||
}
|
||||
return WarehouseProductStorege::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
|
||||
return '仓库商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
|
||||
$data = [
|
||||
'product_id' => '商品ID',
|
||||
'store_name' => '商品名称',
|
||||
'cate_name' => '分类',
|
||||
'unit_name' => '单位',
|
||||
'store_info' => '规格',
|
||||
'nums' => '数量',
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\warehouse_product_storege;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\warehouse\Warehouse;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 仓库商品存储列表
|
||||
* Class WarehouseProductStoregeTwoLists
|
||||
* @package app\admin\listswarehouse_product_storege
|
||||
*/
|
||||
class WarehouseProductStoregeTwoLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExcelInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['warehouse_id', 'product_id'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['nums' => 'nums'];
|
||||
}
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['id' => 'desc', 'nums' => 'desc',];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品存储列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
if ($this->request->get('store_name')) {
|
||||
$ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id');
|
||||
if ($ids) {
|
||||
$this->searchWhere[] = ['product_id', 'in', $ids];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
$this->searchWhere[] = ['nums', '<', 0];
|
||||
return WarehouseProductStorege::where($this->searchWhere)
|
||||
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
->select()->each(function ($item) {
|
||||
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
||||
$find = StoreProduct::where('id', $item->product_id)->withTrashed()->find();
|
||||
$item->store_name = $find->store_name;
|
||||
$item->image = $find->image;
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['stock'] = $item['nums'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取仓库商品存储数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/08/01 10:22
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseProductStorege::where($this->searchWhere)->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
|
||||
return '仓库商品列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
|
||||
$data = [
|
||||
'warehouse_name' => '仓库名称',
|
||||
'product_id' => '商品id',
|
||||
'store_name' => '商品名称',
|
||||
'unit_name' => '单位',
|
||||
'stock' => '数量',
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\finance\AccountsReceivable;
|
||||
use app\common\model\finance\AccountsReceivableInfo;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Class AccountsReceivableLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class AccountsReceivableLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $order
|
||||
*/
|
||||
public static function add(array $order)
|
||||
{
|
||||
$model = new AccountsReceivable();
|
||||
$model->order_id = $order['id'];
|
||||
$model->store_id = $order['store_id'];
|
||||
$model->user_id = $order['uid'];
|
||||
$model->nickname = $order['other_data']->nickname;
|
||||
$model->phone = $order['other_data']->phone;
|
||||
$model->deadline = time() + 86400 * 15;
|
||||
$model->total_debt = $order['total_price'];
|
||||
$model->surplus_debt = $order['total_price'];
|
||||
$model->save();
|
||||
}
|
||||
|
||||
public static function edit($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$accountsReceivable = AccountsReceivable::where(['id' => $params['accounts_receivable_id']])->find();
|
||||
if ($accountsReceivable->surplus_debt <= 0) {
|
||||
throw new BusinessException('该账单已支付');
|
||||
}
|
||||
$surplusDebt = bcsub($accountsReceivable->surplus_debt, $params['pay_debt'], 2);
|
||||
$model = new AccountsReceivableInfo();
|
||||
$model->accounts_receivable_id = $params['accounts_receivable_id'];
|
||||
$model->pay_type = $params['pay_type'];
|
||||
$model->total_debt = $params['surplus_debt'];
|
||||
$model->pay_debt = $params['pay_debt'];
|
||||
$model->recipient = $params['recipient'];
|
||||
$model->surplus_debt = $surplusDebt;
|
||||
$model->file = $params['file'];
|
||||
$model->mark = $params['mark'];
|
||||
if (!$model->save()) {
|
||||
throw new BusinessException('添加失败');
|
||||
}
|
||||
$accountsReceivable->pay_debt = bcadd($accountsReceivable->pay_debt, $params['pay_debt'], 2);
|
||||
$accountsReceivable->surplus_debt = $surplusDebt;
|
||||
if (!$accountsReceivable->save()) {
|
||||
throw new BusinessException('更新账单出错');
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function record($params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function statistics()
|
||||
{
|
||||
$query = AccountsReceivable::field('store_id,sum(total_debt) as total_debt,sum(pay_debt) as pay_debt,sum(surplus_debt) as surplus_debt')->group('store_id');
|
||||
$count = $query->count();
|
||||
$list = $query->select()->toArray();
|
||||
foreach ($list as &$item) {
|
||||
$item['store_name'] = SystemStore::where('id', $item['store_id'])->value('name');
|
||||
}
|
||||
return [
|
||||
'list' => $list,
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\ActivityZone;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\ActivityZoneForm;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\service\xlsx\ActivityZoneService;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityZone逻辑
|
||||
* Class ActivityZoneLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class ActivityZoneFormLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$secondCateIds = [];
|
||||
$thirdCateIds = [];
|
||||
foreach ($params['cate_ids'] as $item) {
|
||||
if (count($item) == 3) {
|
||||
$thirdCateIds[] = $item[2];
|
||||
} else {
|
||||
$secondCateIds[] = $item[1];
|
||||
}
|
||||
}
|
||||
$cateIds = array_merge($secondCateIds, $thirdCateIds);
|
||||
$params['cate_ids'] = !empty($cateIds) ? implode(',', $cateIds) : '';
|
||||
$activityZoneForm = new ActivityZoneForm();
|
||||
$activityZoneForm->save($params);
|
||||
$products = StoreProduct::field('id,two_cate_id,cate_id')->where('two_cate_id', 'in', $cateIds)->whereOr('cate_id', 'in', $cateIds)->select()->toArray();
|
||||
$productInfo = [];
|
||||
$time = time();
|
||||
foreach ($products as $product) {
|
||||
$productInfo[] = [
|
||||
'product_id' => $product['id'],
|
||||
'form_id' => $activityZoneForm->id,
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
];
|
||||
}
|
||||
if (!empty($productInfo)) {
|
||||
ActivityZone::insertAll($productInfo);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ActivityZoneForm::where('id', $params['id'])->update([
|
||||
'type' => $params['type'],
|
||||
'product_id' => $params['product_id'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ActivityZoneForm::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ActivityZoneForm::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function export($params)
|
||||
{
|
||||
$service = new ActivityZoneService();
|
||||
$activityZoneForm = ActivityZoneForm::findOrEmpty($params['id'])->toArray();
|
||||
$productIds = ActivityZone::where('form_id', $params['id'])->column('product_id');
|
||||
$products = StoreProduct::field('id,unit,store_name,two_cate_id')->whereIn('id', $productIds)->order('two_cate_id asc,cate_id asc')->select()->toArray();
|
||||
$unitIds = array_unique(array_column($products, 'unit'));
|
||||
$cateIds = array_unique(array_column($products, 'two_cate_id'));
|
||||
$unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray();
|
||||
$categories = StoreCategory::whereIn('id', $cateIds)->field('id,name')->withTrashed()->select()->toArray();
|
||||
$unit = reset_index($unit, 'id');
|
||||
$categories = reset_index($categories, 'id');
|
||||
$data = [];
|
||||
foreach ($products as $item) {
|
||||
$currentCate = $categories[$item['two_cate_id']]['name'] ?? '';
|
||||
if (!empty($currentCate)) {
|
||||
$item['unit_name'] = $unit[$item['unit']]['name'] ?? '';
|
||||
unset($item['unit'], $item['two_cate_id']);
|
||||
$data[$currentCate][] = $item;
|
||||
}
|
||||
}
|
||||
return $service->export($data, $activityZoneForm['title'], $activityZoneForm['remark']);
|
||||
}
|
||||
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\ActivityZone;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\ActivityZoneForm;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityZone逻辑
|
||||
* Class ActivityZoneLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class ActivityZoneLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$insert = [];
|
||||
$time = time();
|
||||
foreach ($params['product_ids'] as $product_id) {
|
||||
$insert[] = [
|
||||
'form_id' => $params['form_id'],
|
||||
'product_id' => $product_id,
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
];
|
||||
}
|
||||
ActivityZone::insertAll($insert);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ActivityZone::where('id', $params['id'])->update([
|
||||
'form_id' => $params['form_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ActivityZone::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/12/20 10:52
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ActivityZone::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public function addProduct($product)
|
||||
{
|
||||
$activityFormId1 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['two_cate_id']])->column('id');
|
||||
$activityFormId2 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['cate_id']])->column('id');
|
||||
$activityFormIds = array_unique(array_merge($activityFormId1, $activityFormId2));
|
||||
foreach ($activityFormIds as $activityFormId) {
|
||||
$activityZone = new ActivityZone();
|
||||
$activityZone->form_id = $activityFormId;
|
||||
$activityZone->product_id = $product['id'];
|
||||
$activityZone->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateProduct($productId, $product)
|
||||
{
|
||||
$product['id'] = $productId;
|
||||
$formIds = ActivityZone::where('product_id', $productId)->column('form_id');
|
||||
if (empty($formIds)) {
|
||||
$this->addProduct($product);
|
||||
return;
|
||||
}
|
||||
$forms = ActivityZoneForm::whereIn('id', $formIds)->select()->toArray();
|
||||
foreach ($forms as $form) {
|
||||
$cateIds = explode(',', $form['cate_ids']);
|
||||
if (!in_array($product['two_cate_id'], $cateIds) && !in_array($product['cate_id'], $cateIds)) {
|
||||
ActivityZone::where('product_id', $productId)->where('form_id', $form['id'])->update(['delete_time' => time()]);
|
||||
}
|
||||
$this->addProduct($product);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProduct($productId)
|
||||
{
|
||||
ActivityZone::where('product_id', $productId)->update(['delete_time' => time()]);
|
||||
}
|
||||
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\model\ChangeLog;
|
||||
use app\common\logic\BaseLogic;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ChangeLog逻辑
|
||||
* Class ChangeLogLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class ChangeLogLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ChangeLog::create([
|
||||
'model' => $params['model'],
|
||||
'link_id' => $params['link_id'],
|
||||
'nums' => $params['nums'],
|
||||
'pm' => $params['pm'],
|
||||
'url' => $params['url'],
|
||||
'mark' => $params['mark'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ChangeLog::where('id', $params['id'])->update([
|
||||
'model' => $params['model'],
|
||||
'link_id' => $params['link_id'],
|
||||
'nums' => $params['nums'],
|
||||
'pm' => $params['pm'],
|
||||
'url' => $params['url'],
|
||||
'mark' => $params['mark'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ChangeLog::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2025/01/06 10:03
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ChangeLog::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\service\{FileService, ConfigService};
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
@ -47,9 +46,10 @@ class ConfigLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +73,10 @@ class ConfigLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,163 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\admin\logic\delivery_service\DeliveryServiceLogic;
|
||||
use app\common\model\PurchaseFunds;
|
||||
use app\common\logic\BaseLogic;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* PurchaseFunds逻辑
|
||||
* Class PurchaseFundsLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class PurchaseFundsLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseFunds::create([
|
||||
'from_uid' => $params['from_uid'],
|
||||
'amount' => $params['amount'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseFunds::where('id', $params['id'])->update([
|
||||
'from_uid' => $params['from_uid'],
|
||||
'approve_uid' => $params['approve_uid'],
|
||||
'amount' => $params['amount'],
|
||||
'status' => $params['status'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return PurchaseFunds::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return PurchaseFunds::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function audit(array $params): bool
|
||||
{
|
||||
$purchaseFunds = PurchaseFunds::findOrEmpty($params['id']);
|
||||
if ($purchaseFunds->isEmpty()) {
|
||||
throw new BusinessException('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$attrs = [
|
||||
'approve_uid' => $params['approve_uid'],
|
||||
'status' => $params['status'],
|
||||
'audit_time' => time(),
|
||||
];
|
||||
if ($params['status'] == 1) {
|
||||
$attrs['current_amount'] = $purchaseFunds['amount'];
|
||||
}
|
||||
PurchaseFunds::where('id', $params['id'])->update($attrs);
|
||||
if ($params['status'] == 1) {
|
||||
DeliveryServiceLogic::addPurchaseFunds($purchaseFunds['from_uid'], $purchaseFunds['amount']);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 补充
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2025/03/19 14:59
|
||||
*/
|
||||
public static function replenish(array $params): bool
|
||||
{
|
||||
$purchaseFunds = PurchaseFunds::findOrEmpty($params['id']);
|
||||
if ($purchaseFunds->isEmpty()) {
|
||||
throw new BusinessException('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseFunds::where('id', $params['id'])->update([
|
||||
'amount' => Db::raw('amount+' . $params['replenish_amount']),
|
||||
'current_amount' => Db::raw('current_amount+' . $params['replenish_amount']),
|
||||
]);
|
||||
DeliveryServiceLogic::addPurchaseFunds($purchaseFunds['from_uid'], $params['replenish_amount']);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ namespace app\admin\logic\app_update;
|
||||
|
||||
use app\common\model\app_update\AppUpdate;
|
||||
use app\common\logic\BaseLogic;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -41,9 +40,10 @@ class AppUpdateLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,9 +71,10 @@ class AppUpdateLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\AdminSession;
|
||||
use app\common\cache\AdminTokenCache;
|
||||
use app\common\service\FileService;
|
||||
use support\exception\BusinessException;
|
||||
use Webman\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -71,9 +70,10 @@ class AdminLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,9 +138,10 @@ class AdminLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,9 +177,10 @@ class AdminLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ use app\common\{
|
||||
logic\BaseLogic,
|
||||
model\auth\SystemRoleMenu
|
||||
};
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -67,7 +66,8 @@ class RoleLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,8 @@ class RoleLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,486 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\beforehand_order_cart_info;
|
||||
|
||||
use app\admin\logic\product_source_link\ProductSourceLinkLogic;
|
||||
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\product_source_link\ProductSourceLink;
|
||||
use app\common\model\product_source_link_info\ProductSourceLinkInfo;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 预订单购物详情表逻辑
|
||||
* Class BeforehandOrderCartInfoLogic
|
||||
* @package app\admin\logic\beforehand_order_cart_info
|
||||
*/
|
||||
class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加预订单购物详情表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
BeforehandOrderCartInfo::create([
|
||||
'oid' => $params['oid'],
|
||||
'uid' => $params['uid'],
|
||||
'product_id' => $params['product_id'],
|
||||
'attr_value_id' => $params['attr_value_id'],
|
||||
'is_pay' => $params['is_pay'],
|
||||
'purchase' => $params['purchase'],
|
||||
'price' => $params['price'],
|
||||
'total_price' => $params['total_price'],
|
||||
'cart_num' => $params['cart_num'],
|
||||
'old_cart_id' => $params['old_cart_id']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 追加预订单购物详情表
|
||||
*/
|
||||
public static function appendAdd(array $params): bool
|
||||
{
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
if(empty($params['admin_id'])){
|
||||
if ((!empty($order) && $order->is_confirm == 1 ) || $order['is_outbound'] > 0) {
|
||||
throw new BusinessException('该订单已确认,不能追加商品');
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$datas = [];
|
||||
$uid = $params['uid'] ?? 0;
|
||||
$bhoid = $params['id'];
|
||||
$offer = [];
|
||||
$buyerId = PurchaseProductOffer::where('order_id', $order['id'])->value('buyer_id');
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$datas[$k]['product_id'] = $v['id'];
|
||||
$datas[$k]['uid'] = $uid;
|
||||
$datas[$k]['bhoid'] = $bhoid;
|
||||
$datas[$k]['cart_num'] = $v['nums'];
|
||||
$datas[$k]['accept_num'] = $v['nums'];
|
||||
$datas[$k]['purchase'] = $v['prices']??0;
|
||||
$datas[$k]['price'] = $v['purchase'];
|
||||
$datas[$k]['total_price'] = $v['total_price'];
|
||||
$datas[$k]['pay_price'] = $v['total_price'];
|
||||
$datas[$k]['create_time'] = time();
|
||||
$datas[$k]['update_time'] = time();
|
||||
$offer[] = [
|
||||
'order_id' => $order['id'],
|
||||
'product_id' => $v['id'],
|
||||
'is_buyer' => 1,
|
||||
'need_num' => $v['nums'],
|
||||
'unit' => $v['unit'],
|
||||
'buyer_id' => $buyerId,
|
||||
'status' => 0,
|
||||
'source_order_info' => [
|
||||
[
|
||||
'source_order_id' => $order['id'],
|
||||
'product_id' => $v['id'],
|
||||
'need_num' => $v['nums'],
|
||||
'mark' => '',
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
(new BeforehandOrderCartInfo())->saveAll($datas);
|
||||
if ($order['order_type'] == 7 || $order['order_type'] == 9) {
|
||||
PurchaseProductOffer::insertAll($offer);
|
||||
}
|
||||
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price,sum(pay_price) as pay_price')->find();
|
||||
BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'],'pay_price'=>$info['pay_price'], 'total_num' => $info['cart_num']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单购物详情表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$find=BeforehandOrderCartInfo::where('id', $params['id'])->find();
|
||||
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
||||
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
|
||||
}
|
||||
$bhoid = $params['bhoid'];
|
||||
$order=BeforehandOrder::where('id', $bhoid)->find();
|
||||
if($order['outbound_id']>0){
|
||||
throw new BusinessException('该订单已出库,不能修改');
|
||||
}
|
||||
if($params['total_price']<=0){
|
||||
$total_price=bcmul($params['purchases'],$params['nums'],2);
|
||||
}else{
|
||||
$total_price=$params['total_price'];
|
||||
}
|
||||
$find->save([
|
||||
'price' => $params['purchases'],
|
||||
'total_price' => $total_price,
|
||||
'pay_price' => $total_price,
|
||||
'cart_num' => $params['nums'],
|
||||
'accept_num' => $params['nums'],
|
||||
'mark' => $params['mark']??'',
|
||||
]);
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price,sum(pay_price) as pay_price')->find();
|
||||
if($find['is_buyer']==1){
|
||||
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
|
||||
}
|
||||
$order->save(['total_price' => $info['total_price'],'pay_price' => $info['pay_price'], 'total_num' => $info['cart_num']]);
|
||||
|
||||
if($order['outbound_id']>0){
|
||||
$wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find();
|
||||
if($wp){
|
||||
$wp->save(['price'=>$params['purchases'],'total_price'=>$total_price]);
|
||||
$wp_total_price=WarehouseProduct::where('oid', $order['outbound_id'])->where('financial_pm',0)->sum('total_price');
|
||||
WarehouseOrder::where('id', $order['outbound_id'])->update(['total_price' => $wp_total_price]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单购物详情表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public static function editNums(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$find=BeforehandOrderCartInfo::where('id', $params['id'])->find();
|
||||
if($find){
|
||||
$data=['accept_num'=>$params['nums'],'pay_price'=>bcmul($find['price'],$params['nums'],2)];
|
||||
$find->save($data);
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $find['bhoid'])->field('sum(accept_num) as accept_num,sum(pay_price) as pay_price')->find();
|
||||
BeforehandOrder::where('id', $find['bhoid'])->save(['pay_price'=>$info['pay_price'], 'total_num' => $info['accept_num']]);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 一键入库
|
||||
*/
|
||||
public static function oneClickStorage($params)
|
||||
{
|
||||
if($params['bhoid']<=0){
|
||||
throw new BusinessException('参数错误');
|
||||
}
|
||||
$count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'buyer_confirm' => 0])->count('id');
|
||||
$beforehandOrder = BeforehandOrder::where('id', $params['bhoid'])->field('order_type,warehousing_id')->find();
|
||||
|
||||
if ($count > 0) {
|
||||
throw new BusinessException('还有商品正在采购中,请先设置采购信息在入库');
|
||||
}
|
||||
if ($beforehandOrder['warehousing_id'] > 0) {
|
||||
throw new BusinessException('请勿重复入库');
|
||||
}
|
||||
$offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select();
|
||||
foreach ($offer_list as $k => $v) {
|
||||
if($v['buyer_nums']<=0){
|
||||
throw new BusinessException('采购数量不能为0');
|
||||
}
|
||||
}
|
||||
$total_price= PurchaseProductOffer::where(['order_id' => $params['bhoid']])->sum('total_price');
|
||||
$completed_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>1])->sum('total_price');
|
||||
$outstanding_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>2])->sum('total_price');
|
||||
if($params['warehouse_id']<=0){
|
||||
throw new BusinessException('请选择入库仓库');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$code = getNewOrderId('RK');
|
||||
$arr = [
|
||||
'warehouse_id' => $params['warehouse_id'],
|
||||
'supplier_id' => 0,
|
||||
'order_type' => $beforehandOrder['order_type']??0,
|
||||
'oid' => $beforehandOrder['id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'financial_pm' => 1,
|
||||
'batch' => 0,
|
||||
'code' => $code,
|
||||
'mark' => $params['remark'] ?? '',
|
||||
'total_price' => $total_price,
|
||||
'completed_amount' => $completed_amount,
|
||||
'outstanding_amount' => $outstanding_amount,
|
||||
];
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($offer_list as $k => $v) {
|
||||
$data['admin_id'] = $params['admin_id'];
|
||||
$data['order_type'] = $beforehandOrder['order_type'];
|
||||
$data['store_id'] = 0;
|
||||
$data['pay_type'] = $v['pay_type'];
|
||||
$data['oid'] = $res['id'];
|
||||
$data['supplier_id'] = $v['supplier_id'];
|
||||
$data['warehouse_id'] = $params['warehouse_id'];
|
||||
$data['code'] = $code;
|
||||
$data['product_id'] = $v['product_id'];
|
||||
$data['nums'] = $v['buyer_nums'];
|
||||
$data['purchase'] = $v['price'];
|
||||
$data['total_price'] = $v['total_price'];
|
||||
$data['financial_pm'] = 1;
|
||||
$data['manufacture'] = $v['manufacture'] > 0 ? date('Y-m-d H:i:s', $v['manufacture']) : '';
|
||||
$data['expiration_date'] = $v['expiration_date'] > 0 ? date('Y-m-d H:i:s', $v['expiration_date']) : '';
|
||||
$product_arr=[];
|
||||
// if($v['package']!=''){
|
||||
// $product_arr['package']=$v['package'];
|
||||
// }
|
||||
// if($v['store_info']!=''){
|
||||
// $product_arr['store_info']=$v['store_info'];
|
||||
// }
|
||||
// if($v['marques']!=''){
|
||||
// $product_arr['marques']=$v['marques'];
|
||||
// }
|
||||
// if($v['after_sales']!=''){
|
||||
// $product_arr['after_sales']=$v['after_sales'];
|
||||
// }
|
||||
if($product_arr!=[]){
|
||||
StoreProduct::where('id',$v['product_id'])->save($product_arr);
|
||||
}
|
||||
if ($data['nums'] > 0) {
|
||||
WarehouseProductLogic::add($data,1,$params['admin_id']);
|
||||
}
|
||||
PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]);
|
||||
}
|
||||
$attrs = ['warehousing_id' => $res['id'],'is_warehousing'=>1];
|
||||
if ($beforehandOrder['order_type'] == 7) {
|
||||
$attrs['is_buying'] = 1;
|
||||
}
|
||||
$result = BeforehandOrder::where('id', $params['bhoid'])->where('warehousing_id', 0)->where('is_warehousing', 0)->update($attrs);
|
||||
if (!$result) {
|
||||
throw new BusinessException('出库失败,预订单更新出错');
|
||||
}
|
||||
ProductSourceLink::add([
|
||||
'purchase_product_offer' => $offer_list,
|
||||
'types' => ProductSourceLinkInfo::TypeIn,
|
||||
'buyer_id' => $res['buyer_id'],
|
||||
'warehouse_id' => $params['warehouse_id'],
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 删除预订单购物详情表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$find=BeforehandOrderCartInfo::where('id',$params['id'])->find();
|
||||
if($find['is_buyer']==1){
|
||||
PurchaseProductOffer::where('order_id',$find['bhoid'])->where('product_id',$find['product_id'])->update(['delete_time'=>time()]);
|
||||
}
|
||||
$res=BeforehandOrderCartInfo::destroy($params['id']);
|
||||
$pay_price=BeforehandOrderCartInfo::where('bhoid', $find['bhoid'])->sum('pay_price');
|
||||
$total_price=BeforehandOrderCartInfo::where('bhoid', $find['bhoid'])->sum('total_price');
|
||||
BeforehandOrder::where('id',$find['bhoid'])->update(['pay_price'=>$pay_price, 'total_price'=>$total_price]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单购物详情表详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:32
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function fixAcceptNum($params)
|
||||
{
|
||||
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select();
|
||||
foreach ($cartInfo as $k => $v) {
|
||||
if ($v['cart_num'] != $v['accept_num']) {
|
||||
$v->save(['accept_num' => $v['cart_num']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function syncPrice($params)
|
||||
{
|
||||
$outbound_id=BeforehandOrder::where('id', $params['bhoid'])->value('outbound_id');
|
||||
if($outbound_id>0){
|
||||
throw new BusinessException('该订单已出库,不能修改');
|
||||
}
|
||||
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray();
|
||||
$productIds = array_column($cartInfo, 'product_id');
|
||||
$products = StoreProduct::whereIn('id', $productIds)->select()->toArray();
|
||||
$products = reset_index($products, 'id');
|
||||
$update = [];
|
||||
foreach ($cartInfo as $v) {
|
||||
$product = $products[$v['product_id']];
|
||||
if (empty($product) || empty($product['price'])) {
|
||||
continue;
|
||||
}
|
||||
$update[] = [
|
||||
'id' => $v['id'],
|
||||
'price' => $product['price'],
|
||||
'total_price' => $product['price'] * $v['cart_num'],
|
||||
'pay_price' => $product['price'] * $v['cart_num'],
|
||||
];
|
||||
}
|
||||
(new BeforehandOrderCartInfo())->saveAll($update);
|
||||
}
|
||||
|
||||
public static function setStoreSale($params)
|
||||
{
|
||||
$cartInfo = BeforehandOrderCartInfo::where('id', $params['id'])->find();
|
||||
if ($cartInfo['store_sale'] == 1) {
|
||||
$update = ['store_sale' => 0];
|
||||
} else {
|
||||
$update = ['store_sale' => 1];
|
||||
}
|
||||
BeforehandOrderCartInfo::where('id', $params['id'])->update($update);
|
||||
}
|
||||
|
||||
public static function putInStorage($params)
|
||||
{
|
||||
if ($params['warehouse_id'] <= 0 || $params['warehouse_id'] == '') {
|
||||
throw new BusinessException('请选择入库仓库');
|
||||
}
|
||||
$purchaseProductOffer = PurchaseProductOffer::where('id', $params['id'])->find();
|
||||
if (empty($purchaseProductOffer) || $params['warehouse_num'] == 0 || empty($purchaseProductOffer['total_price'])) {
|
||||
throw new BusinessException('请先设置采购信息再入库');
|
||||
}
|
||||
if ($purchaseProductOffer['is_storage'] == 1) {
|
||||
throw new BusinessException('商品已入库');
|
||||
}
|
||||
$beforehandOrder = BeforehandOrder::where('id', $params['bhoid'])->field('id,buyer_id,order_type,warehousing_id,is_warehousing')->find();
|
||||
|
||||
$completed_amount = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'pay_type' => 1, 'is_storage' => 1])->sum('total_price');
|
||||
$outstanding_amount = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'pay_type' => 2, 'is_storage' => 1])->sum('total_price');
|
||||
if ($purchaseProductOffer['pay_type'] == 1) {
|
||||
$completed_amount = bcadd($completed_amount, $purchaseProductOffer['total_price'], 2);
|
||||
} else {
|
||||
$outstanding_amount = bcadd($outstanding_amount, $purchaseProductOffer['total_price'], 2);
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$warehouseOrder = WarehouseOrder::where('oid', $purchaseProductOffer['order_id'])->where('financial_pm', 1)->find();
|
||||
if (empty($warehouseOrder)) {
|
||||
$arr = [
|
||||
'warehouse_id' => $params['warehouse_id'],
|
||||
'supplier_id' => 0,
|
||||
'order_type' => $beforehandOrder['order_type'] ?? 0,
|
||||
'oid' => $beforehandOrder['id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'financial_pm' => 1,
|
||||
'batch' => 0,
|
||||
'code' => getNewOrderId('RK'),
|
||||
'mark' => $params['remark'] ?? '',
|
||||
'total_price' => $purchaseProductOffer['total_price'],
|
||||
'completed_amount' => $completed_amount,
|
||||
'outstanding_amount' => $outstanding_amount,
|
||||
];
|
||||
$warehouseOrder = WarehouseOrder::create($arr);
|
||||
} else {
|
||||
$warehouseOrder->total_price = bcadd($warehouseOrder->total_price, $purchaseProductOffer['total_price'], 2);
|
||||
$warehouseOrder->save();
|
||||
}
|
||||
$purchaseProductOffer['price'] = bcdiv($purchaseProductOffer['total_price'], $params['warehouse_num'], 2);
|
||||
$data['admin_id'] = $params['admin_id'];
|
||||
$data['order_type'] = $beforehandOrder['order_type'];
|
||||
$data['store_id'] = 0;
|
||||
$data['pay_type'] = $purchaseProductOffer['pay_type'];
|
||||
$data['oid'] = $warehouseOrder['id'];
|
||||
$data['supplier_id'] = $purchaseProductOffer['supplier_id'];
|
||||
$data['warehouse_id'] = $params['warehouse_id'];
|
||||
$data['code'] = $warehouseOrder['code'];
|
||||
$data['product_id'] = $purchaseProductOffer['product_id'];
|
||||
$data['nums'] = $params['warehouse_num'];
|
||||
$data['purchase'] = $purchaseProductOffer['price'];
|
||||
$data['total_price'] = $purchaseProductOffer['total_price'];
|
||||
$data['financial_pm'] = 1;
|
||||
$data['buyer_id'] = $beforehandOrder['buyer_id'];
|
||||
$data['buyer_nums'] = $data['nums'];
|
||||
$data['price'] = $data['purchase'];
|
||||
$data['manufacture'] = $purchaseProductOffer['manufacture'] > 0 ? date('Y-m-d H:i:s', $purchaseProductOffer['manufacture']) : '';
|
||||
$data['expiration_date'] = $purchaseProductOffer['expiration_date'] > 0 ? date('Y-m-d H:i:s', $purchaseProductOffer['expiration_date']) : '';
|
||||
$data['purchase_funds_id'] = $params['purchase_funds_id'];
|
||||
if ($data['nums'] > 0) {
|
||||
$warehouseProduct = WarehouseProductLogic::add($data, 1, $params['admin_id']);
|
||||
}
|
||||
$offerUpdate = ['price' => $purchaseProductOffer['price'], 'status' => 1, 'is_storage' => 1, 'warehouse_num' => $params['warehouse_num']];
|
||||
$offerResult = PurchaseProductOffer::where('id', $purchaseProductOffer['id'])->where('is_storage', 0)->update($offerUpdate);
|
||||
if (!$offerResult) {
|
||||
throw new BusinessException('入库失败,采购信息更新出错');
|
||||
}
|
||||
if ($beforehandOrder['is_warehousing'] == 0) {
|
||||
$attrs = ['warehousing_id' => $warehouseOrder['id'], 'is_warehousing' => 1];
|
||||
if ($beforehandOrder['order_type'] == 7) {
|
||||
$attrs['is_buying'] = 1;
|
||||
}
|
||||
$result = BeforehandOrder::where('id', $params['bhoid'])->where('warehousing_id', 0)->where('is_warehousing', 0)->update($attrs);
|
||||
if (!$result) {
|
||||
throw new BusinessException('入库失败,预订单更新出错');
|
||||
}
|
||||
}
|
||||
$purchaseProductOffer['purchase']=$purchaseProductOffer['price'];
|
||||
$product = StoreProduct::where('id', $purchaseProductOffer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
|
||||
|
||||
if (!in_array($beforehandOrder['order_type'], [6, 9])) {
|
||||
PurchaseProductOfferLogic::setProductPrice($purchaseProductOffer, $product, $params['warehouse_id'], $warehouseProduct->id ?? 0);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\delivery_service;
|
||||
|
||||
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\logic\BaseLogic;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 配送员逻辑
|
||||
* Class DeliveryServiceLogic
|
||||
* @package app\admin\logic\delivery_service
|
||||
*/
|
||||
class DeliveryServiceLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加配送员
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
DeliveryService::create([
|
||||
'uid' => $params['uid'],
|
||||
'nickname' => $params['nickname'],
|
||||
'phone' => $params['phone'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑配送员
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
DeliveryService::where('id', $params['id'])->update([
|
||||
'uid' => $params['uid'],
|
||||
'nickname' => $params['nickname'],
|
||||
'phone' => $params['phone'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除配送员
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return DeliveryService::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配送员详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/08/08 14:07
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return DeliveryService::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function addPurchaseFunds($uid, $amount)
|
||||
{
|
||||
$model = DeliveryService::where('uid', $uid)->findOrEmpty();
|
||||
if (!$model->isEmpty()) {
|
||||
$model->purchase_funds_total = bcadd($model->purchase_funds_total, $amount, 2);
|
||||
$model->current_purchase_funds = bcadd($model->current_purchase_funds, $amount, 2);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减采购人员资金
|
||||
* @param $uid
|
||||
* @param $amount
|
||||
* @return void
|
||||
*/
|
||||
public static function subPurchaseFunds($uid, $amount)
|
||||
{
|
||||
$model = DeliveryService::where('uid', $uid)->findOrEmpty();
|
||||
if (!$model->isEmpty()) {
|
||||
$model->current_purchase_funds = bcsub($model->current_purchase_funds, $amount, 2);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@ namespace app\admin\logic\dept;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dept\Dept;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
|
||||
/**
|
||||
* 部门管理逻辑
|
||||
@ -147,8 +147,9 @@ class DeptLogic extends BaseLogic
|
||||
'sort' => $params['sort'] ?? 0
|
||||
]);
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user