浏览代码

兑换记录

moonsflyer 5 月之前
父节点
当前提交
1b55df006a
共有 2 个文件被更改,包括 93 次插入0 次删除
  1. 7 0
      app/shopapi/controller/AccountLogController.php
  2. 86 0
      app/shopapi/lists/GiftCardLists.php

+ 7 - 0
app/shopapi/controller/AccountLogController.php

@@ -16,6 +16,8 @@
 
 namespace app\shopapi\controller;
 
+use app\shopapi\lists\giftCardLists;
+
 /**
  * 账户流水控制器
  * Class AccountLogController
@@ -33,4 +35,9 @@ class AccountLogController extends BaseShopController
     {
         return $this->dataLists();
     }
+
+    public function giftCardlists()
+    {
+        return $this->dataLists(new giftCardLists());
+    }
 }

+ 86 - 0
app/shopapi/lists/GiftCardLists.php

@@ -0,0 +1,86 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\shopapi\lists;
+
+use app\common\model\GiftCardInfo;
+/**
+ * 兑换礼品卡列表
+ * Class AccountLogLists
+ * @package app\shopapi\lists
+ */
+class GiftCardLists extends BaseShopDataLists
+{
+    /**
+     * @notes 设置搜索条件
+     * @author Tab
+     * @date 2021/8/9 17:31
+     */
+    public function setWhere()
+    {
+        // 指定用户
+        $this->searchWhere[] = ['user_id', '=', $this->userId];
+    }
+
+    /**
+     * @notes 账户流水列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author Tab
+     * @date 2021/8/9 17:37
+     */
+    public function lists(): array
+    {
+        // 设置搜索条件
+        $this->setWhere();
+
+        $field = 'user_id,card_pass,card_money,used_time';
+        $lists = GiftCardInfo::field($field)
+            ->where($this->searchWhere)
+            ->order('used_time', 'desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order('used_time', 'desc')
+            ->select()
+            ->toArray();
+
+        foreach($lists as &$item) {
+
+//            $item['used_time'] = $item['action'] == AccountLogEnum::DEC ? '-' . $item['change_amount'] : '+' . $item['change_amount'];
+        }
+
+        return $lists;
+    }
+
+    /**
+     * @notes 账户流水记录数
+     * @return int
+     * @author Tab
+     * @date 2021/8/9 17:36
+     */
+    public function count(): int
+    {
+        // 设置搜索条件
+        $this->setWhere();
+
+        $count = GiftCardInfo::where($this->searchWhere)->count();
+        return $count;
+    }
+}