From e2e470d0926aa74839224ad25e2163f24743c5f9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 27 Sep 2024 18:16:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=94=B6=E6=94=AFAPI=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BranchProductController.php | 3 ++ app/api/controller/store/StoreController.php | 43 +++++++++++++++++++ .../StoreOrderCartInfoController.php | 7 ++- .../SystemStoreStorageController.php | 11 +++++ .../SystemStoreStorageGroupLists.php | 5 +++ .../SystemStoreStorageLists.php | 6 +++ 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/app/api/controller/branch_product/BranchProductController.php b/app/api/controller/branch_product/BranchProductController.php index c08f43515..df4786119 100644 --- a/app/api/controller/branch_product/BranchProductController.php +++ b/app/api/controller/branch_product/BranchProductController.php @@ -4,6 +4,7 @@ namespace app\api\controller\branch_product; use app\api\controller\BaseApiController; use app\api\lists\branch_product\BranchProductLists; +use app\common\model\system_store\SystemStoreStaff; class BranchProductController extends BaseApiController { @@ -14,6 +15,8 @@ class BranchProductController extends BaseApiController */ public function lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new BranchProductLists()); } } diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 5bbfb08e5..a9b554b3b 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -13,10 +13,15 @@ use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; use app\common\model\Config; +use app\common\model\store_finance_flow\StoreFinanceFlow; +use app\common\model\store_order\StoreOrder; +use app\common\model\system_store\SystemStore; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user_create_log\UserCreateLog; use app\common\model\user_recharge\UserRecharge; +use app\common\model\warehouse_product\WarehouseProduct; use app\common\service\Curl; use Exception; use support\Cache; @@ -210,4 +215,42 @@ class StoreController extends BaseApiController ]; return $this->success('ok',['menu'=>$menu]); } + + /** + * 店铺收支 + */ + public function store_statistics(){ + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $total_price=WarehouseProduct::where('store_id',$store_id)->where('financial_pm',0)->sum('total_price'); + $order=StoreOrder::where('store_id',$store_id)->where('refund_status',0)->field('sum(refund_price) as refund_price,sum(pay_price) as pay_price')->find(); + $pay_price=bcsub($order['pay_price'],$order['refund_price'],2); + + $commission=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',3)->sum('number'); + $bond=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',11)->sum('number'); + $vip=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',12)->sum('number'); + $village=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',14)->sum('number'); + $brigade=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',15)->sum('number'); + $attrition=StoreFinanceFlow::where('store_id',$store_id)->where('financial_pm',0)->where('financial_type',16)->sum('number'); + + $money=bcadd($commission,$bond,2); + $money=bcadd($money,$vip,2); + $money=bcadd($money,$village,2); + $money=bcadd($money,$brigade,2); + $expenditure=bcadd($money,$attrition,2); + + + $store_money=SystemStore::where('id',$store_id)->value('store_money'); + + $list=[ + ['name'=>'手续费','data'=>[$commission]], + ['name'=>'保证金','data'=>[$bond]], + ['name'=>'厨师','data'=>[$vip]], + ['name'=>'村长','data'=>[$village]], + ['name'=>'队长','data'=>[$brigade]], + ]; + return $this->success('ok',['total_price'=>$total_price,'pay_price'=>$pay_price,'list'=>$list,'attrition'=>$attrition,'store_money'=>$store_money,'expenditure'=>$expenditure]); + } } diff --git a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php index e85d6710d..5134d6129 100644 --- a/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php +++ b/app/api/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -6,6 +6,7 @@ namespace app\api\controller\store_order_cart_info; use app\api\controller\BaseApiController; use app\api\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; use app\api\lists\store_order_cart_info\StoreOrderCartInfoLists; +use app\common\model\system_store\SystemStoreStaff; /** * 商品销量控制器 @@ -22,13 +23,15 @@ class StoreOrderCartInfoController extends BaseApiController */ public function lists() { - $this->request->__set('store_id',5); + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new StoreOrderCartInfoLists()); } public function group_lists() { - $this->request->__set('store_id',5); + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + $this->request->__set('store_id',$store_id); return $this->dataLists(new StoreOrderCartInfoGroupLists()); } } diff --git a/app/api/controller/system_store_storage/SystemStoreStorageController.php b/app/api/controller/system_store_storage/SystemStoreStorageController.php index c1e1fd1a1..a9eb68379 100644 --- a/app/api/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/api/controller/system_store_storage/SystemStoreStorageController.php @@ -7,6 +7,7 @@ use app\api\controller\BaseApiController; use app\api\lists\system_store_storage\SystemStoreStorageLists; use app\api\lists\system_store_storage\SystemStoreStorageGroupLists; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\system_store\SystemStoreStaff; use app\common\model\system_store_storage\SystemStoreStorage; /** @@ -24,6 +25,11 @@ class SystemStoreStorageController extends BaseApiController */ public function lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $this->request->__set('store_id',$store_id); return $this->dataLists(new SystemStoreStorageLists()); } /** @@ -34,6 +40,11 @@ class SystemStoreStorageController extends BaseApiController */ public function group_lists() { + $store_id=SystemStoreStaff::where('uid',$this->userId)->value('store_id'); + if(!$store_id){ + return $this->fail('请先绑定店铺'); + } + $this->request->__set('store_id',$store_id); return $this->dataLists(new SystemStoreStorageGroupLists()); } diff --git a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php index 84fbaca3d..f44c869fc 100644 --- a/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php +++ b/app/api/lists/system_store_storage/SystemStoreStorageGroupLists.php @@ -62,6 +62,11 @@ class SystemStoreStorageGroupLists extends BaseApiDataLists implements ListsSear */ public function lists(): array { + $store_id=$this->request->__get('store_id'); + if(!$store_id){ + return []; + } + $this->searchWhere[] = ['store_id', '=', $store_id]; $fields = 'store_id,product_id,sum(nums) as nums,mark'; if ($this->request->get('store_name')) { $store_name = $this->request->get('store_name'); diff --git a/app/api/lists/system_store_storage/SystemStoreStorageLists.php b/app/api/lists/system_store_storage/SystemStoreStorageLists.php index f3674d2cb..eccaa3362 100644 --- a/app/api/lists/system_store_storage/SystemStoreStorageLists.php +++ b/app/api/lists/system_store_storage/SystemStoreStorageLists.php @@ -62,6 +62,12 @@ class SystemStoreStorageLists extends BaseApiDataLists implements ListsSearchInt */ public function lists(): array { + $store_id=$this->request->__get('store_id'); + if(!$store_id){ + return []; + } + $this->searchWhere[] = ['store_id', '=', $store_id]; + $fields = 'id,store_id,staff_id,product_id,warehouse_id,nums,mark,status'; if ($this->request->get('store_name')) { $store_name = $this->request->get('store_name');