初始上传

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,167 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\presale\api\controller;
use addon\presale\model\Presale as PresaleModel;
use addon\presale\model\PresaleOrderCommon;
use addon\presale\model\PresaleOrderRefund;
use app\api\controller\BaseApi;
use addon\presale\model\Poster;
use app\model\goods\GoodsApi;
/**
* 预售商品
*/
class Goods extends BaseApi
{
/**
* 预售商品详情信息
*/
public function detail()
{
$presale_id = $this->params['id'] ?? 0;
if (empty($presale_id)) {
return $this->response($this->error('', 'REQUEST_PRESALE_ID'));
}
$sku_id = $this->params['sku_id'] ?? 0;
$presale_model = new PresaleModel();
$condition = [
[ 'pp.presale_id', '=', $presale_id ],
[ 'pp.site_id', '=', $this->site_id ],
[ 'pp.status', '=', 1 ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ]
];
if ($sku_id > 0) {
$condition[] = [ 'ppg.sku_id', '=', $sku_id ];
}
$goods_sku_detail = $presale_model->getPresaleGoodsDetail($condition)[ 'data' ];
if (empty($goods_sku_detail)) {
return $this->response($this->error());
}
$res = [];
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
$res[ 'goods_sku_detail' ][ 'purchased_num' ] = 0;
$token = $this->checkToken();
if ($token[ 'code' ] >= 0) {
$res[ 'goods_sku_detail' ][ 'purchased_num' ] = $presale_model->getGoodsPurchasedNum($goods_sku_detail[ 'presale_id' ], $this->member_id);
$res[ 'goods_sku_detail' ][ 'buying_num' ] = $presale_model->getPresaleOrderCount([
[ 'member_id', '=', $this->member_id ],
[ 'presale_id', '=', $goods_sku_detail[ 'presale_id' ] ],
[ 'order_status', 'not in', [ PresaleOrderCommon::ORDER_CLOSE, PresaleOrderCommon::ORDER_PAY ] ],
[ 'refund_status', '<>', PresaleOrderRefund::REFUND_COMPLETE ]
])[ 'data' ];
}
// 预约人数
$res[ 'goods_sku_detail' ][ 'sale_num' ] = $presale_model->getPresaleOrderCount([
[ 'presale_id', '=', $goods_sku_detail[ 'presale_id' ] ],
[ 'order_status', '<>', PresaleOrderCommon::ORDER_CLOSE ]
])[ 'data' ];
// 处理公共数据
$goods_sku_api = new GoodsApi();
$goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ], $this->member_id, $this->site_id);
return $this->response($this->success($res));
}
/**
* 查询商品SKU集合
* @return false|string
*/
public function goodsSku()
{
$goods_id = $this->params['goods_id'] ?? 0;
$presale_id = $this->params['presale_id'] ?? 0;
if (empty($presale_id)) {
return $this->response($this->error('', 'REQUEST_PRESALE_ID'));
}
if (empty($goods_id)) {
return $this->response($this->error('', 'REQUEST_ID'));
}
$presale_model = new PresaleModel();
$condition = [
[ 'pp.presale_id', '=', $presale_id ],
[ 'g.goods_id', '=', $goods_id ],
[ 'pp.status', '=', 1 ],
[ 'pp.site_id', '=', $this->site_id ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ],
];
$list = $presale_model->getPresaleGoodsSkuList($condition);
return $this->response($list);
}
public function page()
{
$page = $this->params['page'] ?? 1;
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
$condition = [
[ 'pp.status', '=', 1 ],// 状态0未开始 1进行中 2已结束
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ],
[ 'g.site_id', '=', $this->site_id ]
];
if (!empty($goods_id_arr)) {
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
}
$presale_model = new PresaleModel();
$list = $presale_model->getPresaleGoodsPageList($condition, $page, $page_size, 'pp.presale_id desc', '');
return $this->response($list);
}
public function lists()
{
$num = $this->params['num'] ?? 0;
$condition = [
[ 'pp.status', '=', 1 ],// 状态0未开始 1进行中 2已结束
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ],
[ 'g.site_id', '=', $this->site_id ]
];
if (!empty($goods_id_arr)) {
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
}
$presale_model = new PresaleModel();
$list = $presale_model->getPresaleList($condition, '', 'pp.presale_id desc', $num);
return $this->response($list);
}
/**
* 获取商品海报
*/
public function poster()
{
$this->checkToken();
$promotion_type = 'presale';
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
$qrcode_param[ 'source_member' ] = $this->member_id;
$poster = new Poster();
$res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
return $this->response($res);
}
}

View File

@@ -0,0 +1,148 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\presale\api\controller;
use addon\presale\model\PresaleOrder;
use addon\presale\model\PresaleOrderCommon;
use app\api\controller\BaseApi;
/**
* 预售订单
*/
class Order extends BaseApi
{
/**
* 订单列表
* @return false|string
*/
public function page()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$page = $this->params['page'] ?? 1;
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
$condition = [
[ 'ppo.site_id', '=', $this->site_id ],
[ 'ppo.member_id', '=', $this->member_id ]
];
$order_status = $this->params['order_status'] ?? '';
if ($order_status !== '') {
$condition[] = [ 'ppo.order_status', '=', $order_status ];
}
$presale_order_model = new PresaleOrder();
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size);
if (!empty($list[ 'data' ][ 'list' ])) {
foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
$action = empty($v[ "order_status_action" ]) ? [] : json_decode($v[ "order_status_action" ], true);
$member_action = $action[ "member_action" ] ?? [];
$list[ 'data' ][ 'list' ][ $k ][ 'action' ] = $member_action;
unset($list[ 'data' ][ 'list' ][ $k ][ 'order_status_action' ]);
}
}
return $this->response($list);
}
/**
* 订单详情
*/
public function detail()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$presale_order_model = new PresaleOrder();
$condition = [
[ 'id', '=', $id ],
[ 'member_id', '=', $this->member_id ],
];
$order_info = $presale_order_model->getPresaleOrderInfo($condition);
if (!empty($order_info[ 'data' ])) {
$action = empty($order_info[ 'data' ][ "order_status_action" ]) ? [] : json_decode($order_info[ 'data' ][ "order_status_action" ], true);
$member_action = $action[ "member_action" ] ?? [];
$order_info[ 'data' ][ 'action' ] = $member_action;
unset($order_info[ 'data' ][ 'order_status_action' ]);
}
return $this->response($order_info);
}
/**
* 关闭订单
*/
public function close()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$order_common_model = new PresaleOrderCommon();
$condition = [
[ 'id', '=', $id ],
[ 'member_id', '=', $this->member_id ],
];
$res = $order_common_model->depositOrderClose($condition);
return $this->response($res);
}
/**
* 删除订单
*/
public function delete()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$order_common_model = new PresaleOrderCommon();
$condition = [
[ 'id', '=', $id ],
[ 'member_id', '=', $this->member_id ],
];
$res = $order_common_model->deleteOrder($condition);
return $this->response($res);
}
/**
* 获取定金或尾款交易流水号
*/
public function pay()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['id'] ?? ''; //预售订单id
$order_common_model = new PresaleOrderCommon();
$res = $order_common_model->getPresaleOrderOutTradeNo($id, $this->member_id, $this->site_id);
return $this->response($res);
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* Index.php
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: http://www.niushop.com.cn
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
* @author : niuteam
* @date : 2022.8.8
* @version : v5.0.0.1
*/
namespace addon\presale\api\controller;
use addon\presale\model\PresaleOrderCreate as OrderCreateModel;
use app\api\controller\BaseOrderCreateApi;
/**
* 订单创建
* @author Administrator
*
*/
class Ordercreate extends BaseOrderCreateApi
{
/**
* 定金创建订单
*/
public function depositCreate()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_create = new OrderCreateModel();
$data = [
'order_key' => $this->params['order_key'] ?? '',
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
];
$res = $order_create->setParam(array_merge($data, $this->getInputParam(), $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->create();
return $this->response($res);
}
/**
* 定金计算信息
*/
public function depositCalculate()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_create = new OrderCreateModel();
$data = [
'order_key' => $this->params[ 'order_key' ] ?? '', //订单缓存key
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
];
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
return $this->response($this->success($res));
}
/**
* 待支付订单(定金)
* @return string
*/
public function depositPayment()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_create = new OrderCreateModel();
$data = [
'presale_id' => $this->params[ 'presale_id' ] ?? '', //预售id
'sku_id' => $this->params[ 'sku_id' ] ?? '',
'num' => $this->params[ 'num' ] ?? '',
];
if (empty($data[ 'presale_id' ]) && empty($data[ 'sku_id' ])) {
return $this->response($this->error('', '缺少必填参数商品数据'));
}
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->depositOrderPayment();
return $this->response($this->success($res));
}
/**
* 待支付订单(尾款)
* @return string
*/
// public function finalPayment()
// {
// $token = $this->checkToken();
// if ($token[ 'code' ] < 0) return $this->response($token);
// $order_create = new OrderCreateModel();
// $data = [
// 'id' => $this->params[ 'id' ] ?? '', //预售订单id
// 'site_id' => $this->site_id,//站点id
// 'member_id' => $this->member_id,
// 'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
// 'pay_password' => isset($this->params[ 'pay_password' ]) ? $this->params[ 'pay_password' ] : '',//支付密码
// ];
// if (empty($data[ 'id' ])) {
// return $this->response($this->error('', '缺少必填参数订单数据'));
// }
// $res = $order_create->finalCalculate($data);
// return $this->response($this->success($res));
// }
/**
* 尾款订单
*/
public function finalCreate()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_create = new OrderCreateModel();
$data = [
'id' => $this->params[ 'id' ] ?? '', //预售订单id
'site_id' => $this->site_id,//站点id
'member_id' => $this->member_id,
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
'pay_password' => $this->params[ 'pay_password' ] ?? '',//支付密码
];
if (empty($data[ 'id' ])) {
return $this->response($this->error('', '缺少必填参数订单数据'));
}
$res = $order_create->setParam($data)->payfinalMoneyPresaleOrder($data);
return $this->response($res);
}
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\presale\api\controller;
use addon\presale\model\PresaleOrder;
use addon\presale\model\PresaleOrderRefund;
use app\api\controller\BaseApi;
/**
* 预售订单退款
*/
class Refund extends BaseApi
{
/**
* 订单列表
* @return false|string
*/
public function page()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$page = $this->params['page'] ?? 1;
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'member_id', '=', $this->member_id ],
];
$refund_status = $this->params['refund_status'] ?? 0;
if ($refund_status) {
$condition[] = [ 'refund_status', '=', $refund_status ];
} else {
$condition[] = [ 'refund_status', '<>', 0 ];
}
$presale_order_model = new PresaleOrder();
$list = $presale_order_model->getPresaleOrderPageList($condition, $page, $page_size);
return $this->response($list);
}
/**
* 订单详情
*/
public function detail()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$presale_order_model = new PresaleOrder();
$condition = [
[ 'id', '=', $id ],
[ 'member_id', '=', $this->member_id ],
];
$order_info = $presale_order_model->getPresaleOrderInfo($condition);
return $this->response($order_info);
}
/**
* 申请退款(定金)
* @return false|string
*/
public function applyRefund()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$data = [
'id' => $id,
'site_id' => $this->site_id,
'member_id' => $this->member_id
];
$presale_order_refund_model = new PresaleOrderRefund();
$res = $presale_order_refund_model->applyRefund($data);
return $this->response($res);
}
/**
* 取消申请退款
*/
public function cancelRefund()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['order_id'] ?? 0;
if (empty($id)) {
return $this->response($this->error('', '缺少必须参数order_id'));
}
$condition = [
[ 'id', '=', $id ],
[ 'member_id', '=', $this->member_id ]
];
$presale_order_refund_model = new PresaleOrderRefund();
$res = $presale_order_refund_model->cancelRefund($condition);
return $this->response($res);
}
}