Prechádzať zdrojové kódy

Merge branch 'master' of https://git.hxiaoju.top/Teapay/RWACha-API

* 'master' of https://git.hxiaoju.top/Teapay/RWACha-API:
  排序
  轮播图
  rwa发放
  Rwa兑换
  福利兑换
  轮播图
jason 6 mesiacov pred
rodič
commit
161e6cffa6

+ 2 - 1
application/admin/controller/offline/RwaExchangeRecord.php

@@ -17,6 +17,7 @@ class RwaExchangeRecord extends Backend
      * @var \app\admin\model\offline\RwaExchangeRecord
      */
     protected $model = null;
+    protected $relationSearch = true;
 
     public function _initialize()
     {
@@ -44,7 +45,7 @@ class RwaExchangeRecord extends Backend
             return $this->selectpage();
         }
         [$where, $sort, $order, $offset, $limit] = $this->buildparams();
-        $list = $this->model->with('users,products')
+        $list = $this->model->with('users,welfarereda')
             ->where($where)
             ->order($sort, $order)
             ->paginate($limit);

+ 37 - 0
application/admin/controller/product/Welfarerede.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\admin\controller\product;
+
+use app\common\controller\Backend;
+
+/**
+ * 福利兑换管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Welfarerede extends Backend
+{
+
+    /**
+     * Welfarerede模型对象
+     * @var \app\admin\model\product\Welfarerede
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\ProductWelfareRede;
+
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+
+}

+ 1 - 1
application/admin/lang/zh-cn/general/announcement.php

@@ -4,7 +4,7 @@ return [
     'Type_id'        => '分类',
     'Sub_type_id'    => '二级分类',
     'Title'          => '标题',
-    'Introduction'=> '信息导读',
+    'Introduction'=> '信息导读/外链',
     'Body'        => '内容',
     'Images'      => '图片',
     'Weigh'       => '权重',

+ 16 - 0
application/admin/lang/zh-cn/product/welfarerede.php

@@ -0,0 +1,16 @@
+<?php
+
+return [
+    'Id'               => 'ID',
+    'Title'            => '标题',
+    'Product_image'    => '信息图片',
+    'Product_id'       => '兑换产品',
+    'Transfer_address' => '转入地址',
+    'Usdt_num'         => 'USDT数量',
+    'Is_token'         => '是否需要代币',
+    'Token_name'       => '代币名称',
+    'Token_address'    => '代币合约地址',
+    'Token_num'        => '代币数量',
+    'Create_time' => '创建时间',
+    'Update_time' => '更新时间'
+];

+ 27 - 0
application/admin/validate/product/Welfarerede.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate\product;
+
+use think\Validate;
+
+class Welfarerede extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 2 - 28
application/admin/view/product/lists/edit.html

@@ -114,31 +114,7 @@
             <ul class="row list-inline faupload-preview" id="p-images"></ul>
         </div>
     </div>
-    <div class="form-group" id="app">
-        <label class="control-label col-xs-12 col-sm-2">{:__('关联区域')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <div class="block">
-                <treeselect
-                valueFormat="value"
-                :multiple="true"
-                :options="options"
-                :flat="true"
-                :default-expand-level="1"
-                :sort-value-by="sortValueBy"
-                placeholder="选择关联区域"
-                v-model="data"
-                @input="handleChange"
-                :clearable='false'
-                ref="treeselect"/>
-                <template v-slot:value-label="{ node }">
-                  <span>{{ getNode(node) }}</span>
-                </template>
-              </treeselect>
-                <input id="c-product_area" class="form-control" name="row[product_area]" type="hidden" value="{$areaCode|htmlentities}">
-                <input id="c-product_area_txt" class="form-control" name="row[product_area_txt]" type="hidden" value="{$areaTxt|htmlentities}">
-            </div>
-        </div>    
-    </div>
+   
 
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
@@ -156,6 +132,4 @@
     </div>
 </div>
 </form>
-<script src="__CDN__/assets/libs/vue/vue.js"></script>
-<script src="__CDN__/assets/libs/treeselect/treeselect.js"></script>
-<link href="__CDN__/assets/libs/treeselect/treeselect.css" rel="stylesheet">
+

+ 78 - 0
application/admin/view/product/welfarerede/add.html

@@ -0,0 +1,78 @@
+<form id="add-form" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-horizontal">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-title" data-rule="required" class="form-control" rows="5" name="row[title]" cols="50"></textarea>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-product_image" data-rule="required" class="form-control" size="50" name="row[product_image]" type="text" value="">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-product_image" class="btn btn-danger faupload" data-input-id="c-product_image" data-params='{"category":"oss"}' data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-product_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-product_image" class="btn btn-primary fachoose" data-input-id="c-product_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-product_image"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-product_image"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-product_id" data-rule="required" data-source="product/lists/index" data-multiple="true" class="form-control selectpage" data-field="zh_name" name="row[product_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Transfer_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-transfer_address" data-rule="required" class="form-control" name="row[transfer_address]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Usdt_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-usdt_num" data-rule="required" class="form-control" step="0.0001" name="row[usdt_num]" type="number" value="0.0000">
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_token')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input type="radio" name="row[is_token]" value="0" checked />不需要
+            <input type="radio" name="row[is_token]" value="1" /> 需要
+        </div>
+    </div>
+
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_name" data-rule="required" class="form-control" name="row[token_name]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_address" data-rule="required" class="form-control" name="row[token_address]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_num" data-rule="required" class="form-control" step="0.0001" name="row[token_num]" type="number" value="0.0000">
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</div>
+</form>

+ 81 - 0
application/admin/view/product/welfarerede/edit.html

@@ -0,0 +1,81 @@
+<form id="edit-form" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-horizontal">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-title" data-rule="required" class="form-control" rows="5" name="row[title]" cols="50">{$row.title|htmlentities}</textarea>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-product_image" data-rule="required" class="form-control" size="50" name="row[product_image]" type="text" value="{$row.product_image|htmlentities}">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-product_image" class="btn btn-danger faupload" data-input-id="c-product_image" data-params='{"category":"oss"}' data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-product_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-product_image" class="btn btn-primary fachoose" data-input-id="c-product_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-product_image"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-product_image"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-product_id" data-rule="required" data-source="product/lists/index" data-multiple="true" class="form-control selectpage" data-field="zh_name" name="row[product_id]" type="text" value="{$row.product_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Transfer_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-transfer_address" data-rule="required" class="form-control" name="row[transfer_address]" type="text" value="{$row.transfer_address|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Usdt_num')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-usdt_num" data-rule="required" class="form-control" step="0.0001" name="row[usdt_num]" type="number" value="{$row.usdt_num|htmlentities}">
+        </div>
+        <label class="control-label col-xs-12 col-sm-2">{:__('排序')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-weigh" class="form-control" step="0.0001" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_token')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input type="radio" name="row[is_token]" value="0" {if $row.is_token==0} checked {/if}  />不需要 
+            <input type="radio" name="row[is_token]" value="1" {if $row.is_token==1} checked {/if} /> 需要
+        </div>
+    </div>
+
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_name" data-rule="required" class="form-control" name="row[token_name]" type="text" value="{$row.token_name|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_address')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_address" data-rule="required" class="form-control" name="row[token_address]" type="text" value="{$row.token_address|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group" data-favisible="is_token=1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Token_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-token_num" data-rule="required" class="form-control" step="0.0001" name="row[token_num]" type="number" value="{$row.token_num|htmlentities}">
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div></div>
+</form>

+ 35 - 0
application/admin/view/product/welfarerede/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('product/welfarerede/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('product/welfarerede/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('product/welfarerede/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        
+
+                        <div class="dropdown btn-group {:$auth->check('product/welfarerede/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('product/welfarerede/edit')}"
+                           data-operate-del="{:$auth->check('product/welfarerede/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 1 - 1
application/admin/view/user/airdrop/edit.html

@@ -20,7 +20,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('空投类型')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input type="radio" name="row[type_id]" value="0" {if $rowtype_id==0} checked {if/} />指定账号
+            <input type="radio" name="row[type_id]" value="0" {if $row.type_id==0} checked {if/} />指定账号
             <input type="radio" name="row[type_id]" value="1" {if $row.type_id==1} checked {if/} /> 超过Rwa数用户
             <input type="radio" name="row[type_id]" value="2" {if $row.type_id==2} checked {if/} /> 指定区域消费金
         </div>

+ 86 - 70
application/api/controller/Exchange.php

@@ -9,7 +9,7 @@ use app\common\logic\BscApi;
 use app\common\model\ProductLists;
 use app\common\model\LedgerFrozenChangeModel;
 use app\common\model\ProductOrder;
-use app\common\model\ProductsModel;
+use app\common\model\ProductWelfareRede;
 use app\common\model\RwaExchangeRecordModel;
 use app\common\model\LedgerWalletModel;
 use app\common\model\LedgerTeacChangeModel;
@@ -33,75 +33,102 @@ class Exchange extends Api
 
   
       //Rwa福利兑换配置
-      public function getWelfareRedeConfig(){
+      public function getWelfareRedeList(ProductWelfareRede $productWelfareRede){
 
-            $this->success('ok', config('welfare_rede'));
+            $list = $productWelfareRede
+                  ->order('weigh desc')
+                  ->paginate($this->pageSize);
+            $this->success('ok', $list);
       }
 
+      //Rwa福利兑换详情
+      public function getWelfareRedeDetail(ProductWelfareRede $productWelfareRede){
+
+            $ids = $this->request->post('ids');
+            if (empty($ids)) $this->error(__('Parameter error'));
+            $this->success('ok', $productWelfareRede::get($ids));
+      }
+
+
       //Rwa兑换
-      public function submitWelfare(LedgerWalletModel $ledgerWalletModel)
+      public function submitWelfare(LedgerWalletModel $ledgerWalletModel, ProductWelfareRede $productWelfareRede)
       {
-            $coin = $this->request->post('coin'); // 代币
+            $ids = $this->request->post('ids'); // 代币ids
             $coin_from_address = $this->request->post('coin_from_address'); // 代码转入地址
             $usdt_from_address = $this->request->post('usdt_from_address'); // U转入地址
-            if (empty($coin) || empty($coin_from_address) || empty($usdt_from_address)) {
+            if (empty($ids) || empty($coin_from_address) || empty($usdt_from_address)) {
                   $this->error(__('Parameter error'));
             }
             //检查区块链地址是否合法
-            if(!(isErc20AddressValid($coin_from_address) && isErc20AddressValid($usdt_from_address))){
-                  $this->error(__('Invalid parameters'));
-            }
-
-            $welfare_config = config('welfare_rede');
-            if (!in_array($coin, $welfare_config['currency'])) {
+           if(!(isErc20AddressValid($coin_from_address) && isErc20AddressValid($usdt_from_address))){
                   $this->error(__('Invalid parameters'));
             }
-
+            //福利兑换记录
+            $welfare_config = $productWelfareRede::get($ids);
+            if (!$welfare_config)  $this->error(__('Invalid parameters'));
+            
             $check_user = (new RwaExchangeRecordModel())->where('user_id', $this->auth->id)->where('status', 200)->count();
             if($check_user >= 4){
                   $this->error('每人限制兑换两套,您已达上限');
             }
-
-            $BscApi = new BscApi($welfare_config['contract_address'][$coin]);
-            $result_coin = $BscApi->getTransactionRecordsByAddress($coin_from_address, $welfare_config['transfer_address'], 49990000);
-            if ($result_coin['code'] == 0) {
-                  $this->error($result_coin['msg']);
-            }
-            Log::info($result_coin, '代币所有转入记录');
-            $coin_list = [];
-            foreach ($result_coin['data'] as $value) {
-                  if ($value['amount'] == $welfare_config['currency_price'][$coin]) {
-                  $coin_list[] = $value;
+            //有代币
+            $inster_data = [];
+            $order_no = date('YmdHis') . rand(1000, 9999);
+            if($welfare_config->is_token >0){
+                  $coin = $welfare_config->token_name;
+                  $BscApi = new BscApi($welfare_config->token_address);
+                  $result_coin = $BscApi->getTransactionRecordsByAddress($coin_from_address, $welfare_config->transfer_address, 49990000);
+                  if ($result_coin['code'] == 0) {
+                        $this->error($result_coin['msg']);
                   }
-            }
-            if (empty($coin_list)) {
-                  $this->error('未识别到代币转入记录');
-            }
-            Log::info($coin_list, '代币精准转入记录');
-
-            $coin_data = [];
-            foreach ($coin_list as $item) {
-                  $check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
-                  if (empty($check_info)) {
-                  $coin_data = $item;
-                  break;
+                  Log::info($result_coin, '代币所有转入记录');
+                  $coin_list = [];
+                  foreach ($result_coin['data'] as $value) {
+                        if ($value['amount'] == $welfare_config->token_num) {
+                        $coin_list[] = $value;
+                        }
                   }
-            }
-            if (empty($coin_data)) {
-                  $this->error('未识别到新代币转入记录');
-            }
-            Log::info($coin_list, '代币可用转入记录');
-
-            $BscApi = new BscApi($welfare_config['contract_address']['USDT']);
-            $result_usdt = $BscApi->getTransactionRecordsByAddress($usdt_from_address, $welfare_config['transfer_address'], 49990000);
+                  if (empty($coin_list)) {
+                        $this->error('未识别到代币转入记录');
+                  }
+                  Log::info($coin_list, '代币精准转入记录');
+
+                  $coin_data = [];
+                  foreach ($coin_list as $item) {
+                        $check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
+                        if (empty($check_info)) {
+                        $coin_data = $item;
+                        break;
+                        }
+                  }
+                  if (empty($coin_data)) {
+                        $this->error('未识别到新代币转入记录');
+                  }
+                  Log::info($coin_list, '代币可用转入记录');
+                  $inster_data[] = [
+                        'order_no' => $order_no,
+                        'tx_hash' => $coin_data['hash'],
+                        'user_id' => $this->auth->id,
+                        'symbol'  => $coin,
+                        'amount' => $coin_data['amount'],
+                        'product_id' => $welfare_config['product_id'],
+                        'from_address' => $coin_data['from'],
+                        'to_address' => $coin_data['to'],
+                        'welfare_id' => $ids,
+                        'status' => 200,
+                        'create_time' => time(),
+                  ];
+            }
+
+            $BscApi = new BscApi($welfare_config->token_address);
+            $result_usdt = $BscApi->getTransactionRecordsByAddress($usdt_from_address, $welfare_config->transfer_address, 49990000);
             if ($result_usdt['code'] == 0) {
                   $this->error($result_usdt['msg']);
             }
             Log::info($result_usdt, 'USDT所有转入记录');
-
             $usdt_list = [];
             foreach ($result_usdt['data'] as $value) {
-                  if ($value['amount'] == $welfare_config['currency_price']['USDT']) {
+                  if ($value['amount'] == $welfare_config->token_num) {
                   $usdt_list[] = $value;
                   }
             }
@@ -122,22 +149,9 @@ class Exchange extends Api
                   $this->error('未识别到新USDT转入记录');
             }
             Log::info($usdt_list, 'USDT可用入记录');
-
-            $order_no = date('YmdHis') . rand(1000, 9999);
-            $inster_data = [
-                  [
-                  'order_no' => $order_no,
-                  'tx_hash' => $coin_data['hash'],
-                  'user_id' => $this->auth->id,
-                  'symbol' => $coin,
-                  'amount' => $coin_data['amount'],
-                  'product_id' => $welfare_config['product_id'],
-                  'from_address' => $coin_data['from'],
-                  'to_address' => $coin_data['to'],
-                  'status' => 200,
-                  'create_time' => time(),
-                  ],
-                  [
+           
+            //记录
+            $inster_data[] = [
                   'order_no' => $order_no,
                   'tx_hash' => $usdt_data['hash'],
                   'user_id' => $this->auth->id,
@@ -146,21 +160,20 @@ class Exchange extends Api
                   'product_id' => $welfare_config['product_id'],
                   'from_address' => $usdt_data['from'],
                   'to_address' => $usdt_data['to'],
+                  'welfare_id' => $ids,
                   'status' => 200,
-                  'create_time' => time(),
-                  ]
+                  'create_time' => time()
             ];
             Log::info($inster_data, '插入数据');
-            $product_id = $welfare_config['product_id'];
-            $product_info =  (new ProductLists())->where('id', $product_id)->find();
-            if (empty($product_info))  $this->error('产品不存在');
+            
             try {
                   Db::startTrans();
-                  $rs = Db::name('rwa_exchange_record')->fetchSql(false)->insertAll($inster_data);
+                  Db::name('rwa_exchange_record')->fetchSql(false)->insertAll($inster_data);
                   //添加标记茶宝记录
                   $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::FROZEN, $usdt_data['amount'], LedgerFrozenChangeModel::RwaExchangeRecord, 0);
-                  //发放产品
-                  $rs = WelfareLoginc::setUserProductOrder(1, false, $order_no, 0, $product_info['id'], $this->auth->id, ProductOrder::RwaExchange);
+                  
+                  //发放产品奖励
+                  $rs =WelfareLoginc::setUserWelfareProduct($this->auth->id, $welfare_config['product_id'], $order_no, ProductOrder::RwaExchange);
                   Db::commit();
                   $this->success('ok', $order_no);
             } catch (Exception $e) {
@@ -170,6 +183,9 @@ class Exchange extends Api
       }
 
 
+      //
+
+
       //Teac兑换列表
       public function getTeacList(ProductLists $productLists){
              

+ 8 - 1
application/api/controller/Home.php

@@ -39,10 +39,11 @@ class Home extends Api
             'banner_list' => [],
             'notice_list' => []
         ];
-        // banner
+        // banner        
         $resp['banner_list'] = $announcement
             ->field('id,title as title,img_url,createtime')
             ->where('type_id', $announcement::Banner)
+            ->where('find_in_set(:id,sub_type_id)',['id'=>11])
             ->where('status', $announcement::Normal)
             ->where('is_show', $announcement::Normal)
             ->where('to_lang', $this->lan)
@@ -143,4 +144,10 @@ class Home extends Api
         // 提交事务
         $this->success('', $list);
     }
+
+    //首页轮播图
+    public function getBanner()
+    {
+        $this->success('ok', config('best_cha'));
+    }
 }

+ 0 - 1
application/api/logic/OrderLogic.php

@@ -32,7 +32,6 @@ class OrderLogic
       //获取产品发行量
       public static function getProductIssue(int $productId): int
       {
-      
             $popularNum = ProductPopular::where('product_id', $productId)->sum('stock-num');
             $holdNum = ProductOrder::where('product_id', $productId)->where('status', ProductOrder::Paid)->sum('num');
             return bcadd($popularNum, $holdNum);

+ 13 - 3
application/api/logic/WelfareLoginc.php

@@ -82,7 +82,6 @@ class WelfareLoginc
         // 使用bcdiv函数进行高精度除法运算,$num除以100,保留两位小数
         $div = bcdiv($num, 100, 2);
         $list = ProductOrder::getUserOrderByProductId($rwaProductId, $rwa_num);
-
         $user = new UserModel();
         foreach($list as $order){
                 //根据$mod的值决定是否需要对用户的rwa_num进行乘以$div的运算
@@ -174,12 +173,23 @@ class WelfareLoginc
             }
         }
 
-   
         //发放标记茶宝
         Loader::model('LedgerWalletModel')->changeWalletAccount($uid, Asset::FROZEN, $ecology['frozen'], LedgerFrozenChangeModel::Ecology, 0);
-
         //修改生态节点标识
         $user->is_ecology  = 1;
         return $user->save();
     }
+
+    //添加Rwa兑换福利产品
+    public static function setUserWelfareProduct(int $uid, string $productId, string $orderNo, int $typeId)
+    {
+        $productOrder = Loader::model('ProductOrder');
+        $productList = explode(',', $productId);
+        $result = [];
+        foreach ($productList as $item) {
+            $result[] = $productOrder::setCreateOrder(0, ['product_id'=> $item, 'area_id'=>0, 'price'=>0], $typeId, $uid, 0, $orderNo, 0, 0);
+        }
+        return $result;
+    }
+
 }

+ 57 - 0
application/common/model/ProductWelfareRede.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\common\model;
+
+use Exception;
+use fast\Action;
+use fast\Asset;
+use fast\RechargeOrderType;
+use fast\RechargeStatus;
+use think\Db;
+use think\Model;
+
+class ProductWelfareRede extends Model
+{
+    //福利兑换表
+    protected $name = "product_welfare_rede";
+
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'update_time_text'
+    ];
+
+
+
+  
+
+    public function getCreateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    public function getUpdateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setUpdateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+}

+ 6 - 0
application/common/model/RwaExchangeRecordModel.php

@@ -44,6 +44,12 @@ class RwaExchangeRecordModel extends Model
         return $this->hasOne('ProductLists', 'id', 'product_id', [], 'LEFT')->setEagerlyType(0);
     }
  
+    
+    //兑换
+    public function welfarereda()
+    {
+        return $this->hasOne('ProductWelfareRede', 'id', 'welfare_id', [], 'LEFT')->setEagerlyType(0);
+    }
 
     public function getCreateTimeTextAttr($value, $data)
     {

+ 13 - 0
application/config.php

@@ -399,4 +399,17 @@ return [
             4 => ['product_id'=>23, 'num'=>1], //翡翠地址”,空投价值18888茶宝“星火”RWA权益卡1张 product_id 23。
             5 => ['product_id'=>28, 'num'=>1]  //彩宝地址”,空投价值68888茶宝“始”RWA权益卡1张 product_id 28。
     ],
+    //优选茶权
+    'best_cha' => [
+        //横图1
+        'line1' => [
+            "img_url"=> "https://teaclub.oss-cn-chengdu.aliyuncs.com/rwacha/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250603132653.jpg",
+            "url"    => "exList"
+        ],
+        //横图2
+        'line2'=> [
+            "img_url"=> "https://teaclub.oss-cn-chengdu.aliyuncs.com/rwacha/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250603132644.jpg",
+            "url"    => "exchangeList"
+        ],
+    ],
 ];

+ 20 - 1
public/assets/js/backend/offline/rwa_exchange_record.js

@@ -24,12 +24,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id'), operate: false},
+                        {
+                            field: 'welfarereda.title', 
+                            title: __('福利兑换'), 
+                            operate: false,
+                            formatter : function(value, row, index, field){
+                                return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.title + "'>" + value + "</span>";
+                            },
+                            cellStyle : function(value, row, index, field){
+                                return {
+                                    css: {
+                                        "white-space": "nowrap",
+                                        "text-overflow": "ellipsis",
+                                        "overflow": "hidden",
+                                        "max-width":"150px"
+                                    }
+                                };
+                            }
+                        },
+                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                         {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                         {field: 'tx_hash', title: __('Tx_hash'), operate: 'LIKE'},
                         {field: 'users.address', title: __('User_id'),operate: 'LIKE'},
                         {field: 'symbol', title: __('Symbol'), operate: false},
                         {field: 'amount', title: __('Amount'), operate:false},
-                        {field: 'products.zh_name', title: __('Product_id'), operate:'LIKE'},
+                        {field: 'product_id', title: __('发放产品ID'), operate:'LIKE'},
                         {field: 'from_address', title: __('From_address'), operate: 'LIKE'},
                         {field: 'to_address', title: __('To_address'), operate: 'LIKE'},
                         {field: 'status', title: __('Status'), searchList: {

+ 82 - 0
public/assets/js/backend/product/welfarerede.js

@@ -0,0 +1,82 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'product/welfarerede/index' + location.search,
+                    add_url: 'product/welfarerede/add',
+                    edit_url: 'product/welfarerede/edit',
+                    del_url: 'product/welfarerede/del',
+                    multi_url: 'product/welfarerede/multi',
+                    import_url: 'product/welfarerede/import',
+                    table: 'product_welfare_rede',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {
+                            field: 'title', 
+                            title: __('Title'), 
+                            operate: false,
+                            formatter : function(value, row, index, field){
+                                return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.title + "'>" + value + "</span>";
+                            },
+                            cellStyle : function(value, row, index, field){
+                                return {
+                                    css: {
+                                        "white-space": "nowrap",
+                                        "text-overflow": "ellipsis",
+                                        "overflow": "hidden",
+                                        "max-width":"250px"
+                                    }
+                                };
+                            }
+                        },
+                        
+                        {field: 'product_image', title: __('Product_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'product_id', title: __('Product_id'), operate: false},
+                        {field: 'transfer_address', title: __('Transfer_address'), operate: 'LIKE'},
+                        {field: 'usdt_num', title: __('Usdt_num'), operate: false},
+                        {field: 'is_token', title: __('Is_token'), searchList: {'0': '不需要','1': '需要'}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
+                        {field: 'token_name', title: __('Token_name'), operate: false},
+                        {field: 'token_address', title: __('Token_address'), operate: false},
+                        {field: 'token_num', title: __('Token_num'), operate:false},
+                        { field: 'weigh', title: __('Weigh'), operate: false },
+                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});