7 changed files with 0 additions and 571 deletions
@ -1,39 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Active as ActiveModel; |
|||
use app\api\model\sharing\Goods as GoodsModel; |
|||
|
|||
/** |
|||
* 拼团拼单控制器 |
|||
* Class Active |
|||
* @package app\api\controller\sharing |
|||
*/ |
|||
class Active extends Controller |
|||
{ |
|||
/** |
|||
* 拼单详情 |
|||
* @param $active_id |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function detail($active_id) |
|||
{ |
|||
// 拼单详情 |
|||
$detail = ActiveModel::detail($active_id); |
|||
if (!$detail) { |
|||
return $this->renderError('很抱歉,拼单不存在'); |
|||
} |
|||
// 拼团商品详情 |
|||
$goods = GoodsModel::detail($detail['goods_id']); |
|||
// 多规格商品sku信息 |
|||
$specData = $goods['spec_type'] == 20 ? $goods->getManySpecData($goods['spec_rel'], $goods['sku']) : null; |
|||
// 更多拼团商品 |
|||
$model = new GoodsModel; |
|||
$goodsList = $model->getList(10, 0, '', 'all', false, 5); |
|||
return $this->renderSuccess(compact('detail', 'goods', 'goodsList', 'specData')); |
|||
} |
|||
|
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Order as OrderModel; |
|||
use app\api\model\sharing\OrderGoods as OrderGoodsModel; |
|||
use app\api\model\sharing\Comment as CommentModel; |
|||
|
|||
/** |
|||
* 拼团订单评价管理 |
|||
* Class Comment |
|||
* @package app\api\controller\sharing |
|||
*/ |
|||
class Comment extends Controller |
|||
{ |
|||
/** |
|||
* 待评价订单商品列表 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \Exception |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function order($order_id) |
|||
{ |
|||
// 用户信息 |
|||
$user = $this->getUser(); |
|||
// 订单信息 |
|||
$order = OrderModel::getUserOrderDetail($order_id, $user['user_id']); |
|||
// 验证订单是否已完成 |
|||
$model = new CommentModel; |
|||
if (!$model->checkOrderAllowComment($order)) { |
|||
return $this->renderError($model->getError()); |
|||
} |
|||
// 待评价商品列表 |
|||
/* @var \think\Collection $goodsList */ |
|||
$goodsList = OrderGoodsModel::getNotCommentGoodsList($order_id); |
|||
if ($goodsList->isEmpty()) { |
|||
return $this->renderError('该订单没有可评价的商品'); |
|||
} |
|||
// 提交商品评价 |
|||
if ($this->request->isPost()) { |
|||
$formData = $this->request->post('formData', '', null); |
|||
if ($model->addForOrder($order, $goodsList, $formData)) { |
|||
return $this->renderSuccess([], '评价发表成功'); |
|||
} |
|||
return $this->renderError($model->getError() ?: '评价发表失败'); |
|||
} |
|||
return $this->renderSuccess(compact('goodsList')); |
|||
} |
|||
|
|||
/** |
|||
* 商品评价列表 |
|||
* @param $goods_id |
|||
* @param int $scoreType |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function lists($goods_id, $scoreType = -1) |
|||
{ |
|||
$model = new CommentModel; |
|||
$list = $model->getGoodsCommentList($goods_id, $scoreType); |
|||
$total = $model->getTotal($goods_id); |
|||
return $this->renderSuccess(compact('list', 'total')); |
|||
} |
|||
|
|||
} |
|||
@ -1,68 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Goods as GoodsModel; |
|||
use app\common\service\qrcode\Goods as GoodsPoster; |
|||
use app\api\model\sharing\Active as ActiveModel; |
|||
|
|||
/** |
|||
* 商品控制器 |
|||
* Class Goods |
|||
* @package app\api\controller |
|||
*/ |
|||
class Goods extends Controller |
|||
{ |
|||
/** |
|||
* 商品列表 |
|||
* @param int $category_id |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function lists($category_id = 0) |
|||
{ |
|||
$model = new GoodsModel; |
|||
$list = $model->getList(10, $category_id); |
|||
return $this->renderSuccess(compact('list')); |
|||
} |
|||
|
|||
/** |
|||
* 获取商品详情 |
|||
* @param $goods_id |
|||
* @return array |
|||
*/ |
|||
public function detail($goods_id) |
|||
{ |
|||
// 商品详情 |
|||
$detail = GoodsModel::detail($goods_id); |
|||
if (!$detail || $detail['is_delete'] || $detail['goods_status']['value'] != 10) { |
|||
return $this->renderError('很抱歉,商品信息不存在或已下架'); |
|||
} |
|||
// 多规格商品sku信息 |
|||
$specData = $detail['spec_type'] == 20 ? $detail->getManySpecData($detail['spec_rel'], $detail['sku']) : null; |
|||
// 当前进行中的拼单 |
|||
$activeList = ActiveModel::getActivityListByGoods($goods_id, 2); |
|||
return $this->renderSuccess(compact('detail', 'specData', 'activeList')); |
|||
} |
|||
|
|||
/** |
|||
* 获取推广二维码 |
|||
* @param $goods_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
* @throws \Exception |
|||
*/ |
|||
public function poster($goods_id) |
|||
{ |
|||
// 商品详情 |
|||
$detail = GoodsModel::detail($goods_id); |
|||
// 生成推广二维码 |
|||
$Qrcode = new GoodsPoster($detail, $this->getUser(false), 20); |
|||
return $this->renderSuccess([ |
|||
'qrcode' => $Qrcode->getImage(), |
|||
]); |
|||
} |
|||
|
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Category as CategoryModel; |
|||
|
|||
/** |
|||
* 拼团首页控制器 |
|||
* Class Active |
|||
* @package app\api\controller\sharing |
|||
*/ |
|||
class Index extends Controller |
|||
{ |
|||
/** |
|||
* 拼团首页 |
|||
* @return array |
|||
*/ |
|||
public function index() |
|||
{ |
|||
// 拼团分类列表 |
|||
$categoryList = CategoryModel::getCacheAll(); |
|||
return $this->renderSuccess(compact('categoryList')); |
|||
} |
|||
|
|||
} |
|||
@ -1,235 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Order as OrderModel; |
|||
|
|||
use app\common\enum\OrderType as OrderTypeEnum; |
|||
use app\common\enum\DeliveryType as DeliveryTypeEnum; |
|||
use app\common\enum\order\PayType as PayTypeEnum; |
|||
use app\common\service\qrcode\Extract as ExtractQRcode; |
|||
|
|||
/** |
|||
* 拼团订单控制器 |
|||
* Class Order |
|||
* @package app\api\controller |
|||
*/ |
|||
class Order extends Controller |
|||
{ |
|||
/* @var \app\api\model\User $user */ |
|||
private $user; |
|||
|
|||
/** |
|||
* 构造方法 |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function _initialize() |
|||
{ |
|||
parent::_initialize(); |
|||
$this->user = $this->getUser(); // 用户信息 |
|||
} |
|||
|
|||
/** |
|||
* 订单确认 |
|||
* @param int $order_type 订单类型 (10单独购买 20拼团) |
|||
* @param int $goods_id 商品id |
|||
* @param int $goods_num |
|||
* @param int $goods_sku_id |
|||
* @param int $delivery 配送方式 |
|||
* @param int $pay_type 支付方式 |
|||
* @param int $shop_id 自提门店id |
|||
* @param int $active_id 拼团活动id |
|||
* @param int $coupon_id 优惠券id |
|||
* @param string $remark |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\Exception |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function checkout( |
|||
$order_type, |
|||
$goods_id, |
|||
$goods_num, |
|||
$goods_sku_id, |
|||
$delivery = DeliveryTypeEnum::EXPRESS, |
|||
$pay_type = PayTypeEnum::WECHAT, |
|||
$shop_id = 0, |
|||
$active_id = null, |
|||
$coupon_id = null, |
|||
$remark = '' |
|||
) |
|||
{ |
|||
// 商品结算信息 |
|||
$model = new OrderModel; |
|||
$order = $model->getBuyNow( |
|||
$this->user, |
|||
$order_type, |
|||
$goods_id, |
|||
$goods_num, |
|||
$goods_sku_id, |
|||
$delivery, |
|||
$pay_type, |
|||
$shop_id |
|||
); |
|||
if (!$this->request->isPost()) { |
|||
return $this->renderSuccess($order); |
|||
} |
|||
if ($model->hasError()) { |
|||
return $this->renderError($model->getError()); |
|||
} |
|||
// 创建订单 |
|||
if (!$model->createOrder($this->user, $order, $active_id, $coupon_id, $remark)) { |
|||
return $this->renderError($model->getError() ?: '订单创建失败'); |
|||
} |
|||
// 构建微信支付请求 |
|||
$payment = ($pay_type == PayTypeEnum::WECHAT) ? $model->paymentByWechat($this->user) : []; |
|||
return $this->renderSuccess([ |
|||
'order_id' => $model['order_id'], // 订单id |
|||
'pay_type' => $pay_type, // 支付方式 |
|||
'payment' => $payment // 微信支付参数 |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* 我的拼团订单列表 |
|||
* @param $dataType |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function lists($dataType) |
|||
{ |
|||
$model = new OrderModel; |
|||
$list = $model->getList($this->user['user_id'], $dataType); |
|||
return $this->renderSuccess(compact('list')); |
|||
} |
|||
|
|||
/** |
|||
* 拼团订单详情信息 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
*/ |
|||
public function detail($order_id) |
|||
{ |
|||
// 订单详情 |
|||
$order = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
// 该订单是否允许申请售后 |
|||
$order['isAllowRefund'] = $order->isAllowRefund(); |
|||
return $this->renderSuccess(compact('order')); |
|||
} |
|||
|
|||
/** |
|||
* 获取物流信息 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
*/ |
|||
public function express($order_id) |
|||
{ |
|||
// 订单信息 |
|||
$order = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
if (!$order['express_no']) { |
|||
return $this->renderError('没有物流信息'); |
|||
} |
|||
// 获取物流信息 |
|||
/* @var \app\store\model\Express $model */ |
|||
$model = $order['express']; |
|||
$express = $model->dynamic($model['express_name'], $model['express_code'], $order['express_no']); |
|||
if ($express === false) { |
|||
return $this->renderError($model->getError()); |
|||
} |
|||
return $this->renderSuccess(compact('express')); |
|||
} |
|||
|
|||
/** |
|||
* 取消订单 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
*/ |
|||
public function cancel($order_id) |
|||
{ |
|||
$model = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
if ($model->cancel()) { |
|||
return $this->renderSuccess($model->getError() ?: '订单取消成功'); |
|||
} |
|||
return $this->renderError($model->getError() ?: '订单取消失败'); |
|||
} |
|||
|
|||
/** |
|||
* 确认收货 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function receipt($order_id) |
|||
{ |
|||
$model = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
if ($model->receipt()) { |
|||
return $this->renderSuccess(); |
|||
} |
|||
return $this->renderError($model->getError()); |
|||
} |
|||
|
|||
/** |
|||
* 立即支付 |
|||
* @param int $order_id 订单id |
|||
* @param int $payType 支付方式 |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\Exception |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function pay($order_id, $payType = PayTypeEnum::WECHAT) |
|||
{ |
|||
// 订单详情 |
|||
$model = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
// 判断商品状态、库存 |
|||
if (!$model->checkGoodsStatusFromOrder($model['goods'])) { |
|||
return $this->renderError($model->getError()); |
|||
} |
|||
$render = [ |
|||
'order_id' => $model['order_id'], // 订单id |
|||
'pay_type' => $payType, // 支付方式 |
|||
]; |
|||
if ($payType == PayTypeEnum::WECHAT) { |
|||
$render['payment'] = $model->paymentByWechat($this->user); |
|||
} elseif ($payType == PayTypeEnum::BALANCE) { |
|||
if ($model->paymentByBalance($model['order_no'])) { |
|||
return $this->renderSuccess($render, '支付成功'); |
|||
} |
|||
return $this->renderError($model->getError() ?: '支付失败', $render); |
|||
} |
|||
return $this->renderSuccess($render); |
|||
} |
|||
|
|||
/** |
|||
* 获取订单核销二维码 |
|||
* @param $order_id |
|||
* @return array |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function extractQrcode($order_id) |
|||
{ |
|||
// 订单详情 |
|||
$order = OrderModel::getUserOrderDetail($order_id, $this->user['user_id']); |
|||
// 判断是否为待核销订单 |
|||
if (!$order->checkExtractOrder($order)) { |
|||
return $this->renderError($order->getError()); |
|||
} |
|||
$Qrcode = new ExtractQRcode( |
|||
$this->wxapp_id, |
|||
$this->user, |
|||
$order_id, |
|||
OrderTypeEnum::SHARING |
|||
); |
|||
return $this->renderSuccess([ |
|||
'qrcode' => $Qrcode->getImage(), |
|||
]); |
|||
} |
|||
|
|||
} |
|||
@ -1,109 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\Express as ExpressModel; |
|||
use app\api\model\sharing\OrderGoods as OrderGoodsModel; |
|||
use app\api\model\sharing\OrderRefund as OrderRefundModel; |
|||
|
|||
/** |
|||
* 拼团订单售后服务 |
|||
* Class Refund |
|||
* @package app\api\controller\user\order |
|||
*/ |
|||
class Refund extends Controller |
|||
{ |
|||
/* @var \app\api\model\User $user */ |
|||
private $user; |
|||
|
|||
/** |
|||
* 构造方法 |
|||
* @throws \app\common\exception\BaseException |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function _initialize() |
|||
{ |
|||
parent::_initialize(); |
|||
$this->user = $this->getUser(); // 用户信息 |
|||
} |
|||
|
|||
/** |
|||
* 用户售后单列表 |
|||
* @param int $state |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function lists($state = -1) |
|||
{ |
|||
$model = new OrderRefundModel; |
|||
$list = $model->getList($this->user['user_id'], (int)$state); |
|||
return $this->renderSuccess(compact('list')); |
|||
} |
|||
|
|||
/** |
|||
* 申请售后 |
|||
* @param $order_goods_id |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
* @throws \Exception |
|||
*/ |
|||
public function apply($order_goods_id) |
|||
{ |
|||
// 订单商品详情 |
|||
$goods = OrderGoodsModel::detail($order_goods_id); |
|||
if (isset($goods['refund']) && !empty($goods['refund'])) { |
|||
return $this->renderError('当前商品已申请售后'); |
|||
} |
|||
if (!$this->request->isPost()) { |
|||
return $this->renderSuccess(['detail' => $goods]); |
|||
} |
|||
// 新增售后单记录 |
|||
$model = new OrderRefundModel; |
|||
if ($model->apply($this->user, $goods, $this->request->post())) { |
|||
return $this->renderSuccess([], '提交成功'); |
|||
} |
|||
return $this->renderError($model->getError() ?: '提交失败'); |
|||
} |
|||
|
|||
/** |
|||
* 售后单详情 |
|||
* @param $order_refund_id |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function detail($order_refund_id) |
|||
{ |
|||
// 售后单详情 |
|||
$detail = OrderRefundModel::detail([ |
|||
'user_id' => $this->user['user_id'], |
|||
'order_refund_id' => $order_refund_id |
|||
]); |
|||
if (empty($detail)) { |
|||
return $this->renderError('售后单不存在'); |
|||
} |
|||
// 物流公司列表 |
|||
$expressList = ExpressModel::getAll(); |
|||
return $this->renderSuccess(compact('detail', 'expressList')); |
|||
} |
|||
|
|||
/** |
|||
* 用户发货 |
|||
* @param $order_refund_id |
|||
* @return array |
|||
* @throws \think\exception\DbException |
|||
*/ |
|||
public function delivery($order_refund_id) |
|||
{ |
|||
// 售后单详情 |
|||
$model = OrderRefundModel::detail([ |
|||
'user_id' => $this->user['user_id'], |
|||
'order_refund_id' => $order_refund_id |
|||
]); |
|||
if ($model->delivery($this->postData())) { |
|||
return $this->renderSuccess([], '操作成功'); |
|||
} |
|||
return $this->renderError($model->getError() ?: '提交失败'); |
|||
} |
|||
|
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace app\api\controller\sharing; |
|||
|
|||
use app\api\controller\Controller; |
|||
use app\api\model\sharing\Setting as SettingModel; |
|||
|
|||
/** |
|||
* 拼团设置控制器 |
|||
* Class Setting |
|||
* @package app\api\controller\sharing |
|||
*/ |
|||
class Setting extends Controller |
|||
{ |
|||
/** |
|||
* 获取拼团设置 |
|||
* @return array |
|||
*/ |
|||
public function getAll() |
|||
{ |
|||
// 获取拼团设置 |
|||
$setting = SettingModel::getSetting(); |
|||
return $this->renderSuccess(compact('setting')); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue