初始上传
This commit is contained in:
126
addon/birthdaygift/api/controller/Config.php
Executable file
126
addon/birthdaygift/api/controller/Config.php
Executable file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\birthdaygift\model\BirthdayGift;
|
||||
use app\model\member\Member;
|
||||
|
||||
/**
|
||||
* 会员生日奖励
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 计算信息
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
//获取生日有礼信息
|
||||
$gift_model = new BirthdayGift();
|
||||
$info = $gift_model->getAward($this->site_id);
|
||||
$flag = false;
|
||||
if (!empty($info[ 'data' ])) {
|
||||
//获取会员信息
|
||||
$member_model = new Member();
|
||||
if (empty($info[ 'data' ][ 'level_id' ])) {
|
||||
// 所有会员
|
||||
$member_info = $member_model->getMemberInfo([['member_id', '=', $this->member_id], ['site_id', '=', $this->site_id]], 'member_id,nickname,member_level,member_level_name,birthday,reg_time')[ 'data' ];
|
||||
} else {
|
||||
$member_info = $member_model->getMemberInfo([['member_id', '=', $this->member_id], ['site_id', '=', $this->site_id], ['member_level', 'in', $info[ 'data' ][ 'level_id' ]]], 'member_id,nickname,member_level,member_level_name,birthday,reg_time')[ 'data' ];
|
||||
}
|
||||
if (!empty($member_info)) {
|
||||
// 判断今年有没有领取过
|
||||
$start_year = strtotime(date('Y-01-01 00:00:00'));
|
||||
$end_year = strtotime('+1 year', $start_year);
|
||||
|
||||
$record_condition[] = ['member_id', '=', $this->member_id];
|
||||
$record_condition[] = ['receive_time', '>', $start_year];
|
||||
$record_condition[] = ['receive_time', '<', $end_year];
|
||||
$recode = $gift_model->getRecordList($record_condition);
|
||||
if (empty($recode[ 'data' ])) {
|
||||
$today = date('Y-m-d', time());
|
||||
//以上条件都满足 判断奖励时间 (1生日当天 2生日当周 3生日当月)
|
||||
if ($info[ 'data' ][ 'activity_time_type' ] == 1) {
|
||||
$birthday = date('m-d', $member_info[ 'birthday' ]);
|
||||
if (date('m-d') == $birthday) {
|
||||
$flag = true;
|
||||
}
|
||||
} else if ($info[ 'data' ][ 'activity_time_type' ] == 2) {
|
||||
// 把会员的生日转换为当前的年份
|
||||
$birth_month_and_day = date('m-d', $member_info[ 'birthday' ]);
|
||||
$now_birthday = date('Y', time());
|
||||
$now_birthday_year_month_day = $now_birthday . '-' . $birth_month_and_day;
|
||||
$member_birthday_time = date_to_time($now_birthday_year_month_day);
|
||||
$end_time = date_to_time("$today sunday");
|
||||
$end_time_date = date('Y-m-d', $end_time);
|
||||
$begin_time = date_to_time("$end_time_date -6 days");
|
||||
if ($begin_time <= $member_birthday_time && $member_birthday_time <= $end_time) {
|
||||
$flag = true;
|
||||
}
|
||||
} else if ($info[ 'data' ][ 'activity_time_type' ] == 3) {
|
||||
$birthday = date('m', $member_info[ 'birthday' ]);
|
||||
if (date('m') == $birthday) {
|
||||
$flag = true;
|
||||
}
|
||||
}
|
||||
$info[ 'data' ][ 'nickname' ] = $member_info[ 'nickname' ];
|
||||
}
|
||||
}
|
||||
}
|
||||
$info[ 'data' ][ 'flag' ] = $flag;
|
||||
|
||||
if (!empty($info[ 'data' ][ 'coupon_list' ])) {
|
||||
foreach ($info[ 'data' ][ 'coupon_list' ] as $kk => $vv) {
|
||||
$coupon_flag = false;
|
||||
if ($vv[ 'status' ] == 1) {
|
||||
if ($vv[ 'count' ] == -1 || $vv[ 'count' ] - $vv[ 'lead_count' ] > 0) $coupon_flag = true;
|
||||
}
|
||||
$info[ 'data' ][ 'coupon_list' ][ $kk ][ 'coupon_flag' ] = $coupon_flag;
|
||||
}
|
||||
} else {
|
||||
$info[ 'data' ][ 'coupon_list' ] = [];
|
||||
}
|
||||
return $this->response($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取生日奖励
|
||||
*/
|
||||
public function receive()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$activity_id = $this->params[ 'id' ];
|
||||
if (empty($activity_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$gift_model = new BirthdayGift();
|
||||
$res = $gift_model->receive($this->member_id, $activity_id, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询领取记录
|
||||
*/
|
||||
public function getRecord()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
$gift_model = new BirthdayGift();
|
||||
$res = $gift_model->verificationRecord($this->member_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
52
addon/birthdaygift/config/diy_view.php
Executable file
52
addon/birthdaygift/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' => 'BIRTHDAYGIFT',
|
||||
// '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' => []
|
||||
];
|
||||
28
addon/birthdaygift/config/event.php
Executable file
28
addon/birthdaygift/config/event.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\birthdaygift\event\ShowPromotion',
|
||||
],
|
||||
'PointRule' => [
|
||||
'addon\birthdaygift\event\PointRule',
|
||||
],
|
||||
//活动开启
|
||||
'OpenBirthdayGift' => [
|
||||
'addon\birthdaygift\event\OpenBirthdayGift',
|
||||
],
|
||||
//活动关闭
|
||||
'CloseBirthdayGift' => [
|
||||
'addon\birthdaygift\event\CloseBirthdayGift',
|
||||
],
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/birthdaygift/config/info.php
Executable file
20
addon/birthdaygift/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'birthdaygift',
|
||||
'title' => '生日有礼',
|
||||
'description' => '生日有礼',
|
||||
'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
77
addon/birthdaygift/config/menu_shop.php
Executable file
77
addon/birthdaygift/config/menu_shop.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT',
|
||||
'title' => '生日有礼',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/lists',
|
||||
'picture' => '',
|
||||
'picture_selected' => '',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'sort' => 101,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_LIST',
|
||||
'title' => '生日有礼',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/lists',
|
||||
'is_show' => 0,
|
||||
'sort' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_ADD_BIRTHDAYGIFT',
|
||||
'title' => '添加生日有礼活动',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/add',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_EDIT_BIRTHDAYGIFT',
|
||||
'title' => '编辑生日有礼活动',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/edit',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_DETAIL_BIRTHDAYGIFT',
|
||||
'title' => '生日有礼活动详情',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_DELETE_BIRTHDAYGIFT',
|
||||
'title' => '生日有礼活动删除',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/delete',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_CLOSE_BIRTHDAYGIFT',
|
||||
'title' => '关闭生日有礼活动',
|
||||
'url' => 'birthdaygift://shop/birthdaygift/close',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BIRTHDAYGIFT_RECORD_BIRTHDAYGIFT',
|
||||
'title' => '生日有礼活动领取',
|
||||
'url' => 'birthdaygift://shop/record/lists',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/birthdaygift/data/install.sql
Executable file
1
addon/birthdaygift/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/birthdaygift/data/uninstall.sql
Executable file
1
addon/birthdaygift/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
28
addon/birthdaygift/event/CloseBirthdayGift.php
Executable file
28
addon/birthdaygift/event/CloseBirthdayGift.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
use addon\birthdaygift\model\BirthdayGift;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class CloseBirthdayGift
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$model = new BirthdayGift();
|
||||
$res = $model->cronCloseBirthdayGift($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
25
addon/birthdaygift/event/Install.php
Executable file
25
addon/birthdaygift/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
28
addon/birthdaygift/event/OpenBirthdayGift.php
Executable file
28
addon/birthdaygift/event/OpenBirthdayGift.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
use addon\birthdaygift\model\BirthdayGift;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenBirthdayGift
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$model = new BirthdayGift();
|
||||
$res = $model->cronOpenBirthdayGift($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
32
addon/birthdaygift/event/PointRule.php
Executable file
32
addon/birthdaygift/event/PointRule.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
/**
|
||||
* 积分规则
|
||||
*/
|
||||
class PointRule
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$info = model("promotion_birthdaygift")->getInfo([ ['status', '=', 1], ['site_id', '=', $data['site_id']]], '*');
|
||||
|
||||
$data = [
|
||||
'title' => '会员生日礼',
|
||||
'content' => empty($info) || !strstr($info['type'], 'point') ? '-' : "会员生日,赠送" . $info['point'] . "积分",
|
||||
'url' => 'birthdaygift://shop/birthdaygift/lists',
|
||||
'update_time' => empty($info) ? 0 : $info['update_time']
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
95
addon/birthdaygift/event/ShowPromotion.php
Executable file
95
addon/birthdaygift/event/ShowPromotion.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 店铺活动
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'birthdaygift',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'member',
|
||||
//展示主题
|
||||
'title' => '生日有礼',
|
||||
//展示介绍
|
||||
'description' => '生日有礼',
|
||||
//展示图标
|
||||
'icon' => 'addon/birthdaygift/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'birthdaygift://shop/birthdaygift/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' ])) {
|
||||
$info = model("promotion_birthdaygift")->getInfo([ [ 'status', '=', 1 ], [ 'site_id', '=', $params[ 'site_id' ] ] ], 'id');
|
||||
if (!empty($info)) {
|
||||
return [
|
||||
'count' => 1
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
|
||||
$list = model("promotion_birthdaygift")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'status', '<>', -1 ],
|
||||
[ 'is_delete', '=', 0 ]
|
||||
], 'activity_name as promotion_name,id as promotion_id,start_time,end_time', '', 'a', null, 'activity_name');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#6D66FF'
|
||||
]
|
||||
] : [];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
25
addon/birthdaygift/event/UnInstall.php
Executable file
25
addon/birthdaygift/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/birthdaygift/icon.png
Executable file
BIN
addon/birthdaygift/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
422
addon/birthdaygift/model/BirthdayGift.php
Executable file
422
addon/birthdaygift/model/BirthdayGift.php
Executable file
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\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 think\facade\Db;
|
||||
|
||||
/**
|
||||
* 生日有礼
|
||||
*/
|
||||
class BirthdayGift extends BaseModel
|
||||
{
|
||||
public $status = [
|
||||
0 => '未开始',
|
||||
1 => '进行中',
|
||||
2 => '已结束',
|
||||
3 => '已关闭',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取订单详细列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @param null $group
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function birthdayGiftPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [], $group = null, $limit = null)
|
||||
{
|
||||
$list = model('promotion_birthdaygift')->pageList($condition, $field, $order, $page, $page_size, $alias, $join, $group, $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加生日有礼
|
||||
*/
|
||||
public function addBirthdayGiftActivity($data)
|
||||
{
|
||||
//时间检测
|
||||
if ($data[ 'end_time' ] < time()) {
|
||||
return $this->error('', '结束时间不能早于当前时间');
|
||||
}
|
||||
|
||||
$activity_info = model('promotion_birthdaygift')->getInfo([
|
||||
['status', 'in', '0,1'],
|
||||
['site_id', '=', $data[ 'site_id' ]],
|
||||
['', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))')]
|
||||
], 'start_time,end_time');
|
||||
if (!empty($activity_info)) {
|
||||
return $this->error('', '此时间段已有同类型的活动');
|
||||
}
|
||||
$data[ 'create_time' ] = time();
|
||||
if ($data[ 'start_time' ] <= time()) {
|
||||
$data[ 'status' ] = 1;//直接启动
|
||||
} else {
|
||||
$data[ 'status' ] = 0;
|
||||
}
|
||||
|
||||
model('promotion_birthdaygift')->startTrans();
|
||||
try {
|
||||
|
||||
$res = model('promotion_birthdaygift')->add($data);
|
||||
|
||||
$cron = new Cron();
|
||||
if ($data[ 'start_time' ] <= time()) {
|
||||
$cron->addCron(1, 0, '生日有礼活动关闭', 'CloseBirthdayGift', $data[ 'end_time' ], $res);
|
||||
} else {
|
||||
$cron->addCron(1, 0, '生日有礼活动开启', 'OpenBirthdayGift', $data[ 'start_time' ], $res);
|
||||
$cron->addCron(1, 0, '生日有礼活动关闭', 'CloseBirthdayGift', $data[ 'end_time' ], $res);
|
||||
}
|
||||
|
||||
model('promotion_birthdaygift')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_birthdaygift')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑生日有礼活动
|
||||
* @param array $data 活动数据
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function editBirthdayGiftActivity($data, $id)
|
||||
{
|
||||
//时间检测
|
||||
if ($data[ 'end_time' ] < time()) {
|
||||
return $this->error('', '结束时间不能早于当前时间');
|
||||
}
|
||||
|
||||
$activity_info = model('promotion_birthdaygift')->getInfo([
|
||||
['status', 'in', '0,1'],
|
||||
['site_id', '=', $data[ 'site_id' ]],
|
||||
['', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))')],
|
||||
['id', '<>', $id],
|
||||
], 'id,start_time,end_time');
|
||||
if (!empty($activity_info)) {
|
||||
return $this->error('', '此时间段已有同类型的活动');
|
||||
}
|
||||
$data[ 'update_time' ] = time();
|
||||
if ($data[ 'start_time' ] <= time()) {
|
||||
$data[ 'status' ] = 1;//直接启动
|
||||
} else {
|
||||
$data[ 'status' ] = 0;
|
||||
}
|
||||
|
||||
model('promotion_birthdaygift')->startTrans();
|
||||
try {
|
||||
|
||||
model('promotion_birthdaygift')->update($data, [['site_id', '=', $data[ 'site_id' ]], ['id', '=', $id]]);
|
||||
|
||||
$cron = new Cron();
|
||||
|
||||
$cron->deleteCron([['event', '=', 'CloseBirthdayGift'], ['relate_id', '=', $id]]);
|
||||
$cron->deleteCron([['event', '=', 'OpenBirthdayGift'], ['relate_id', '=', $id]]);
|
||||
|
||||
if ($data[ 'start_time' ] <= time()) {
|
||||
$cron->addCron(1, 0, '生日有礼关闭', 'CloseBirthdayGift', $data[ 'end_time' ], $id);
|
||||
} else {
|
||||
$cron->addCron(1, 0, '生日有礼开启', 'OpenBirthdayGift', $data[ 'start_time' ], $id);
|
||||
$cron->addCron(1, 0, '生日有礼关闭', 'CloseBirthdayGift', $data[ 'end_time' ], $id);
|
||||
}
|
||||
|
||||
model('promotion_birthdaygift')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_birthdaygift')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改生日有礼活动,用于做状态修改
|
||||
* @param $id
|
||||
* @param $site_id
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function updateBirthdayGift($id, $site_id, $data = [])
|
||||
{
|
||||
$res = model('promotion_birthdaygift')->update($data, [['id', '=', $id], ['site_id', '=', $site_id]]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生日有礼列表
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getBirthdayGiftList($condition, $field = '*')
|
||||
{
|
||||
$list = model('promotion_birthdaygift')->getList($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生日有礼详情
|
||||
* @param $condition
|
||||
* @param $field
|
||||
* @return array
|
||||
*/
|
||||
public function getBirthdayGiftDetail($condition, $field)
|
||||
{
|
||||
$res = model('promotion_birthdaygift')->getInfo($condition, $field);
|
||||
if (!empty($res)) {
|
||||
$res[ 'type' ] = explode(',', $res[ '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
|
||||
* @return array
|
||||
*/
|
||||
public function getAward($site_id)
|
||||
{
|
||||
// 获取进行中的生日有礼
|
||||
$award_info = model('promotion_birthdaygift')->getInfoTo([['site_id', '=', $site_id], ['status', '=', '1'], ['is_delete', '=', '0']], 'id,activity_name,activity_time_type,level_id,blessing_content,type,point,balance,balance_type,balance_money,coupon,level_name');
|
||||
if (!empty($award_info)) {
|
||||
$award_info[ 'type' ] = explode(',', $award_info[ '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);
|
||||
}
|
||||
|
||||
public function receive($member_id, $activity_id, $site_id)
|
||||
{
|
||||
$award_info = model('promotion_birthdaygift')->getInfo([['site_id', '=', $site_id], ['id', '=', $activity_id], ['is_delete', '=', '0'], ['status', '=', 1]], 'id,activity_name,activity_time_type,level_id,blessing_content,type,point,balance,balance_type,balance_money,coupon');
|
||||
if (empty($award_info)) 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($award_info[ 'level_id' ])) {
|
||||
$level = explode(',', $award_info[ 'level_id' ]);
|
||||
if (!in_array($member_info[ 'member_level' ], $level)) {
|
||||
return $this->error('', "只有{$award_info['level_name']}等级的会员可参与该活动");
|
||||
}
|
||||
}
|
||||
|
||||
// 判断今年有没有领取过
|
||||
$start_year = strtotime(date('Y-01-01 00:00:00'));
|
||||
$end_year = strtotime('+1 year', $start_year);
|
||||
|
||||
$record_condition[] = ['member_id', '=', $member_id];
|
||||
$record_condition[] = ['receive_time', '>', $start_year];
|
||||
$record_condition[] = ['receive_time', '<', $end_year];
|
||||
|
||||
$recode = $this->getRecordList($record_condition,'record_id');
|
||||
if (!empty($recode[ 'data' ])) {
|
||||
return $this->error('', "今年您已经领取过生日有礼啦");
|
||||
}
|
||||
|
||||
model('promotion_birthdaygift_record')->startTrans();
|
||||
try {
|
||||
$member_account = new MemberAccount();
|
||||
|
||||
if (!empty($award_info[ 'type' ])) {
|
||||
$type_arr = explode(',', $award_info[ 'type' ]);
|
||||
|
||||
foreach ($type_arr as $v) {
|
||||
switch ($v) {
|
||||
case 'point':
|
||||
// 积分
|
||||
$member_account->addMemberAccount($site_id, $member_id, AccountDict::point, $award_info[ 'point' ], 'birthdaygift', $activity_id, '生日有礼活动奖励发放');
|
||||
break;
|
||||
case 'balance':
|
||||
// 余额
|
||||
if ($award_info[ 'balance_type' ] == 0) {
|
||||
$member_account->addMemberAccount($site_id, $member_id, AccountDict::balance, $award_info[ 'balance' ], 'birthdaygift', $activity_id, '生日有礼活动奖励发放');
|
||||
} else {
|
||||
$member_account->addMemberAccount($site_id, $member_id, 'balance_money', $award_info[ 'balance_money' ], 'birthdaygift', $activity_id, '生日有礼活动奖励发放');
|
||||
}
|
||||
break;
|
||||
case 'coupon':
|
||||
// 优惠券
|
||||
$coupon = new Coupon();
|
||||
$coupon_list = explode(',', $award_info[ 'coupon' ]);
|
||||
$coupon_list = array_map(function($value) {
|
||||
return ['coupon_type_id' => $value, 'num' => 1];
|
||||
}, $coupon_list);
|
||||
$receive_res = $coupon->giveCoupon($coupon_list, $site_id, $member_id, Coupon::GET_TYPE_ACTIVITY_GIVE);
|
||||
break;
|
||||
case 4:
|
||||
// 赠品
|
||||
break;
|
||||
}
|
||||
}
|
||||
$record[ 'member_id' ] = $member_id;
|
||||
$record[ 'member_name' ] = $member_info[ 'nickname' ];
|
||||
$record[ 'activity_id' ] = $activity_id;
|
||||
$record[ 'receive_time' ] = time();
|
||||
|
||||
}
|
||||
$res = model('promotion_birthdaygift_record')->add($record);
|
||||
model('promotion_birthdaygift_record')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_games')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生日有礼奖励信息列表
|
||||
* @param $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getRecordList($condition, $field = '*')
|
||||
{
|
||||
$list = model('promotion_birthdaygift_record')->getList($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生日有礼奖励分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @param null $group
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getRecordPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [], $group = null, $limit = null)
|
||||
{
|
||||
$list = model('promotion_birthdaygift_record')->pageList($condition, $field, $order, $page, $page_size, $alias, $join, $group, $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证当前年是否领取
|
||||
*/
|
||||
public function verificationRecord($member_id)
|
||||
{
|
||||
$list = $this->getRecordList([['member_id', '=', $member_id]]);
|
||||
$res = true;
|
||||
if ($list[ 'data' ]) {
|
||||
foreach ($list[ 'data' ] as $key => $val) {
|
||||
if (date('Y', $val[ 'receive_time' ]) == date('Y', time())) {
|
||||
$res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时开启活动
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function cronOpenBirthdayGift($id)
|
||||
{
|
||||
$info = model('promotion_birthdaygift')->getInfo([['id', '=', $id]], 'start_time,status');
|
||||
if (!empty($info)) {
|
||||
if ($info[ 'start_time' ] <= time() && $info[ 'status' ] == 0) {
|
||||
|
||||
model('promotion_birthdaygift')->startTrans();
|
||||
try {
|
||||
|
||||
model('promotion_birthdaygift')->update(['status' => 1], [['id', '=', $id]]);
|
||||
|
||||
model('promotion_birthdaygift')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_birthdaygift')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error('', '生日有礼活动已开启或者关闭');
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error('', '生日有礼活动不存在');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时关闭活动
|
||||
* @param $recommend_id
|
||||
* @return array
|
||||
*/
|
||||
public function cronCloseBirthdayGift($id)
|
||||
{
|
||||
$info = model('promotion_birthdaygift')->getInfo([['id', '=', $id]], 'status');
|
||||
if (!empty($info)) {
|
||||
if ($info[ 'status' ] == 1) {
|
||||
|
||||
model('promotion_birthdaygift')->startTrans();
|
||||
try {
|
||||
|
||||
model('promotion_birthdaygift')->update(['status' => -1], [['id', '=', $id]]);
|
||||
|
||||
model('promotion_birthdaygift')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
model('promotion_birthdaygift')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->error('', '生日有礼活动已关闭');
|
||||
}
|
||||
} else {
|
||||
return $this->error('', '生日有礼活动不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
240
addon/birthdaygift/shop/controller/Birthdaygift.php
Executable file
240
addon/birthdaygift/shop/controller/Birthdaygift.php
Executable file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\shop\controller;
|
||||
|
||||
use addon\coupon\model\CouponType;
|
||||
use app\model\member\MemberLevel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\birthdaygift\model\BirthdayGift as BirthdayGiftModel;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 生日有礼控制器
|
||||
*/
|
||||
class Birthdaygift extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'BIRTHDAYGIFT_CSS' => __ROOT__ . '/addon/birthdaygift/shop/view/public/css',
|
||||
'BIRTHDAYGIFT_JS' => __ROOT__ . '/addon/birthdaygift/shop/view/public/js',
|
||||
'BIRTHDAYGIFT_IMG' => __ROOT__ . '/addon/birthdaygift/shop/view/public/img',
|
||||
];
|
||||
//执行父类构造函数
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生日有礼活动列表
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$status = input('status', '');
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'is_delete', '=', 0 ];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'activity_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
$gift_model = new BirthdayGiftModel();
|
||||
$order = 'create_time DESC';
|
||||
$field = '*';
|
||||
$lists = $gift_model->birthdayGiftPageList($condition, $page, $page_size, $order, $field);
|
||||
return $lists;
|
||||
} else {
|
||||
return $this->fetch('birthdaygift/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建生日有礼活动
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
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;
|
||||
}
|
||||
$data = [
|
||||
'activity_name' => input('activity_name', ''),
|
||||
'activity_time_type' => input('activity_time_type', 1),// 活动时间(1生日当天2生日当周3生日当月)
|
||||
'blessing_content' => input('blessing_content', ''),
|
||||
'level_id' => input('level_id', 0),
|
||||
'level_name' => input('level_name', ''),
|
||||
'type' => input('type', ''),
|
||||
'point' => $point,
|
||||
'balance' => $balance,
|
||||
'balance_type' => input('balance_type', '0'),
|
||||
'balance_money' => $balance_money,
|
||||
'coupon' => $coupon,
|
||||
'site_id' => $this->site_id,
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
];
|
||||
$gift_model = new BirthdayGiftModel();
|
||||
$res = $gift_model->addBirthdayGiftActivity($data);
|
||||
return $res;
|
||||
} 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' ]);
|
||||
|
||||
return $this->fetch('birthdaygift/add', $this->replace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生日有礼详情
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$activity_id = input('id', '0');
|
||||
//获取信息
|
||||
$activity_model = new BirthdayGiftModel();
|
||||
$info = $activity_model->getBirthdayGiftDetail([ [ 'site_id', '=', $this->site_id ], [ 'id', '=', $activity_id ] ], '*')[ 'data' ] ?? [];
|
||||
if (empty($info)) $this->error('未获取到活动数据', href_url('birthdaygift://shop/birthdaygift/lists'));
|
||||
$info[ 'status_name' ] = $activity_model->status[ $info[ 'status' ] ] ?? '';
|
||||
$this->assign('info', $info);
|
||||
|
||||
return $this->fetch('birthdaygift/detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生日有礼活动关闭
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
$activity_id = input('activity_id', '0');
|
||||
if (empty($activity_id)) $this->error('缺少必传参数', href_url('birthdaygift://shop/birthdaygift/lists'));
|
||||
$activity_model = new BirthdayGiftModel();
|
||||
$data = [
|
||||
'status' => -1
|
||||
];
|
||||
$res = $activity_model->updateBirthdayGift($activity_id, $this->site_id, $data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生日有礼编辑
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$activity_id = input('id', '0');
|
||||
if (request()->isJson()) {
|
||||
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;
|
||||
}
|
||||
$data = [
|
||||
'activity_name' => input('activity_name', ''),
|
||||
'activity_time_type' => input('activity_time_type', 1),// 活动时间(1生日当天2生日当周3生日当月)
|
||||
'blessing_content' => input('blessing_content', ''),
|
||||
'level_id' => input('level_id', 0),
|
||||
'level_name' => input('level_name', ''),
|
||||
'type' => input('type', ''),
|
||||
'point' => $point,
|
||||
'balance' => $balance,
|
||||
'balance_type' => input('balance_type', '0'),
|
||||
'balance_money' => $balance_money,
|
||||
'coupon' => $coupon,
|
||||
'site_id' => $this->site_id,
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
];
|
||||
|
||||
$gift_model = new BirthdayGiftModel();
|
||||
$res = $gift_model->editBirthdayGiftActivity($data, $activity_id);
|
||||
return $res;
|
||||
} 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' ]);
|
||||
|
||||
//获取信息
|
||||
$activity_model = new BirthdayGiftModel();
|
||||
$info = $activity_model->getBirthdayGiftDetail([ [ 'site_id', '=', $this->site_id ], [ 'id', '=', $activity_id ] ], '*');
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到活动数据', href_url('birthdaygift://shop/birthdaygift/lists'));
|
||||
|
||||
return $this->fetch('birthdaygift/edit', $this->replace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除生日有礼活动
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$activity_id = input('activity_id', 0);
|
||||
if (empty($activity_id)) $this->error('缺少必传参数', href_url('birthdaygift://shop/birthdaygift/lists'));
|
||||
$activity_model = new BirthdayGiftModel();
|
||||
$data = [
|
||||
'is_delete' => 1
|
||||
];
|
||||
$res = $activity_model->updateBirthdayGift($activity_id, $this->site_id, $data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
63
addon/birthdaygift/shop/controller/Record.php
Executable file
63
addon/birthdaygift/shop/controller/Record.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\birthdaygift\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\birthdaygift\model\BirthdayGift as BirthdayGiftModel;
|
||||
|
||||
/**
|
||||
* 生日有礼控制器
|
||||
*/
|
||||
class Record extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 生日有礼活动领取列表
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$activity_id = input('id',0);
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$alias = 'pbgr';
|
||||
$condition[] = ['pbgr.activity_id','=',$activity_id];
|
||||
$join = [
|
||||
[
|
||||
'promotion_birthdaygift pbg',
|
||||
'pbg.id = pbgr.activity_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
|
||||
//领取时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if (!empty($start_time) && empty($end_time)) {
|
||||
$condition[] = ['pbgr.receive_time', '>=', date_to_time($start_time)];
|
||||
} elseif (empty($start_time) && !empty($end_time)) {
|
||||
$condition[] = ['pbgr.receive_time', '<=', date_to_time($end_time)];
|
||||
} elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
|
||||
$condition[] = ['pbgr.receive_time', 'between', [date_to_time($start_time), date_to_time($end_time)]];
|
||||
}
|
||||
$field = 'pbgr.record_id,pbg.activity_name,pbg.activity_time_type,pbgr.member_name,pbgr.receive_time';
|
||||
$gift_model = new BirthdayGiftModel();
|
||||
$order = 'pbgr.receive_time DESC';
|
||||
$lists = $gift_model->getRecordPageList($condition,$page,$page_size,$order,$field,$alias,$join);
|
||||
return $lists;
|
||||
} else {
|
||||
$this->assign('activity_id',$activity_id);
|
||||
return $this->fetch("record/lists");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
415
addon/birthdaygift/shop/view/birthdaygift/add.html
Executable file
415
addon/birthdaygift/shop/view/birthdaygift/add.html
Executable file
@@ -0,0 +1,415 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/game.css">
|
||||
<style>
|
||||
.birthdaygift-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.birthdaygift-preview {
|
||||
margin: 50px 50px 0 0;
|
||||
}
|
||||
.flex {
|
||||
flex: 1;
|
||||
}
|
||||
.birthdaygift-preview img {
|
||||
width: 300px;
|
||||
height: 617px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.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 birthdaygift-flex">
|
||||
<div class="flex">
|
||||
<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-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">
|
||||
<label class="layui-form-label"><span class="required">*</span>发放时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" checked value="1" title="生日当天" class="layui-input len-mid" autocomplete="off" >
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" value="2" title="生日当周(自然周)" class="layui-input len-mid" autocomplete="off" >
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" value="3" title="生日当月(自然月)" class="layui-input len-mid" autocomplete="off" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">在活动期间内,积分、余额、优惠劵只赠送一次</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">祝福语:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="blessing_content" 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>
|
||||
|
||||
</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" 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="hidden" 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>
|
||||
|
||||
</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="backBirthdayGiftList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="birthdaygift-preview">
|
||||
<img src="__STATIC__/img/birthday_gift.png" >
|
||||
</div>-->
|
||||
</div>
|
||||
<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
|
||||
});
|
||||
}
|
||||
|
||||
//祝福语
|
||||
$('textarea[name="remark"]').bind('input propertychange', function () {
|
||||
$('.preview-content-desc').text($(this).val() || '祝福语');
|
||||
});
|
||||
|
||||
//参与条件
|
||||
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.verify({
|
||||
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的整数';
|
||||
}
|
||||
},
|
||||
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();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
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.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;
|
||||
}
|
||||
data.field.award_json = JSON.stringify(tableData);
|
||||
|
||||
if (!data.field.no_winning_img && upload.path != 'public/uniapp/game/no_winning.png') upload.delete();
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/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("birthdaygift://shop/birthdaygift/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 backBirthdayGiftList() {
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/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);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
156
addon/birthdaygift/shop/view/birthdaygift/detail.html
Executable file
156
addon/birthdaygift/shop/view/birthdaygift/detail.html
Executable file
@@ -0,0 +1,156 @@
|
||||
<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>{: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.activity_time_type == 1}
|
||||
生日当天
|
||||
{elseif $info.activity_time_type == 2 /}
|
||||
生日当周(自然周)
|
||||
{else/}
|
||||
生日当月(自然月)
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
{if in_array('point', $info['type'])}
|
||||
<div class="promotion-view-item">
|
||||
<label>奖励积分:</label>
|
||||
<span>{$info.point}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if in_array('balance', $info['type'])}
|
||||
<div class="layui-form-item">
|
||||
<label>奖励红包:</label>
|
||||
<span>{$info.blessing_content}</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['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)}{else/}""{/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;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}]
|
||||
],
|
||||
data: promotion_list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
428
addon/birthdaygift/shop/view/birthdaygift/edit.html
Executable file
428
addon/birthdaygift/shop/view/birthdaygift/edit.html
Executable file
@@ -0,0 +1,428 @@
|
||||
<link rel="stylesheet" href="SHOP_CSS/game.css">
|
||||
<style>
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.flex {
|
||||
flex: 1;
|
||||
}
|
||||
.birthdaygift-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.birthdaygift-preview img {
|
||||
width: 300px;
|
||||
height: 617px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.birthdaygift-preview {
|
||||
margin: 50px 50px 0 0;
|
||||
}
|
||||
|
||||
.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 birthdaygift-flex">
|
||||
<div class="flex">
|
||||
<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-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" {if condition="$info.status == 1"}disabled {/if} value="{:date('Y-m-d H:i:s', $info.start_time)}" class="layui-input" name="start_time" lay-verify="required" id="start_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" {if condition="$info.status == 1"}disabled {/if} value="{:date('Y-m-d H:i:s', $info.end_time)}" class="layui-input" name="end_time" lay-verify="required|times" id="end_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
{if condition="$info.status == 1"}
|
||||
<div class="word-aux">
|
||||
<p>活动进行中时间不可更改</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>发放时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" {if $info.activity_time_type == 1} checked {/if} value="1" title="生日当天" class="layui-input len-mid" autocomplete="off" disabled>
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" {if $info.activity_time_type == 2} checked {/if} value="2" title="生日当周(自然周)" class="layui-input len-mid" autocomplete="off" disabled>
|
||||
<input type="radio" name="activity_time_type" lay-verify="required" {if $info.activity_time_type == 3} checked {/if} value="3" title="生日当月(自然月)" class="layui-input len-mid" autocomplete="off" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">在活动期间内,积分、余额、优惠劵只赠送一次</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">祝福语:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="blessing_content" class="layui-textarea len-long" maxlength="150">{$info.blessing_content}</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="全部会员" {if !$info.level_id}checked{/if}>
|
||||
<input type="radio" name="level_id" value="1" lay-filter="participation" title="部分会员" {if $info.level_id}checked{/if}>
|
||||
</div>
|
||||
<div class="layui-inline {if !$info.level_id}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>
|
||||
</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['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['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['type']) }checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="point-wrap {if !in_array('point', $info['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')" id="point" type="number" lay-verify="{if in_array('point', $info['type']) }required|num{/if}" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="balance-wrap {if !in_array('balance', $info['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="hidden" 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>
|
||||
|
||||
</div>
|
||||
<div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>
|
||||
</div>
|
||||
|
||||
<div class="coupon-wrap {if !in_array('coupon', $info['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="id" value="{$info.id}">
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backBirthdayGiftList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="birthdaygift-preview">
|
||||
<img src="__STATIC__/img/birthday_gift.png" >
|
||||
</div>-->
|
||||
</div>
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script>
|
||||
var form,laydate,laytpl,
|
||||
repeat_flag = false,
|
||||
awardId = 0,
|
||||
minDate = "",
|
||||
currentDate = new Date(),
|
||||
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;
|
||||
currentDate.setDate(currentDate.getDate() + 30);
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
done: function(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.render();
|
||||
|
||||
initTableData();
|
||||
|
||||
//参与条件
|
||||
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.verify({
|
||||
type: function(){
|
||||
if ($('.reward-wrap [name="type"]:checked').length == 0) {
|
||||
return '请选择邀请人可得奖励';
|
||||
}
|
||||
},
|
||||
mum: function(value, item){
|
||||
if (isNaN(parseInt(value))) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
value = parseInt(value);
|
||||
if (/^\d{0,10}$/.test(value) === false || value <= 0) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
},
|
||||
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();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
if($("input[name='level_id']:checked").val() == 1 && data.field.level_id.length == 0){
|
||||
layer.msg('请选择会员等级', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
var type = [];
|
||||
$('.reward-wrap [name="type"]:checked').each(function(){
|
||||
type.push($(this).val());
|
||||
});
|
||||
|
||||
$($("input[name='checked_id']")).each(function(){
|
||||
coupon_id.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;
|
||||
}
|
||||
}
|
||||
|
||||
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(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/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("birthdaygift://shop/birthdaygift/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
//初始化数据
|
||||
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 backBirthdayGiftList() {
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/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);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
252
addon/birthdaygift/shop/view/birthdaygift/lists.html
Executable file
252
addon/birthdaygift/shop/view/birthdaygift/lists.html
Executable file
@@ -0,0 +1,252 @@
|
||||
<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 .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="search_text" placeholder="请输入活动名称" autocomplete="off" class="layui-input">
|
||||
</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="bargain_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
<li data-status="1">进行中</li>
|
||||
<li data-status="-1">已结束</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="activity_list" lay-filter="activity_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
未开始
|
||||
{{# }else if(d.status == 1){ }}
|
||||
进行中
|
||||
{{# }else if(d.status == -1){ }}
|
||||
已结束
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-game-id="{{d.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="detail">详情</a>
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn" lay-event="close">关闭</a>
|
||||
{{# }else if(d.status == 0){ }}
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# }else if(d.status == -1){ }}
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# } }}
|
||||
<a class="layui-btn" lay-event="record">领取记录</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<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>
|
||||
layui.use(['form', 'element'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(bargain_tab)', function () {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#activity_list',
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field:'activity_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
width:'20%'
|
||||
}, {
|
||||
title: '发放时间',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
if (data.activity_time_type == 1){
|
||||
return '生日当天'
|
||||
}else if(data.activity_time_type == 2){
|
||||
return '生日当周(自然周)'
|
||||
}else if(data.activity_time_type == 3){
|
||||
return '生日当月(自然月)'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '状态',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: '#status'
|
||||
},{
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width:'20%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/detail", {"id": data.id});
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/edit", {"id": data.id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deleteActivity(data.id);
|
||||
break;
|
||||
case 'close': // 结束
|
||||
closeActivity(data.id);
|
||||
break;
|
||||
case 'record'://领取记录
|
||||
location.hash = ns.hash("birthdaygift://shop/record/lists", {"id": data.id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteActivity(id) {
|
||||
layer.confirm('确定要删除该活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/delete"),
|
||||
data: {
|
||||
activity_id: 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 closeActivity(id) {
|
||||
layer.confirm('确定要关闭该活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/finish"),
|
||||
data: {
|
||||
activity_id: 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 add() {
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/add");
|
||||
}
|
||||
</script>
|
||||
BIN
addon/birthdaygift/shop/view/public/img/birthday_background.png
Executable file
BIN
addon/birthdaygift/shop/view/public/img/birthday_background.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 97 KiB |
255
addon/birthdaygift/shop/view/record/lists.html
Executable file
255
addon/birthdaygift/shop/view/record/lists.html
Executable file
@@ -0,0 +1,255 @@
|
||||
<style>
|
||||
.layui-table-view td:last-child>div{overflow: inherit;}
|
||||
.layui-table-box{overflow: inherit;}
|
||||
.layui-table-body{overflow: inherit;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
</style>
|
||||
|
||||
<!-- 筛选面板 -->
|
||||
<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" 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 class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab">
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="record_list" lay-filter="record_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
未开始
|
||||
{{# }else if(d.status == 1){ }}
|
||||
进行中
|
||||
{{# }else if(d.status == -1){ }}
|
||||
已结束
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form' ,'laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#record_list',
|
||||
url: ns.url("birthdaygift://shop/record/lists"),
|
||||
where: {
|
||||
"id": {$activity_id}
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
field:'activity_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
width:'20%'
|
||||
}, {
|
||||
title: '活动时间',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
templet: function(data){
|
||||
if (data.activity_time_type == 1){
|
||||
return '生日当天'
|
||||
}else if(data.activity_time_type == 2){
|
||||
return '生日当周(自然周)'
|
||||
}else if(data.activity_time_type == 3){
|
||||
return '生日当月(自然月)'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '会员',
|
||||
width:'20%',
|
||||
unresize: 'false',
|
||||
field:'member_name',
|
||||
},{
|
||||
title: '领取时间',
|
||||
unresize: 'false',
|
||||
width:'20%',
|
||||
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
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/detail", {"id": data.id});
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/edit", {"id": data.id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deleteActivity(data.id);
|
||||
break;
|
||||
case 'close': // 结束
|
||||
closeActivity(data.id);
|
||||
break;
|
||||
case 'record'://领取记录
|
||||
location.hash = ns.hash("birthdaygift://shop/record/lists", {"id": data.id});
|
||||
break;
|
||||
case 'start'://重新开启
|
||||
start(data.game_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteActivity(id) {
|
||||
layer.confirm('确定要删除该活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/delete"),
|
||||
data: {
|
||||
activity_id: 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 closeActivity(id) {
|
||||
|
||||
layer.confirm('确定要关闭该活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("birthdaygift://shop/birthdaygift/finish"),
|
||||
data: {
|
||||
activity_id: 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(game_id) {
|
||||
|
||||
layer.confirm('确定要重启该刮刮乐活动吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("cards://shop/cards/start"),
|
||||
data: {
|
||||
game_id: game_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 add() {
|
||||
location.hash = ns.hash("birthdaygift://shop/birthdaygift/add");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user