From caa504e7dd3cb546e301c7ae655085358efe10ef Mon Sep 17 00:00:00 2001
From: mkm <727897186@qq.com>
Date: Thu, 3 Aug 2023 10:15:51 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0api?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/api/controller/AccountLogController.php | 34 +++++++++++----------
 app/api/controller/CompanyController.php    |  2 +-
 app/api/lists/AccountLogLists.php           |  4 ++-
 app/common/model/user/UserAccountLog.php    |  5 +++
 vendor/ebaoquan/junziqian_sdk               |  2 +-
 5 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/app/api/controller/AccountLogController.php b/app/api/controller/AccountLogController.php
index d93344ae5..b2e90bd12 100755
--- a/app/api/controller/AccountLogController.php
+++ b/app/api/controller/AccountLogController.php
@@ -38,7 +38,7 @@ class AccountLogController extends BaseApiController
     //个人月份统计
     public function year_count()
     {
-        $data = [['month'=>date('Y').'-01'],['month'=>date('Y').'-02'],['month'=>date('Y').'-03'],['month'=>date('Y').'-04'],['month'=>date('Y').'-05'],['month'=>date('Y').'-06'],['month'=>date('Y').'-07'],['month'=>date('Y').'-08'],['month'=>date('Y').'-09'],['month'=>date('Y').'-10'],['month'=>date('Y').'-11'],['month'=>date('Y').'-12']];
+        $data = [['month' => date('Y') . '-01'], ['month' => date('Y') . '-02'], ['month' => date('Y') . '-03'], ['month' => date('Y') . '-04'], ['month' => date('Y') . '-05'], ['month' => date('Y') . '-06'], ['month' => date('Y') . '-07'], ['month' => date('Y') . '-08'], ['month' => date('Y') . '-09'], ['month' => date('Y') . '-10'], ['month' => date('Y') . '-11'], ['month' => date('Y') . '-12']];
         $year = date('Y');
         $change_amount_1 = Db::name('user_account_log')
             ->whereYear('create_time', $year)
@@ -54,37 +54,39 @@ class AccountLogController extends BaseApiController
             ->group('month')
             ->order('month')
             ->select();
-        foreach($data as $k=>$v){
-            foreach($change_amount_1 as $key=>$val){
-                if($v['month'] == $val['month']){
+        foreach ($data as $k => $v) {
+            foreach ($change_amount_1 as $key => $val) {
+                if ($v['month'] == $val['month']) {
                     $data[$k]['income'] = $val['total'];
-                    if(!isset($data[$k]['expenditure'])){
+                    if (!isset($data[$k]['expenditure'])) {
                         $data[$k]['expenditure'] = 0;
                     }
                     $data[$k]['income'] = $val['total'];
                 }
             }
-            foreach($change_amount_2 as $key=>$val){
-                if($v['month'] == $val['month']){
+            foreach ($change_amount_2 as $key => $val) {
+                if ($v['month'] == $val['month']) {
                     $data[$k]['expenditure'] = $val['total'];
-                    if(!isset($data[$k]['income'])){
+                    if (!isset($data[$k]['income'])) {
                         $data[$k]['income'] = 0;
                     }
                 }
             }
-            if(!isset($data[$k]['income'])||!isset($data[$k]['expenditure'])){
+            if (!isset($data[$k]['income']) || !isset($data[$k]['expenditure'])) {
                 unset($data[$k]);
             }
         }
-        return $this->success('ok',array_reverse($data));
+        return $this->success('ok', array_reverse($data));
     }
 
     //公司日流水统计
-    public function company_lists(){
-        return $this->dataLists(new AccountLogLists(),'company_lists');
+    public function company_lists()
+    {
+        return $this->success('ok',(new AccountLogLists())->company_lists());
+    }
+    //公司月流水统计
+    public function company_year_count()
+    {
+        return $this->success('ok',(new AccountLogLists())->company_year_count());
     }
-        //公司月流水统计
-        public function company_year_count(){
-            return $this->dataLists(new AccountLogLists(),'company_year_count');
-        }
 }
diff --git a/app/api/controller/CompanyController.php b/app/api/controller/CompanyController.php
index 4163325bc..e0050afcf 100644
--- a/app/api/controller/CompanyController.php
+++ b/app/api/controller/CompanyController.php
@@ -40,7 +40,7 @@ class CompanyController extends BaseApiController
     public function unsigned()
     {
         $myCompany = Company::findOrEmpty($this->userInfo['company_id'])->toArray();
-        $query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18]]);
+        $query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18],'is_contract'=>0]);
         $count = $query->count();
         $companies = $query->select()->toArray();
         return $this->success('', ['count' => $count, 'data' => $companies]);
diff --git a/app/api/lists/AccountLogLists.php b/app/api/lists/AccountLogLists.php
index d1a3fb40b..38668b889 100755
--- a/app/api/lists/AccountLogLists.php
+++ b/app/api/lists/AccountLogLists.php
@@ -102,12 +102,13 @@ class AccountLogLists extends BaseApiDataLists
      */
     public function company_lists(): array
     {
-        $field = 'change_type,change_amount,action,create_time,remark';
+        $field = 'change_type,change_amount,action,create_time,remark,user_id';
         $where=[
             'company_id'=>$this->params['company_id']
         ];
         $lists = UserAccountLog::field($field)
             ->where($where)
+            ->with(['userInfo'])
             ->whereDay('create_time')
             ->order('id', 'desc')
             ->limit($this->limitOffset, $this->limitLength)
@@ -168,6 +169,7 @@ class AccountLogLists extends BaseApiDataLists
                     }
                 }
             }
+            $data[$k]['remark']='任务收益';
             if(!isset($data[$k]['income'])||!isset($data[$k]['expenditure'])){
                 unset($data[$k]);
             }
diff --git a/app/common/model/user/UserAccountLog.php b/app/common/model/user/UserAccountLog.php
index 98548b338..169867a1e 100755
--- a/app/common/model/user/UserAccountLog.php
+++ b/app/common/model/user/UserAccountLog.php
@@ -27,4 +27,9 @@ class UserAccountLog extends BaseModel
     use SoftDelete;
 
     protected $deleteTime = 'delete_time';
+
+    public function userInfo()
+    {
+        return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname');
+    }
 }
\ No newline at end of file
diff --git a/vendor/ebaoquan/junziqian_sdk b/vendor/ebaoquan/junziqian_sdk
index 1294ea49f..9acc82cd2 160000
--- a/vendor/ebaoquan/junziqian_sdk
+++ b/vendor/ebaoquan/junziqian_sdk
@@ -1 +1 @@
-Subproject commit 1294ea49ff9ecc4532821f8798304816cbf8dd74
+Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049