diff --git a/app/admin/controller/Danye.php b/app/admin/controller/Danye.php index 780379b..7d65976 100755 --- a/app/admin/controller/Danye.php +++ b/app/admin/controller/Danye.php @@ -9,6 +9,7 @@ use app\common\model\Danye as DanyeModel; class Danye extends Base { + public $page = '50'; public function index() { $whe = []; @@ -47,7 +48,7 @@ class Danye extends Base if (!$info) { return $this->renderError('请求参数错误1'); } - if ($info['id'] != 1) { + if ($info['id'] != 1 && $info['id'] < 21) { unset($data['title']); } $data['update_time'] = time(); diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index bf6eb1c..55b3b7c 100755 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -142,7 +142,7 @@ class Goods extends Base } $data['prize_num'] = 0; $data['category_id'] = 0; - } elseif ($data['type'] == 2) { + } elseif ($data['type'] == 2 || $data['type'] == 16) { $data['stock'] = 0; $data['lock_is'] = 0; $data['lock_time'] = 0; @@ -390,7 +390,7 @@ class Goods extends Base } $data['prize_num'] = 0; $data['category_id'] = 0; - } elseif ($type == 2) { + } elseif ($type == 2 || $type == 16) { $data['stock'] = 0; $data['lock_is'] = 0; $data['lock_time'] = 0; @@ -573,6 +573,7 @@ class Goods extends Base } } + /** * 上、下架,删除盒子 */ @@ -613,45 +614,88 @@ class Goods extends Base return $this->renderError('请求参数错误'); } $type = $info['type']; - $title = trim(input('get.title')); - $lian_ji_type = input('get.lian_ji_type'); - $whe = array(); - $whe[] = ['goods_id', '=', $goods_id]; + + View::assign('goods_id', $goods_id); + View::assign('type', $type); + return View::fetch("Goods/goodslist"); + } + + /** + * 获取奖品列表数据(前后端分离接口) + */ + public function getGoodsListData(Request $request) + { + $goods_id = $request->param('goods_id/d', 0); + $page = $request->param('page/d', 1); + $limit = $request->param('limit/d', 50); + $title = $request->param('title/s', ''); + $lian_ji_type = $request->param('lian_ji_type/s', ''); + + $info = GoodsModel::where(['id' => $goods_id])->find(); + if (!$info) { + return $this->renderError('请求参数错误'); + } + $type = $info['type']; + + $where = []; + $where[] = ['goods_id', '=', $goods_id]; if ($type == 1 || $type == 3 || $type == 5 || $type == 6 || $type == 10 || $type == 11) { - $whe[] = ['num', '=', 1]; - } elseif ($type == 2 || $type == 8 || $type == 9 || $type == 15) { - $whe[] = ['num', '=', 0]; + $where[] = ['num', '=', 1]; + } elseif ($type == 2 || $type == 8 || $type == 9 || $type == 15 || $type == 16) { + $where[] = ['num', '=', 0]; } else { return $this->renderError('请求参数错误1'); } + if (!empty($title)) { - $whe[] = ['title', 'like', '%' . $title . '%']; + $where[] = ['title', 'like', "%{$title}%"]; } if (!empty($lian_ji_type)) { - $whe[] = ['lian_ji_type', '=', $lian_ji_type]; + $where[] = ['lian_ji_type', '=', $lian_ji_type]; } - $field = "*"; - $order = "sort desc,shang_id asc,id asc"; - $data = GoodsList::getList($whe, $field, $order, 150); - $real_pro = 0; - foreach ($data['list'] as &$value) { - $value['shang'] = Shang::where(['id' => $value['shang_id']])->value('title'); - // if ($value['goods_type'] == 2) { -// $value['sale_time'] = date('Y-m-d', $value['sale_time']); -// } else { -// $value['sale_time'] = ''; -// } - $real_pro += $value['real_pro']; - } - View::assign('list', $data['list']); - View::assign('count', $data['count']); - View::assign('page', $data['page']); - View::assign('goods_id', $goods_id); - View::assign('type', $type); - View::assign('real_pro', $real_pro); - return View::fetch("Goods/goodslist"); + $where[] = ['goods_list_id', '=', 0]; + $query = GoodsList::where($where)->order('sort desc, shang_id asc, id asc'); + $count = $query->count(); + + $list = $query->page($page, $limit)->select()->toArray(); + $real_pro = 0; + + // 处理数据 + foreach ($list as &$item) { + $item['shang'] = Shang::where(['id' => $item['shang_id']])->value('title'); + $item['imgurl'] = imageUrl($item['imgurl']); + if (!empty($item['imgurl_detail'])) { + $item['imgurl_detail'] = imageUrl($item['imgurl_detail']); + } + $real_pro += $item['real_pro']; + if ($item['goods_type'] == 4) { + $goods_list = GoodsList::where('goods_id', $item['goods_id']) + ->where('goods_list_id', '=', $item['id']) + ->select() + ->toArray(); + if ($goods_list) { + $item['isParent'] = 'true'; + $real_pro1 = 0; + + foreach ($goods_list as &$goods_list_item) { + $goods_list_item['shang'] = Shang::where(['id' => $goods_list_item['shang_id']])->value('title'); + $goods_list_item['imgurl'] = imageUrl($goods_list_item['imgurl']); + if (!empty($goods_list_item['imgurl_detail'])) { + $goods_list_item['imgurl_detail'] = imageUrl($goods_list_item['imgurl_detail']); + } + $real_pro1 += $goods_list_item['real_pro']; + } + if ($type == 2 || $type == 8 || $type == 9 || $type == 15 || $type == 16) { + $goods_list[] = ['title' => '宝箱概率合计', 'real_pro' => $real_pro1, 'id' => -1]; + } + $item['children'] = $goods_list; + } + } + } + + return $this->renderTable('获取成功', $count, $list, ['code' => 0, 'real_pro' => $real_pro]); } /** @@ -662,12 +706,16 @@ class Goods extends Base if (!$request->isPost()) { $goods_id = $request->param('goods_id/d', 0); $info = GoodsModel::where(['id' => $goods_id])->find(); + $goods_list_id = $request->param('goods_list_id/d', 0); if (!$info) { return $this->renderError('请求参数错误'); } if ($info['type'] == 1 || $info['type'] == 5 || $info['type'] == 10 || $info['type'] == 11 || $info['type'] == 6) { $shang = Shang::where('id', '<=', 33)->where('id', '<>', 5)->select()->toArray(); - } elseif ($info['type'] == 2 || $info['type'] == 8 || $info['type'] == 9) { + if( $goods_list_id){ + $shang = Shang::where('id', '<=', 33)->where('id', '>', 5)->select()->toArray(); + } + } elseif ($info['type'] == 2 || $info['type'] == 8 || $info['type'] == 9 || $info['type'] == 16) { $shang = Shang::where('id', 'between', [34, 38])->select()->toArray(); } elseif ($info['type'] == 3) { $shang = Shang::where('id', 'between', [4, 33])->select()->toArray(); @@ -678,6 +726,7 @@ class Goods extends Base } View::assign('shang', $shang); View::assign('goods_id', $goods_id); + View::assign('goods_list_id', $goods_list_id); View::assign('type', $info['type']); return View::fetch('Goods/goodslist_add'); } else { @@ -707,7 +756,7 @@ class Goods extends Base } if ($data['goods_type'] == 1) { $data['sale_time'] = 0; - } else if (in_array($data['goods_type'], [2, 8, 9])) { + } else if (in_array($data['goods_type'], [2, 8, 9, 16])) { if (empty($data['sale_time'])) { return $this->renderError('请选择预售时间'); } @@ -718,6 +767,8 @@ class Goods extends Base } } elseif ($type == 15) { $data['sale_time'] = 0; + } elseif ($data['goods_type'] == 3 || $data['goods_type'] == 4) { + $data['sale_time'] = 0; } else { return $this->err('奖品类型选择错误'); } @@ -745,9 +796,9 @@ class Goods extends Base $data['prize_code'] = $prize_code; $save_sports_data[] = $data; } - } elseif (in_array($type, [2, 8, 9])) { - if (RegMoney($data['real_pro'] * 100)) { - return $this->renderError('真实概率设置错误,最多保留两位小数1'); + } elseif (in_array($type, [2, 8, 9, 16])) { + if (RegMoney($data['real_pro'] * 10000)) { + return $this->renderError('真实概率设置错误,最多保留四位小数'); } $prize_code = getPrizeCode() . '_' . time(); @@ -817,6 +868,7 @@ class Goods extends Base if (!$request->isPost()) { $id = $request->param('id/d', 0); $goods = GoodsList::where(['id' => $id])->find(); + $goods_list_id = $request->param('goods_list_id/d', 0); if (!$goods) { return $this->renderError('请求参数错误'); } @@ -832,7 +884,10 @@ class Goods extends Base } if ($info['type'] == 1 || $info['type'] == 5 || $info['type'] == 6 || $info['type'] == 10 | $info['type'] == 11) { $shang = Shang::where('id', '<=', 33)->where('id', '<>', 5)->select()->toArray(); - } elseif ($info['type'] == 2 || $info['type'] == 8 || $info['type'] == 9) { + if( $goods_list_id){ + $shang = Shang::where('id', '<=', 33)->where('id', '>', 5)->select()->toArray(); + } + } elseif ($info['type'] == 2 || $info['type'] == 8 || $info['type'] == 9 || $info['type'] == 16) { $shang = Shang::where('id', 'between', [34, 38])->select()->toArray(); } elseif ($info['type'] == 15) { $shang = Shang::where('id', '>=', 114)->select()->toArray(); @@ -845,6 +900,7 @@ class Goods extends Base View::assign('goods', $goods); View::assign('shang', $shang); View::assign('type', $info['type']); + View::assign('goods_list_id', $goods_list_id); return View::fetch('Goods/goodslist_edit'); } else { @@ -887,7 +943,7 @@ class Goods extends Base if ($today_time >= $data['sale_time']) { return $this->renderError('预售时间请在今天之后'); } - } elseif ($data['goods_type'] == 3) { + } elseif ($data['goods_type'] == 3 || $data['goods_type'] == 4) { $data['sale_time'] = 0; } else { return $this->err('奖品类型选择错误'); @@ -899,9 +955,9 @@ class Goods extends Base 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)) { - return $this->renderError('真实概率设置错误,最多保留两位小数'); + } elseif ($type == 2 || $type == 8 || $type == 9 || $type == 16) { + if (RegMoney($data['real_pro'] * 10000)) { + return $this->renderError('真实概率设置错误,最多保留四位小数'); } } else if ($type == 3) { if (RegInt($data['prize_num']) && $data['shang_id'] == 5) { diff --git a/app/admin/route/app.php b/app/admin/route/app.php index 13fca4b..f754bb0 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -161,6 +161,7 @@ Route::rule('card_set', 'CardGoods/card_set', 'GET|POST'); #============================ Route::rule('goods', 'Goods/goods', 'GET|POST'); Route::rule('api/goods/list', 'Goods/getGoodsList', 'GET'); +Route::rule('getGoodsListData', 'Goods/getGoodsListData', 'GET|POST'); Route::rule('api/goods/types', 'Goods/getGoodsTypeList', 'GET'); Route::rule('goods_add', 'Goods/goods_add', 'GET|POST'); Route::rule('goods_edit', 'Goods/goods_edit', 'GET|POST'); diff --git a/app/admin/view/Danye/edit.html b/app/admin/view/Danye/edit.html index 3b2b575..9b27ccb 100755 --- a/app/admin/view/Danye/edit.html +++ b/app/admin/view/Danye/edit.html @@ -15,7 +15,7 @@
+ condition="$info['id'] lt 20" }readonly{/if}>
diff --git a/app/admin/view/Goods/goods_add.html b/app/admin/view/Goods/goods_add.html index c3afaf8..15d7080 100755 --- a/app/admin/view/Goods/goods_add.html +++ b/app/admin/view/Goods/goods_add.html @@ -21,9 +21,9 @@
- -
@@ -358,6 +358,8 @@ $(".lian_ji_num").hide(); $(".lian_ji_shang_id").hide(); form.on('radio(type)', function (data) { + console.log('aaa'); + var value = data.value; // 当前选中的value值 $("#div_daily_xiangou").show(); $("#goods_describe_div").hide(); @@ -382,7 +384,7 @@ $(".lingzhu_shang_id").hide(); $(".lian_ji_num").hide(); $(".lian_ji_shang_id").hide(); - } else if (value == 2) { + } else if (value == 2 || value == 16) { $(".id_stock").hide(); $(".id_lock_is").hide(); $(".id_lock_time").hide(); @@ -546,6 +548,13 @@ $('.xiajia-config').hide(); } }); + + // 首抽五折切换事件 + form.on('radio(shou_zhe)', function (data) { + // 仅记录选择,不做界面显示变化 + console.log('首抽五折设置为:', data.value); + }); + //执行实例 upload.render({ accept: 'imgurl' diff --git a/app/admin/view/Goods/goods_edit.html b/app/admin/view/Goods/goods_edit.html index 8427d86..8e7dcf6 100755 --- a/app/admin/view/Goods/goods_edit.html +++ b/app/admin/view/Goods/goods_edit.html @@ -21,9 +21,9 @@
- -
@@ -65,7 +65,8 @@ class="layui-input" style="width: 600px">
-
+ {if $type eq 15} +
-
+
-
+
+ {/if}
@@ -350,6 +352,12 @@ var value = data.value; // 当前选中的value值 type_switch(value); }); + + // 首抽五折切换事件 + form.on('radio(shou_zhe)', function (data) { + // 仅记录选择,不做界面显示变化 + console.log('首抽五折设置为:', data.value); + }); function type_switch(value) { $('#isshouwchou').show(); @@ -376,7 +384,7 @@ $(".lingzhu_shang_id").hide(); $(".lian_ji_num").hide(); $(".lian_ji_shang_id").hide(); - } else if (value == 2) { + } else if (value == 2 || value == 16) { $(".id_stock").hide(); $(".id_lock_is").hide(); $(".id_lock_time").hide(); @@ -534,6 +542,15 @@ } } + // 自动下架开关切换事件 + form.on('radio(autoXiajia)', function (data) { + if (data.value == "1") { + $('.xiajia-config').show(); + } else { + $('.xiajia-config').hide(); + } + }); + //执行实例 upload.render({ accept: 'imgurl' diff --git a/app/admin/view/Goods/goodslist.html b/app/admin/view/Goods/goodslist.html index cd385e9..cae4a4d 100755 --- a/app/admin/view/Goods/goodslist.html +++ b/app/admin/view/Goods/goodslist.html @@ -1,20 +1,20 @@ -{include file="Public:header2"/} +{include file="Public:header3"/}
-
+
- +
{if $type eq 9}
- @@ -24,165 +24,304 @@
{/if} - + +
-
- +
- -
- 添加奖品 - 共有数据: {$count}条 -
-
- - - - - - - - - {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} - - {/if} - {if $type eq 9} - - {/if} - - - - - - - - - {volist name="list" id="vo"} - - - - - - - {if $type eq 1} - {/if} - {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} - - {/if} - {if $type eq 9} - {if condition="$vo['lian_ji_type'] eq 0"} - - {elseif condition="$vo['lian_ji_type'] eq 1"} - - {/if} - {/if} - - - - - - - {/volist} - - {if condition="empty($list)"} - - - - {/if} - -
奖品名称奖品图片商品详情图奖品售价奖品兑换价奖品数量真实概率({$real_pro})奖池分类奖赏类型排序操作
{$vo['title']} - - {if condition="!empty($vo['imgurl_detail'])"} - - {else/} - - {/if} - {$vo['price']}{$vo['money']}{$vo['stock']}{$vo['real_pro']}%连击赏池秘宝池 - - {$vo['sort']} - - 编辑 - - 删除 - -
暂时没有数据!
-
- {$page|raw} +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
- {include file="Public:footer"/} + {include file="Public:footer3"/} + diff --git a/app/admin/view/Goods/goodslist_add.html b/app/admin/view/Goods/goodslist_add.html index c737934..3cfee41 100755 --- a/app/admin/view/Goods/goodslist_add.html +++ b/app/admin/view/Goods/goodslist_add.html @@ -28,14 +28,19 @@ {/if}
-
+
+ +
+ 货币:抽到后直接发放,不会到用户的盒柜里
+
@@ -68,7 +73,8 @@ class="layui-input">
- {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 6 || $type eq 11 || $type eq 15} + {if $type eq 1 || $type eq 3 || $type eq 5 || $type eq 10 || $type eq 6 || $type eq 11 + || $type eq 15}
@@ -87,7 +93,7 @@
{/if} - {if $type eq 2 || $type eq 8 || $type eq 9} + {if $type eq 2 || $type eq 8 || $type eq 9 || $type eq 16}
@@ -97,6 +103,16 @@
{/if} + {if $type eq 16} +
+ +
+ +
+
+ {/if} +