初始上传

This commit is contained in:
2026-04-04 17:27:12 +08:00
parent 4d80d28eb4
commit b7e11774ee
11191 changed files with 1588469 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\card\Card as CardModel;
use addon\giftcard\model\card\CardImport as CardImportModel;
use addon\giftcard\model\card\CardLog;
use addon\giftcard\model\card\CardOperation;
use addon\giftcard\model\giftcard\GiftCard as GiftCardModel;
use addon\giftcard\model\membercard\MemberCard;
/**
* 礼品卡控制器
*/
class Card extends Giftcard
{
/**
* 兑换卡列表
* @return array|mixed
*/
public function lists()
{
$giftcard_id = input('giftcard_id', 0);
$import_id = input('import_id', 0);
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$status = input('status', 'all');
$import_name = input('import_name', '');
$condition = array (
[ 'gc.site_id', '=', $this->site_id ],
);
if (!empty($search_text)) {
$condition[] = [ 'gc.card_no', 'like', '%' . $search_text . '%' ];
}
if ($status != 'all') {
$condition[] = [ 'gc.status', '=', $status ];
}
if (!empty($card_type)) {
$condition[] = [ 'gc.card_type', '=', $card_type ];
}
if ($giftcard_id > 0) {
$condition[] = [ 'gc.giftcard_id', '=', $giftcard_id ];
}
if ($import_name) {
$import_model = new CardImportModel();
$import_ids = $import_model->getCardImportColumn([ [ 'name', '=', $import_name ] ], 'import_id')[ 'data' ] ?? [];
if (!empty($import_id)) {
$import_id = array_merge($import_ids, [ $import_id, '-1' ]);
} else {
$import_id = array_merge($import_ids, [ -1 ]);
}
}
if (!empty($import_id)) {
$condition[] = [ 'gc.import_id', 'in', $import_id ];
}
$card_model = new CardModel();
$list = $card_model->getCardPageList($condition, $page, $page_size, 'gc.card_id desc', 'gc.*,go.order_no', 'gc', [
[ 'giftcard_order go', 'gc.order_id=go.order_id', 'left' ]
])[ 'data' ];
foreach ($list[ 'list' ] as $k => $v) {
$list[ 'list' ][ $k ] = $card_model->tran($v);
}
return $card_model->success($list);
} else {
$this->assign('import_id', $import_id);
$this->assign('giftcard_id', $giftcard_id);
$giftcard_info = ( new GiftCardModel() )->getGiftcardInfo([ [ 'giftcard_id', '=', $giftcard_id ] ], 'card_type')[ 'data' ] ?? [];
$this->assign('status_list', ( new CardModel() )->getStatusList($giftcard_info[ 'card_type' ]));
return $this->fetch('card/lists');
}
}
/**
* 详情
*/
public function detail()
{
$card_id = input('card_id', 0);
$card_model = new CardModel();
$member_card = new MemberCard();
$detail = $card_model->getCardDetail([ 'card_id' => $card_id, 'site_id' => $this->site_id ])[ 'data' ] ?? [];
if (empty($detail))
$this->error('找不到礼品卡项');
$detail[ 'status_name' ] = $card_model->getStatusList($detail[ 'card_type' ])[ $detail[ 'status' ] ] ?? '';
$this->assign('detail', $detail);
$member_card_list = $member_card->getMemberCardDetailList([ [ 'gmc.card_id', '=', $card_id ], [ 'gmc.site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
$this->assign('member_card_list', $member_card_list);
$card_log_model = new CardLog();
$card_log_condition = array (
[ 'card_id', '=', $card_id ],
[ 'site_id', '=', $this->site_id ]
);
$card_log_list = $card_log_model->getCardLogList($card_log_condition, '*', 'create_time desc')[ 'data' ] ?? [];
$this->assign('card_log_list', $card_log_list);
return $this->fetch('card/detail');
}
/**
* 删除
* @return array|mixed
*/
public function delete()
{
$card_id = input('card_id', 0);
$card_model = new CardModel();
$params = array (
'site_id' => $this->site_id,
'card_id' => $card_id
);
$result = $card_model->delete($params);
return $result;
}
/**
* 卡作废
* @return array
*/
public function invalid()
{
$card_id = input('card_id', 0);
$card_operation_model = new CardOperation();
$params = array (
'site_id' => $this->site_id,
'card_id' => $card_id,
'operator_data' => $this->user_info
);
$result = $card_operation_model->cardInvalid($params);
return $result;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\card\CardImport as CardImportModel;
use addon\giftcard\model\card\RealCard;
/**
* 礼品卡批次控制器
*/
class Cardimport extends Giftcard
{
/**
* 批次列表
* @return array|mixed
*/
public function lists()
{
$giftcard_id = input('giftcard_id', 0);
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'giftcard_id', '=', $giftcard_id ],
);
if (!empty($search_text)) {
$condition[] = [ 'name', 'like', '%' . $search_text . '%' ];
}
$card_import_model = new CardImportModel();
$list = $card_import_model->getCardImportPageList($condition, $page, $page_size, 'create_time desc')[ 'data' ];
foreach ($list[ 'list' ] as $k => $v) {
$v[ 'type_name' ] = $card_import_model->create_type_list[ $v[ 'type' ] ];
$list[ 'list' ][ $k ] = $card_import_model->tran($v);
}
return $card_import_model->success($list);
} else {
$this->assign('giftcard_id', $giftcard_id);
return $this->fetch('cardimport/lists');
}
}
/**
* 删除
* @return array|mixed|void
*/
public function delete()
{
if (request()->isJson()) {
$import_id = input('import_id', 0);
$condition = array (
'site_id' => $this->site_id,
'import_id' => $import_id,
);
$card_import_model = new CardImportModel();
$res = $card_import_model->delete($condition);
return $res;
}
}
/**
* 作废
* @param $params
*/
public function invalid()
{
if (request()->isJson()) {
$import_id = input('import_id', 0);
$params = array (
'site_id' => $this->site_id,
'import_id' => $import_id,
'operator_data' => $this->user_info
);
$card_import_model = new CardImportModel();
$res = $card_import_model->invalid($params);
return $res;
}
}
/**
* 导出卡密和卡编号
*/
public function export()
{
$import_id = input('import_id', 0);
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'card_import_id', '=', $import_id ],
);
$card_import_model = new CardImportModel();
$card_import_model->export($condition);
}
/**
* 创建导入记录
*/
public function create()
{
$giftcard_id = input('giftcard_id', 0);
$type = input('type', 0);
$num = input('num', 0);
$card_cdk = input('card_cdk', '');
$card_import_model = new CardImportModel();
$result = $card_import_model->create([
'site_id' => $this->site_id,
'giftcard_id' => $giftcard_id,
'type' => $type,
'num' => $num,
'card_cdk' => $card_cdk,
'operator_data' => $this->user_info
]);
if ($result[ 'code' ] >= 0) {
// http(addon_url('giftcard://shop/cardimportlog/cdkLog', [ 'import_id' => $result[ 'data' ] ]), 1);
}
return $result;
}
/**
* 导入记录
*/
public function getCardImportInfo()
{
$import_id = input('import_id', 0);
$card_import_model = new CardImportModel();
$info = $card_import_model->getCardImportInfo([ [ 'site_id', '=', $this->site_id ], [ 'import_id', '=', $import_id ] ]);
return $info;
}
/**
* 录入卡项
*/
public function cdkLog()
{
set_time_limit(0);
$import_id = input('import_id', 0);
$real_card_model = new RealCard();
$result = $real_card_model->cdkLog([
'site_id' => $this->site_id,
'import_id' => $import_id,
'operator_data' => $this->user_info
]);
return $result;
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\card\RealCard;
use app\Controller;
/**
* 礼品卡批次控制器
*/
class Cardimportlog extends Controller
{
/**
* 录入卡项
*/
public function cdkLog()
{
set_time_limit(0);
$import_id = input('import_id', 0);
$real_card_model = new RealCard();
$result = $real_card_model->cdkLog([
'import_id' => $import_id,
'operator_data' => []
]);
return $result;
}
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\giftcard\Category as CategoryModel;
/**
* 礼品卡分组控制器
*/
class Category extends Giftcard
{
/**
* 兑换卡列表
* @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', '');
$condition = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($search_text)) {
$condition[] = [ 'category_name', 'like', '%' . $search_text . '%' ];
}
$category_model = new CategoryModel();
$list = $category_model->getPageList($condition, $page, $page_size);
return $list;
} else {
return $this->fetch('category/lists');
}
}
public function add()
{
if (request()->isJson()) {
$data = [
'category_name' => input('category_name', ''),
'sort' => input('sort', 0),
'font_color' => input('font_color', ''),
'site_id' => $this->site_id
];
$category_model = new CategoryModel();
$result = $category_model->add($data);
return $result;
} else {
return $this->fetch('category/add');
}
}
/**
* 编辑礼品卡活动
*/
public function edit()
{
$category_id = input('category_id', 0);
$category_model = new CategoryModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'category_id', '=', $category_id ]
);
if (request()->isJson()) {
$data = [
'category_name' => input('category_name', ''),
'sort' => input('sort', 0),
'font_color' => input('font_color', ''),
'site_id' => $this->site_id
];
$result = $category_model->edit($data, $condition);
return $result;
} else {
$detail = $category_model->getInfo($condition)[ 'data' ] ?? [];
$this->assign('detail', $detail);
return $this->fetch('category/edit');
}
}
/**
* 删除
* @return mixed
*/
public function delete()
{
$category_id = input('category_id', 0);
$category_model = new CategoryModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'category_id', '=', $category_id ]
);
$result = $category_model->delete($condition);
return $result;
}
public function modifySort()
{
$category_id = input('category_id', 0);
$category_model = new CategoryModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'category_id', '=', $category_id ]
);
$sort = input('sort', 0);
$result = $category_model->modifySort($sort, $condition);
return $result;
}
}

View File

@@ -0,0 +1,301 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\giftcard\Category as CategoryModel;
use addon\giftcard\model\giftcard\GiftCard as GiftCardModel;
use addon\giftcard\model\giftcard\Media as MediaModel;
use app\shop\controller\BaseShop;
use addon\giftcard\model\card\Card;
use addon\giftcard\model\giftcard\Category as GiftCardCategoryModel;
use think\App;
/**
* 礼品卡控制器
*/
class Giftcard extends BaseShop
{
public function __construct(App $app = null)
{
$this->replace = [
'GIFTCARD_CSS' => __ROOT__ . '/addon/giftcard/shop/view/public/css',
'GIFTCARD_JS' => __ROOT__ . '/addon/giftcard/shop/view/public/js',
'GIFTCARD_IMG' => __ROOT__ . '/addon/giftcard/shop/view/public/img',
'GIFTCARD_CSV' => __ROOT__ . '/addon/giftcard/shop/view/public/csv',
];
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', 'all');
$category_id = input('category_id', 0);
$card_type = input('card_type', 'all');
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'is_delete', '=', 0 ]
);
if (!empty($search_text)) {
$condition[] = [ 'card_name', 'like', '%' . $search_text . '%' ];
}
if (!empty($card_type) && $card_type != 'all') {
$condition[] = [ 'card_type', '=', $card_type ];
}
if ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if ($category_id > 0) {
$condition[] = [ 'category_id', '=', $category_id ];
}
$giftcard_model = new GiftCardModel();
$list = $giftcard_model->getGiftcardDetailPageListInAdmin($condition, $page, $page_size, 'giftcard_id desc')[ 'data' ];
return $list;
} else {
return $this->fetch('giftcard/lists');
}
}
/**
* 添加礼品卡
* @return array|mixed
*/
public function add()
{
$card_type = input('card_type', 'virtual');
if (request()->isJson()) {
$goods_sku_list = input('goods_sku_list', '');
$goods_sku_list = empty($goods_sku_list) ? [] : json_decode($goods_sku_list, true);
$cdk_type_array = input()[ 'cdk_type' ] ?? [];
$data = [
'card_name' => input('card_name', ''),
'card_count' => input('card_count', 0),
'card_cover' => input('card_cover', ''),
'media_ids' => input('media_ids', ''),
'cdk_length' => input('cdk_length', 0),
'cdk_type' => implode(',', $cdk_type_array),
'card_prefix' => input('card_prefix', ''),
'card_suffix' => input('card_suffix', ''),
'card_right_type' => input('card_right_type', ''),
'card_right_goods_type' => input('card_right_goods_type', ''),
'card_right_goods_count' => input('card_right_goods_count', ''),
'card_price' => input('card_price', 0),
'balance' => input('balance', 0),
'sort' => input('sort', 0),
'validity_type' => input('validity_type', ''),
'validity_time' => input('validity_time', 0),
'validity_day' => input('validity_day', 0),
'status' => input('status', 0),
'category_id' => input('category_id', 0),
'is_allow_transfer' => input('is_allow_transfer', 0),
'site_id' => $this->site_id,
'goods_sku_list' => $goods_sku_list,
'desc' => input('desc', ''),
'card_type' => input('card_type', ''),
'instruction' => input('instruction', ''),
];
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->addGiftCard($data);
return $result;
} else {
$this->assign('category_list', ( new GiftCardCategoryModel() )->getList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? []);
$this->assign('card_right_type_list', ( new GiftCardModel )->card_right_type_list ?? []);
$this->assign('card_type', $card_type);
return $this->fetch('giftcard/add');
}
}
/**
* 编辑礼品卡活动
*/
public function edit()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
if (request()->isJson()) {
$goods_sku_list = input('goods_sku_list', '');
$goods_sku_list = empty($goods_sku_list) ? [] : json_decode($goods_sku_list, true);
$cdk_type_array = input()[ 'cdk_type' ] ?? [];
$data = [
'card_name' => input('card_name', ''),
'card_cover' => input('card_cover', ''),
'media_ids' => input('media_ids', ''),
'cdk_length' => input('cdk_length', 0),
'cdk_type' => implode(',', $cdk_type_array),
'card_prefix' => input('card_prefix', ''),
'card_suffix' => input('card_suffix', ''),
'card_right_type' => input('card_right_type', ''),
'card_right_goods_type' => input('card_right_goods_type', ''),
'card_right_goods_count' => input('card_right_goods_count', ''),
'card_price' => input('card_price', 0),
'balance' => input('balance', 0),
'sort' => input('sort', 0),
'validity_type' => input('validity_type', ''),
'validity_time' => input('validity_time', 0),
'validity_day' => input('validity_day', 0),
'status' => input('status', 0),
'category_id' => input('category_id', 0),
'card_type' => input('card_type', ''),
'is_allow_transfer' => input('is_allow_transfer', 0),
'site_id' => $this->site_id,
'goods_sku_list' => $goods_sku_list,
'giftcard_id' => $giftcard_id,
'desc' => input('desc', ''),
'instruction' => input('instruction', ''),
];
$result = $giftcard_model->editGiftCard($data);
return $result;
} else {
// 分组列表
$this->assign('category_list', ( new GiftCardCategoryModel() )->getList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? []);
// 详情
$giftcard_info = $giftcard_model->getGiftcardDetail([ 'giftcard_id' => $giftcard_id, 'site_id' => $this->site_id ])[ 'data' ] ?? [];
if (empty($giftcard_info))
$this->error('找不到礼品卡活动');
$this->assign('giftcard_info', $giftcard_info);
$this->assign('card_right_type_list', ( new GiftCardModel )->card_right_type_list ?? []);
return $this->fetch('giftcard/edit');
}
}
/**
* 详情
*/
public function detail()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
$detail = $giftcard_model->getGiftcardDetail([ 'giftcard_id' => $giftcard_id, 'site_id' => $this->site_id ])[ 'data' ] ?? [];
if (empty($detail)) {
$this->error('找不到礼品卡活动');
}
$this->assign('category_list', ( new GiftCardCategoryModel() )->getList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? []);
$this->assign('card_right_type_list', ( new GiftCardModel )->card_right_type_list ?? []);
$this->assign('detail', $detail);
$this->assign('status_list', ( new Card() )->getStatusList($detail[ 'card_type' ]));
return $this->fetch('giftcard/detail');
}
/**
* 删除
* @return mixed
*/
public function delete()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->deleteGiftcard([ [ 'giftcard_id', '=', $giftcard_id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
/**
* 排序
* @return array
*/
public function sort()
{
$giftcard_id = input('giftcard_id', 0);
$sort = input('sort', 0);
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->modifyGiftcardSort($sort, [ [ 'giftcard_id', '=', $giftcard_id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
public function getCategoryMedia()
{
if (request()->isJson()) {
$category_id = input('category_id', '');
if (empty($category_id)) return error('-1', '参数不能为空', '');
$condition = [
[ 'category_id', '=', $category_id ]
];
$category_model = new CategoryModel();
$category_info = $category_model->getInfo($condition, 'media_ids')[ 'data' ];
$res = success();
if (isset($category_info[ 'media_ids' ]) && !empty($category_info[ 'media_ids' ])) {
$condition = [
[ 'media_id', 'in', $category_info[ 'media_ids' ] ]
];
$media_model = new MediaModel();
$res = $media_model->getList($condition);
if (!empty($res[ 'data' ])) {
foreach ($res[ 'data' ] as $k => $v) {
$res[ 'data' ][ $k ][ 'media_path' ] = img($v[ 'media_path' ]);
}
}
}
return $res;
}
}
/**
* 电子卡上/下架
* @return array
*/
public function isuse()
{
if (request()->isJson()) {
$giftcard_id = input('id', '');
$status = input('status', '');
$giftcard_model = new GiftCardModel();
$param = [
'giftcard_id' => $giftcard_id,
'status' => $status,
'site_id' => $this->site_id
];
if ($status == 0) {
$result = $giftcard_model->giftcardOff($param);
} elseif ($status == 1) {
$result = $giftcard_model->giftcardOn($param);
}
return $result;
}
}
/**
* 实体卡批量激活/作废
* @return array
*/
public function editstatus()
{
if (request()->isJson()) {
$giftcard_id = input('id', '');
$status = input('status', '');
$giftcard_model = new GiftCardModel();
$param = [
'giftcard_id' => $giftcard_id,
'status' => $status,
'site_id' => $this->site_id
];
if ($status == 2) {
$result = $giftcard_model->giftcardOff($param);
} elseif ($status == 1) {
$result = $giftcard_model->giftcardOn($param);
}
return $result;
}
}
}

View File

@@ -0,0 +1,179 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\giftcard\GiftCard as GiftCardModel;
use addon\giftcard\model\giftcard\Category as GiftCardCategoryModel;
/**
* 礼品卡记录控制器
*/
class GiftcardRecords extends Giftcard
{
/**
* 兑换卡列表
* @return array|mixed
*/
public function lists()
{
if (request()->isJson()) {
$card_type = input('card_type', '');
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$search_text = input('search_text', '');
$status = input('status', 'all');
$category_id = input('category_id', 0);
$condition = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($search_text)) {
$condition[] = [ 'card_name', 'like', '%' . $search_text . '%' ];
}
if ($status != 'all') {
$condition[] = [ 'status', '=', $status ];
}
if (!empty($card_type)) {
$condition[] = [ 'card_type', '=', $card_type ];
}
if ($category_id > 0) {
$condition[] = [ 'category_id', '=', $category_id ];
}
$giftcard_model = new GiftCardModel();
$list = $giftcard_model->getGiftcardDetailPageList($condition, $page, $page_size);
return $list;
} else {
return $this->fetch('giftcard/lists');
}
}
public function add()
{
if (request()->isJson()) {
$goods_sku_list = input('goods_sku_list', '');
$goods_sku_list = empty($goods_sku_list) ? [] : json_decode($goods_sku_list, true);
$data = [
'card_name' => input('card_name', ''),
'card_count' => input('card_count', 0),
'card_cover' => input('card_cover', ''),
'cdk_length' => input('cdk_length', 0),
'cdk_prefix' => input('cdk_prefix', ''),
'cdk_suffix' => input('cdk_suffix', ''),
'cdk_type' => input('cdk_type', ''),
'card_right_type' => input('card_right_type', ''),
'card_right_goods_type' => input('card_right_goods_type', ''),
'card_right_goods_count' => input('card_right_goods_count', ''),
'card_price' => input('card_price', 0),
'balance' => input('balance', 0),
// 'sale_num' => input('sale_num', 0),
'sort' => input('sort', 0),
'validity_type' => input('validity_type', ''),
'validity_time' => input('validity_time', 0),
'validity_day' => input('validity_day', 0),
'status' => input('status', 0),
'media_id' => input('media_id', 0),
'category_id' => input('category_id', 0),
'card_type' => input('card_type', ''),
'is_allow_transfer' => input('is_allow_transfer', 0),
'site_id' => $this->site_id,
'goods_sku_list' => $goods_sku_list
];
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->addGiftCard($data);
return $result;
} else {
$this->assign('category_list', ( new GiftCardCategoryModel() )->getList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? []);
return $this->fetch('giftcard/add');
}
}
/**
* 编辑礼品卡活动
*/
public function edit()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
if (request()->isJson()) {
$goods_sku_list = input('goods_sku_list', '');
$goods_sku_list = empty($goods_sku_list) ? [] : json_decode($goods_sku_list, true);
$data = [
'card_name' => input('card_name', ''),
'card_count' => input('card_count', 0),
'card_cover' => input('card_cover', ''),
'cdk_length' => input('cdk_length', 0),
'cdk_prefix' => input('cdk_prefix', ''),
'cdk_suffix' => input('cdk_suffix', ''),
'cdk_type' => input('cdk_type', ''),
'card_right_type' => input('card_right_type', ''),
'card_right_goods_type' => input('card_right_goods_type', ''),
'card_right_goods_count' => input('card_right_goods_count', ''),
'card_price' => input('card_price', 0),
'balance' => input('balance', 0),
// 'sale_num' => input('sale_num', 0),
'sort' => input('sort', 0),
'validity_type' => input('validity_type', ''),
'validity_time' => input('validity_time', 0),
'validity_day' => input('validity_day', 0),
'status' => input('status', 0),
'media_id' => input('media_id', 0),
'category_id' => input('category_id', 0),
'is_allow_transfer' => input('is_allow_transfer', 0),
'site_id' => $this->site_id,
'goods_sku_list' => $goods_sku_list,
'giftcard_id' => $giftcard_id
];
//
$result = $giftcard_model->editGiftCard($data);
return $result;
} else {
$this->assign('category_list', ( new GiftCardCategoryModel() )->getList([ [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? []);
$detail = $giftcard_model->getGiftcardDetail([ 'giftcard_id' => $giftcard_id, 'site_id' => $this->site_id ])[ 'data' ] ?? [];
$this->assign('detail', $detail);
return $this->fetch('giftcard/edit');
}
}
/**
* 活动详情
*/
public function detail()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
$detail = $giftcard_model->getGiftcardDetail([ 'giftcard_id' => $giftcard_id, 'site_id' => $this->site_id ])[ 'data' ] ?? [];
$this->assign('detail', $detail);
return $this->fetch('giftcard/detail');
}
/**
* 删除
* @return mixed
*/
public function delete()
{
$giftcard_id = input('giftcard_id', 0);
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->deleteGiftcard([ [ 'giftcard_id', '=', $giftcard_id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
public function sort()
{
$giftcard_id = input('giftcard_id', 0);
$sort = input('sort', 0);
$giftcard_model = new GiftCardModel();
$result = $giftcard_model->modifyGiftcardSort($sort, [ [ 'giftcard_id', '=', $giftcard_id ], [ 'site_id', '=', $this->site_id ] ]);
return $result;
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\giftcard\Media as MediaModel;
/**
* 礼品卡分组控制器
*/
class Media extends Giftcard
{
/**
* 分页列表
* @return array|mixed
*/
public function lists()
{
header("Expires:-1");
header("Cache-Control:no_cache");
header("Pragma:no-cache");
$media_model = new MediaModel();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$condition = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($media_name)) {
$condition[] = [ 'media_name', '=', $media_name ];
}
$list = $media_model->getPageList($condition, $page, $page_size, 'create_time desc');
return $list;
} else {
return $this->fetch('media/lists');
}
}
/**
* 删除
* @return mixed
*/
public function delete()
{
$media_id = input('media_id', 0);
$media_model = new MediaModel();
$condition = array (
[ 'site_id', '=', $this->site_id ],
[ 'media_id', '=', $media_id ]
);
$result = $media_model->delete($condition);
return $result;
}
/**
* 上传
*/
public function upload()
{
if (request()->isJson()) {
$media_model = new MediaModel();
$param = [
'site_id' => $this->site_id,
'name' => 'file'
];
$result = $media_model->upload($param);
return $result;
}
}
/*
* 替换
* */
public function modifyFile()
{
if (request()->isJson()) {
// 参数
$media_id = input('media_id', '');
// 获取图片信息
$media_model = new MediaModel();
$params = [
'media_id' => $media_id,
'site_id' => $this->site_id,
'name' => 'file'
];
$result = $media_model->replace($params);
return $result;
}
}
/**
* 相册管理界面
* @return mixed
*/
public function media()
{
$img_num = input('imgNum', '');
$media_ids = input('mediaIds', '');
$media_model = new MediaModel();
if (request()->isJson()) {
$page_index = input('page', 1);
$list_rows = input('limit', PAGE_LIST_ROWS);
$media_name = input("media_name", "");
$condition = array (
[ 'site_id', "=", $this->site_id ],
);
if (!empty($media_name)) {
$condition[] = [ 'media_name', 'like', '%' . $media_name . '%' ];
}
$list = $media_model->getPageList($condition, $page_index, $list_rows, 'update_time desc');
return $list;
} else {
$media_list = $media_model->getList([ [ 'site_id', "=", $this->site_id ] ]);
$this->assign("media_list", $media_list[ 'data' ]);
if (!empty($media_ids)) {
$media_ids = implode(',', array_unique(explode(',', $media_ids)));
}
$this->assign("media_ids", $media_ids);
$this->assign("img_num", $img_num);
return $this->fetch('media/media');
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\giftcard\shop\controller;
use addon\giftcard\model\card\Card as CardModel;
use addon\giftcard\model\order\GiftCardOrder;
use think\App;
/**
* 礼品卡订单控制器
*/
class Order extends Giftcard
{
/**
* 订单列表
* @return mixed
*/
public function order()
{
$giftcard_id = input('giftcard_id', 0);
$order_model = new GiftCardOrder();
if (request()->isJson()) {
$page = input('page', 1);
$page_size = input('page_size', PAGE_LIST_ROWS);
$status = input('status', 'all');
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$nickname = input('nickname', '');
$order_no = input('order_no', '');
$card_right_type = input('card_right_type', '');
$condition = array (
[ 'o.site_id', '=', $this->site_id ],
[ 'o.is_delete', '=', 0 ],
[ 'o.order_status', '=', 'complete' ],
);
if ($giftcard_id > 0) {
$condition[] = [ 'o.giftcard_id', '=', $giftcard_id ];
}
if (!empty($nickname)) {
$condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
}
if (!empty($card_right_type)) {
$condition[] = [ 'o.card_right_type', '=', $card_right_type ];
}
if (!empty($order_no)) {
$condition[] = [ 'o.order_no', 'like', '%'. $order_no . '%' ];
}
//支付时间
if (!empty($start_time) && empty($end_time)) {
$condition[] = [ "o.pay_time", ">=", date_to_time($start_time) ];
} elseif (empty($start_time) && !empty($end_time)) {
$condition[] = [ "o.pay_time", "<=", date_to_time($end_time) ];
} elseif (!empty($start_time) && !empty($end_time)) {
$condition[] = [ 'o.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
}
$order = 'o.create_time desc';
$field = 'o.*, m.nickname,m.headimg,m.mobile';
$join = [
[ 'member m', 'o.member_id = m.member_id', 'left' ]
];
$list = $order_model->getOrderDetailPageList($condition, $page, $page_size, $order, $field, 'o', $join);
return $list;
}
$this->assign('giftcard_id', $giftcard_id);
return $this->fetch("order/order");
}
/**
* 详情
* @return mixed|void
*/
public function detail()
{
$order_id = input('order_id', '');
$order_model = new GiftCardOrder();
$order_detail = $order_model->getOrderDetail([ 'site_id' => $this->site_id, 'order_id' => $order_id ])[ 'data' ] ?? [];
$card_model = new CardModel();
$card_list = $card_model->getCardList([ [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', $order_detail[ 'order_id' ] ] ])[ 'data' ];
foreach ($card_list as $k => $v) {
$card_list[ $k ] = $card_model->tran($v);
}
$this->assign('order_detail', $order_detail);
$this->assign('card_list', $card_list);
return $this->fetch("order/detail");
}
}