Browse Source

删除不需要文件

master
wanghongjun 3 years ago
parent
commit
8ed932e013
  1. 111
      source/application/api/controller/Address.php
  2. 53
      source/application/api/controller/Article.php
  3. 84
      source/application/api/controller/Cart.php
  4. 29
      source/application/api/controller/Category.php
  5. 29
      source/application/api/controller/Comment.php
  6. 29
      source/application/api/controller/Coupon.php
  7. 74
      source/application/api/controller/Goods.php
  8. 135
      source/application/api/controller/Order.php
  9. 61
      source/application/api/controller/Page.php
  10. 65
      source/application/api/controller/Recharge.php
  11. 41
      source/application/api/controller/Shop.php
  12. 86
      source/application/api/controller/Upload.php
  13. 43
      source/application/api/controller/User.php
  14. 39
      source/application/api/controller/Wxapp.php
  15. 28
      source/application/api/controller/balance/Log.php
  16. 28
      source/application/api/controller/library/Pass.php
  17. 26
      source/application/api/controller/live/Room.php
  18. 28
      source/application/api/controller/recharge/Order.php
  19. 72
      source/application/api/controller/shop/Order.php
  20. 53
      source/application/api/controller/user/Comment.php
  21. 74
      source/application/api/controller/user/Coupon.php
  22. 115
      source/application/api/controller/user/Dealer.php
  23. 41
      source/application/api/controller/user/Index.php
  24. 177
      source/application/api/controller/user/Order.php
  25. 109
      source/application/api/controller/user/Refund.php
  26. 45
      source/application/api/controller/user/dealer/Apply.php
  27. 56
      source/application/api/controller/user/dealer/Order.php
  28. 57
      source/application/api/controller/user/dealer/Qrcode.php
  29. 60
      source/application/api/controller/user/dealer/Team.php
  30. 72
      source/application/api/controller/user/dealer/Withdraw.php
  31. 25
      source/application/api/controller/wxapp/Formid.php
  32. 25
      source/application/api/controller/wxapp/Submsg.php

111
source/application/api/controller/Address.php

@ -1,111 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\UserAddress;
/**
* 收货地址管理
* Class Address
* @package app\api\controller
*/
class Address extends Controller
{
/**
* 收货地址列表
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function lists()
{
$user = $this->getUser();
$model = new UserAddress;
$list = $model->getList($user['user_id']);
return $this->renderSuccess([
'list' => $list,
'default_id' => $user['address_id'],
]);
}
/**
* 添加收货地址
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function add()
{
$model = new UserAddress;
if ($model->add($this->getUser(), $this->request->post())) {
return $this->renderSuccess([], '添加成功');
}
return $this->renderError('添加失败');
}
/**
* 收货地址详情
* @param $address_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function detail($address_id)
{
$user = $this->getUser();
$detail = UserAddress::detail($user['user_id'],$address_id);
$region = array_values($detail['region']);
return $this->renderSuccess(compact('detail', 'region'));
}
/**
* 编辑收货地址
* @param $address_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function edit($address_id)
{
$user = $this->getUser();
$model = UserAddress::detail($user['user_id'], $address_id);
if ($model->edit($this->request->post())) {
return $this->renderSuccess([], '更新成功');
}
return $this->renderError('更新失败');
}
/**
* 设为默认地址
* @param $address_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function setDefault($address_id) {
$user = $this->getUser();
$model = UserAddress::detail($user['user_id'], $address_id);
if ($model->setDefault($user)) {
return $this->renderSuccess([], '设置成功');
}
return $this->renderError('设置失败');
}
/**
* 删除收货地址
* @param $address_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function delete($address_id)
{
$user = $this->getUser();
$model = UserAddress::detail($user['user_id'], $address_id);
if ($model->remove($user)) {
return $this->renderSuccess([], '删除成功');
}
return $this->renderError('删除失败');
}
}

53
source/application/api/controller/Article.php

@ -1,53 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Article as ArticleModel;
use app\api\model\article\Category as CategoryModel;
/**
* 文章控制器
* Class Article
* @package app\api\controller
*/
class Article extends Controller
{
/**
* 文章首页
* @return array
*/
public function index()
{
// 文章分类列表
$categoryList = CategoryModel::getAll();
return $this->renderSuccess(compact('categoryList'));
}
/**
* 文章列表
* @param int $category_id
* @return array
* @throws \think\exception\DbException
*/
public function lists($category_id = 0)
{
$model = new ArticleModel;
$list = $model->getList($category_id);
return $this->renderSuccess(compact('list'));
}
/**
* 文章详情
* @param $article_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function detail($article_id)
{
$detail = ArticleModel::detail($article_id);
return $this->renderSuccess(compact('detail'));
}
}

84
source/application/api/controller/Cart.php

@ -1,84 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Cart as CartModel;
/**
* 购物车管理
* Class Cart
* @package app\api\controller
*/
class Cart extends Controller
{
/* @var \app\api\model\User $user */
private $user;
/* @var \app\api\model\Cart $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->user = $this->getUser();
$this->model = new CartModel($this->user);
}
/**
* 购物车列表
* @return array
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function lists()
{
return $this->renderSuccess($this->model->getList());
}
/**
* 加入购物车
* @param $goods_id
* @param $goods_num
* @param $goods_sku_id
* @return array
*/
public function add($goods_id, $goods_num, $goods_sku_id)
{
if (!$this->model->add($goods_id, $goods_num, $goods_sku_id)) {
return $this->renderError($this->model->getError() ?: '加入购物车失败');
}
$total_num = $this->model->getTotalNum();
return $this->renderSuccess(['cart_total_num' => $total_num], '加入购物车成功');
}
/**
* 减少购物车商品数量
* @param $goods_id
* @param $goods_sku_id
* @return array
*/
public function sub($goods_id, $goods_sku_id)
{
$this->model->sub($goods_id, $goods_sku_id);
return $this->renderSuccess();
}
/**
* 删除购物车中指定商品
* @param $goods_sku_id (支持字符串ID集)
* @return array
*/
public function delete($goods_sku_id)
{
$this->model->delete($goods_sku_id);
return $this->renderSuccess();
}
}

29
source/application/api/controller/Category.php

@ -1,29 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Category as CategoryModel;
use app\api\model\WxappCategory as WxappCategoryModel;
/**
* 商品分类控制器
* Class Goods
* @package app\api\controller
*/
class Category extends Controller
{
/**
* 分类页面
* @return array
* @throws \think\exception\DbException
*/
public function index()
{
// 分类模板
$templet = WxappCategoryModel::detail();
// 商品分类列表
$list = array_values(CategoryModel::getCacheTree());
return $this->renderSuccess(compact('templet', 'list'));
}
}

29
source/application/api/controller/Comment.php

@ -1,29 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Comment as CommentModel;
/**
* 商品评价控制器
* Class Comment
* @package app\api\controller
*/
class Comment extends Controller
{
/**
* 商品评价列表
* @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'));
}
}

29
source/application/api/controller/Coupon.php

@ -1,29 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Coupon as CouponModel;
/**
* 优惠券中心
* Class Coupon
* @package app\api\controller
*/
class Coupon extends Controller
{
/**
* 优惠券列表
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function lists()
{
$model = new CouponModel;
$list = $model->getList($this->getUser(false));
return $this->renderSuccess(compact('list'));
}
}

74
source/application/api/controller/Goods.php

@ -1,74 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Goods as GoodsModel;
use app\api\model\Cart as CartModel;
use app\common\service\qrcode\Goods as GoodsPoster;
/**
* 商品控制器
* Class Goods
* @package app\api\controller
*/
class Goods extends Controller
{
/**
* 商品列表
* @param $category_id
* @param $search
* @param $sortType
* @param $sortPrice
* @return array
* @throws \think\exception\DbException
*/
public function lists($category_id, $search, $sortType, $sortPrice)
{
$model = new GoodsModel;
$list = $model->getList(10, $category_id, $search, $sortType, $sortPrice);
return $this->renderSuccess(compact('list'));
}
/**
* 获取商品详情
* @param $goods_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
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;
// 购物车商品总数量
$cart_total_num = 0;
if ($user = $this->getUser(false)) {
$cart_total_num = (new CartModel($user))->getGoodsNum();
}
return $this->renderSuccess(compact('detail', 'cart_total_num', 'specData'));
}
/**
* 获取推广二维码
* @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));
return $this->renderSuccess([
'qrcode' => $Qrcode->getImage(),
]);
}
}

135
source/application/api/controller/Order.php

@ -1,135 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Order as OrderModel;
use app\api\model\Cart as CartModel;
use app\common\enum\DeliveryType as DeliveryTypeEnum;
use app\common\enum\order\PayType as PayTypeEnum;
/**
* 订单控制器
* 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 $goods_id 商品id
* @param int $goods_num 购买数量
* @param int $goods_sku_id 商品sku_id
* @param int $delivery 配送方式
* @param int $pay_type 支付方式
* @param int $coupon_id 优惠券id
* @param int $shop_id 自提门店id
* @param string $remark 买家留言
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
* @throws \Exception
*/
public function buyNow(
$goods_id,
$goods_num,
$goods_sku_id,
$delivery = DeliveryTypeEnum::EXPRESS,
$pay_type = PayTypeEnum::WECHAT,
$shop_id = 0,
$coupon_id = null,
$remark = ''
)
{
// 商品结算信息
$model = new OrderModel;
$order = $model->getBuyNow(
$this->user,
$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, $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 string $cart_ids (支持字符串ID集)
* @param int $delivery 配送方式
* @param int $pay_type 支付方式
* @param int $shop_id 自提门店id
* @param int $coupon_id 优惠券id
* @param string $remark 买家留言
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \Exception
*/
public function cart(
$cart_ids,
$delivery = DeliveryTypeEnum::EXPRESS,
$pay_type = PayTypeEnum::WECHAT,
$shop_id = 0,
$coupon_id = null,
$remark = ''
)
{
// 商品结算信息
$Cart = new CartModel($this->user);
$order = $Cart->getList($cart_ids, $delivery, $pay_type, $shop_id);
if (!$this->request->isPost()) {
return $this->renderSuccess($order);
}
// 创建订单
$model = new OrderModel;
if (!$model->createOrder($this->user, $order, $coupon_id, $remark)) {
return $this->renderError($model->getError() ?: '订单创建失败');
}
// 移出购物车中已下单的商品
$Cart->clearAll($cart_ids);
// 构建微信支付请求
$payment = ($pay_type == PayTypeEnum::WECHAT) ? $model->paymentByWechat($this->user) : [];
// 返回状态
return $this->renderSuccess([
'order_id' => $model['order_id'], // 订单id
'pay_type' => $pay_type, // 支付方式
'payment' => $payment // 微信支付参数
]);
}
}

61
source/application/api/controller/Page.php

@ -1,61 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\WxappPage;
/**
* 页面控制器
* Class Index
* @package app\api\controller
*/
class Page extends Controller
{
/**
* 页面数据
* @param null $page_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index($page_id = null)
{
// 页面元素
$data = WxappPage::getPageData($this->getUser(false), $page_id);
return $this->renderSuccess($data);
}
/**
* 首页diy数据 (即将废弃)
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function home()
{
// 页面元素
$data = WxappPage::getPageData($this->getUser(false));
return $this->renderSuccess($data);
}
/**
* 自定义页数据 (即将废弃)
* @param $page_id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function custom($page_id)
{
// 页面元素
$data = WxappPage::getPageData($this->getUser(false), $page_id);
return $this->renderSuccess($data);
}
}

65
source/application/api/controller/Recharge.php

@ -1,65 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Setting as SettingModel;
use app\api\model\recharge\Plan as PlanModel;
use app\api\model\recharge\Order as OrderModel;
use app\api\service\Payment as PaymentService;
use app\common\enum\OrderType as OrderTypeEnum;
/**
* 用户充值管理
* Class Recharge
* @package app\api\controller
*/
class Recharge extends Controller
{
/**
* 充值中心
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
// 用户信息
$userInfo = $this->getUser();
// 充值套餐列表
$planList = (new PlanModel)->getList();
// 充值设置
$setting = SettingModel::getItem('recharge');
return $this->renderSuccess(compact('userInfo', 'planList', 'setting'));
}
/**
* 确认充值
* @param null $planId
* @param int $customMoney
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function submit($planId = null, $customMoney = 0)
{
// 用户信息
$userInfo = $this->getUser();
// 生成充值订单
$model = new OrderModel;
if (!$model->createOrder($userInfo, $planId, $customMoney)) {
return $this->renderError($model->getError() ?: '充值失败');
}
// 构建微信支付
$payment = PaymentService::wechat(
$userInfo,
$model['order_id'],
$model['order_no'],
$model['pay_price'],
OrderTypeEnum::RECHARGE
);
return $this->renderSuccess(compact('payment'));
}
}

41
source/application/api/controller/Shop.php

@ -1,41 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\store\Shop as ShopModel;
/**
* 门店列表
* Class Shop
* @package app\api\controller
*/
class Shop extends Controller
{
/**
* 门店列表
* @param string $longitude
* @param string $latitude
* @return array
* @throws \think\exception\DbException
*/
public function lists($longitude = '', $latitude = '')
{
$model = new ShopModel;
$list = $model->getList(true, $longitude, $latitude);
return $this->renderSuccess(compact('list'));
}
/**
* 门店详情
* @param $shop_id
* @return array
* @throws \think\exception\DbException
*/
public function detail($shop_id)
{
$detail = ShopModel::detail($shop_id);
return $this->renderSuccess(compact('detail'));
}
}

86
source/application/api/controller/Upload.php

@ -1,86 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\UploadFile;
use app\api\model\Setting as SettingModel;
use app\common\library\storage\Driver as StorageDriver;
/**
* 文件库管理
* Class Upload
* @package app\api\controller
*/
class Upload extends Controller
{
private $config;
private $user;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 存储配置信息
$this->config = SettingModel::getItem('storage');
// 验证用户
$this->user = $this->getUser();
}
/**
* 图片上传接口
* @return array
* @throws \think\Exception
*/
public function image()
{
// 实例化存储驱动
$StorageDriver = new StorageDriver($this->config);
// 设置上传文件的信息
$StorageDriver->setUploadFile('iFile');
// 上传图片
if (!$StorageDriver->upload()) {
return json(['code' => 0, 'msg' => '图片上传失败' . $StorageDriver->getError()]);
}
// 图片上传路径
$fileName = $StorageDriver->getFileName();
// 图片信息
$fileInfo = $StorageDriver->getFileInfo();
// 添加文件库记录
$uploadFile = $this->addUploadFile($fileName, $fileInfo, 'image');
// 图片上传成功
return json(['code' => 1, 'msg' => '图片上传成功', 'data' => $uploadFile->visible(['file_id'])]);
}
/**
* 添加文件库上传记录
* @param $fileName
* @param $fileInfo
* @param $fileType
* @return UploadFile
*/
private function addUploadFile($fileName, $fileInfo, $fileType)
{
// 存储引擎
$storage = $this->config['default'];
// 存储域名
$fileUrl = isset($this->config['engine'][$storage]['domain'])
? $this->config['engine'][$storage]['domain'] : '';
// 添加文件库记录
$model = new UploadFile;
$model->add([
'storage' => $storage,
'file_url' => $fileUrl,
'file_name' => $fileName,
'file_size' => $fileInfo['size'],
'file_type' => $fileType,
'extension' => pathinfo($fileInfo['name'], PATHINFO_EXTENSION),
'is_user' => 1
]);
return $model;
}
}

43
source/application/api/controller/User.php

@ -1,43 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\User as UserModel;
/**
* 用户管理
* Class User
* @package app\api
*/
class User extends Controller
{
/**
* 用户自动登录
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function login()
{
$model = new UserModel;
return $this->renderSuccess([
'user_id' => $model->login($this->request->post()),
'token' => $model->getToken()
]);
}
/**
* 当前用户详情
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function detail()
{
// 当前用户信息
$userInfo = $this->getUser();
return $this->renderSuccess(compact('userInfo'));
}
}

39
source/application/api/controller/Wxapp.php

@ -1,39 +0,0 @@
<?php
namespace app\api\controller;
use app\api\model\Wxapp as WxappModel;
use app\api\model\WxappHelp;
/**
* 微信小程序
* Class Wxapp
* @package app\api\controller
*/
class Wxapp extends Controller
{
/**
* 小程序基础信息
* @return array
*/
public function base()
{
// $wxapp = WxappModel::getWxappCache();
return $this->renderSuccess([]);
}
/**
* 帮助中心
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function help()
{
$model = new WxappHelp;
$list = $model->getList();
return $this->renderSuccess(compact('list'));
}
}

28
source/application/api/controller/balance/Log.php

@ -1,28 +0,0 @@
<?php
namespace app\api\controller\balance;
use app\api\controller\Controller;
use app\api\model\user\BalanceLog as BalanceLogModel;
/**
* 余额账单明细
* Class Log
* @package app\api\controller\balance
*/
class Log extends Controller
{
/**
* 余额账单明细列表
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function lists()
{
$user = $this->getUser();
$list = (new BalanceLogModel)->getList($user['user_id']);
return $this->renderSuccess(compact('list'));
}
}

28
source/application/api/controller/library/Pass.php

@ -1,28 +0,0 @@
<?php
namespace app\api\controller\library;
use app\api\controller\Controller;
class Pass extends Controller
{
/**
* 图书管数据接口
* @return array
* 返回数据:today.incount=今天进 month.incount=本月进 year.incount=今年进 day30.incount=近30天近 outcount=出
* 不传参数就是所有摄像头,传cameraid就是按传的摄像头ID
* cameraid = 宝安图书馆9,7,6,4,2,1,67,3 1990分馆134、 135
*/
public function allFlowTrends()
{
$url = 'http://balib.cn:8999/CustCount/baoan/stat.json?key=baoan';
$result = curlPost($url);
$data = json_decode($result,true);
return $this->renderSuccess(compact('data'));
}
}

26
source/application/api/controller/live/Room.php

@ -1,26 +0,0 @@
<?php
namespace app\api\controller\live;
use app\api\controller\Controller;
use app\api\model\wxapp\LiveRoom as LiveRoomModel;
/**
* 微信小程序直播列表
* Class Room
* @package app\api\controller\live
*/
class Room extends Controller
{
/**
* 获取直播间列表
* @return mixed
* @throws \think\exception\DbException
*/
public function lists()
{
$model = new LiveRoomModel;
$list = $model->getList();
return $this->renderSuccess(compact('list'));
}
}

28
source/application/api/controller/recharge/Order.php

@ -1,28 +0,0 @@
<?php
namespace app\api\controller\recharge;
use app\api\controller\Controller;
use app\api\model\recharge\Order as OrderModel;
/**
* 充值记录
* Class Order
* @package app\api\controller\user\balance
*/
class Order extends Controller
{
/**
* 我的充值记录列表
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function lists()
{
$user = $this->getUser();
$list = (new OrderModel)->getList($user['user_id']);
return $this->renderSuccess(compact('list'));
}
}

72
source/application/api/controller/shop/Order.php

@ -1,72 +0,0 @@
<?php
namespace app\api\controller\shop;
use app\api\controller\Controller;
use app\common\service\Order as OrderService;
use app\common\enum\OrderType as OrderTypeEnum;
use app\api\model\store\shop\Clerk as ClerkModel;
/**
* 自提订单管理
* Class Order
* @package app\api\controller\shop
*/
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 $order_id
* @param int $order_type
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function detail($order_id, $order_type = OrderTypeEnum::MASTER)
{
// 订单详情
$order = OrderService::getOrderDetail($order_id, $order_type);
// 验证是否为该门店的核销员
$clerkModel = ClerkModel::detail(['user_id' => $this->user['user_id']]);
return $this->renderSuccess(compact('order', 'clerkModel'));
}
/**
* 确认核销
* @param $order_id
* @param int $order_type
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function extract($order_id, $order_type = OrderTypeEnum::MASTER)
{
// 订单详情
$order = OrderService::getOrderDetail($order_id, $order_type);
// 验证是否为该门店的核销员
$ClerkModel = ClerkModel::detail(['user_id' => $this->user['user_id']]);
if (!$ClerkModel->checkUser($order['extract_shop_id'])) {
return $this->renderError($ClerkModel->getError());
}
// 确认核销
if ($order->extract($ClerkModel['clerk_id'])) {
return $this->renderSuccess([], '订单核销成功');
}
return $this->renderError($order->getError() ?: '核销失败');
}
}

53
source/application/api/controller/user/Comment.php

@ -1,53 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\Order as OrderModel;
use app\api\model\OrderGoods as OrderGoodsModel;
use app\api\model\Comment as CommentModel;
/**
* 订单评价管理
* Class Comment
* @package app\api\controller\user
*/
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()) {
$post = $this->request->post('formData');
if ($model->addForOrder($order, $goodsList, $post)) {
return $this->renderSuccess([], '评价发表成功');
}
return $this->renderError($model->getError() ?: '评价发表失败');
}
return $this->renderSuccess(compact('goodsList'));
}
}

74
source/application/api/controller/user/Coupon.php

@ -1,74 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\UserCoupon as UserCouponModel;
/**
* 用户优惠券
* Class Coupon
* @package app\api\controller
*/
class Coupon extends Controller
{
/* @var UserCouponModel $model */
private $model;
/* @var \app\api\model\User $model */
private $user;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->model = new UserCouponModel;
$this->user = $this->getUser();
}
/**
* 优惠券列表
* @param string $data_type
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function lists($data_type = 'all')
{
$is_use = false;
$is_expire = false;
switch ($data_type) {
case 'not_use':
$is_use = false;
break;
case 'is_use':
$is_use = true;
break;
case 'is_expire':
$is_expire = true;
break;
}
$list = $this->model->getList($this->user['user_id'], $is_use, $is_expire);
return $this->renderSuccess(compact('list'));
}
/**
* 领取优惠券
* @param $coupon_id
* @return array
* @throws \think\exception\DbException
*/
public function receive($coupon_id)
{
if ($this->model->receive($this->user, $coupon_id)) {
return $this->renderSuccess([], '领取成功');
}
return $this->renderError($this->model->getError() ?: '添加失败');
}
}

115
source/application/api/controller/user/Dealer.php

@ -1,115 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\dealer\Apply as DealerApplyModel;
/**
* 分销中心
* Class Dealer
* @package app\api\controller\user
*/
class Dealer extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 分销商中心
* @return array
*/
public function center()
{
return $this->renderSuccess([
// 当前是否为分销商
'is_dealer' => $this->isDealerUser(),
// 当前用户信息
'user' => $this->user,
// 分销商用户信息
'dealer' => $this->dealer,
// 背景图
'background' => $this->setting['background']['values']['index'],
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
/**
* 分销商申请状态
* @param null $referee_id
* @return array
* @throws \think\exception\DbException
*/
public function apply($referee_id = null)
{
// 推荐人昵称
$referee_name = '平台';
if ($referee_id > 0 && ($referee = DealerUserModel::detail($referee_id))) {
$referee_name = $referee['user']['nickName'];
}
return $this->renderSuccess([
// 当前是否为分销商
'is_dealer' => $this->isDealerUser(),
// 当前是否在申请中
'is_applying' => DealerApplyModel::isApplying($this->user['user_id']),
// 推荐人昵称
'referee_name' => $referee_name,
// 背景图
'background' => $this->setting['background']['values']['apply'],
// 页面文字
'words' => $this->setting['words']['values'],
// 申请协议
'license' => $this->setting['license']['values']['license'],
]);
}
/**
* 分销商提现信息
* @return array
*/
public function withdraw()
{
return $this->renderSuccess([
// 分销商用户信息
'dealer' => $this->dealer,
// 结算设置
'settlement' => $this->setting['settlement']['values'],
// 背景图
'background' => $this->setting['background']['values']['withdraw_apply'],
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
/**
* 当前用户是否为分销商
* @return bool
*/
private function isDealerUser()
{
return !!$this->dealer && !$this->dealer['is_delete'];
}
}

41
source/application/api/controller/user/Index.php

@ -1,41 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\Order as OrderModel;
use app\api\model\UserCoupon as UserCouponModel;
/**
* 个人中心主页
* Class Index
* @package app\api\controller\user
*/
class Index extends Controller
{
/**
* 获取当前用户信息
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function detail()
{
// 当前用户信息
$user = $this->getUser();
// 订单总数
$model = new OrderModel;
return $this->renderSuccess([
'userInfo' => $user,
'orderCount' => [
'payment' => $model->getCount($user['user_id'], 'payment'),
'received' => $model->getCount($user['user_id'], 'received'),
'comment' => $model->getCount($user['user_id'], 'comment'),
],
'couponCount'=> (new UserCouponModel)->getCount($user['user_id']),
'menus' => $user->getMenus() // 个人中心菜单列表
]);
}
}

177
source/application/api/controller/user/Order.php

@ -1,177 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\Order as OrderModel;
use app\common\service\qrcode\Extract as ExtractQRcode;
use app\common\enum\OrderType as OrderTypeEnum;
use app\common\enum\order\PayType as PayTypeEnum;
/**
* 用户订单管理
* Class Order
* @package app\api\controller\user
*/
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 $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
* @throws \think\exception\DbException
*/
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
* @throws \think\exception\DbException
*/
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 \Exception
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
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::MASTER
);
return $this->renderSuccess([
'qrcode' => $Qrcode->getImage(),
]);
}
}

109
source/application/api/controller/user/Refund.php

@ -1,109 +0,0 @@
<?php
namespace app\api\controller\user;
use app\api\controller\Controller;
use app\api\model\Express as ExpressModel;
use app\api\model\OrderGoods as OrderGoodsModel;
use app\api\model\OrderRefund as OrderRefundModel;
/**
* 订单售后服务
* Class service
* @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() ?: '提交失败');
}
}

45
source/application/api/controller/user/dealer/Apply.php

@ -1,45 +0,0 @@
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Apply as DealerApplyModel;
/**
* 分销商申请
* Class Apply
* @package app\api\controller\user\dealer
*/
class Apply 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 string $name
* @param string $mobile
* @return array
* @throws \think\exception\DbException
*/
public function submit($name = '', $mobile = '')
{
$model = new DealerApplyModel;
if ($model->submit($this->user, $name, $mobile)) {
return $this->renderSuccess();
}
return $this->renderError($model->getError() ?: '提交失败');
}
}

56
source/application/api/controller/user/dealer/Order.php

@ -1,56 +0,0 @@
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\dealer\Order as OrderModel;
/**
* 分销商订单
* Class Order
* @package app\api\controller\user\dealer
*/
class Order extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 分销商订单列表
* @param int $settled
* @return array
* @throws \think\exception\DbException
*/
public function lists($settled = -1)
{
$model = new OrderModel;
return $this->renderSuccess([
// 提现明细列表
'list' => $model->getList($this->user['user_id'], (int)$settled),
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
}

57
source/application/api/controller/user/dealer/Qrcode.php

@ -1,57 +0,0 @@
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\common\service\qrcode\Poster;
/**
* 推广二维码
* Class Order
* @package app\api\controller\user\dealer
*/
class Qrcode extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 获取推广二维码
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
* @throws \Exception
*/
public function poster()
{
$Qrcode = new Poster($this->dealer);
return $this->renderSuccess([
// 二维码图片地址
'qrcode' => $Qrcode->getImage(),
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
}

60
source/application/api/controller/user/dealer/Team.php

@ -1,60 +0,0 @@
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\dealer\Referee as RefereeModel;
/**
* 我的团队
* Class Order
* @package app\api\controller\user\dealer
*/
class Team extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 我的团队列表
* @param int $level
* @return array
* @throws \think\exception\DbException
*/
public function lists($level = -1)
{
$model = new RefereeModel;
return $this->renderSuccess([
// 分销商用户信息
'dealer' => $this->dealer,
// 我的团队列表
'list' => $model->getList($this->user['user_id'], (int)$level),
// 基础设置
'setting' => $this->setting['basic']['values'],
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
}

72
source/application/api/controller/user/dealer/Withdraw.php

@ -1,72 +0,0 @@
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\dealer\Withdraw as WithdrawModel;
/**
* 分销商提现
* Class Withdraw
* @package app\api\controller\user\dealer
*/
class Withdraw extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 提交提现申请
* @param $data
* @return array
* @throws \app\common\exception\BaseException
*/
public function submit($data)
{
$formData = json_decode(htmlspecialchars_decode($data), true);
$model = new WithdrawModel;
if ($model->submit($this->dealer, $formData)) {
return $this->renderSuccess([], '提现申请已提交成功,请等待审核');
}
return $this->renderError($model->getError() ?: '提交失败');
}
/**
* 分销商提现明细
* @param int $status
* @return array
* @throws \think\exception\DbException
*/
public function lists($status = -1)
{
$model = new WithdrawModel;
return $this->renderSuccess([
// 提现明细列表
'list' => $model->getList($this->user['user_id'], (int)$status),
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
}

25
source/application/api/controller/wxapp/Formid.php

@ -1,25 +0,0 @@
<?php
namespace app\api\controller\wxapp;
use app\api\controller\Controller;
/**
* form_id 管理 (已废弃)
* Class Formid
* @package app\api\controller\wxapp
*/
class Formid extends Controller
{
/**
* 新增form_id
* (因微信模板消息已下线,所以formId取消不再收集)
* @param $formId
* @return array
*/
public function save($formId)
{
return $this->renderSuccess();
}
}

25
source/application/api/controller/wxapp/Submsg.php

@ -1,25 +0,0 @@
<?php
namespace app\api\controller\wxapp;
use app\api\controller\Controller;
use app\api\model\Setting as SettingModel;
/**
* 微信小程序订阅消息
* Class Submsg
* @package app\api\controller\wxapp
*/
class Submsg extends Controller
{
/**
* 获取订阅消息配置
* @return array
*/
public function setting()
{
$setting = SettingModel::getSubmsg();
return $this->renderSuccess(compact('setting'));
}
}
Loading…
Cancel
Save