diff --git a/app/admin/controller/Cardextractor.php b/app/admin/controller/Cardextractor.php index e173f86..c33037e 100755 --- a/app/admin/controller/Cardextractor.php +++ b/app/admin/controller/Cardextractor.php @@ -478,7 +478,7 @@ class Cardextractor extends Base // if (!$goods) { // return $this->renderError("请求参数错误"); // } - $data = Shang::where('id','<',39) ->order('sort desc,id asc') + $data = Shang::where('id','<',39)->whereOr('id','>',113) ->order('id desc') ->select()->toArray(); #概率 $pro = array_sum(array_column($data, 'pro')); @@ -495,25 +495,25 @@ class Cardextractor extends Base public function card_shang_add(Request $request) { if (!$request->isPost()) { - $goods_id = request()->param('goods_id/d', 0); - $goods = GoodsModel::where(['id' => $goods_id])->find(); - if (!$goods) { - return $this->renderError("请求参数错误"); - } - if ($goods['type'] != 4) { - return $this->renderError("请求参数错误1"); - } - View::assign('goods_id', $goods_id); + // $goods_id = request()->param('goods_id/d', 0); + // $goods = GoodsModel::where(['id' => $goods_id])->find(); + // if (!$goods) { + // return $this->renderError("请求参数错误"); + // } + // if ($goods['type'] != 4) { + // return $this->renderError("请求参数错误1"); + // } + View::assign('goods_id', 0); return View::fetch("Cardextractor/card_shang_add"); } else { $data = input('post.'); - if (empty($data['goods_id'])) { - return $this->renderError("请求参数错误"); - } - $goods = GoodsModel::where(['id' => $data['goods_id']])->find(); - if (!$goods) { - return $this->renderError("请求参数错误1"); - } + // if (empty($data['goods_id'])) { + // return $this->renderError("请求参数错误"); + // } + // $goods = GoodsModel::where(['id' => $data['goods_id']])->find(); + // if (!$goods) { + // return $this->renderError("请求参数错误1"); + // } if (empty($data['title'])) { return $this->renderError("请输入等级名称"); } @@ -523,9 +523,9 @@ class Cardextractor extends Base if (RegZero($data['sort'])) { return $this->renderError("排序输入不规范,请输入整数"); } - if (empty($data['imgurl'])) { - return $this->renderError("请上传等级图标"); - } + // if (empty($data['imgurl'])) { + // return $this->renderError("请上传等级图标"); + // } $data['update_time'] = time(); $dd = Shang::insert($data); if ($dd) { diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index 0158a52..2f24b8b 100755 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -12,7 +12,7 @@ use app\common\model\GoodsList; use app\common\model\AdminGoodsLog; use think\facade\Db; use app\common\model\Shang; - +use app\common\model\Reward; class Goods extends Base { /** @@ -232,6 +232,55 @@ class Goods extends Base $data['integral_is'] = 0; $data['category_id'] = 0; $data['stock'] = 1; + } elseif ($data['type'] == 15) { + // 福利屋类型处理 + $data['stock'] = 0; // 隐藏套数 + $data['lock_is'] = 0; // 隐藏锁箱类型 + $data['lock_time'] = 0; // 隐藏锁箱时间 + $data['coupon_is'] = 0; // 隐藏发券开关 + $data['coupon_pro'] = 0; // 隐藏发券概率 + $data['integral_is'] = 0; // 隐藏发积分开关 + $data['prize_num'] = 0; + $data['category_id'] = 0; + $data['is_flw'] = 1; // 标记为福利屋 + + // 处理时间字段 + if (!empty($data['flw_start_time'])) { + $data['flw_start_time'] = strtotime($data['flw_start_time']); + } else { + return $this->renderError("请选择开始时间"); + } + + if (!empty($data['flw_end_time'])) { + $data['flw_end_time'] = strtotime($data['flw_end_time']); + } else { + return $this->renderError("请选择结束时间"); + } + + if (!empty($data['open_time'])) { + $data['open_time'] = strtotime($data['open_time']); + } else { + return $this->renderError("请选择开奖时间"); + } + + // 验证时间逻辑 + if ($data['flw_start_time'] >= $data['flw_end_time']) { + return $this->renderError("开始时间必须早于结束时间"); + } + + if ($data['flw_end_time'] >= $data['open_time']) { + return $this->renderError("结束时间必须早于开奖时间"); + } + + // 验证抽奖门槛 + if (!isset($data['choujiang_xianzhi']) || $data['choujiang_xianzhi'] === '') { + $data['choujiang_xianzhi'] = 0; + } else if (!is_numeric($data['choujiang_xianzhi']) || intval($data['choujiang_xianzhi']) < 0) { + return $this->renderError("抽奖门槛必须是非负整数"); + } + + // 默认未开奖 + $data['is_open'] = 0; } else { return $this->renderError("盒子类型选择错误"); } @@ -407,11 +456,61 @@ class Goods extends Base $data['lock_is'] = 0; $data['lock_time'] = 0; $data['prize_num'] = 0; + $data['show_is'] = 0; $data['coupon_is'] = 0; $data['coupon_pro'] = 0; $data['integral_is'] = 0; $data['category_id'] = 0; $data['stock'] = 1; + } elseif ($type == 15) { + // 福利屋类型处理 + $data['stock'] = 0; // 隐藏套数 + $data['lock_is'] = 0; // 隐藏锁箱类型 + $data['lock_time'] = 0; // 隐藏锁箱时间 + $data['coupon_is'] = 0; // 隐藏发券开关 + $data['coupon_pro'] = 0; // 隐藏发券概率 + $data['integral_is'] = 0; // 隐藏发积分开关 + $data['prize_num'] = 0; + $data['category_id'] = 0; + $data['is_flw'] = 1; // 标记为福利屋 + + // 处理时间字段 + if (!empty($data['flw_start_time'])) { + $data['flw_start_time'] = strtotime($data['flw_start_time']); + } else { + return $this->renderError("请选择开始时间"); + } + + if (!empty($data['flw_end_time'])) { + $data['flw_end_time'] = strtotime($data['flw_end_time']); + } else { + return $this->renderError("请选择结束时间"); + } + + if (!empty($data['open_time'])) { + $data['open_time'] = strtotime($data['open_time']); + } else { + return $this->renderError("请选择开奖时间"); + } + + // 验证时间逻辑 + if ($data['flw_start_time'] >= $data['flw_end_time']) { + return $this->renderError("开始时间必须早于结束时间"); + } + + if ($data['flw_end_time'] >= $data['open_time']) { + return $this->renderError("结束时间必须早于开奖时间"); + } + + // 验证抽奖门槛 + if (!isset($data['choujiang_xianzhi']) || $data['choujiang_xianzhi'] === '') { + $data['choujiang_xianzhi'] = 0; + } else if (!is_numeric($data['choujiang_xianzhi']) || intval($data['choujiang_xianzhi']) < 0) { + return $this->renderError("抽奖门槛必须是非负整数"); + } + + // 默认未开奖 + $data['is_open'] = 0; } else { return $this->renderError("盒子类型选择错误"); } @@ -521,7 +620,7 @@ class Goods extends Base if ($type == 1 || $type == 3 || $type == 5 || $type == 6 || $type == 10 || $type == 11) { $whe[] = ['num', '=', 1]; - } elseif ($type == 2 || $type == 8 || $type == 9) { + } elseif ($type == 2 || $type == 8 || $type == 9 || $type == 15) { $whe[] = ['num', '=', 0]; } else { return $this->renderError('请求参数错误1'); @@ -572,6 +671,8 @@ class Goods extends Base $shang = Shang::where('id', 'between', [34, 38])->select()->toArray(); } elseif ($info['type'] == 3) { $shang = Shang::where('id', 'between', [4, 33])->select()->toArray(); + } elseif ($info['type'] == 15) { + $shang = Shang::where('id', '>=', 114)->select()->toArray(); } else { return $this->renderError('请求参数错误1'); } @@ -615,6 +716,8 @@ class Goods extends Base if ($today_time >= $data['sale_time']) { return $this->renderError('预售时间请在今天之后'); } + } elseif ($type == 15) { + $data['sale_time'] = 0; } else { return $this->err('奖品类型选择错误'); } @@ -649,7 +752,7 @@ class Goods extends Base $prize_code = getPrizeCode() . '_' . time(); $data['prize_code'] = $prize_code; - } else if ($type == 3) { + } elseif ($type == 3) { if ($data['shang_id'] == 1 || $data['shang_id'] == 2 || $data['shang_id'] == 3 || $data['shang_id'] == 5) { if ($data['stock'] != 1) { return $this->renderError('特殊奖品库存请设置为1'); @@ -672,18 +775,19 @@ class Goods extends Base if (RegInt($data['prize_num']) && $data['shang_id'] == 5) { return $this->renderError("擂台赏抽全局赏数量设置错误,请设置大于0的整数"); } + } elseif ($type == 15) { + $prize_code = getPrizeCode() . '_' . time(); + $data['prize_code'] = $prize_code; + if (RegInt($data['stock'])) { + return $this->renderError('奖品数量设置错误,请设置大于0的整数'); + } } else { return $this->err('请求参数错误'); } if (RegZero($data['sort'])) { return $this->renderError('排序请输入整数'); } - // if ($data['card_no']) { -// $card_no_info = GoodsList::field('id')->where('card_no', '=', $data['card_no'])->find(); -// if ($card_no_info) { -// return $this->renderError('赠送编号已存在'); -// } -// } else { + $data['card_no'] = NULL; // } @@ -729,6 +833,8 @@ class Goods extends Base $shang = Shang::where('id', '<=', 33)->where('id', '<>', 5)->select()->toArray(); } elseif ($info['type'] == 2 || $info['type'] == 8 || $info['type'] == 9) { $shang = Shang::where('id', 'between', [34, 38])->select()->toArray(); + } elseif ($info['type'] == 15) { + $shang = Shang::where('id', '>=', 114)->select()->toArray(); } elseif ($info['type'] == 3) { $shang = Shang::where('id', 'between', [4, 33])->select()->toArray(); } else { @@ -780,6 +886,8 @@ class Goods extends Base if ($today_time >= $data['sale_time']) { return $this->renderError('预售时间请在今天之后'); } + } elseif ($data['goods_type'] == 3) { + $data['sale_time'] = 0; } else { return $this->err('奖品类型选择错误'); } @@ -788,7 +896,7 @@ class Goods extends Base $data['reward_num'] = 0; // - if ($type == 1 || $type == 5 || $type == 10 || $type == 6 || $type == 11) { + if ($type == 1 || $type == 5 || $type == 10 || $type == 6 || $type == 11 || $type == 15) { } elseif ($type == 2 || $type == 8 || $type == 9) { if (RegMoney($data['real_pro'] * 1000)) { @@ -804,17 +912,8 @@ class Goods extends Base if (RegZero($data['sort'])) { return $this->renderError('排序请输入整数'); } - // if ($data['card_no']) { -// $card_no_info = GoodsList::field('id') -// ->where('prize_code', '<>', $goods['prize_code']) -// ->where('card_no', '=', trim($data['card_no'])) -// ->find(); -// if ($card_no_info) { -// return $this->renderError('赠送编号已存在'); -// } -// } else { + $data['card_no'] = NULL; - // } if (empty($data['imgurl'])) { return $this->renderError('请上传图片'); @@ -845,9 +944,9 @@ class Goods extends Base $prize_code = GoodsList::field('prize_code') ->where(['id' => $id]) ->value('prize_code'); - if (!$prize_code) { - return $this->renderError("请勿重复操作"); - } + // if (!$prize_code) { + // return $this->renderError("请勿重复操作"); + // } #删除奖品 $res = GoodsList::field('id') ->where(['prize_code' => $prize_code]) @@ -1325,49 +1424,120 @@ class Goods extends Base */ public function clear_goods_data(Request $request) { - $id = $request->post('id/d'); - if (!$id) { - return $this->renderError('盒子ID不能为空'); + if (!$request->isPost()) { + return $this->renderError('请求方式错误'); } - // 检查盒子是否存在 + $id = $request->post('id/d'); $goods = GoodsModel::where(['id' => $id])->find(); if (!$goods) { return $this->renderError('盒子不存在'); } + // 开启事务 Db::startTrans(); try { - // 清空订单表 - $orderCount = Db::name('order')->where('goods_id', $id)->delete(); + // 删除相关订单数据 + Db::name('order')->where('goods_id', $id)->delete(); + Db::name('order_list')->where('goods_id', $id)->delete(); - // 清空订单详情表 - $orderListCount = Db::name('order_list')->where('goods_id', $id)->delete(); + // 重置奖品剩余数量 + Db::name('goods_list')->where('goods_id', $id)->update(['surplus_stock' => Db::raw('stock')]); - // 提交事务 Db::commit(); - - // 记录管理员操作日志 - AdminGoodsLog::add_goods_log( - session('admin_id'), - $id, - 0, - json_encode(['operation' => '清空抽奖数据前']), - json_encode([ - 'operation' => '清空抽奖数据后', - 'clear_order_count' => $orderCount, - 'clear_order_list_count' => $orderListCount - ]) - ); - - return $this->renderSuccess("操作成功,共清空订单 {$orderCount} 条,订单详情 {$orderListCount} 条"); + return $this->renderSuccess('盒子抽奖数据已清空'); } catch (\Exception $e) { - // 回滚事务 Db::rollback(); return $this->renderError('操作失败:' . $e->getMessage()); } } + /** + * 复制盒子 + */ + public function copy_goods(Request $request) + { + if (!$request->isPost()) { + return $this->renderError('请求方式错误'); + } + + $id = $request->post('id/d'); + $goods = GoodsModel::where(['id' => $id])->find(); + if (!$goods) { + return $this->renderError('盒子不存在'); + } + + // 开启事务 + Db::startTrans(); + try { + // 复制盒子基本信息 + $goodsData = $goods->toArray(); + unset($goodsData['id']); + unset($goodsData['delete_time']); + + // 修改标题,添加"复制"标识 + $goodsData['title'] = $goodsData['title'] . '(复制)'; + $goodsData['status'] = 2; // 默认下架状态 + $goodsData['addtime'] = time(); + $goodsData['async_code'] = ''; // 清空同步代码,避免混淆 + + // 插入新盒子 + $newGoods = new GoodsModel(); + $newGoods->save($goodsData); + $newGoodsId = $newGoods->id; + + // 复制盒子奖品 + $goodsLists = GoodsList::where(['goods_id' => $id])->select(); + foreach ($goodsLists as $item) { + $listData = $item->toArray(); + unset($listData['id']); + $listData['goods_id'] = $newGoodsId; + $listData['addtime'] = time(); + if ($listData['reward_id'] && $listData['reward_id'] != '') { + $reward = Reward::where(['reward_id' => $listData['reward_id']])->select(); + $listData['reward_id'] = 'MHHZ' . date('YmdHis') . mt_rand(1000, 9999);//$this->generateUUID(); + if ($reward) { + $rewards = $reward->toArray(); + foreach ($rewards as $item2) { + unset($item2['id']); + $item2['reward_id'] = $listData['reward_id']; + $item2['create_time'] = time(); + $item2['update_time'] = time(); + Reward::insert($item2); + } + + } + } + // 插入新奖品 + $newGoodsList = new GoodsList(); + $newGoodsList->save($listData); + + // 如果有扩展奖品,也进行复制 + if ($goods['type'] == 1 || $goods['type'] == 11) { + $goodsExtends = Db::name('goods_extend_list') + ->where(['goods_list_id' => $item['id']]) + ->select() + ->toArray(); + + foreach ($goodsExtends as $extend) { + unset($extend['id']); + $extend['goods_id'] = $newGoodsId; + $extend['goods_list_id'] = $newGoodsList->id; + $extend['addtime'] = time(); + + Db::name('goods_extend_list')->insert($extend); + } + } + } + + Db::commit(); + return $this->renderSuccess('盒子复制成功'); + } catch (\Exception $e) { + Db::rollback(); + return $this->renderError('复制失败:' . $e->getMessage()); + } + } + /** * 生成UUID */ diff --git a/app/admin/controller/Reward.php b/app/admin/controller/Reward.php index 12dba13..1ceb167 100644 --- a/app/admin/controller/Reward.php +++ b/app/admin/controller/Reward.php @@ -17,20 +17,20 @@ class Reward extends Base { $reward_type = trim(input('get.reward_type', '')); $keyword = trim(input('get.keyword')); - + $where = []; if (!empty($keyword)) { $where[] = ['title', 'like', '%' . $keyword . '%']; } - + if ($reward_type !== '') { $where[] = ['reward_type', '=', $reward_type]; } - + $field = "*"; $order = "id desc"; $data = RewardModel::getList($where, $field, $order, $this->page); - + // 获取关联的优惠券信息 foreach ($data['list'] as $key => &$item) { if ($item['reward_type'] == 1 && !empty($item['reward_id'])) { @@ -38,15 +38,15 @@ class Reward extends Base $item['coupon'] = $coupon; } } - + View::assign('list', $data['list']); View::assign('count', $data['count']); View::assign('page', $data['page']); View::assign('reward_type', $reward_type); - + return View::fetch("Reward/index"); } - + /** * 添加奖励 */ @@ -56,17 +56,17 @@ class Reward extends Base // 获取优惠券列表供选择 $coupons = Coupon::where('status', 0)->select(); View::assign('coupons', $coupons); - + return View::fetch("Reward/add"); } else { $data = input('post.'); - + // 处理优惠券类型的特殊情况 if ($data['reward_type'] == 1) { if (empty($data['reward_id'])) { return $this->renderError("请选择优惠券"); } - + // 获取优惠券信息,设置默认标题 if (empty($data['title'])) { $coupon = Coupon::find($data['reward_id']); @@ -78,12 +78,12 @@ class Reward extends Base // 非优惠券类型,reward_id设为0 $data['reward_id'] = 0; } - + $data['create_time'] = time(); $data['update_time'] = time(); - + $result = RewardModel::insertGetId($data); - + if ($result) { return $this->renderSuccess("添加成功"); } else { @@ -91,7 +91,7 @@ class Reward extends Base } } } - + /** * 编辑奖励 */ @@ -99,31 +99,31 @@ class Reward extends Base { if (!$request->isPost()) { $id = input('get.id/d', 0); - + if (empty($id)) { return $this->renderError("参数错误"); } - + $info = RewardModel::find($id); if (empty($info)) { return $this->renderError("奖励不存在"); } - + // 获取优惠券列表供选择 $coupons = Coupon::where('status', 0)->select(); - + View::assign('info', $info); View::assign('coupons', $coupons); - + return View::fetch("Reward/edit"); } else { $data = input('post.'); $id = isset($data['id']) ? intval($data['id']) : 0; - + if (empty($id)) { return $this->renderError("参数错误"); } - + // 处理优惠券类型的特殊情况 if ($data['reward_type'] == 1) { if (empty($data['reward_id'])) { @@ -133,11 +133,11 @@ class Reward extends Base // 非优惠券类型,reward_id设为0 $data['reward_id'] = 0; } - + $data['update_time'] = time(); - + $result = RewardModel::where('id', $id)->update($data); - + if ($result !== false) { return $this->renderSuccess("编辑成功"); } else { @@ -145,27 +145,27 @@ class Reward extends Base } } } - + /** * 删除奖励 */ public function delete(Request $request) { $id = input('post.id/d', 0); - + if (empty($id)) { return $this->renderError("参数错误"); } - + $result = RewardModel::destroy($id); - + if ($result) { return $this->renderSuccess("删除成功"); } else { return $this->renderError("删除失败"); } } - + /** * 修改状态 */ @@ -173,13 +173,13 @@ class Reward extends Base { $id = input('post.id/d', 0); $status = input('post.status/d', 0); - + if (empty($id)) { return $this->renderError("参数错误"); } - + $result = RewardModel::where('id', $id)->update(['status' => $status, 'update_time' => time()]); - + if ($result !== false) { return $this->renderSuccess("状态更新成功"); } else { @@ -193,19 +193,19 @@ class Reward extends Base public function getRewardsByRewardId(Request $request) { $reward_id = trim(input('get.reward_id', '')); - + if (empty($reward_id)) { return json([ - 'code' => 1, + 'status' => 0, 'msg' => '参数错误', 'data' => [] ]); } - + try { // 查询对应的奖励列表 $rewards = RewardModel::where('reward_id', $reward_id)->select()->toArray(); - + // 处理优惠券数据 foreach ($rewards as &$reward) { if ($reward['reward_type'] == 1) { // 优惠券类型 @@ -216,18 +216,63 @@ class Reward extends Base } } } - + return json([ - 'code' => 0, + 'status' => 1, 'msg' => '获取成功', 'data' => $rewards ]); } catch (\Exception $e) { return json([ - 'code' => 1, + 'status' => 0, 'msg' => '获取奖励失败: ' . $e->getMessage(), 'data' => [] ]); } } -} \ No newline at end of file + + /** + * 添加奖励 + */ + public function addReward(Request $request) + { + + $data = input('post.'); + //签到奖励 + $reward = json_decode($data['reward'], true); + $reward_id = $data['reward_id']; + $reward_id_pre = $data['reward_id_pre']; + if (!$reward_id_pre) { + $reward_id_pre = "MHCC"; + } + if (!$reward_id || $reward_id == '') { + $reward_id = $reward_id_pre . date('YmdHis') . mt_rand(1000, 9999); + } + + // 开启事务 + \think\facade\Db::startTrans(); + try { + RewardModel::where('reward_id', $reward_id)->delete(); + if (!empty($reward) && is_array($reward)) { + foreach ($reward as $item) { + $rewardData = [ + 'reward_type' => $item['reward_type'], + 'reward_value' => isset($item['reward_value']) && !empty($item['reward_value']) ? $item['reward_value'] : 0, + 'reward_extend' => isset($item['coupon_id']) && !empty($item['coupon_id']) ? $item['coupon_id'] : 0, + 'description' => '', + 'create_time' => time(), + 'update_time' => time(), + 'reward_id' => $reward_id + ]; + RewardModel::insert($rewardData); + } + } + \think\facade\Db::commit(); + return $this->renderSuccess("更新成功", ['reward_id' => $reward_id]); + } catch (\Exception $e) { + \think\facade\Db::rollback(); + return $this->renderError("更新失败: " . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/admin/route/app.php b/app/admin/route/app.php index cd1bb6b..13fca4b 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -180,6 +180,7 @@ Route::rule('yushou_rili_edit', 'Goods/yushou_rili_edit', 'GET|POST'); Route::rule('yushou_rili_del', 'Goods/yushou_rili_del', 'GET|POST'); Route::rule('offshelf_log', 'Goods/offshelf_log', 'GET|POST'); Route::rule('clear_goods_data', 'Goods/clear_goods_data', 'POST'); +Route::rule('copy_goods', 'Goods/copy_goods', 'POST'); Route::rule('draw_raffle', 'Draw/goods', 'GET|POST'); Route::rule('draw_edit', 'Draw/draw_edit', 'GET|POST'); Route::rule('drawlist', 'Draw/drawlist', 'GET|POST'); @@ -365,6 +366,7 @@ Route::rule('reward_edit', 'Reward/edit', 'GET|POST'); Route::rule('reward_delete', 'Reward/delete', 'POST'); Route::rule('reward_status', 'Reward/status', 'POST'); Route::rule('get_rewards_by_id', 'Reward/getRewardsByRewardId', 'GET'); +Route::rule('reward_add_json', 'Reward/addReward', 'POST'); // 签到配置 Route::get('sign_config', 'SignConfig/index'); diff --git a/app/admin/view/Cardextractor/card_shang.html b/app/admin/view/Cardextractor/card_shang.html index 07a28d2..b5a1b9c 100755 --- a/app/admin/view/Cardextractor/card_shang.html +++ b/app/admin/view/Cardextractor/card_shang.html @@ -5,13 +5,14 @@
- + 添加等级 共有数据: {$count}条
+ @@ -24,6 +25,7 @@ {volist name="list" id="vo"} + diff --git a/app/admin/view/Cardextractor/card_shang_add.html b/app/admin/view/Cardextractor/card_shang_add.html index f8dcfbb..b8b335a 100755 --- a/app/admin/view/Cardextractor/card_shang_add.html +++ b/app/admin/view/Cardextractor/card_shang_add.html @@ -25,6 +25,12 @@ +
+ +
+ +
+
diff --git a/app/admin/view/Goods/goods.html b/app/admin/view/Goods/goods.html index 1f39733..9835c5b 100755 --- a/app/admin/view/Goods/goods.html +++ b/app/admin/view/Goods/goods.html @@ -115,17 +115,22 @@
+ + 复制 + 同步 +
+
清空抽奖 -
删除
+ @@ -218,6 +223,21 @@ { field: 'unlock_amount', title: '解锁金额', width: 100, templet: function(d) { return d.unlock_amount > 0 ? '' + d.unlock_amount + '' : '无需解锁'; }}, + // 福利屋时间信息 + { field: 'is_flw', title: '福利屋信息', width: 200, templet: function(d) { + if (d.type == 15) { + var startTime = d.flw_start_time ? new Date(d.flw_start_time * 1000).toLocaleString() : '未设置'; + var endTime = d.flw_end_time ? new Date(d.flw_end_time * 1000).toLocaleString() : '未设置'; + var openTime = d.open_time ? new Date(d.open_time * 1000).toLocaleString() : '未设置'; + var isOpen = d.is_open == 1 ? '已开奖' : '未开奖'; + return '
开始: ' + startTime + '
' + + '
结束: ' + endTime + '
' + + '
开奖: ' + openTime + '
' + + '
状态: ' + isOpen + '
'; + } else { + return ''; + } + }}, { field: 'sort', title: '排序', width: 80 }, { field: 'addtime_text', title: '添加时间', width: 160 }, { fixed: 'right',field: 'status', title: '状态', width: 100, templet: '#statusTpl' }, @@ -279,6 +299,9 @@ } else if (layEvent === 'sync') { // 同步盒子 goods_sync(data.id, data.async_code); + } else if (layEvent === 'copy') { + // 复制盒子 + copy_goods(data.id); } else if (layEvent === 'clear') { // 清空抽奖数据 clear_goods_data(data.id); @@ -474,6 +497,31 @@ }); } + // 复制盒子 + function copy_goods(id) { + layer.confirm('确定要复制此盒子及其所有奖品吗?', { + btn: ['确定', '取消'], + title: '复制确认' + }, function (index) { + var url = "{:url('/admin/copy_goods')}"; + var load = layer.load(2); + var $ = layui.$; + $.post(url, { "id": id }, function (data) { + layer.close(load); + if (data.status == 1) { + layer.msg(data.msg, { icon: 1, time: 2000 }, function () { + table.reload('goodsTable'); + }); + } else { + layer.msg(data.msg, { icon: 2, anim: 6, time: 2000 }, function () { + layer.close(load); + }); + } + }); + layer.close(index); + }); + } + // 图片预览功能 function previewImg(obj) { var img = new Image(); @@ -503,7 +551,7 @@ } .layui-table-cell { - height: 100px !important; + height: 120px !important; line-height: 28px; padding: 0 15px; position: relative; diff --git a/app/admin/view/Goods/goods_add.html b/app/admin/view/Goods/goods_add.html index 2b649af..84c946f 100755 --- a/app/admin/view/Goods/goods_add.html +++ b/app/admin/view/Goods/goods_add.html @@ -55,6 +55,30 @@ class="layui-input" style="width: 600px"> + + + + + +
@@ -236,7 +260,7 @@
-
新用户需要消费满此金额才能解锁此盒子,0表示无需解锁
+
用户需要消费满此金额才能看到此盒子,0表示都能看到
@@ -271,24 +295,51 @@
{include file="Public:footer"/} - - \ No newline at end of file + \ No newline at end of file diff --git a/app/admin/view/Goods/goods_edit.html b/app/admin/view/Goods/goods_edit.html index 6b7368b..8427d86 100755 --- a/app/admin/view/Goods/goods_edit.html +++ b/app/admin/view/Goods/goods_edit.html @@ -65,6 +65,30 @@ class="layui-input" style="width: 600px">
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
@@ -247,7 +271,7 @@
-
新用户需要消费满此金额才能解锁此盒子,0表示无需解锁
+
用户需要消费满此金额才能看到此盒子,0表示都能看到
@@ -284,270 +308,299 @@
{include file="Public:footer"/} - \ No newline at end of file diff --git a/app/admin/view/Goods/goodslist.html b/app/admin/view/Goods/goodslist.html index fec1b2d..af0a52b 100755 --- a/app/admin/view/Goods/goodslist.html +++ b/app/admin/view/Goods/goodslist.html @@ -48,7 +48,7 @@
- {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11} + {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11|| $type eq 15} {/if} {if $type eq 2 || $type eq 8 || $type eq 9} @@ -74,7 +74,7 @@ {if $type eq 1} {/if} - {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11} + {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11 || $type eq 15} {/if} {if $type eq 2 || $type eq 8 || $type eq 9} @@ -140,7 +140,7 @@ } - + //编辑奖品 function goodslist_edit(id) { var url = "{:url('/admin/goodslist_edit?id=" + id + "')}"; diff --git a/app/admin/view/Goods/goodslist_add.html b/app/admin/view/Goods/goodslist_add.html index 023d5c7..29a3a70 100755 --- a/app/admin/view/Goods/goodslist_add.html +++ b/app/admin/view/Goods/goodslist_add.html @@ -1,197 +1,224 @@ {include file="Public:header2"/} - -
-
-
-
-
-
-
-
- -
- -
-
- {if $type eq 9} -
- -
- - -
-
- {/if} -
- -
- -
-
-
- -
- -
- -
- -
- -
-
- -
- -
-
- {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 6 || $type eq 11} -
- -
- -
-
- {/if} - {if $type eq 3} -
- -
- + +
+
+
+
+
+ +
+
+ +
+ +
+
+ {if $type eq 9} +
+ +
+ + +
+
+ {/if} +
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 6 || $type eq 11 || $type eq 15} +
+ +
+ +
+
+ + {/if} + {if $type eq 3} +
+ +
+ +
+
+ {/if} + {if $type eq 2 || $type eq 8 || $type eq 9} +
+ +
+ % +
+
+ {/if} + + +
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+ + +
+
+ +
+
+ +
- {/if} - {if $type eq 2 || $type eq 8 || $type eq 9} -
- -
- % -
-
- {/if} -
- -
- - -
-
- -
- -
- -
-
- - - - - - -
- -
- - -
-
- -
-
- -
-
-
- + +
-
-{include file="Public:footer"/} - - - - - - + + + + + + + \ No newline at end of file diff --git a/app/admin/view/Goods/goodslist_edit.html b/app/admin/view/Goods/goodslist_edit.html index f752a4a..f1051cb 100755 --- a/app/admin/view/Goods/goodslist_edit.html +++ b/app/admin/view/Goods/goodslist_edit.html @@ -1,186 +1,219 @@ {include file="Public:header2"/} + -
-
-
-
-
-
-
-
- -
- +
+
+
+
+
+ +
+
+ +
+ +
+
+ {if $type eq 9} +
+ +
+ + +
+
+ {/if} +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ + +
+ {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11 || $type eq 6 + || $type eq 15} +
+ +
+ +
+
+ {/if} + {if $type eq 3} +
+ +
+ +
+
+ {/if} + {if $type eq 2 || $type eq 8 || $type eq 9} +
+ +
+ % +
+
+ {/if} +
+ +
+ + + +
+
+ +
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+ + +
+
+ +
+
+ +
- {if $type eq 9} -
- -
- - -
-
- {/if} -
- -
- -
-
-
- -
- -
- -
- -
-
-
- -
- -
- - -
- {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 11 || $type eq 6} -
- -
- -
-
- {/if} - {if $type eq 3} -
- -
- -
-
- {/if} - {if $type eq 2 || $type eq 8 || $type eq 9} -
- -
- % -
-
- {/if} -
- -
- - -
-
- -
- -
- -
-
-
- -
- - -
-
- -
-
- -
-
-
- + +
-
-{include file="Public:footer"/} + {include file="Public:footer"/} - + + \ No newline at end of file diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 1f07b35..5e12f8c 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -83,8 +83,10 @@ class Goods extends Base $whe[] = ['type', '=', 11]; } elseif ($type_str == 12) { $whe[] = ['type', '=', 12]; + } elseif ($type_str == 15) { + $whe[] = ['type', '=', 15]; } else { - $whe[] = ['type', 'not in', [4, 10]]; + $whe[] = ['type', 'not in', [4, 10, 15]]; } $user_id = $this->getUserId(); @@ -166,7 +168,64 @@ class Goods extends Base } + /** + * 福利屋 + * @param \think\Request $request + * @return \think\response\Json + */ + public function goods_fuliwu(Request $request) + { + $type_str = request()->param('type', 1); + if ($type_str != 1 && $type_str != 3) { + return $this->renderError('参数错误'); + } + $whe = []; + $whe[] = ['status', '=', $type_str]; + $paginate = 15; + $whe[] = ['type', '=', 15]; + $user_id = $this->getUserId(); + if ($user_id == 0) { + //充值金额 + $whe[] = ['unlock_amount', '=', 0]; + } else { + $order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('price'); + $userInfo = User::where('id', '=', $user_id)->field('istest')->find(); + if ($userInfo && $userInfo['istest'] > 0) { + //推广账号,门槛计算是全部的 + $order_money = Order::where('status', '=', 1)->where('user_id', '=', $user_id)->sum('order_zhe_total'); + } + $whe[] = ['unlock_amount', '<=', $order_money]; + } + #盒子 + $goods = GoodsModel::where($whe) + ->field("id,title,imgurl,price,type,new_is,quanju_xiangou,choujiang_xianzhi,flw_start_time,flw_end_time,open_time,goods_describe,is_open") + ->order("sort desc,id desc")->paginate($paginate)->each(function ($itme) { + $itme['imgurl'] = imageUrl($itme['imgurl']); + $itme['flw_start_time'] = date('Y-m-d H:i:s', $itme['flw_start_time']); + $itme['flw_end_time'] = date('Y-m-d H:i:s', $itme['flw_end_time']); + $itme['open_time'] = date('Y-m-d H:i:s', $itme['open_time']); + $goodslist = GoodsList::where('goods_id', '=', $itme['id']) + ->where('num', '=', 0) + ->field('title,imgurl,stock,price,sc_money') + ->select() + ->toArray(); + $itme['goodslist'] = $goodslist; + #参与次数 + $join_count = OrderList::field('id') + ->where('goods_id', '=', $itme['id']) + ->where('order_type', '=', $itme['type']) + ->count(); + $itme['join_count'] = $join_count; + }); + $new_data = [ + 'data' => $goods->items(), + 'last_page' => $goods->lastPage(), + ]; + return $this->renderSuccess('请求成功', $new_data); + } + + /** * 商品详情 * @param $goods_id 盒子id @@ -627,6 +686,31 @@ class Goods extends Base if ($shou_zhe_price <= 0) { $iszhifu = 0; + # 余额抵扣 + if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { + if ($goodsType['is_deduction'] == 1) { + # 抵扣模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + } else { + $use_money = $user['money']; + $price = bcsub("$price", "$use_money", 2); + } + } else { + # 支付模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + $iszhifu++; + } else { + # 支付模式下余额不足无法抵扣 + $use_money = 0; + return $this->renderError('金额不足'); + } + } + } + # 货币1抵扣 if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1) { $price_in_currency = $price * 100; # 1:100比例 @@ -653,30 +737,7 @@ class Goods extends Base } } - # 余额抵扣 - if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { - if ($goodsType['is_deduction'] == 1) { - # 抵扣模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - $use_money = $user['money']; - $price = bcsub("$price", "$use_money", 2); - } - } else { - # 支付模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - $iszhifu++; - } else { - # 支付模式下余额不足无法抵扣 - $use_money = 0; - return $this->renderError('金额不足'); - } - } - } + # 货币2抵扣 if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { @@ -888,7 +949,35 @@ class Goods extends Base # 对于非积分赏类型,应用会员折扣 if ($shou_zhe_price <= 0) { + + $iszhifu = 0; + + # 余额抵扣 + if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { + if ($goodsType['is_deduction'] == 1) { + # 抵扣模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + } else { + $use_money = $user['money']; + $price = bcsub("$price", "$use_money", 2); + } + } else { + # 支付模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + $iszhifu++; + } else { + # 支付模式下余额不足无法抵扣 + $use_money = 0; + return $this->renderError('金额不足'); + } + } + } + # 货币1抵扣 if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1) { $price_in_currency = $price * 100; # 1:100比例 @@ -915,30 +1004,7 @@ class Goods extends Base } } - # 余额抵扣 - if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { - if ($goodsType['is_deduction'] == 1) { - # 抵扣模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - $use_money = $user['money']; - $price = bcsub("$price", "$use_money", 2); - } - } else { - # 支付模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - $iszhifu++; - } else { - # 支付模式下余额不足无法抵扣 - $use_money = 0; - return $this->renderError('金额不足'); - } - } - } + # 货币2抵扣 if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { @@ -1114,7 +1180,7 @@ class Goods extends Base $attach = 'order_lts'; } elseif ($goods['type'] == 5) { $attach = 'order_jfs'; - }elseif ($goods['type'] == 6) { + } elseif ($goods['type'] == 6) { $attach = 'order_lts'; } elseif ($goods['type'] == 11) { $attach = 'order_zzs'; diff --git a/app/api/controller/Infinite.php b/app/api/controller/Infinite.php index 15e95a2..98249ec 100755 --- a/app/api/controller/Infinite.php +++ b/app/api/controller/Infinite.php @@ -343,13 +343,13 @@ class Infinite extends Base if (!$goods) { return $this->renderError("盒子不存在"); } - + # 获取盒子类型配置 $goodsType = \app\common\model\GoodsType::where('value', $goods['type'])->find(); if (!$goodsType) { return $this->renderError("盒子类型配置不存在"); } - + if ($goods['status'] != 1) { return $this->renderError("盒子已下架"); } @@ -390,7 +390,7 @@ class Infinite extends Base $use_money2 = 0; # 货币2抵扣 $zhe = 0; # 会员折扣 $coupon_price = 0; # 优惠券金额 - + #首抽半价 if ($shou_zhe_price <= 0) { # 判断是否可使用优惠券 @@ -419,7 +419,7 @@ class Infinite extends Base $price = 0; } $order_zhe_total = $price; - + # 会员折扣 $vip_info = UserVip::where(['id' => $user['vip']])->find(); if ($vip_info && $vip_info['discount'] > 0 && $goods['type'] != 10) { @@ -427,8 +427,34 @@ class Infinite extends Base $zhe_bl = bcdiv("$zhe", "10", 2); $order_zhe_total = $price = bcmul("$price", "$zhe_bl", 2); } - + $iszhifu = 0; + + # 余额抵扣 + if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { + if ($goodsType['is_deduction'] == 1) { + # 抵扣模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + } else { + $use_money = $user['money']; + $price = bcsub("$price", "$use_money", 2); + } + } else { + # 支付模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + $iszhifu++; + } else { + # 支付模式下余额不足无法抵扣 + $use_money = 0; + return $this->renderError('金额不足'); + } + } + } + # 货币1抵扣(吧唧币) if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1 && $goods_type != 10) { $price_in_currency = $price * 100; # 1:100比例 @@ -454,32 +480,9 @@ class Infinite extends Base } } } - - # 余额抵扣 - if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { - if ($goodsType['is_deduction'] == 1) { - # 抵扣模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - $use_money = $user['money']; - $price = bcsub("$price", "$use_money", 2); - } - } else { - # 支付模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - $iszhifu++; - } else { - # 支付模式下余额不足无法抵扣 - $use_money = 0; - return $this->renderError('金额不足'); - } - } - } - + + + # 货币2抵扣 if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { $price_in_currency2 = $price * 100; # 1:100比例 @@ -505,7 +508,7 @@ class Infinite extends Base } } } - + if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) { return $this->renderError('请选择支付方式'); } @@ -555,7 +558,7 @@ class Infinite extends Base */ public function infinite_orderbuy() { - + $user = $this->getUser(); if (empty($user['mobile'])) { return $this->renderError('请先绑定手机号', [], -9); @@ -575,13 +578,13 @@ class Infinite extends Base if (!$goods) { return $this->renderError("盒子不存在"); } - + # 获取盒子类型配置 $goodsType = \app\common\model\GoodsType::where('value', $goods['type'])->find(); if (!$goodsType) { return $this->renderError("盒子类型配置不存在"); } - + if ($goods['status'] != 1) { return $this->renderError("盒子已下架"); } @@ -693,7 +696,7 @@ class Infinite extends Base } else { $coupon_id = 0; } - + $price = bcsub("$price", "$coupon_price", 2); if ($price <= 0) { @@ -709,8 +712,34 @@ class Infinite extends Base $zhe_bl = bcdiv("$zhe", "10", 2); $order_zhe_total = $price = bcmul("$price", "$zhe_bl", 2); } - + $iszhifu = 0; + + # 余额抵扣 + if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { + if ($goodsType['is_deduction'] == 1) { + # 抵扣模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + } else { + $use_money = $user['money']; + $price = bcsub("$price", "$use_money", 2); + } + } else { + # 支付模式 + if ($user['money'] >= $price) { + $use_money = $price; + $price = 0; + $iszhifu++; + } else { + # 支付模式下余额不足无法抵扣 + $use_money = 0; + return $this->renderError('金额不足'); + } + } + } + # 货币1抵扣(吧唧币) if ($use_integral_is == 1 && $goodsType['pay_currency'] == 1 && $goods['type'] != 10) { $price_in_currency = $price * 100; # 1:100比例 @@ -736,32 +765,9 @@ class Infinite extends Base } } } - - # 余额抵扣 - if ($use_money_is == 1 && $goodsType['pay_balance'] == 1) { - if ($goodsType['is_deduction'] == 1) { - # 抵扣模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - } else { - $use_money = $user['money']; - $price = bcsub("$price", "$use_money", 2); - } - } else { - # 支付模式 - if ($user['money'] >= $price) { - $use_money = $price; - $price = 0; - $iszhifu++; - } else { - # 支付模式下余额不足无法抵扣 - $use_money = 0; - return $this->renderError('金额不足'); - } - } - } - + + + # 货币2抵扣 if ($use_money2_is == 1 && $goodsType['pay_currency2'] == 1) { $price_in_currency2 = $price * 100; # 1:100比例 @@ -787,7 +793,7 @@ class Infinite extends Base } } } - + if ($goodsType['is_deduction'] == 0 && $iszhifu == 0 && $goodsType['pay_wechat'] == 0) { return $this->renderError('请选择支付方式'); } @@ -864,7 +870,7 @@ class Infinite extends Base 'order_num' => $order_num, ]; } - + if (resCheck($res)) { Db::commit(); #删除redis diff --git a/app/api/controller/Sign.php b/app/api/controller/Sign.php index 71dd465..7c7398f 100644 --- a/app/api/controller/Sign.php +++ b/app/api/controller/Sign.php @@ -143,7 +143,7 @@ class Sign extends Base if ($signDays >= $day) { $config['is_sign'] = 2; } else { - if ($nowDay == $day) { + if (($signDays + 1) == $day) { $config['is_sign'] = 1; } else { $config['is_sign'] = 0; diff --git a/app/api/controller/UserSign.php b/app/api/controller/UserSign.php deleted file mode 100755 index f2e67ad..0000000 --- a/app/api/controller/UserSign.php +++ /dev/null @@ -1,55 +0,0 @@ -getUser(); - - //获取签到信息 - $data = UserSignmodel::getListByUserId($user['id']); - $sign = []; - $sign['days'] = $data[0]; //连续签到天数 - $sign['is_sign'] = $data[1]; //今日是否签到 - $config = getConfig('sign'); - $sign_info = []; //签到奖励信息 - $sign_info[] = $config['one_num']; - $sign_info[] = $config['two_num']; - $sign_info[] = $config['three_num']; - $sign_info[] = $config['four_num']; - $sign_info[] = $config['five_num']; - $sign_info[] = $config['six_num']; - $sign_info[] = $config['seven_num']; - $sign['sign_info'] = $sign_info; - - return $this->renderSuccess("请求成功", compact('sign')); - } - - /** - * 签到 - */ - public function sign_add(Request $request) - { - $user = $this->getUser(); - $data = UserSignmodel::add($user['id']); - if ($data != '今日您已签到') { - return $this->renderSuccess($data['msg'], $data['data']); - } else { - return $this->renderError($data); - } - } - -} \ No newline at end of file diff --git a/app/api/route/app.php b/app/api/route/app.php index 09739d7..4c920c4 100755 --- a/app/api/route/app.php +++ b/app/api/route/app.php @@ -80,6 +80,8 @@ Route::any('quan_yi_ling', 'QuanYi/quan_yi_ling'); #Goods.php盒子管理 #============================ Route::any('goods', 'Goods/goods'); +Route::any('goods_fuliwu', 'Goods/goods_fuliwu'); + Route::any('goodsdetail', 'Goods/goodsdetail'); Route::any('goodslist_count', 'Goods/goodslist_count'); Route::any('goodslist_content', 'Goods/goodslist_content'); diff --git a/public/static/admin/reward-component.js b/public/static/admin/reward-component.js index 58d2e3f..1c67bf7 100644 --- a/public/static/admin/reward-component.js +++ b/public/static/admin/reward-component.js @@ -14,9 +14,9 @@ function initRewardInfo(containerId, existingRewards = null) { // 奖励类型选项 var rewardTypes = [ - { value: '1', text: '余额' }, - { value: '2', text: '货币1' }, - { value: '3', text: '货币2' }, + { value: '1', text: '钻石' }, + { value: '2', text: 'UU币' }, + { value: '3', text: '达达卷' }, { value: '4', text: '优惠券' } ]; @@ -36,6 +36,9 @@ function initRewardInfo(containerId, existingRewards = null) { '
' + '
' + '
'; + if ($('input[name="reward_id"]').length == 0) { + cardHtml += ''; + } // 渲染奖励信息卡片 $('#' + containerId).html(cardHtml); @@ -192,7 +195,7 @@ function initRewardInfo(containerId, existingRewards = null) { // 如果传入的是字符串(reward_id),则通过接口获取奖励数据 if (typeof existingRewards === 'string' && existingRewards.trim() !== '') { var rewardId = existingRewards; - + // 通过API获取奖励数据 var loadingIndex = layer.load(1, { shade: [0.1, '#fff'] }); $.ajax({ @@ -200,11 +203,14 @@ function initRewardInfo(containerId, existingRewards = null) { type: 'GET', data: { reward_id: rewardId }, dataType: 'json', - success: function(res) { + success: function (res) { layer.close(loadingIndex); if (res.status === 1 && res.data && res.data.length > 0) { // 先获取优惠券数据,再初始化奖励表单 - fetchCoupons(function() { + if ($('input[name="reward_id"]').length > 0) { + $('input[name="reward_id"]').val(rewardId); + } + fetchCoupons(function () { // 遍历奖励数据,添加奖励项 for (var i = 0; i < res.data.length; i++) { var rewardItem = { @@ -219,16 +225,16 @@ function initRewardInfo(containerId, existingRewards = null) { layer.msg('没有找到奖励数据或获取失败', { icon: 2, time: 2000 }); } }, - error: function() { + error: function () { layer.close(loadingIndex); layer.msg('网络错误,无法获取奖励数据', { icon: 2, time: 2000 }); } }); - } + } // 如果传入的是数组,直接使用 else if (Array.isArray(existingRewards) && existingRewards.length > 0) { // 先获取优惠券数据,再初始化奖励表单 - fetchCoupons(function() { + fetchCoupons(function () { for (var i = 0; i < existingRewards.length; i++) { addRewardItem(existingRewards[i]); } @@ -321,6 +327,64 @@ function processRewardData() { $('form').append(''); } + // 清除可能残留的旧字段(兼容性考虑) + $('input[name="reward_type[]"], input[name="reward_value[]"], input[name="coupon_id[]"]').remove(); +} + +/** + * 处理奖励数据,将其转换为JSON格式并添加到隐藏字段 + */ +async function processRewardIdData(pre, reward_id = '') { + var $ = layui.$; + var rewardData = []; + + // 收集所有奖励项的数据 + $('.reward-item').each(function () { + var $item = $(this); + var rewardType = $item.find('.reward-type-select').val(); + + if (rewardType) { + var rewardObj = { + reward_type: rewardType, + reward_value: '', + coupon_id: '' + }; + + // 根据奖励类型设置相应的值 + if (rewardType == '4') { // 优惠券类型 + rewardObj.coupon_id = $item.find('.coupon-select').val() || ''; + } else { // 其他类型 + rewardObj.reward_value = $item.find('.reward-value-input').val() || ''; + } + + rewardData.push(rewardObj); + } + }); + if (reward_id || reward_id == '') { + if ($('input[name="reward_id"]').length > 0) { + reward_id = $('input[name="reward_id"]').val(); + } + } + // 将奖励数据转换为JSON字符串 + var rewardJson = JSON.stringify(rewardData); + // reward_add_json + var url = "/admin/reward_add_json.html"; + var $ = layui.$; + var load = layer.load(2); + let l = await $.post(url, { reward: rewardJson, reward_id: reward_id, reward_id_pre: pre }); + layer.close(load); + console.log(l); + if (l && l.status === 1) { + reward_id = l.data.reward_id; + } + // 检查表单中是否已存在reward隐藏字段 + if ($('input[name="reward_id"]').length > 0) { + $('input[name="reward_id"]').val(reward_id); + } else { + // 创建隐藏字段并添加到表单中 + $('form').append(''); + } + // 清除可能残留的旧字段(兼容性考虑) $('input[name="reward_type[]"], input[name="reward_value[]"], input[name="coupon_id[]"]').remove(); } \ No newline at end of file diff --git a/public/ueditor/php/upload/image/20250402/1743585174596970.gif b/public/ueditor/php/upload/image/20250402/1743585174596970.gif new file mode 100644 index 0000000..3186701 Binary files /dev/null and b/public/ueditor/php/upload/image/20250402/1743585174596970.gif differ
等级名称 等级图标 发光特效
{$vo['id']} {$vo['title']} {if $vo['imgurl']}{/if} {if $vo['special_imgurl']}{/if} 奖品图片 奖品售价 奖品兑换价奖品数量{$vo['money']}{$vo['stock']}