初始上传
This commit is contained in:
35
addon/giftcard/event/AddStat.php
Executable file
35
addon/giftcard/event/AddStat.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\giftcard\CardStat;
|
||||
|
||||
/**
|
||||
* 礼品卡统计
|
||||
*/
|
||||
class AddStat
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$type = $params['type'];
|
||||
if($type == 'gift_card_order'){
|
||||
$giftcard_stat_model = new CardStat();
|
||||
$res = $giftcard_stat_model->addGiftcardStat($params['data']);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
44
addon/giftcard/event/CronCardExpire.php
Executable file
44
addon/giftcard/event/CronCardExpire.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\card\CardOperation;
|
||||
use addon\giftcard\model\giftcard\GiftCard;
|
||||
|
||||
/**
|
||||
* 礼品卡过期(轮询 一天一次)
|
||||
*/
|
||||
class CronCardExpire
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$card_operation_model = new CardOperation();
|
||||
$card_condition = [
|
||||
[ 'valid_time', 'between', [ 1, time() ] ]
|
||||
];
|
||||
$card_ids = model('giftcard_card')->getColumn($card_condition, 'card_id');
|
||||
$res = $card_operation_model->cardExpire([ 'card_ids' => $card_ids ]);
|
||||
|
||||
// 礼品卡到期
|
||||
$gift_card_model = new GiftCard();
|
||||
$gift_card_model->modifyStatus(0, [
|
||||
[ 'validity_type', '=', 'date' ],
|
||||
[ 'validity_time', '<', time() ]
|
||||
]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
33
addon/giftcard/event/GiftCardOrderClose.php
Executable file
33
addon/giftcard/event/GiftCardOrderClose.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\order\GiftCardOrderOperation;
|
||||
|
||||
/**
|
||||
* 订单关闭
|
||||
*/
|
||||
class GiftCardOrderClose
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$model = new GiftCardOrderOperation();
|
||||
$params[ 'close_cause' ] = '长时间未支付,订单自动关闭';
|
||||
$params[ 'order_id' ] = $params[ 'relate_id' ];
|
||||
$res = $model->close($params);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
31
addon/giftcard/event/GiftCardOrderPayNotify.php
Executable file
31
addon/giftcard/event/GiftCardOrderPayNotify.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\order\GiftCardOrderOperation;
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
class GiftCardOrderPayNotify
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$model = new GiftCardOrderOperation();
|
||||
$res = $model->orderPay($params);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
40
addon/giftcard/event/IncomeStatistics.php
Executable file
40
addon/giftcard/event/IncomeStatistics.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\order\GiftCardOrder;
|
||||
|
||||
/**
|
||||
* 资金收入统计
|
||||
*/
|
||||
class IncomeStatistics
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$money = ( new GiftCardOrder() )->getOrderSum(
|
||||
[
|
||||
[ 'go.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'go.pay_time', 'between', [ $param[ 'start_time' ], $param[ 'end_time' ] ] ]
|
||||
], 'p.pay_money', 'go', [
|
||||
[
|
||||
'pay p', 'go.out_trade_no = p.out_trade_no', 'left'
|
||||
]
|
||||
])[ 'data' ];
|
||||
return [
|
||||
[
|
||||
'title' => '礼品卡订单',
|
||||
'value' => $money,
|
||||
'desc' => '统计时间内,所有礼品卡订单金额之和',
|
||||
'url' => 'giftcard://shop/order/order',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
103
addon/giftcard/event/Install.php
Executable file
103
addon/giftcard/event/Install.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\giftcard\Media;
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
execute_sql('addon/giftcard/data/install.sql');
|
||||
|
||||
$cron = new Cron();
|
||||
$cron->deleteCron([ [ 'event', '=', 'CronCardExpire' ] ]);
|
||||
$cron->addCron(2, 1, '礼品卡过期', 'CronCardExpire', time(), 0);
|
||||
|
||||
$site_id = 1;
|
||||
$media = ( new Media() )->getInfo([ [ 'is_system', '=', 1 ], [ 'site_id', '=', $site_id ] ], 'media_id')[ 'data' ];
|
||||
if (empty($media)) {
|
||||
( new Media() )->addList($this->giftMedia($site_id));
|
||||
}
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function giftMedia($site_id)
|
||||
{
|
||||
return [
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '001.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/001.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
],
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '002.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/002.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
],
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '003.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/003.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
],
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '004.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/004.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
],
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '005.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/005.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
],
|
||||
[
|
||||
'site_id' => $site_id,
|
||||
'media_type' => 'img',
|
||||
'is_system' => 1,
|
||||
'media_name' => '006.png',
|
||||
'media_path' => 'public/uniapp/giftcard/media/006.png',
|
||||
'media_spec' => '640*400',
|
||||
'create_time' => time(),
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
39
addon/giftcard/event/OrderPayAfter.php
Executable file
39
addon/giftcard/event/OrderPayAfter.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
|
||||
/**
|
||||
* 礼品卡统计
|
||||
*/
|
||||
class OrderPayAfter
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$promotion_type = $params[ 'promotion_type' ];
|
||||
if ($promotion_type == 'giftcard') {
|
||||
$condition = array (
|
||||
[ 'order_id', '=', $params[ 'order_id' ] ]
|
||||
);
|
||||
$data = array (
|
||||
'is_enable_refund' => 0
|
||||
);
|
||||
//将订单改成不可退款
|
||||
model('order')->update($data, $condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
27
addon/giftcard/event/OrderPromotionType.php
Executable file
27
addon/giftcard/event/OrderPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
/**
|
||||
* 活动
|
||||
*/
|
||||
class OrderPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "礼品卡优惠", "type" => "giftcard" ];
|
||||
}
|
||||
}
|
||||
33
addon/giftcard/event/PayReset.php
Executable file
33
addon/giftcard/event/PayReset.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\order\GiftCardOrderPay;
|
||||
|
||||
/**
|
||||
* 礼品卡支付重置
|
||||
*/
|
||||
class PayReset
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$event = $params[ 'event' ];
|
||||
if ($event == 'GiftCardOrderPayNotify') {
|
||||
$giftcard_order_pay_model = new GiftCardOrderPay();
|
||||
$result = $giftcard_order_pay_model->resetPay($params);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
45
addon/giftcard/event/ShowPromotion.php
Executable file
45
addon/giftcard/event/ShowPromotion.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
/**
|
||||
* 店铺活动
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'giftcard',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '礼品卡',
|
||||
//展示介绍
|
||||
'description' => '购买礼品,赠送好友',
|
||||
//展示图标
|
||||
'icon' => 'addon/giftcard/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'giftcard://shop/giftcard/lists',
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
34
addon/giftcard/event/UnInstall.php
Executable file
34
addon/giftcard/event/UnInstall.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$cron = new Cron();
|
||||
$cron->deleteCron([ [ 'event', '=', 'CronCardExpire' ] ]);
|
||||
execute_sql('addon/giftcard/data/uninstall.sql');
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
30
addon/giftcard/event/WapOrderDetailPathByPayInfo.php
Executable file
30
addon/giftcard/event/WapOrderDetailPathByPayInfo.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\giftcard\event;
|
||||
|
||||
use addon\giftcard\model\order\GiftCardOrder;
|
||||
|
||||
/**
|
||||
* 通过支付信息获取手机端订单详情路径
|
||||
*/
|
||||
class WapOrderDetailPathByPayInfo
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
if($data['event'] == 'GiftCardOrderPayNotify'){
|
||||
$order_model = new GiftCardOrder();
|
||||
$order_info = $order_model->getOrderInfo([['out_trade_no', '=', $data['out_trade_no']]], 'order_id')[ 'data' ];
|
||||
if(!empty($order_info)){
|
||||
return '/pages_promotion/giftcard/order_detail?order_id='.$order_info['order_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user