chore(src): 所有代码上传
This commit is contained in:
@@ -1,38 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
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' => []
|
||||
<?php
|
||||
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' => []
|
||||
];
|
||||
@@ -1,20 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
return [
|
||||
'name' => 'freeshipping',
|
||||
'title' => '满额包邮',
|
||||
'description' => '满额包邮',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.3.1',
|
||||
'version_no' => '525231212001',
|
||||
'content' => '',
|
||||
<?php
|
||||
return [
|
||||
'name' => 'freeshipping',
|
||||
'title' => '满额包邮',
|
||||
'description' => '满额包邮',
|
||||
'type' => 'system', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.3.1',
|
||||
'version_no' => '525231212001',
|
||||
'content' => '',
|
||||
];
|
||||
@@ -1,25 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return ["name" => "满额包邮", "type" => "freeshipping"];
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return ["name" => "满额包邮", "type" => "freeshipping"];
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'freeshipping',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '满额包邮',
|
||||
//展示介绍
|
||||
'description' => '购满指定金额订单包邮',
|
||||
//展示图标
|
||||
'icon' => 'addon/freeshipping/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'freeshipping://shop/freeshipping/lists',
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'freeshipping',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '满额包邮',
|
||||
//展示介绍
|
||||
'description' => '购满指定金额订单包邮',
|
||||
//展示图标
|
||||
'icon' => 'addon/freeshipping/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'freeshipping://shop/freeshipping/lists',
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
<?php
|
||||
|
||||
|
||||
namespace addon\freeshipping\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -1,157 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
class Freeshipping extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加满额包邮
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addFreeshipping($data)
|
||||
{
|
||||
$data[ 'create_time' ] = time();
|
||||
$area_ids = json_decode($data[ 'area_ids' ], true);
|
||||
if (!empty($area_ids)) {
|
||||
foreach ($area_ids[ '3' ] as $k => $v) {
|
||||
foreach ($v as $area_id) {
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $data[ 'site_id' ] ],
|
||||
[ 'merch_id', '=', $data[ 'merch_id' ] ],
|
||||
[ 'area_ids', 'like', '%' . $area_id . '%' ],
|
||||
];
|
||||
if($data[ 'merch_id' ]){
|
||||
$condition[] = [ 'merch_id', '=', $data[ 'merch_id' ] ];
|
||||
}
|
||||
//判断该城市是否已存在
|
||||
$count = model('promotion_freeshipping')->getCount($condition);
|
||||
if ($count > 0) {
|
||||
return $this->error('', '指定地区城市不能重复');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$res = model('promotion_freeshipping')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑满额包邮
|
||||
* @param $groupbuy_id
|
||||
* @param $site_id
|
||||
* @param $groupbuy_data
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function editFreeshipping($data)
|
||||
{
|
||||
$freeshipping_id = $data[ 'freeshipping_id' ];
|
||||
unset($data[ 'freeshipping_id' ]);
|
||||
$data[ 'update_time' ] = time();
|
||||
$area_ids = json_decode($data[ 'area_ids' ], true);
|
||||
if (!empty($area_ids)) {
|
||||
foreach ($area_ids[ '3' ] as $k => $v) {
|
||||
foreach ($v as $area_id) {
|
||||
$condition = [
|
||||
[ 'site_id', '=', $data[ 'site_id' ] ],
|
||||
[ 'merch_id', '=', $data[ 'merch_id' ] ],
|
||||
[ 'area_ids', 'like', '%' . $area_id . '%' ],
|
||||
[ 'freeshipping_id', '<>', $freeshipping_id ]
|
||||
];
|
||||
if($data[ 'merch_id' ]){
|
||||
$condition[] = [ 'merch_id', '=', $data[ 'merch_id' ] ];
|
||||
}
|
||||
//判断该城市是否已存在
|
||||
$count = model('promotion_freeshipping')->getCount($condition);
|
||||
if ($count > 0) {
|
||||
return $this->error('', '指定地区城市不能重复');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$res = model('promotion_freeshipping')->update($data,
|
||||
[ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'freeshipping_id', '=', $freeshipping_id ] ]
|
||||
);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除满额包邮活动
|
||||
* @param $groupbuy_id
|
||||
* @param $site_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function deleteFreeshipping($freeshipping_id, $site_id)
|
||||
{
|
||||
$list = model('promotion_freeshipping')->delete([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeshippingInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('promotion_freeshipping')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取满额包邮分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getFreeshippingPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = model('promotion_freeshipping')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/********************************************************************* 订单核验是否符合地区 start*****************************************************************************/
|
||||
|
||||
/**
|
||||
* 是否符合满额包邮
|
||||
* @param $money
|
||||
* @param $district_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function calculate($money, $district_id, $site_id)
|
||||
{
|
||||
$condition = array (
|
||||
[ 'price', '<=', $money ],
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'area_ids', 'like', '%"' . $district_id . '"%' ]
|
||||
);
|
||||
|
||||
$info = model('promotion_freeshipping')->getInfo($condition, '*');
|
||||
if (!empty($info)) {
|
||||
return $this->success($info);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
/********************************************************************* 订单核验是否符合地区 end*****************************************************************************/
|
||||
|
||||
<?php
|
||||
|
||||
namespace addon\freeshipping\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
class Freeshipping extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加满额包邮
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function addFreeshipping($data)
|
||||
{
|
||||
$data[ 'create_time' ] = time();
|
||||
$area_ids = json_decode($data[ 'area_ids' ], true);
|
||||
if (!empty($area_ids)) {
|
||||
foreach ($area_ids[ '3' ] as $k => $v) {
|
||||
foreach ($v as $area_id) {
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $data[ 'site_id' ] ],
|
||||
[ 'merch_id', '=', $data[ 'merch_id' ] ],
|
||||
[ 'area_ids', 'like', '%' . $area_id . '%' ],
|
||||
];
|
||||
if($data[ 'merch_id' ]){
|
||||
$condition[] = [ 'merch_id', '=', $data[ 'merch_id' ] ];
|
||||
}
|
||||
//判断该城市是否已存在
|
||||
$count = model('promotion_freeshipping')->getCount($condition);
|
||||
if ($count > 0) {
|
||||
return $this->error('', '指定地区城市不能重复');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$res = model('promotion_freeshipping')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑满额包邮
|
||||
* @param $groupbuy_id
|
||||
* @param $site_id
|
||||
* @param $groupbuy_data
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function editFreeshipping($data)
|
||||
{
|
||||
$freeshipping_id = $data[ 'freeshipping_id' ];
|
||||
unset($data[ 'freeshipping_id' ]);
|
||||
$data[ 'update_time' ] = time();
|
||||
$area_ids = json_decode($data[ 'area_ids' ], true);
|
||||
if (!empty($area_ids)) {
|
||||
foreach ($area_ids[ '3' ] as $k => $v) {
|
||||
foreach ($v as $area_id) {
|
||||
$condition = [
|
||||
[ 'site_id', '=', $data[ 'site_id' ] ],
|
||||
[ 'merch_id', '=', $data[ 'merch_id' ] ],
|
||||
[ 'area_ids', 'like', '%' . $area_id . '%' ],
|
||||
[ 'freeshipping_id', '<>', $freeshipping_id ]
|
||||
];
|
||||
if($data[ 'merch_id' ]){
|
||||
$condition[] = [ 'merch_id', '=', $data[ 'merch_id' ] ];
|
||||
}
|
||||
//判断该城市是否已存在
|
||||
$count = model('promotion_freeshipping')->getCount($condition);
|
||||
if ($count > 0) {
|
||||
return $this->error('', '指定地区城市不能重复');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$res = model('promotion_freeshipping')->update($data,
|
||||
[ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'freeshipping_id', '=', $freeshipping_id ] ]
|
||||
);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除满额包邮活动
|
||||
* @param $groupbuy_id
|
||||
* @param $site_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function deleteFreeshipping($freeshipping_id, $site_id)
|
||||
{
|
||||
$list = model('promotion_freeshipping')->delete([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $site_id ] ]);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeshippingInfo($condition = [], $field = '*')
|
||||
{
|
||||
$res = model('promotion_freeshipping')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取满额包邮分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getFreeshippingPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = model('promotion_freeshipping')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/********************************************************************* 订单核验是否符合地区 start*****************************************************************************/
|
||||
|
||||
/**
|
||||
* 是否符合满额包邮
|
||||
* @param $money
|
||||
* @param $district_id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function calculate($money, $district_id, $site_id)
|
||||
{
|
||||
$condition = array (
|
||||
[ 'price', '<=', $money ],
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'area_ids', 'like', '%"' . $district_id . '"%' ]
|
||||
);
|
||||
|
||||
$info = model('promotion_freeshipping')->getInfo($condition, '*');
|
||||
if (!empty($info)) {
|
||||
return $this->success($info);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
/********************************************************************* 订单核验是否符合地区 end*****************************************************************************/
|
||||
|
||||
}
|
||||
@@ -1,111 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\freeshipping\model\Freeshipping as FreeshippingModel;
|
||||
|
||||
class Freeshipping extends BaseShop
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFreeshippingPageList($condition, $page, $page_size, 'price asc');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('freeshipping/lists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$model = new FreeshippingModel();
|
||||
$result = $model->addFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
return $this->fetch('freeshipping/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
$freeshipping_id = input('freeshipping_id', 0);
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$data[ 'freeshipping_id' ] = $freeshipping_id;
|
||||
|
||||
$result = $model->editFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
$this->assign('freeshipping_id', $freeshipping_id);
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
|
||||
$info = $model->getFreeshippingInfo([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
|
||||
$this->assign('info', $info);
|
||||
return $this->fetch('freeshipping/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$freeshipping_id = input('freeshipping_id', '');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$model = new FreeshippingModel();
|
||||
return $model->deleteFreeshipping($freeshipping_id, $site_id);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
namespace addon\freeshipping\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\freeshipping\model\Freeshipping as FreeshippingModel;
|
||||
|
||||
class Freeshipping extends BaseShop
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFreeshippingPageList($condition, $page, $page_size, 'price asc');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('freeshipping/lists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$model = new FreeshippingModel();
|
||||
$result = $model->addFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
return $this->fetch('freeshipping/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
$freeshipping_id = input('freeshipping_id', 0);
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$data[ 'freeshipping_id' ] = $freeshipping_id;
|
||||
|
||||
$result = $model->editFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
$this->assign('freeshipping_id', $freeshipping_id);
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
|
||||
$info = $model->getFreeshippingInfo([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
|
||||
$this->assign('info', $info);
|
||||
return $this->fetch('freeshipping/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$freeshipping_id = input('freeshipping_id', '');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$model = new FreeshippingModel();
|
||||
return $model->deleteFreeshipping($freeshipping_id, $site_id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user