初始上传
This commit is contained in:
81
addon/topic/api/controller/Ordercreate.php
Executable file
81
addon/topic/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?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\topic\api\controller;
|
||||
|
||||
use addon\topic\model\TopicOrderCreate 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[ 'topic_goods_id' ] ?? '',//专题商品id
|
||||
'num' => $this->params[ 'num' ] ?? 1,//专题商品数量(买几套)
|
||||
];
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
40
addon/topic/api/controller/Topic.php
Executable file
40
addon/topic/api/controller/Topic.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\topic\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\topic\model\Topic as TopicModel;
|
||||
|
||||
/**
|
||||
* 专题活动
|
||||
*/
|
||||
class Topic extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$condition = [
|
||||
[ 'status', '=', 2 ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
$order = 'create_time desc';
|
||||
$field = 'topic_id,topic_name,topic_adv,status,remark,start_time,end_time';
|
||||
$topic_model = new TopicModel();
|
||||
$list = $topic_model->getTopicPageList($condition, $page, $page_size, $order, $field);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
}
|
||||
147
addon/topic/api/controller/Topicgoods.php
Executable file
147
addon/topic/api/controller/Topicgoods.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\topic\api\controller;
|
||||
|
||||
use addon\topic\model\Poster;
|
||||
use addon\topic\model\Topic as TopicModel;
|
||||
use addon\topic\model\TopicGoods as TopicGoodsModel;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\goods\GoodsApi;
|
||||
use app\model\system\Promotion as PromotionModel;
|
||||
|
||||
/**
|
||||
* 专题活动商品
|
||||
*/
|
||||
class Topicgoods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 详情信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$this->checkToken();
|
||||
$id = $this->params['topic_id'] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$topic_goods_model = new TopicGoodsModel();
|
||||
$condition = [
|
||||
[ 'ptg.id', '=', $id ],
|
||||
[ 'pt.status', '=', 2 ]
|
||||
];
|
||||
$goods_sku_detail = $topic_goods_model->getTopicGoodsDetail($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 = $topic_goods_model->getGoodsSpecFormat($goods_sku_detail[ 'topic_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;
|
||||
$topic_id = $this->params['topic_id'] ?? 0;
|
||||
|
||||
if (empty($topic_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$topic_goods_model = new TopicGoodsModel();
|
||||
$condition = [
|
||||
[ 'ptg.topic_id', '=', $topic_id ],
|
||||
[ 'ptg.goods_id', '=', $goods_id ],
|
||||
[ 'pt.status', '=', 2 ]
|
||||
];
|
||||
$list = $topic_goods_model->getTopicGoodsSkuList($condition);
|
||||
if (!empty($list[ 'data' ])) {
|
||||
foreach ($list[ 'data' ] as $k => $v) {
|
||||
if (!empty($v[ 'goods_spec_format' ])) {
|
||||
$goods_spec_format = $topic_goods_model->getGoodsSpecFormat($v[ 'topic_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()
|
||||
{
|
||||
$topic_id = $this->params['topic_id'] ?? 0;
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
|
||||
if (empty($topic_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_TOPIC_ID'));
|
||||
}
|
||||
$condition = [
|
||||
[ 'nptg.topic_id', '=', $topic_id ],
|
||||
[ 'ngs.goods_state', '=', 1 ],
|
||||
[ 'ngs.is_delete', '=', 0 ],
|
||||
[ 'nptg.default', '=', 1 ]
|
||||
];
|
||||
$order = 'nptg.id asc';
|
||||
$topic_goods_model = new TopicGoodsModel();
|
||||
|
||||
$topic_model = new TopicModel();
|
||||
$info = $topic_model->getTopicInfo([ [ "topic_id", "=", $topic_id ] ], 'bg_color,topic_adv,topic_name');
|
||||
$info = $info[ 'data' ];
|
||||
|
||||
$res = $topic_goods_model->getTopicGoodsPageList($condition, $page, $page_size, $order);
|
||||
// $res[ 'data' ][ 'bg_color' ] = $info[ 'bg_color' ];
|
||||
$res[ 'data' ][ 'topic_adv' ] = $info[ 'topic_adv' ];
|
||||
$res[ 'data' ][ 'topic_name' ] = $info[ 'topic_name' ];
|
||||
|
||||
$promotion_model = new PromotionModel();
|
||||
$zone_config = $promotion_model->getPromotionZoneConfig('topic', $this->site_id)[ 'data' ][ 'value' ];
|
||||
$res[ 'data' ][ 'bg_color' ] = $zone_config[ 'bg_color' ];
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品海报
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
$promotion_type = 'topic';
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user