dongasai 6 mesiacov pred
rodič
commit
6a6f39d6fc

+ 77 - 0
app/Module/AppGame/Handler/Public/PlayerDataHandler.php

@@ -5,7 +5,9 @@ namespace App\Module\AppGame\Handler\Public;
 use App\Module\AppGame\Handler\BaseHandler;
 use App\Module\Farm\Services\BuffService;
 use App\Module\Farm\Services\LandService;
+use App\Module\Fund\Services\AccountService;
 use App\Module\Game\Services\SkinService;
+use App\Module\GameItems\Services\ItemService;
 use App\Module\Pet\Services\PetService;
 use App\Module\User\Services\UserService;
 use Google\Protobuf\Internal\Message;
@@ -15,6 +17,7 @@ use Uraus\Kku\Response\PublicUserInfo;
 use Uraus\Kku\Response\PublicGod;
 use Uraus\Kku\Response\PublicLand;
 use Uraus\Kku\Response\PublicPet;
+use Uraus\Kku\Response\PublicZichan;
 
 /**
  * 处理玩家数据请求(公共数据)
@@ -54,6 +57,9 @@ class PlayerDataHandler extends BaseHandler
         // 获取宠物数据
         $this->setPetInfo($response, $targetUserId);
 
+        // 获取资产数据
+        $this->setZichanInfo($response, $targetUserId);
+
         return $response;
     }
 
@@ -229,4 +235,75 @@ class PlayerDataHandler extends BaseHandler
             ]);
         }
     }
+
+    /**
+     * 设置资产数据
+     *
+     * @param ResponsePublicPlayerData $response
+     * @param int $userId
+     * @return void
+     */
+    private function setZichanInfo(ResponsePublicPlayerData $response, int $userId): void
+    {
+        try {
+            // 创建PublicZichan对象
+            $publicZichan = new PublicZichan();
+
+            // 获取钻石余额(fund_id = 2)
+            $diamondBalance = 0;
+            try {
+                $accounts = AccountService::list4user($userId);
+                foreach ($accounts as $account) {
+                    if ($account->getFundId() == 2) { // 钻石的fund_id是2
+                        $diamondBalance = $account->balance;
+                        break;
+                    }
+                }
+            } catch (\Exception $e) {
+                \Illuminate\Support\Facades\Log::warning('获取用户钻石余额失败', [
+                    'user_id' => $userId,
+                    'error' => $e->getMessage()
+                ]);
+            }
+
+            // 获取建筑材料数量
+            $woodQuantity = 0;   // 木材 (item_id = 33)
+            $stoneQuantity = 0;  // 石材 (item_id = 34)
+            $steelQuantity = 0;  // 钢材 (item_id = 35)
+
+            try {
+                // 获取木材数量
+                $woodItems = ItemService::getUserItems($userId, ['item_id' => 33]);
+                $woodQuantity = $woodItems->sum('quantity');
+
+                // 获取石材数量
+                $stoneItems = ItemService::getUserItems($userId, ['item_id' => 34]);
+                $stoneQuantity = $stoneItems->sum('quantity');
+
+                // 获取钢材数量
+                $steelItems = ItemService::getUserItems($userId, ['item_id' => 35]);
+                $steelQuantity = $steelItems->sum('quantity');
+            } catch (\Exception $e) {
+                \Illuminate\Support\Facades\Log::warning('获取用户建筑材料数量失败', [
+                    'user_id' => $userId,
+                    'error' => $e->getMessage()
+                ]);
+            }
+
+            // 设置资产信息
+            $publicZichan->setZuanshi((float)$diamondBalance);
+            $publicZichan->setMucai((float)$woodQuantity);
+            $publicZichan->setShicai((float)$stoneQuantity);
+            $publicZichan->setGangcai((float)$steelQuantity);
+
+            $response->setZichan($publicZichan);
+
+        } catch (\Exception $e) {
+            // 如果获取资产信息失败,记录日志但不影响其他数据的返回
+            \Illuminate\Support\Facades\Log::warning('获取用户资产公共信息失败', [
+                'user_id' => $userId,
+                'error' => $e->getMessage()
+            ]);
+        }
+    }
 }

+ 1 - 1
config/proto_route.php

@@ -106,7 +106,7 @@ return array (
       7 => 'query_data',
     ),
   ),
-  'generated_at' => '+00:00 2025-07-08 08:01:58',
+  'generated_at' => '+08:00 2025-07-11 13:34:39',
   'conventions' => 
   array (
     'handler_namespace' => 'App\\Module\\AppGame\\Handler',

+ 11 - 5
protophp/GPBMetadata/Proto/Game.php

@@ -16,7 +16,7 @@ class Game
         }
         $pool->internalAddGeneratedFile(
             '
-òÂ
+õÃ
 proto/game.proto	uraus.kku"ç?
 Request
 request_unid (	;
@@ -278,7 +278,7 @@ select_ids (.
 times (R
 RequestPromotionList+
 page (2.uraus.kku.Common.RequestPage
-level ("¶R
+level ("¹S
 Response
 run_unid (	
 run_ms (-
@@ -375,12 +375,13 @@ shop_query
 is_prohibit (:
 last_login_info (2!.uraus.kku.Response.LastLoginInfo-
 ResponsePublicRegister
-is_register (ç
+is_register (™
 ResponsePublicPlayerData5
 	user_info (2".uraus.kku.Response.PublicUserInfo0
 	gods_info (2.uraus.kku.Response.PublicGod1
 	land_info (2.uraus.kku.Response.PublicLand/
-pet_info (2.uraus.kku.Response.PublicPetH
+pet_info (2.uraus.kku.Response.PublicPet0
+zichan (2 .uraus.kku.Response.PublicZichanH
 ResponsePublicSendSms
 remaining_times (
 next_send_time ((
@@ -418,7 +419,12 @@ PublicLand
 type_id (
 name (	
 level (
-power (
+power (O
+PublicZichan
+zuanshi (
+mucai (
+shicai (
+gangcai (
 ResponseLandFertilizer
 ResponseLandWatering
 ResponseLandPesticide

+ 176 - 0
protophp/Uraus/Kku/Response/PublicZichan.php

@@ -0,0 +1,176 @@
+<?php
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: proto/game.proto
+
+namespace Uraus\Kku\Response;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * 公开资产信息
+ *
+ * Generated from protobuf message <code>uraus.kku.Response.PublicZichan</code>
+ */
+class PublicZichan extends \Google\Protobuf\Internal\Message
+{
+    /**
+     * 资产信息
+     *钻石
+     *
+     * Generated from protobuf field <code>float zuanshi = 2;</code>
+     */
+    protected $zuanshi = 0.0;
+    /**
+     *木材
+     *
+     * Generated from protobuf field <code>float mucai = 3;</code>
+     */
+    protected $mucai = 0.0;
+    /**
+     *石材
+     *
+     * Generated from protobuf field <code>float shicai = 4;</code>
+     */
+    protected $shicai = 0.0;
+    /**
+     *钢材
+     *
+     * Generated from protobuf field <code>float gangcai = 6;</code>
+     */
+    protected $gangcai = 0.0;
+
+    /**
+     * Constructor.
+     *
+     * @param array $data {
+     *     Optional. Data for populating the Message object.
+     *
+     *     @type float $zuanshi
+     *           资产信息
+     *          钻石
+     *     @type float $mucai
+     *          木材
+     *     @type float $shicai
+     *          石材
+     *     @type float $gangcai
+     *          钢材
+     * }
+     */
+    public function __construct($data = NULL) {
+        \GPBMetadata\Proto\Game::initOnce();
+        parent::__construct($data);
+    }
+
+    /**
+     * 资产信息
+     *钻石
+     *
+     * Generated from protobuf field <code>float zuanshi = 2;</code>
+     * @return float
+     */
+    public function getZuanshi()
+    {
+        return $this->zuanshi;
+    }
+
+    /**
+     * 资产信息
+     *钻石
+     *
+     * Generated from protobuf field <code>float zuanshi = 2;</code>
+     * @param float $var
+     * @return $this
+     */
+    public function setZuanshi($var)
+    {
+        GPBUtil::checkFloat($var);
+        $this->zuanshi = $var;
+
+        return $this;
+    }
+
+    /**
+     *木材
+     *
+     * Generated from protobuf field <code>float mucai = 3;</code>
+     * @return float
+     */
+    public function getMucai()
+    {
+        return $this->mucai;
+    }
+
+    /**
+     *木材
+     *
+     * Generated from protobuf field <code>float mucai = 3;</code>
+     * @param float $var
+     * @return $this
+     */
+    public function setMucai($var)
+    {
+        GPBUtil::checkFloat($var);
+        $this->mucai = $var;
+
+        return $this;
+    }
+
+    /**
+     *石材
+     *
+     * Generated from protobuf field <code>float shicai = 4;</code>
+     * @return float
+     */
+    public function getShicai()
+    {
+        return $this->shicai;
+    }
+
+    /**
+     *石材
+     *
+     * Generated from protobuf field <code>float shicai = 4;</code>
+     * @param float $var
+     * @return $this
+     */
+    public function setShicai($var)
+    {
+        GPBUtil::checkFloat($var);
+        $this->shicai = $var;
+
+        return $this;
+    }
+
+    /**
+     *钢材
+     *
+     * Generated from protobuf field <code>float gangcai = 6;</code>
+     * @return float
+     */
+    public function getGangcai()
+    {
+        return $this->gangcai;
+    }
+
+    /**
+     *钢材
+     *
+     * Generated from protobuf field <code>float gangcai = 6;</code>
+     * @param float $var
+     * @return $this
+     */
+    public function setGangcai($var)
+    {
+        GPBUtil::checkFloat($var);
+        $this->gangcai = $var;
+
+        return $this;
+    }
+
+}
+
+// Adding a class alias for backwards compatibility with the previous class name.
+class_alias(PublicZichan::class, \Uraus\Kku\Response_PublicZichan::class);
+

+ 44 - 0
protophp/Uraus/Kku/Response/ResponsePublicPlayerData.php

@@ -39,6 +39,12 @@ class ResponsePublicPlayerData extends \Google\Protobuf\Internal\Message
      * Generated from protobuf field <code>.uraus.kku.Response.PublicPet pet_info = 4;</code>
      */
     protected $pet_info = null;
+    /**
+     *     资产信息
+     *
+     * Generated from protobuf field <code>.uraus.kku.Response.PublicZichan zichan = 5;</code>
+     */
+    protected $zichan = null;
 
     /**
      * Constructor.
@@ -54,6 +60,8 @@ class ResponsePublicPlayerData extends \Google\Protobuf\Internal\Message
      *           土地数据
      *     @type \Uraus\Kku\Response\PublicPet $pet_info
      *           宠物
+     *     @type \Uraus\Kku\Response\PublicZichan $zichan
+     *               资产信息
      * }
      */
     public function __construct($data = NULL) {
@@ -185,6 +193,42 @@ class ResponsePublicPlayerData extends \Google\Protobuf\Internal\Message
         return $this;
     }
 
+    /**
+     *     资产信息
+     *
+     * Generated from protobuf field <code>.uraus.kku.Response.PublicZichan zichan = 5;</code>
+     * @return \Uraus\Kku\Response\PublicZichan
+     */
+    public function getZichan()
+    {
+        return isset($this->zichan) ? $this->zichan : null;
+    }
+
+    public function hasZichan()
+    {
+        return isset($this->zichan);
+    }
+
+    public function clearZichan()
+    {
+        unset($this->zichan);
+    }
+
+    /**
+     *     资产信息
+     *
+     * Generated from protobuf field <code>.uraus.kku.Response.PublicZichan zichan = 5;</code>
+     * @param \Uraus\Kku\Response\PublicZichan $var
+     * @return $this
+     */
+    public function setZichan($var)
+    {
+        GPBUtil::checkMessage($var, \Uraus\Kku\Response\PublicZichan::class);
+        $this->zichan = $var;
+
+        return $this;
+    }
+
 }
 
 // Adding a class alias for backwards compatibility with the previous class name.

+ 16 - 0
protophp/Uraus/Kku/Response_PublicZichan.php

@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: proto/game.proto
+
+namespace Uraus\Kku;
+
+if (false) {
+    /**
+     * This class is deprecated. Use Uraus\Kku\Response\PublicZichan instead.
+     * @deprecated
+     */
+    class Response_PublicZichan {}
+}
+class_exists(Response\PublicZichan::class);
+@trigger_error('Uraus\Kku\Response_PublicZichan is deprecated and will be removed in the next major release. Use Uraus\Kku\Response\PublicZichan instead', E_USER_DEPRECATED);
+