Browse Source

下订单,解锁用户的微信账号和私密视频

lizhen_gitee 3 years ago
parent
commit
cf24801921
2 changed files with 99 additions and 0 deletions
  1. 96 0
      application/api/controller/Unlockorder.php
  2. 3 0
      application/extra/wallet.php

+ 96 - 0
application/api/controller/Unlockorder.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 解锁微信号和私密视频
+ */
+class Unlockorder extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    //解锁微信订单
+    public function wechataccount(){
+        $to_user_id = input('to_user_id','');
+        if(empty($to_user_id)){
+            $this->error();
+        }
+        $to_user_info = Db::name('user')->find($to_user_id);
+        if(empty($to_user_info)){
+            $this->error('不存在的用户');
+        }
+
+        $price = config('site.unlock_wechataccount');
+        $price = bcadd(intval($price),0,0);
+
+        $data = [
+            'user_id' => $this->auth->id,
+            'to_user_id' => $to_user_id,
+            'createtime' => time(),
+            'endtime' => time() + 604800,
+            'price' => $price,
+        ];
+
+        Db::startTrans();
+        $order_id = Db::name('order_wechataccount')->insertGetId($data);
+        if(!$order_id){
+            Db::rollback();
+            $this->error('解锁失败');
+        }
+
+        if($price > 0){
+            $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',$price,71,'解锁:'.$to_user_id,'order_wechataccount',$order_id);
+            if($wallet_rs['status'] === false){
+                Db::rollback();
+                $this->error($wallet_rs['msg']);
+            }
+        }
+
+        Db::commit();
+        $this->success('解锁成功');
+    }
+
+    //解锁私密视频订单
+    public function secretvideo(){
+        $to_user_id = input('to_user_id','');
+        if(empty($to_user_id)){
+            $this->error();
+        }
+        $to_user_info = Db::name('user')->find($to_user_id);
+        if(empty($to_user_info)){
+            $this->error('不存在的用户');
+        }
+
+        $price = config('site.unlock_secretvideo');
+        $price = bcadd(intval($price),0,0);
+
+        $data = [
+            'user_id' => $this->auth->id,
+            'to_user_id' => $to_user_id,
+            'createtime' => time(),
+            'endtime' => time() + 604800,
+            'price' => $price,
+        ];
+
+        Db::startTrans();
+        $order_id = Db::name('order_secretvideo')->insertGetId($data);
+        if(!$order_id){
+            Db::rollback();
+            $this->error('解锁失败');
+        }
+
+        if($price > 0){
+            $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',$price,71,'解锁:'.$to_user_id,'order_secretvideo',$order_id);
+            if($wallet_rs['status'] === false){
+                Db::rollback();
+                $this->error($wallet_rs['msg']);
+            }
+        }
+
+        Db::commit();
+        $this->success('解锁成功');
+    }
+}

+ 3 - 0
application/extra/wallet.php

@@ -33,6 +33,9 @@ return [
         61 => '完成个人任务',
         62 => '解锁喜欢我的人',
         63 => '邀请注册奖励',//money
+
+        71 => '解锁微信',
+        72 => '解锁视频',
     ],
     'moneyname' => [
         'money'    => '余额',