feat: 添加店铺收支API功能
This commit is contained in:
parent
362c348140
commit
e2e470d092
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user