moonsflyer 6 месяцев назад
Родитель
Сommit
679d5fb8f9

+ 33 - 1
app/adminapi/lists/gift_card/GiftCardInfoLists.php

@@ -22,6 +22,7 @@ namespace app\adminapi\lists\gift_card;
 
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\GiftCardInfo;
+use app\common\service\FileService;
 
 class GiftCardInfoLists extends BaseAdminDataLists
 {
@@ -64,7 +65,7 @@ class GiftCardInfoLists extends BaseAdminDataLists
     public function lists(): array
     {
         $lists = GiftCardInfo::where($this->setSearch())
-            ->with(['user'])
+            ->with(['giftCard','user'])
             ->append(['is_used_desc'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order('id', 'desc')
@@ -88,4 +89,35 @@ class GiftCardInfoLists extends BaseAdminDataLists
     {
         return GiftCardInfo::where($this->setSearch())->count();
     }
+
+    /**
+     * @notes 设置excel表名
+     * @return string
+     * @author cjhao
+     * @date 2021/9/23 9:52
+     */
+    public function setFileName(): string
+    {
+        return '礼品卡列表';
+    }
+
+    /**
+     * @notes 设置导出字段
+     * @return array
+     * @author cjhao
+     * @date 2021/9/23 9:59
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'gc_id'      => '批次',
+            'card_no'    => '礼品卡卡号',
+            'card_pass'  => '礼品卡密码',
+            'card_money' => '礼品卡价值',
+            'is_used'    => '是否使用',
+            'used_id'    => '使用人',
+            'used_time'  => '使用时间',
+            'create_time'=> '创建时间',
+        ];
+    }
 }

+ 4 - 0
app/common/model/GiftCardInfo.php

@@ -23,6 +23,7 @@ use app\common\enum\IntegralGoodsEnum;
 use app\common\enum\IntegralOrderEnum;
 use app\common\enum\PayEnum;
 use app\common\service\RegionService;
+use app\common\model\GiftCard;
 use think\model\concern\SoftDelete;
 
 /**
@@ -51,6 +52,9 @@ class GiftCardInfo extends BaseModel
             ->field('id,sn,nickname,avatar,real_name,mobile,sex,create_time');
     }
 
+    public function giftCard(){
+        return $this->hasOne(GiftCard::class, 'id', 'gc_id');
+    }
     /**
      * @notes 使用状态
      * @param $value