初始上传
This commit is contained in:
152
addon/scenefestival/api/controller/Config.php
Executable file
152
addon/scenefestival/api/controller/Config.php
Executable file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\api\controller;
|
||||
|
||||
use addon\scenefestival\model\Record;
|
||||
use addon\scenefestival\model\SceneFestival as Festival;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\member\Member;
|
||||
|
||||
/**
|
||||
* 会员节日有礼奖励
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 计算信息
|
||||
*/
|
||||
public function Config()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
//获取当前时间
|
||||
$time = time();
|
||||
|
||||
//获取满足条件的节日有礼活动
|
||||
$game_condition = [
|
||||
['status', 'in', '0,1'],
|
||||
['push_time', '<=', $time],
|
||||
['festival_type', '=', 'scenefestival'],
|
||||
['site_id', '=', $this->site_id]
|
||||
];
|
||||
|
||||
$festival_model = new Festival();
|
||||
$member_model = new Member();
|
||||
$field = 'festival_id,festival_type,site_id,activity_name,festival_type_name,remark,status,start_time,end_time,level_id,level_name,join_type,join_frequency,push_time';
|
||||
$festival_list = $festival_model->getFestivalList($game_condition, $field);
|
||||
|
||||
if (!empty($festival_list)) {
|
||||
foreach ($festival_list[ 'data' ] as $k => $v) {
|
||||
$flag = false;
|
||||
//获取会员信息
|
||||
if ($v[ 'level_id' ] == 0) {//所有会员
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $this->member_id ], [ 'site_id', '=', $this->site_id ] ], 'member_id,nickname,member_level,member_level_name')[ 'data' ];
|
||||
} else {
|
||||
$member_info = $member_model->getMemberInfo([ [ 'member_id', '=', $this->member_id ], [ 'site_id', '=', $this->site_id ], [ 'member_level', 'in', $v[ 'level_id' ] ] ], 'member_id,nickname,member_level,member_level_name')[ 'data' ];
|
||||
}
|
||||
// 判断今年有没有领取过
|
||||
$record = new Record();
|
||||
$start_year = date_to_time(date('Y-01-01 00:00:00'));
|
||||
$end_year = $start_year + 31535999;
|
||||
$record_condition[] = [ 'member_id', '=', $this->member_id ];
|
||||
$record_condition[] = [ 'festival_id', '=', $v[ 'festival_id' ] ];
|
||||
$record_condition[] = [ 'receive_time', '>', $start_year ];
|
||||
$record_condition[] = [ 'receive_time', '<', $end_year ];
|
||||
$record_data = $record->getFestivalDrawRecordList($record_condition, '*', 'receive_time desc')[ 'data' ];
|
||||
// 奖项
|
||||
$game_ward = $festival_model->getGameAward([ [ 'festival_id', '=', $v[ 'festival_id' ] ] ], 'award_id,award_type,coupon,point,balance,balance_type,balance_money')[ 'data' ];
|
||||
if (!empty($game_ward[ 'coupon_list' ])) {
|
||||
foreach ($game_ward[ 'coupon_list' ] as $coupon_k => &$coupon_v) {
|
||||
$coupon_flag = false;
|
||||
if ($coupon_v[ 'status' ] == 1) {
|
||||
if ($coupon_v[ 'count' ] == -1 || $coupon_v[ 'count' ] - $coupon_v[ 'lead_count' ] > 0) $coupon_flag = true;
|
||||
}
|
||||
$coupon_v[ 'coupon_flag' ] = $coupon_flag;
|
||||
}
|
||||
} else {
|
||||
$game_ward[ 'coupon_list' ] = [];
|
||||
}
|
||||
if (( isset($member_info) && !empty($member_info) ) && empty($record_data) && !empty($game_ward)) {
|
||||
$flag = true;
|
||||
}
|
||||
$festival_list[ 'data' ][ $k ][ 'award_list' ] = $game_ward;
|
||||
$festival_list[ 'data' ][ $k ][ 'nickname' ] = $member_info[ 'nickname' ];
|
||||
$festival_list[ 'data' ][ $k ][ 'flag' ] = $flag;
|
||||
}
|
||||
}
|
||||
return $this->response($festival_list);
|
||||
}
|
||||
|
||||
public function getFestivalDrawRecordList()
|
||||
{
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
//获取当前时间
|
||||
$time = time();
|
||||
//获取满足条件的节日有礼活动
|
||||
$game_condition = [
|
||||
[
|
||||
'status', 'in', '0,1'
|
||||
],
|
||||
[
|
||||
'push_time', '<=', $time
|
||||
],
|
||||
[
|
||||
'festival_type', '=', 'scenefestival'
|
||||
],
|
||||
[
|
||||
'site_id', '=', $this->site_id
|
||||
]
|
||||
];
|
||||
|
||||
$festival_model = new Festival();
|
||||
$field = 'festival_id,festival_type,site_id,activity_name,festival_type_name,remark,status,start_time,end_time,level_id,level_name,join_type,join_frequency,push_time';
|
||||
$festival_list = $festival_model->getFestivalList($game_condition, $field);
|
||||
|
||||
if (!empty($festival_list)) {
|
||||
foreach ($festival_list[ 'data' ] as $k => $v) {
|
||||
$flag = false;
|
||||
$record = new Record();
|
||||
$start_year = date_to_time(date('Y-01-01 00:00:00'));
|
||||
$end_year = $start_year + 31535999;
|
||||
$record_condition[] = [ 'member_id', '=', $this->member_id ];
|
||||
$record_condition[] = [ 'festival_id', '=', $v[ 'festival_id' ] ];
|
||||
$record_condition[] = [ 'receive_time', '>', $start_year ];
|
||||
$record_condition[] = [ 'receive_time', '<', $end_year ];
|
||||
$record_data = $record->getFestivalDrawRecordList($record_condition, '*', 'receive_time desc')[ 'data' ];
|
||||
if (empty($record_data)) {
|
||||
$flag = true;
|
||||
}
|
||||
$festival_list[ 'data' ][ $k ][ 'flag' ] = $flag;
|
||||
}
|
||||
}
|
||||
return $this->response($festival_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取节日有礼奖励
|
||||
*/
|
||||
public function receive()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$festival_id = $this->params[ 'festival_id' ];
|
||||
if (empty($festival_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$game = new Festival();
|
||||
$res = $game->receive($festival_id, $this->member_id, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
52
addon/scenefestival/config/diy_view.php
Executable file
52
addon/scenefestival/config/diy_view.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [
|
||||
// [
|
||||
// 'name' => 'SCENEFESTIVAL',
|
||||
// 'title' => '节日有礼',
|
||||
// 'parent' => 'INTERACTION_PROMOTION',
|
||||
// 'wap_url' => '',
|
||||
// 'web_url' => '',
|
||||
// 'sort' => 0,
|
||||
// 'child_list' => [
|
||||
//
|
||||
// ]
|
||||
// ],
|
||||
],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
23
addon/scenefestival/config/event.php
Executable file
23
addon/scenefestival/config/event.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\scenefestival\event\ShowPromotion',
|
||||
],
|
||||
'cronOpenFestival' => [
|
||||
'addon\scenefestival\event\OpenFestival',
|
||||
],
|
||||
'cronCloseFestival' => [
|
||||
'addon\scenefestival\event\CloseFestival',
|
||||
],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/scenefestival/config/info.php
Executable file
20
addon/scenefestival/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'scenefestival',
|
||||
'title' => '节日有礼',
|
||||
'description' => '节日有礼',
|
||||
'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
77
addon/scenefestival/config/menu_shop.php
Executable file
77
addon/scenefestival/config/menu_shop.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL',
|
||||
'title' => '节日有礼',
|
||||
'url' => 'scenefestival://shop/scenefestival/lists',
|
||||
'picture' => '',
|
||||
'picture_selected' => '',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'sort' => 102,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_LIST',
|
||||
'title' => '节日有礼',
|
||||
'url' => 'scenefestival://shop/scenefestival/lists',
|
||||
'is_show' => 0,
|
||||
'sort' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_ADD_SCENEFESTIVAL',
|
||||
'title' => '添加节日有礼活动',
|
||||
'url' => 'scenefestival://shop/scenefestival/add',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_EDIT_SCENEFESTIVAL',
|
||||
'title' => '编辑节日有礼活动',
|
||||
'url' => 'scenefestival://shop/scenefestival/edit',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_DETAIL_SCENEFESTIVAL',
|
||||
'title' => '节日有礼活动详情',
|
||||
'url' => 'scenefestival://shop/scenefestival/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_DELETE_SCENEFESTIVAL',
|
||||
'title' => '节日有礼活动删除',
|
||||
'url' => 'scenefestival://shop/scenefestival/delete',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_CLOSE_SCENEFESTIVAL',
|
||||
'title' => '关闭节日有礼活动',
|
||||
'url' => 'scenefestival://shop/scenefestival/close',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_SCENEFESTIVAL_RECORD_SCENEFESTIVAL',
|
||||
'title' => '节日有礼活动领取',
|
||||
'url' => 'scenefestival://shop/record/lists',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/scenefestival/data/install.sql
Executable file
1
addon/scenefestival/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/scenefestival/data/uninstall.sql
Executable file
1
addon/scenefestival/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
31
addon/scenefestival/event/CloseFestival.php
Executable file
31
addon/scenefestival/event/CloseFestival.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\scenefestival\event;
|
||||
|
||||
use addon\scenefestival\model\SceneFestival;
|
||||
|
||||
/**
|
||||
* 活动关闭
|
||||
*/
|
||||
class CloseFestival
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$festival_model = new SceneFestival();
|
||||
$res = $festival_model->cronCloseGames($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
25
addon/scenefestival/event/Install.php
Executable file
25
addon/scenefestival/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
31
addon/scenefestival/event/OpenFestival.php
Executable file
31
addon/scenefestival/event/OpenFestival.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\scenefestival\event;
|
||||
|
||||
use addon\scenefestival\model\SceneFestival;
|
||||
|
||||
/**
|
||||
* 活动关闭
|
||||
*/
|
||||
class OpenFestival
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$festival_model = new SceneFestival();
|
||||
$res = $festival_model->cronOpenGames($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
90
addon/scenefestival/event/ShowPromotion.php
Executable file
90
addon/scenefestival/event/ShowPromotion.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 店铺活动
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'scenefestival',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'member',
|
||||
//展示主题
|
||||
'title' => '节日有礼',
|
||||
//展示介绍
|
||||
'description' => '节日有礼',
|
||||
//展示图标
|
||||
'icon' => 'addon/scenefestival/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'scenefestival://shop/scenefestival/lists',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("promotion_festival")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$list = model("promotion_festival")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'status', '<>', 2 ],
|
||||
[ 'status', '<>', 3 ]
|
||||
], 'activity_name as promotion_name,festival_id as promotion_id,start_time,end_time');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#6699FF'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
25
addon/scenefestival/event/UnInstall.php
Executable file
25
addon/scenefestival/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/scenefestival/icon.png
Executable file
BIN
addon/scenefestival/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
432
addon/scenefestival/model/DayService.php
Executable file
432
addon/scenefestival/model/DayService.php
Executable file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/11/25
|
||||
* Time: 17:42
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
class DayService extends BaseModel
|
||||
{
|
||||
var $MIN_YEAR = 1891;
|
||||
var $MAX_YEAR = 2100;
|
||||
var $lunarInfo = array (
|
||||
array ( 0, 2, 9, 21936 ), array ( 6, 1, 30, 9656 ), array ( 0, 2, 17, 9584 ), array ( 0, 2, 6, 21168 ), array ( 5, 1, 26, 43344 ), array ( 0, 2, 13, 59728 ),
|
||||
array ( 0, 2, 2, 27296 ), array ( 3, 1, 22, 44368 ), array ( 0, 2, 10, 43856 ), array ( 8, 1, 30, 19304 ), array ( 0, 2, 19, 19168 ), array ( 0, 2, 8, 42352 ),
|
||||
array ( 5, 1, 29, 21096 ), array ( 0, 2, 16, 53856 ), array ( 0, 2, 4, 55632 ), array ( 4, 1, 25, 27304 ), array ( 0, 2, 13, 22176 ), array ( 0, 2, 2, 39632 ),
|
||||
array ( 2, 1, 22, 19176 ), array ( 0, 2, 10, 19168 ), array ( 6, 1, 30, 42200 ), array ( 0, 2, 18, 42192 ), array ( 0, 2, 6, 53840 ), array ( 5, 1, 26, 54568 ),
|
||||
array ( 0, 2, 14, 46400 ), array ( 0, 2, 3, 54944 ), array ( 2, 1, 23, 38608 ), array ( 0, 2, 11, 38320 ), array ( 7, 2, 1, 18872 ), array ( 0, 2, 20, 18800 ),
|
||||
array ( 0, 2, 8, 42160 ), array ( 5, 1, 28, 45656 ), array ( 0, 2, 16, 27216 ), array ( 0, 2, 5, 27968 ), array ( 4, 1, 24, 44456 ), array ( 0, 2, 13, 11104 ),
|
||||
array ( 0, 2, 2, 38256 ), array ( 2, 1, 23, 18808 ), array ( 0, 2, 10, 18800 ), array ( 6, 1, 30, 25776 ), array ( 0, 2, 17, 54432 ), array ( 0, 2, 6, 59984 ),
|
||||
array ( 5, 1, 26, 27976 ), array ( 0, 2, 14, 23248 ), array ( 0, 2, 4, 11104 ), array ( 3, 1, 24, 37744 ), array ( 0, 2, 11, 37600 ), array ( 7, 1, 31, 51560 ),
|
||||
array ( 0, 2, 19, 51536 ), array ( 0, 2, 8, 54432 ), array ( 6, 1, 27, 55888 ), array ( 0, 2, 15, 46416 ), array ( 0, 2, 5, 22176 ), array ( 4, 1, 25, 43736 ),
|
||||
array ( 0, 2, 13, 9680 ), array ( 0, 2, 2, 37584 ), array ( 2, 1, 22, 51544 ), array ( 0, 2, 10, 43344 ), array ( 7, 1, 29, 46248 ), array ( 0, 2, 17, 27808 ),
|
||||
array ( 0, 2, 6, 46416 ), array ( 5, 1, 27, 21928 ), array ( 0, 2, 14, 19872 ), array ( 0, 2, 3, 42416 ), array ( 3, 1, 24, 21176 ), array ( 0, 2, 12, 21168 ),
|
||||
array ( 8, 1, 31, 43344 ), array ( 0, 2, 18, 59728 ), array ( 0, 2, 8, 27296 ), array ( 6, 1, 28, 44368 ), array ( 0, 2, 15, 43856 ), array ( 0, 2, 5, 19296 ),
|
||||
array ( 4, 1, 25, 42352 ), array ( 0, 2, 13, 42352 ), array ( 0, 2, 2, 21088 ), array ( 3, 1, 21, 59696 ), array ( 0, 2, 9, 55632 ), array ( 7, 1, 30, 23208 ),
|
||||
array ( 0, 2, 17, 22176 ), array ( 0, 2, 6, 38608 ), array ( 5, 1, 27, 19176 ), array ( 0, 2, 15, 19152 ), array ( 0, 2, 3, 42192 ), array ( 4, 1, 23, 53864 ),
|
||||
array ( 0, 2, 11, 53840 ), array ( 8, 1, 31, 54568 ), array ( 0, 2, 18, 46400 ), array ( 0, 2, 7, 46752 ), array ( 6, 1, 28, 38608 ), array ( 0, 2, 16, 38320 ),
|
||||
array ( 0, 2, 5, 18864 ), array ( 4, 1, 25, 42168 ), array ( 0, 2, 13, 42160 ), array ( 10, 2, 2, 45656 ), array ( 0, 2, 20, 27216 ), array ( 0, 2, 9, 27968 ),
|
||||
array ( 6, 1, 29, 44448 ), array ( 0, 2, 17, 43872 ), array ( 0, 2, 6, 38256 ), array ( 5, 1, 27, 18808 ), array ( 0, 2, 15, 18800 ), array ( 0, 2, 4, 25776 ),
|
||||
array ( 3, 1, 23, 27216 ), array ( 0, 2, 10, 59984 ), array ( 8, 1, 31, 27432 ), array ( 0, 2, 19, 23232 ), array ( 0, 2, 7, 43872 ), array ( 5, 1, 28, 37736 ),
|
||||
array ( 0, 2, 16, 37600 ), array ( 0, 2, 5, 51552 ), array ( 4, 1, 24, 54440 ), array ( 0, 2, 12, 54432 ), array ( 0, 2, 1, 55888 ), array ( 2, 1, 22, 23208 ),
|
||||
array ( 0, 2, 9, 22176 ), array ( 7, 1, 29, 43736 ), array ( 0, 2, 18, 9680 ), array ( 0, 2, 7, 37584 ), array ( 5, 1, 26, 51544 ), array ( 0, 2, 14, 43344 ),
|
||||
array ( 0, 2, 3, 46240 ), array ( 4, 1, 23, 46416 ), array ( 0, 2, 10, 44368 ), array ( 9, 1, 31, 21928 ), array ( 0, 2, 19, 19360 ), array ( 0, 2, 8, 42416 ),
|
||||
array ( 6, 1, 28, 21176 ), array ( 0, 2, 16, 21168 ), array ( 0, 2, 5, 43312 ), array ( 4, 1, 25, 29864 ), array ( 0, 2, 12, 27296 ), array ( 0, 2, 1, 44368 ),
|
||||
array ( 2, 1, 22, 19880 ), array ( 0, 2, 10, 19296 ), array ( 6, 1, 29, 42352 ), array ( 0, 2, 17, 42208 ), array ( 0, 2, 6, 53856 ), array ( 5, 1, 26, 59696 ),
|
||||
array ( 0, 2, 13, 54576 ), array ( 0, 2, 3, 23200 ), array ( 3, 1, 23, 27472 ), array ( 0, 2, 11, 38608 ), array ( 11, 1, 31, 19176 ), array ( 0, 2, 19, 19152 ),
|
||||
array ( 0, 2, 8, 42192 ), array ( 6, 1, 28, 53848 ), array ( 0, 2, 15, 53840 ), array ( 0, 2, 4, 54560 ), array ( 5, 1, 24, 55968 ), array ( 0, 2, 12, 46496 ),
|
||||
array ( 0, 2, 1, 22224 ), array ( 2, 1, 22, 19160 ), array ( 0, 2, 10, 18864 ), array ( 7, 1, 30, 42168 ), array ( 0, 2, 17, 42160 ), array ( 0, 2, 6, 43600 ),
|
||||
array ( 5, 1, 26, 46376 ), array ( 0, 2, 14, 27936 ), array ( 0, 2, 2, 44448 ), array ( 3, 1, 23, 21936 ), array ( 0, 2, 11, 37744 ), array ( 8, 2, 1, 18808 ),
|
||||
array ( 0, 2, 19, 18800 ), array ( 0, 2, 8, 25776 ), array ( 6, 1, 28, 27216 ), array ( 0, 2, 15, 59984 ), array ( 0, 2, 4, 27424 ), array ( 4, 1, 24, 43872 ),
|
||||
array ( 0, 2, 12, 43744 ), array ( 0, 2, 2, 37600 ), array ( 3, 1, 21, 51568 ), array ( 0, 2, 9, 51552 ), array ( 7, 1, 29, 54440 ), array ( 0, 2, 17, 54432 ),
|
||||
array ( 0, 2, 5, 55888 ), array ( 5, 1, 26, 23208 ), array ( 0, 2, 14, 22176 ), array ( 0, 2, 3, 42704 ), array ( 4, 1, 23, 21224 ), array ( 0, 2, 11, 21200 ),
|
||||
array ( 8, 1, 31, 43352 ), array ( 0, 2, 19, 43344 ), array ( 0, 2, 7, 46240 ), array ( 6, 1, 27, 46416 ), array ( 0, 2, 15, 44368 ), array ( 0, 2, 5, 21920 ),
|
||||
array ( 4, 1, 24, 42448 ), array ( 0, 2, 12, 42416 ), array ( 0, 2, 2, 21168 ), array ( 3, 1, 22, 43320 ), array ( 0, 2, 9, 26928 ), array ( 7, 1, 29, 29336 ),
|
||||
array ( 0, 2, 17, 27296 ), array ( 0, 2, 6, 44368 ), array ( 5, 1, 26, 19880 ), array ( 0, 2, 14, 19296 ), array ( 0, 2, 3, 42352 ), array ( 4, 1, 24, 21104 ),
|
||||
array ( 0, 2, 10, 53856 ), array ( 8, 1, 30, 59696 ), array ( 0, 2, 18, 54560 ), array ( 0, 2, 7, 55968 ), array ( 6, 1, 27, 27472 ), array ( 0, 2, 15, 22224 ),
|
||||
array ( 0, 2, 5, 19168 ), array ( 4, 1, 25, 42216 ), array ( 0, 2, 12, 42192 ), array ( 0, 2, 1, 53584 ), array ( 2, 1, 21, 55592 ), array ( 0, 2, 9, 54560 )
|
||||
);
|
||||
|
||||
/**
|
||||
* 将阳历转换为阴历
|
||||
* @param year 公历-年
|
||||
* @param month 公历-月
|
||||
* @param date 公历-日
|
||||
*/
|
||||
function convertSolarToLunar($year, $month, $date)
|
||||
{
|
||||
//debugger;
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
if ($year == $this->MIN_YEAR && $month <= 2 && $date <= 9) return array ( 1891, '正月', '初一', '辛卯', 1, 1, '兔' );
|
||||
return $this->getLunarByBetween($year, $this->getDaysBetweenSolar($year, $month, $date, $yearData[ 1 ], $yearData[ 2 ]));
|
||||
}
|
||||
|
||||
function convertSolarMonthToLunar($year, $month, $date)
|
||||
{
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
if ($year == $this->MIN_YEAR && $month <= 2 && $date <= 9) return array ( 1891, '正月', '初一', '辛卯', 1, 1, '兔' );
|
||||
$month_days_ary = array ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
|
||||
$dd = $month_days_ary[ $month ];
|
||||
if ($this->isLeapYear($year) && $month == 2) $dd++;
|
||||
$lunar_ary = array ();
|
||||
for ($i = 1; $i < $dd; $i++) {
|
||||
$array = $this->getLunarByBetween($year, $this->getDaysBetweenSolar($year, $month, $i, $yearData[ 1 ], $yearData[ 2 ]));
|
||||
$array[] = $year . '-' . $month . '-' . $i;
|
||||
$lunar_ary[ $i ] = $array;
|
||||
}
|
||||
return $lunar_ary;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将阴历转换为阳历
|
||||
* @param year 阴历-年
|
||||
* @param month 阴历-月,闰月处理:例如如果当年闰五月,那么第二个五月就传六月,相当于阴历有13个月,只是有的时候第13个月的天数为0
|
||||
* @param date 阴历-日
|
||||
*/
|
||||
function convertLunarToSolar($year, $month, $date)
|
||||
{
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
$between = $this->getDaysBetweenLunar($year, $month, $date);
|
||||
$res = mktime(0, 0, 0, $yearData[ 1 ], $yearData[ 2 ], $year);
|
||||
$res = date('Y-m-d', $res + $between * 24 * 60 * 60);
|
||||
$day = explode('-', $res);
|
||||
$year = $day[ 0 ];
|
||||
$month = $day[ 1 ];
|
||||
$day = $day[ 2 ];
|
||||
return array ( $year, $month, $day );
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是闰年
|
||||
* @param year
|
||||
*/
|
||||
function isLeapYear($year)
|
||||
{
|
||||
return ( ( $year % 4 == 0 && $year % 100 != 0 ) || ( $year % 400 == 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取干支纪年
|
||||
* @param year
|
||||
*/
|
||||
function getLunarYearName($year)
|
||||
{
|
||||
$sky = array ( '庚', '辛', '壬', '癸', '甲', '乙', '丙', '丁', '戊', '己' );
|
||||
$earth = array ( '申', '酉', '戌', '亥', '子', '丑', '寅', '卯', '辰', '巳', '午', '未' );
|
||||
$year = $year . '';
|
||||
return $sky[ $year{3} ] . $earth[ $year % 12 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据阴历年获取生肖
|
||||
* @param year 阴历年
|
||||
*/
|
||||
function getYearZodiac($year)
|
||||
{
|
||||
$zodiac = array ( '猴', '鸡', '狗', '猪', '鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊' );
|
||||
return $zodiac[ $year % 12 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阳历月份的天数
|
||||
* @param year 阳历-年
|
||||
* @param month 阳历-月
|
||||
*/
|
||||
function getSolarMonthDays($year, $month)
|
||||
{
|
||||
$monthHash = array ( '1' => 31, '2' => $this->isLeapYear($year) ? 29 : 28, '3' => 31, '4' => 30, '5' => 31, '6' => 30, '7' => 31, '8' => 31, '9' => 30, '10' => 31, '11' => 30, '12' => 31 );
|
||||
return $monthHash[ "$month" ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阴历月份的天数
|
||||
* @param year 阴历-年
|
||||
* @param month 阴历-月,从一月开始
|
||||
*/
|
||||
function getLunarMonthDays($year, $month)
|
||||
{
|
||||
$monthData = $this->getLunarMonths($year);
|
||||
return $monthData[ $month - 1 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阴历每月的天数的数组
|
||||
* @param year
|
||||
*/
|
||||
function getLunarMonths($year)
|
||||
{
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
$leapMonth = $yearData[ 0 ];
|
||||
$bit = decbin($yearData[ 3 ]);
|
||||
for ($i = 0; $i < strlen($bit); $i++) $bitArray[ $i ] = substr($bit, $i, 1);
|
||||
for ($k = 0, $klen = 16 - count($bitArray); $k < $klen; $k++) array_unshift($bitArray, '0');
|
||||
$bitArray = array_slice($bitArray, 0, ( $leapMonth == 0 ? 12 : 13 ));
|
||||
for ($i = 0; $i < count($bitArray); $i++) $bitArray[ $i ] = $bitArray[ $i ] + 29;
|
||||
return $bitArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取农历每年的天数
|
||||
* @param year 农历年份
|
||||
*/
|
||||
function getLunarYearDays($year)
|
||||
{
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
$monthArray = $this->getLunarYearMonths($year);
|
||||
$len = count($monthArray);
|
||||
return ( $monthArray[ $len - 1 ] == 0 ? $monthArray[ $len - 2 ] : $monthArray[ $len - 1 ] );
|
||||
}
|
||||
|
||||
function getLunarYearMonths($year)
|
||||
{
|
||||
//debugger;
|
||||
$monthData = $this->getLunarMonths($year);
|
||||
$res = array ();
|
||||
$temp = 0;
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
$len = ( $yearData[ 0 ] == 0 ? 12 : 13 );
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$temp = 0;
|
||||
for ($j = 0; $j <= $i; $j++) $temp += $monthData[ $j ];
|
||||
$res[] = $temp;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取闰月
|
||||
* @param year 阴历年份
|
||||
*/
|
||||
function getLeapMonth($year)
|
||||
{
|
||||
$yearData = $this->lunarInfo[ $year - $this->MIN_YEAR ];
|
||||
return $yearData[ 0 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算阴历日期与正月初一相隔的天数
|
||||
* @param year
|
||||
* @param month
|
||||
* @param date
|
||||
*/
|
||||
function getDaysBetweenLunar($year, $month, $date)
|
||||
{
|
||||
$yearMonth = $this->getLunarMonths($year);
|
||||
$res = 0;
|
||||
for ($i = 1; $i < $month; $i++) $res += $yearMonth[ $i - 1 ];
|
||||
$res += $date - 1;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算2个阳历日期之间的天数
|
||||
* @param year 阳历年
|
||||
* @param cmonth
|
||||
* @param cdate
|
||||
* @param dmonth 阴历正月对应的阳历月份
|
||||
* @param ddate 阴历初一对应的阳历天数
|
||||
*/
|
||||
function getDaysBetweenSolar($year, $cmonth, $cdate, $dmonth, $ddate)
|
||||
{
|
||||
$a = mktime(0, 0, 0, $cmonth, $cdate, $year);
|
||||
$b = mktime(0, 0, 0, $dmonth, $ddate, $year);
|
||||
return ceil(( $a - $b ) / 24 / 3600);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据距离正月初一的天数计算阴历日期
|
||||
* @param year 阳历年
|
||||
* @param between 天数
|
||||
*/
|
||||
function getLunarByBetween($year, $between)
|
||||
{
|
||||
//debugger;
|
||||
$lunarArray = array ();
|
||||
$yearMonth = array ();
|
||||
$t = 0;
|
||||
$e = 0;
|
||||
$leapMonth = 0;
|
||||
$m = '';
|
||||
if ($between == 0) {
|
||||
array_push($lunarArray, $year, '01', '01');
|
||||
$t = 1;
|
||||
$e = 1;
|
||||
} else {
|
||||
$year = $between > 0 ? $year : ( $year - 1 );
|
||||
$yearMonth = $this->getLunarYearMonths($year);
|
||||
$leapMonth = $this->getLeapMonth($year);
|
||||
$between = $between > 0 ? $between : ( $this->getLunarYearDays($year) + $between );
|
||||
for ($i = 0; $i < 13; $i++) {
|
||||
if ($between == $yearMonth[ $i ]) {
|
||||
$t = $i + 2;
|
||||
$e = 1;
|
||||
break;
|
||||
} else if ($between < $yearMonth[ $i ]) {
|
||||
$t = $i + 1;
|
||||
$e = $between - ( empty($yearMonth[ $i - 1 ]) ? 0 : $yearMonth[ $i - 1 ] ) + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$m = ( $leapMonth != 0 && $t == $leapMonth + 1 ) ? ( '闰' . $this->getCapitalNum($t - 1, true) ) : $this->getCapitalNum(( $leapMonth != 0 && $leapMonth + 1 < $t ? ( $t - 1 ) : $t ), true);
|
||||
|
||||
array_push($lunarArray, $year, $m, $this->getCapitalNum($e, false));
|
||||
}
|
||||
|
||||
$lunarArray[] = $this->getLunarYearName($year);// 天干地支
|
||||
array_push($lunarArray, $t, $e);
|
||||
$lunarArray[] = $this->getYearZodiac($year);// 12生肖
|
||||
$lunarArray[] = $leapMonth;// 闰几月
|
||||
|
||||
return $lunarArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数字的阴历叫法
|
||||
* @param num 数字
|
||||
* @param isMonth 是否是月份的数字
|
||||
*/
|
||||
function getCapitalNum($num, $isMonth)
|
||||
{
|
||||
$isMonth = $isMonth || false;
|
||||
$dateHash = array ( '0' => '', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10' );
|
||||
$monthHash = array ( '0' => '', '1' => '01', '2' => '02', '3' => '03', '4' => '04', '5' => '05', '6' => '06', '7' => '07', '8' => '08', '9' => '09', '10' => '10', '11' => '11', '12' => '12' );
|
||||
$res = '';
|
||||
if ($isMonth) $res = $monthHash[ $num ];
|
||||
else {
|
||||
if ($num <= 10) $res = '0' . $dateHash[ $num ];
|
||||
else if ($num > 10 && $num < 20) $res = '1' . $dateHash[ $num - 10 ];
|
||||
else if ($num == 20) $res = '20';
|
||||
else if ($num > 20 && $num < 30) $res = '2' . $dateHash[ $num - 20 ];
|
||||
else if ($num == 30) $res = '30';
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* 节气通用算法
|
||||
*/
|
||||
function getJieQi($_year, $month, $day)
|
||||
{
|
||||
$year = substr($_year, -2) + 0;
|
||||
$coefficient = array (
|
||||
array ( 5.4055, 2019, -1 ),//小寒
|
||||
array ( 20.12, 2082, 1 ),//大寒
|
||||
array ( 3.87 ),//立春
|
||||
array ( 18.74, 2026, -1 ),//雨水
|
||||
array ( 5.63 ),//惊蛰
|
||||
array ( 20.646, 2084, 1 ),//春分
|
||||
array ( 4.81 ),//清明
|
||||
array ( 20.1 ),//谷雨
|
||||
array ( 5.52, 1911, 1 ),//立夏
|
||||
array ( 21.04, 2008, 1 ),//小满
|
||||
array ( 5.678, 1902, 1 ),//芒种
|
||||
array ( 21.37, 1928, 1 ),//夏至
|
||||
array ( 7.108, 2016, 1 ),//小暑
|
||||
array ( 22.83, 1922, 1 ),//大暑
|
||||
array ( 7.5, 2002, 1 ),//立秋
|
||||
array ( 23.13 ),//处暑
|
||||
array ( 7.646, 1927, 1 ),//白露
|
||||
array ( 23.042, 1942, 1 ),//秋分
|
||||
array ( 8.318 ),//寒露
|
||||
array ( 23.438, 2089, 1 ),//霜降
|
||||
array ( 7.438, 2089, 1 ),//立冬
|
||||
array ( 22.36, 1978, 1 ),//小雪
|
||||
array ( 7.18, 1954, 1 ),//大雪
|
||||
array ( 21.94, 2021, -1 )//冬至
|
||||
);
|
||||
$term_name = array (
|
||||
'小寒', '大寒', '立春', '雨水', '惊蛰', '春分', '清明', '谷雨',
|
||||
'立夏', '小满', '芒种', '夏至', '小暑', '大暑', '立秋', '处暑',
|
||||
'白露', '秋分', '寒露', '霜降', '立冬', '小雪', '大雪', '冬至');
|
||||
$idx1 = ( $month - 1 ) * 2;
|
||||
$_leap_value = floor(( $year - 1 ) / 4);
|
||||
$day1 = floor($year * 0.2422 + $coefficient[ $idx1 ][ 0 ]) - $_leap_value;
|
||||
if (isset($coefficient[ $idx1 ][ 1 ]) && $coefficient[ $idx1 ][ 1 ] == $_year) $day1 += $coefficient[ $idx1 ][ 2 ];
|
||||
$day2 = floor($year * 0.2422 + $coefficient[ $idx1 + 1 ][ 0 ]) - $_leap_value;
|
||||
if (isset($coefficient[ $idx1 + 1 ][ 1 ]) && $coefficient[ $idx1 + 1 ][ 1 ] == $_year) $day1 += $coefficient[ $idx1 + 1 ][ 2 ];
|
||||
//echo __FILE__.'->'.__LINE__.' $day1='.$day1,',$day2='.$day2.'<br/>'.chr(10);
|
||||
$data = array ();
|
||||
if ($day < $day1) {
|
||||
$data[ 'name1' ] = $term_name[ $idx1 - 1 ];
|
||||
$data[ 'name2' ] = $term_name[ $idx1 - 1 ] . '后';
|
||||
} else if ($day == $day1) {
|
||||
$data[ 'name1' ] = $term_name[ $idx1 ];
|
||||
$data[ 'name2' ] = $term_name[ $idx1 ];
|
||||
} else if ($day > $day1 && $day < $day2) {
|
||||
$data[ 'name1' ] = $term_name[ $idx1 ];
|
||||
$data[ 'name2' ] = $term_name[ $idx1 ] . '后';
|
||||
} else if ($day == $day2) {
|
||||
$data[ 'name1' ] = $term_name[ $idx1 + 1 ];
|
||||
$data[ 'name2' ] = $term_name[ $idx1 + 1 ];
|
||||
} else if ($day > $day2) {
|
||||
$data[ 'name1' ] = $term_name[ $idx1 + 1 ];
|
||||
$data[ 'name2' ] = $term_name[ $idx1 + 1 ] . '后';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取节日:特殊的节日只能修改此函数来计算
|
||||
*/
|
||||
function getFestival($today, $nl_info = false, $config = 1)
|
||||
{
|
||||
if ($config == 1) {
|
||||
$arr_lunar = array ( '01-01' => '春节', '01-15' => '元宵节', '02-02' => '二月二', '05-05' => '端午节', '07-07' => '七夕节', '08-15' => '中秋节', '09-09' => '重阳节', '12-08' => '腊八节', '12-23' => '小年' );
|
||||
$arr_solar = array ( '01-01' => '元旦', '02-14' => '情人节', '03-12' => '植树节', '04-01' => '愚人节', '05-01' => '劳动节', '06-01' => '儿童节', '10-01' => '国庆节', '10-31' => '万圣节', '12-24' => '平安夜', '12-25' => '圣诞节' );
|
||||
}//需要不同节日的,用不同的$config,然后配置$arr_lunar和$arr_solar
|
||||
$festivals = array ();
|
||||
list($y, $m, $d) = explode('-', $today);
|
||||
if (!$nl_info) $nl_info = $this->convertSolarToLunar($y, intval($m), intval($d));
|
||||
if ($nl_info[ 7 ] > 0 && $nl_info[ 7 ] < $nl_info[ 4 ]) $nl_info[ 4 ] -= 1;
|
||||
$md_lunar = substr('0' . $nl_info[ 4 ], -2) . '-' . substr('0' . $nl_info[ 5 ], -2);
|
||||
$md_solar = substr_replace($today, '', 0, 5);
|
||||
isset($arr_lunar[ $md_lunar ]) ? array_push($festivals, $arr_lunar[ $md_lunar ]) : '';
|
||||
isset($arr_solar[ $md_solar ]) ? array_push($festivals, $arr_solar[ $md_solar ]) : '';
|
||||
$glweek = date('w', strtotime($today)); //0-6
|
||||
if ($m == 5 && ( $d > 7 ) && ( $d < 15 ) && ( $glweek == 0 )) $festivals[] = '母亲节';
|
||||
if ($m == 6 && ( $d > 14 ) && ( $d < 22 ) && ( $glweek == 0 )) $festivals[] = '父亲节';
|
||||
$jieqi = $this->getJieQi($y, $m, $d);
|
||||
if ($jieqi) $festivals[] = $jieqi;
|
||||
return implode('/', $festivals);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取当前时间属于哪个时辰
|
||||
@param int $time 时间戳
|
||||
*/
|
||||
function getTheHour($h)
|
||||
{
|
||||
$d = $h;
|
||||
if ($d == 23 || $d == 0) {
|
||||
return '子时';
|
||||
} else if ($d == 1 || $d == 2) {
|
||||
return '丑时';
|
||||
} else if ($d == 3 || $d == 4) {
|
||||
return '寅时';
|
||||
} else if ($d == 5 || $d == 6) {
|
||||
return '卯时';
|
||||
} else if ($d == 7 || $d == 8) {
|
||||
return '辰时';
|
||||
} else if ($d == 9 || $d == 10) {
|
||||
return '巳时';
|
||||
} else if ($d == 11 || $d == 12) {
|
||||
return '午时';
|
||||
} else if ($d == 13 || $d == 14) {
|
||||
return '未时';
|
||||
} else if ($d == 15 || $d == 16) {
|
||||
return '申时';
|
||||
} else if ($d == 17 || $d == 18) {
|
||||
return '酉时';
|
||||
} else if ($d == 19 || $d == 20) {
|
||||
return '戌时';
|
||||
} else if ($d == 21 || $d == 22) {
|
||||
return '亥时';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
71
addon/scenefestival/model/Record.php
Executable file
71
addon/scenefestival/model/Record.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 领取记录
|
||||
*/
|
||||
class Record extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取领取记录列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getFestivalDrawRecordList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('promotion_festival_draw_record')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取领取记录分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getGamesDrawRecordPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [])
|
||||
{
|
||||
$list = model('promotion_festival_draw_record')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
|
||||
if (!empty($list[ 'list' ])) {
|
||||
foreach ($list[ 'list' ] as $awark_k => $awark_v) {
|
||||
$list[ 'list' ][ $awark_k ][ 'coupon_name' ] = '';
|
||||
if (!empty($awark_v[ 'coupon' ])) {
|
||||
$coupon_info = model('promotion_coupon_type')->getList([ [ 'coupon_type_id', 'in', $awark_v[ 'coupon' ] ] ], 'coupon_type_id,coupon_name,count,lead_count');
|
||||
if (!empty($coupon_info)) {
|
||||
$coupon_name = '';
|
||||
foreach ($coupon_info as $k => $v) {
|
||||
if ($v[ 'count' ] < 0 || $v[ 'count' ] - $v[ 'lead_count' ] > 0) {
|
||||
$coupon_name .= $v[ 'coupon_name' ];
|
||||
}
|
||||
}
|
||||
$coupon_name = ltrim($coupon_name, ',');
|
||||
$list[ 'list' ][ $awark_k ][ 'coupon_name' ] = $coupon_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
528
addon/scenefestival/model/SceneFestival.php
Executable file
528
addon/scenefestival/model/SceneFestival.php
Executable file
@@ -0,0 +1,528 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\model;
|
||||
|
||||
|
||||
use addon\coupon\model\Coupon;
|
||||
use addon\coupon\model\CouponType;
|
||||
use app\dict\member_account\AccountDict;
|
||||
use app\model\BaseModel;
|
||||
use app\model\member\MemberAccount;
|
||||
use app\model\system\Cron;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动
|
||||
*/
|
||||
class SceneFestival extends BaseModel
|
||||
{
|
||||
public $status = [
|
||||
0 => '未开始',
|
||||
1 => '进行中',
|
||||
2 => '已结束',
|
||||
3 => '已关闭',
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
* @param $game_data
|
||||
* @param $award_json
|
||||
* @return array
|
||||
*/
|
||||
public function addFestival($festival_data, $award_arr)
|
||||
{
|
||||
Cache::clear();
|
||||
model('promotion_festival')->startTrans();
|
||||
try {
|
||||
$condition = [
|
||||
[ 'status', 'in', '0,1' ],
|
||||
[ 'site_id', '=', $festival_data[ 'site_id' ] ],
|
||||
[ '', 'exp', Db::raw('not ( (`push_time` > ' . $festival_data[ 'end_time' ] . ' and `push_time` > ' . $festival_data[ 'push_time' ] . ' ) or (`end_time` < ' . $festival_data[ 'push_time' ] . ' and `end_time` < ' . $festival_data[ 'end_time' ] . '))') ]
|
||||
];
|
||||
$res = model('promotion_festival')->getList($condition, 'festival_id');
|
||||
if (!empty($res)) {
|
||||
return $this->error('', "当前时间段已有相同的活动");
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$festival_data[ 'create_time' ] = $time;
|
||||
|
||||
if ($time > $festival_data[ 'push_time' ] && $time < $festival_data[ 'end_time' ]) {
|
||||
$festival_data[ 'status' ] = 1;
|
||||
} else {
|
||||
$festival_data[ 'status' ] = 0;
|
||||
}
|
||||
|
||||
$festival_id = model('promotion_festival')->add($festival_data);
|
||||
$award_arr[ 'site_id' ] = $festival_data[ 'site_id' ];
|
||||
$award_arr[ 'festival_id' ] = $festival_id;
|
||||
model('promotion_festival_award')->add($award_arr);
|
||||
|
||||
$cron = new Cron();
|
||||
if ($festival_data[ 'status' ] == 1) {//进行中
|
||||
|
||||
$cron->addCron(1, 0, "节日有礼活动关闭", "cronCloseFestival", $festival_data[ 'end_time' ], $festival_id);
|
||||
} else {//未进行
|
||||
$cron->addCron(1, 0, "节日有礼活动开启", "cronOpenFestival", $festival_data[ 'push_time' ], $festival_id);
|
||||
$cron->addCron(1, 0, "节日有礼活动关闭", "cronCloseFestival", $festival_data[ 'end_time' ], $festival_id);
|
||||
}
|
||||
|
||||
model('promotion_festival')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_festival')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
* @param $condition
|
||||
* @param $game_data
|
||||
* @param $award_json
|
||||
* @return array
|
||||
*/
|
||||
public function editGames($condition, $festival_data, $award_data)
|
||||
{
|
||||
|
||||
$festival_info = model('promotion_festival')->getInfo($condition, 'festival_id,status');
|
||||
if (in_array($festival_info[ 'status' ], [ 2, 3 ])) {
|
||||
return $this->error('', '已关闭或已结束的活动不能编辑');
|
||||
}
|
||||
$festival_id = $festival_info[ 'festival_id' ];
|
||||
|
||||
$verify_condition = [
|
||||
[ 'festival_id', '<>', $festival_id ],
|
||||
[ 'status', 'in', '1,2' ],
|
||||
[ 'site_id', '=', $festival_data[ 'site_id' ] ],
|
||||
[ '', 'exp', Db::raw('not ( (`push_time` > ' . $festival_data[ 'end_time' ] . ' and `push_time` > ' . $festival_data[ 'push_time' ] . ' ) or (`end_time` < ' . $festival_data[ 'push_time' ] . ' and `end_time` < ' . $festival_data[ 'end_time' ] . '))') ]
|
||||
];
|
||||
$res = model('promotion_festival')->getList($verify_condition, 'festival_id');
|
||||
if (!empty($res)) {
|
||||
return $this->error('', "当前时间段已有相同的活动");
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$festival_data[ 'update_time' ] = $time;
|
||||
|
||||
if ($time > $festival_data[ 'push_time' ] && $time < $festival_data[ 'end_time' ]) {
|
||||
$festival_data[ 'status' ] = 1;
|
||||
} else {
|
||||
$festival_data[ 'status' ] = 0;
|
||||
}
|
||||
model('promotion_festival')->startTrans();
|
||||
try {
|
||||
|
||||
model('promotion_festival')->update($festival_data, $condition);
|
||||
|
||||
model('promotion_festival_award')->update($award_data, [ [ 'festival_id', '=', $festival_id ] ]);
|
||||
|
||||
$cron = new Cron();
|
||||
|
||||
$cron->deleteCron([ [ 'event', '=', 'cronOpenFestival' ], [ 'relate_id', '=', $festival_id ] ]);
|
||||
$cron->deleteCron([ [ 'event', '=', 'cronCloseFestival' ], [ 'relate_id', '=', $festival_id ] ]);
|
||||
|
||||
if ($festival_data[ 'status' ] == 1) {//进行中
|
||||
|
||||
$cron->addCron(1, 0, "节日有礼活动关闭", "cronCloseFestival", $festival_data[ 'end_time' ], $festival_id);
|
||||
} else {
|
||||
//未进行
|
||||
$cron->addCron(1, 0, "节日有礼活动开启", "cronOpenFestival", $festival_data[ 'push_time' ], $festival_id);
|
||||
$cron->addCron(1, 0, "节日有礼活动关闭", "cronCloseFestival", $festival_data[ 'end_time' ], $festival_id);
|
||||
}
|
||||
|
||||
model('promotion_festival')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_festival')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动奖励
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
*/
|
||||
public function getGameAward($condition = [], $field = '*')
|
||||
{
|
||||
$award_info = model('promotion_festival_award')->getInfo($condition, $field);
|
||||
if (!empty($award_info)) {
|
||||
$award_info[ 'award_type' ] = explode(',', $award_info[ 'award_type' ]);
|
||||
//获取优惠券信息
|
||||
if (isset($award_info[ 'coupon' ]) && !empty($award_info[ 'coupon' ])) {
|
||||
//优惠券字段
|
||||
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
|
||||
|
||||
$model = new CouponType();
|
||||
$coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $award_info[ 'coupon' ] ] ], $coupon_field);
|
||||
$award_info[ 'coupon_list' ] = $coupon[ 'data' ];
|
||||
}
|
||||
}
|
||||
return $this->success($award_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
*/
|
||||
public function getGamesInfo($condition, $field = '*')
|
||||
{
|
||||
$res = model('promotion_festival')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动有礼详情
|
||||
*/
|
||||
public function getFestivalDetail($condition, $field, $alias = 'a', $join = [])
|
||||
{
|
||||
|
||||
$res = model('promotion_festival')->getInfo($condition, $field, $alias, $join);
|
||||
if (!empty($res)) {
|
||||
$res[ 'award_type' ] = explode(',', $res[ 'award_type' ]);
|
||||
//获取优惠券信息
|
||||
if (isset($res[ 'coupon' ]) && !empty($res[ 'coupon' ])) {
|
||||
//优惠券字段
|
||||
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
|
||||
|
||||
$model = new CouponType();
|
||||
$coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $res[ 'coupon' ] ] ], $coupon_field);
|
||||
$res[ 'coupon_list' ] = $coupon[ 'data' ];
|
||||
$res[ 'coupon_ids' ] = explode(',', $res[ 'coupon' ]);
|
||||
} else {
|
||||
$res[ 'coupon_ids' ] = [];
|
||||
}
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动
|
||||
* @param $site_id
|
||||
* @param $game_id
|
||||
* @return array
|
||||
*/
|
||||
public function deleteGames($site_id, $festival_id)
|
||||
{
|
||||
model('promotion_festival')->startTrans();
|
||||
try {
|
||||
model('promotion_festival')->delete([ [ 'site_id', '=', $site_id ], [ 'festival_id', '=', $festival_id ] ]);
|
||||
model('promotion_festival_award')->delete([ [ 'site_id', '=', $site_id ], [ 'festival_id', '=', $festival_id ] ]);
|
||||
model('promotion_festival')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_festival')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getFestivalList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('promotion_festival')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getGamesPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = model('promotion_festival')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
* @param $site_id
|
||||
* @param $game_id
|
||||
* @return array
|
||||
*/
|
||||
public function finishGames($site_id, $festival_id)
|
||||
{
|
||||
$game_info = model('promotion_festival')->getInfo([ [ 'festival_id', '=', $festival_id ], [ 'site_id', '=', $site_id ] ], 'status');
|
||||
if (!empty($game_info)) {
|
||||
|
||||
if ($game_info[ 'status' ] != 3) {
|
||||
$res = model('promotion_festival')->update([ 'status' => 3 ], [ [ 'festival_id', '=', $festival_id ] ]);
|
||||
// if ($res) {
|
||||
// $cron = new Cron();
|
||||
// $cron->deleteCron([ [ 'event', '=', 'OpenGame' ], [ 'relate_id', '=', $game_id ] ]);
|
||||
// $cron->deleteCron([ [ 'event', '=', 'CloseGame' ], [ 'relate_id', '=', $game_id ] ]);
|
||||
// }
|
||||
return $this->success($res);
|
||||
} else {
|
||||
$this->error('', '该活动已关闭');
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->error('', '该活动不存在');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务开启活动
|
||||
* @param $game_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function cronOpenGames($game_id)
|
||||
{
|
||||
$game_info = model('promotion_festival')->getInfo([ [ 'festival_id', '=', $game_id ] ], 'start_time,push_time,status');
|
||||
if (!empty($game_info)) {
|
||||
|
||||
if ($game_info[ 'start_time' ] <= time() && $game_info[ 'status' ] == 0) {
|
||||
$res = model('promotion_festival')->update([ 'status' => 1 ], [ [ 'festival_id', '=', $game_id ] ]);
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error("", "活动已开启或者关闭");
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error("", "活动不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启活动
|
||||
* @param $game_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function startGames($festival_id)
|
||||
{
|
||||
$game_info = model('promotion_festival')->getInfo([ [ 'festival_id', '=', $festival_id ] ], 'end_time,status');
|
||||
if (!empty($game_info)) {
|
||||
|
||||
if ($game_info[ 'end_time' ] >= time()) {
|
||||
$res = model('promotion_festival')->update([ 'status' => 1 ], [ [ 'festival_id', '=', $festival_id ] ]);
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error("", "活动已结束");
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error("", "活动不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务关闭活动
|
||||
* @param $game_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function cronCloseGames($festival_id)
|
||||
{
|
||||
$game_info = model('promotion_festival')->getInfo([ [ 'festival_id', '=', $festival_id ] ], 'start_time,status');
|
||||
if (!empty($game_info)) {
|
||||
if ($game_info[ 'status' ] != 2) {
|
||||
$res = model('promotion_festival')->update([ 'status' => 2 ], [ [ 'festival_id', '=', $festival_id ] ]);
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error("", "该活动已结束");
|
||||
}
|
||||
} else {
|
||||
return $this->error("", "活动不存在");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 节日有礼领取
|
||||
* @param $game_id
|
||||
* @param $member_id
|
||||
* @param $site_id
|
||||
*/
|
||||
public function receive($festival_id, $member_id, $site_id)
|
||||
{
|
||||
$game_info = model('promotion_festival')->getInfo([ [ 'festival_id', '=', $festival_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
if (empty($game_info)) return $this->error("", "未获取到活动信息");
|
||||
|
||||
if ($game_info[ 'status' ] == 2 || $game_info[ 'status' ] == 3) return $this->error("", "活动已经结束");
|
||||
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ], [ 'status', '=', 1 ] ], 'nickname,member_level,point');
|
||||
if (empty($member_info)) return $this->error("", "未获取到会员信息");
|
||||
|
||||
if (!empty($game_info[ 'level_id' ])) {
|
||||
$level = explode(',', $game_info[ 'level_id' ]);
|
||||
if (!in_array($member_info[ 'member_level' ], $level)) {
|
||||
return $this->error("", "只有{$game_info['level_name']}等级的会员可参与该活动");
|
||||
}
|
||||
}
|
||||
|
||||
// 判断今年有没有领取过
|
||||
$record_model = new Record();
|
||||
$start_year = date_to_time(date('Y-01-01 00:00:00'));
|
||||
$end_year = $start_year + 31535999;
|
||||
$record_condition[] = [ 'member_id', '=', $member_id];
|
||||
$record_condition[] = [ 'festival_id', '=', $festival_id ];
|
||||
$record_condition[] = [ 'receive_time', '>', $start_year ];
|
||||
$record_condition[] = [ 'receive_time', '<', $end_year ];
|
||||
$record_data = $record_model->getFestivalDrawRecordList($record_condition, 'record_id', 'receive_time desc')[ 'data' ];
|
||||
if (!empty($record_data)) {
|
||||
return $this->error('', "今年您已经领取过节日有礼奖励啦");
|
||||
}
|
||||
|
||||
model('promotion_festival_draw_record')->startTrans();
|
||||
try {
|
||||
$member_account = new MemberAccount();
|
||||
$award_info = model('promotion_festival_award')->getInfo([ [ 'festival_id', '=', $festival_id ] ], 'award_id,festival_id,award_type,coupon,point,balance,balance_type,balance_money');
|
||||
|
||||
if (!empty($award_info)) {
|
||||
$type_arr = explode(',', $award_info[ 'award_type' ]);
|
||||
foreach ($type_arr as $v) {
|
||||
switch ( $v ) {
|
||||
case 'point':
|
||||
// 积分
|
||||
$member_account->addMemberAccount($site_id, $member_id, 'point', $award_info[ 'point' ], $game_info[ 'festival_type' ], $festival_id, '节日有礼活动奖励发放');
|
||||
break;
|
||||
case 'balance':
|
||||
// 余额
|
||||
if ($award_info[ 'balance_type' ] == 0) {
|
||||
$member_account->addMemberAccount($site_id, $member_id, AccountDict::balance, $award_info[ 'balance' ], $game_info[ 'festival_type' ], $festival_id, '节日有礼活动奖励发放');
|
||||
} else {
|
||||
$member_account->addMemberAccount($site_id, $member_id, 'balance_money', $award_info[ 'balance_money' ], $game_info[ 'festival_type' ], $festival_id, '节日有礼活动奖励发放');
|
||||
}
|
||||
|
||||
break;
|
||||
case 'coupon':
|
||||
// 优惠券
|
||||
$coupon = new Coupon();
|
||||
$coupon_array = explode(',', $award_info[ 'coupon' ]);
|
||||
$coupon_array = array_map(function($value) {
|
||||
return [ 'coupon_type_id' => $value, 'num' => 1 ];
|
||||
}, $coupon_array);
|
||||
$receive_res = $coupon->giveCoupon($coupon_array, $site_id, $member_id, Coupon::GET_TYPE_ACTIVITY_GIVE);
|
||||
break;
|
||||
case 4:
|
||||
// 赠品
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
$record[ 'award_id' ] = $award_info[ 'award_id' ];
|
||||
$record[ 'festival_id' ] = $award_info[ 'festival_id' ];
|
||||
$record[ 'festival_type' ] = $game_info[ 'festival_type' ];
|
||||
$record[ 'member_id' ] = $member_id;
|
||||
$record[ 'site_id' ] = $site_id;
|
||||
$record[ 'receive_time' ] = time();
|
||||
$record[ 'member_nick_name' ] = $member_info[ 'nickname' ];
|
||||
|
||||
model('promotion_festival_draw_record')->add($record);
|
||||
}
|
||||
|
||||
model('promotion_festival_draw_record')->commit();
|
||||
return $this->success([ 'status' => 1 ]);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_festival_draw_record')->rollback();
|
||||
return $this->error("", $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广二维码
|
||||
* @param $game_id
|
||||
* @param $game_name
|
||||
* @param $url
|
||||
* @param $site_id
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function qrcode($festival_id, $game_name, $url, $site_id, $type = "create")
|
||||
{
|
||||
$data = [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => "all", // all为全部
|
||||
'type' => $type, // 类型 create创建 get获取
|
||||
'data' => [
|
||||
"id" => $festival_id
|
||||
],
|
||||
'page' => $url,
|
||||
'qrcode_path' => 'upload/qrcode/games',
|
||||
'qrcode_name' => "games_qrcode_" . $festival_id
|
||||
];
|
||||
|
||||
event('Qrcode', $data, true);
|
||||
$app_type_list = config('app_type');
|
||||
$path = [];
|
||||
foreach ($app_type_list as $k => $v) {
|
||||
switch ( $k ) {
|
||||
case 'h5':
|
||||
$wap_domain = getH5Domain();
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?id=' . $festival_id;
|
||||
$path[ $k ][ 'img' ] = "upload/qrcode/games/games_qrcode_" . $festival_id . "_" . $k . ".png";
|
||||
break;
|
||||
case 'weapp' :
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信小程序';
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
|
||||
}
|
||||
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信小程序';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'wechat' :
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
|
||||
if (!empty($res[ 'data' ])) {
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信公众号';
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 1;
|
||||
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
|
||||
}
|
||||
} else {
|
||||
$path[ $k ][ 'status' ] = 2;
|
||||
$path[ $k ][ 'message' ] = '未配置微信公众号';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$return = [
|
||||
'path' => $path,
|
||||
'game_name' => $game_name,
|
||||
];
|
||||
|
||||
return $this->success($return);
|
||||
}
|
||||
|
||||
}
|
||||
77
addon/scenefestival/shop/controller/Record.php
Executable file
77
addon/scenefestival/shop/controller/Record.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\shop\controller;
|
||||
|
||||
use addon\scenefestival\model\Record as RecordModel;
|
||||
use addon\scenefestival\model\SceneFestival as Festival;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
/**
|
||||
* 节日有礼活动领取记录
|
||||
*/
|
||||
class Record extends BaseShop
|
||||
{
|
||||
/*
|
||||
* 领取记录
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$game_id = input('festival_id');
|
||||
if (request()->isJson()) {
|
||||
$condition = [
|
||||
[ 'pfdr.site_id', '=', $this->site_id ],
|
||||
[ 'pfdr.festival_id', '=', $game_id ]
|
||||
];
|
||||
|
||||
//会员昵称
|
||||
$member_nick_name = input('member_nick_name', '');
|
||||
if ($member_nick_name) {
|
||||
$condition[] = [ 'pfdr.member_nick_name', 'like', '%' . $member_nick_name . '%' ];
|
||||
}
|
||||
//参与时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && $end_time) {
|
||||
$condition[] = [ 'pfdr.receive_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
} else if (!$start_time && $end_time) {
|
||||
$condition[] = [ 'pfdr.receive_time', '<=', date_to_time($end_time) ];
|
||||
} else if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'pfdr.receive_time', '>=', date_to_time($start_time) ];
|
||||
}
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$alias = 'pfdr';
|
||||
$join = [
|
||||
[
|
||||
'promotion_festival_award pfa',
|
||||
'pfa.award_id = pfdr.award_id',
|
||||
'left'
|
||||
],
|
||||
];
|
||||
$fields = 'pfdr.*,pfa.award_type,pfa.coupon,pfa.point,pfa.balance,pfa.balance_type,pfa.balance_money';
|
||||
$model = new RecordModel();
|
||||
$list = $model->getGamesDrawRecordPageList($condition, $page, $page_size, 'pfdr.record_id desc', $fields, $alias, $join);
|
||||
return $list;
|
||||
|
||||
} else {
|
||||
|
||||
$this->assign('festival_id', $game_id);
|
||||
//游戏活动信息
|
||||
$game_model = new Festival();
|
||||
$game_info = $game_model->getGamesInfo([ [ 'site_id', '=', $this->site_id ], [ 'festival_id', '=', $game_id ] ]);
|
||||
if (empty($game_info[ 'data' ])) $this->error('未获取到活动数据', href_url('scenefestival://shop/scenefestival/lists'));
|
||||
$this->assign('game_info', $game_info[ 'data' ]);
|
||||
return $this->fetch("record/lists");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
361
addon/scenefestival/shop/controller/Scenefestival.php
Executable file
361
addon/scenefestival/shop/controller/Scenefestival.php
Executable file
@@ -0,0 +1,361 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\scenefestival\shop\controller;
|
||||
|
||||
use addon\coupon\model\CouponType;
|
||||
use addon\scenefestival\model\SceneFestival as Festival;
|
||||
use app\model\member\MemberLevel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 节日有礼控制器
|
||||
*/
|
||||
class Scenefestival extends BaseShop
|
||||
{
|
||||
//活动类型
|
||||
private $game_type = 'scenefestival';
|
||||
private $game_type_name = '节日有礼';
|
||||
private $festival_url = '/pages_promotion/game/turntable';
|
||||
|
||||
/*
|
||||
* 节日有礼活动列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$model = new Festival();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'festival_type', '=', $this->game_type ]
|
||||
];
|
||||
|
||||
$status = input('status', '');//节日有礼状态
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
//活动名称
|
||||
$activity_name = input('activity_name', '');
|
||||
if ($activity_name) {
|
||||
$condition[] = [ 'activity_name', 'like', '%' . $activity_name . '%' ];
|
||||
}
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
$list = $model->getGamesPageList($condition, $page, $page_size, 'festival_id desc');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch("scenefestival/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$model = new Festival();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$holiday_time = input('holiday_time', '');
|
||||
$days = input('join_frequency', '1');
|
||||
$join_type = input('join_type', 1);
|
||||
$join_time = input('join_time', '0'); //1传统节日 0自定义节日
|
||||
if ($join_time == 1) {
|
||||
$holiday_name = input('holiday_name', '');
|
||||
$date = substr($holiday_time, '0', '4') . '-' . substr($holiday_time, '4', '2') . '-' . substr($holiday_time, '6', '2');
|
||||
$end_time = strtotime($date . ' ' . '23:59:59');
|
||||
if ($join_type == 1) {
|
||||
$start_time = strtotime($date . ' ' . '00:00:00');
|
||||
$push_time = $start_time;
|
||||
} else {
|
||||
$start_time = strtotime($date . ' ' . '00:00:00');
|
||||
$push_time = $start_time - ( 86400 * $days );
|
||||
}
|
||||
} else {
|
||||
$holiday_name = input('festival_name', '');
|
||||
if (input('join_type') == 1) {
|
||||
$start_time = strtotime(input('start_time', ''));
|
||||
$push_time = $start_time;
|
||||
} else if (input('join_type') == 0) {
|
||||
$start_time = strtotime(input('start_time', ''));
|
||||
$push_time = $start_time - ( 86400 * $days );
|
||||
}
|
||||
$end_time = strtotime(input('end_time', ''));
|
||||
}
|
||||
|
||||
//获取节日信息
|
||||
$festival_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'activity_name' => input('activity_name', ''),
|
||||
'festival_type' => $this->game_type,
|
||||
'festival_type_name' => $this->game_type_name,
|
||||
'festival_name' => $holiday_name,
|
||||
'level_id' => input('level_id', ''),
|
||||
'level_name' => input('level_name', ''),
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
'remark' => input('remark', ''),
|
||||
'join_time' => input('join_time', ''),//0自定义节日 1传统节日
|
||||
'join_type' => input('join_type', ''), //奖励发放时间类型(1节日当天 0节日前某天)
|
||||
'join_frequency' => $days,//天数
|
||||
'push_time' => $push_time//活动推送时间
|
||||
];
|
||||
|
||||
if (strpos(input('type', ''), 'point') !== false) {
|
||||
$point = input('point', 0);
|
||||
} else {
|
||||
$point = 0;
|
||||
}
|
||||
if (strpos(input('type', ''), 'balance') !== false) {
|
||||
if (input('balance_type') == 0) {
|
||||
$balance = input('balance', '0.00');
|
||||
$balance_money = '0.00';
|
||||
} else {
|
||||
$balance_money = input('balance_money', '0.00');
|
||||
$balance = '0.00';
|
||||
}
|
||||
} else {
|
||||
$balance = '0.00';
|
||||
$balance_money = '0.00';
|
||||
|
||||
}
|
||||
if (strpos(input('type', ''), 'coupon') !== false) {
|
||||
$coupon = input('coupon', '');
|
||||
} else {
|
||||
$coupon = 0;
|
||||
}
|
||||
|
||||
$award_arr = [
|
||||
'award_type' => input('type', ''),
|
||||
'point' => $point,
|
||||
'balance' => $balance,
|
||||
'balance_type' => input('balance_type', '0'),
|
||||
'balance_money' => $balance_money,
|
||||
'coupon' => $coupon
|
||||
];
|
||||
return $model->addFestival($festival_data, $award_arr);
|
||||
} else {
|
||||
$jieri_list = Cache::get('jieri_list');
|
||||
if (empty($jieri_list)) {
|
||||
$jieri_data = file_get_contents('https://api.apihubs.cn/holiday/get?field=year,month,date,lunar_year,lunar_month,lunar_date,holiday&year=' . date('Y') . '&holiday=22,15,11,16,17,19,44,55,58,62,66,70,77,88,89,97&holiday_today=1&order_by=1&cn=1&size=31');
|
||||
$jieri_data = json_decode($jieri_data, true);
|
||||
$jieri_list = $jieri_data[ 'data' ][ 'list' ];
|
||||
Cache::set('jieri_list', $jieri_list);
|
||||
}
|
||||
$this->assign('jieri_list', $jieri_list);
|
||||
|
||||
//会员等级
|
||||
$member_level_model = new MemberLevel();
|
||||
$member_level_list = $member_level_model->getMemberLevelList([ [ 'site_id', '=', $this->site_id ] ], 'level_id, level_name', 'growth asc');
|
||||
$this->assign('member_level_list', $member_level_list[ 'data' ]);
|
||||
|
||||
return $this->fetch("scenefestival/add");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$model = new Festival();
|
||||
$festival_id = input('festival_id');
|
||||
if (request()->isJson()) {
|
||||
$holiday_time = input('holiday_time', '');
|
||||
$days = input('join_frequency', '1');
|
||||
$join_type = input('join_type', 1);
|
||||
$join_time = input('join_time', '0'); //1传统节日 0自定义节日
|
||||
if ($join_time == 1) {
|
||||
$holiday_name = input('holiday_name', '');
|
||||
$date = substr($holiday_time, '0', '4') . '-' . substr($holiday_time, '4', '2') . '-' . substr($holiday_time, '6', '2');
|
||||
$end_time = strtotime($date . ' ' . '23:59:59');
|
||||
if ($join_type == 1) {
|
||||
$start_time = strtotime($date . ' ' . '00:00:00');
|
||||
$push_time = $start_time;
|
||||
} else {
|
||||
$start_time = strtotime($date . ' ' . '00:00:00');
|
||||
$push_time = $start_time - ( 86400 * $days );
|
||||
}
|
||||
|
||||
} else {
|
||||
$holiday_name = input('festival_name', '');
|
||||
if (input('join_type') == 1) {
|
||||
$start_time = strtotime(input('start_time', ''));
|
||||
$push_time = $start_time;
|
||||
} else if (input('join_type') == 0) {
|
||||
$start_time = strtotime(input('start_time', ''));
|
||||
$push_time = $start_time - ( 86400 * $days );
|
||||
}
|
||||
$end_time = strtotime(input('end_time', ''));
|
||||
}
|
||||
//获取活动信息
|
||||
$festival_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'activity_name' => input('activity_name', ''),
|
||||
'festival_type' => $this->game_type,
|
||||
'festival_type_name' => $this->game_type_name,
|
||||
'festival_name' => $holiday_name,
|
||||
'level_id' => input('level_id', ''),
|
||||
'level_name' => input('level_name', ''),
|
||||
'start_time' => $start_time,
|
||||
'end_time' => $end_time,
|
||||
'remark' => input('remark', ''),
|
||||
'join_time' => input('join_time', ''),//0自定义节日 1传统节日
|
||||
'join_type' => input('join_type', ''), //奖励发放时间类型(1节日当天 0节日前某天)
|
||||
'join_frequency' => $days,//天数
|
||||
'push_time' => $push_time//活动推送时间
|
||||
];
|
||||
|
||||
if (strpos(input('type', ''), 'point') !== false) {
|
||||
$point = input('point', 0);
|
||||
} else {
|
||||
$point = 0;
|
||||
}
|
||||
if (strpos(input('type', ''), 'balance') !== false) {
|
||||
if (input('balance_type') == 0) {
|
||||
$balance = input('balance', '0.00');
|
||||
$balance_money = '0.00';
|
||||
} else {
|
||||
$balance_money = input('balance_money', '0.00');
|
||||
$balance = '0.00';
|
||||
}
|
||||
} else {
|
||||
$balance = '0.00';
|
||||
$balance_money = '0.00';
|
||||
|
||||
}
|
||||
if (strpos(input('type', ''), 'coupon') !== false) {
|
||||
$coupon = input('coupon', '');
|
||||
} else {
|
||||
$coupon = 0;
|
||||
}
|
||||
|
||||
$award_arr = [
|
||||
'award_type' => input('type', ''),
|
||||
'point' => $point,
|
||||
'balance' => $balance,
|
||||
'balance_type' => input('balance_type', '0'),
|
||||
'balance_money' => $balance_money,
|
||||
'coupon' => $coupon
|
||||
];
|
||||
|
||||
return $model->editGames([ [ 'site_id', '=', $this->site_id ], [ 'festival_id', '=', $festival_id ] ], $festival_data, $award_arr);
|
||||
} else {
|
||||
//会员等级
|
||||
$member_level_model = new MemberLevel();
|
||||
$member_level_list = $member_level_model->getMemberLevelList([ [ 'site_id', '=', $this->site_id ] ], 'level_id, level_name', 'growth asc');
|
||||
$this->assign('member_level_list', $member_level_list[ 'data' ]);
|
||||
|
||||
$jieri_list = Cache::get('jieri_list');
|
||||
if (empty($jieri_list)) {
|
||||
$jieri_data = file_get_contents('https://api.apihubs.cn/holiday/get?field=year,month,date,lunar_year,lunar_month,lunar_date,holiday&year=' . date('Y') . '&holiday=22,15,11,16,17,19,44,55,58,62,66,70,77,88,89,97&holiday_today=1&order_by=1&cn=1&size=31');
|
||||
$jieri_data = json_decode($jieri_data, true);
|
||||
$jieri_list = $jieri_data[ 'data' ][ 'list' ];
|
||||
Cache::set('jieri_list', $jieri_list);
|
||||
}
|
||||
$this->assign('jieri_list', $jieri_list);
|
||||
|
||||
//获取详情
|
||||
$info = $model->getFestivalDetail([ [ 'a.festival_id', '=', $festival_id ], [ 'a.site_id', '=', $this->site_id ] ], 'a.*,pfa.award_type,pfa.coupon,pfa.point,pfa.balance,pfa.balance_type,pfa.balance_money', 'a', [ [ 'promotion_festival_award pfa', 'pfa.festival_id = a.festival_id', 'left' ] ]);
|
||||
$info[ 'data' ][ 'time' ] = time();
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到活动数据', href_url('scenefestival://shop/scenefestival/lists'));
|
||||
return $this->fetch("scenefestival/edit");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 节日有礼详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$festival_model = new Festival();
|
||||
|
||||
$festival_id = input('festival_id', '');
|
||||
//获取详情
|
||||
$info = $festival_model->getFestivalDetail([ [ 'a.festival_id', '=', $festival_id ], [ 'a.site_id', '=', $this->site_id ] ], 'a.*,pfa.award_type,pfa.coupon,pfa.point,pfa.balance,pfa.balance_type,pfa.balance_money', 'a', [ [ 'promotion_festival_award pfa', 'pfa.festival_id = a.festival_id', 'left' ] ])[ 'data' ] ?? [];
|
||||
if (empty($info)) $this->error('未获取到活动数据', href_url('scenefestival://shop/scenefestival/lists'));
|
||||
$info[ 'status_name' ] = $festival_model->status[ $info[ 'status' ] ] ?? '';
|
||||
$this->assign('info', $info);
|
||||
|
||||
return $this->fetch("scenefestival/detail");
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除节日有礼活动
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$festival_id = input('festival_id', '0');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$festival_model = new Festival();
|
||||
return $festival_model->deleteGames($site_id, $festival_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 结束节日有礼活动
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
$festival_id = input('festival_id', '0');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$festival_model = new Festival();
|
||||
return $festival_model->finishGames($site_id, $festival_id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 重启节日有礼活动
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
$festival_id = input('festival_id', '0');
|
||||
|
||||
$festival_model = new Festival();
|
||||
return $festival_model->startGames($festival_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广
|
||||
* return
|
||||
*/
|
||||
public function gameUrl()
|
||||
{
|
||||
$festival_id = input('festival_id', '0');
|
||||
$model = new Festival();
|
||||
$festival_info_data = $model->getGamesInfo([ [ 'festival_id', '=', $festival_id ] ], 'festival_id,activity_name');
|
||||
$festival_info = $festival_info_data[ 'data' ];
|
||||
$res = $model->qrcode($festival_info[ 'festival_id' ], $festival_info[ 'activity_name' ], $this->festival_url, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
173
addon/scenefestival/shop/view/record/lists.html
Executable file
173
addon/scenefestival/shop/view/record/lists.html
Executable file
@@ -0,0 +1,173 @@
|
||||
<div class="layui-collapse tips-wrap">
|
||||
<div class="layui-colla-item">
|
||||
<ul class="layui-colla-content layui-show">
|
||||
<li>活动名称:{$game_info.activity_name} ({:date('Y-m-d H:i:s',$game_info.start_time)} -- {:date('Y-m-d H:i:s',$game_info.end_time)}) </li>
|
||||
<li>参与条件:{if $game_info.level_id != 0} {$game_info.level_name} {else/}全体会员 {/if}</li>
|
||||
<li>奖励发放时间:{if $game_info.join_type == 1} 节日当天{else/} 节日前{$game_info.join_frequency}天{/if}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="single-filter-box">
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="member_nick_name" placeholder="会员昵称" class="layui-input" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="start_time" id="start_time" placeholder="开始时间" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-input-inline end-time">
|
||||
<input type="text" name="end_time" id="end_time" placeholder="结束时间" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="search">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="record_tab">
|
||||
<!-- <ul class="layui-tab-title">-->
|
||||
<!-- <li class="layui-this" data-status="">全部</li>-->
|
||||
<!-- <li data-status="1">中奖</li>-->
|
||||
<!-- <li data-status="0">未中奖</li>-->
|
||||
<!-- </ul>-->
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="record_list" lay-filter="record_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var game_id = "{$festival_id}";
|
||||
layui.use(['form', 'element','laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
element = layui.element;
|
||||
form.render();
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time' //指定元素
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time' //指定元素
|
||||
});
|
||||
|
||||
element.on('tab(record_tab)', function() {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#record_list',
|
||||
url: ns.url("scenefestival://shop/record/lists"),
|
||||
where:{
|
||||
'festival_id':game_id
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
field:'member_nick_name',
|
||||
title: '会员昵称',
|
||||
unresize: 'false',
|
||||
width:'20%'
|
||||
},
|
||||
{
|
||||
field: '',
|
||||
title: '奖励积分',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
var str = data.award_type;
|
||||
if(str.search("point") != -1 ){
|
||||
return '奖励积分' + "【"+data.point+"积分】";
|
||||
}else {
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: '',
|
||||
title: '奖励红包',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
var str = data.award_type;
|
||||
if(str.search("balance") != -1 ){
|
||||
if(data.balance_type == 0){
|
||||
return '奖励储值余额' + "【"+data.balance+"元】";
|
||||
}else{
|
||||
return '奖励现金余额' + "【"+data.balance_money+"元】";
|
||||
}
|
||||
}else {
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: '',
|
||||
title: '奖励优惠券',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
var str = data.award_type;
|
||||
if(str.search("coupon") != -1 ){
|
||||
return '奖励优惠券' + "【"+data.coupon_name+"】";
|
||||
}else {
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '领取时间',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
return ns.time_to_date(data.receive_time);
|
||||
}
|
||||
}]
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function(data) {
|
||||
var status = $(this).attr("data-status");
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
587
addon/scenefestival/shop/view/scenefestival/add.html
Executable file
587
addon/scenefestival/shop/view/scenefestival/add.html
Executable file
@@ -0,0 +1,587 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/game.css">
|
||||
<style>
|
||||
.choose-item > span {
|
||||
display: inline-block;
|
||||
padding: 0 10px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
text-align: center;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ededed;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
margin: 5px 0;
|
||||
margin-right: 11px;
|
||||
}
|
||||
.choose-item > span i {
|
||||
position: absolute;
|
||||
bottom: -5px;
|
||||
right: -6px;
|
||||
border-radius: 50%;
|
||||
color: #FFF;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
}
|
||||
.holiday-active {
|
||||
color: #fff;
|
||||
}
|
||||
.holiday-hidden {
|
||||
border: none;
|
||||
width: .1px;
|
||||
}
|
||||
|
||||
.coupon-box .layui-form{
|
||||
padding: 0!important;
|
||||
}
|
||||
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow: auto !important;
|
||||
}
|
||||
|
||||
.del-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.level-equity .layui-input {
|
||||
display: inline-block;
|
||||
}
|
||||
.gods-box table:first-of-type{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.gods-box table:last-of-type{
|
||||
margin-top: 0;
|
||||
display: block;
|
||||
max-height: 323px;
|
||||
overflow: auto;
|
||||
}
|
||||
.coupon-box .single-filter-box{
|
||||
padding-top: 0;
|
||||
}
|
||||
.coupon-box .select-coupon-btn{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow-y: scroll!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动设置</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="activity_name" lay-verify="required" maxlength="15" placeholder="最多可填写15个字" autocomplete="off" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="join_time" value="1" lay-verify="required" lay-filter="join_time" title="传统节日" checked>
|
||||
<input type="radio" name="join_time" value="0" lay-verify="required" lay-filter="join_time" title="自定义节日">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide" id="festival_name">
|
||||
<label class="layui-form-label"><span class="required">*</span>节日名称:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" maxlength="15" placeholder="最多可填写15个字" name="festival_name" class="layui-input len-mid" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide" id="self_time">
|
||||
<label class="layui-form-label"><span class="required">*</span>节日日期:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="start_time" name="start_time" lay-verify="required" class="layui-input len-mid" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline end-time">
|
||||
<input type="text" id="end_time" name="end_time" lay-verify="required|time" class="layui-input len-mid" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" id="join_time">
|
||||
<label class="layui-form-label"><span class="required">*</span>节日日期:</label>
|
||||
<div class="layui-input-block">
|
||||
<span class="holiday-name"></span>
|
||||
<input type="hidden" class="holiday-hidden" lay-verify='holiday'>
|
||||
<button class="layui-btn" type="button" onclick="choose()">重新选择</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">祝福语:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="150"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item participation-condition">
|
||||
<label class="layui-form-label">参与条件:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="level_id" value="0" lay-filter="participation" title="全部会员" checked>
|
||||
<input type="radio" name="level_id" value="1" lay-filter="participation" title="部分会员">
|
||||
</div>
|
||||
<div class="layui-inline layui-hide">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
{foreach $member_level_list as $k =>$v}
|
||||
<input type="checkbox" class="level-id" value="{$v.level_id}" title="{$v.level_name}" lay-skin="primary">
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">选择参与的会员等级,默认为所有会员都可参与</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励发放时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="join_type" value="1" lay-verify="required" lay-filter="join_type" title="活动时间内" checked>
|
||||
<input type="radio" name="join_type" value="0" lay-verify="required" lay-filter="join_type" title="活动开始前">
|
||||
<span id="time" class="layui-hide">
|
||||
<input type="number" name="join_frequency" min="0" max="7" lay-verify="required|join_frequency" onchange="detectionNumType(this,'positiveInteger')" autocomplete="off" class="layui-input len-short" value="1">天
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item layui-hide" id="time">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="join_frequency" min="0" max="7" lay-verify="required|join_frequency" onchange="detectionNumType(this,'positiveInteger')" autocomplete="off" class="layui-input len-short" value="1">天
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">奖品设置</span>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-card-body">-->
|
||||
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">奖品明细:</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <table id="award_list"></table>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="word-aux">-->
|
||||
<!-- <span class="aux-title">注意:</span>-->
|
||||
<!-- <div class="aux-item">1、奖项设置包含优惠券时,请保证优惠券数量充足</div>-->
|
||||
<!-- <div class="aux-item">2、奖品奖项不能少于1项且不能超过7项。</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="word-aux">-->
|
||||
<!-- <button class="layui-btn" onclick="addAward()">添加奖品</button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-card-body reward-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="type" value="point" title="积分" lay-skin="primary" lay-filter="type" lay-verify="type" checked>
|
||||
<input type="checkbox" name="type" value="balance" title="余额" lay-skin="primary" lay-filter="type" lay-verify="type">
|
||||
<input type="checkbox" name="type" value="coupon" title="优惠券" lay-skin="primary" lay-filter="type" lay-verify="type">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="point-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="point" value="1" type="number" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required|mum" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="balance-wrap layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励红包:</label>
|
||||
<div class="layui-input-block len-long">
|
||||
<input type="radio" name="balance_type" value="0" checked title="不可提现" lay-verify="balance_type"><input name="balance" onchange="detectionNumType(this,'positiveNumber')" value="1" type="number" lay-verify="" class="layui-input len-short">元
|
||||
</div>
|
||||
<!--<label class="layui-form-label"></label>-->
|
||||
<!--<div class="layui-input-block len-long">-->
|
||||
<!--<input type="radio" value="1" name="balance_type" title="可提现" lay-verify="balance_type"><input name="balance_money" onchange="detectionNumType(this,'positiveInteger')" value="1" type="number" lay-verify="" class="layui-input len-short" style="margin-left: 14px;">元-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<!-- <div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>-->
|
||||
</div>
|
||||
|
||||
<div class="coupon-wrap layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="coupon_list"></div>
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>活动优惠券发放,不受优惠券自身数量和领取数量的限制</p>
|
||||
</div>
|
||||
<button class="layui-btn" id="select_coupon">选择优惠券</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backScenefestivalList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加奖品 -->
|
||||
{include file="scenefestival/award_select"/}
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script>
|
||||
var form,laydate,laytpl,upload,tableData = [],
|
||||
repeat_flag = false,
|
||||
awardId = 0,
|
||||
currentDate = new Date(),
|
||||
minDate = "",
|
||||
coupon_id = [], addCoupon;
|
||||
|
||||
var coupon_select = new CouponSelect({
|
||||
tableElem:'#coupon_list',
|
||||
selectElem:'#select_coupon',
|
||||
})
|
||||
|
||||
layui.use(['form', 'laydate', 'laytpl'], function() {
|
||||
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
laytpl = layui.laytpl;
|
||||
|
||||
currentDate.setDate(currentDate.getDate() + 30);
|
||||
form.render();
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class = "layui-input len-mid" autocomplete="off"> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
//参与条件
|
||||
form.on('radio(participation)', function(data){
|
||||
if (parseInt(data.value))
|
||||
$('.participation-condition .layui-inline').removeClass('layui-hide');
|
||||
else
|
||||
$('.participation-condition .layui-inline').addClass('layui-hide');
|
||||
});
|
||||
|
||||
form.on('radio(join_type)', function(data){
|
||||
if (data.value == 1 ) {
|
||||
$("#time").addClass('layui-hide');
|
||||
}else {
|
||||
$("#time").removeClass('layui-hide');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
form.on('radio(join_time)', function(data){
|
||||
if (data.value == 1 ) {
|
||||
$("#join_time").removeClass('layui-hide');
|
||||
$("#self_time").addClass('layui-hide');
|
||||
$("#festival_name").addClass('layui-hide');
|
||||
}else {
|
||||
$("#join_time").addClass('layui-hide');
|
||||
$("#self_time").removeClass('layui-hide');
|
||||
$("#festival_name").removeClass('layui-hide');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
var time_type = $('input[name="join_time"]:checked').val();
|
||||
if(time_type == 0){
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
holiday:function(){
|
||||
if($('input[name = "join_time"]:checked').val() == 1 && $('.holiday-hidden').val() != 1){
|
||||
return "请选择节日日期";
|
||||
}
|
||||
},
|
||||
type: function(){
|
||||
if ($('.reward-wrap [name="type"]:checked').length == 0) {
|
||||
return '请选择领奖励内容';
|
||||
}
|
||||
},
|
||||
mum: function(value, item){
|
||||
if (/^\d{0,10}$/.test(value) === false) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
|
||||
if (parseInt(value) <= 0) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
},
|
||||
// float: function(value, item){
|
||||
// if (/^\d{0,10}$/.test(value) === false) {
|
||||
// return '请输入大于0的数字,支持小数点后两位';
|
||||
// }
|
||||
// if (parseInt(value) <= 0) {
|
||||
// return '请输入大于0的数字,支持小数点后两位';
|
||||
// }
|
||||
// },
|
||||
join_frequency: function(value){
|
||||
if(value > 7){
|
||||
return '不得超过7天'
|
||||
}
|
||||
}
|
||||
});
|
||||
form.on('checkbox(type)', function(data) {
|
||||
$('[name="type"]').each(function(){
|
||||
var type = $(this).val();
|
||||
if ($(this).is(':checked')) {
|
||||
$('.reward-wrap .' + type + '-wrap').removeClass('layui-hide');
|
||||
if (type == 'point' || type == 'coupon') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|mum');
|
||||
}
|
||||
if (type == 'balance') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|float');
|
||||
}
|
||||
} else {
|
||||
$('.reward-wrap .' + type + '-wrap').addClass('layui-hide');
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', '');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
let coupon_selected_ids = coupon_select.getSelectedData().selectedIds;
|
||||
var type = [];
|
||||
$('.reward-wrap [name="type"]:checked').each(function(){
|
||||
type.push($(this).val());
|
||||
});
|
||||
if ($.inArray('coupon', type) != -1 && coupon_selected_ids.length == 0) {
|
||||
layer.msg('请选择优惠券', {icon: 5});
|
||||
return;
|
||||
}
|
||||
if(data.field.join_time == 0 && data.field.festival_name == '') {
|
||||
layer.msg('请输入节日名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.field.max_fetch == ''){
|
||||
layer.msg('请输入邀请奖励上限', {icon: 5});
|
||||
return;
|
||||
}else if (data.field.max_fetch < 0){
|
||||
layer.msg('请输入大于或等于0的整数', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.type = type.toString();
|
||||
data.field.coupon = coupon_selected_ids.toString();
|
||||
|
||||
if (parseInt(data.field.level_id)){
|
||||
var levelId = [],
|
||||
levelName = [];
|
||||
$('.level-id').each(function(){
|
||||
if($(this).prop('checked')){
|
||||
levelId.push($(this).val());
|
||||
levelName.push($(this).attr("title"));
|
||||
}
|
||||
});
|
||||
data.field.level_id = levelId.toString();
|
||||
data.field.level_name = levelName.toString();
|
||||
}
|
||||
|
||||
if($("input[name='level_id']:checked").val() == 1 && data.field.level_id.length == 0){
|
||||
layer.msg('请选择会员等级', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.field.no_winning_img && upload.path != 'public/uniapp/game/no_winning.png') upload.delete();
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
if($('.holiday-name').html()){
|
||||
data.field.holiday_name = $('.holiday-name').html();
|
||||
data.field.holiday_time =$('.holiday-name').attr('date-time')
|
||||
}else{
|
||||
data.field.holiday_name = '';
|
||||
data.field.holiday_time = '';
|
||||
}
|
||||
|
||||
// console.log($('input[name = "join_time"]:checked').val())
|
||||
// console.log($('.holiday-hidden').val())
|
||||
|
||||
// console.log($('input[name = "join_time"]:checked').val() == 1 && $('.holiday-hidden').val() > 0)
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("scenefestival://shop/scenefestival/add"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var upload = new Upload({
|
||||
elem: '#no_winning_img'
|
||||
});
|
||||
});
|
||||
|
||||
function backScenefestivalList() {
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/lists");
|
||||
}
|
||||
|
||||
//检测数据类型
|
||||
function detectionNumType(el,type){
|
||||
var value = $(el).val();
|
||||
|
||||
//大于零 且 不是小数
|
||||
if (value < 0 && type == 'integral')
|
||||
$(el).val(0);
|
||||
else if(type == 'integral')
|
||||
$(el).val(Math.round(value));
|
||||
|
||||
//大于1 且 不是小数
|
||||
if (value < 1 && type == 'positiveInteger'){
|
||||
$(el).val(1);
|
||||
} else if (type == 'positiveInteger'){
|
||||
var val = Math.round(value);
|
||||
if(Object.is(val,NaN)){
|
||||
$(el).val(1);
|
||||
}else{
|
||||
$(el).val(val);
|
||||
}
|
||||
}
|
||||
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveNumber'){
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveMoney'){
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
}
|
||||
|
||||
// 选择节日日期
|
||||
function choose() {
|
||||
var data = {};
|
||||
laytpl($("#choose_time").html()).render(data, function(html) {
|
||||
coupon_list = layer.open({
|
||||
title: '选择节日',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['520px', 'auto'],
|
||||
btn:['确定','取消'],
|
||||
content: html,
|
||||
});
|
||||
form.render();
|
||||
|
||||
$('.holiday').each(function(){
|
||||
if($(this).html() == $('.holiday-name').html()){
|
||||
$(this).addClass('holiday-active bg-color')
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function holiday(data){
|
||||
$('.holiday').removeClass('holiday-active bg-color');
|
||||
$(data).addClass('holiday-active bg-color');
|
||||
$('.holiday-name').html($(data).html());
|
||||
$('.holiday-hidden').val(1);
|
||||
$('.holiday-name').attr('date-time' , $(data).attr('date-time'))
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="choose_time">
|
||||
<div class="choose-time">
|
||||
<div class="choose-item">
|
||||
<p>传统节日</p>
|
||||
{foreach $jieri_list as $jieri_list_k => $jieri_list_v}
|
||||
<span class="border-color holiday" date-time="{$jieri_list_v.date}" onclick = "holiday(this)">{$jieri_list_v.holiday_cn}</span>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
276
addon/scenefestival/shop/view/scenefestival/award_select.html
Executable file
276
addon/scenefestival/shop/view/scenefestival/award_select.html
Executable file
@@ -0,0 +1,276 @@
|
||||
<script type="text/html" id="add_award">
|
||||
<div class="layui-form form-wrap add-award">
|
||||
{{# if($.isEmptyObject(d)){ }}
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" maxlength="6" placeholder="最多可输入6个字" value="" name="award_name" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item award-type">
|
||||
<label class="layui-form-label">奖品:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block coupon">
|
||||
<input type="radio" name="award_type" value="3" title="优惠券" checked>
|
||||
<div class="len-mid coupon-box">
|
||||
<span class="coupon-title">请选择</span>
|
||||
<div class="coupon-option layui-hide">
|
||||
<div class="coupon-search">
|
||||
<i class="layui-icon"></i>
|
||||
<input type="text" class="layui-input" placeholder="请输入搜索内容">
|
||||
</div>
|
||||
<div class="coupon-item-box">
|
||||
<div class="coupon-item">内容</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="relate_name">
|
||||
<input type="hidden" name="relate_id">
|
||||
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="1" title="积分">
|
||||
<input type="text" name="point" value="1" class="layui-input len-mid">
|
||||
<div class="layui-word-aux">积分</div>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="2" title="红包">
|
||||
<input type="text" name="balance" value="1" class="layui-input len-mid" onchange="detectionNumType(this,'positiveMoney')">
|
||||
<div class="layui-word-aux">元</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="award_num" value="1" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖项权重:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="award_winning_rate" value="1" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" maxlength="6" placeholder="最多可输入6个字" value="{{d.award_name}}" name="award_name" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item award-type">
|
||||
<label class="layui-form-label">奖品:</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
<!-- 红包 -->
|
||||
{{# if(d.award_type == 3){ }}
|
||||
<div class="layui-input-block coupon">
|
||||
<input type="radio" name="award_type" value="3" title="优惠券" checked>
|
||||
<div class="len-mid coupon-box">
|
||||
<span class="coupon-title">{{d.relate_name}}</span>
|
||||
<div class="coupon-option layui-hide">
|
||||
<div class="coupon-search">
|
||||
<i class="layui-icon"></i>
|
||||
<input type="text" class="layui-input" placeholder="请输入搜索内容">
|
||||
</div>
|
||||
<div class="coupon-item-box"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="relate_name" value="{{d.relate_name}}">
|
||||
<input type="hidden" name="relate_id" value="{{d.relate_id}}">
|
||||
{{# }else{ }}
|
||||
<div class="layui-input-block coupon">
|
||||
<input type="radio" name="award_type" value="3" title="优惠券" checked>
|
||||
<div class="len-mid coupon-box">
|
||||
<span class="coupon-title">请选择</span>
|
||||
<div class="coupon-option layui-hide">
|
||||
<div class="coupon-search">
|
||||
<i class="layui-icon"></i>
|
||||
<input type="text" class="layui-input" placeholder="请输入搜索内容">
|
||||
</div>
|
||||
<div class="coupon-item-box"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="relate_name">
|
||||
<input type="hidden" name="relate_id">
|
||||
{{# } }}
|
||||
|
||||
<!-- 积分 -->
|
||||
{{# if(d.award_type == 1){ }}
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="1" title="积分" checked>
|
||||
<input type="text" name="point" value="{{d.point}}" class="layui-input len-mid">
|
||||
<div class="layui-word-aux">积分</div>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="1" title="积分">
|
||||
<input type="text" name="point" value="1" class="layui-input len-mid">
|
||||
<div class="layui-word-aux">积分</div>
|
||||
</div>
|
||||
{{# } }}
|
||||
|
||||
<!-- 红包 -->
|
||||
{{# if(d.award_type == 2){ }}
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="2" title="红包" checked>
|
||||
<input type="text" name="balance" value="{{d.balance}}" onchange="detectionNumType(this,'positiveMoney')" class="layui-input len-mid">
|
||||
<div class="layui-word-aux">元</div>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="award_type" value="2" title="红包">
|
||||
<input type="text" name="balance" value="1" class="layui-input len-mid" onchange="detectionNumType(this,'positiveMoney')">
|
||||
<div class="layui-word-aux">元</div>
|
||||
</div>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="award_num" value="{{d.award_num}}" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖项权重:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="award_winning_rate" value="{{d.award_winning_rate}}" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="ident" value="{{d.ident}}">
|
||||
{{# } }}
|
||||
<input type="hidden" name="award_id" value="{{d.award_id}}">
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="addAwardSave">确定</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="cancelAward()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
/*
|
||||
* 奖品弹框
|
||||
* */
|
||||
function awardPop(data = {}){
|
||||
laytpl($('#add_award').html()).render(data,function(html){
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '添加奖品',
|
||||
area:['650px','auto'],
|
||||
content: html,
|
||||
success: function(layero, index){
|
||||
form.render();
|
||||
form.on('submit(addAwardSave)', function(data) {
|
||||
if (data.field.award_type == 3 && !data.field.relate_name){
|
||||
layer.msg("请选择优惠券");
|
||||
return false;
|
||||
}
|
||||
if (data.field.award_type == 1 && data.field.point <=0){
|
||||
layer.msg("积分必须大于0");
|
||||
return false;
|
||||
}
|
||||
if (data.field.award_type == 2 && data.field.balance <=0){
|
||||
layer.msg("红包必须大于0");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tableData.length > 0 && data.field.ident){
|
||||
for (var i = 0; i < tableData.length; i++){
|
||||
if(tableData[i].ident == data.field.ident){
|
||||
tableData[i] = data.field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
data.field.ident = ++awardId;
|
||||
tableData.push(data.field);
|
||||
}
|
||||
renderTable(tableData);
|
||||
layer.closeAll();
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getCouponData({'status': 1});
|
||||
//选择框效果
|
||||
$(".award-type .coupon-title").click(function (e) {
|
||||
e.stopPropagation(); //阻止事件冒泡
|
||||
if (!$(this).hasClass("focus")){
|
||||
|
||||
$(this).addClass("focus border-color");
|
||||
$(this).parents(".coupon-box").find(".coupon-option").removeClass("layui-hide");
|
||||
|
||||
} else{
|
||||
$(this).removeClass("focus border-color");
|
||||
$(this).parents(".coupon-box").find(".coupon-option").addClass("layui-hide");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取优惠券数据
|
||||
* */
|
||||
var getCouponIdent = false;
|
||||
function getCouponData(data = ''){
|
||||
if (getCouponIdent) return false;
|
||||
getCouponIdent = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("coupon://shop/coupon/lists"),
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
type: 'post',
|
||||
success : function(res) {
|
||||
getCouponIdent = false;
|
||||
$(".coupon-search input").val();
|
||||
var data = res.data.list,
|
||||
html = '';
|
||||
if (res.code >= 0){
|
||||
for(var i = 0; i < data.length; i++){
|
||||
html += '<div class="coupon-item layui-elip" data-coupon_id="'+data[i].coupon_type_id+'">'+ data[i].coupon_name +'</div>';
|
||||
}
|
||||
$(".add-award .coupon .coupon-item-box").html(html);
|
||||
}else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//点击搜素对应优惠券
|
||||
$("body").off("click",".coupon-search i").on("click",".coupon-search i",function (e) {
|
||||
e.stopPropagation(); //阻止事件冒泡
|
||||
var data = {'coupon_name': $(".coupon-search input").val(),'status': 1};
|
||||
getCouponData(data);
|
||||
});
|
||||
|
||||
//选择具体优惠券
|
||||
$("body").off("click",".add-award .coupon .coupon-item").on("click",".add-award .coupon .coupon-item",function (e) {
|
||||
e.stopPropagation(); //阻止事件冒泡
|
||||
$("input[name='relate_name']").val($(this).text());
|
||||
$("input[name='relate_id']").val($(this).attr('data-coupon_id'));
|
||||
$(this).parents(".coupon-box").find(".coupon-title").text($(this).text());
|
||||
$(".coupon-option").addClass("layui-hide");
|
||||
$(".award-type .coupon-title").removeClass("focus border-color");
|
||||
});
|
||||
|
||||
$("body").off("click",".add-award .coupon-search").on("click",".add-award .coupon-search", function (e) {
|
||||
e.stopPropagation(); //阻止事件冒泡
|
||||
});
|
||||
|
||||
function cancelAward (){
|
||||
layer.closeAll();
|
||||
}
|
||||
</script>
|
||||
153
addon/scenefestival/shop/view/scenefestival/detail.html
Executable file
153
addon/scenefestival/shop/view/scenefestival/detail.html
Executable file
@@ -0,0 +1,153 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item">
|
||||
<label>活动名称:</label>
|
||||
<span>{$info.activity_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>活动状态:</label>
|
||||
<span>{$info.status_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>节日:</label>
|
||||
<span>{$info.festival_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.end_time)}</span>
|
||||
</div>
|
||||
|
||||
<div class="promotion-view-item">
|
||||
<label>添加时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.create_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>参与条件:</label>
|
||||
<span>{if $info.level_id == 0} 全部会员 {else/} {$info.level_name} {/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>奖励发放时间:</label>
|
||||
<span>{if $info.join_type == 1} 活动时间内{else/} 活动开始前{$info.join_frequency}天{/if}</span>
|
||||
</div>
|
||||
{if in_array('point', $info['award_type'])}
|
||||
<div class="promotion-view-item">
|
||||
<label>奖励积分:</label>
|
||||
<span>{$info.point}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if in_array('balance', $info['award_type'])}
|
||||
<div class="layui-form-item">
|
||||
<label>奖励红包:</label>
|
||||
<span>{$info.balance}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{if !empty($info.remark)}
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item-line">
|
||||
<label class="promotion-view-item-custom-label">祝福语:</label>
|
||||
<div class="promotion-view-item-custom-box">{$info.remark}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{if in_array('coupon', $info['award_type']) && !empty($info['coupon_list'])}
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">奖励优惠券</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class='promotion-view-list'>
|
||||
<table id="promotion_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<script type='text/html' id="promotion_list_item_box_html">
|
||||
<div class="promotion-list-item-title">
|
||||
<div class="promotion-list-item-title-icon">
|
||||
{{# if(d.image != ''){ }}
|
||||
<img src="{{ ns.img(d.image) }}">
|
||||
{{# }else{ }}
|
||||
<img src="__ROOT__/public/uniapp/game/coupon.png">
|
||||
{{# } }}
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.coupon_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var promotion_list = {if !empty($info.coupon_list)}{:json_encode($info.coupon_list, JSON_UNESCAPED_UNICODE)}{/if};
|
||||
|
||||
layui.use('table', function() {
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
cols: [
|
||||
[{
|
||||
title: '优惠券名称',
|
||||
width: '30%',
|
||||
unresize: 'false',
|
||||
templet: '#promotion_list_item_box_html'
|
||||
}, {
|
||||
title: '类型',
|
||||
templet: function(data) {
|
||||
return data.type == 'reward' ? '满减': '折扣';
|
||||
}
|
||||
}, {
|
||||
title: '优惠金额/折扣',
|
||||
templet: function(data) {
|
||||
return data.type == 'reward' ? data.money : data.discount;
|
||||
}
|
||||
}, {
|
||||
title: '适用商品',
|
||||
templet: function (data) {
|
||||
return data.goods_type_name;
|
||||
}
|
||||
}, {
|
||||
field: 'max_fetch',
|
||||
title: '领取人限制',
|
||||
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '已领取/发放数',
|
||||
templet: function(data) {
|
||||
return data.count == -1 ? data.lead_count+'/不限量': data.lead_count+'/'+data.count;
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '结束时间',
|
||||
unresize: 'false',
|
||||
width:'20%',
|
||||
templet: function(data) {
|
||||
var str = '';
|
||||
switch(data.validity_type) {
|
||||
case 0:
|
||||
str = ns.time_to_date(data.end_time);
|
||||
break;
|
||||
case 1:
|
||||
str = '领取之日起' + data.fixed_term + '天有效';
|
||||
break;
|
||||
default:
|
||||
str = '长期有效';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}]
|
||||
],
|
||||
data: promotion_list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
596
addon/scenefestival/shop/view/scenefestival/edit.html
Executable file
596
addon/scenefestival/shop/view/scenefestival/edit.html
Executable file
@@ -0,0 +1,596 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/game.css">
|
||||
<style>
|
||||
.choose-item > span {
|
||||
display: inline-block;
|
||||
padding: 0 10px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
text-align: center;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ededed;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
margin: 5px 0;
|
||||
margin-right: 11px;
|
||||
}
|
||||
.choose-item > span i {
|
||||
position: absolute;
|
||||
bottom: -5px;
|
||||
right: -6px;
|
||||
border-radius: 50%;
|
||||
color: #FFF;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
}
|
||||
.holiday-active {
|
||||
color: #fff;
|
||||
}
|
||||
.holiday-hidden {
|
||||
border: none;
|
||||
width: .1px;
|
||||
}
|
||||
|
||||
.coupon-box .layui-form{
|
||||
padding: 0!important;
|
||||
}
|
||||
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow: auto !important;
|
||||
}
|
||||
|
||||
.del-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.level-equity .layui-input {
|
||||
display: inline-block;
|
||||
}
|
||||
.gods-box table:first-of-type{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.gods-box table:last-of-type{
|
||||
margin-top: 0;
|
||||
display: block;
|
||||
max-height: 323px;
|
||||
overflow: auto;
|
||||
}
|
||||
.coupon-box .single-filter-box{
|
||||
padding-top: 0;
|
||||
}
|
||||
.coupon-box .select-coupon-btn{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow-y: scroll!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动设置</span>
|
||||
</div>
|
||||
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="activity_name" lay-verify="required" maxlength="15" placeholder="最多可填写15个字" autocomplete="off" class="layui-input len-long" value="{$info.activity_name}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="join_time" {if($info.join_time) == 1}checked {/if} value="1" lay-verify="required" lay-filter="join_time" title="传统节日">
|
||||
<input type="radio" name="join_time"{if($info.join_time) == 0}checked {/if} value="0" lay-verify="required" lay-filter="join_time" title="自定义节日">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item {if($info.join_time) == 0}layui-hide {/if}" id="join_time">
|
||||
<label class="layui-form-label">节日日期:</label>
|
||||
<div class="layui-input-block">
|
||||
<span class="holiday-name">{$info.festival_name}</span>
|
||||
<input type="hidden" class="holiday-hidden" lay-verify='holiday' value="">
|
||||
<button class="layui-btn" type="button" onclick="choose()">重新选择</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">祝福语:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" value="{$info.remark}" maxlength="150">{$info.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if($info.join_time) == 1}layui-hide {/if}" id="festival_name">
|
||||
<label class="layui-form-label"><span class="required">*</span>节日名称:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" maxlength="15" placeholder="最多可填写15个字" name="festival_name" value="{$info.festival_name}" class="layui-input len-mid" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item {if($info.join_time) == 1}layui-hide {/if}" id="self_time">
|
||||
<label class="layui-form-label"><span class="required">*</span>节日日期:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" value="{:date('Y-m-d H:i:s', $info.start_time)}" id="start_time" name="start_time" lay-verify="required" class="layui-input len-mid" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline end-time">
|
||||
<input type="hidden" value="{:date('Y-m-d H:i:s', $info.end_time)}" id="old_end_time">
|
||||
<input type="text" id="end_time" value="{:date('Y-m-d H:i:s', $info.end_time)}" name="end_time" lay-verify="required|time" class="layui-input len-mid" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item participation-condition">
|
||||
<label class="layui-form-label">参与条件:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="level_id" value="0" lay-filter="participation" title="全部会员" {if $info.level_id == 0}checked{/if}>
|
||||
<input type="radio" name="level_id" value="1" lay-filter="participation" title="部分会员" {if $info.level_id != 0}checked{/if}>
|
||||
</div>
|
||||
<div class="layui-inline {if $info.level_id == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
{foreach $member_level_list as $k =>$v}
|
||||
<input type="checkbox" class="level-id" value="{$v.level_id}" title="{$v.level_name}" lay-skin="primary">
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">选择参与的会员等级,默认为所有会员都可参与</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励发放时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="join_type" value="1" lay-verify="required" lay-filter="join_type" title="活动时间内" {if $info.join_type == 1} checked{/if}>
|
||||
<input type="radio" name="join_type" value="0" lay-verify="required" lay-filter="join_type" title="活动开始前" {if $info.join_type == 0} checked{/if}>
|
||||
<span id="time" class="{if $info.join_type == 1} layui-hide{/if}">
|
||||
<input type="number" name="join_frequency" min="0" value="{$info.join_frequency}" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-short"> 天
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-form-item layui-hide" id="time">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="join_frequency" min="0" value="{$info.join_frequency}" onchange="detectionNumType(this,'positiveInteger')" lay-verify="required" autocomplete="off" class="layui-input len-short"> 次
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">奖励设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body reward-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="type" value="point" title="积分" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('point', $info['award_type']) }checked{/if}>
|
||||
<input type="checkbox" name="type" value="balance" title="余额" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('balance', $info['award_type']) }checked{/if}>
|
||||
<input type="checkbox" name="type" value="coupon" title="优惠券" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('coupon', $info['award_type']) }checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="point-wrap {if !in_array('point', $info['award_type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="point" value="{$info.point}" onchange="detectionNumType(this,'positiveInteger')" type="number" id="point" lay-verify="{if in_array('point', $info['award_type']) }required|num{/if}" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="balance-wrap {if !in_array('balance', $info['award_type']) }layui-hide{/if}">-->
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label"><span class="required">*</span>奖励红包:</label>-->
|
||||
<!-- <div class="layui-input-block len-long">-->
|
||||
<!-- <input name="balance" value="{$info.balance}" type="number" lay-verify="{if in_array('balance', $info['award_type']) }required|float{/if}" class="layui-input len-short">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="balance-wrap {if !in_array('balance', $info['award_type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励红包:</label>
|
||||
<div class="layui-input-block len-long">
|
||||
<input type="radio" name="balance_type" lay-verify="balance_type" value="0" {if $info.balance_type == 0} checked {/if} title="不可提现"><input name="balance" onchange="detectionNumType(this,'positiveNumber')" value="{$info.balance}" type="number" lay-verify="" class="layui-input len-short">元
|
||||
</div>
|
||||
<!--<label class="layui-form-label"></label>-->
|
||||
<!--<div class="layui-input-block len-long">-->
|
||||
<!--<input type="radio" name="balance_type" lay-verify="balance_type" value="1" {if $info.balance_type == 1} checked {/if} title="可提现">    <input name="balance_money" onchange="detectionNumType(this,'positiveInteger')" value="{$info.balance_money}" type="number" lay-verify="" class="layui-input len-short">元-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<!-- <div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>-->
|
||||
</div>
|
||||
|
||||
<div class="coupon-wrap {if !in_array('coupon', $info['award_type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="coupon_list"></div>
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>活动优惠券发放,不受优惠券自身数量和领取数量的限制</p>
|
||||
</div>
|
||||
<button class="layui-btn" id="select_coupon">选择优惠券</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="festival_id" value="{$info.festival_id}">
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backScenefestivalList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加奖品 -->
|
||||
{include file="scenefestival/award_select" /}
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script>
|
||||
var form,laydate,upload,laytpl,repeat_flag = false,
|
||||
awardId = 0,
|
||||
minDate = "",
|
||||
coupon_id = [], addCoupon;
|
||||
var coupon_select = new CouponSelect({
|
||||
tableElem:'#coupon_list',
|
||||
selectElem:'#select_coupon',
|
||||
selectedIds:'{$info.coupon}',
|
||||
})
|
||||
|
||||
layui.use(['form', 'laydate', 'laytpl'], function() {
|
||||
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
laytpl = layui.laytpl;
|
||||
|
||||
form.render();
|
||||
initTableData();
|
||||
var time = "{$info.time}",
|
||||
start_time = "{$info.start_time}";
|
||||
if (time < start_time){
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class = "layui-input len-mid" autocomplete="off"> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
//参与条件
|
||||
form.on('radio(participation)', function(data){
|
||||
if (parseInt(data.value))
|
||||
$('.participation-condition .layui-inline').removeClass('layui-hide');
|
||||
else
|
||||
$('.participation-condition .layui-inline').addClass('layui-hide');
|
||||
});
|
||||
|
||||
form.on('radio(join_type)', function(data){
|
||||
if (data.value == 1 ) {
|
||||
$("#time").addClass('layui-hide');
|
||||
}else {
|
||||
$("#time").removeClass('layui-hide');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
form.on('radio(join_time)', function(data){
|
||||
if (data.value == 1 ) {
|
||||
$("#join_time").removeClass('layui-hide');
|
||||
$("#self_time").addClass('layui-hide');
|
||||
$("#festival_name").addClass('layui-hide');
|
||||
}else {
|
||||
$("#join_time").addClass('layui-hide');
|
||||
$("#self_time").removeClass('layui-hide');
|
||||
$("#festival_name").removeClass('layui-hide');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
var old_end_time = (new Date($("#old_end_time").val())).getTime();
|
||||
var time_type = $('input[name="join_time"]:checked').val();
|
||||
if(time_type == 0){
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
if (old_end_time > end_time){
|
||||
return '结束时间不能小于之前设置的时间!';
|
||||
}
|
||||
}
|
||||
},
|
||||
holiday:function(){
|
||||
if($('input[name = "join_time"]:checked').val() == 1 && $('.holiday-hidden').val() != 1){
|
||||
return "请选择节日日期";
|
||||
}
|
||||
},
|
||||
type: function(){
|
||||
if ($('.reward-wrap [name="type"]:checked').length == 0) {
|
||||
return '请选择领奖励内容';
|
||||
}
|
||||
},
|
||||
mum: function(value, item){
|
||||
if (/^\d{0,10}$/.test(value) === false) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
|
||||
if (parseInt(value) <= 0) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
},
|
||||
float: function(value, item){
|
||||
if (/^\d{0,10}$/.test(value) === false) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
if (parseInt(value) <= 0) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
},
|
||||
join_frequency: function(value){
|
||||
if(value > 7){
|
||||
return '不得超过7天'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
form.on('checkbox(type)', function(data) {
|
||||
$('[name="type"]').each(function(){
|
||||
var type = $(this).val();
|
||||
if ($(this).is(':checked')) {
|
||||
$('.reward-wrap .' + type + '-wrap').removeClass('layui-hide');
|
||||
if (type == 'point' || type == 'coupon') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|mum');
|
||||
}
|
||||
if (type == 'balance') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|float');
|
||||
}
|
||||
} else {
|
||||
$('.reward-wrap .' + type + '-wrap').addClass('layui-hide');
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', '');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 表单提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
let coupon_selected_ids = coupon_select.getSelectedData().selectedIds;
|
||||
if (parseInt(data.field.level_id)){
|
||||
var levelId = [],
|
||||
levelName = [];
|
||||
$('.level-id').each(function(){
|
||||
if($(this).prop('checked')){
|
||||
levelId.push($(this).val());
|
||||
levelName.push($(this).attr("title"));
|
||||
}
|
||||
});
|
||||
data.field.level_id = levelId.toString();
|
||||
data.field.level_name = levelName.toString();
|
||||
}
|
||||
var type = [];
|
||||
$('.reward-wrap [name="type"]:checked').each(function(){
|
||||
type.push($(this).val());
|
||||
})
|
||||
|
||||
if ($.inArray('coupon', type) != -1 && coupon_selected_ids.length == 0) {
|
||||
layer.msg('请选择优惠券', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($.inArray('point', type) != -1 ) {
|
||||
if($('#point').val() <= 0){
|
||||
layer.msg('积分请输入正整数', {icon: 5});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var end_time = (new Date($("#end_time").val())).getTime();
|
||||
var old_end_time = (new Date($("#old_end_time").val())).getTime();
|
||||
if(old_end_time > end_time){
|
||||
layer.msg('结束时间不能小于之前设置的时间!', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.type = type.toString();
|
||||
data.field.coupon = coupon_selected_ids.toString();
|
||||
|
||||
if($("input[name='level_id']:checked").val() == 1 && data.field.level_id.length == 0){
|
||||
layer.msg('请选择会员等级', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
if($('.holiday-name').html()){
|
||||
data.field.holiday_name = $('.holiday-name').html();
|
||||
data.field.holiday_time =$('.holiday-name').attr('date-time')
|
||||
}else{
|
||||
data.field.holiday_name = '';
|
||||
data.field.holiday_time = '';
|
||||
}
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("scenefestival://shop/scenefestival/edit"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var upload = new Upload({
|
||||
elem: '#no_winning_img'
|
||||
});
|
||||
|
||||
//参与条件
|
||||
form.on('radio(participation)', function(data){
|
||||
if (parseInt(data.value))
|
||||
$('.participation-condition .layui-inline').removeClass('layui-hide');
|
||||
else
|
||||
$('.participation-condition .layui-inline').addClass('layui-hide');
|
||||
});
|
||||
|
||||
form.on('radio(join_type)', function(data){
|
||||
if (data.value == 1 ) {
|
||||
$("#time").addClass('layui-hide');
|
||||
}else {
|
||||
$("#time").removeClass('layui-hide');
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
//初始化数据
|
||||
function initTableData(){
|
||||
var levelIdStr = '{$info.level_id}',
|
||||
levelIdArr = levelIdStr.split(",");
|
||||
if (levelIdArr.length >= 1){
|
||||
$(".participation-condition input.level-id").each(function (index,item) {
|
||||
for (var i = 0; i < levelIdArr.length; i++){
|
||||
if (parseInt($(item).val()) == levelIdArr[i]){
|
||||
$(item).prop('checked',true);
|
||||
}
|
||||
}
|
||||
});
|
||||
form.render();
|
||||
}
|
||||
}
|
||||
|
||||
function backScenefestivalList() {
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/lists");
|
||||
}
|
||||
|
||||
// 选择节日日期
|
||||
function choose() {
|
||||
var data = {};
|
||||
laytpl($("#choose_time").html()).render(data, function(html) {
|
||||
layer.open({
|
||||
title: '选择节日',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['520px', 'auto'],
|
||||
btn:['确定','取消'],
|
||||
content: html,
|
||||
success: function (layero, index) {
|
||||
$('.holiday').each(function(){
|
||||
if($(this).html() == $('.holiday-name').html()){
|
||||
$(this).addClass('holiday-active bg-color')
|
||||
}
|
||||
});
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function holiday(data){
|
||||
$('.holiday').removeClass('holiday-active bg-color');
|
||||
$(data).addClass('holiday-active bg-color');
|
||||
$('.holiday-name').html($(data).html());
|
||||
$('.holiday-hidden').val(1);
|
||||
$('.holiday-name').attr('date-time' , $(data).attr('date-time'))
|
||||
}
|
||||
|
||||
//检测数据类型
|
||||
function detectionNumType(el,type){
|
||||
var value = $(el).val();
|
||||
|
||||
//大于零 且 不是小数
|
||||
if (value < 0 && type == 'integral')
|
||||
$(el).val(0);
|
||||
else if(type == 'integral')
|
||||
$(el).val(Math.round(value));
|
||||
|
||||
//大于1 且 不是小数
|
||||
if (value < 1 && type == 'positiveInteger'){
|
||||
$(el).val(1);
|
||||
} else if (type == 'positiveInteger'){
|
||||
var val = Math.round(value);
|
||||
if(Object.is(val,NaN)){
|
||||
$(el).val(1);
|
||||
}else{
|
||||
$(el).val(val);
|
||||
}
|
||||
}
|
||||
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveNumber'){
|
||||
value = parseFloat(value);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="choose_time">
|
||||
<div class="choose-time">
|
||||
<div class="choose-item">
|
||||
<p>传统节日</p>
|
||||
{foreach $jieri_list as $jieri_list_k => $jieri_list_v}
|
||||
<span class="border-color holiday" date-time="{$jieri_list_v.date}" onclick = "holiday(this)">{$jieri_list_v.holiday_cn}</span>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
403
addon/scenefestival/shop/view/scenefestival/lists.html
Executable file
403
addon/scenefestival/shop/view/scenefestival/lists.html
Executable file
@@ -0,0 +1,403 @@
|
||||
<style>
|
||||
.layui-table-view td:last-child>div{overflow: inherit;}
|
||||
.operation-wrap{position: relative;}
|
||||
.layui-table-box{overflow: inherit;}
|
||||
.layui-table-body{overflow: inherit;}
|
||||
.popup-qrcode-wrap{text-align: center;background: #fff;border-radius: 2px;box-shadow: 0 2px 8px 0 rgba(200,201,204,.5);padding: 10px;position: absolute;z-index: 1;top: -70px;left: -190px;display: none;width: 170px;height: 230px;}
|
||||
.popup-qrcode-wrap:before, .popup-qrcode-wrap:after {left: 100%;top: 50%;border: solid transparent;content: " ";height: 0;width: 0;position: absolute;pointer-events: none;}
|
||||
.popup-qrcode-wrap:before {border-color: transparent;border-left-color: #e5e5e5;border-width: 8px;margin-top: -29px;}
|
||||
.popup-qrcode-wrap:after {border-color: transparent;border-left-color: #ffffff;border-width: 7px;margin-top: -31px;}
|
||||
.popup-qrcode-wrap img{width: 150px;height: 150px;max-width: initial;}
|
||||
.popup-qrcode-wrap p{font-size: 12px;margin: 5px 0;line-height: 1.8!important;}
|
||||
.popup-qrcode-wrap a{font-size: 12px;}
|
||||
.popup-qrcode-wrap input{opacity: 0;position: absolute;}
|
||||
.popup-qrcode-wrap .popup-qrcode-loadimg {width: 16px!important; height: 16px!important; margin-top: 107px;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加节日有礼活动</button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="activity_name" placeholder="请输入活动名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-filter="search" lay-submit>筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="cards_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
<li data-status="0">未开始</li>
|
||||
<li data-status="1">进行中</li>
|
||||
<li data-status="2">已结束</li>
|
||||
<li data-status="3">已关闭</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="festival_list" lay-filter="festival_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始: {{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
未开始
|
||||
{{# }else if(d.status == 1){ }}
|
||||
进行中
|
||||
{{# }else if(d.status == 2){ }}
|
||||
已结束
|
||||
{{# }else if(d.status == 3){ }}
|
||||
已关闭
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-game-id="{{d.game_id}}">
|
||||
<div class="popup-qrcode-wrap"><img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif" /></div>
|
||||
<div class="table-btn">
|
||||
<!-- <a class="layui-btn" lay-event="select">推广</a>-->
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
{{# if(d.status == 0){ }}
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# }else if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="close">关闭</a>
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn" lay-event="record">领取记录</a>
|
||||
{{# }else if(d.status == 2){ }}
|
||||
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
<a class="layui-btn" lay-event="record">领取记录</a>
|
||||
{{# }else if(d.status == 3){ }}
|
||||
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
<a class="layui-btn" lay-event="record">领取记录</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 游戏推广 -->
|
||||
<script type="text/html" id="game_url">
|
||||
{{# if(d.path.h5.status == 1){ }}
|
||||
<img src="{{ ns.img(d.path.h5.img) }}" alt="推广二维码">
|
||||
<p class="qrcode-item-description">扫码后直接访问</p>
|
||||
<a class="text-color" href="javascript:ns.copy('h5_url_{{ d.game_id }}');">复制链接</a>
|
||||
<a class="text-color" href="{{ ns.img(d.path.h5.img) }}" download>下载二维码</a>
|
||||
<input class="layui-input" type="text" value="{{ d.path.h5.url }}" id="h5_url_{{ d.game_id }}" readonly>
|
||||
{{# } }}
|
||||
</script>
|
||||
<script>
|
||||
layui.use(['form', 'element','laytpl','laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laytpl = layui.laytpl,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(cards_tab)', function() {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#festival_list',
|
||||
url: ns.url("scenefestival://shop/scenefestival/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field:'activity_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
width:'15%'
|
||||
},
|
||||
{
|
||||
field:'festival_name',
|
||||
title: '节日名称',
|
||||
unresize: 'false',
|
||||
width:'15%'
|
||||
},{
|
||||
title: '参与条件',
|
||||
unresize: 'false',
|
||||
width:'15%',
|
||||
templet: function(data) {
|
||||
if(data.level_id == 0){
|
||||
return '全部会员';
|
||||
}else{
|
||||
return data.level_name;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '奖励发放时间',
|
||||
unresize: 'false',
|
||||
width:'15%',
|
||||
templet: function(data) {
|
||||
if(data.join_type == 1){
|
||||
return '活动时间内';
|
||||
}else{
|
||||
return '活动开始前'+data.join_frequency + '天';
|
||||
}
|
||||
}
|
||||
},
|
||||
// {
|
||||
// field:'winning_num',
|
||||
// title: '领取人数',
|
||||
// unresize: 'false',
|
||||
// width:'15%'
|
||||
// },
|
||||
{
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
templet: '#status'
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width: '14%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function(data) {
|
||||
var status = $(this).attr("data-status");
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/detail", {"festival_id": data.festival_id});
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/edit", {"festival_id": data.festival_id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deleteFestival(data.festival_id);
|
||||
break;
|
||||
case 'close': // 结束
|
||||
closeFestival(data.festival_id);
|
||||
break;
|
||||
case 'record': //领取记录
|
||||
location.hash = ns.hash("scenefestival://shop/record/lists", {"festival_id": data.festival_id});
|
||||
break;
|
||||
case 'select'://推广
|
||||
gameUrl(data);
|
||||
break;
|
||||
case 'start'://重启
|
||||
start(data.festival_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteFestival(festival_id) {
|
||||
layer.confirm('确定要删除该节日有礼活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("scenefestival://shop/scenefestival/delete"),
|
||||
data: {
|
||||
festival_id: festival_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 结束
|
||||
function closeFestival(festival_id) {
|
||||
|
||||
layer.confirm('确定要关闭该节日有礼活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("scenefestival://shop/scenefestival/finish"),
|
||||
data: {
|
||||
festival_id: festival_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//重新开始
|
||||
function start(festival_id) {
|
||||
|
||||
layer.confirm('确定要重启该节日有礼活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("scenefestival://shop/scenefestival/start"),
|
||||
data: {
|
||||
festival_id:festival_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
// 游戏推广
|
||||
function gameUrl(data) {
|
||||
$(".operation-wrap[data-game-id='" + data.game_id + "'] .popup-qrcode-wrap").css("display", "block");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ns.url("turntable://shop/turntable/gameUrl"),
|
||||
data: {
|
||||
'game_id': data.game_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
success: function (res) {
|
||||
if (res.data.path.h5.status == 1) {
|
||||
res.data.game_id = data.game_id;
|
||||
laytpl($("#game_url").html()).render(res.data, function (html) {
|
||||
$(".operation-wrap[data-game-id='" + data.game_id + "'] .popup-qrcode-wrap").html(html).show();
|
||||
|
||||
$("body").bind('click',function (e) {
|
||||
if (!$(e.target).closest(".popup-qrcode-wrap").length) {
|
||||
$(".operation-wrap[data-game-id='" + data.game_id + "'] .popup-qrcode-wrap").hide();
|
||||
$("body").unbind('click');
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.data.path.h5.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("scenefestival://shop/scenefestival/add");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user