初始上传

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,32 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrderPay;
/**
* 订单异步回调执行
*/
class CashierOrderPayNotify
{
// 行为扩展的执行入口必须是run
public function handle($data)
{
$order_pay_model = new CashierOrderPay();
$data[ 'online_type' ] = 'online';
$result = $order_pay_model->doPay($data);
return $result;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrder as CashierOrderModel;
use app\model\order\OrderCommon;
/**
* 订单自动删除事件5分钟内未支付
*/
class CronOrderDelete
{
// 行为扩展的执行入口必须是run
public function handle($data)
{
$order = new OrderCommon();
$order_info = $order->getOrderInfo([ ['order_id', '=', $data['relate_id'] ] ], 'order_id,order_status,store_id,site_id')[ 'data' ];
if (!empty($order_info) && $order_info['order_status'] == 0) {
//订单关闭并删除
$order_common_model = new OrderCommon();
$close_result = $order_common_model->orderClose($order_info[ 'order_id' ]);
if ($close_result[ 'code' ] < 0) {
return $close_result;
}
$order_model = new CashierOrderModel();
$condition = array (
[ 'site_id', '=', $order_info[ 'site_id' ] ],
[ 'store_id', '=', $order_info[ 'store_id' ] ],
[ 'order_id', '=', $order_info[ 'order_id' ] ],
);
$res = $order_model->deleteOrder($condition);
return $res;
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrder;
use app\dict\goods\GoodsDict;
/**
* 订单类型映射
*/
class GetOrderModel
{
/**
* 支付方式及配置
*/
public function handle($param)
{
if($param['order_type'] == 5){
if(isset($param['order_goods']) && count($param['order_goods']) == 1){
if(in_array($param['order_goods'][0]['goods_class'], [GoodsDict::virtual, GoodsDict::virtualcard, GoodsDict::service, GoodsDict::card])){
$order_model = new \app\model\order\VirtualOrder();
return $order_model;
}
}
$order_model = new CashierOrder();
return $order_model;
}
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
/**
* 订单类型
*/
class GetOrderType
{
/**
* 订单类型
*/
public function handle($param)
{
return [
5 => '收银订单'
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use app\model\order\Order as OrderModel;
/**
* 资金收入统计
*/
class IncomeStatistics
{
public function handle($param)
{
$money = ( new OrderModel() )->getOrderMoneySum([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'pay_time', 'between', [ $param[ 'start_time' ], $param[ 'end_time' ] ] ], [ 'order_scene', '=', 'cashier' ], [ 'cashier_order_type', '<>', 'recharge' ] ], 'pay_money')[ 'data' ];
return [
[
'title' => '收银订单',
'value' => $money,
'desc' => '统计时间内,收银台所有开放售卡订单实付金额之和',
'url' => 'cashier://shop/order/lists'
]
];
}
}

30
addon/cashier/event/Install.php Executable file
View File

@@ -0,0 +1,30 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\Cashier;
use app\model\system\Menu;
/**
* 应用安装
*/
class Install
{
/**
* 执行安装
*/
public function handle()
{
(new Cashier())->refreshCashier();
(new Menu())->refreshCashierAuth('cashier');
return success();
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrder;
/**
* 订单来源
*/
class OrderFromList
{
/**
* 订单来源
*/
public function handle($params)
{
$order_scene = $params[ 'order_scene' ] ?? '';
if (empty($order_scene) || $order_scene = 'cashier') {
return ( new CashierOrder )->order_from_list;
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrder;
use app\dict\order\OrderDict;
/**
* 订单项退款
*/
class OrderGoodsRefund
{
/**
* 支付方式及配置
*/
public function handle($params)
{
$order_info = $params[ 'order_info' ];
if ($order_info[ 'order_type' ] == OrderDict::cashier) {
$order_model = new CashierOrder();
$result = $order_model->refund($params);
return $result;
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\Push as PushModel;
/**
* 订单类型
*/
class OrderPay
{
/**
* 订单类型
*/
public function handle($order_info)
{
return (new PushModel())->orderPay($order_info);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\order\CashierOrder;
/**
* 原路退款
*/
class PayRefund
{
/**
* 关闭支付
*/
public function handle($params)
{
$pay_type_array = array (
'cash', 'own_wechatpay', 'own_alipay', 'own_pos'
);
if (in_array($params[ "pay_info" ][ "pay_type" ], $pay_type_array)) {
$cashier_order_model = new CashierOrder();
return $cashier_order_model->success();
}
}
}

View File

@@ -0,0 +1,145 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use addon\cashier\model\Cashier;
use addon\printer\model\Printer;
use addon\printer\model\PrinterTemplate;
use app\model\system\Site;
/**
* 打印内容
*/
class PrinterContent
{
public function handle($params)
{
if ($params[ 'type' ] == 'change_shifts') {
$print_model = new Printer();
$printer_condition = [
[ 'site_id', '=', $params[ 'site_id' ] ],
[ 'store_id', '=', $params[ 'store_id' ] ],
[ 'change_shifts_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' ] ?? [];
if (empty($printer_data)) return error(-1, '未找到可用的打印机');
if (isset($params[ 'record_id' ]) && !empty($params[ 'record_id' ])) {
$shifts_data = ( new Cashier() )->getChangeShiftsRecordInfo([
[ 'r.site_id', '=', $params[ 'site_id' ] ], [ 'r.store_id', '=', $params[ 'store_id' ] ], [ 'r.id', '=', $params[ 'record_id' ] ]
], 'r.*,u.username', 'r', [ [ 'user u', 'r.uid = u.uid', 'inner' ] ])[ 'data' ];
if (empty($shifts_data)) return error(-1, '未查询到交班记录');
$user_info = [
'username' => $shifts_data[ 'username' ]
];
$shifts_data['sale_goods_count'] = ( new Cashier() )->getSaleGoodsCount([
['o.store_id', '=', $shifts_data['store_id']],
['o.pay_time', '>', $shifts_data['start_time']],
['o.pay_time', '<=', $shifts_data['end_time']],
])['data'];
} else {
$shifts_data = ( new Cashier() )->getShiftsData($params[ 'site_id' ], $params[ 'store_id' ]);
$user_info = $params[ 'userinfo' ];
}
$res_data = [];
foreach ($printer_data as $k => $v) {
//此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
$array = [];
$array[ 'printer_info' ] = $v;
$template_id = $v[ 'change_shifts_template_id' ];
$print_num = $v[ 'change_shifts_print_num' ];
$print_template_model = new PrinterTemplate();
$print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
if (empty($print_template)) continue;
$array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
$array[ 'origin_id' ] = time();
$array[ 'content' ] = $this->handleChangeShiftsPrintContent($print_num, $print_template, $user_info, $shifts_data);
$res_data[] = $array;
}
return $res_data;
}
}
/**
* 获取收银交班打印内容
* @param $print_num
* @param $print_template
* @param $user_info
* @param $shifts_data
* @return string
*/
private function handleChangeShiftsPrintContent($print_num, $print_template, $user_info, $shifts_data)
{
$content = "<MN>" . $print_num . "</MN>";
//小票名称
if ($print_template[ 'title' ] != '') {
$content .= "<center>" . $print_template[ 'title' ] . "</center>";
$content .= str_repeat('.', 32);
}
//商城名称
if ($print_template[ 'head' ] == 1) {
$site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', request()->siteid() ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
$content .= "<FH2><FS><center>" . $site_name . "</center></FS></FH2>";
$content .= str_repeat('.', 32);
}
$content .= "交班员工:" . $user_info[ 'username' ] . "\n";
$content .= "上班时间:" . ( $shifts_data[ 'start_time' ] ? date("Y-m-d H:i:s", $shifts_data[ 'start_time' ]) : '初始化' ) . "\n";
$content .= "交班时间:" . date("Y-m-d H:i:s", $shifts_data[ 'end_time' ]) . "\n";
$content .= str_repeat('.', 32);
$content .= "<FH2><FS>总销售</FS></FH2>\n";
$content .= "开单销售:¥" . $shifts_data[ "billing_money" ] . "\n";
$content .= "售卡销售:¥" . $shifts_data[ "buycard_money" ] . "\n";
$content .= str_repeat('.', 32);
$content .= "<FH2><FS>会员充值</FS></FH2>\n";
$content .= "会员充值:¥" . $shifts_data[ "recharge_money" ] . "\n";
$content .= str_repeat('.', 32);
$content .= "<FH2><FS>应收金额</FS></FH2>\n";
$content .= "开单销售:¥" . $shifts_data[ "billing_money" ] . "\n";
$content .= "售卡销售:¥" . $shifts_data[ "buycard_money" ] . "\n";
$content .= "会员充值:¥" . $shifts_data[ "recharge_money" ] . "\n";
$content .= "订单退款:¥" . $shifts_data[ "refund_money" ] . "\n";
$content .= str_repeat('.', 32);
$pay_arr = [];
if ($shifts_data[ "cash" ] > 0) $pay_arr[] = "现金收款:¥" . $shifts_data[ "cash" ] . "\n";
if ($shifts_data[ "wechatpay" ] > 0) $pay_arr[] = "微信收款:¥" . $shifts_data[ "wechatpay" ] . "\n";
if ($shifts_data[ "alipay" ] > 0) $pay_arr[] = "支付宝收款:¥" . $shifts_data[ "alipay" ] . "\n";
if ($shifts_data[ "own_wechatpay" ] > 0) $pay_arr[] = "个人微信收款:¥" . $shifts_data[ "own_wechatpay" ] . "\n";
if ($shifts_data[ "own_alipay" ] > 0) $pay_arr[] = "个人支付宝收款:¥" . $shifts_data[ "own_alipay" ] . "\n";
if ($shifts_data[ "own_pos" ] > 0) $pay_arr[] = "个人POS收款" . $shifts_data[ "own_pos" ] . "\n";
if(!empty($pay_arr)){
$content .= "<FH2><FS>支付统计</FS></FH2>\n";
$content .= join('', $pay_arr);
}
if($shifts_data['sale_goods_count']['num'] > 0){
$content .= "<FH2><FS>商品销售</FS></FH2>\n";
$content .= "总计:".$shifts_data['sale_goods_count']['class_num']."".$shifts_data['sale_goods_count']['num']."\n";
$content .= "线上:".$shifts_data['sale_goods_count']['online_class_num']."".$shifts_data['sale_goods_count']['online_num']."\n";
$content .= "线下:".$shifts_data['sale_goods_count']['offline_class_num']."".$shifts_data['sale_goods_count']['offline_num']."\n";
}
return $content;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
use app\Controller;
/**
* 收银交班打印
*/
class PrinterHtml extends Controller
{
public function handle($data)
{
return $this->fetch('addon/cashier/shop/view/printer/printer_template.html');
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
/**
* 收银交班打印
*/
class PrinterTemplateType
{
public function handle($data)
{
return [
[
'type' => 'change_shifts',
'type_name' => '收银交班',
'edit' => 'addon/cashier/shop/view/printer/change_shifts.html',
'add' => 'addon/cashier/shop/view/printer/change_shifts.html',
]
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\cashier\event;
/**
* 活动展示
*/
class ShowPromotion
{
/**
* 活动展示
* @return array
*/
public function handle()
{
$data = [
'shop' => [
[
//插件名称
'name' => 'cashier',
//店铺端展示分类 shop:营销活动 member:互动营销
'show_type' => 'tool',
//展示主题
'title' => '收银台',
//展示介绍
'description' => '收银台',
//展示图标
'icon' => 'addon/cashier/icon.png',
//跳转链接
'url' => 'cashier://shop/index/cashier',
]
]
];
return $data;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
/**
* 支付方式 (后台调用)
*/
class TradePayType
{
/**
* 支付方式及配置
*/
public function handle($param)
{
$info = [
'cash' => '现金支付',
'own_wechatpay' => '个人微信',
'own_alipay' => '个人支付宝',
'own_pos' => '个人pos刷卡',
'ONLINE_PAY' => '在线支付',
];
return $info;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\cashier\event;
/**
* 应用卸载
*/
class UnInstall
{
/**
* 执行卸载
*/
public function handle()
{
return success();
}
}