初始上传
This commit is contained in:
15
addon/memberrecharge/event/CashierCalculate.php
Executable file
15
addon/memberrecharge/event/CashierCalculate.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use addon\memberrecharge\model\cashier\Calculate;
|
||||
|
||||
class CashierCalculate
|
||||
{
|
||||
public function handle($params=[])
|
||||
{
|
||||
$calculate_model = new Calculate();
|
||||
$res = $calculate_model->calculate($params);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
33
addon/memberrecharge/event/IncomeStatistics.php
Executable file
33
addon/memberrecharge/event/IncomeStatistics.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use addon\memberrecharge\model\MemberrechargeOrder;
|
||||
|
||||
/**
|
||||
* 资金收入统计
|
||||
*/
|
||||
class IncomeStatistics
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
$money = (new MemberrechargeOrder())->getOrderSum([ ['site_id', '=', $param['site_id'] ], ['pay_time', 'between', [$param['start_time'], $param['end_time']] ] ], 'buy_price')['data'];
|
||||
return [
|
||||
[
|
||||
'title' => '会员充值',
|
||||
'value' => $money,
|
||||
'desc' => '统计时间内,所有会员充值金额之和',
|
||||
'url' => 'memberrecharge://shop/memberrecharge/orderlists'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
26
addon/memberrecharge/event/Install.php
Executable file
26
addon/memberrecharge/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
51
addon/memberrecharge/event/MemberAccountFromType.php
Executable file
51
addon/memberrecharge/event/MemberAccountFromType.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 会员账户变化来源类型
|
||||
*/
|
||||
class MemberAccountFromType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$from_type = [
|
||||
'balance' => [
|
||||
'memberrecharge' => [
|
||||
'type_name' => '会员充值',
|
||||
'admin_url' => 'admin/order/detail',
|
||||
'tag_name' => 'order_id'
|
||||
],
|
||||
],
|
||||
'point' => [
|
||||
'memberrecharge' => [
|
||||
'type_name' => '会员充值',
|
||||
'type_url' => '',
|
||||
],
|
||||
|
||||
],
|
||||
'growth' => [
|
||||
'memberrecharge' => [
|
||||
'type_name' => '会员充值',
|
||||
'type_url' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($data == '') {
|
||||
return $from_type;
|
||||
} else {
|
||||
return $from_type[$data] ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
28
addon/memberrecharge/event/MemberrechargeOrderClose.php
Executable file
28
addon/memberrecharge/event/MemberrechargeOrderClose.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use addon\memberrecharge\model\MemberrechargeOrder;
|
||||
|
||||
/**
|
||||
* 订单支付回调
|
||||
*/
|
||||
class MemberrechargeOrderClose
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$order = new MemberrechargeOrder();
|
||||
$res = $order->cronMemberRechargeOrderClose($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
28
addon/memberrecharge/event/MemberrechargeOrderPayNotify.php
Executable file
28
addon/memberrecharge/event/MemberrechargeOrderPayNotify.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use addon\memberrecharge\model\MemberrechargeOrder;
|
||||
|
||||
/**
|
||||
* 充值订单回调
|
||||
*/
|
||||
class MemberrechargeOrderPayNotify
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$model = new MemberrechargeOrder();
|
||||
$res = $model->orderPay($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
135
addon/memberrecharge/event/PrinterContent.php
Executable file
135
addon/memberrecharge/event/PrinterContent.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use app\model\member\Member;
|
||||
use app\model\shop\Shop;
|
||||
use addon\printer\model\Printer;
|
||||
use addon\printer\model\PrinterTemplate;
|
||||
use app\Controller;
|
||||
use addon\memberrecharge\model\MemberrechargeOrder;
|
||||
use app\model\system\Site;
|
||||
|
||||
/**
|
||||
* 打印内容
|
||||
*/
|
||||
class PrinterContent extends Controller
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ 'type' ] == 'recharge') {
|
||||
$order_id = $params[ 'order_id' ];
|
||||
|
||||
$order_common_model = new MemberrechargeOrder();
|
||||
$order_info = $order_common_model->getMemberRechargeOrderInfo([ [ 'order_id', '=', $order_id ] ])[ 'data' ];
|
||||
$params[ 'site_id' ] = $order_info[ 'site_id' ] ?? 0;
|
||||
|
||||
$member = new Member();
|
||||
$member_info = $member->getMemberInfo([ [ 'member_id', '=', $order_info[ 'member_id' ] ] ], 'balance, balance_money')[ 'data' ] ?? [];
|
||||
$account = number_format($member_info[ 'balance' ] + $member_info[ 'balance_money' ], 2, '.', '');
|
||||
|
||||
//获取店铺信息
|
||||
$shop_model = new Shop();
|
||||
$shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ])[ 'data' ];
|
||||
|
||||
$site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
|
||||
|
||||
//获取打印机列表
|
||||
$print_model = new Printer();
|
||||
$printer_condition = [
|
||||
[ 'site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'store_id', '=', $order_info[ 'store_id' ] ],
|
||||
[ 'recharge_open', '=', 1 ],
|
||||
];
|
||||
//指定打印机
|
||||
if(isset($params['printer_ids']) && $params['printer_ids'] != 'all'){
|
||||
if(empty($params['printer_ids'])) $params['printer_ids'] = '0';
|
||||
$printer_condition[] = ['printer_id', 'in', $params['printer_ids']];
|
||||
}
|
||||
$printer_data = $print_model->getPrinterList($printer_condition)[ 'data' ] ?? [];
|
||||
|
||||
$res_data = [];
|
||||
|
||||
foreach ($printer_data as $k => $v) {
|
||||
//此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
|
||||
$array = [];
|
||||
$array[ 'printer_info' ] = $v;
|
||||
$print_template_model = new PrinterTemplate();
|
||||
|
||||
$template_id = $v[ 'recharge_template_id' ];
|
||||
|
||||
$print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
|
||||
|
||||
$array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
|
||||
$array[ 'origin_id' ] = $order_info[ 'order_no' ]; //内部订单号(32位以内)
|
||||
/**文本接口开始**/
|
||||
$content = "<MN>" . $v[ 'recharge_print_num' ] . "</MN>";
|
||||
//小票名称
|
||||
if ($print_template[ 'title' ] != '') {
|
||||
$content .= "<center>" . $print_template[ 'title' ] . "</center>";
|
||||
$content .= str_repeat('.', 32);
|
||||
}
|
||||
//商城名称
|
||||
if ($print_template[ 'head' ] == 1) {
|
||||
$content .= "<FH2><FS><center>" . $site_name . "</center></FS></FH2>";
|
||||
$content .= str_repeat('.', 32);
|
||||
}
|
||||
$content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
|
||||
$content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
|
||||
$content .= "支付方式:" . $order_info[ 'pay_type_name' ] . "\n";
|
||||
$content .= str_repeat('.', 32);
|
||||
|
||||
$content .= "充值金额:¥" . $order_info[ "face_value" ] . "\n";
|
||||
$content .= "实付金额:¥" . $order_info[ "price" ] . "\n";
|
||||
$content .= "会员余额:¥" . $account . "\n";
|
||||
|
||||
/******************** 买家信息 **************************/
|
||||
//买家姓名
|
||||
if ($print_template[ 'buy_name' ] == 1) {
|
||||
$content .= "会员:" . $order_info[ "nickname" ] . "\n";
|
||||
$content .= str_repeat('.', 32);
|
||||
}
|
||||
|
||||
/******************** 商城信息 **************************/
|
||||
//联系方式
|
||||
if ($print_template[ 'shop_mobile' ] == 1) {
|
||||
$content .= "" . $shop_info[ "mobile" ] . "\n";
|
||||
}
|
||||
//地址
|
||||
if ($print_template[ 'shop_address' ] == 1) {
|
||||
$content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
|
||||
}
|
||||
|
||||
if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
|
||||
$content .= str_repeat('.', 32);
|
||||
}
|
||||
//二维码
|
||||
if ($print_template[ 'shop_qrcode' ] == 1) {
|
||||
$content .= "<QR>" . $print_template[ 'qrcode_url' ] . "</QR>";
|
||||
$content .= str_repeat('.', 32);
|
||||
}
|
||||
|
||||
//底部内容
|
||||
if (!empty($print_template[ 'bottom' ])) {
|
||||
|
||||
$content .= "<center>" . $print_template[ 'bottom' ] . "</center>";
|
||||
}
|
||||
$array[ 'content' ] = $content;
|
||||
|
||||
$res_data[] = $array;
|
||||
}
|
||||
|
||||
return $res_data;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/memberrecharge/event/PrinterHtml.php
Executable file
26
addon/memberrecharge/event/PrinterHtml.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use app\Controller;
|
||||
|
||||
/**
|
||||
* 会员充值小票打印打印机添加
|
||||
*/
|
||||
class PrinterHtml extends Controller
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
return $this->fetch('addon/memberrecharge/shop/view/template/printer_template.html');
|
||||
}
|
||||
}
|
||||
31
addon/memberrecharge/event/PrinterTemplateType.php
Executable file
31
addon/memberrecharge/event/PrinterTemplateType.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 会员充值小票打印
|
||||
*/
|
||||
class PrinterTemplateType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
return [
|
||||
[
|
||||
'type' => 'recharge',
|
||||
'type_name' => '会员充值',
|
||||
'edit' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
|
||||
'add' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
27
addon/memberrecharge/event/PromotionType.php
Executable file
27
addon/memberrecharge/event/PromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "充值礼包", "type" => "memberrecharge" ];
|
||||
}
|
||||
}
|
||||
84
addon/memberrecharge/event/ShowPromotion.php
Executable file
84
addon/memberrecharge/event/ShowPromotion.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
use addon\memberrecharge\model\Memberrecharge;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'unlimited_time';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'memberrecharge',
|
||||
//展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
|
||||
'show_type' => 'member',
|
||||
//展示主题
|
||||
'title' => '充值礼包',
|
||||
//展示介绍
|
||||
'description' => '提高客户充值金额',
|
||||
//展示图标
|
||||
'icon' => 'addon/memberrecharge/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'memberrecharge://shop/memberrecharge/lists',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Memberrecharge() )->getConfig($params[ 'site_id' ])[ 'data' ];
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ], [ 'status', '=', 1 ] ]);
|
||||
|
||||
return [
|
||||
'unlimited_time' => [
|
||||
'status' => $config[ 'is_use' ],
|
||||
'detail' => $count ? '已配置' . $count . '个充值套餐' : '未配置充值套餐',
|
||||
'switch_type' => 'switch',
|
||||
'config_key' => 'MEMBER_RECHARGE_CONFIG'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/memberrecharge/event/UnInstall.php
Executable file
26
addon/memberrecharge/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
24
addon/memberrecharge/event/WapOrderDetailPathByPayInfo.php
Executable file
24
addon/memberrecharge/event/WapOrderDetailPathByPayInfo.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecharge\event;
|
||||
|
||||
/**
|
||||
* 通过支付信息获取手机端订单详情路径
|
||||
*/
|
||||
class WapOrderDetailPathByPayInfo
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
if($data['event'] == 'MemberrechargeOrderPayNotify'){
|
||||
return '/pages_tool/recharge/order_list';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user