afa 7 сар өмнө
parent
commit
8e7bf8e4fb

+ 40 - 126
application/api/controller/Market.php

@@ -8,10 +8,8 @@ use app\common\logic\MyBscApi;
 use app\common\controller\Api;
 use app\common\model\AnnouncementModel;
 use app\common\model\UserCollect;
-use app\common\model\LedgerSmhChangeModel;
 use app\common\model\LedgerUsdtChangeModel;
-use app\common\model\OfflineRechargeRecordModel;
-use app\common\model\OfflineWithdrawRecordModel;
+use app\common\model\ProductBuying;
 use app\common\model\ParametersModel;
 use app\common\model\ProductOrder;
 use app\common\model\UserModel;
@@ -43,141 +41,57 @@ class Market extends Api
 
 
 
-    
-
     /*
-     * 收藏列表
+     * 相关公告 
      */
-    public function collectList()
+    public function announcement(AnnouncementModel $announcementModel)
     {
-        //3.更新主表会员上级
-        dump('重建网体');
-        $parent_id = 100100;
-        $user_id = 101134;
-        $user = (new UserModel())
-            ->fetchSql(false)
-            ->where('id', $user_id)
-            ->update([
-                'parent_id' => $parent_id
-            ]);
-        dump($user, true, '更新状态');
-        //删除网体
-        (new UserPathModel())
-            ->where('user_id', $user_id)
-            ->delete();
-        // 创建网体
-        (new UserPathModel())->createPath($user_id, $parent_id);
-
-        $user_list = (new UserModel())
-            ->where('parent_id', $user_id)
-            ->select();
-        $i = 0;
-        foreach ($user_list as $user){
-            //删除网体
-            (new UserPathModel())
-                ->where('user_id', $user['id'])
-                ->delete();
-
-            // 创建网体
-            (new UserPathModel())->createPath($user['id'], $user['parent_id']);
-            $i++;
-        }
+        $params = $this->request->post();
+        $validate = \think\Loader::validate('Market');
+        if(!$validate->scene('announcement')->check($params)) $this->error($validate->getError());
+        $announcement = $announcementModel
+            ->where('find_in_set(:id,product_id)',['id'=>$params['product_id']])
+            ->where('status', $announcementModel::Normal)
+            ->where('to_lang', $this->request->getLan())
+            ->order('id desc')
+            ->paginate($this->pageSize);
+        $this->success('ok', $announcement);
+    }
+
+
+    //获取产品最大求购价格
+    public function getBuyingMaxPrice(ProductBuying $productBuying)
+    {
+        $params = $this->request->post();
+        $validate = \think\Loader::validate('Market');
+        if(!$validate->scene('announcement')->check($params)) $this->error($validate->getError());
+
+        $this->success('ok', $productBuying::getProductBuyingMaxPrice($params['product_id']));
 
-        halt($i);
     }
-   
-    public function daoru()
+    
+    //求购
+    public function buying()
     {
-        die;
-        $daoru_list = Db::table('user_base')
-            //->where('is_dao', 1)
-            ->select();
-        $i = 0;
-        $j = 0;
-        //重建钱包
-        foreach ($daoru_list as $key => $info) {
-            $user = (new UserModel())->getByAddress($info['address']);
-            if (!empty($user)) { // 已存在
-                // 更新总算力和账变
-                (new LedgerWalletModel)->changeWalletAccount($user['id'], Asset::POWER, $info['power'], Action::Reversal, 0);
-
-                // 更新自己(有效会员时间)和所有上级的信息(有效直推人数和团队总算力)
-                (new UserModel())->updateForRental($user['id'], $info['power']);
-                $j++;
-                continue;
-            }
-        }
+        $params = $this->request->post();
+        $validate = \think\Loader::validate('Market');
+        if(!$validate->scene('announcement')->check($params)) $this->error($validate->getError());
+
+   
 
-        //重建用户
-//        foreach ($daoru_list as $key => $info) {
-//
-//            $parent_user = (new UserModel())->getByAddress($info['parent_address']);
-//            if(empty($parent_user)){
-//                dump('没有上级');
-//                dump($info);
-//                continue;
-//            }
-//
-//            $user = (new UserModel())->getByAddress($info['address']);
-//            if (!empty($user)) { // 已存在
-//                dump($info['id'] . ' - ' . $info['address'] . ' - 已存在');
-//
-//                $is = Db::table('user')
-//                    ->where('id', $user['id'])
-//                    ->update([
-//                        'parent_id' => $parent_user['id']
-//                    ]);
-//                $j++;
-//                continue;
-//            }
-//
-//            unset($info['id']);
-//            unset($info['parent_address']);
-//            unset($info['is_dao']);
-//            $info['parent_id'] = $parent_user['id'];
-//            // 创建用户
-//            $newUserID = (new UserModel())->insertGetId($info);
-//            // 创建钱包
-//            (new LedgerWalletModel())->insertGetId([
-//                'user_id' => $newUserID,
-//            ]);
-//
-//            // 创建网体
-//            (new UserPathModel())->createPath($newUserID, $parent_user['id']);
-//
-//            $i++;
-//
-//        }
-        dump($i);
-        dump($j);
     }
 
-    public function updaetWallet()
+
+
+    //求购列表
+    public function buyingList()
     {
-        $daoru_list = Db::table('ledger_wallet_1')
-            ->whereNotNull('address')
-            ->select();
-        $i = 0;
-        foreach ($daoru_list as $key => $info) {
-            dump($info);
-            $user = (new UserModel())->getByAddress($info['address']);
-            if (empty($user)) {
-                dump($info['user_id'] . ' - ' . $info['address'] . ' - 不存在');
-                continue;
-            }
-            unset($info['user_id']);
-            unset($info['address']);
-
-            //更新钱包
-            $is_up = (new LedgerWalletModel())
-                ->where('user_id', $user['id'])
-                ->update($info);
-            dump($user['id'] . '更新' . $is_up);
-            $i++;
-        }
-        dump($i);
+     
+        
     }
 
+
+
     /**
      * 手段向某会员报单算力
      * @return void

+ 3 - 3
application/api/validate/Market.php

@@ -10,7 +10,7 @@ class Market extends Validate
      * 验证规则
      */
     protected $rule = [
-      'market_id'=> 'require',
+      'market_id'  => 'require',
       'product_id' => 'require',
       'area_id'    => 'requireIf:type,1',
       'num'        => 'requireIf:type,2|gt:0',
@@ -41,8 +41,8 @@ class Market extends Validate
      * 验证场景
      */
     protected $scene = [
-        'collect'  => ['market_id'],
-        'pick' => ['order_id'],
+        'collect'      => ['market_id'],
+        'announcement' => ['product_id'],
         'tran' => ['price', 'order_id'],
         'out'  => ['order_id'],
         'giv'  => ['order_id', 'address'],

+ 8 - 1
application/common/model/ProductBuying.php

@@ -22,6 +22,13 @@ class ProductBuying extends Model
         self::Normal        => '正常',
         self::SaleOut       => '已出售',
         self::Close         => '关闭',
-
     ];
+
+    public static function getProductBuyingMaxPrice(int $productId)
+    {
+        return self::where('product_id', $productId)->max('min_price');
+    }
+
+
+
 }