初始上传

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,179 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\pintuan\api\controller;
use addon\pintuan\model\Pintuan as PintuanModel;
use addon\pintuan\model\Poster;
use app\api\controller\BaseApi;
use app\model\goods\GoodsApi;
/**
* 拼团商品
*/
class Goods extends BaseApi
{
/**
* 拼团商品详情信息
*/
public function detail()
{
$pintuan_id = $this->params['pintuan_id'] ?? 0;
if (empty($pintuan_id)) {
return $this->response($this->error('', 'REQUEST_ID'));
}
$pintuan_model = new PintuanModel();
$condition = [
[ 'ppg.pintuan_id', '=', $pintuan_id ],
[ 'ppg.site_id', '=', $this->site_id ],
[ 'pp.status', '=', 1 ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ]
];
$goods_sku_detail = $pintuan_model->getPintuanGoodsDetail($condition)[ 'data' ];
if (empty($goods_sku_detail)) return $this->response($this->error());
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
//判断商品规格项
$goods_spec_format = $pintuan_model->getGoodsSpecFormat($pintuan_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
}
// 处理公共数据
$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;
$pintuan_id = $this->params['pintuan_id'] ?? 0;
$pintuan_num = $this->params[ 'pintuan_num' ] ?? 0;
if (empty($goods_id)) {
return $this->response($this->error('', 'REQUEST_ID'));
}
if (empty($pintuan_id)) {
return $this->response($this->error('', 'REQUEST_ID'));
}
$pintuan_model = new PintuanModel();
$condition = [
[ 'ppg.pintuan_id', '=', $pintuan_id ],
[ 'ppg.site_id', '=', $this->site_id ],
[ 'pp.status', '=', 1 ],
[ 'g.goods_id', '=', $goods_id ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ]
];
$list = $pintuan_model->getPintuanGoodsSkuList($condition);
foreach ($list[ 'data' ] as $k => $v) {
if ($v[ 'pintuan_type' ] == 'ladder') {
$v[ 'pintuan_ladder' ] = $pintuan_num;
$price = $pintuan_model->getPintuanPrice($v);
$list[ 'data' ][ $k ][ 'pintuan_price' ] = $price;
}
if (!empty($v[ 'goods_spec_format' ])) {
$goods_spec_format = $pintuan_model->getGoodsSpecFormat($pintuan_id, $this->site_id, $v[ 'goods_spec_format' ]);
$list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
}
}
return $this->response($list);
}
public function page()
{
$site_id = $this->site_id;
$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活动已结束 3失效 4删除
[ 'g.goods_stock', '>', 0 ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ],
[ 'g.site_id', '=', $site_id ]
];
if (!empty($goods_id_arr)) {
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
}
$pintuan_model = new PintuanModel();
$list = $pintuan_model->getPintuanGoodsPageList($condition, $page, $page_size, 'pp.pintuan_id desc');
return $this->response($list);
}
public function lists()
{
$site_id = $this->site_id;
$num = $this->params['num'] ?? null;
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
$condition = [
[ 'pp.status', '=', 1 ],// 状态0正常 1活动进行中 2活动已结束 3失效 4删除
[ 'g.goods_stock', '>', 0 ],
[ 'g.goods_state', '=', 1 ],
[ 'g.is_delete', '=', 0 ],
[ 'g.site_id', '=', $site_id ]
];
if (!empty($goods_id_arr)) {
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
}
$pintuan_model = new PintuanModel();
$list = $pintuan_model->getPintuanList($condition, '', 'pp.pintuan_id desc', $num);
return $this->response($list);
}
/**
* 获取商品海报
*/
public function poster()
{
$this->checkToken();
$promotion_type = 'pintuan';
$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);
}
/**
* 分享图片
* @return false|string
*/
public function shareImg()
{
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
$poster = new Poster();
$res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id);
return $this->response($res);
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* Index.php
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
* @author : niuteam
* @date : 2022.8.8
* @version : v5.0.0.1
*/
namespace addon\pintuan\api\controller;
use addon\pintuan\model\Pintuan;
use addon\pintuan\model\PintuanOrder as PintuanOrderModel;
use app\api\controller\BaseApi;
/**
* 拼团订单
* @author Administrator
*
*/
class Order extends BaseApi
{
/**
* 拼团订单详情
* @return string
*/
public function detail()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$id = $this->params['id'] ?? 0;//拼团订单主键id
if (empty($id)) {
return $this->response($this->error('', 'REQUEST_ID'));
}
$pintuan_order_model = new PintuanOrderModel();
$res = $pintuan_order_model->getPintuanOrderDetail($id, $this->member_id, $this->site_id);
return $this->response($res);
}
/**
* 拼团列表
* @return string
*/
public function page()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$pintuan_order_model = new PintuanOrderModel();
$condition = array (
[ "ppo.member_id", "=", $this->member_id ],
[ "ppo.site_id", "=", $this->site_id ]
);
$pintuan_status = $this->params['pintuan_status'] ?? 'all';
if ($pintuan_status != "all") {
$condition[] = [ "ppo.pintuan_status", "=", $pintuan_status ];
} else {
$condition[] = [ "ppo.pintuan_status", "<>", "0" ];//不查询未支付的拼团
}
$page_index = $this->params['page'] ?? 1;
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
$res = $pintuan_order_model->getPintuanOrderPageList($condition, $page_index, $page_size, "o.pay_time desc");
if (!empty($res[ 'data' ][ 'list' ])) {
foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
$member_list = $pintuan_order_model->getPintuanOrderList([ [ "group_id", "=", $v[ "group_id" ] ], [ 'pintuan_status', 'in', '2,3' ] ], "member_img,nickname");
$res[ 'data' ][ 'list' ][ $k ][ 'member_list' ] = $member_list[ 'data' ];
}
}
return $this->response($res);
}
/**
* 拼团会员
* @return string
*/
public function pintuanMember()
{
$token = $this->checkToken();
$pintuan_order_model = new PintuanOrderModel();
$pintuan = new Pintuan();
$condition = array (
[ "site_id", "=", $this->site_id ],
[ "pintuan_status", "=", '3' ],
);
$limit = $this->params['num'] ?? 5;
$field = 'head_id,member_id,member_img,nickname';
$pintuna_member_list = $pintuan_order_model->getPintuanOrderList($condition, $field, 'id desc', $limit, 'member_id')[ 'data' ] ?? [];
$pintuna_member_count = $pintuan->getPintuanInfo([
[ 'pp.site_id', '=', $this->site_id ],
[ 'pp.status', '=', 1 ],
], '(sum(g.sale_num) + sum(g.virtual_sale)) as sale_num', 'pp', [
[ 'goods g', 'g.goods_id=pp.goods_id', 'inner' ],
])[ 'data' ][ 'sale_num' ] ?? 0;
$data = [
'member_list' => $pintuna_member_list,
'pintuan_count' => numberFormat($pintuna_member_count)
];
return $this->response($this->success($data));
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* Index.php
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
* @author : niuteam
* @date : 2022.8.8
* @version : v5.0.0.1
*/
namespace addon\pintuan\api\controller;
use addon\pintuan\model\PintuanOrderCreate as OrderCreateModel;
use app\api\controller\BaseOrderCreateApi;
/**
* 订单创建
*
*/
class Ordercreate extends BaseOrderCreateApi
{
/**
* 创建订单
*/
public function create()
{
$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 calculate()
{
$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->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
return $this->response($this->success($res));
}
/**
* 待支付订单 数据初始化
* @return string
*/
public function payment()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_create = new OrderCreateModel();
$data = [
'id' => $this->params[ 'pintuan_goods_id' ] ?? '',//拼团商品id
'num' => $this->params[ 'num' ] ?? 1,//拼团商品数量(买几套)
'group_id' => $this->params[ 'group_id' ] ?? 0,//拼团组id
'extend' => !empty($this->params[ 'extend' ]) ? json_decode($this->params[ 'extend' ], true) : [],//业务扩展字段 {"pintuan_num":5}
];
if (empty($data[ 'id' ])) {
return $this->response($this->error('', '缺少必填参数商品数据'));
}
if ($data[ 'num' ] < 1) {
return $this->response($this->error('', '购买数量不能小于1'));
}
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->orderPayment();
return $this->response($this->success($res));
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\pintuan\api\controller;
use addon\pintuan\model\PintuanGroup as PintuanGroupModel;
use addon\pintuan\model\PintuanOrder;
use app\api\controller\BaseApi;
use app\model\order\OrderCommon;
/**
* 拼团组
*/
class Pintuangroup extends BaseApi
{
/**
* 列表信息
*/
public function lists()
{
$goods_id = $this->params[ 'goods_id' ] ?? 0;
if (empty($goods_id)) {
return $this->response($this->error('', 'REQUEST_GOODS_ID'));
}
$pintuan_group_model = new PintuanGroupModel();
$condition = [
[ 'ppg.goods_id', '=', $goods_id ],
[ 'ppg.status', '=', 2 ],// 当前状态:0未支付 1拼团失败 2.组团中3.拼团成功
[ 'ppg.site_id', '=', $this->site_id ]
];
$list = $pintuan_group_model->getPintuanGoodsGroupList($condition);
return $this->response($list);
}
/**
* 获取开团信息
* @return false|string
*/
public function info()
{
$group_id = input('group_id', 0);
$condition = [
[ 'pg.group_id', '=', $group_id ],
[ 'pg.site_id', '=', $this->site_id ]
];
$pintuan_group_model = new PintuanGroupModel();
$info = $pintuan_group_model->getPintuanGroupDetail($condition);
if (!empty($info)) {
$info[ 'data' ][ 'is_self' ] = 0;
$token = $this->checkToken();
if ($token[ 'code' ] == 0 && $info[ 'data' ][ 'head_id' ] == $this->member_id) $info[ 'data' ][ 'is_self' ] = 1;
//待支付的参团订单
$info[ 'data' ][ 'order_id' ] = 0;
if ($token[ 'code' ] == 0) {
$pintuan_order = new PintuanOrder();
$field = 'po.order_id';
$order_info = $pintuan_order->getPintuanOrderInfo([
[ 'po.pintuan_id', '=', $info[ 'data' ][ 'pintuan_id' ] ],
[ 'po.site_id', '=', $this->site_id ],
[ 'po.group_id', '=', $group_id ],
[ 'po.head_id', '<>', $this->member_id ],
[ 'o.member_id', '=', $this->member_id ],
[ 'o.order_status', '<>', OrderCommon::ORDER_CLOSE ],
], $field, 'po', [
[ 'order o', 'o.order_id = po.order_id', 'left' ]
]);
$info[ 'data' ][ 'order_id' ] = $order_info[ 'data' ][ 'order_id' ] ?? 0;
}
}
return $this->response($info);
}
}