作者 耿培杰

修改接口

@@ -21,7 +21,7 @@ class Student extends Model @@ -21,7 +21,7 @@ class Student extends Model
21 // 定义时间戳字段名 21 // 定义时间戳字段名
22 protected $createTime = 'createtime'; 22 protected $createTime = 'createtime';
23 protected $updateTime = 'updatetime'; 23 protected $updateTime = 'updatetime';
24 - protected $deleteTime = 'deletetime'; 24 + protected $deleteTime = false;
25 25
26 // 追加属性 26 // 追加属性
27 protected $append = [ 27 protected $append = [
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 <!-- </ul>--> 20 <!-- </ul>-->
21 <!-- </div>--> 21 <!-- </div>-->
22 22
23 - <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('student/recyclebin')?'':'hide'}" href="student/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a> 23 + <!--<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('student/recyclebin')?'':'hide'}" href="student/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>-->
24 </div> 24 </div>
25 <table id="table" class="table table-striped table-bordered table-hover table-nowrap" 25 <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
26 data-operate-edit="{:$auth->check('student/edit')}" 26 data-operate-edit="{:$auth->check('student/edit')}"
@@ -13,7 +13,7 @@ function handleOrder($orderInfo) { @@ -13,7 +13,7 @@ function handleOrder($orderInfo) {
13 } 13 }
14 $insertData = [ 14 $insertData = [
15 'user_id' => $orderInfo['other']['user_id'], 15 'user_id' => $orderInfo['other']['user_id'],
16 - 'money' => $orderInfo['other']['money'], 16 + 'money' => $orderInfo['money'],
17 'memo' => '收到打赏', 17 'memo' => '收到打赏',
18 'createtime' => time(), 18 'createtime' => time(),
19 ]; 19 ];
@@ -24,7 +24,7 @@ function handleOrder($orderInfo) { @@ -24,7 +24,7 @@ function handleOrder($orderInfo) {
24 } 24 }
25 25
26 $updateData = [ 26 $updateData = [
27 - 'money' => bcadd($userInfo['money'], $orderInfo['other']['money'], 2) 27 + 'money' => bcadd($userInfo['money'], $orderInfo['money'], 2)
28 ]; 28 ];
29 $res = $user->updateOne($orderInfo['other']['user_id'], $updateData); 29 $res = $user->updateOne($orderInfo['other']['user_id'], $updateData);
30 if(!$res) { 30 if(!$res) {
@@ -32,16 +32,32 @@ function handleOrder($orderInfo) { @@ -32,16 +32,32 @@ function handleOrder($orderInfo) {
32 } 32 }
33 return true; 33 return true;
34 } elseif ($orderInfo['type'] == 2) { // 购买vip 34 } elseif ($orderInfo['type'] == 2) { // 购买vip
  35 +
35 $student = new \app\api\model\Student(); 36 $student = new \app\api\model\Student();
36 $studentInfo = $student->infoByUserIdCanShow($orderInfo['other']['user_id']); 37 $studentInfo = $student->infoByUserIdCanShow($orderInfo['other']['user_id']);
37 if(!$student) { 38 if(!$student) {
38 return false; 39 return false;
39 } 40 }
40 41
  42 + //添加明细
  43 + $insertData = [
  44 + 'user_id' => $orderInfo['other']['user_id'],
  45 + 'money' => $orderInfo['money'],
  46 + 'memo' => '购买VIP',
  47 + 'createtime' => time()
  48 + ];
  49 +
41 if($studentInfo['vip_endtime']) { 50 if($studentInfo['vip_endtime']) {
42 if($studentInfo['vip_level'] == $orderInfo['other']['vip_level']) { 51 if($studentInfo['vip_level'] == $orderInfo['other']['vip_level']) {
43 if($studentInfo['vip_endtime'] >= time()) { 52 if($studentInfo['vip_endtime'] >= time()) {
44 $vipEndTime = bcadd($studentInfo['vip_endtime'], bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), 0); 53 $vipEndTime = bcadd($studentInfo['vip_endtime'], bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), 0);
  54 + //添加明细
  55 + $insertData = [
  56 + 'user_id' => $orderInfo['other']['user_id'],
  57 + 'money' => $orderInfo['money'],
  58 + 'memo' => '续费VIP',
  59 + 'createtime' => time()
  60 + ];
45 } else { 61 } else {
46 $vipEndTime = bcadd(bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), time(), 0); 62 $vipEndTime = bcadd(bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), time(), 0);
47 } 63 }
@@ -51,13 +67,7 @@ function handleOrder($orderInfo) { @@ -51,13 +67,7 @@ function handleOrder($orderInfo) {
51 } else { 67 } else {
52 $vipEndTime = bcadd(bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), time(), 0); 68 $vipEndTime = bcadd(bcmul($orderInfo['other']['keep'], bcmul(3600, 24, 0), 0), time(), 0);
53 } 69 }
54 - //添加明细  
55 - $insertData = [  
56 - 'user_id' => $orderInfo['other']['user_id'],  
57 - 'money' => $orderInfo['other']['money'],  
58 - 'memo' => '购买VIP',  
59 - 'createtime' => time()  
60 - ]; 70 +
61 $userMoneyLog = new \app\api\model\UserMoneyLog(); 71 $userMoneyLog = new \app\api\model\UserMoneyLog();
62 $res1 = $userMoneyLog->addOne($insertData); 72 $res1 = $userMoneyLog->addOne($insertData);
63 73
@@ -66,6 +76,7 @@ function handleOrder($orderInfo) { @@ -66,6 +76,7 @@ function handleOrder($orderInfo) {
66 'vip_endtime' => $vipEndTime, 76 'vip_endtime' => $vipEndTime,
67 ]; 77 ];
68 $res = $student->updateOne($studentInfo['user_id'], $updateData); 78 $res = $student->updateOne($studentInfo['user_id'], $updateData);
  79 +
69 if(!$res) { 80 if(!$res) {
70 return false; 81 return false;
71 } 82 }
@@ -23,21 +23,21 @@ class Student extends Model @@ -23,21 +23,21 @@ class Student extends Model
23 // 获取高中同校的本校学长总数 23 // 获取高中同校的本校学长总数
24 public function countByUniversityIdAndSchoolId($universityId, $schoolId) 24 public function countByUniversityIdAndSchoolId($universityId, $schoolId)
25 { 25 {
26 - return $this->where(['university_id' => ['=', $universityId], 'show_switch' => ['=', 1], 'school_id' => ['=', $schoolId]])->useSoftDelete($this->deleteTime)->count(); 26 + return $this->where(['university_id' => ['=', $universityId], 'show_switch' => ['=', 1], 'school_id' => ['=', $schoolId]])->count();
27 } 27 }
28 28
29 // 获取高中同城/省的本校学长总数 29 // 获取高中同城/省的本校学长总数
30 public function countByUniversityIdAndSchoolIds($universityId, $schoolIds) 30 public function countByUniversityIdAndSchoolIds($universityId, $schoolIds)
31 { 31 {
32 - return $this->where(['university_id' => ['=', $universityId], 'show_switch' => ['=', 1], 'school_id' => ['in', $schoolIds]])->useSoftDelete($this->deleteTime)->count(); 32 + return $this->where(['university_id' => ['=', $universityId], 'show_switch' => ['=', 1], 'school_id' => ['in', $schoolIds]])->count();
33 } 33 }
34 34
35 // 根据用户ID获取一个可以展示的学生的数据 35 // 根据用户ID获取一个可以展示的学生的数据
36 public function infoByUserIdCanShow($userId) 36 public function infoByUserIdCanShow($userId)
37 { 37 {
38 return $this 38 return $this
39 - ->where(['user_id' => ['=', $userId]])  
40 - ->useSoftDelete($this->deleteTime) 39 + ->where(['user_id' => ['eq', $userId]])
  40 +// ->useSoftDelete($this->deleteTime)
41 ->find(); 41 ->find();
42 } 42 }
43 43
@@ -46,7 +46,6 @@ class Student extends Model @@ -46,7 +46,6 @@ class Student extends Model
46 { 46 {
47 return $this 47 return $this
48 ->where($where) 48 ->where($where)
49 - ->useSoftDelete($this->deleteTime)  
50 ->order($this->createTime, 'desc') 49 ->order($this->createTime, 'desc')
51 ->page($page, $size) 50 ->page($page, $size)
52 ->select(); 51 ->select();