afa il y a 8 mois
Parent
commit
1945a63712

+ 0 - 19
application/admin/behavior/Airdrop.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace app\admin\behavior;
-
-use think\Request;
-
-class Airdrop
-{
-      // 行为逻辑
-      public function run($params)
-      {
-            
-            for ($i=0; $i < 5000 ; $i++) { 
-                  file_put_contents('1.log', $i."A===",FILE_APPEND);
-            }
-            
-            
-      }
-}

+ 0 - 3
application/admin/command/Task.php

@@ -11,9 +11,6 @@ use app\common\model\Region;
 
 class Task extends Command
 {
-
-  
-
       protected function configure()
       {
             $this->setName('task')->setDescription('Compress js and css file');

+ 27 - 21
application/admin/controller/user/Airdrop.php

@@ -3,16 +3,12 @@
 namespace app\admin\controller\user;
 
 use app\common\controller\Backend;
-use app\admin\library\Auth;
 use Exception;
-use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
-use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
-use PhpOffice\PhpSpreadsheet\Reader\Xls;
-use PhpOffice\PhpSpreadsheet\Reader\Csv;
 use think\Db;
-use think\db\exception\BindParamException;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\ModelNotFoundException;
+use app\common\model\ProductPopular;
+use app\common\model\UserModel;
+use app\api\logic\WelfareLoginc;
+use app\common\model\ProductOrder;
 use think\exception\DbException;
 use think\exception\PDOException;
 use think\exception\ValidateException;
@@ -42,12 +38,10 @@ class Airdrop extends Backend
 
     /**
      * 1. 从平台向指定账号空投一定数量的指定产品
-     * 2. 
-     * 3.茶付宝上指定区域消费指定金额空投 D 茶权需要开发回调接口
+     * 2. 向所有持有超过设定数量RWA茶的用户空投一定"数量"的指定产品(同一用户是否重复空头) a.先统计(RWA茶的用户)
+     * 3. 茶付宝上指定区域消费指定金额空投 D 茶权需要开发回调接口
      */
-
-
-       /**
+    /**
      * 查看
      *
      * @return string|Json
@@ -75,9 +69,8 @@ class Airdrop extends Backend
     }
 
 
-      /**
+    /**
      * 添加
-     *
      * @return string
      * @throws \think\Exception
      */
@@ -91,7 +84,6 @@ class Airdrop extends Backend
             $this->error(__('Parameter %s can not be empty', ''));
         }
         $params = $this->preExcludeFields($params);
-
         if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
             $params[$this->dataLimitField] = $this->auth->id;
         }
@@ -104,7 +96,25 @@ class Airdrop extends Backend
                 $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
                 $this->model->validateFailException()->validate($validate);
             }
-
+            if($params['type_id'] == 0){
+                $user = (new UserModel)->getByAddress($params['address']);
+                if(empty($user)) throw new Exception('用户不存在');
+                WelfareLoginc::setUserWelfareLos($user->id, $params['product_id'], $params['num'], time(), 'zh', ProductOrder::Airdrop);
+                //添加Rwa数
+                UserModel::updateForRwaNum($user->id, $user->parent_id, $params['num'], '+');
+                $params['status'] = 1;
+            }
+            if($params['type_id'] == 1){
+                $totalNum = WelfareLoginc::getUserRwaNum($params['rwa_num'], $params['rwa_mod'], $params['num']);
+                $result = ProductPopular::getPopularByTime($params['product_id'], 'zh', strtotime($params['start_time']));
+                if(!$result || $totalNum > $result->stock) throw new Exception(__('库存不足'));
+                $params['total_num'] = $totalNum;
+            }
+            if(!empty($params['area_id'][0])){
+                $params['area_id'] = rtrim(implode(',', $params['area_id']), ',');
+            }else{
+                unset($params['area_id']); 
+            }
             $result = $this->model->allowField(true)->save($params);
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
@@ -114,11 +124,7 @@ class Airdrop extends Backend
         if ($result === false) {
             $this->error(__('No rows were inserted'));
         }
-
-        hook('airdropSend',['phone'=>1,'code'=>2,'status'=>"3"]);
         $this->success();
     }
 
-
-
 }

+ 3 - 1
application/admin/lang/zh-cn/user/airdrop.php

@@ -7,5 +7,7 @@ return [
     'Product_id' => '产品',
     'Num'        => '空投数量',
     'Remark'     => '备注',
-    'Status'     => '状态'
+    'Status'     => '状态',
+     'Create_time'       => '创建时间',
+    'Update_time'       => '更新时间'
 ];

+ 31 - 9
application/admin/view/product/lists/add.html

@@ -34,22 +34,45 @@
         </div>
     </div>
     <div class="form-group">
-        
         <label class="control-label col-xs-12 col-sm-2">{:__('Gift_fee')}:</label>
-        <div class="col-xs-12 col-sm-2">
+        <div class="col-xs-12 col-sm-3">
             <input id="c-gift_fee" data-rule="required" class="form-control" name="row[gift_fee]" type="text"  value="">
         </div>
-    
-        <label class="control-label col-xs-12 col-sm-1">{:__('关联区域')}:</label>
-        <div class="col-xs-12 col-sm-1">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Freight')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-freight" data-rule="required" class="form-control" name="row[freight]" type="text"  value="">
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('开启赠送')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_gift]', ['1'=>__('开启'), '0'=>__('关闭')])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启寄售')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_transfer]', ['1'=>__('开启'), '0'=>__('关闭')])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启提货')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_freight]', ['1'=>__('开启'), '0'=>__('关闭')])}
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('关联区域')}:</label>
+        <div class="col-xs-12 col-sm-2">
             {:build_radios('row[is_area]', ['0'=>__('否'), '1'=>__('关联')])}
         </div>
-        <label class="control-label col-xs-12 col-sm-1">{:__('Freight')}:</label>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启存储')}:</label>
         <div class="col-xs-12 col-sm-2">
-            <input id="c-freight" data-rule="required" class="form-control" name="row[freight]" type="text"  value="">
+            {:build_radios('row[is_storage]', ['1'=>__('开启'), '0'=>__('关闭')])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启求购')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_buying]', ['1'=>__('开启'), '0'=>__('关闭')])}
         </div>
     </div>
-
+    
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Thum')}:</label>
         <div class="col-xs-12 col-sm-8">
@@ -78,7 +101,6 @@
             <ul class="row list-inline faupload-preview" id="p-images"></ul>
         </div>
     </div>
-   
 
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>

+ 29 - 6
application/admin/view/product/lists/edit.html

@@ -33,19 +33,42 @@
         </div>
     </div>
     <div class="form-group">
-        
         <label class="control-label col-xs-12 col-sm-2">{:__('Gift_fee')}:</label>
-        <div class="col-xs-12 col-sm-2">
+        <div class="col-xs-12 col-sm-3">
             <input id="c-gift_fee" data-rule="required" class="form-control" name="row[gift_fee]" type="text"  value="{$row.gift_fee|htmlentities}">
         </div>
+        <label class="control-label col-xs-12 col-sm-2">{:__('Freight')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-freight" data-rule="required" class="form-control" name="row[freight]" type="text"  value="{$row.freight|htmlentities}">
+        </div>
+    </div>
     
-        <label class="control-label col-xs-12 col-sm-1">{:__('关联区域')}:</label>
-        <div class="col-xs-12 col-sm-1">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('开启赠送')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_gift]', ['1'=>__('开启'), '0'=>__('关闭')], $row['is_gift'])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启寄售')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_transfer]', ['1'=>__('开启'), '0'=>__('关闭')], $row['is_transfer'])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启提货')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_freight]', ['1'=>__('开启'), '0'=>__('关闭')], $row['is_freight'])}
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('关联区域')}:</label>
+        <div class="col-xs-12 col-sm-2">
             {:build_radios('row[is_area]', ['0'=>__('否'), '1'=>__('关联')], $row['is_area'])}
         </div>
-        <label class="control-label col-xs-12 col-sm-1">{:__('Freight')}:</label>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启存储')}:</label>
         <div class="col-xs-12 col-sm-2">
-            <input id="c-freight" data-rule="required" class="form-control" name="row[freight]" type="text"  value="{$row.freight|htmlentities}">
+            {:build_radios('row[is_storage]', ['1'=>__('开启'), '0'=>__('关闭')], $row['is_storage'])}
+        </div>
+        <label class="control-label col-xs-12 col-sm-1">{:__('开启求购')}:</label>
+        <div class="col-xs-12 col-sm-2">
+            {:build_radios('row[is_buying]', ['1'=>__('开启'), '0'=>__('关闭')], $row['is_buying'])}
         </div>
     </div>
 

+ 0 - 2
application/admin/view/product/popular/edit.html

@@ -17,7 +17,6 @@
             <input id="c-cost_price" data-rule="required" class="form-control" step="0.01" name="row[cost_price]" type="number" value="{$row.cost_price|htmlentities}">
         </div>
     </div>
-
     <div class='form-group'>
         <label class="control-label col-xs-12 col-sm-2">{:__('Pv')}:</label>
         <div class="col-xs-12 col-sm-3">
@@ -28,7 +27,6 @@
             <input id="c-weigh" data-rule="required" class="form-control" 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">{:__('Start_time')}:</label>
         <div class="col-xs-12 col-sm-3">

+ 60 - 5
application/admin/view/user/airdrop/add.html

@@ -1,19 +1,73 @@
-<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+<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">{:__('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-field="zh_name" class="form-control selectpage" name="row[product_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-num" data-rule="required;range(0.1~)" class="form-control" name="row[num]" type="number" value="0">
+        </div>
+    </div>
+  
+    <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" checked />指定账号
+            <input type="radio" name="row[type_id]" value="1" /> 超过Rwa数用户
+            <input type="radio" name="row[type_id]" value="2" /> 指定区域消费金
+        </div>
+    </div>
+
+    <div data-favisible="type_id=0" class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="">
         </div>
     </div>
   
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+    <div data-favisible="type_id=1" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('超过Rwa数')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number" value="0">
+            <input id="c-rwa_num" data-rule="required" class="form-control" name="row[rwa_num]" type="text" value="">
         </div>
     </div>
-   
+    <div data-favisible="type_id=1" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('发放方式')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_radios('row[rwa_mod]', ['0'=>__('数量'),'1'=>__('比例')])}
+            <label>选择比例方式发放, 上面"空投数量"请输入比例</label>
+        </div>
+        
+    </div>
+    
+    <div data-favisible="type_id=2" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('指定区域')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area,county">
+                <select class="province form-control" name="row[area_id][]" data-url="ajax/area"></select>
+                <select class="city form-control" name="row[area_id][]" data-url="ajax/area"></select>
+                <select class="area form-control" name="row[area_id][]" data-url="ajax/area"></select>
+                <select class="county form-control" name="row[area_id][]" data-url="ajax/area"></select>
+                <input type="hidden"  id="c-address" name="row[area_txt]" class="form-control" value="1" > 
+            </div>
+        </div>
+    </div>
+    <div data-favisible="type_id=2" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('消费金额')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-amount" data-rule="required" class="form-control" name="row[amount]" type="text" value="">
+        </div>
+        <label class="control-label col-xs-12 col-sm-2">{:__('投放时间')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[start_time]" type="text" value="{:date('Y-m-d H:i:s')}">
+        </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">
@@ -21,4 +75,5 @@
             <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
         </div>
     </div>
+  </div>
 </form>

+ 46 - 26
application/admin/view/user/airdrop/edit.html

@@ -1,53 +1,72 @@
-<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
-
+<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">{:__('Address')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
+            <input id="c-product_id" data-rule="required" data-source="product/lists/index" data-field="zh_name" class="form-control selectpage" 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">{:__('Rwa_num')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-rwa_num" data-rule="required" class="form-control" name="row[rwa_num]" type="number" value="{$row.rwa_num|htmlentities}">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-num" data-rule="required;range(1~)" class="form-control" name="row[num]" type="number" value="{$row.num|htmlentities}">
         </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/index" class="form-control selectpage" name="row[product_id]" type="text" value="{$row.product_id|htmlentities}">
+        <label class="control-label col-xs-12 col-sm-2">{:__('投放时间')}:</label>
+        <div class="col-xs-12 col-sm-3">
+            <input id="c-start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[start_time]" type="text" value="{:$row.start_time?datetime($row.start_time):''}">
         </div>
     </div>
+        
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">{:__('空投类型')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number" value="{$row.num|htmlentities}">
+            <input type="radio" name="row[type_id]" value="0" {if $rowtype_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>
     </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
+
+    <div data-favisible="type_id=0" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-remark" data-rule="required" class="form-control" name="row[remark]" type="text" value="{$row.remark|htmlentities}">
+            <input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
         </div>
     </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+  
+    <div data-favisible="type_id=1" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('超过Rwa数')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}">
+            <input id="c-address" data-rule="required" class="form-control" name="row[rwa_num]" type="text" value="{$row.rwa_num|htmlentities}">
         </div>
     </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
+    
+    <div data-favisible="type_id=2" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('指定区域')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-create_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}">
+            <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area,county">
+                <select class="province form-control" name="row[province]" data-url="ajax/area">
+                    <option value="11" selected=""></option>
+                </select>
+                <select class="city form-control" name="row[city]" data-url="ajax/area" >
+                    <option value="11" selected=""></option>
+                </select>
+                <select class="area form-control" name="row[area]" data-url="ajax/area">
+                    <option value="11" selected=""></option>
+                </select>
+                <select class="county form-control" name="row[county]" data-url="ajax/area">
+                    <option value="11" selected=""></option>
+                </select>
+                <input type="hidden"  id="c-address" name="row[area_txt]" class="form-control" value="{$row.area_txt|htmlentities}" > 
+            </div>
         </div>
     </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label>
+    <div data-favisible="type_id=2" class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('消费金额')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-update_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:$row.update_time?datetime($row.update_time):''}">
+            <input id="c-amount" data-rule="required" class="form-control" name="row[amount]" type="text" value="{$row.amount|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">
@@ -55,4 +74,5 @@
             <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
         </div>
     </div>
+</div>
 </form>

+ 0 - 12
application/admin/view/user/airdrop/index.html

@@ -8,19 +8,7 @@
                     <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('user/airdrop/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('user/airdrop/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('user/airdrop/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
-                        
-
-                        <div class="dropdown btn-group {:$auth->check('user/airdrop/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('user/airdrop/edit')}"

+ 35 - 0
application/api/command/SenAirdrop.php

@@ -0,0 +1,35 @@
+<?php
+
+
+namespace app\api\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use app\common\logic\AirdropLogic;
+use app\common\model\UserAirdrop;
+use think\Model;
+
+//空投,发放
+class SenAirdrop extends Command
+{
+    protected function configure()
+    {
+        $this->setName('SenAirdrop')->setDescription('Here is the remark ');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+
+        // 记录开始运行的时间
+        $GLOBALS['_beginTime'] = microtime(TRUE);
+        $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
+
+        // 发放团队奖励
+        $teamRewards = new AirdropLogic();
+        $teamRewards->setAirdropRewards();
+    
+        $time_total = round(microtime(true) - $GLOBALS['_beginTime'], 4);//计算耗时
+        $output->writeln('定时任务执行结束,总耗时' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
+    }
+}

+ 2 - 2
application/api/command/SendBonusRewards.php

@@ -6,7 +6,7 @@ namespace app\api\command;
 use think\console\Command;
 use think\console\Input;
 use think\console\Output;
-use app\common\logic\BonusRewards;
+use app\common\logic\BonusRewardsLogic;
 use app\common\model\TimedTaskLogModel;
 use think\Model;
 
@@ -30,7 +30,7 @@ class SendBonusRewards extends Command
         /*** 发放团队算力奖励 ***/
         $output->writeln("开始发放团队算力奖励:");
 
-        $model = new BonusRewards();
+        $model = new BonusRewardsLogic();
         
         $model->allowanceRewards();
 

+ 0 - 84
application/api/command/Team.php

@@ -1,84 +0,0 @@
-<?php
-
-
-namespace app\api\command;
-
-use think\console\Command;
-use think\console\Input;
-use think\console\Output;
-use app\common\logic\TeamRewards;
-use app\common\model\TimedTaskLogModel;
-use think\Model;
-
-
-class Team extends Command
-{
-    protected function configure()
-    {
-        $this->setName('Team')->setDescription('Here is the remark ');
-    }
-
-    protected function execute(Input $input, Output $output)
-    {
-        /* 永不超时 */
-//        ini_set('max_execution_time', 0);
-
-        // 记录开始运行的时间
-        $GLOBALS['_beginTime'] = microtime(TRUE);
-        $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
-
-//        $output->writeln("SMH拨币:" . date('Y-m-d H:i:s', time()));
-//        $begin = microtime(TRUE);
-//        $log_id = (new \app\common\logic\Team())->AllocateSmh();
-//        $time_total = round(microtime(true) - $begin, 4);//计算耗时
-//        //更新发放日志
-//        if($log_id > 0){
-//            (new TimedTaskLogModel())
-//                ->where('id', $log_id)
-//                ->update([
-//                    'id'            => $log_id,
-//                    'status'        => 1,
-//                    'end_time'      => date('Y-m-d H:i:s'),
-//                    'elapsed_time'  => $time_total
-//                ]);
-//        }
-//        $output->writeln('SMH拨币结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
-
-//        $output->writeln("Qubic拨币:" . date('Y-m-d H:i:s', time()));
-//        $begin = microtime(TRUE);
-//        $log_id = (new \app\common\logic\Team())->AllocateQubic();
-//        $time_total = round(microtime(true) - $begin, 4);//计算耗时
-//        //更新发放日志
-//        if($log_id > 0){
-//            (new TimedTaskLogModel())
-//                ->where('id', $log_id)
-//                ->update([
-//                    'id'            => $log_id,
-//                    'status'        => 1,
-//                    'end_time'      => date('Y-m-d H:i:s'),
-//                    'elapsed_time'  => $time_total
-//                ]);
-//        }
-//        $output->writeln('Qubic拨币结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
-
-        $output->writeln("Aleo拨币:" . date('Y-m-d H:i:s', time()));
-        $begin = microtime(TRUE);
-        $log_id = (new \app\common\logic\Team())->AllocateAleo();
-        $time_total = round(microtime(true) - $begin, 4);//计算耗时
-        //更新发放日志
-        if($log_id > 0){
-            (new TimedTaskLogModel())
-                ->where('id', $log_id)
-                ->update([
-                    'id'            => $log_id,
-                    'status'        => 1,
-                    'end_time'      => date('Y-m-d H:i:s'),
-                    'elapsed_time'  => $time_total
-                ]);
-        }
-        $output->writeln('Aleo拨币结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
-
-        $time_total = round(microtime(true) - $GLOBALS['_beginTime'], 4);//计算耗时
-        $output->writeln('定时任务执行结束,总耗时' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
-    }
-}

+ 0 - 10
application/api/common.php

@@ -55,13 +55,3 @@ function getConfig(string $name): string
     return (new \app\common\model\Config())->where('name', $name)->value('value');
 }
 
-
-/**
- * 获取配置
- * @param string $prefix
- * @return string
- */
-function getOrderSN(string $prefix = 'ORD'): string
-{  
-    return $prefix.date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
-}

+ 2 - 2
application/api/controller/Airdrop.php

@@ -45,7 +45,7 @@ class Airdrop extends Api
         Db::startTrans();
         try {
             //添加Rwa茶记录
-            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->new_product_id, $row->new_num, $this->lan, $productOrder::Newbie);
+            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->new_product_id, $row->new_num, time(), $this->lan, $productOrder::Newbie);
             //添加茶数量
             $userModel::updateForRwaNum($this->auth->id, $this->auth->parent_id, $row->new_num, '+');
             Db::commit();
@@ -70,7 +70,7 @@ class Airdrop extends Api
         Db::startTrans();
         try {
             //添加Rwa茶记录
-            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->super_product_id, $row->super_num, $this->lan, $productOrder::Super);
+            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->super_product_id, $row->super_num, time(), $this->lan, $productOrder::Super);
 
             //添加超级福利标识/上级
             $userModel::updateUserSuper($this->auth->id, $this->auth->parent_id);

+ 64 - 71
application/api/logic/WelfareLoginc.php

@@ -32,91 +32,84 @@ class WelfareLoginc
      * @param int   $num       数量
      * @param int   $lan       语言
      */
-    public static function setUserWelfareLos($uid, int $productId, $num, $lan, $typeId)
-    {
-        $tim = time();
+    public static function setUserWelfareLos($uid, int $productId, $num, $tim, $lan, $typeId)
+    {   
         $result = ProductPopular::getPopularByTime($productId, $lan, $tim);
         if(!$result || $num > $result->stock) throw new Exception(__('库存不足'));
-        if(empty($result->is_area)){
-            ProductOrder::setPopularNoAreaOrder($num, $result->id, $result->price, $result->product_id, $uid, $typeId);
-        }else{
-            $areaArr = ProductArea::where('product_id', $productId)->where('status', ProductArea::NORMAL)->orderRaw('RAND()')->limit($num)->column('id');
-            ProductOrder::setPopularAreaOrder($areaArr, $result->id, $result->price, $result->product_id, $uid, $typeId);
-        }
+        // if(empty($result->is_area)){
+        //     ProductOrder::setPopularNoAreaOrder($num, $result->id, $result->price, $result->product_id, $uid, $typeId);
+        // }else{
+        //     $areaArr = ProductArea::where('product_id', $productId)->where('status', ProductArea::NORMAL)->orderRaw('id desc')->limit($num)->column('id');
+        //     ProductOrder::setPopularAreaOrder($areaArr, $result->id, $result->price, $result->product_id, $uid, $typeId);
+        // }
+        self::setUserProductOrder($num, $result->is_area, $result->id, $result->price, $productId, $uid, $typeId);
         return ['start_time'=>$tim, 'name'=>$result->name, 'num'=>$num];
     }
 
 
-
-  
-
- 
-
-
-    /**
-     * 获取当日收益 Daily earnings
+    /*
+    这个条件是
+    向持有选定产品超过指定数量的用户空投指定数量/或比例/的指定产品,
+    比如
+    向持有A茶超过10套的用户,空投2套B茶
+    或
+    向持有A茶超过10套的用户,空投持有 数量X20%套B茶,数量取整
+    */
+    /** $mod 0指定数量 1比
+     * 获取用户Rwa数量
      */
-    private static function getDayEarnings(string $date)
+    public static function getUserRwaNum(int $rwa_num, $mod, $num): int
     {   
-        $between_time = [strtotime($date), strtotime($date) + 86400];
         //读取当日新增数据
-        return ProductOrder::where('type_id', ProductOrder::Popular)->where('status', ProductOrder::Paid)->whereBetween('create_time', $between_time)->sum('price');
+        $list = UserModel::where('rwa_num', '>=',$rwa_num)->column('id,rwa_num');
+        if(empty($list)) return 0;
+        $total = 0; //总数量
+        if($mod == 1 && $num > 0){
+            $num = bcdiv($num, 100, 2);
+            foreach ($list as $item) {
+                $total += bcmul($item, $num);
+            } 
+        }else{
+            $total = count($list) * $num;
+        }
+        return $total;
     }
 
-  
+    //空投Rwa发放
+    public static function setUserExRwaNum(int $rwa_num, $productId, $isArea, $orderId, $price, $mod, $num): int
+    {   
+        //读取当日新增数据
+        //$list = UserModel::where('rwa_num', '>=',$rwa_num)->column('id,rwa_num');
+        $total = 0; //总数量
+        $div = bcdiv($num, 100, 2);
+        UserModel::where('rwa_num', '>=',$rwa_num)->chunk(100,function($users) use($mod,$div,$num,$isArea,$orderId,$price,$productId,&$total){
+            foreach($users as $user){
+                // 处理user模型对象
+                $num = ($mod == 1)? bcmul($user->rwa_num, $div) : $num;
+                if(!empty(self::setUserProductOrder($num, $isArea, $orderId, $price, $productId, $user->id, ProductOrder::Airdrop))){
+                    // $user->rwa_num +=  $num;
+                    // $total +=$user->save();
+                    $user::updateForRwaNum($user->id, $user->parent_id, $num, '+');
+                }
+            }
+        });
+        return $total;
+    }
 
-  
 
-    /**
-     * 获取可用日期
-     * @var array
-     */
-    protected function getExeDate($type_id = 1)
+    private static function setUserProductOrder(int $num, $isArea, $orderId, $price, $productId, $uid, $typeId)
     {
-        $today = date('Y-m-d',strtotime("-1day"));//当前时间减一天为最后一次可用时间
-        $dateInfo = DB::table('timed_task_log')
-            ->where('type_id' ,$type_id)
-            ->where('status', 1)
-            ->order('date_time', 'desc')
-            ->find();
-        if(empty($dateInfo)){//首次
-            return $today;
-        }
-        $new_date = date('Y-m-d',strtotime("+1day",strtotime($dateInfo['date_time'])));//最后一次发放日期+1天为本次执行时间
-        if($new_date > $today){//超过今天
-            return "";
-        }
-        return $new_date;
+        if(empty($isArea)){
+            $result = ProductOrder::setPopularNoAreaOrder($num, $orderId, $price, $productId, $uid, $typeId);
+        }else{
+            $areaArr = ProductArea::where('product_id', $productId)->where('status', ProductArea::NORMAL)->orderRaw('id desc')->limit($num)->column('id');
+            $result =  ProductOrder::setPopularAreaOrder($areaArr, $orderId, $price, $productId, $uid, $typeId);
+        }  
+        return $result;
     }
 
-    /**
-     * 插入或更新收益统计信息
-     * @var array
-     */
-    protected function createData($uids, $amount, $date)
-    {
-        foreach ($uids as $user_id) {
-            $check = DB::table('team_rewards')
-                ->field('id')
-                ->where('user_id', $user_id)
-                ->where('date_time', $date)
-                ->find();
-            if ($check) {//存在,则更新
-                DB::table('team_rewards')
-                    ->where('id', $check['id'])
-                    ->update([
-                        'today_power' => Db::raw('today_power+' . $amount),
-                        'update_time' => date('Y-m-d H:i:s')
-                    ]);
-            } else {//新增
-                DB::table('team_rewards')
-                    ->insert([
-                        'user_id' => $user_id,
-                        'date_time' => $date,
-                        'today_power' => Db::raw('today_power+' . $amount),
-                        'create_time' => date('Y-m-d H:i:s')
-                    ]);
-            }
-        }
-    }
+
+
+   
+  
 }

+ 1 - 1
application/command.php

@@ -19,8 +19,8 @@ return [
     'app\admin\command\Api',
 
     'app\api\command\OrderPay',
-    'app\api\command\Team',
     'app\api\command\RechargeTxHashVerify',
     'app\api\command\SendBonusRewards', //奖金
+    'app\api\command\SenAirdrop', //空投
     'app\admin\command\Task',
 ];

+ 10 - 0
application/common.php

@@ -541,4 +541,14 @@ if (!function_exists('paymentLog')) {
         file_put_contents($filePath . $file_name, $content.PHP_EOL, FILE_APPEND);
 
     }
+
+    /**
+     * 获取单号
+     * @param string $prefix
+     * @return string
+     */
+    function getOrderSN(string $prefix = 'ORD'): string
+    {  
+        return $prefix.date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
+    }
 }

+ 24 - 69
application/common/logic/Team.php → application/common/logic/AirdropLogic.php

@@ -4,18 +4,12 @@
 namespace app\common\logic;
 
 use app\common\model\Config;
-use app\common\model\EtcWithdrawRecordModel;
-use app\common\model\LedgerQubicChangeModel;
-use app\common\model\LedgerSmhChangeModel;
+use app\common\model\UserAirdrop;
+use app\api\logic\WelfareLoginc;
+use app\common\model\ProductPopular;
 use app\common\model\LedgerTokenChangeModel;
-use app\common\model\LedgerUsdtChangeModel;
 use app\common\model\LedgerWalletModel;
-use app\common\model\OfflineRechargeRecordModel;
-use app\common\model\ParametersModel;
-use app\common\model\SmhWithdrawRecordModel;
 use app\common\model\TimedTaskLogModel;
-use app\common\model\UserModel;
-use app\common\model\UserPathModel;
 use fast\Action;
 use fast\Asset;
 use fast\MembershipLevel;
@@ -31,7 +25,7 @@ use fast\Http;
  * 团队奖励发放逻辑
  * 定时任务,定时发放,每天一次,一般在凌晨12一过开始
  */
-class Team
+class AirdropLogic
 {
     /**
      * 奖励名称及类型ID
@@ -40,74 +34,35 @@ class Team
     private array $rewards_type = [
         1 => 'SMH拨币',
         2 => 'Qubic拨币',
-        3 => '团队算力分红',
-        4 => '团队算力平级奖',
-        5 => '市场分红',
-        6 => '加权分红',
-        7 => '公司推荐奖',
-        8 => '保持等级',
-        9 => 'ETC拨币',
-        10 => 'SMH拨币',
-        11 => 'Aleo拨币',
     ];
 
     /**
-     * 拨币
-     * 向会员发放SMH
-     * 每一万算力每天收益9-10个币
+     * 空投发放
      */
-    public function AllocateSmh()
+    public function setAirdropRewards()
     {
-        $type_id = 1;
-
-        $date = $this->getExeDate($type_id);
-        if(empty($date)){
-            (new Output())->writeln("本次没有可用时间:" . $date);
-            return ;
-        }
-
-        //创建定时任务执行日志
-        $log_id = (new TimedTaskLogModel())->insertGetId([
-            'type_id'       => $type_id,
-            'type_name'     => $this->rewards_type[$type_id],
-            'date_time'     => $date,
-            'create_time'   => date('Y-m-d H:i:s'),
-        ]);
-
         //查找会员资产列表
-        $info_list = DB::table('ledger_wallet')
-            ->alias('w')
-            ->join('user u','u.id = w.user_id')
-            ->field('user_id,power')
-            ->where('power', '>', 0)
-            ->where('effective_time', '>', 0) //报单有收益
-            ->select();
-
+        $info_list = UserAirdrop::where('type_id', UserAirdrop::typeRwa)->where('status', UserAirdrop::NORMAL)->find();    
         if(empty($info_list)){
-            (new Output())->writeln("本次没有可用会员数据:" . $date);
-            return $log_id;
+            (new Output())->writeln("本次没有空投发放数据:");
+            return false;
         }
-
-        $num =rand(3000,4000);
-        $power_smh_price = $num/10000/1000;//每算力每日获得SMH的数量,算法为每一万算力每日产10个SMH
-
-        foreach ($info_list as $info) {
-            $amount = ($info['power']) * $power_smh_price;
-            $check = (new LedgerSmhChangeModel())
-                ->where('user_id', $info['user_id'])
-                ->where('action', LedgerSmhChangeModel::SysSend)
-                ->where('from_id', strtotime($date))
-                ->count();
-            if($check){
-                dump('用户ID:' . $info['user_id'] . '已拨过,拨币量为:' . $amount);
-            }else{
-                dump(['用户ID:' . $info['user_id'],'拨币量为:' . $amount]);
-
-                //发放
-                (new LedgerWalletModel)->changeWalletAccount($info['user_id'], Asset::SMH, $amount, LedgerSmhChangeModel::SysSend);
-            }
+        $result = ProductPopular::getPopularByTime($info_list['product_id'], 'zh', $info_list->start_time);
+        if(!$result || $info_list->total_num > $result->stock) {
+            (new Output())->writeln("本次执行库存不足:");
+            return false;
         }
-        return $log_id;
+        WelfareLoginc::setUserExRwaNum(
+            $info_list['rwa_num'],
+            $info_list['product_id'],
+            $result->is_area,  $result->id, $result->price,
+            $info_list['rwa_mod'],
+            $info_list['num']);
+        $info_list->status = UserAirdrop::STOP;
+        $info_list->remark = '总发放'.$info_list->total_num.'套';
+        return $info_list->save();
+        
+        
     }
 
     /**

+ 1 - 1
application/common/logic/BonusRewards.php → application/common/logic/BonusRewardsLogic.php

@@ -23,7 +23,7 @@ use fast\Http;
  * 团队奖励发放逻辑
  * 定时任务,定时发放,每天一次,一般在凌晨12一过开始
  */
-class BonusRewards
+class BonusRewardsLogic
 {
     /**
      * 奖励名称及类型ID

+ 2 - 1
application/common/model/ProductOrder.php

@@ -37,7 +37,8 @@ class ProductOrder extends Model
     const Transfer          = 1; //转让
     const Giveaway          = 2; //赠送
     const Newbie            = 3; //新人茶权空投
-    const Super             = 4; //新人福利空投 
+    const Super             = 4; //新人福利空投
+    const Airdrop           = 5; //空投
     /* 
      *  订单状态 '已下单', 1=>'已付款', 2=>'已转让', 3=>'提货', 4=>'已取消', 5=>'完成'];
      */

+ 2 - 1
application/common/model/ProductPopular.php

@@ -86,8 +86,9 @@ class ProductPopular extends Model
         return $info;
     }
 
+
     //获取当前抢购产品
-    public static function getPopularByTime(int $productId, string $lan, $tim): object
+    public static function getPopularByTime(int $productId, string $lan, $tim)
     {   
        return self::alias('a')->where('a.start_time', '<=', $tim)->where('a.end_time', '>=', $tim)
         ->join('product_list b', "a.product_id = b.id", "left")

+ 29 - 1
application/common/model/UserAirdrop.php

@@ -22,9 +22,27 @@ class UserAirdrop extends Model
     // 追加属性
     protected $append = [
         'create_time_text',
-        'update_time_text'
+        'update_time_text',
+        'start_time_text',
     ];
     
+    //状态
+    const STOP           = 1;
+    const NORMAL         = 0;
+
+    //0指定用户 1超过Rwa数 2指定地址
+    const typeUser        = 0;
+    const typeRwa         = 1;
+    const typeAddr        = 2;
+
+    //状态
+    public $status_list = [
+        '-1'                    => '全部',
+        self::STOP              => '停用',
+        self::NORMAL            => '正常'
+    ];
+
+
 
     public function getStatusList(){
         
@@ -55,5 +73,15 @@ class UserAirdrop extends Model
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
     }
 
+    
+    public function getStartTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['start_time']) ? $data['start_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+    protected function setStartTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
 
 }

+ 3 - 18
public/assets/js/backend/product/lists.js

@@ -47,22 +47,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
                                 };
                             }
                         },
-                        {
-                            field: 'en_name', title: __('En_name'), operate: false,
-                            formatter: function (value, row, index, field) {
-                                return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.en_name + "'>" + value + "</span>";
-                            },
-                            cellStyle: function (value, row, index, field) {
-                                return {
-                                    css: {
-                                        "white-space": "nowrap",
-                                        "text-overflow": "ellipsis",
-                                        "overflow": "hidden",
-                                        "max-width": "200px"
-                                    }
-                                };
-                            }
-                        },
                         { field: 'total_num', title: __('总设置数量'), operate: false },
                         { field: 'sell_num', title: __('已出售数量'), operate: false },
                         { field: 'min_transfer_fee', title: __('寄售转让费'), operate: false, formatter: function (value, row, index, field) {
@@ -74,6 +58,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
                         { field: 'status', title: __('Status'), searchList: { "1": __('上架'), "0": __('下架') }, formatter: Table.api.formatter.toggle },
                         { field: 'weigh', title: __('Weigh'), operate: false },
                         { field: 'is_area', title: __('关联区域'), searchList: { "1": __('是'), "0": __('否') }, formatter: Table.api.formatter.status },
+                        { field: 'is_transfer', title: __('寄售'), searchList: { "1": __('开启'), "0": __('关闭') }, formatter: Table.api.formatter.toggle },
+                        { field: 'is_gift', title: __('赠送'), searchList: { "1": __('开启'), "0": __('关闭') }, formatter: Table.api.formatter.toggle },
+                        { field: 'is_freight', title: __('提货'), searchList: { "1": __('开启'), "0": __('关闭') }, formatter: Table.api.formatter.toggle },
                         { field: 'create_time', title: __('Create_time'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                         
                         { field: 'operate', title: __('Operate'),
@@ -116,7 +103,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
             Controller.api.bindevent();
         },
         setarea: function () {
-
             Form.api.bindevent($("form[role=form]"));
         },
         api: {
@@ -125,7 +111,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
                 Vue.component('treeselect', VueTreeselect.Treeselect)
                 let areaData = [];
                 if ((Config.areaData).length > 0) areaData = JSON.parse(Config.areaData);
-         
                 let areas = markDisabled(area, areaData)
                 new Vue({
                     el: '#app',

+ 0 - 1
public/assets/js/backend/product/popular.js

@@ -32,7 +32,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'title', title: __('期数')},
                         {field: 'price', title: __('Price'), operate: false},
                         {field: 'cost_price', title: __('Cost_price'), operate:false},
-                        
                         {field: 'stock', title: __('Stock'), operate:false},
                         {field: 'init_num', title: __('初始销量'), operate:false},
                         {field: 'weigh', title: __('Weigh'), operate: false},

+ 14 - 7
public/assets/js/backend/user/airdrop.js

@@ -7,16 +7,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'user/airdrop/index' + location.search,
                     add_url: 'user/airdrop/add',
-                    edit_url: 'user/airdrop/edit',
                     del_url: 'user/airdrop/del',
                     multi_url: 'user/airdrop/multi',
                     import_url: 'user/airdrop/import',
                     table: 'user_airdrop',
                 }
             });
-
             var table = $("#table");
-
             // 初始化表格
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
@@ -26,12 +23,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
+                        { field: 'type_id', title: __('投放类型'), searchList: { "0": __('指定账号'), "1": __('超过Rwa数用户'),"2": __('指定区域消费金')}, formatter: Table.api.formatter.label },
+                        {field: 'product_id', title: __('Product_id'), operate: 'LIKE'},
+                        {field: 'num', title: __('Num'), operate: false},
                         {field: 'address', title: __('Address'), operate: 'LIKE'},
-                        {field: 'rwa_num', title: __('Rwa_num')},
-                        {field: 'product_id', title: __('Product_id')},
-                        {field: 'num', title: __('Num')},
+                        {field: 'rwa_num', title: __('Rwa_num'), operate: false},
+                        {field: 'amount', title: __('指定区域消费金'), operate: false, formatter: function (value, row, index, field) {
+                            return (row.amount > 0)? row.area_txt+ "-"+ row.amount: "";
+                        }},
                         {field: 'remark', title: __('Remark'), operate: 'LIKE'},
-                        {field: 'status', title: __('Status')},
+                        { field: 'status', title: __('Status'), searchList: { "1": __('已发放'), "0": __('待发放') }, formatter: Table.api.formatter.status },
                         {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}
@@ -51,6 +52,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));
+                //地区选择
+                $(document).on('change','.form-inline select',function(){
+                    let txt = $(this).find("option:selected").text();
+                    let obj = $(this).parents('.form-inline').find('input')
+                    if(txt != '请选择') obj.val(txt)
+                });
             }
         }
     };