afa 10 сар өмнө
parent
commit
a79d4497ea

+ 8 - 17
application/admin/controller/user/User.php

@@ -102,21 +102,6 @@ class User extends Backend
      */
     public function edit($ids = null)
     {
-
-
-        $google=new GoogleAuthenticator();
-        //生成验证秘钥
-        $secret=$google->createSecret();
-
-        //生成验证二维码 $username 需要绑定的用户名
-
-        echo $secret;
-        // $qrCodeUrl = $ga->getQRCodeGoogleUrl('localhost', $secret);
-        $qrCodeUrl = $google->getQRCodeGoogleUrl('localhost', $secret);
-
-      
-        dump($qrCodeUrl);die;
-
         $ids = intval($ids);
         $row = $this->model->get($ids);
         if (!$row) {
@@ -130,7 +115,12 @@ class User extends Backend
             $wallet             = (new LedgerWalletModel())->get($ids);
             $row['power']       = $wallet['power'] ?? "-";
 
+            $google=new GoogleAuthenticator();
+            //生成验证秘钥
+            //$secret=$google->createSecret();
+            $qrCodeUrl = $google->getQRCodeGoogleUrl('RWACHA',  config('google_secret'));
             $this->view->assign('row', $row);
+            $this->view->assign('qrCodeUrl', $qrCodeUrl);
             return $this->view->fetch();
         }
         $params = $this->request->post('row/a');
@@ -138,12 +128,13 @@ class User extends Backend
             $this->error(__('Parameter %s can not be empty', ''));
         }
         $params = $this->preExcludeFields($params);
-
         $newLevelId = $params['team_level_id'];
         if($newLevelId > 0 && empty((new TeamLevelModel())->getTeamLevelName($newLevelId))){
             $this->error('会员等级错误');
         }
-
+        $google=new GoogleAuthenticator();
+        $checkResult = $google->verifyCode(config('google_secret'), $params['code'], 6);
+        if (!$checkResult) $this->error('谷歌验证码错误');
         //茶宝
         $newPower       = bcadd($params['new_power'], 0, 6);
         // 启动事务

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

@@ -24,11 +24,23 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">茶宝调整(+/-):</label>
         <div class="col-xs-12 col-sm-8">
-            <label for="c-power"></label>
             <input id="c-power" class="form-control" placeholder="不填则不调整" name="row[new_power]" 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-8">
+            <input id="c-code" class="form-control" data-rule="required" placeholder="请输入验证码" name="row[code]" 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-8">
+            <img src="{$qrCodeUrl}" />
+        </div>
+    </div>
+ 
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">会员等级调整:</label>
         <div class="col-xs-8">

+ 6 - 3
application/api/controller/Order.php

@@ -125,7 +125,7 @@ class Order extends Api
      * 订单转让
      * @return void
      */
-    public function transfer(ProductOrder $productOrder, ProductTransfer $productTransfer, UserModel $userModel)
+    public function transfer(ProductOrder $productOrder, ProductTransfer $productTransfer, ProductPopular $productPopular)
     {   
         $params = $this->request->post();
         $validate = \think\Loader::validate('Order');
@@ -137,7 +137,10 @@ class Order extends Api
             $order_info = $productOrder->where('id', $params['order_id'])->where('status', $productOrder::Paid)->find();
             if(empty($order_info)) throw new Exception(__("订单不存在"));
 
-            //转让订单
+            $min_transfer = $productPopular::where('id', $order_info->order_id)->value('min_transfer');
+            if(bccomp($params['price'],$min_transfer, 2) < 0) throw new Exception(__("当前订单最低转让金额为").$min_transfer);
+
+            //转让订单  min_transfer
             $fee = getConfig('transfer_fee');
             $feeAmount = bcmul($params['price'], $fee, 2) ;
             $productTransfer::setTransferOrder($this->auth->id, $order_info['product_id'], $order_info['area_id'], $feeAmount, $params);
@@ -148,7 +151,7 @@ class Order extends Api
             Db::commit();
         } catch (Exception $e) {
             Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
+            $this->error($e->getMessage());
         }
         $this->success('ok');
     }

+ 1 - 0
application/api/controller/Product.php

@@ -27,6 +27,7 @@ class Product extends Api
      */
     public function getPopularList(ProductsModel $productsModel, ProductPopular $productPopular, ProductLists $productLists)
     {
+
         $item = $productsModel->where('status', 1)->column('id,'.$this->lan.'_title as title');
         $resp = array();
         foreach ($item as $kk =>$val) {

+ 1 - 0
application/api/lang/en.php

@@ -26,4 +26,5 @@ return [
     '赠送支出'                               => 'Gift Expenses',
     '赠送收款'                                                                    => 'Gift Receipt',
     '抢购未开始'                                                                  => 'The flash sale has not started yet',
+    '当前订单最低转让金额为'                                                       => 'The current minimum transfer amount for an order is',
 ]; 

+ 1 - 0
application/api/lang/zh-cn.php

@@ -115,5 +115,6 @@ return [
     '社区津贴'                                                                    => '社区津贴',
     '服务津贴'                                                                    => '服务津贴',
     '共创津贴'                                                                    => '共创津贴',
+    '当前订单最低转让金额为'                                                       => '当前订单最低转让金额为',
 
 ];

+ 1 - 1
application/common/model/ProductTransfer.php

@@ -3,7 +3,7 @@
 namespace app\common\model;
 
 use think\Model;
-
+use Exception;
 class ProductTransfer extends Model
 {
 

+ 1 - 6
application/config.php

@@ -318,10 +318,5 @@ return [
     'community_ratio' => 0.035,
     'service_ratio'   => 0.05, //服务津贴
     'together_ratio'  => 0.05, //共创津贴
-    'google' => [
-        'client_id'     => '你的客户端ID',
-        'client_secret' => '你的客户端密钥',
-        'redirect_uri'  => 'http://yourdomain.com/oauth2callback',
-        'developer_key' => '你的开发者密钥(如果有的话)',
-    ],
+    'google_secret'   => 'EHAO77VUMH5XHFR6', //谷歌验证私钥
 ];

+ 18 - 3
public/assets/js/backend/user/user.js

@@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.init({
                 extend: {
                     index_url: 'user/user/index' + location.search,
-                    add_url: 'user/user/add',
-                    edit_url: 'user/user/edit',
+                    //add_url: 'user/user/add',
+                    //edit_url: 'user/user/edit',
                     del_url: 'user/user/del',
                     multi_url: 'user/user/multi',
                     import_url: 'user/user/import',
@@ -46,7 +46,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'effective_time', title: __('Effective_time'), operate: false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'is_login', title: __('登录锁定'), searchList: {"1":__('Yes'),"0":__('No')}, formatter: Table.api.formatter.toggle},
                         {field: 'is_withdraw', title: __('提现锁定'), searchList: {"1":__('Yes'),"0":__('No')}, formatter: Table.api.formatter.toggle},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        //茶宝调整的功能
+                        {
+                            field: 'operate', title: __('Operate'), table: table,
+                            events: Table.api.events.operate,
+                            buttons: [{
+                                name: 'approve',
+                                text: '茶宝调整',
+                                title: '茶宝调整',
+                                classname: 'btn btn-xs btn-info btn-dialog btn-receivable',
+                                icon: 'fa fa-pencil',
+                                url: 'user/user/edit',
+                                extend: 'data-area=\'["50%", "70%"]\'',
+                            },],
+                            formatter: Table.api.formatter.operate
+                        }
                     ]
                 ]
             });