Browse Source

fix:url地址组建

super-yimizi 2 months ago
parent
commit
b2ef4fc88b

+ 395 - 46
application/admin/controller/lottery/Activity.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller\lottery;
 
 use app\common\controller\Backend;
-use app\common\Enum\LotteryEnum;
+use app\common\Enum\ActivityEnum;
 use think\Db;
 use think\exception\ValidateException;
 use think\exception\PDOException;
@@ -29,25 +29,25 @@ class Activity extends Backend
         $this->model = new \app\admin\model\lottery\Activity;
        
         // 获取枚举值列表
-        $this->view->assign("typeList",     LotteryEnum::getActivityTypeMap());
-        $this->assignconfig("typeList", json_encode(LotteryEnum::getActivityTypeMap()));
-        $this->view->assign("statusList", LotteryEnum::getActivityStatusMap());
-        $this->assignconfig("statusList", json_encode(LotteryEnum::getActivityStatusMap()));
-        $this->view->assign("lotteryTypeList", LotteryEnum::getLotteryTypeMap());
-        $this->assignconfig("lotteryTypeList", json_encode(LotteryEnum::getLotteryTypeMap()));
-        $this->view->assign("userLimitTypeList", LotteryEnum::getUserLimitTypeMap());
-        $this->assignconfig("userLimitTypeList", json_encode(LotteryEnum::getUserLimitTypeMap()));
-        $this->view->assign("guideStyleList", LotteryEnum::getGuideStyleMap());
-        $this->assignconfig("guideStyleList", json_encode(LotteryEnum::getGuideStyleMap()));
-        $this->view->assign("conditionTypeList", LotteryEnum::getConditionTypeMap());
-        $this->assignconfig("conditionTypeList", json_encode(LotteryEnum::getConditionTypeMap()));
+        $this->view->assign("typeList",     ActivityEnum::getActivityTypeMap());
+        $this->assignconfig("typeList", json_encode(ActivityEnum::getActivityTypeMap()));
+        $this->view->assign("statusList", ActivityEnum::getActivityStatusMap());
+        $this->assignconfig("statusList", json_encode(ActivityEnum::getActivityStatusMap()));
+        $this->view->assign("lotteryTypeList", ActivityEnum::getLotteryTypeMap());
+        $this->assignconfig("lotteryTypeList", json_encode(ActivityEnum::getLotteryTypeMap()));
+        $this->view->assign("userLimitTypeList", ActivityEnum::getUserLimitTypeMap());
+        $this->assignconfig("userLimitTypeList", json_encode(ActivityEnum::getUserLimitTypeMap()));
+        $this->view->assign("guideStyleList", ActivityEnum::getGuideStyleMap());
+        $this->assignconfig("guideStyleList", json_encode(ActivityEnum::getGuideStyleMap()));
+        $this->view->assign("conditionTypeList", ActivityEnum::getConditionTypeMap());
+        $this->assignconfig("conditionTypeList", json_encode(ActivityEnum::getConditionTypeMap()));
         
         // 奖品类型配置
-        $this->view->assign("prizeTypeList", LotteryEnum::getPrizeTypeMap());
-        $this->assignconfig("prizeTypeList", json_encode(LotteryEnum::getPrizeTypeMap()));
+        $this->view->assign("prizeTypeList", ActivityEnum::getPrizeTypeMap());
+        $this->assignconfig("prizeTypeList", json_encode(ActivityEnum::getPrizeTypeMap()));
         
         // 奖品默认图片配置
-        $this->assignconfig("prizeDefaultImages", json_encode(LotteryEnum::getPrizeDefaultImageMap()));
+        $this->assignconfig("prizeDefaultImages", json_encode(ActivityEnum::getPrizeDefaultImageMap()));
 
         $config = config('site');
         $lottery_guide = $config['lottery_guide'] ?? '';
@@ -102,32 +102,42 @@ class Activity extends Backend
             if ($params) {
                 $params = $this->preExcludeFields($params);
                 
-                // 处理时间字段
-                if (isset($params['start_time']) && $params['start_time']) {
-                    $params['start_time'] = strtotime($params['start_time']);
-                }
-                if (isset($params['end_time']) && $params['end_time']) {
-                    $params['end_time'] = strtotime($params['end_time']);
-                }
-                if (isset($params['lottery_time']) && $params['lottery_time']) {
-                    $params['lottery_time'] = strtotime($params['lottery_time']);
-                }
+                // 获取奖品和条件数据
+                $prizesData = $this->request->post("prizes/a", []);
+                $conditionData = $this->request->post("condition/a", []);
+                $taskTypes = isset($params['task_type']) ? $params['task_type'] : [];
                 
-                // 处理JSON字段
-                if (isset($params['user_limit_value']) && $params['user_limit_value']) {
-                    $params['user_limit_value'] = json_encode($params['user_limit_value']);
-                }
+                // 处理活动基础数据
+                $activityData = $this->processActivityData($params);
+                
+                // 验证奖品数据
+                $this->validatePrizesData($prizesData);
+                
+                // 验证条件数据
+                $this->validateConditionData($conditionData, $taskTypes);
 
                 $result = false;
                 Db::startTrans();
                 try {
+                    // 保存活动主表数据
                     //是否采用模型验证
                     if ($this->modelValidate) {
                         $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                         $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
                         $this->model->validateFailException(true)->validate($validate);
                     }
-                    $result = $this->model->allowField(true)->save($params);
+                    $result = $this->model->allowField(true)->save($activityData);
+                    
+                    if ($result) {
+                        $activityId = $this->model->id;
+                        
+                        // 保存奖品数据
+                        $this->savePrizesData($activityId, $prizesData);
+                        
+                        // 保存参与条件数据
+                        $this->saveConditionData($activityId, $conditionData, $taskTypes);
+                    }
+                    
                     Db::commit();
                 } catch (ValidateException $e) {
                     Db::rollback();
@@ -149,6 +159,259 @@ class Activity extends Backend
         }
         return $this->view->fetch();
     }
+    
+    /**
+     * 处理活动基础数据
+     */
+    private function processActivityData($params)
+    {
+        // 处理时间字段
+        if (isset($params['start_time']) && $params['start_time']) {
+            $params['start_time'] = strtotime($params['start_time']);
+        }
+        if (isset($params['end_time']) && $params['end_time']) {
+            $params['end_time'] = strtotime($params['end_time']);
+        }
+        if (isset($params['lottery_time']) && $params['lottery_time']) {
+            $params['lottery_time'] = strtotime($params['lottery_time']);
+        }
+        
+        // 处理JSON字段
+        if (isset($params['user_limit_value']) && $params['user_limit_value']) {
+            $params['user_limit_value'] = json_encode($params['user_limit_value']);
+        }
+        
+        // 处理渠道字段(如果存在的话)
+        if (isset($params['channels']) && is_array($params['channels'])) {
+            $params['channels'] = json_encode($params['channels']);
+        }
+        
+        // 处理兑奖期限设置
+        if (isset($params['redeem_expire_type'])) {
+            $params['redeem_expire_type'] = intval($params['redeem_expire_type']);
+            if ($params['redeem_expire_type'] == ActivityEnum::REDEEM_EXPIRE_FIXED) {
+                $params['redeem_expire_days'] = isset($params['redeem_expire_days']) ? intval($params['redeem_expire_days']) : 7;
+            } else {
+                $params['redeem_expire_days'] = null;
+            }
+        }
+        
+        // 字段名映射 - 将前端字段名映射到实际数据表字段名
+        if (isset($params['title'])) {
+            $params['name'] = $params['title']; // 活动标题映射到name字段
+            unset($params['title']);
+        }
+        
+        if (isset($params['lottery_people'])) {
+            $params['lottery_people_num'] = $params['lottery_people']; // 开奖人数字段名映射
+            unset($params['lottery_people']);
+        }
+        
+        if (isset($params['per_person_limit'])) {
+            $params['person_limit_num'] = $params['per_person_limit']; // 单人限制次数字段名映射
+            unset($params['per_person_limit']);
+        }
+        
+        // 移除不属于活动表的字段
+        unset($params['task_type']);
+        
+        // 设置默认值
+        $params['type'] = ActivityEnum::ACTIVITY_TYPE_CONSUMPTION_LOTTERY; // 消费抽奖
+        
+        // 初始化统计字段
+        if (!isset($params['total_draw_count'])) {
+            $params['total_draw_count'] = 0;
+        }
+        if (!isset($params['total_people_count'])) {
+            $params['total_people_count'] = 0;
+        }
+        if (!isset($params['total_win_count'])) {
+            $params['total_win_count'] = 0;
+        }
+        
+        return $params;
+    }
+    
+    /**
+     * 验证奖品数据
+     */
+    private function validatePrizesData($prizesData)
+    {
+        if (empty($prizesData) || count($prizesData) < 8) {
+            throw new Exception('奖品数量不足,必须配置8个奖品(包含未中奖项)');
+        }
+        
+        $totalRate = 0;
+        foreach ($prizesData as $prize) {
+            if (!isset($prize['name']) || !isset($prize['type']) || !isset($prize['rate'])) {
+                throw new Exception('奖品配置不完整');
+            }
+            
+            $totalRate += floatval($prize['rate']);
+            
+            // 验证特定类型奖品的必需字段
+            switch (intval($prize['type'])) {
+                case 5: // 优惠券
+                    if (empty($prize['coupon_id'])) {
+                        throw new Exception('优惠券奖品必须选择优惠券');
+                    }
+                    break;
+                case 8: // 商城奖品
+                    if (empty($prize['goods_id'])) {
+                        throw new Exception('商城奖品必须选择商品');
+                    }
+                    break;
+            }
+        }
+        
+        if (abs($totalRate - 100) > 0.01) {
+            throw new Exception('奖品总概率必须等于100%,当前为' . $totalRate . '%');
+        }
+    }
+    
+    /**
+     * 验证条件数据
+     */
+    private function validateConditionData($conditionData, $taskTypes)
+    {
+        if (empty($taskTypes)) {
+            throw new Exception('请至少选择一种任务类型');
+        }
+        
+        foreach ($taskTypes as $taskType) {
+            $type = intval($taskType);
+            
+            switch ($type) {
+                case 1: // 购买指定商品
+                    if (!isset($conditionData[$type]) || empty($conditionData[$type]['goods_ids'])) {
+                        throw new Exception('购买指定商品任务必须選擇商品');
+                    }
+                    break;
+                case 2: // 单笔订单消费满额
+                case 3: // 单次充值满额
+                case 4: // 活动期间累计消费满额
+                    if (!isset($conditionData[$type]) || empty($conditionData[$type]['condition_value'])) {
+                        throw new Exception('消费/充值任务必须设置金额');
+                    }
+                    if (floatval($conditionData[$type]['condition_value']) <= 0) {
+                        throw new Exception('消费/充值任务金额必须大于0');
+                    }
+                    break;
+            }
+        }
+    }
+    
+    /**
+     * 保存奖品数据
+     */
+    private function savePrizesData($activityId, $prizesData)
+    {
+        $prizeModel = new \app\admin\model\lottery\Prize;
+        
+        foreach ($prizesData as $index => $prize) {
+            $prizeData = [
+                'activity_id' => $activityId,
+                'name' => $prize['name'],
+                'type' => intval($prize['type']),
+                'image' => isset($prize['image']) ? $prize['image'] : '',
+                'probability' => floatval($prize['rate']),
+                'total_stock' => isset($prize['quantity']) ? intval($prize['quantity']) : 0,
+                'remain_stock' => isset($prize['quantity']) ? intval($prize['quantity']) : 0,
+                'sort_order' => $index,
+                'status' => 1,
+                'createtime' => time()
+            ];
+            
+                         // 根据奖品类型设置特定字段
+            switch (intval($prize['type'])) {
+                case ActivityEnum::PRIZE_TYPE_POINTS: // 积分 - 使用amount字段存储积分数量
+                    $prizeData['amount'] = isset($prize['points']) ? intval($prize['points']) : 0;
+                    $prizeData['description'] = '积分奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_BALANCE: // 余额 - 使用amount字段存储余额金额
+                    $prizeData['amount'] = isset($prize['balance']) ? floatval($prize['balance']) : 0;
+                    $prizeData['description'] = '余额奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_COUPON: // 优惠券
+                    $prizeData['coupon_id'] = isset($prize['coupon_id']) ? intval($prize['coupon_id']) : 0;
+                    $prizeData['description'] = '优惠券奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_REDPACK: // 红包 - 使用amount字段存储红包金额
+                    $prizeData['amount'] = isset($prize['redpack_amount']) ? floatval($prize['redpack_amount']) : 0;
+                    $prizeData['description'] = '红包奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_CODE: // 兑换码
+                    if (isset($prize['manual_codes']) && !empty($prize['manual_codes'])) {
+                        $codes = array_filter(array_map('trim', explode("\n", $prize['manual_codes'])));
+                        $prizeData['exchange_codes'] = json_encode($codes);
+                        $prizeData['used_codes'] = json_encode([]); // 初始化已使用列表
+                        $prizeData['total_stock'] = count($codes);
+                        $prizeData['remain_stock'] = count($codes);
+                    }
+                    $prizeData['description'] = '兑换码奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_SHOP_GOODS: // 商城奖品
+                    $prizeData['goods_id'] = isset($prize['goods_id']) ? intval($prize['goods_id']) : 0;
+                    $prizeData['goods_sku_id'] = isset($prize['goods_sku_id']) ? intval($prize['goods_sku_id']) : null;
+                    $prizeData['description'] = '商城奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_GOODS: // 实物奖品
+                    $prizeData['description'] = isset($prize['description']) ? $prize['description'] : '实物奖品';
+                    break;
+                case ActivityEnum::PRIZE_TYPE_NO_PRIZE: // 未中奖
+                default:
+                    $prizeData['description'] = '未中奖';
+                    break;
+            }
+            
+            $prizeModel->create($prizeData);
+        }
+    }
+    
+    /**
+     * 保存参与条件数据
+     */
+    private function saveConditionData($activityId, $conditionData, $taskTypes)
+    {
+        $conditionModel = new \app\admin\model\lottery\Condition;
+        
+        foreach ($taskTypes as $taskType) {
+            $type = intval($taskType);
+            $condition = isset($conditionData[$type]) ? $conditionData[$type] : [];
+            
+            $conditionRecord = [
+                'activity_id' => $activityId,
+                'type' => $type,
+                'reward_times' => 1,
+                'is_repeatable' => 0,
+                'status' => $conditionModel::STATUS_ENABLED,
+                'createtime' => time()
+            ];
+            
+            switch ($type) {
+                case ActivityEnum::CONDITION_TYPE_BUY_GOODS: // 购买指定商品
+                    $goodsIds = isset($condition['goods_ids']) ? $condition['goods_ids'] : '[]';
+                    if (is_string($goodsIds)) {
+                        $goodsIds = json_decode($goodsIds, true) ?: [];
+                    }
+                    $conditionRecord['goods_ids'] = json_encode($goodsIds);
+                    $conditionRecord['goods_rule'] = isset($condition['goods_rule']) ? intval($condition['goods_rule']) : $conditionModel::GOODS_RULE_INCLUDE;
+                    break;
+                case ActivityEnum::CONDITION_TYPE_ORDER_AMOUNT: // 单笔订单消费满额
+                case ActivityEnum::CONDITION_TYPE_RECHARGE_AMOUNT: // 单次充值满额
+                case ActivityEnum::CONDITION_TYPE_TOTAL_AMOUNT: // 活动期间累计消费满额
+                    $conditionRecord['condition_value'] = isset($condition['condition_value']) ? floatval($condition['condition_value']) : 0;
+                    if ($type == ActivityEnum::CONDITION_TYPE_TOTAL_AMOUNT) {
+                        $conditionRecord['is_repeatable'] = 0; // 累计消费不可重复
+                    } else {
+                        $conditionRecord['is_repeatable'] = 1; // 其他类型可重复
+                    }
+                    break;
+            }
+            
+            $conditionModel->create($conditionRecord);
+        }
+    }
 
     /**
      * 编辑
@@ -170,32 +433,48 @@ class Activity extends Backend
             if ($params) {
                 $params = $this->preExcludeFields($params);
                 
-                // 处理时间字段
-                if (isset($params['start_time']) && $params['start_time']) {
-                    $params['start_time'] = strtotime($params['start_time']);
-                }
-                if (isset($params['end_time']) && $params['end_time']) {
-                    $params['end_time'] = strtotime($params['end_time']);
-                }
-                if (isset($params['lottery_time']) && $params['lottery_time']) {
-                    $params['lottery_time'] = strtotime($params['lottery_time']);
-                }
+                // 获取奖品和条件数据
+                $prizesData = $this->request->post("prizes/a", []);
+                $conditionData = $this->request->post("condition/a", []);
+                $taskTypes = isset($params['task_type']) ? $params['task_type'] : [];
                 
-                // 处理JSON字段
-                if (isset($params['user_limit_value']) && $params['user_limit_value']) {
-                    $params['user_limit_value'] = json_encode($params['user_limit_value']);
-                }
+                // 处理活动基础数据
+                $activityData = $this->processActivityData($params);
+                
+                // 验证奖品数据
+                $this->validatePrizesData($prizesData);
+                
+                // 验证条件数据
+                $this->validateConditionData($conditionData, $taskTypes);
 
                 $result = false;
                 Db::startTrans();
                 try {
+                    // 更新活动主表数据
                     //是否采用模型验证
                     if ($this->modelValidate) {
                         $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                         $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                         $row->validateFailException(true)->validate($validate);
                     }
-                    $result = $row->allowField(true)->save($params);
+                    $result = $row->allowField(true)->save($activityData);
+                    
+                    if ($result !== false) {
+                        $activityId = $ids;
+                        
+                        // 删除原有奖品数据
+                        Db::name('shop_lottery_prize')->where('activity_id', $activityId)->delete();
+                        
+                        // 删除原有条件数据
+                        Db::name('shop_lottery_condition')->where('activity_id', $activityId)->delete();
+                        
+                        // 保存新的奖品数据
+                        $this->savePrizesData($activityId, $prizesData);
+                        
+                        // 保存新的参与条件数据
+                        $this->saveConditionData($activityId, $conditionData, $taskTypes);
+                    }
+                    
                     Db::commit();
                 } catch (ValidateException $e) {
                     Db::rollback();
@@ -232,7 +511,77 @@ class Activity extends Backend
             $row->user_limit_value = json_decode($row->user_limit_value, true);
         }
         
+        // 处理渠道字段
+        if ($row->channels) {
+            $row->channels = json_decode($row->channels, true);
+        }
+        
+        // 字段名映射 - 将数据表字段名映射回前端字段名
+        if (isset($row->name)) {
+            $row->title = $row->name; // 将name映射回title供前端使用
+        }
+        if (isset($row->lottery_people_num)) {
+            $row->lottery_people = $row->lottery_people_num; // 映射回前端字段名
+        }
+        if (isset($row->person_limit_num)) {
+            $row->per_person_limit = $row->person_limit_num; // 映射回前端字段名
+        }
+        
+        // 获取奖品数据
+        $prizes = Db::name('shop_lottery_prize')
+            ->where('activity_id', $ids)
+            ->order('sort_order', 'asc')
+            ->select();
+        
+        // 处理奖品数据的字段映射
+        foreach ($prizes as &$prize) {
+            // 将数据表字段映射回前端字段
+            $prize['quantity'] = $prize['total_stock']; // 前端使用quantity字段
+            $prize['rate'] = $prize['probability']; // 前端使用rate字段
+            
+            // 根据奖品类型设置特定字段
+            switch (intval($prize['type'])) {
+                case ActivityEnum::PRIZE_TYPE_POINTS:
+                    $prize['points'] = $prize['amount'] ?? 0;
+                    break;
+                case ActivityEnum::PRIZE_TYPE_BALANCE:
+                    $prize['balance'] = $prize['amount'] ?? 0;
+                    break;
+                case ActivityEnum::PRIZE_TYPE_REDPACK:
+                    $prize['redpack_amount'] = $prize['amount'] ?? 0;
+                    break;
+                case ActivityEnum::PRIZE_TYPE_CODE:
+                    if (!empty($prize['exchange_codes'])) {
+                        $codes = json_decode($prize['exchange_codes'], true) ?: [];
+                        $prize['manual_codes'] = implode("\n", $codes);
+                    }
+                    break;
+            }
+        }
+        
+        // 获取条件数据
+        $conditions = Db::name('shop_lottery_condition')
+            ->where('activity_id', $ids)
+            ->select();
+        
+        // 处理条件数据的字段映射
+        $taskTypes = [];
+        $conditionsData = [];
+        foreach ($conditions as $condition) {
+            $taskTypes[] = $condition['type'];
+            $conditionsData[$condition['type']] = $condition;
+            
+            // 处理商品IDs JSON
+            if (!empty($condition['goods_ids'])) {
+                $conditionsData[$condition['type']]['goods_ids_array'] = json_decode($condition['goods_ids'], true) ?: [];
+            }
+        }
+        
         $this->view->assign("row", $row);
+        $this->view->assign("prizes", $prizes);
+        $this->view->assign("conditions", $conditions);
+        $this->view->assign("conditionsData", $conditionsData);
+        $this->view->assign("taskTypes", $taskTypes);
         return $this->view->fetch();
     }
 

+ 35 - 0
application/admin/controller/shop/Goods.php

@@ -710,6 +710,41 @@ class Goods extends Backend
     }
 
     /**
+     * 获取单个商品信息
+     */
+    public function info()
+    {
+        $id = $this->request->request('id');
+        if (!$id) {
+            $this->error('商品ID不能为空');
+        }
+        
+        $goods = $this->model
+            ->with(['Brand'])
+            ->where('id', $id)
+            ->find();
+            
+        if (!$goods) {
+            $this->error('商品不存在');
+        }
+        
+        // 处理图片URL和SKU信息
+        if ($goods['image']) {
+            $goods['image'] = cdnurl($goods['image'], true);
+        }
+        
+        // 获取商品的第一个SKU ID(单规格商品通常只有一个SKU)
+        $sku = \app\common\model\Sku::where('goods_id', $goods['id'])->find();
+        $goods['sku_id'] = $sku ? $sku['id'] : 0;
+        
+        // 添加商品类型文本
+        $goodsTypeMap = GoodsEnum::getGoodsTypeMap();
+        $goods['type_text'] = isset($goodsTypeMap[$goods['type']]) ? $goodsTypeMap[$goods['type']] : '';
+        
+        $this->success('获取成功', null, $goods);
+    }
+
+    /**
      * 根据ID批量获取商品信息
      */
     public function get_goods_by_ids()

+ 33 - 0
application/admin/lang/zh-cn/inspection/application.php

@@ -0,0 +1,33 @@
+<?php
+
+return [
+    'Id'                    => '申请ID',
+    'User_id'               => '用户ID',
+    'Name'                  => '姓名',
+    'Phone'                 => '联系电话',
+    'Province_adcode'       => '省份编码',
+    'City_adcode'           => '城市编码',
+    'District_adcode'       => '区县编码',
+    'Address'               => '详细地址',
+    'Id_card_front'         => '身份证正面',
+    'Id_card_back'          => '身份证反面',
+    'Apply_time'            => '申请时间',
+    'Audit_time'            => '审核时间',
+    'Audit_status'          => '审核状态',
+    'Reject_reason'         => '驳回原因',
+    'Createtime'            => '创建时间',
+    'Updatetime'            => '更新时间',
+    'Deletetime'            => '删除时间',
+    'Audit_status_text'     => '审核状态',
+    'Apply_time_text'       => '申请时间',
+    'Audit_time_text'       => '审核时间',
+    'Province_name'         => '省份',
+    'City_name'             => '城市',
+    'District_name'         => '区县',
+    'Status 1'              => '审核中',
+    'Status 2'              => '审核通过',
+    'Status 3'              => '审核驳回',
+    'Audit status 1'        => '审核中',
+    'Audit status 2'        => '审核通过',
+    'Audit status 3'        => '审核驳回',
+];

+ 22 - 8
application/admin/model/lottery/Condition.php

@@ -27,16 +27,30 @@ class Condition extends Model
         'status_text'
     ];
 
+    // 条件类型常量
+    const TYPE_BUY_GOODS = 1;        // 购买指定商品
+    const TYPE_ORDER_AMOUNT = 2;     // 单笔订单消费满额
+    const TYPE_RECHARGE_AMOUNT = 3;  // 单次充值满额
+    const TYPE_TOTAL_AMOUNT = 4;     // 活动期间累计消费满额
+
+    // 商品规则常量
+    const GOODS_RULE_INCLUDE = 1;    // 指定商品参与
+    const GOODS_RULE_EXCLUDE = 2;    // 指定商品不可参与
+
+    // 状态常量
+    const STATUS_DISABLED = 0;       // 禁用
+    const STATUS_ENABLED = 1;        // 启用
+
     /**
      * 条件类型列表
      */
     public function getTypeList()
     {
         return [
-            '1' => __('购买指定商品'),
-            '2' => __('单笔订单消费满额'),
-            '3' => __('单次充值满额'),
-            '4' => __('活动期间累计消费满额')
+            self::TYPE_BUY_GOODS => __('购买指定商品'),
+            self::TYPE_ORDER_AMOUNT => __('单笔订单消费满额'),
+            self::TYPE_RECHARGE_AMOUNT => __('单次充值满额'),
+            self::TYPE_TOTAL_AMOUNT => __('活动期间累计消费满额')
         ];
     }
 
@@ -46,8 +60,8 @@ class Condition extends Model
     public function getGoodsRuleList()
     {
         return [
-            '1' => __('指定商品参与'),
-            '2' => __('指定商品不可参与')
+            self::GOODS_RULE_INCLUDE => __('指定商品参与'),
+            self::GOODS_RULE_EXCLUDE => __('指定商品不可参与')
         ];
     }
 
@@ -57,8 +71,8 @@ class Condition extends Model
     public function getStatusList()
     {
         return [
-            '0' => __('禁用'),
-            '1' => __('启用')
+            self::STATUS_DISABLED => __('禁用'),
+            self::STATUS_ENABLED => __('启用')
         ];
     }
 

+ 130 - 0
application/admin/model/lottery/Prize.php

@@ -0,0 +1,130 @@
+<?php
+
+namespace app\admin\model\lottery;
+
+use think\Model;
+
+/**
+ * 抽奖奖品模型
+ */
+class Prize extends Model
+{
+    // 表名
+    protected $name = 'shop_lottery_prize';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = 'deletetime';
+
+    // 软删除
+    use \traits\model\SoftDelete;
+
+    // 追加属性
+    protected $append = [
+        'type_text',
+        'status_text'
+    ];
+    
+    // 奖品类型常量 - 与ActivityEnum保持一致
+    const TYPE_NO_PRIZE = 1;     // 未中奖
+    const TYPE_GOODS = 2;        // 实物奖品
+    const TYPE_POINTS = 3;       // 积分
+    const TYPE_BALANCE = 4;      // 余额
+    const TYPE_COUPON = 5;       // 优惠券
+    const TYPE_REDPACK = 6;      // 红包
+    const TYPE_CODE = 7;         // 兑换码
+    const TYPE_SHOP_GOODS = 8;   // 商城奖品
+
+    // 状态
+    const STATUS_DISABLED = 0;   // 禁用
+    const STATUS_ENABLED = 1;    // 启用
+
+    // 发放方式
+    const DELIVER_TYPE_AUTO = 1;   // 自动发放
+    const DELIVER_TYPE_MANUAL = 2; // 手动发放
+
+    /**
+     * 获取奖品类型列表
+     */
+    public static function getTypeList()
+    {
+        return [
+            self::TYPE_NO_PRIZE => '未中奖',
+            self::TYPE_GOODS => '实物奖品',
+            self::TYPE_POINTS => '积分',
+            self::TYPE_BALANCE => '余额',
+            self::TYPE_COUPON => '优惠券',
+            self::TYPE_REDPACK => '红包',
+            self::TYPE_CODE => '兑换码',
+            self::TYPE_SHOP_GOODS => '商城奖品'
+        ];
+    }
+
+    /**
+     * 获取发放方式列表
+     */
+    public static function getDeliverTypeList()
+    {
+        return [
+            self::DELIVER_TYPE_AUTO => '自动发放',
+            self::DELIVER_TYPE_MANUAL => '手动发放'
+        ];
+    }
+
+    /**
+     * 获取状态列表
+     */
+    public static function getStatusList()
+    {
+        return [
+            self::STATUS_DISABLED => '禁用',
+            self::STATUS_ENABLED => '启用'
+        ];
+    }
+
+    /**
+     * 获取类型文本
+     */
+    public function getTypeTextAttr($value, $data)
+    {
+        $typeList = self::getTypeList();
+        return isset($typeList[$data['type']]) ? $typeList[$data['type']] : '';
+    }
+
+    /**
+     * 获取状态文本
+     */
+    public function getStatusTextAttr($value, $data)
+    {
+        $statusList = self::getStatusList();
+        return isset($statusList[$data['status']]) ? $statusList[$data['status']] : '';
+    }
+
+    /**
+     * 关联活动
+     */
+    public function activity()
+    {
+        return $this->belongsTo('app\\admin\\model\\lottery\\Activity', 'activity_id', 'id');
+    }
+
+    /**
+     * 关联商品
+     */
+    public function goods()
+    {
+        return $this->belongsTo('app\\admin\\model\\shop\\Goods', 'goods_id', 'id');
+    }
+
+    /**
+     * 关联优惠券
+     */
+    public function coupon()
+    {
+        return $this->belongsTo('app\\admin\\model\\shop\\Coupon', 'coupon_id', 'id');
+    }
+}

+ 116 - 0
application/admin/view/inspection/application/audit.html

@@ -0,0 +1,116 @@
+<form id="audit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="panel panel-default">
+        <div class="panel-heading">
+            <h4 class="panel-title">申请信息</h4>
+        </div>
+        <div class="panel-body">
+            <div class="row">
+                <div class="col-md-6">
+                    <table class="table table-striped table-condensed">
+                        <tbody>
+                            <tr>
+                                <td width="30%">姓名:</td>
+                                <td>{$row.name}</td>
+                            </tr>
+                            <tr>
+                                <td>联系电话:</td>
+                                <td>{$row.phone}</td>
+                            </tr>
+                            <tr>
+                                <td>地区:</td>
+                                <td>{$row.province_name} {$row.city_name} {$row.district_name}</td>
+                            </tr>
+                            <tr>
+                                <td>详细地址:</td>
+                                <td>{$row.address}</td>
+                            </tr>
+                            <tr>
+                                <td>申请时间:</td>
+                                <td>{$row.apply_time_text}</td>
+                            </tr>
+                            <tr>
+                                <td>当前状态:</td>
+                                <td><span class="label label-warning">{$row.audit_status_text}</span></td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+                <div class="col-md-6">
+                    <div class="form-group">
+                        <label>身份证正面:</label>
+                        <div class="thumbnail" style="max-width: 250px;">
+                            <img src="{$row.id_card_front}" alt="身份证正面" class="img-responsive" onclick="Fast.api.open(this.src, '身份证正面')">
+                        </div>
+                    </div>
+                    
+                    <div class="form-group">
+                        <label>身份证反面:</label>
+                        <div class="thumbnail" style="max-width: 250px;">
+                            <img src="{$row.id_card_back}" alt="身份证反面" class="img-responsive" onclick="Fast.api.open(this.src, '身份证反面')">
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="panel panel-default">
+        <div class="panel-heading">
+            <h4 class="panel-title">审核操作</h4>
+        </div>
+        <div class="panel-body">
+            <div class="form-group">
+                <label class="control-label col-xs-12 col-sm-2">审核结果:</label>
+                <div class="col-xs-12 col-sm-8">
+                    <div class="radio">
+                        <label for="audit_status-2">
+                            <input id="audit_status-2" name="audit_status" type="radio" value="2" checked /> 
+                            <span class="text-success">审核通过</span>
+                        </label>
+                    </div>
+                    <div class="radio">
+                        <label for="audit_status-3">
+                            <input id="audit_status-3" name="audit_status" type="radio" value="3" /> 
+                            <span class="text-danger">审核驳回</span>
+                        </label>
+                    </div>
+                </div>
+            </div>
+            
+            <div class="form-group" id="reject-reason-group" style="display: none;">
+                <label class="control-label col-xs-12 col-sm-2">驳回原因:</label>
+                <div class="col-xs-12 col-sm-8">
+                    <textarea id="reject_reason" class="form-control" name="reject_reason" rows="4" placeholder="请输入驳回原因..."></textarea>
+                    <div class="help-block">驳回时必须填写驳回原因</div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">
+                <i class="fa fa-check"></i> 提交审核
+            </button>
+            <button type="button" class="btn btn-default" onclick="Layer.closeAll();">取消</button>
+        </div>
+    </div>
+</form>
+
+<script>
+$(function() {
+    // 监听审核状态变化
+    $('input[name="audit_status"]').change(function() {
+        var status = $(this).val();
+        if (status == '3') {
+            $('#reject-reason-group').show();
+            $('#reject_reason').attr('data-rule', 'required');
+        } else {
+            $('#reject-reason-group').hide();
+            $('#reject_reason').removeAttr('data-rule').val('');
+        }
+    });
+});
+</script>

+ 99 - 0
application/admin/view/inspection/application/detail.html

@@ -0,0 +1,99 @@
+<div class="panel panel-default panel-intro">
+    <div class="panel-heading">
+        <div class="panel-lead"><em>验货员申请详情</em></div>
+    </div>
+    
+    <div class="panel-body">
+        <div class="row">
+            <div class="col-md-6">
+                <table class="table table-striped">
+                    <tbody>
+                        <tr>
+                            <td width="30%">申请ID</td>
+                            <td>{$row.id}</td>
+                        </tr>
+                        <tr>
+                            <td>姓名</td>
+                            <td>{$row.name}</td>
+                        </tr>
+                        <tr>
+                            <td>联系电话</td>
+                            <td>{$row.phone}</td>
+                        </tr>
+                        <tr>
+                            <td>省份</td>
+                            <td>{$row.province_name}</td>
+                        </tr>
+                        <tr>
+                            <td>城市</td>
+                            <td>{$row.city_name}</td>
+                        </tr>
+                        <tr>
+                            <td>区县</td>
+                            <td>{$row.district_name}</td>
+                        </tr>
+                        <tr>
+                            <td>详细地址</td>
+                            <td>{$row.address}</td>
+                        </tr>
+                        <tr>
+                            <td>申请时间</td>
+                            <td>{$row.apply_time_text}</td>
+                        </tr>
+                        <tr>
+                            <td>审核状态</td>
+                            <td>
+                                {if condition="$row.audit_status eq 1"}
+                                <span class="label label-warning">{$row.audit_status_text}</span>
+                                {elseif condition="$row.audit_status eq 2"}
+                                <span class="label label-success">{$row.audit_status_text}</span>
+                                {else}
+                                <span class="label label-danger">{$row.audit_status_text}</span>
+                                {/if}
+                            </td>
+                        </tr>
+                        {if condition="$row.audit_time > 0"}
+                        <tr>
+                            <td>审核时间</td>
+                            <td>{$row.audit_time_text}</td>
+                        </tr>
+                        {/if}
+                        {if condition="$row.reject_reason"}
+                        <tr>
+                            <td>驳回原因</td>
+                            <td class="text-danger">{$row.reject_reason}</td>
+                        </tr>
+                        {/if}
+                    </tbody>
+                </table>
+            </div>
+            
+            <div class="col-md-6">
+                <div class="form-group">
+                    <label>身份证正面:</label>
+                    <div class="thumbnail" style="max-width: 300px;">
+                        <img src="{$row.id_card_front}" alt="身份证正面" class="img-responsive" onclick="Fast.api.open(this.src, '身份证正面')">
+                    </div>
+                </div>
+                
+                <div class="form-group">
+                    <label>身份证反面:</label>
+                    <div class="thumbnail" style="max-width: 300px;">
+                        <img src="{$row.id_card_back}" alt="身份证反面" class="img-responsive" onclick="Fast.api.open(this.src, '身份证反面')">
+                    </div>
+                </div>
+            </div>
+        </div>
+        
+        <!-- <div class="form-group layer-footer">
+            <div class="col-xs-12">
+                {if condition="$row.audit_status eq 1"}
+                <a href="javascript:;" class="btn btn-success" onclick="Fast.api.open('inspection/application/audit/ids/{$row.id}', '审核申请', {area: ['800px', '500px']})">
+                    <i class="fa fa-check"></i> 立即审核
+                </a>
+                {/if}
+                <button type="button" class="btn btn-default" onclick="Layer.closeAll();">关闭</button>
+            </div>
+        </div> -->
+    </div>
+</div>

+ 41 - 0
application/admin/view/inspection/application/index.html

@@ -0,0 +1,41 @@
+<div class="panel panel-default panel-intro">
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="audit_status">
+            <li class="{:$Think.get.audit_status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="auditStatusList" item="vo"}
+            <li class="{:$Think.get.audit_status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <!-- <a href="javascript:;" class="btn btn-info btn-detail btn-disabled disabled {:$auth->check('inspection/application/detail')?'':'hide'}" title="查看详情" ><i class="fa fa-eye"></i> 查看详情</a>
+                        <a href="javascript:;" class="btn btn-warning btn-audit btn-disabled disabled {:$auth->check('inspection/application/audit')?'':'hide'}" title="审核" ><i class="fa fa-check"></i> 审核</a> -->
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('inspection/application/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        
+                        <div class="dropdown btn-group">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> 批量操作</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-batch-pass btn-disabled disabled {:$auth->check('inspection/application/batchPass')?'':'hide'}" href="javascript:;" data-url="inspection/application/batchPass"><i class="fa fa-check text-success"></i> 批量通过</a></li>
+                                <li><a class="btn btn-link btn-batch-reject btn-disabled disabled {:$auth->check('inspection/application/batchReject')?'':'hide'}" href="javascript:;" data-url="inspection/application/batchReject"><i class="fa fa-times text-danger"></i> 批量驳回</a></li>
+                            </ul>
+                        </div>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-detail="{:$auth->check('inspection/application/detail')}"
+                           data-operate-audit="{:$auth->check('inspection/application/audit')}"
+                           data-operate-del="{:$auth->check('inspection/application/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 2 - 2
application/admin/view/lottery/activity/add.html

@@ -298,12 +298,12 @@
                 <!-- 添加奖品按钮和提示信息 -->
                 <div style="margin-bottom: 15px;">
                     <button type="button" id="add-prize-btn" class="btn btn-success btn-sm" onclick="addPrize()">
-                        <i class="fa fa-plus"></i> <span class="btn-text">添加奖品</span> (<span id="prize-count">0</span>/8)
+                        <i class="fa fa-plus"></i> <span class="btn-text">添加奖品</span> (<span id="prize-count">1</span>/8)
                     </button>
                     <span class="text-muted" style="margin-left: 15px;">
                         当前总概率:<span id="total-rate" class="text-warning">0.00%</span>
                     </span>
-                    <div id="prize-count-tip" class="text-muted" style="margin-top: 5px; font-size: 12px;">还需添加 8 个奖品</div>
+                    <div id="prize-count-tip" class="text-muted" style="margin-top: 5px; font-size: 12px;">还需添加 7 个奖品</div>
                 </div>
                 
                 <!-- 提示信息 -->

+ 10 - 4
application/admin/view/lottery/activity/scripttpl.html

@@ -30,7 +30,7 @@
             <label class="control-label col-sm-3">积分数量:</label>
             <div class="col-sm-8">
                 <div class="input-group" style="width: 200px;">
-                    <input type="number" class="form-control" name="reward_value" data-rule="required;digits;min(1)" min="1" step="1" placeholder="请输入积分数量">
+                    <input type="number" class="form-control reward-value-input" name="reward_value_integral" data-rule="required;digits;min(1)" min="1" step="1" placeholder="请输入积分数量">
                     <span class="input-group-addon">积分</span>
                 </div>
             </div>
@@ -41,7 +41,7 @@
             <label class="control-label col-sm-3">余额金额:</label>
             <div class="col-sm-8">
                 <div class="input-group" style="width: 200px;">
-                    <input type="number" class="form-control" name="reward_value" data-rule="required;number;min(0.01)" min="0.01" step="0.01" placeholder="请输入余额金额">
+                    <input type="number" class="form-control reward-value-input" name="reward_value_balance" data-rule="required;number;min(0.01)" min="0.01" step="0.01" placeholder="请输入余额金额">
                     <span class="input-group-addon">元</span>
                 </div>
             </div>
@@ -64,7 +64,7 @@
             <label class="control-label col-sm-3">红包金额:</label>
             <div class="col-sm-8">
                 <div class="input-group" style="width: 200px;">
-                    <input type="number" class="form-control" name="reward_value" data-rule="required;number;range(0.3~200)" min="0.3" max="200" step="0.01" placeholder="请输入红包金额">
+                    <input type="number" class="form-control reward-value-input" name="reward_value_redpack" data-rule="required;number;range(0.3~200)" min="0.3" max="200" step="0.01" placeholder="请输入红包金额">
                     <span class="input-group-addon">元</span>
                 </div>
                 <div class="help-block">红包金额支持0.3-200元</div>
@@ -155,6 +155,12 @@
             <input type="hidden" class="prize-name-input" name="prizes[<%=index%>][name]" value="<%=name%>">
             <input type="hidden" class="prize-type-input" name="prizes[<%=index%>][type]" value="<%=type%>">
             <input type="hidden" class="prize-image-input" name="prizes[<%=index%>][image]" value="<%=imageRelative%>">
+            <% if(goodsId) { %>
+            <input type="hidden" class="prize-goods-id-input" name="prizes[<%=index%>][goods_id]" value="<%=goodsId%>">
+            <% } %>
+            <% if(couponId) { %>
+            <input type="hidden" class="prize-coupon-id-input" name="prizes[<%=index%>][coupon_id]" value="<%=couponId%>">
+            <% } %>
         </td>
         <td>
             <span class="label label-<%=labelClass%>"><%=typeName%></span>
@@ -199,7 +205,7 @@
                 <% if(type_text) { %>
                 <span class="label label-danger" style="margin-right: 6px; font-size: 10px;"><%=type_text%></span>
                 <% } %>
-                <%=name || title%>
+                <span class="goods-name-display"><%=name || title%></span>
             </div>
             <div style="font-size: 12px; color: #666; margin-bottom: 2px;">
                 <% if(price) { %>

+ 4 - 4
application/admin/view/shop/goods/select.html

@@ -14,18 +14,18 @@
                            data-operate-del="{:$auth->check('shop/goods/del')}"
                            width="100%">
                     </table>
-                    <!-- <div class="form-group layer-footer">
+                    <div class="form-group layer-footer">
                         <label class="control-label col-xs-12 col-sm-2"></label>
                         <div class="col-xs-12 col-sm-8">
-                            <div id="selection-info" class="alert alert-info" style="margin-bottom: 10px; display: none;">
+                            <!-- <div id="selection-info" class="alert alert-info" style="margin-bottom: 10px; display: none;">
                                 <i class="fa fa-info-circle"></i> 
                                 <span id="selection-mode-text">选择模式</span>:
                                 <span id="selection-tip">请点击商品行最后的"选择"按钮进行选择</span>
-                            </div>
+                            </div> -->
                             <button type="button" class="btn btn-success btn-goods-select btn-embossed" id="confirm-select-btn">{:__('确认选择')}</button>
                              <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> 
                         </div>
-                    </div> -->
+                    </div>
                 </div>
             </div>
 

+ 38 - 6
application/api/controller/Article.php

@@ -20,12 +20,44 @@ class Article extends Base
         $parentId = $this->request->param('parent_id', 0, 'intval');
         $page = $this->request->param('page', 1, 'intval');
         $pageSize = $this->request->param('page_size', 10, 'intval');
-        $list = Category::getCategoryList($parentId, $page, $pageSize);
-        // 处理图像的
-        $list->each(function ($item) {
-            $item['image'] = $item['image'] ? cdnurl($item['image']) : '';
-        });
-        $this->success('', $list);
+        
+        // 如果存在parent_id,先查询父分类信息
+        if ($parentId > 0) {
+            $parentCategory = Category::get($parentId);
+            if (!$parentCategory) {
+                $this->error('父分类不存在');
+            }
+            
+            // 处理父分类图片
+            $parentCategory['image'] = $parentCategory['image'] ? cdnurl($parentCategory['image']) : '';
+            
+            // 获取子分类列表
+            $children = Category::getCategoryList($parentId, $page, $pageSize);
+            
+            // 处理子分类图片
+            $children->each(function ($item) {
+                $item['image'] = $item['image'] ? cdnurl($item['image']) : '';
+            });
+            
+            // 将子分类添加到父分类的children字段
+            $parentCategory['children'] = $children;
+            $parentCategory['total'] = $children->total();
+            $parentCategory['per_page'] = $children->listRows();
+            $parentCategory['current_page'] = $children->currentPage();
+            $parentCategory['last_page'] = $children->lastPage();
+            
+            $this->success('', $parentCategory);
+        } else {
+            // 如果没有parent_id,直接返回顶级分类列表
+            $list = Category::getCategoryList($parentId, $page, $pageSize);
+            
+            // 处理图片
+            $list->each(function ($item) {
+                $item['image'] = $item['image'] ? cdnurl($item['image']) : '';
+            });
+            
+            $this->success('', $list);
+        }
     }
 
     /**

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

@@ -216,7 +216,7 @@ class Common extends Api
     {
         // 固定 
         $type = ['首页BANNER', '首页LOTTERY','首页ARTICE','首页MEASURE'];
-        $field = 'id,type,name,image,url,status,begintime,endtime,title';
+        $field = 'id,type,name,image,url,page_name,status,begintime,endtime,title';
         $list = Block::getBlockList(['type' => $type, 'field' => $field]);
         // 根据type  区分新的数组 
 

+ 281 - 26
application/common/Enum/ActivityEnum.php

@@ -2,24 +2,239 @@
 namespace app\common\Enum;
 
 /**
- * 全局状态枚举
+ * 抽奖活动相关枚举类
  */
 class ActivityEnum
 {
-    // 活动状态
-    const ACTIVITY_STATUS_NOT_STARTED = 1; // 未开始
-    const ACTIVITY_STATUS_ONGOING = 2; // 进行中
-    const ACTIVITY_STATUS_ENDED = 3; // 已结束
-    const ACTIVITY_STATUS_CANCELLED = 4; // 已取消
-    const ACTIVITY_STATUS_SUSPENDED = 5; // 已暂停
-    const ACTIVITY_STATUS_CLOSED = 6; // 已关闭
-    const ACTIVITY_STATUS_DELETED = 7; // 已删除
-    const ACTIVITY_STATUS_EXPIRED = 8; // 已过期
+    // ============ 活动基础状态 ============
+    const ACTIVITY_STATUS_DRAFT = 0;        // 草稿
+    const ACTIVITY_STATUS_ONGOING = 1;      // 进行中
+    const ACTIVITY_STATUS_ENDED = 2;        // 已结束
+    const ACTIVITY_STATUS_SUSPENDED = 3;    // 已暂停
+
+    // ============ 活动类型 ============
+    const ACTIVITY_TYPE_CONSUMPTION_LOTTERY = 1; // 消费抽奖
+
+    // ============ 开奖方式 ============
+    const LOTTERY_TYPE_INSTANT = 1;         // 即抽即中
+    const LOTTERY_TYPE_TIME = 2;            // 按时间开奖
+    const LOTTERY_TYPE_PEOPLE = 3;          // 按人数开奖
+
+    // ============ 用户群体类型 ============
+    const USER_LIMIT_ALL = 1;               // 全部会员
+    const USER_LIMIT_LEVEL = 2;             // 会员等级
+    const USER_LIMIT_TAG = 3;               // 会员标签
+
+    // ============ 引导样式 ============
+    const GUIDE_STYLE_DEFAULT = 1;          // 默认样式
+    const GUIDE_STYLE_CUSTOM = 2;           // 自定义
+
+    // ============ 奖品类型 ============
+    const PRIZE_TYPE_NO_PRIZE = 1;          // 未中奖
+    const PRIZE_TYPE_GOODS = 2;             // 实物奖品
+    const PRIZE_TYPE_POINTS = 3;            // 积分
+    const PRIZE_TYPE_BALANCE = 4;           // 余额
+    const PRIZE_TYPE_COUPON = 5;            // 优惠券
+    const PRIZE_TYPE_REDPACK = 6;           // 红包
+    const PRIZE_TYPE_CODE = 7;              // 兑换码
+    const PRIZE_TYPE_SHOP_GOODS = 8;        // 商城奖品
+
+    // ============ 奖品发放方式 ============
+    const DELIVER_TYPE_AUTO = 1;            // 自动发放
+    const DELIVER_TYPE_MANUAL = 2;          // 手动发放
+
+    // ============ 奖品发放状态 ============
+    const DELIVER_STATUS_PENDING = 0;       // 待发放
+    const DELIVER_STATUS_SUCCESS = 1;       // 已发放
+    const DELIVER_STATUS_FAILED = 2;        // 发放失败
+    const DELIVER_STATUS_CANCELLED = 3;     // 已取消
+
+    // ============ 参与条件类型 ============
+    const CONDITION_TYPE_BUY_GOODS = 1;     // 购买指定商品
+    const CONDITION_TYPE_ORDER_AMOUNT = 2;  // 单笔订单消费满额
+    const CONDITION_TYPE_RECHARGE_AMOUNT = 3; // 单次充值满额
+    const CONDITION_TYPE_TOTAL_AMOUNT = 4;  // 活动期间累计消费满额
+
+    // ============ 商品规则 ============
+    const GOODS_RULE_INCLUDE = 1;           // 指定商品参与
+    const GOODS_RULE_EXCLUDE = 2;           // 指定商品不可参与
+
+    // ============ 触发类型 ============
+    const TRIGGER_TYPE_BUY_GOODS = 1;       // 购买商品
+    const TRIGGER_TYPE_ORDER_CONSUME = 2;   // 订单消费
+    const TRIGGER_TYPE_RECHARGE = 3;        // 充值
+    const TRIGGER_TYPE_TOTAL_CONSUME = 4;   // 累计消费
+
+    // ============ 兑奖期限类型 ============
+    const REDEEM_EXPIRE_FOREVER = 1;        // 永久有效
+    const REDEEM_EXPIRE_FIXED = 2;          // 固定时长
+
+    /**
+     * 获取活动状态映射
+     */
+    public static function getActivityStatusMap()
+    {
+        return [
+            self::ACTIVITY_STATUS_DRAFT => '草稿',
+            self::ACTIVITY_STATUS_ONGOING => '进行中',
+            self::ACTIVITY_STATUS_ENDED => '已结束',
+            self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
+        ];
+    }
+
+    /**
+     * 获取活动类型映射
+     */
+    public static function getActivityTypeMap()
+    {
+        return [
+            self::ACTIVITY_TYPE_CONSUMPTION_LOTTERY => '消费抽奖',
+        ];
+    }
+
+    /**
+     * 获取开奖方式映射
+     */
+    public static function getLotteryTypeMap()
+    {
+        return [
+            self::LOTTERY_TYPE_INSTANT => '即抽即中',
+            self::LOTTERY_TYPE_TIME => '按时间开奖',
+            self::LOTTERY_TYPE_PEOPLE => '按人数开奖',
+        ];
+    }
+
+    /**
+     * 获取用户群体类型映射
+     */
+    public static function getUserLimitTypeMap()
+    {
+        return [
+            self::USER_LIMIT_ALL => '全部会员',
+            self::USER_LIMIT_LEVEL => '会员等级',
+            self::USER_LIMIT_TAG => '会员标签',
+        ];
+    }
+
+    /**
+     * 获取引导样式映射
+     */
+    public static function getGuideStyleMap()
+    {
+        return [
+            self::GUIDE_STYLE_DEFAULT => '默认样式',
+            self::GUIDE_STYLE_CUSTOM => '自定义',
+        ];
+    }
+
+    /**
+     * 获取奖品类型映射
+     */
+    public static function getPrizeTypeMap()
+    {
+        return [
+            self::PRIZE_TYPE_NO_PRIZE => '未中奖',
+            self::PRIZE_TYPE_GOODS => '实物奖品',
+            self::PRIZE_TYPE_POINTS => '积分',
+            self::PRIZE_TYPE_BALANCE => '余额',
+            self::PRIZE_TYPE_COUPON => '优惠券',
+            self::PRIZE_TYPE_REDPACK => '红包',
+            self::PRIZE_TYPE_CODE => '兑换码',
+            self::PRIZE_TYPE_SHOP_GOODS => '商城奖品',
+        ];
+    }
+
+    /**
+     * 获取奖品默认图片映射
+     */
+    public static function getPrizeDefaultImageMap()
+    {
+        return [
+            self::PRIZE_TYPE_NO_PRIZE => '/assets/img/lottery/no_prize.png',
+            self::PRIZE_TYPE_GOODS => '/assets/img/lottery/goods.png',
+            self::PRIZE_TYPE_POINTS => '/assets/img/lottery/points.png',
+            self::PRIZE_TYPE_BALANCE => '/assets/img/lottery/balance.png',
+            self::PRIZE_TYPE_COUPON => '/assets/img/lottery/coupon.png',
+            self::PRIZE_TYPE_REDPACK => '/assets/img/lottery/redpack.png',
+            self::PRIZE_TYPE_CODE => '/assets/img/lottery/code.png',
+            self::PRIZE_TYPE_SHOP_GOODS => '/assets/img/lottery/shop_goods.png',
+        ];
+    }
+
+    /**
+     * 获取奖品发放方式映射
+     */
+    public static function getDeliverTypeMap()
+    {
+        return [
+            self::DELIVER_TYPE_AUTO => '自动发放',
+            self::DELIVER_TYPE_MANUAL => '手动发放',
+        ];
+    }
 
     /**
-     * 获取状态描述
-     * @param int $status
-     * @return string
+     * 获取奖品发放状态映射
+     */
+    public static function getDeliverStatusMap()
+    {
+        return [
+            self::DELIVER_STATUS_PENDING => '待发放',
+            self::DELIVER_STATUS_SUCCESS => '已发放',
+            self::DELIVER_STATUS_FAILED => '发放失败',
+            self::DELIVER_STATUS_CANCELLED => '已取消',
+        ];
+    }
+
+    /**
+     * 获取参与条件类型映射
+     */
+    public static function getConditionTypeMap()
+    {
+        return [
+            self::CONDITION_TYPE_BUY_GOODS => '购买指定商品',
+            self::CONDITION_TYPE_ORDER_AMOUNT => '单笔订单消费满N元',
+            self::CONDITION_TYPE_RECHARGE_AMOUNT => '单次充值金额满N元',
+            self::CONDITION_TYPE_TOTAL_AMOUNT => '活动期间累计消费N元',
+        ];
+    }
+
+    /**
+     * 获取商品规则映射
+     */
+    public static function getGoodsRuleMap()
+    {
+        return [
+            self::GOODS_RULE_INCLUDE => '指定商品参与',
+            self::GOODS_RULE_EXCLUDE => '指定商品不可参与',
+        ];
+    }
+
+    /**
+     * 获取触发类型映射
+     */
+    public static function getTriggerTypeMap()
+    {
+        return [
+            self::TRIGGER_TYPE_BUY_GOODS => '购买商品',
+            self::TRIGGER_TYPE_ORDER_CONSUME => '订单消费',
+            self::TRIGGER_TYPE_RECHARGE => '充值',
+            self::TRIGGER_TYPE_TOTAL_CONSUME => '累计消费',
+        ];
+    }
+
+    /**
+     * 获取兑奖期限类型映射
+     */
+    public static function getRedeemExpireTypeMap()
+    {
+        return [
+            self::REDEEM_EXPIRE_FOREVER => '永久有效',
+            self::REDEEM_EXPIRE_FIXED => '固定时长',
+        ];
+    }
+
+    /**
+     * 获取活动状态文本
      */
     public static function getActivityStatusText($status)
     {
@@ -27,22 +242,62 @@ class ActivityEnum
         return $map[$status] ?? '未知';
     }
 
+    /**
+     * 获取奖品类型文本
+     */
+    public static function getPrizeTypeText($type)
+    {
+        $map = self::getPrizeTypeMap();
+        return $map[$type] ?? '未知';
+    }
 
     /**
-     * 获取状态映射
-     * @return array
+     * 获取开奖方式文本
      */
-    public static function getActivityStatusMap()
+    public static function getLotteryTypeText($type)
     {
-        return [
-            self::ACTIVITY_STATUS_NOT_STARTED => '未开始',
-            self::ACTIVITY_STATUS_ONGOING => '进行中',
-            self::ACTIVITY_STATUS_ENDED => '已结束',
-            self::ACTIVITY_STATUS_CANCELLED => '已取消',
-            self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
-            self::ACTIVITY_STATUS_CLOSED => '已关闭',
-            self::ACTIVITY_STATUS_DELETED => '已删除',
-            self::ACTIVITY_STATUS_EXPIRED => '已过期',
-        ];  
+        $map = self::getLotteryTypeMap();
+        return $map[$type] ?? '未知';
+    }
+
+    /**
+     * 获取条件类型文本
+     */
+    public static function getConditionTypeText($type)
+    {
+        $map = self::getConditionTypeMap();
+        return $map[$type] ?? '未知';
+    }
+
+    /**
+     * 验证活动状态是否有效
+     */
+    public static function isValidActivityStatus($status)
+    {
+        return array_key_exists($status, self::getActivityStatusMap());
+    }
+
+    /**
+     * 验证奖品类型是否有效
+     */
+    public static function isValidPrizeType($type)
+    {
+        return array_key_exists($type, self::getPrizeTypeMap());
+    }
+
+    /**
+     * 验证开奖方式是否有效
+     */
+    public static function isValidLotteryType($type)
+    {
+        return array_key_exists($type, self::getLotteryTypeMap());
+    }
+
+    /**
+     * 验证条件类型是否有效
+     */
+    public static function isValidConditionType($type)
+    {
+        return array_key_exists($type, self::getConditionTypeMap());
     }
 } 

+ 1 - 0
install.sql

@@ -0,0 +1 @@
+ 

+ 192 - 0
public/assets/js/backend/inspection/application.js

@@ -0,0 +1,192 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数
+            Table.api.init({
+                extend: {
+                    index_url: 'inspection/application/index' + location.search,
+                    detail_url: 'inspection/application/detail',
+                    audit_url: 'inspection/application/audit',
+                    del_url: 'inspection/application/del',
+                    multi_url: 'inspection/application/multi',
+                    dragsort_url: ''
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                sortOrder: 'desc',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'), operate: false, sortable: true},
+                        {field: 'name', title: '姓名', operate: 'LIKE'},
+                        {field: 'phone', title: '联系电话', operate: 'LIKE'},
+                        {field: 'user.nickname', title: '用户昵称', operate: false},
+                        {field: 'user.mobile', title: '用户手机', operate: false},
+                        {field: 'province_name', title: '省份', operate: false},
+                        {field: 'city_name', title: '城市', operate: false},
+                        {field: 'district_name', title: '区县', operate: false},
+                        {field: 'apply_time_text', title: '申请时间', operate: false, sortable: true},
+                        {field: 'audit_status', title: '审核状态', searchList: {"1":"审核中","2":"审核通过","3":"审核驳回"}, formatter: Table.api.formatter.status, custom: {"1":"warning","2":"success","3":"danger"}},
+                        {field: 'audit_time_text', title: '审核时间', operate: false},
+                        {field: 'reject_reason', title: '驳回原因', operate: false, formatter: function(value, row, index) {
+                            return value ? '<span class="text-danger">' + value + '</span>' : '-';
+                        }},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 
+                            buttons: [
+                                {
+                                    name: 'detail',
+                                    title: '查看详情',
+                                    text: '详情',
+                                    classname: 'btn btn-xs btn-info btn-dialog',
+                                    icon: 'fa fa-eye',
+                                    url: 'inspection/application/detail',
+                                    callback: function (data) {
+                                        Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    },
+                                    visible: function (row) {
+                                        return true;
+                                    }
+                                },
+                                {
+                                    name: 'audit',
+                                    title: '审核',
+                                    text: '审核',
+                                    classname: 'btn btn-xs btn-warning btn-dialog',
+                                    icon: 'fa fa-check',
+                                    url: 'inspection/application/audit',
+                                    callback: function (data) {
+                                        table.bootstrapTable('refresh');
+                                    },
+                                    visible: function (row) {
+                                        return row.audit_status == 1; // 只有审核中状态才显示审核按钮
+                                    }
+                                }
+                            ],
+                            formatter: Table.api.formatter.operate
+                        }
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+
+            // 批量通过
+            $(document).on("click", ".btn-batch-pass", function () {
+                var ids = Table.api.selectedids(table);
+                if (ids.length == 0) {
+                    Toastr.error(__('Please select at least one record'));
+                    return false;
+                }
+                Layer.confirm(__('Are you sure you want to batch pass these applications?'), function(index) {
+                    Fast.api.ajax({
+                        url: "inspection/application/batchPass",
+                        data: {ids: ids},
+                        type: 'post'
+                    }, function(data, ret) {
+                        table.bootstrapTable('refresh');
+                        Layer.close(index);
+                    });
+                });
+            });
+
+            // 批量驳回
+            $(document).on("click", ".btn-batch-reject", function () {
+                var ids = Table.api.selectedids(table);
+                if (ids.length == 0) {
+                    Toastr.error(__('Please select at least one record'));
+                    return false;
+                }
+                
+                // 弹出驳回原因输入框
+                Layer.prompt({
+                    title: '批量驳回',
+                    formType: 2,
+                    value: '',
+                    area: ['400px', '200px']
+                }, function(value, index) {
+                    if (!value || value.trim() == '') {
+                        Toastr.error('请输入驳回原因');
+                        return false;
+                    }
+                    
+                    Layer.confirm(__('Are you sure you want to batch reject these applications?'), function(confirmIndex) {
+                        Fast.api.ajax({
+                            url: "inspection/application/batchReject",
+                            data: {ids: ids, reject_reason: value},
+                            type: 'post'
+                        }, function(data, ret) {
+                            table.bootstrapTable('refresh');
+                            Layer.close(index);
+                            Layer.close(confirmIndex);
+                        });
+                    });
+                });
+            });
+
+            // 单独的详情按钮事件
+            $(document).on("click", ".btn-detail", function () {
+                var ids = Table.api.selectedids(table);
+                if (ids.length != 1) {
+                    Toastr.error(__('Please select one record'));
+                    return false;
+                }
+                Fast.api.open("inspection/application/detail/ids/" + ids.join(","), '查看详情', {
+                    area: ['90%', '90%']
+                });
+            });
+
+            // 单独的审核按钮事件
+            $(document).on("click", ".btn-audit", function () {
+                var ids = Table.api.selectedids(table);
+                if (ids.length != 1) {
+                    Toastr.error(__('Please select one record'));
+                    return false;
+                }
+                Fast.api.open("inspection/application/audit/ids/" + ids.join(","), '审核申请', {
+                    area: ['800px', '600px'],
+                    callback: function(data) {
+                        table.bootstrapTable('refresh');
+                    }
+                });
+            });
+        },
+        
+        detail: function () {
+            // 详情页面逻辑
+            Controller.api.bindevent();
+        },
+        
+        audit: function () {
+            // 审核页面逻辑
+            Controller.api.bindevent();
+            
+            // 监听审核状态变化
+            $(document).on('change', 'input[name="audit_status"]', function() {
+                var status = $(this).val();
+                if (status == '3') {
+                    $('#reject-reason-group').show();
+                    $('#reject_reason').attr('data-rule', 'required');
+                } else {
+                    $('#reject-reason-group').hide();
+                    $('#reject_reason').removeAttr('data-rule').val('');
+                }
+            });
+        },
+        
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 596 - 68
public/assets/js/backend/lottery/activity.js

@@ -116,10 +116,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                     rules: {
                         // 奖品设置验证
                         prize_setting_check: function(element) {
-                            // 检查奖品数量
-                            var prizeCount = $('.prize-item').length - 1; // 减去未中奖项
-                            if (prizeCount < 8) {
-                                return '奖品数量不足,必须添加8个奖品,当前只有' + prizeCount + '个';
+                            // 检查奖品数量(总共需要8个奖品,包含系统默认的未中奖项)
+                            var totalPrizeCount = $('.prize-item').length; // 总奖品数
+                            if (totalPrizeCount < 8) {
+                                var userPrizeCount = totalPrizeCount - 1; // 用户添加的奖品数
+                                var needCount = 8 - totalPrizeCount; // 还需要添加的奖品数
+                                return '奖品数量不足,还需要添加' + needCount + '个奖品(当前总共' + totalPrizeCount + '个奖品)';
                             }
                             
                             // 检查总概率
@@ -171,58 +173,81 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
             
             // 初始化添加页面
             initAddPage: function() {
-                // 使用辅助函数解析并输出JSON数据
-                var conditionTypeList = Controller.api.parseConfigJson('conditionTypeList', {});
-                var prizeTypeList = Controller.api.parseConfigJson('prizeTypeList', {});
-                var prizeDefaultImages = Controller.api.parseConfigJson('prizeDefaultImages', {});
+                // 初始化基础UI组件
+                Controller.api.initBasicUI();
                 
-
+                // 初始化奖品管理
+                Controller.api.initPrizeManagement();
+                
+                // 初始化任务规则管理
+                Controller.api.initTaskRuleManagement();
                 
+                // 确保DOM渲染完成后再计算奖品数量
+                setTimeout(function() {
+                    Controller.api.updatePrizeCount();
+                }, 50);
+                
+                // 初始化表单验证
+                Controller.api.initFormValidation();
+            },
+            
+            // 初始化基础UI组件
+            initBasicUI: function() {
                 // 活动名称字数统计
                 $('#c-name').on('input', function(){
                     var len = $(this).val().length;
                     $('#activity-name-count').text(len + '/24');
                 });
                 
+                // 初始化商品选择
+                Controller.api.initGoodsSelector();
+            },
+            
+            // 初始化任务规则管理
+            initTaskRuleManagement: function() {
                 // 任务类型切换(复选框)
                 $(document).on('change', 'input[name="row[task_type][]"]', function() {
-                    var checkedTypes = $('input[name="row[task_type][]"]:checked');
-                    
-                    // 更新复选框样式
-                    $('input[name="row[task_type][]"]').each(function() {
-                        var label = $(this).closest('label');
-                        if ($(this).is(':checked')) {
-                            label.addClass('checked');
-                        } else {
-                            label.removeClass('checked');
-                        }
-                    });
-                    
-                    // 隐藏所有任务设置项
-                    $('.task-setting-item').hide();
-                    
-                    // 显示选中的任务设置项
-                    checkedTypes.each(function() {
-                        var type = parseInt($(this).val());
-                        $('#task-setting-' + type).show();
-                    });
+                    Controller.api.handleTaskTypeChange();
                 });
                 
-                // 初始化奖品管理
-                Controller.api.initPrizeManagement();
+                // 商品规则切换
+                $(document).on('change', 'input[name^="condition"][name$="[goods_rule]"]', function() {
+                    Controller.api.updateGoodsRuleDisplay($(this));
+                });
                 
-                // 初始化奖品计数(因为默认有未中奖项,所以显示0)
-                $('#prize-count').text('0');
+                // 初始化任务类型状态
+                Controller.api.initTaskTypeState();
+            },
+            
+            // 处理任务类型变化
+            handleTaskTypeChange: function() {
+                var checkedTypes = $('input[name="row[task_type][]"]:checked');
                 
-                // 初始化添加奖品按钮状态
-                Controller.api.updateAddPrizeButtonState(0);
+                // 更新复选框样式
+                $('input[name="row[task_type][]"]').each(function() {
+                    var label = $(this).closest('label');
+                    if ($(this).is(':checked')) {
+                        label.addClass('checked');
+                    } else {
+                        label.removeClass('checked');
+                    }
+                });
                 
-                // 初始化商品选择
-                Controller.api.initGoodsSelector();
+                // 隐藏所有任务设置项
+                $('.task-setting-item').hide();
                 
-
+                // 显示选中的任务设置项
+                checkedTypes.each(function() {
+                    var type = parseInt($(this).val());
+                    $('#task-setting-' + type).show();
+                });
                 
-                // 初始化任务类型验证状态和显示
+                // 更新验证规则
+                Controller.api.updateTaskValidation();
+            },
+            
+            // 初始化任务类型状态
+            initTaskTypeState: function() {
                 var checkedTasks = $('input[name="row[task_type][]"]:checked');
                 
                 // 初始化复选框样式
@@ -244,9 +269,245 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 });
             },
             
+            // 更新商品规则显示
+            updateGoodsRuleDisplay: function($radio) {
+                var container = $radio.closest('.task-setting-item');
+                var rule = $radio.val();
+                var helpText = container.find('.goods-description-box');
+                
+                if (rule == '1') {
+                    helpText.html('<span class="text-muted">指定商品下单后将自动触发抽奖活动且发放一次抽奖机会,若用户产生维权退款,已发放的奖励自动回收。</span>');
+                } else {
+                    helpText.html('<span class="text-muted">除指定商品外的其他商品下单后将自动触发抽奖活动且发放一次抽奖机会。</span>');
+                }
+            },
+            
+            // 更新任务验证规则
+            updateTaskValidation: function() {
+                var checkedTypes = $('input[name="row[task_type][]"]:checked');
+                
+                // 移除旧的验证规则
+                $('[name^="condition"]').removeAttr('data-rule');
+                
+                // 为选中的任务类型添加验证规则
+                checkedTypes.each(function() {
+                    var type = parseInt($(this).val());
+                    
+                    switch(type) {
+                        case 1: // 购买指定商品
+                            // 商品选择验证会在选择商品时处理
+                            break;
+                        case 2: // 单笔订单消费满额
+                        case 3: // 单次充值满额  
+                        case 4: // 活动期间累计消费满额
+                            $('[name="condition[' + type + '][condition_value]"]').attr('data-rule', 'required;number(0.01~999999.99)');
+                            break;
+                    }
+                });
+            },
+            
+            // 初始化表单验证
+            initFormValidation: function() {
+                // 自定义验证规则已在bindevent中定义
+                
+                // 监听表单提交事件
+                $('form[role="form"]').on('submit', function(e) {
+                    console.log('表单提交开始');
+                    
+                    // 验证奖品设置
+                    if (!Controller.api.validatePrizes()) {
+                        e.preventDefault();
+                        return false;
+                    }
+                    
+                    // 验证任务规则设置
+                    if (!Controller.api.validateTaskRules()) {
+                        e.preventDefault();
+                        return false;
+                    }
+                    
+                    // 收集奖品数据并添加到表单
+                    var prizeData = Controller.api.collectPrizeData();
+                    if (prizeData.length > 0) {
+                        // 移除之前的隐藏字段
+                        $('form[role="form"] input[name^="prizes["]').remove();
+                        
+                        // 添加新的奖品数据
+                        for (var i = 0; i < prizeData.length; i++) {
+                            var prize = prizeData[i];
+                            for (var key in prize) {
+                                if (prize[key] !== null && prize[key] !== undefined) {
+                                    $('<input>').attr({
+                                        type: 'hidden',
+                                        name: 'prizes[' + i + '][' + key + ']',
+                                        value: prize[key]
+                                    }).appendTo('form[role="form"]');
+                                }
+                            }
+                        }
+                    }
+                    
+                    // 收集条件数据并添加到表单
+                    var conditionResult = Controller.api.collectConditionData();
+                    var conditionData = conditionResult.conditionData;
+                    var taskTypes = conditionResult.taskTypes;
+                    
+                    if (conditionData.length > 0) {
+                        // 移除之前的隐藏字段
+                        $('form[role="form"] input[name^="condition["]').remove();
+                        
+                        // 添加新的条件数据
+                        for (var i = 0; i < conditionData.length; i++) {
+                            var condition = conditionData[i];
+                            for (var key in condition) {
+                                if (condition[key] !== null && condition[key] !== undefined) {
+                                    var value = condition[key];
+                                    if (Array.isArray(value)) {
+                                        value = JSON.stringify(value);
+                                    }
+                                    $('<input>').attr({
+                                        type: 'hidden',
+                                        name: 'condition[' + i + '][' + key + ']',
+                                        value: value
+                                    }).appendTo('form[role="form"]');
+                                }
+                            }
+                        }
+                    }
+                    
+                    // 添加任务类型数据
+                    if (taskTypes.length > 0) {
+                        // 移除之前的task_type隐藏字段
+                        $('form[role="form"] input[type="hidden"][name^="task_type"]').remove();
+                        
+                        // 添加任务类型数据
+                        for (var i = 0; i < taskTypes.length; i++) {
+                            $('<input>').attr({
+                                type: 'hidden',
+                                name: 'task_type[' + i + ']',
+                                value: taskTypes[i]
+                            }).appendTo('form[role="form"]');
+                        }
+                    }
+                    
+                    console.log('表单验证通过,数据收集完成,准备提交');
+                    console.log('奖品数据:', prizeData);
+                    console.log('条件数据:', conditionData);
+                    console.log('任务类型:', taskTypes);
+                    return true;
+                });
+            },
+            
             // 初始化编辑页面
             initEditPage: function() {
                 Controller.api.initAddPage(); // 复用添加页面的初始化逻辑
+            },
+            
+            // 验证奖品设置
+            validatePrizes: function() {
+                var prizeItems = $('.prize-item');
+                var prizeCount = prizeItems.length;
+                
+                // 检查奖品数量
+                if (prizeCount < 1) {
+                    Toastr.error('请至少设置一个奖品');
+                    return false;
+                }
+                
+                // 检查奖品总概率
+                var totalRate = 0;
+                var hasValidPrize = false;
+                
+                prizeItems.each(function() {
+                    var type = $(this).attr('data-type');
+                    var rateInput = $(this).find('.prize-rate');
+                    var rate = parseFloat(rateInput.val()) || 0;
+                    
+                    totalRate += rate;
+                    
+                    // 检查非未中奖项是否有有效概率
+                    if (type !== 'no-prize' && rate > 0) {
+                        hasValidPrize = true;
+                    }
+                    
+                    // 检查奖品设置是否完整
+                    var nameInput = $(this).find('.prize-name');
+                    if (nameInput.length > 0 && !nameInput.val().trim()) {
+                        Toastr.error('请填写奖品名称');
+                        nameInput.focus();
+                        return false;
+                    }
+                    
+                    // 检查奖品数量(未中奖项除外)
+                    if (type !== 'no-prize') {
+                        var quantityInput = $(this).find('.prize-quantity');
+                        var quantity = parseInt(quantityInput.val()) || 0;
+                        if (quantity <= 0) {
+                            Toastr.error('奖品数量必须大于0');
+                            quantityInput.focus();
+                            return false;
+                        }
+                    }
+                });
+                
+                // 检查是否有非未中奖的有效奖品
+                if (!hasValidPrize) {
+                    Toastr.error('请至少设置一个有效的奖品(概率大于0)');
+                    return false;
+                }
+                
+                // 检查总概率是否合理
+                if (totalRate > 100) {
+                    Toastr.error('奖品总概率不能超过100%');
+                    return false;
+                }
+                
+                return true;
+            },
+            
+            // 验证任务规则设置
+            validateTaskRules: function() {
+                var checkedTypes = $('input[name="row[task_type][]"]:checked');
+                
+                // 检查是否选择了任务类型
+                if (checkedTypes.length === 0) {
+                    Toastr.error('请选择至少一种参与条件');
+                    return false;
+                }
+                
+                // 验证每个选中的任务类型
+                var isValid = true;
+                checkedTypes.each(function() {
+                    var type = parseInt($(this).val());
+                    var container = $('#task-setting-' + type);
+                    
+                    switch(type) {
+                        case 1: // 购买指定商品
+                            var goodsContainer = container.find('#selected-goods');
+                            if (goodsContainer.find('.goods-list-item').length === 0) {
+                                Toastr.error('请选择参与的商品');
+                                isValid = false;
+                                return false;
+                            }
+                            break;
+                            
+                        case 2: // 单笔订单消费满额
+                        case 3: // 单次充值满额
+                        case 4: // 活动期间累计消费满额
+                            var amountInput = container.find('input[name*="[condition_value]"]');
+                            var amount = parseFloat(amountInput.val()) || 0;
+                            if (amount <= 0) {
+                                var typeName = type === 2 ? '订单消费' : (type === 3 ? '充值' : '累计消费');
+                                Toastr.error('请填写' + typeName + '金额');
+                                amountInput.focus();
+                                isValid = false;
+                                return false;
+                            }
+                            break;
+                    }
+                });
+                
+                return isValid;
             },            
             // 初始化奖品管理
             initPrizeManagement: function() {
@@ -366,7 +627,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 Layer.open({
                     type: 1,
                     title: config.title,
-                    area: isEditMode ? ['700px', '600px'] : ['80%', '80%'],
+                    area: isEditMode ? ['80%', '80%'] : ['80%', '80%'],
                     content: formHtml,
                     btn: [isEditMode ? '保存' : '确定', '取消'],
                     success: function(layero, index) {
@@ -427,6 +688,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 // 设置奖品类型(单选框)
                 form.find('input[name="row[prize_type]"][value="' + data.type + '"]').prop('checked', true);
                 
+                // 根据奖品类型处理特殊字段
+                if (data.type == '8' && data.goodsId) {
+                    // 商城奖品:设置商品ID并获取商品信息
+                    form.find('input[name="goods_id"]').val(data.goodsId);
+                    Controller.api.loadGoodsInfo(form, data.goodsId, function() {
+                        // 商品信息加载完成,触发FastAdmin的表单更新
+                        setTimeout(function() {
+                            Form.api.bindevent(form);
+                        }, 100);
+                    });
+                } else if (data.type == '5' && data.couponId) {
+                    // 优惠券:设置优惠券ID并获取优惠券信息
+                    form.find('input[name="coupon_id"]').val(data.couponId);
+                    Controller.api.loadCouponInfo(form, data.couponId);
+                }
+                
                 // FastAdmin的动态显示会根据奖品类型自动处理字段显示
                 // 无需手动控制显示逻辑
                 
@@ -505,6 +782,114 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 form.find('input[name="prize_image"]').val(defaultImage).trigger('change');
             },
             
+            // 加载商品信息用于编辑模式回显
+            loadGoodsInfo: function(form, goodsId, callback) {
+                if (!goodsId) {
+                    console.warn('loadGoodsInfo: 商品ID为空');
+                    if (callback) callback();
+                    return;
+                }
+                
+                console.log('正在加载商品信息,ID:', goodsId);
+                
+                // 通过Ajax获取商品信息
+                $.ajax({
+                    url: Fast.api.fixurl('shop/goods/info'),
+                    type: 'POST',
+                    data: {id: goodsId},
+                    dataType: 'json',
+                    success: function(data) {
+                        console.log('商品信息API响应:', data);
+                        
+                        if (data.code === 1 && data.data) {
+                            var goods = data.data; // 标准FastAdmin响应格式
+                            console.log('成功获取商品信息:', goods);
+                            
+                            // 处理商品数据
+                            var processedGoods = {
+                                id: goods.id,
+                                name: goods.name || goods.title,
+                                title: goods.title || goods.name,
+                                image: goods.image ? Fast.api.cdnurl(goods.image) : '',
+                                price: goods.price || goods.sellprice || '',
+                                goods_sn: goods.goods_sn || '',
+                                spec_type: goods.spec_type !== undefined ? goods.spec_type : null,
+                                category: goods.category || null,
+                                type_name: Controller.api.getGoodsTypeName(goods),
+                                type_text: Controller.api.getGoodsTypeText(goods)
+                            };
+                            
+                            // 使用商品模板显示
+                            var html = Template('prize-goods-template', processedGoods);
+                            form.find('#selected-goods-display').html(html).show();
+                            
+                            // 绑定删除事件
+                            form.find('.remove-prize-goods').off('click').on('click', function() {
+                                $(this).closest('.prize-goods-item').remove();
+                                form.find('input[name="goods_id"]').val('');
+                            });
+                            
+                            console.log('商品信息已成功显示');
+                            
+                            // 执行回调
+                            if (callback) callback();
+                        } else {
+                            console.warn('商品信息API返回异常:', data);
+                            // 显示友好的提示信息
+                            var errorMsg = data.msg || '获取商品信息失败';
+                            form.find('#selected-goods-display').html(
+                                '<div class="alert alert-warning" style="margin-top: 10px;">' +
+                                '<i class="fa fa-warning"></i> ' + errorMsg + 
+                                ' (商品ID: ' + goodsId + ')' +
+                                '</div>'
+                            ).show();
+                            
+                            // 即使失败也执行回调
+                            if (callback) callback();
+                        }
+                    },
+                    error: function(xhr, status, error) {
+                        console.error('加载商品信息失败 - 详细信息:');
+                        console.error('- 商品ID:', goodsId);
+                        console.error('- HTTP状态:', xhr.status);
+                        console.error('- 错误信息:', error);
+                        console.error('- 响应内容:', xhr.responseText);
+                        
+                        // 显示友好的错误提示
+                        var errorHtml = '<div class="alert alert-danger" style="margin-top: 10px;">' +
+                            '<i class="fa fa-exclamation-circle"></i> 加载商品信息失败<br>' +
+                            '<small>商品ID: ' + goodsId + '</small><br>' +
+                            '<small>错误: ' + (xhr.status === 404 ? '商品不存在或已删除' : 
+                                           xhr.status === 403 ? '无权限访问' : 
+                                           '网络错误,请稍后重试') + '</small>' +
+                            '</div>';
+                        form.find('#selected-goods-display').html(errorHtml).show();
+                        
+                        // 错误时也执行回调
+                        if (callback) callback();
+                    }
+                });
+            },
+            
+            // 加载优惠券信息用于编辑模式回显
+            loadCouponInfo: function(form, couponId) {
+                if (!couponId) {
+                    console.warn('loadCouponInfo: 优惠券ID为空');
+                    return;
+                }
+                
+                console.log('正在加载优惠券信息,ID:', couponId);
+                
+                // 暂时显示一个简单的占位信息,提醒需要重新选择
+                var placeholderHtml = '<div class="alert alert-info" style="margin-top: 10px;">' +
+                    '<i class="fa fa-info-circle"></i> 编辑模式下需要重新选择优惠券<br>' +
+                    '<small>优惠券ID: ' + couponId + '</small>' +
+                    '</div>';
+                form.find('#selected-coupon-display').html(placeholderHtml).show();
+                
+                console.log('优惠券占位信息已显示,用户需要重新选择');
+            },
+            
             
             // 打开商品选择器
             openGoodsSelector: function(form) {
@@ -569,9 +954,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                         }
                     }
                 });
-            },
-            
-
+            }, 
             
             // 保存奖品
             savePrize: function(layero) {
@@ -580,7 +963,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 var type = form.find('input[name="row[prize_type]"]:checked').val();
                 var image = form.find('input[name="prize_image"]').val();
                 var quantity = form.find('input[name="prize_quantity"]').val();
-                var rewardValue = form.find('input[name="reward_value"]').val();
+                
+                // 根据奖品类型获取对应的奖励值
+                var rewardValue = '';
+                if (type == 3) { // 积分
+                    rewardValue = form.find('input[name="reward_value_integral"]').val();
+                } else if (type == 4) { // 余额
+                    rewardValue = form.find('input[name="reward_value_balance"]').val();
+                } else if (type == 6) { // 红包
+                    rewardValue = form.find('input[name="reward_value_redpack"]').val();
+                }
+                
                 var goodsId = form.find('input[name="goods_id"]').val();
                 var couponId = form.find('input[name="coupon_id"]').val();
                 
@@ -676,7 +1069,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                         break;
                     case 8: // 商城奖品
                         prizeData.goods_id = goodsId;
-                        prizeData.goods_name = form.find('#selected-goods-display .selected-goods-item span').text();
+                        // 使用简化的选择器获取商品名称
+                        prizeData.goods_name = form.find('#selected-goods-display .goods-name-display').text() || '';
                         break;
                 }
                 
@@ -715,7 +1109,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                     imageRelative: imageRelative, // 相对路径
                     imageDisplay: imageDisplay,   // CDN URL
                     quantity: prize.quantity || 0,
-                    rate: prize.rate || 0
+                    rate: prize.rate || 0,
+                    goodsId: prize.goods_id || '',
+                    couponId: prize.coupon_id || ''
                 });
                 
                 $('.prize-list').append(prizeHtml);
@@ -832,23 +1228,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                     case 2: // 实物奖品
                         return '';
                     case 3: // 积分
-                        var points = form.find('input[name="reward_value"]').val();
+                        var points = form.find('input[name="reward_value_integral"]').val();
                         return points ? (points + ' 积分') : '';
                     case 4: // 余额
-                        var balance = form.find('input[name="reward_value"]').val();
+                        var balance = form.find('input[name="reward_value_balance"]').val();
                         return balance ? (balance + ' 余额') : '';
                     case 5: // 优惠券
                         var couponName = form.find('#selected-coupon-display .selected-coupon-item span:first').text();
                         return couponName || '';
                     case 6: // 红包
-                        var amount = form.find('input[name="reward_value"]').val();
+                        var amount = form.find('input[name="reward_value_redpack"]').val();
                         return amount ? (amount + ' 元红包') : '';
                     case 7: // 兑换码
                         var codeType = form.find('input[name="code_type"]:checked').val();
                         return codeType == 'manual' ? '手动兑换码' : '自动兑换码';
                     case 8: // 商城奖品
-                        var goodsName = form.find('#selected-goods-display .selected-goods-item span').text();
-                        return goodsName || '';
+                        // 使用简化的选择器获取商品名称
+                        return form.find('#selected-goods-display .goods-name-display').text() || '';
                     default:
                         return '';
                 }
@@ -869,23 +1265,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
             
             // 更新奖品数量统计
             updatePrizeCount: function() {
-                var count = $('.prize-item').length - 1; // 减去未中奖项
-                $('#prize-count').text(count);
+                var totalCount = $('.prize-item').length; // 总奖品数(包含未中奖项)
+                var userCount = totalCount - 1; // 用户添加的奖品数(减去未中奖项)
+                
+                // 显示总奖品数(包含系统默认的未中奖项)
+                $('#prize-count').text(totalCount);
                 
-                // 更新添加奖品按钮状态
-                Controller.api.updateAddPrizeButtonState(count);
+                // 更新添加奖品按钮状态(基于用户可添加的奖品数)
+                Controller.api.updateAddPrizeButtonState(userCount);
                 
                 // 更新验证状态
                 $('input[name="prize_setting_check"]').val('1').trigger('change');
             },
             
             // 更新添加奖品按钮状态
-            updateAddPrizeButtonState: function(count) {
-                var maxCount = 8; // 最大奖品数量
+            updateAddPrizeButtonState: function(userCount) {
+                var maxUserCount = 8; // 用户最大可添加奖品数量
                 var addButton = $('#add-prize-btn');
-                var remainingCount = maxCount - count;
+                var remainingCount = maxUserCount - userCount;
                 
-                if (count >= maxCount) {
+                if (userCount >= maxUserCount) {
                     // 达到最大数量,禁用按钮
                     addButton.prop('disabled', true).addClass('disabled');
                     addButton.find('.btn-text').text('已达最大数量');
@@ -897,7 +1296,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                     if (remainingCount <= 2) {
                         $('#prize-count-tip').text('还可添加 ' + remainingCount + ' 个奖品').removeClass('text-muted text-danger').addClass('text-warning');
                     } else {
-                        $('#prize-count-tip').text('还需添加 ' + remainingCount + ' 个奖品').removeClass('text-warning text-danger').addClass('text-muted');
+                        // 当用户还没添加奖品时,显示还需添加多少个才能满足最低要求
+                        var minRequired = Math.max(0, 7 - userCount); // 至少需要7个用户奖品(总共8个,已有1个系统默认)
+                        if (minRequired > 0) {
+                            $('#prize-count-tip').text('还需添加 ' + minRequired + ' 个奖品').removeClass('text-warning text-danger').addClass('text-muted');
+                        } else {
+                            $('#prize-count-tip').text('还可添加 ' + remainingCount + ' 个奖品').removeClass('text-warning text-danger').addClass('text-muted');
+                        }
                     }
                 }
             },
@@ -929,17 +1334,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 
                 // 更新验证状态
                 $('input[name="prize_setting_check"]').val('1').trigger('change');
-            },
-            
-
+            },   
               
-              // 编辑奖品(统一处理所有类型)
+            // 编辑奖品(统一处理所有类型)
             editPrize: function(prizeItem) {
                 // 判断是否为系统默认未中奖项
                 var isSystemNoPrize = prizeItem.attr('data-type') === 'no-prize';
                 
                 // 获取奖品信息
-                var name, imageRelative, type, quantity, rate;
+                var name, imageRelative, type, quantity, rate, goodsId, couponId;
                 
                 if (isSystemNoPrize) {
                     // 系统默认项从不同位置获取数据
@@ -955,6 +1358,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                     type = prizeItem.find('.prize-type-input').val();
                     quantity = prizeItem.find('.prize-quantity').val();
                     rate = prizeItem.find('.prize-rate').val();
+                    
+                    // 获取商品ID和优惠券ID(如果存在)
+                    goodsId = prizeItem.find('.prize-goods-id-input').val();
+                    couponId = prizeItem.find('.prize-coupon-id-input').val();
                 }
                 
                 var title = isSystemNoPrize ? '编辑未中奖项' : '编辑奖品';
@@ -970,7 +1377,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                         image: imageRelative,
                         type: type,
                         quantity: quantity,
-                        rate: rate
+                        rate: rate,
+                        goodsId: goodsId,
+                        couponId: couponId
                     }
                 });
             },
@@ -1052,22 +1461,141 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 // 重新编号所有奖品的隐藏域name属性
                 $('.prize-list .prize-item').each(function(index) {
                     var $item = $(this);
-                    var isNoPrize = $item.attr('data-type') === 'no-prize';
-                    var prizeIndex = isNoPrize ? 0 : index; // 未中奖项固定为索引0
+                    var prizeIndex = index; // 按实际位置索引
                     
                     // 更新隐藏域的name属性
                     $item.find('.prize-name-input').attr('name', 'prizes[' + prizeIndex + '][name]');
                     $item.find('.prize-type-input').attr('name', 'prizes[' + prizeIndex + '][type]');
                     $item.find('.prize-image-input').attr('name', 'prizes[' + prizeIndex + '][image]');
                     
+                    // 更新商品ID和优惠券ID的隐藏域name属性
+                    $item.find('.prize-goods-id-input').attr('name', 'prizes[' + prizeIndex + '][goods_id]');
+                    $item.find('.prize-coupon-id-input').attr('name', 'prizes[' + prizeIndex + '][coupon_id]');
+                    
                     // 更新其他表单字段的name属性
                     $item.find('.prize-quantity').attr('name', 'prizes[' + prizeIndex + '][quantity]');
                     $item.find('.prize-rate').attr('name', 'prizes[' + prizeIndex + '][rate]');
+                    
+                    // 更新奖品特定字段的name属性
+                    var prizeType = parseInt($item.find('.prize-type-input').val());
+                    switch(prizeType) {
+                        case 3: // 积分
+                            $item.find('.prize-points-input').attr('name', 'prizes[' + prizeIndex + '][points]');
+                            break;
+                        case 4: // 余额
+                            $item.find('.prize-balance-input').attr('name', 'prizes[' + prizeIndex + '][balance]');
+                            break;
+                        case 6: // 红包
+                            $item.find('.prize-redpack-input').attr('name', 'prizes[' + prizeIndex + '][redpack_amount]');
+                            break;
+                        case 7: // 兑换码
+                            $item.find('.prize-codes-input').attr('name', 'prizes[' + prizeIndex + '][manual_codes]');
+                            break;
+                    }
                 });
                 
                 console.log('奖品排序已更新');
             },
             
+            // 在表单提交前收集奖品数据
+            collectPrizeData: function() {
+                var prizesData = [];
+                
+                $('.prize-list .prize-item').each(function(index) {
+                    var $item = $(this);
+                    var prizeType = parseInt($item.find('.prize-type-input').val());
+                    
+                    var prizeData = {
+                        name: $item.find('.prize-name-input').val() || $item.find('.prize-name').text() || $item.find('td:eq(1)').text(),
+                        type: prizeType,
+                        image: $item.find('.prize-image-input').val(),
+                        quantity: $item.find('.prize-quantity').val() || 0,
+                        rate: $item.find('.prize-rate').val() || 0
+                    };
+                    
+                    // 根据奖品类型添加特定字段
+                    switch(prizeType) {
+                        case 3: // 积分
+                            var pointsInput = $item.find('.prize-points-input');
+                            if (pointsInput.length === 0) {
+                                // 如果隐藏域不存在,从表单中获取
+                                pointsInput = $('input[name="reward_value_integral"]');
+                            }
+                            prizeData.points = pointsInput.val() || 0;
+                            break;
+                        case 4: // 余额
+                            var balanceInput = $item.find('.prize-balance-input');
+                            if (balanceInput.length === 0) {
+                                balanceInput = $('input[name="reward_value_balance"]');
+                            }
+                            prizeData.balance = balanceInput.val() || 0;
+                            break;
+                        case 5: // 优惠券
+                            prizeData.coupon_id = $item.find('.prize-coupon-id-input').val() || 0;
+                            break;
+                        case 6: // 红包
+                            var redpackInput = $item.find('.prize-redpack-input');
+                            if (redpackInput.length === 0) {
+                                redpackInput = $('input[name="reward_value_redpack"]');
+                            }
+                            prizeData.redpack_amount = redpackInput.val() || 0;
+                            break;
+                        case 7: // 兑换码
+                            var codesInput = $item.find('.prize-codes-input');
+                            if (codesInput.length === 0) {
+                                codesInput = $('textarea[name="manual_codes"]');
+                            }
+                            prizeData.manual_codes = codesInput.val() || '';
+                            break;
+                        case 8: // 商城奖品
+                            prizeData.goods_id = $item.find('.prize-goods-id-input').val() || 0;
+                            break;
+                    }
+                    
+                    prizesData.push(prizeData);
+                });
+                
+                return prizesData;
+            },
+            
+            // 在表单提交前收集条件数据
+            collectConditionData: function() {
+                var conditionData = {};
+                var taskTypes = [];
+                
+                // 获取选中的任务类型
+                $('input[name="row[task_type][]"]:checked').each(function() {
+                    taskTypes.push($(this).val());
+                });
+                
+                // 为每个任务类型收集条件数据
+                taskTypes.forEach(function(taskType) {
+                    var type = parseInt(taskType);
+                    var condition = {};
+                    
+                    switch(type) {
+                        case 1: // 购买指定商品
+                            condition.type = type;
+                            condition.goods_rule = $('input[name="condition[' + type + '][goods_rule]"]:checked').val() || 1;
+                            condition.goods_ids = $('#task-goods-ids-' + type).val() || '[]';
+                            break;
+                        case 2: // 单笔订单消费满额
+                        case 3: // 单次充值满额
+                        case 4: // 活动期间累计消费满额
+                            condition.type = type;
+                            condition.condition_value = $('input[name="condition[' + type + '][condition_value]"]').val() || 0;
+                            break;
+                    }
+                    
+                    conditionData[type] = condition;
+                });
+                
+                return {
+                    conditionData: conditionData,
+                    taskTypes: taskTypes
+                };
+            },
+            
             // 初始化商品选择器
             initGoodsSelector: function() {
                 // 商品选择器初始化逻辑

+ 1 - 0
抽奖活动系统完成说明.md

@@ -0,0 +1 @@
+