浏览代码

答主收益

lizhen_gitee 3 周之前
父节点
当前提交
36f1077a98
共有 2 个文件被更改,包括 25 次插入1 次删除
  1. 7 0
      app/Http/Controllers/Api/AskController.php
  2. 18 1
      app/Wen/Utils/UserUtils.php

+ 7 - 0
app/Http/Controllers/Api/AskController.php

@@ -153,10 +153,17 @@ class AskController extends BaseController
             return $this->fail(200016,[],'咨询已经结束了');
         }
 
+        //给答主钱
+        $askorder_blogger_balance_rate = Settings::get('askorder_blogger_balance_rate');
+        $blogger_price = bcdiv(bcmul($order['ask_price'],$askorder_blogger_balance_rate)100,2);
+        UserUtils::update_user_financial($order['blogger_user_id'], 103, $order['ask_price'], '咨询收益'.$blogger_price);
+
         //
         $update = [
             'status'      => 20,
             'finish_time' => time(),
+            'blogger_rate' => $askorder_blogger_balance_rate,
+            'blogger_price' => $blogger_price,
         ];
         DB::table('ask_order')->where('id',$order_id)->update($update);
 

+ 18 - 1
app/Wen/Utils/UserUtils.php

@@ -2222,7 +2222,7 @@ class UserUtils{
             }
         }
 
-        if(in_array($type, [0, 1, 3, 4, 5, 6, 12,15, 16, 17, 18, 20, 23, 24, 25, 26, 28, 29, 31, 33, 10002])){
+        if(in_array($type, [0, 1, 3, 4, 5, 6, 12,15, 16, 17, 18, 20, 23, 24, 25, 26, 28, 29, 31, 33, 103, 104, 10002])){
             // 增加余额
             $financial = WxUserFinancial::where('user_id', $user_id)->exists();
             if ($financial) {
@@ -2289,6 +2289,23 @@ class UserUtils{
         return true;
     }
 
+    private function balance_type_data(){
+        //减少
+        $arr1 = [
+            2   => '提现',
+            101 => '付费咨询',
+            102 => '付费旁听',
+        ];
+
+        //增加
+        $arr2 = [
+            103 => '答主收益',
+            104 => '咨询者旁听收益',
+        ];
+    }
+
+
+
     public static function get_user_shop_address($uid){
         if(_empty_($uid)){
             return null;