初始上传
This commit is contained in:
270
addon/bargain/api/controller/Bargain.php
Executable file
270
addon/bargain/api/controller/Bargain.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
*/
|
||||
class Bargain extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取我的砍价详情
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
$bargain = new BargainModel();
|
||||
$data = $bargain->getBargainLaunchDetail($condition, 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status');
|
||||
if ($data[ 'code' ] == 0) {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$bargain_goods_info = $bargain->getBargainGoodsDetail([ [ 'pbg.sku_id', '=', $data[ 'data' ][ 'sku_id' ] ], [ 'pb.status', '=', '1' ] ], 'pbg.bargain_stock,pb.status,g.goods_content')[ 'data' ];
|
||||
$data[ 'data' ][ 'bargain_stock' ] = $bargain_goods_info[ 'bargain_stock' ];
|
||||
$data[ 'data' ][ 'bargain_status' ] = $bargain_goods_info[ 'status' ];
|
||||
$data[ 'data' ][ 'goods_content' ] = $bargain_goods_info[ 'goods_content' ];
|
||||
if ($data[ 'data' ][ 'member_id' ] == $this->member_id) {
|
||||
$data[ 'data' ][ 'self' ] = 1;
|
||||
} else {
|
||||
$data[ 'data' ][ 'self' ] = 0;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $id ], [ 'member_id', '=', $this->member_id ] ], 'id');
|
||||
$data[ 'data' ][ 'cut' ] = empty($record_info[ 'data' ]) ? 0 : 1;
|
||||
}
|
||||
} else {
|
||||
$data[ 'data' ][ 'self' ] = 0;
|
||||
$data[ 'data' ][ 'cut' ] = 0;
|
||||
}
|
||||
}
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的砍价分页列表
|
||||
*/
|
||||
public function launchPage()
|
||||
{
|
||||
$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;
|
||||
$status = $this->params[ 'status' ] ?? 'all';
|
||||
|
||||
$condition = [
|
||||
[ 'pbl.site_id', '=', $this->site_id ],
|
||||
[ 'pbl.member_id', '=', $this->member_id ]
|
||||
];
|
||||
if ($status != 'all') {
|
||||
$condition[] = [ 'pbl.status', '=', $status ];
|
||||
}
|
||||
$bargain = new BargainModel();
|
||||
$field = 'pbl.*, pb.status as bargain_status';
|
||||
$data = $bargain->getBargainLaunchPageList($condition, $field, 'pbl.launch_id desc', $page, $page_size, 'pbl', [
|
||||
[ 'promotion_bargain pb', 'pbl.bargain_id = pb.bargain_id', 'inner' ]
|
||||
]);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起砍价
|
||||
* @return false|string
|
||||
*/
|
||||
public function launch()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->launch($id, $this->member_id, $this->site_id, $this->store_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
*/
|
||||
public function bargain()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargain($id, $this->member_id, $this->site_id);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价记录
|
||||
* @return false|string
|
||||
*/
|
||||
public function record()
|
||||
{
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $id ]
|
||||
];
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$data = $bargain->getBargainRecordPageList($condition, '*', 'id desc', $page, $page_size);
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价详情
|
||||
* @return false|string|void
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
$launch_id = $this->params[ 'launch_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$token = $this->checkToken();
|
||||
$bargain = new BargainModel();
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
// [ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$goods_sku_detail = $bargain->getBargainGoodsDetail($condition, '')[ 'data' ];
|
||||
|
||||
$bargain->bargainBrowseInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
|
||||
if (empty($goods_sku_detail)) return $this->response($this->error($res));
|
||||
|
||||
if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
|
||||
//判断商品规格项
|
||||
$goods_spec_format = $bargain->getGoodsSpecFormat($bargain_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
|
||||
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
|
||||
$launch_info = [];
|
||||
if ($launch_id) {
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $launch_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
$launch_info = $bargain->getBargainLaunchDetail($condition, 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status')[ 'data' ] ?? [];
|
||||
} else {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$launch_info = $bargain->getBargainLaunchDetail([
|
||||
[ 'bargain_id', '=', $goods_sku_detail[ 'bargain_id' ] ],
|
||||
[ 'sku_id', '=', $goods_sku_detail[ 'sku_id' ] ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'status', '=', 0 ]
|
||||
], 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status')[ 'data' ] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($launch_info) {
|
||||
$launch_info[ 'pay_status' ] = 0;
|
||||
if ($launch_info[ 'order_id' ]) {
|
||||
$order = new OrderCommon();
|
||||
$order_info = $order->getOrderInfo([ [ 'order_id', '=', $launch_info[ 'order_id' ] ], [ 'site_id', '=', $this->site_id ] ], 'order_status, pay_status')[ 'data' ] ?? [];
|
||||
$launch_info[ 'pay_status' ] = $order_info[ 'pay_status' ] ?? 0;
|
||||
$launch_info[ 'order_status' ] = $order_info[ 'order_status' ];
|
||||
// if($launch_info['order_status'] == OrderCommon::ORDER_CLOSE) $launch_info['order_id'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($launch_info)) {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
if ($launch_info[ 'member_id' ] == $this->member_id) {
|
||||
$launch_info[ 'self' ] = 1;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $launch_info[ 'launch_id' ] ], [ 'member_id', '=', $this->member_id ] ], 'money');
|
||||
$launch_info[ 'my_bargain_money' ] = $record_info[ 'data' ][ 'money' ] ?? 0;
|
||||
} else {
|
||||
$launch_info[ 'self' ] = 0;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $launch_info[ 'launch_id' ] ], [ 'member_id', '=', $this->member_id ] ], 'id');
|
||||
$launch_info[ 'cut' ] = empty($record_info[ 'data' ]) ? 0 : 1;
|
||||
}
|
||||
} else {
|
||||
$launch_info[ 'self' ] = 0;
|
||||
$launch_info[ 'cut' ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$res[ 'launch_info' ] = $launch_info;
|
||||
|
||||
//已砍成功的人
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'bargain_id', '=', $bargain_id ],
|
||||
[ 'status', '=', 1 ]
|
||||
];
|
||||
$launch_list = $bargain->getBargainLaunchList($condition, 'status,curr_price,nickname,headimg,end_time', 'launch_id desc', '', '', '', 20);
|
||||
$res[ 'launch_list' ] = $launch_list;
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
public function browse()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargainBrowseInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
public function share()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargainShareInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
226
addon/bargain/api/controller/Goods.php
Executable file
226
addon/bargain/api/controller/Goods.php
Executable file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\api\controller;
|
||||
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
use addon\bargain\model\Poster;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\api\controller\Goodssku;
|
||||
|
||||
/**
|
||||
* 砍价商品
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取砍价活动列表
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$id_arr = $this->params[ 'id_arr' ] ?? '';
|
||||
$is_exclude_bargaining = $this->params[ 'is_exclude_bargaining' ] ?? 0; // 是否需排除砍价中
|
||||
|
||||
$bargain = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if (!empty($id_arr)) {
|
||||
$condition[] = [ 'pb.goods_id', 'in', $id_arr ];
|
||||
}
|
||||
if ($is_exclude_bargaining) {
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$goods_id = $bargain->getBargainingGoodsId($this->member_id);
|
||||
if (!empty($goods_id)) $condition[] = [ 'g.goods_id', 'not in', $goods_id ];
|
||||
}
|
||||
}
|
||||
|
||||
$data = $bargain->getBargainPageList($condition, $page, $page_size, 'pb.bargain_id desc', '');
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价活动列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$num = $this->params[ 'num' ] ?? null;
|
||||
$id_arr = $this->params[ 'id_arr' ] ?? '';
|
||||
$is_exclude_bargaining = $this->params[ 'is_exclude_bargaining' ] ?? 0; // 是否需排除砍价中
|
||||
|
||||
$bargain = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if (!empty($id_arr)) {
|
||||
$condition[] = [ 'pb.goods_id', 'in', $id_arr ];
|
||||
}
|
||||
if ($is_exclude_bargaining) {
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$goods_id = $bargain->getBargainingGoodsId($this->member_id);
|
||||
if (!empty($goods_id)) $condition[] = [ 'g.goods_id', 'not in', $goods_id ];
|
||||
}
|
||||
}
|
||||
|
||||
$data = $bargain->getBargainList($condition, '', 'pb.bargain_id desc', $num);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价中的商品列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function bargainingList()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$condition = [
|
||||
[ 'pbl.site_id', '=', $this->site_id ],
|
||||
[ 'pbl.member_id', '=', $this->member_id ],
|
||||
[ 'pbl.status', '=', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
];
|
||||
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = pbl.goods_id', 'left' ],
|
||||
[ 'promotion_bargain pb', 'pb.goods_id = pbl.goods_id', 'left' ],
|
||||
];
|
||||
$field = 'pb.sale_num,pb.join_num,pbl.launch_id,pbl.bargain_id,pbl.sku_id,pbl.goods_id,pbl.site_id,pbl.start_time,pbl.end_time,pbl.member_id,pbl.curr_price,pbl.price,g.goods_name,g.goods_image,g.recommend_way,pbl.floor_price';
|
||||
$bargain = new BargainModel();
|
||||
$list = $bargain->getBargainLaunchList($condition, $field, 'pbl.start_time desc', 'pbl', $join);
|
||||
return $this->response($this->success($list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$bargain = new BargainModel();
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
[ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$goods_sku_detail = $bargain->getBargainGoodsDetail($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 = $bargain->getGoodsSpecFormat($bargain_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
|
||||
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$launch_info = $bargain->getBargainLaunchDetail([
|
||||
[ 'bargain_id', '=', $goods_sku_detail[ 'bargain_id' ] ],
|
||||
[ 'sku_id', '=', $goods_sku_detail[ 'sku_id' ] ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'status', '=', 0 ]
|
||||
], 'launch_id');
|
||||
if (!empty($launch_info[ 'data' ])) $res[ 'goods_sku_detail' ][ 'launch_info' ] = $launch_info[ 'data' ];
|
||||
}
|
||||
|
||||
// 处理公共数据
|
||||
$goods_sku_api = new Goodssku();
|
||||
$goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ]);
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品SKU集合
|
||||
* @return false|string
|
||||
*/
|
||||
public function goodsSku()
|
||||
{
|
||||
$goods_id = $this->params[ 'goods_id' ] ?? 0;
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
// [ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_id', '=', $goods_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
$goods = new BargainModel();
|
||||
$list = $goods->getBargainGoodsSkuList($condition);
|
||||
foreach ($list[ 'data' ] as $k => $v) {
|
||||
if (!empty($v[ 'goods_spec_format' ])) {
|
||||
$goods_spec_format = $goods->getGoodsSpecFormat($bargain_id, $this->site_id, $v[ 'goods_spec_format' ]);
|
||||
$list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品海报
|
||||
* @return false|string
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
$promotion_type = 'bargain';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
74
addon/bargain/api/controller/Ordercreate.php
Executable file
74
addon/bargain/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?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\bargain\api\controller;
|
||||
|
||||
use addon\bargain\model\BargainOrderCreate 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['launch_id'] ?? '',//砍价发起id
|
||||
'num' => 1,
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->orderPayment();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user