初始上传
This commit is contained in:
64
addon/memberconsume/api/controller/Config.php
Executable file
64
addon/memberconsume/api/controller/Config.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Index.php
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
* @author : niuteam
|
||||
* @date : 2022.8.8
|
||||
* @version : v5.0.0.1
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\memberconsume\model\Consume;
|
||||
|
||||
|
||||
/**
|
||||
* 消费奖励
|
||||
* Class Config
|
||||
* @package addon\memberconsume\api\controller
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
public function info()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$out_trade_no = $this->params['out_trade_no'] ?? '';
|
||||
$consume_model = new Consume();
|
||||
$reward_list = $consume_model->getConsumeRecordList([['out_trade_no', '=', $out_trade_no]]);
|
||||
|
||||
$res = [
|
||||
'is_reward' => 0,
|
||||
'point_num' => 0,
|
||||
'growth_num' => 0,
|
||||
'coupon_list' => [],
|
||||
];
|
||||
|
||||
foreach($reward_list as $item){
|
||||
$res['is_reward'] = 1;
|
||||
switch($item['type']){
|
||||
case 'point':
|
||||
$res['point_num'] += $item['value'];
|
||||
break;
|
||||
case 'growth':
|
||||
$res['growth_num'] += $item['value'];
|
||||
break;
|
||||
case 'coupon':
|
||||
$res['coupon_list'][] = [
|
||||
'coupon_type_id' => $item['value'],
|
||||
'coupon_content' => $item['remark'],
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
}
|
||||
38
addon/memberconsume/config/diy_view.php
Executable file
38
addon/memberconsume/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'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' => []
|
||||
];
|
||||
45
addon/memberconsume/config/event.php
Executable file
45
addon/memberconsume/config/event.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
'OrderPayAfter' => [
|
||||
'addon\memberconsume\event\OrderPayAfter',
|
||||
],
|
||||
'GiftCardOrderPay' => [
|
||||
'addon\memberconsume\event\OrderPayAfter',
|
||||
],
|
||||
'BlindboxGoodsOrderPay' => [
|
||||
'addon\memberconsume\event\OrderPayAfter',
|
||||
],
|
||||
//会员行为事件
|
||||
'MemberAction' => [
|
||||
'addon\memberconsume\event\MemberAction',
|
||||
],
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\memberconsume\event\ShowPromotion',
|
||||
],
|
||||
|
||||
'MemberAccountFromType' => [
|
||||
'addon\memberconsume\event\MemberAccountFromType',
|
||||
],
|
||||
|
||||
'MemberAccountRule' => [
|
||||
'addon\memberconsume\event\MemberAccountRule',
|
||||
],
|
||||
|
||||
'OrderRefundFinish' => [
|
||||
'addon\memberconsume\event\OrderRefundFinish'
|
||||
],
|
||||
'PointRule' => [
|
||||
'addon\memberconsume\event\PointRule',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/memberconsume/config/info.php
Executable file
21
addon/memberconsume/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'memberconsume',
|
||||
'title' => '消费奖励',
|
||||
'description' => '会员消费后奖励设置',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
32
addon/memberconsume/config/menu_shop.php
Executable file
32
addon/memberconsume/config/menu_shop.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'MEMBER_CONSUME',
|
||||
'title' => '消费奖励',
|
||||
'url' => 'memberconsume://shop/config/index',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'is_control' => 1,
|
||||
'is_icon' => 0,
|
||||
'picture' => '',
|
||||
'picture_select' => '',
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'MEMBER_CONSUME_CONFIG',
|
||||
'title' => '奖励设置',
|
||||
'url' => 'memberconsume://shop/config/index',
|
||||
'is_show' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'MEMBER_CONSUME_LIST',
|
||||
'title' => '奖励记录',
|
||||
'url' => 'memberconsume://shop/config/lists',
|
||||
'is_show' => 1,
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
1
addon/memberconsume/data/install.sql
Executable file
1
addon/memberconsume/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/memberconsume/data/uninstall.sql
Executable file
1
addon/memberconsume/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
26
addon/memberconsume/event/Install.php
Executable file
26
addon/memberconsume/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
48
addon/memberconsume/event/MemberAccountFromType.php
Executable file
48
addon/memberconsume/event/MemberAccountFromType.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
/**
|
||||
* 会员账户变化来源类型
|
||||
*/
|
||||
class MemberAccountFromType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$from_type = [
|
||||
|
||||
'point' => [
|
||||
'memberconsume' => [
|
||||
'type_name' => '消费奖励',
|
||||
'admin_url' => 'admin/order/detail',
|
||||
'tag_name' => 'order_id'
|
||||
],
|
||||
|
||||
],
|
||||
'growth' => [
|
||||
'memberconsume' => [
|
||||
'type_name' => '消费奖励',
|
||||
'admin_url' => 'admin/order/detail',
|
||||
'tag_name' => 'order_id'
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
if ($data == '') {
|
||||
return $from_type;
|
||||
} else {
|
||||
return $from_type[$data] ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
35
addon/memberconsume/event/MemberAccountRule.php
Executable file
35
addon/memberconsume/event/MemberAccountRule.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
use addon\memberconsume\model\Consume;
|
||||
|
||||
/**
|
||||
* 会员账户变化规则
|
||||
*/
|
||||
class MemberAccountRule
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$config = new Consume();
|
||||
$info = $config->getConfig($data['site_id']);
|
||||
$return = [];
|
||||
if ($info['data']['is_use'] == 1) {
|
||||
$return['point'] = "会员消费,订单支付返积分,比率" . $info['data']['value']['return_point_rate'] . "%";
|
||||
$return['growth'] = "会员消费订单支付返成长值,比率" . $info['data']['value']['return_growth_rate'] . "%";
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
}
|
||||
29
addon/memberconsume/event/MemberAction.php
Executable file
29
addon/memberconsume/event/MemberAction.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
/**
|
||||
* 会员操作
|
||||
*/
|
||||
class MemberAction
|
||||
{
|
||||
/**
|
||||
* 会员操作
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
if ($data[ 'member_action' ] == 'memberconsume') {
|
||||
return success();
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
}
|
||||
27
addon/memberconsume/event/OrderPayAfter.php
Executable file
27
addon/memberconsume/event/OrderPayAfter.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
use addon\memberconsume\model\Consume as ConsumeModel;
|
||||
|
||||
/**
|
||||
* 订单支付事件
|
||||
*/
|
||||
class OrderPayAfter
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$consume_model = new ConsumeModel();
|
||||
$res = $consume_model->memberConsume([ 'out_trade_no' => $data[ 'out_trade_no' ]], $data[ 'order_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
28
addon/memberconsume/event/OrderRefundFinish.php
Executable file
28
addon/memberconsume/event/OrderRefundFinish.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
use addon\memberconsume\model\Consume as ConsumeModel;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 订单维权成功
|
||||
*/
|
||||
class OrderRefundFinish
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$consume_model = new ConsumeModel();
|
||||
$res = $consume_model->rewardRecovery($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
34
addon/memberconsume/event/PointRule.php
Executable file
34
addon/memberconsume/event/PointRule.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
use addon\memberconsume\model\Consume;
|
||||
|
||||
/**
|
||||
* 积分规则
|
||||
*/
|
||||
class PointRule
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$config = new Consume();
|
||||
$info = $config->getConfig($data[ 'site_id' ])[ 'data' ];
|
||||
|
||||
$data = [
|
||||
'title' => '会员消费奖励',
|
||||
'content' => !$info[ 'is_use' ] || !$info[ 'value' ][ 'return_point_rate' ] ? '-' : "会员消费,赠送消费金额" . $info[ 'value' ][ 'return_point_rate' ] . "%的积分",
|
||||
'url' => 'memberconsume://shop/config/index',
|
||||
'update_time' => $info[ 'modify_time' ]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
88
addon/memberconsume/event/ShowPromotion.php
Executable file
88
addon/memberconsume/event/ShowPromotion.php
Executable file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
use addon\memberconsume\model\Consume;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'memberconsume',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'member',
|
||||
//展示主题
|
||||
'title' => '消费奖励',
|
||||
//展示介绍
|
||||
'description' => '客户消费后发放奖励',
|
||||
//展示图标
|
||||
'icon' => 'addon/memberconsume/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'memberconsume://shop/config/index',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Consume() )->getConfig($params[ 'site_id' ])[ 'data' ];
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
return [
|
||||
'count' => $config[ 'is_use' ]
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$content = [];
|
||||
|
||||
$value = $config[ 'value' ];
|
||||
if ($value[ 'return_point_rate' ]) $content[] = '消费返消费额' . $value['return_point_rate'] . '%积分';
|
||||
if ($value[ 'return_growth_rate' ]) $content[] = '消费返消费额' . $value['return_growth_rate'] . '%成长值';
|
||||
if ($value[ 'coupon_list' ]) $content[] = '消费送优惠券';
|
||||
|
||||
return [
|
||||
'unlimited_time' => [
|
||||
'status' => $config[ 'is_use' ],
|
||||
'detail' => empty($content) ? '未配置活动' : implode('、', $content),
|
||||
'switch_type' => empty($content) ? 'jump' : 'switch',
|
||||
'config_key' => 'MEMBER_CONSUME_CONFIG'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/memberconsume/event/UnInstall.php
Executable file
26
addon/memberconsume/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return error('', "系统插件不允许删除");
|
||||
}
|
||||
}
|
||||
BIN
addon/memberconsume/icon.png
Executable file
BIN
addon/memberconsume/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
331
addon/memberconsume/model/Consume.php
Executable file
331
addon/memberconsume/model/Consume.php
Executable file
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\model;
|
||||
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
use app\model\member\MemberAccount as MemberAccountModel;
|
||||
use app\model\order\OrderCommon as OrderCommonModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
use addon\coupon\model\CouponType;
|
||||
use addon\coupon\model\Coupon;
|
||||
|
||||
/**
|
||||
* 会员消费
|
||||
*/
|
||||
class Consume extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 会员消费设置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setConfig($data, $is_use, $site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '会员消费设置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_CONSUME_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员消费设置
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_CONSUME_CONFIG' ] ]);
|
||||
|
||||
//数据处理
|
||||
if (empty($res[ 'data' ][ 'value' ])) $res[ 'data' ][ 'value' ] = [];
|
||||
$default_value = [
|
||||
//奖励回收
|
||||
'is_recovery_reward' => 0,
|
||||
//积分
|
||||
'is_return_point' => 0,
|
||||
'return_point_rate' => 0,
|
||||
//成长值
|
||||
'is_return_growth' => 0,
|
||||
'return_growth_rate' => 0,
|
||||
//优惠券
|
||||
'is_return_coupon' => 0,
|
||||
'return_coupon' => '',
|
||||
];
|
||||
foreach ($res['data']['value'] as $key=>$val){
|
||||
if(!isset($default_value[$key])) unset($res['data']['value'][$key]);
|
||||
}
|
||||
$res['data']['value'] = array_merge($default_value, $res['data']['value']);
|
||||
|
||||
//优惠券数据
|
||||
$coupon_list = [];
|
||||
if ($res[ 'data' ][ 'value' ][ 'is_return_coupon' ] == 1) {
|
||||
$coupon = new CouponType();
|
||||
$coupon_list = $coupon->getCouponTypeList([ [ 'site_id', '=', $site_id ], [ 'status', '=', 1 ], [ 'coupon_type_id', 'in', $res[ 'data' ][ 'value' ][ 'return_coupon' ] ] ])[ 'data' ];
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'coupon_list' ] = $coupon_list;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单信息
|
||||
* @param $out_trade_no
|
||||
* @return array
|
||||
*/
|
||||
public function getOrderInfo($out_trade_no)
|
||||
{
|
||||
$pay_info = model('pay')->getInfo([ [ 'out_trade_no', '=', $out_trade_no ], [ 'pay_status', '=', 2 ] ]);
|
||||
if (empty($pay_info)) return $this->error('', '支付信息未找到');
|
||||
|
||||
$order_info = [];
|
||||
switch ( $pay_info[ 'event' ] ) {
|
||||
case 'OrderPayNotify':
|
||||
//普通订单
|
||||
$order = new OrderCommonModel();
|
||||
$order_info = $order->getOrderInfo([ [ 'out_trade_no', '=', $out_trade_no ]], 'order_id, order_money, site_id, member_id, order_type')[ 'data' ];
|
||||
break;
|
||||
case 'GiftCardOrderPayNotify':
|
||||
//礼品卡
|
||||
$order_info = model('giftcard_order')->getInfo([ [ 'out_trade_no', '=', $out_trade_no ]], 'order_id,order_money, site_id, member_id');
|
||||
break;
|
||||
case 'BlindboxGoodsOrderPayNotify':
|
||||
//盲盒
|
||||
$order_info = model('blindbox_order')->getInfo([ [ 'out_trade_no', '=', $out_trade_no ]], 'order_id,price as order_money, site_id, member_id');
|
||||
break;
|
||||
case 'CashierOrderPayNotify':
|
||||
//收银订单
|
||||
$order = new OrderCommonModel();
|
||||
$order_info = $order->getOrderInfo([ [ 'out_trade_no', '=', $out_trade_no ], [ 'member_id', '>', 0 ], [ 'cashier_order_type', 'in', [ 'goods', 'card' ] ]], 'order_id, order_money, site_id, member_id, order_type, cashier_order_type, order_scene')[ 'data' ];
|
||||
break;
|
||||
}
|
||||
return $this->success($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费记录发放
|
||||
* @param $param
|
||||
* @param int $order_id
|
||||
* @return array
|
||||
*/
|
||||
public function memberConsume($param, $order_id = 0)
|
||||
{
|
||||
$out_trade_no = $param[ 'out_trade_no' ];
|
||||
|
||||
//支付信息
|
||||
$pay_info = model('pay')->getInfo([ [ 'out_trade_no', '=', $out_trade_no ], [ 'pay_status', '=', 2 ] ]);
|
||||
if (empty($pay_info)) return $this->error('', '支付信息未找到');
|
||||
|
||||
//订单信息
|
||||
$order_info_res = $this->getOrderInfo($param['out_trade_no']);
|
||||
if($order_info_res['code'] < 0) return $order_info_res;
|
||||
$order_info = $order_info_res['data'];
|
||||
if (empty($order_info)) return $this->success();
|
||||
|
||||
//检测是否发放过
|
||||
$count = model('promotion_consume_record')->getCount([ [ 'out_trade_no', '=', $param[ 'out_trade_no' ] ], [ 'order_id', '=', $order_id ] ]);
|
||||
if (!empty($count)) {
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
$consume_config = $this->getConfig($order_info[ 'site_id' ])[ 'data' ];
|
||||
if($consume_config['is_use'] == 0) return $this->success();
|
||||
|
||||
$member_account_model = new MemberAccountModel();
|
||||
$consume_data = [];
|
||||
|
||||
// 发放积分
|
||||
$consume_config = $consume_config[ 'value' ];
|
||||
if (!empty($consume_config[ 'return_point_rate' ])) {
|
||||
$adjust_num = intval($consume_config[ 'return_point_rate' ] / 100 * $order_info[ 'order_money' ]);
|
||||
if ($adjust_num > 0) {
|
||||
$remark = '活动奖励发放';
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'point', $adjust_num, 'memberconsume', $order_info[ 'order_id' ], $remark);
|
||||
$consume_data[] = [
|
||||
'site_id' => $order_info[ 'site_id' ],
|
||||
'type' => 'point',
|
||||
'value' => $adjust_num,
|
||||
'order_id' => $order_info[ 'order_id' ],
|
||||
'member_id' => $order_info[ 'member_id' ],
|
||||
'out_trade_no' => $pay_info[ 'out_trade_no' ],
|
||||
'remark' => $remark,
|
||||
'config' => json_encode($consume_config),
|
||||
'create_time' => time()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 发放成长值
|
||||
if (!empty($consume_config[ 'return_growth_rate' ])) {
|
||||
$adjust_num = intval($consume_config[ 'return_growth_rate' ] / 100 * $order_info[ 'order_money' ]);
|
||||
if ($adjust_num > 0) {
|
||||
$remark = '活动奖励发放';
|
||||
$member_account_model->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'growth', $adjust_num, 'memberconsume', $order_info[ 'order_id' ], $remark);
|
||||
$consume_data[] = [
|
||||
'site_id' => $order_info[ 'site_id' ],
|
||||
'type' => 'growth',
|
||||
'value' => $adjust_num,
|
||||
'order_id' => $order_info[ 'order_id' ],
|
||||
'member_id' => $order_info[ 'member_id' ],
|
||||
'out_trade_no' => $pay_info[ 'out_trade_no' ],
|
||||
'remark' => $remark,
|
||||
'config' => json_encode($consume_config),
|
||||
'create_time' => time()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 发放优惠券
|
||||
if (!empty($consume_config[ 'is_return_coupon' ]) && !empty($consume_config[ 'return_coupon' ])) {
|
||||
$coupon_type = new CouponType();
|
||||
$coupon_list = $coupon_type->getCouponTypeList([ [ 'site_id', '=', $order_info[ 'site_id' ] ], [ 'status', '=', 1 ], [ 'coupon_type_id', 'in', $consume_config[ 'return_coupon' ] ] ])[ 'data' ];
|
||||
$coupon = new Coupon();
|
||||
foreach ($coupon_list as $k => $v) {
|
||||
$res = $coupon->giveCoupon([ [ 'coupon_type_id' => $v[ 'coupon_type_id' ], 'num' => 1 ] ], $order_info[ 'site_id' ], $order_info[ 'member_id' ], Coupon::GET_TYPE_ACTIVITY_GIVE);
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
if ($v[ 'at_least' ] > 0) {
|
||||
$remark = '满' . $v[ 'at_least' ] . ( $v[ 'type' ] == 'discount' ? '打' . $v[ 'discount' ] : '减' . $v[ 'money' ] );
|
||||
} else {
|
||||
$remark = '无门槛' . ( $v[ 'type' ] == 'discount' ? '打' . $v[ 'discount' ] : '减' . $v[ 'money' ] );
|
||||
}
|
||||
|
||||
$consume_data[] = [
|
||||
'site_id' => $order_info[ 'site_id' ],
|
||||
'type' => 'coupon',
|
||||
'value' => $v[ 'coupon_type_id' ],
|
||||
'order_id' => $order_info[ 'order_id' ],
|
||||
'member_id' => $order_info[ 'member_id' ],
|
||||
'out_trade_no' => $pay_info[ 'out_trade_no' ],
|
||||
'remark' => $remark,
|
||||
'config' => json_encode($consume_config),
|
||||
'create_time' => time()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($consume_data) > 0) {
|
||||
model('promotion_consume_record')->addList($consume_data);
|
||||
}
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
private function returnStatusToZh($status)
|
||||
{
|
||||
$status_zh = [
|
||||
'pay' => '付款',
|
||||
'receive' => '收货',
|
||||
'complete' => '完成'
|
||||
];
|
||||
return $status_zh[ $status ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消费奖励列表
|
||||
* @param $condition
|
||||
* @param $field
|
||||
* @param $order
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConsumeRecordList($condition, $field = '*', $order = '')
|
||||
{
|
||||
$list = model('promotion_consume_record')->getList($condition, $field, $order);
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖励记录分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getConsumeRecordPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [])
|
||||
{
|
||||
$list = model('promotion_consume_record')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖励回收
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function rewardRecovery($data)
|
||||
{
|
||||
$order_info = $data['order_info'];
|
||||
$order_goods_info = $data['order_goods_info'];
|
||||
$is_refund_all = $data['is_all_refund'];
|
||||
$out_trade_no = $order_info['out_trade_no'];
|
||||
|
||||
$list = model('promotion_consume_record')->getList([ [ 'type', 'in', [ 'point', 'coupon', 'growth' ] ], [ 'out_trade_no', '=', $out_trade_no ], [ 'is_recycled', '=', 0 ] ]);
|
||||
if (!empty($list)) {
|
||||
$site_id = $list[ 0 ][ 'site_id' ];
|
||||
$member_id = $list[ 0 ][ 'member_id' ];
|
||||
|
||||
$consume_config = $this->getConfig($site_id)[ 'data' ];
|
||||
// 回收权益
|
||||
if ($consume_config[ 'value' ][ 'is_recovery_reward' ]) {
|
||||
$member_account = new MemberAccountModel();
|
||||
foreach ($list as $item) {
|
||||
// 扣除积分
|
||||
if ($item[ 'type' ] == 'point') {
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ] ], 'point');
|
||||
$return_value = $item['value'];
|
||||
if($order_info['order_money'] > 0){
|
||||
$return_value = round(($order_goods_info['goods_money'] / $order_info['goods_money']) * $item['value']);
|
||||
}
|
||||
$point = min($return_value, $member_info['point']);
|
||||
$res = $member_account->addMemberAccount($site_id, $member_id, 'point', -( $point ), 'memberconsume', $item[ 'order_id' ], '订单商品【'.$order_goods_info['sku_name'].'】退款奖励回收');
|
||||
if ($res[ 'code' ] == 0 && $is_refund_all) {
|
||||
model('promotion_consume_record')->update([ 'is_recycled' => 1 ], [ [ 'id', '=', $item[ 'id' ] ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除未使用的优惠券
|
||||
if ($item[ 'type' ] == 'coupon') {
|
||||
$coupon = model('promotion_coupon')->getFirstData([ [ 'member_id', '=', $member_id ], [ 'coupon_type_id', '=', $item[ 'value' ] ], [ 'state', '=', 1 ] ], 'coupon_id');
|
||||
if (!empty($coupon)) {
|
||||
$delete_num = model('promotion_coupon')->delete([ [ 'coupon_id', '=', $coupon[ 'coupon_id' ] ] ]);
|
||||
if ($delete_num) {
|
||||
model('promotion_consume_record')->update([ 'is_recycled' => 1 ], [ [ 'id', '=', $item[ 'id' ] ] ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 扣除成长值
|
||||
if ($item[ 'type' ] == 'growth') {
|
||||
$member_info = model('member')->getInfo([ [ 'member_id', '=', $member_id ] ], 'growth');
|
||||
$return_value = $item['value'];
|
||||
if($order_info['order_money'] > 0){
|
||||
$return_value = round(($order_goods_info['goods_money'] / $order_info['goods_money']) * $item['value']);
|
||||
}
|
||||
$growth = min($return_value, $member_info['growth']);
|
||||
$remark = '订单商品【'.$order_goods_info['sku_name'].'】退款奖励回收';
|
||||
$res = $member_account->addMemberAccount($site_id, $member_id, 'growth', -( $growth ), 'memberconsume', $item[ 'order_id' ], $remark);
|
||||
if ($res[ 'code' ] == 0 && $is_refund_all) {
|
||||
model('promotion_consume_record')->update([ 'is_recycled' => 1 ], [ [ 'id', '=', $item[ 'id' ] ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
115
addon/memberconsume/shop/controller/Config.php
Executable file
115
addon/memberconsume/shop/controller/Config.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberconsume\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\memberconsume\model\Consume;
|
||||
|
||||
/**
|
||||
* 会员消费
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 消费返积分
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
//订单消费返积分设置数据
|
||||
$data = [
|
||||
'is_recovery_reward' => input('is_recovery_reward', 0),
|
||||
'is_return_point' => input('is_return_point', 0),
|
||||
'return_point_rate' => input('return_point_rate', 0),
|
||||
'is_return_growth' => input('is_return_growth', 0),
|
||||
'return_growth_rate' => input('return_growth_rate', 0),
|
||||
'is_return_coupon' => input('is_return_coupon', 0),
|
||||
'return_coupon' => input('return_coupon', ''),
|
||||
];
|
||||
$this->addLog('设置会员消费奖励');
|
||||
$is_use = input('is_use', 0);//是否启用
|
||||
$config_model = new Consume();
|
||||
$res = $config_model->setConfig($data, $is_use, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$event_list = array (
|
||||
[ 'name' => 'pay', 'title' => '订单付款'],
|
||||
[ 'name' => 'receive', 'title' => '订单收货'],
|
||||
[ 'name' => 'complete', 'title' => '订单完成'],
|
||||
);
|
||||
$this->assign('event_list', $event_list);
|
||||
$config_model = new Consume();
|
||||
//订单返积分设置
|
||||
$config_result = $config_model->getConfig($this->site_id);
|
||||
$this->assign('config', $config_result[ 'data' ]);
|
||||
|
||||
return $this->fetch('config/index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖励记录
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$status = input('status', '');
|
||||
$order_no = input('order_no', '');
|
||||
$username = input('username', '');
|
||||
|
||||
$condition = [];
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'pcr.type', '=', $status ];
|
||||
}
|
||||
if ($order_no) {
|
||||
$condition[] = [ 'o.order_no', 'like', '%' . $order_no . '%' ];
|
||||
}
|
||||
if ($username) {
|
||||
$condition[] = [ 'm.username', 'like', '%' . $username . '%' ];
|
||||
}
|
||||
$condition[] = [ 'pcr.site_id', '=', $this->site_id ];
|
||||
$order = 'pcr.create_time desc';
|
||||
$field = 'pcr.*,m.username,m.nickname,m.mobile,m.headimg,o.order_no';
|
||||
$alias = 'pcr';
|
||||
$join = [
|
||||
[ 'member m', 'pcr.member_id = m.member_id', 'left' ],
|
||||
[ 'order o', 'pcr.order_id = o.order_id', 'left' ],
|
||||
];
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'pcr.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'pcr.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$condition[] = [ 'pcr.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
$config_model = new Consume();
|
||||
$res = $config_model->getConsumeRecordPageList($condition, $page, $page_size, $order, $field, $alias, $join);
|
||||
return $res;
|
||||
} else {
|
||||
$event_list = array (
|
||||
[ 'name' => 'coupon', 'title' => '优惠券'],
|
||||
[ 'name' => 'point', 'title' => '积分'],
|
||||
[ 'name' => 'growth', 'title' => '成长值'],
|
||||
);
|
||||
$this->assign('event_list', $event_list);
|
||||
|
||||
return $this->fetch('config/lists');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
158
addon/memberconsume/shop/view/config/index.html
Executable file
158
addon/memberconsume/shop/view/config/index.html
Executable file
@@ -0,0 +1,158 @@
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否开启:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_use" lay-filter="is_use" value="1" lay-skin="switch" {if !empty($config) && $config.is_use==1 } checked {/if} >
|
||||
</div>
|
||||
<div class="word-aux">活动开启后用户在付款完成后将按活动设置发放相关奖励</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">奖励回收:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_recovery_reward" {if !empty($config) && $config.value.is_recovery_reward == 1 } checked {/if} value="1" title="是">
|
||||
<input type="radio" name="is_recovery_reward" {if empty($config) || $config.value.is_recovery_reward == 0 } checked {/if} value="0" title="否">
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">如果开启奖励回收,用户退款维权成功后,已发放的奖励会进行回收</div>
|
||||
<div class="word-aux">回收说明:已使用的优惠券将无法收回,如果会员剩余积分/成长值不足将只扣除至0</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">奖励类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="reward_type" lay-filter="reward_type" value="point" lay-skin="primary" {if isset($config.value.is_return_point) && $config.value.is_return_point == 1}checked{/if} title="送积分">
|
||||
<input type="checkbox" name="reward_type" lay-filter="reward_type" value="growth" lay-skin="primary" {if isset($config.value.is_return_growth) && $config.value.is_return_growth == 1}checked{/if} title="送成长值">
|
||||
<input type="checkbox" name="reward_type" lay-filter="reward_type" value="coupon" lay-skin="primary" {if isset($config.value.is_return_coupon) && $config.value.is_return_coupon == 1}checked{/if} title="送优惠券">
|
||||
</div>
|
||||
<input type="hidden" lay-verify="reward_type"/>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item reward-content point {if !isset($config.value.is_return_point) || $config.value.is_return_point == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">奖励积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="return_point_rate" value="{if condition="!empty($config.value)"}{$config.value.return_point_rate}{else/}0{/if}" lay-verify="return_point_rate" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<span class="layui-form-mid">%</span>
|
||||
</div>
|
||||
<div class="word-aux">比率必须为0-100的整数,例:当设置为100时,每消费1元奖励1个积分</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item reward-content growth {if !isset($config.value.is_return_growth) || $config.value.is_return_growth == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">奖励成长值:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" name="return_growth_rate" value="{if condition="!empty($config.value)"}{$config.value.return_growth_rate ?: 0}{else/}0{/if}" lay-verify="return_growth_rate" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<span class="layui-form-mid">%</span>
|
||||
</div>
|
||||
<div class="word-aux">比率必须为0-100的整数,例:当设置为100时,每消费1元奖励1个成长值</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item reward-content coupon {if !isset($config.value.is_return_coupon) || $config.value.is_return_coupon == 0}layui-hide{/if}">
|
||||
<label class="layui-form-label">奖励优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div><a href="javascript:;" class="text-color" id="select_coupon">选择优惠券</a></div>
|
||||
<div class="word-aux" style="margin-left: 0">
|
||||
<p>活动优惠券发放,不受优惠券自身数量和领取数量的限制</p>
|
||||
</div>
|
||||
<div id="coupon_list"></div>
|
||||
<input type="hidden" lay-verify="return_coupon_ids"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script >
|
||||
var laytpl;
|
||||
var coupon_select = new CouponSelect({
|
||||
tableElem:'#coupon_list',
|
||||
selectElem:'#select_coupon',
|
||||
selectedIds:'{$config.value.return_coupon}',
|
||||
})
|
||||
layui.use(['form','laytpl'], function(){
|
||||
// 监听返积分是否启用
|
||||
var form = layui.form,
|
||||
repeat_flag = false; //防重复标识
|
||||
laytpl = layui.laytpl;
|
||||
form.render();
|
||||
|
||||
form.on('checkbox(reward_type)', function (data){
|
||||
var reward_type = data.value;
|
||||
var dom = $(".reward-content."+reward_type);
|
||||
if(data.elem.checked){
|
||||
dom.removeClass('layui-hide');
|
||||
}else{
|
||||
dom.addClass('layui-hide');
|
||||
}
|
||||
})
|
||||
|
||||
form.on('submit(save)', function(data){
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
data.field.is_return_point = getRewardTypeIsReturn('point');
|
||||
data.field.is_return_growth = getRewardTypeIsReturn('growth');
|
||||
data.field.is_return_coupon = getRewardTypeIsReturn('coupon');
|
||||
if(!data.field.is_return_point) data.field.return_point_rate = 0;
|
||||
if(!data.field.is_return_growth) data.field.return_growth_rate = 0;
|
||||
if(data.field.is_return_coupon) data.field.return_coupon = coupon_select.getSelectedData().selectedIds.toString();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("memberconsume://shop/config/index"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.verify({
|
||||
reward_type:function (value){
|
||||
var checked_num = $("input[name='reward_type']:checked").length;
|
||||
var is_use = $("input[name='is_use']:checked").length;
|
||||
if(is_use && !checked_num){
|
||||
return '请至少设置一种奖励';
|
||||
}
|
||||
},
|
||||
return_point_rate: function(value){
|
||||
return checkReturnRate('point', value);
|
||||
},
|
||||
return_growth_rate: function(value){
|
||||
return checkReturnRate('growth', value);
|
||||
},
|
||||
return_coupon_ids: function (value){
|
||||
var checked = getRewardTypeIsReturn('coupon');
|
||||
if(checked && coupon_select.getSelectedData().selectedIds.length == 0){
|
||||
return '请选择优惠券';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function checkReturnRate(reward_type, value){
|
||||
var checked = getRewardTypeIsReturn(reward_type);
|
||||
if(checked && !ns.getRegexp('>0num').test(value) || value > 100){
|
||||
return '请输入1-100之间的整数';
|
||||
}
|
||||
}
|
||||
|
||||
function getRewardTypeIsReturn(reward_type){
|
||||
return $("input[name='reward_type'][value='"+reward_type+"']:checked").length ? 1 : 0;
|
||||
}
|
||||
});
|
||||
|
||||
function back(){
|
||||
location.hash = ns.hash("shop/promotion/market");
|
||||
}
|
||||
|
||||
</script>
|
||||
188
addon/memberconsume/shop/view/config/lists.html
Executable file
188
addon/memberconsume/shop/view/config/lists.html
Executable file
@@ -0,0 +1,188 @@
|
||||
<style>
|
||||
.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="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="username" 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" name="order_no" 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="activity_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" lay-id="">全部</li>
|
||||
{foreach $event_list as $k => $v}
|
||||
<li lay-id="{$v['name']}">{$v['title']}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="activity_list" lay-filter="activity_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{ d.status == 0 ? '已下架' : '已上架' }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">查看订单</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="member_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' "/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color"
|
||||
title="{{d.nickname}}">{{d.nickname}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form','element','laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate;
|
||||
|
||||
form.render();
|
||||
|
||||
element.on('tab(activity_tab)', function(){
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where:{
|
||||
'status':this.getAttribute('lay-id')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#activity_list',
|
||||
url: ns.url("memberconsume://shop/config/lists"),
|
||||
cols: [
|
||||
[{
|
||||
title: '会员信息',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: '#member_info'
|
||||
}, {
|
||||
field: 'remark',
|
||||
title: '内容',
|
||||
unresize: 'false',
|
||||
width: '30%'
|
||||
}, {
|
||||
title: '奖励类型',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
align: 'left',
|
||||
templet: function(data) {
|
||||
if(data.type == 'point'){
|
||||
return '积分';
|
||||
}
|
||||
if(data.type == 'growth'){
|
||||
return '成长值';
|
||||
}
|
||||
if(data.type == 'coupon'){
|
||||
return '优惠券';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '奖励时间',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("shop/order/detail", {"order_id": data.order_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//开始时间
|
||||
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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("bundling://shop/bundling/add");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user