浏览代码

任务,签到,钱包,充值等修改

lizhen_gitee 1 月之前
父节点
当前提交
cdaf800493

+ 1 - 1
application/api/controller/Notify.php

@@ -99,7 +99,7 @@ class Notify extends Api
         exit;
     }
 
-    //充值金币 逻辑
+    //充值VIP 逻辑
     private function vip_notify_do($out_trade_no)
     {
 

+ 1 - 1
application/api/controller/Pay.php

@@ -216,7 +216,7 @@ class Pay extends Api
         if ($money <= 0) {
             $this->error('支付金额必须大于0');
         }
-        if ($money > 10000) {
+        if ($money > 100000) {
             $this->error('支付金额太大');
         }
 

+ 3 - 10
application/api/controller/Task.php

@@ -38,7 +38,7 @@ class Task extends Api
             $where["is_show"] = 1;
 
             $taskList = Db::name('task')
-                ->field("id,type_id,image,name,exp,number,".$jump_url." as jump_url,url_type")
+                ->field("id,type_id,image,name,title,exp,number,".$jump_url." as jump_url,url_type")
                 ->where($where)
                 ->autopage()
                 ->select();
@@ -83,7 +83,7 @@ class Task extends Api
             $where["a.type_id"] = 1;
             $where["a.is_show"] = 1;
             $taskList = Db::name('task')->alias("a")
-                ->field("a.id,a.type_id,a.image,a.name,a.exp,a.number,a.".$jump_url." as jump_url,a.url_type,l.pace,l.is_reward,l.is_finish,l.finish_number")
+                ->field("a.id,a.type_id,a.image,a.name,a.title,a.exp,a.number,a.".$jump_url." as jump_url,a.url_type,l.pace,l.is_reward,l.is_finish,l.finish_number")
                 ->join("task_log l", "l.task_id = a.id and l.user_id = ".$this->auth->id, "left")
                 ->where($where)
                 ->autopage()
@@ -91,8 +91,6 @@ class Task extends Api
                 ->select();
             $taskList = list_domain_image($taskList,['image']);
 
-            $comment_for_gold_switch = config('site.comment_for_gold_switch');//好评有礼开关
-
             if($taskList) {
                 foreach($taskList as $k => $v) {
                     $v["pace"] || $taskList[$k]["pace"] = 0;
@@ -102,11 +100,6 @@ class Task extends Api
                     if($v["is_finish"] != 1 && $v["pace"] != 0) {
                         $taskList[$k]["pace_txt"] = $v["finish_number"]."/".$v["number"];
                     }
-
-                    //好评有礼开关
-                    if($v['id'] == 17 && $comment_for_gold_switch == 0){
-                        unset($taskList[$k]);
-                    }
                 }
             }
         }
@@ -145,7 +138,7 @@ class Task extends Api
         Db::startTrans();
         try{
             // 增加用户金币
-            $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',$taskInfo["exp"],61,$taskInfo['name'],'task_log',$tasklogInfo['id']);
+            $res1 = model('wallet')->lockChangeAccountRemain($this->auth->id,'bean',$taskInfo["exp"],102,$taskInfo['name'],'task_log',$tasklogInfo['id']);
             if($res1['status'] === false){
                 Db::rollback();
                 $this->error($res1['msg']);

+ 16 - 13
application/api/controller/Userwallet.php

@@ -25,28 +25,29 @@ class Userwallet extends Api
     {
         $tab = $this->request->param('type', 'all');
 
-        $user = auth_user();
 
         $where = [
-            'user_id' => $user->id,
-            'type'    => 'money',
+            'user_id' => $this->auth->id,
         ];
 
         if($tab == 1){
-            $where['amount'] = ['>', 0];
+            $where['change_value'] = ['>', 0];
         }
         if($tab == 2){
-            $where['amount'] = ['<', 0];
+            $where['change_value'] = ['<', 0];
         }
 
-        $logs = UserWalletLogModel::where($where)
-            ->order('id', 'desc')
+        $logs = Db::name('user_money_log')
+            ->field('id,log_type,before,change_value,remain,remark,createtime')
+            ->where($where)
+            ->order('id desc')
             ->autopage()->select();
 
         $this->success(1, $logs);
     }
 
-    /*public function my_money_log(){
+    //善豆明细
+    public function my_bean_log(){
         $type = input('type',0);
 
         $map = [
@@ -56,13 +57,15 @@ class Userwallet extends Api
             $map['log_type'] = $type;
         }
 
-        $list = Db::name('user_money_log')
+        $list = Db::name('user_bean_log')
             ->field('id,log_type,before,change_value,remain,remark,createtime')
-            ->where($map)->order('id desc')->autopage()->select();
-        $list = $this->list_appen_logtext($list);
+            ->where($map)
+            ->order('id desc')
+            ->autopage()->select();
+//        $list = $this->list_appen_logtext($list);
 
-        $this->success('success',$list);
-    }*/
+        $this->success(1,$list);
+    }
 
 
 

+ 17 - 0
application/common/model/Task.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 模型
+ */
+class Task extends Model
+{
+
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+}

+ 81 - 0
application/common/model/TaskLog.php

@@ -0,0 +1,81 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 模型
+ */
+class TaskLog extends Model
+{
+
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+
+    /**
+     * 增加任务完成进度
+     */
+    public static function tofinish($user_id,$task_id,$number = 1) {
+        if(!$user_id || !$task_id || !$number) {
+            return false;
+        }
+        // 查询任务明细
+        $taskModel = new \app\common\model\Task();
+        $tasklogModel = new \app\common\model\TaskLog();
+
+        $where = [];
+        $where["id"] = $task_id;
+        $taskInfo = $taskModel->where($where)->find();
+        if(!$taskInfo) {
+            return false;
+        }
+        if($taskInfo['is_show'] != 1){
+            return true;
+        }
+        // 添加/修改任务日志
+        $where = [];
+        $where["user_id"] = $user_id;
+        $where["task_id"] = $taskInfo["id"];
+
+        if($taskInfo["type_id"] == 2){
+            $where["finish_date"] = date("Ymd");
+        };
+
+        $tasklogInfo = $tasklogModel->where($where)->lock(true)->find();
+        if($tasklogInfo) {
+            if($tasklogInfo["finish_number"] >= $taskInfo["number"] || $tasklogInfo["is_finish"] == 1) {
+                return true;
+            }
+            $finish_number = $tasklogInfo["finish_number"]+$number;
+            $where = [];
+            $where["id"] = $tasklogInfo["id"];
+            $data = [];
+            $data["finish_number"] = $finish_number;
+            $data["pace"] = round($finish_number/$taskInfo["number"],2)*100;
+            $data["finish_date"] = date("Ymd");
+            if($finish_number >= $taskInfo["number"]) {
+                $data["is_finish"] = 1;
+                $data["finish_time"] = time();
+            }
+            $res = $tasklogModel->update($data,$where);
+        } else {
+            $data = [];
+            $data["user_id"] = $user_id;
+            $data["task_id"] = $taskInfo["id"];
+            $data["finish_number"] = $number;
+            $data["pace"] = round($number/$taskInfo["number"],2)*100;
+            $data["finish_date"] = date("Ymd");
+            if($number >= $taskInfo["number"]) {
+                $data["is_finish"] = 1;
+                $data["finish_time"] = time();
+            }
+            $data["createtime"] = time();
+            $res = $tasklogModel->insertGetId($data);
+        }
+        return $res;
+    }
+}

+ 4 - 1
application/common/model/Wallet.php

@@ -13,11 +13,14 @@ class Wallet extends Model
     // 日志变动类型
     const log_type = [
         1  => '系统调节',//money + -
-        10  => '用户充值',//money + -
+        10  => '用户充值',//money +
         20 => '老年大学活动报名',//money + -
+        31 => '商城订单支付', //money -
+        32 => '商城订单退款', //money +
 
         //善豆
         101 => '签到', //bean +
+        102 => '完成任务', //bean +
     ];
     // 操作钱包余额类型
     const money_type = [

+ 1 - 1
application/database.php

@@ -16,7 +16,7 @@ return [
     // 数据库类型
     'type'            => Env::get('database.type', 'mysql'),
     // 服务器地址
-    'hostname'        => Env::get('database.hostname', '106.54.206.212'),
+    'hostname'        => Env::get('database.hostname', '122.51.218.69'),
     // 数据库名
     'database'        => Env::get('database.database', 'xiaoshan'),
     // 用户名