diff --git a/app/api/controller/Order.php b/app/api/controller/Order.php index 49a22b89..856b8921 100644 --- a/app/api/controller/Order.php +++ b/app/api/controller/Order.php @@ -12,6 +12,9 @@ declare (strict_types=1); namespace app\api\controller; +use app\api\model\RecoveryOrder; +use app\common\enum\OrderType; +use app\common\enum\user\UserTypeEnum; use think\response\Json; use app\api\model\Order as OrderModel; use app\api\model\Setting as SettingModel; @@ -41,10 +44,7 @@ class Order extends Controller { $model = new OrderModel; $list = $model->getList($dataType); -// return $this->renderSuccess(compact('list')); - $list = $this->renderSuccess(compact('list')); - - return $list; + return $this->renderSuccess(compact('list')); } public function del() @@ -110,7 +110,7 @@ class Order extends Controller $transferRecordService = new TransferRecord(); $data = $transferRecordService->getExpressByExpressNo($expressNo); $express = []; - if ($data['traces']) { + if (!empty($data['traces'])) { $express['items'] = $data['traces']; $express['express_name'] = $data['express']['express_name']; $express['express_no'] = $data['express_no']; @@ -171,17 +171,17 @@ class Order extends Controller */ public function actionCounts(): Json { -// $model = new OrderModel; -// $counts = $model->getTodoCounts(); + $model = new OrderModel; + $counts = $model->getActionCounts(); $data = [ - 'reservation_number' => 1,//预约记录 - 'view_number' => 2,//浏览记录 - 'send_number' => 0,//发货数量 - 'integral_number' => 0,//积分数量 - 'coupon_number' => 0,//优惠券 - 'goods_collect_number' => 0,//收藏商品数量 - 'cart_number' => 0,//购物车数量 - 'take_goods_number' => 1,//发货记录&提货记录 + 'reservation_number' => $counts['reservation_number'],//预约记录 + 'view_number' => $counts['view_number'],//浏览记录 + 'send_number' => $counts['send_number'],//发货数量 + 'integral_number' => $counts['integral_number'],//积分数量 + 'coupon_number' => $counts['coupon_number'],//优惠券 + 'goods_collect_number' => $counts['goods_collect_number'],//收藏商品数量 + 'cart_number' => $counts['cart_number'],//购物车数量 + 'take_goods_number' => $counts['take_goods_number'],//发货记录&提货记录 ]; return $this->renderSuccess($data); } @@ -192,27 +192,30 @@ class Order extends Controller */ public function todoCounts(): Json { - // $model = new OrderModel; - // $counts = $model->getTodoCounts(); + $model = new OrderModel; + $goods_counts = $model->getTodoCounts(OrderType::ORDER); + $service_counts = $model->getTodoCounts(OrderType::SERVER); + $dealer_counts = $model->getTodoCounts(OrderType::DEALER); +// var_dump($dealer_counts); $data = [ 'goods_order' => [ - 'payment_number' => 0,//待付款 - 'delivery_number' => 0,//待发货 - 'received_number' => 0,//待收货 - 'finish_number' => 0,//已完成 + 'payment_number' => $goods_counts['payment_number'],//待付款 + 'delivery_number' => $goods_counts['delivery_number'],//待发货 + 'received_number' => $goods_counts['received_number'],//待收货 + 'finish_number' => $goods_counts['finish_number'],//已完成 ], 'service_order' => [ - 'confirm_number' => 0,//待确认 - 'service_number' => 0,//待服务 - 'payment_number' => 0,//待支付 - 'check_number' => 0,//已完成 + 'confirm_number' => $service_counts['confirm_number'],//待确认 + 'service_number' => $service_counts['service_number'],//待服务 + 'payment_number' => $service_counts['payment_number'],//待支付 + 'check_number' => $service_counts['check_number'],//已完成 ], 'distribution_order' => [//分销订单 - 'payment_number' => 0,//待付款 - 'delivery_number' => 0,//待发货 - 'received_number' => 0,//待收货 - 'finish_number' => 0,//已完成 - 'retund_number' => 0,//退款中 + 'payment_number' => $dealer_counts['payment_number'],//待付款 + 'delivery_number' => $dealer_counts['delivery_number'],//待发货 + 'received_number' => $dealer_counts['received_number'],//待收货 + 'finish_number' => $dealer_counts['finish_number'],//已完成 + 'retund_number' => $dealer_counts['refund_number'],//退款中 ], ]; return $this->renderSuccess($data); diff --git a/app/api/controller/StoreKeeper.php b/app/api/controller/StoreKeeper.php index 6903219e..9cdcebfe 100644 --- a/app/api/controller/StoreKeeper.php +++ b/app/api/controller/StoreKeeper.php @@ -42,11 +42,11 @@ class StoreKeeper extends Controller public function __construct(App $app) { parent::__construct($app); - $res = UserService::isStore(); - if ($res === false) { - print_r(json_encode(['code' => config('status.error'), 'msg' => '无权操作'])); - exit; - } +// $res = UserService::isStore(); +// if ($res === false) { +// print_r(json_encode(['code' => config('status.error'), 'msg' => '无权操作'])); +// exit; +// } } /** diff --git a/app/api/controller/User.php b/app/api/controller/User.php index a9f42bda..05a47b30 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -17,6 +17,7 @@ use app\api\model\user\BalanceLog; use app\api\model\user\GoodSource as GoodsSourceModel; use app\api\model\user\InvoiceOrder; use app\api\model\user\UserInvoice; +use app\api\model\user\UserCoupon; use app\api\model\UserCoupon as UserCouponModel; use app\api\model\Agreement as AgreementModel; use app\api\service\Feedback; @@ -280,4 +281,17 @@ class User extends Controller return $this->renderSuccess(compact('detail'), 'success'); } + /** + * 添加用户浏览记录 + */ + public function addView(): Json { + $goods_id = $this->request->param('goods_id'); + $user_id = UserService::getCurrentLoginUserId(); + $userView = new UserCoupon(); + if ($userView->add(['user_id' => $user_id, 'goods_id' => $goods_id, 'store_id' => $this->storeId])) { + return $this->renderSuccess('记录成功'); + } + return $this->renderSuccess($userView->getError() ?: '记录失败'); + } + } diff --git a/app/api/model/Cart.php b/app/api/model/Cart.php index 88ac8e2d..a9a95e98 100644 --- a/app/api/model/Cart.php +++ b/app/api/model/Cart.php @@ -178,4 +178,12 @@ class Cart extends CartModel ->where('is_delete', '=', 0) ->sum('goods_num'); } + + public static function getCount() { + if (!UserService::isLogin()) return 0; + $userId = UserService::getCurrentLoginUserId(); + return self::where('user_id', '=', $userId) + ->where('is_delete', '=', 0) + ->sum('goods_num'); + } } diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 74959ddf..55e9a962 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -204,13 +204,14 @@ class Goods extends GoodsModel } - public function browseDel() + public function browseDel($param) { $userId = UserService::getCurrentLoginUserId(true); + $ids = $param['ids']; $info = GoodsBrowseLog::where([ 'store_id' => request()->header()['storeid'], 'user_id' => $userId, - ])->whereIn('id', $_POST['ids'])->delete(); + ])->whereIn('id', $ids)->delete(); return $info; } diff --git a/app/api/model/GoodsBrowseLog.php b/app/api/model/GoodsBrowseLog.php index 76f1e6b7..85899fa0 100644 --- a/app/api/model/GoodsBrowseLog.php +++ b/app/api/model/GoodsBrowseLog.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\api\model; +use app\api\service\User as UserService; use app\common\model\GoodsSpecRel as GoodsSpecRelModel; use think\model\relation\HasMany; use think\model\relation\HasOne; @@ -46,4 +47,13 @@ class GoodsBrowseLog extends GoodsSpecRelModel return $this->hasMany(GoodsImage::class, 'goods_id', 'goods_id')->order(['id']); } + public static function getCount(): int + { + // 当前用户ID + $userId = UserService::getCurrentLoginUserId(); + // 查询数据 + return self::where('user_id', '=', $userId) + ->count(); + } + } diff --git a/app/api/model/Order.php b/app/api/model/Order.php index f87d8e7f..7c607d6e 100644 --- a/app/api/model/Order.php +++ b/app/api/model/Order.php @@ -12,18 +12,19 @@ declare (strict_types=1); namespace app\api\model; -use app\api\model\{Goods as GoodsModel, OrderRefund as OrderRefundModel, Setting as SettingModel}; +use app\common\model\TransferRecord; +use app\api\model\{Goods as GoodsModel, OrderRefund as OrderRefundModel, Setting as SettingModel, user\UserCoupon}; use app\api\service\{User as UserService, order\source\Factory as OrderSourceFactory}; use app\common\model\Order as OrderModel; use app\common\service\{Order as OrderService, order\Complete as OrderCompleteService}; -use app\common\enum\{ +use app\common\enum\{OrderType, Setting as SettingEnum, order\PayStatus as PayStatusEnum, order\OrderStatus as OrderStatusEnum, order\DeliveryType as DeliveryTypeEnum, order\ReceiptStatus as ReceiptStatusEnum, - order\DeliveryStatus as DeliveryStatusEnum -}; + order\DeliveryStatus as DeliveryStatusEnum, + user\UserTypeEnum}; use app\api\service\Store as StoreService; use app\common\library\helper; use cores\exception\BaseException; @@ -109,25 +110,19 @@ class Order extends OrderModel */ public function getList(string $dataType = 'all') { - + $keyword = $_GET['keyword']; // 设置订单类型条件 $dataTypeFilter = $this->getFilterDataType($dataType); // 当前用户ID $userId = UserService::getCurrentLoginUserId(); - $query = $this->with(['goods.image']) - ->where($dataTypeFilter) + $query = $this->with(['goods.image']); + if (!empty($keyword) && $keyword !== 'undefined') { + $query->where('order_no', 'like', "%{$keyword}%"); + } + $query->where($dataTypeFilter) ->where('user_id', '=', $userId) ->where('is_delete', '=', 0) ->order(['create_time' => 'desc']); - if (!empty($_GET['keyword'])) { - $query = $this->with(['goods.image']) - ->join('order_goods b', 'b.order_id = a.order_id') - ->where($dataTypeFilter) - ->where('a.user_id', '=', $userId) - ->where('b.goods_name', '=', $_GET['keyword']) - ->where('a.is_delete', '=', 0) - ->order(['a.create_time' => 'desc']); - } $list = $query->paginate(15)->toArray(); //这边后面改成多商户的话需要根据storeid去获取信息 @@ -222,20 +217,22 @@ class Order extends OrderModel * @return int * @throws BaseException */ - public function getCount(string $dataType = 'all'): int + public function getCount(string $dataType = 'all', $dealer_order_ids = []): int { // 设置订单类型条件 $dataTypeFilter = $this->getFilterDataType($dataType); // 当前用户ID $userId = UserService::getCurrentLoginUserId(); // 查询数据 - return $this->where('user_id', '=', $userId) - ->where('order_status', '<>', 20) + $query = $this->where('user_id', '=', $userId); + if ($dealer_order_ids) { + $query->whereIn('order_id', $dealer_order_ids); + } + return $query->where('order_status', '<>', 20) ->where($dataTypeFilter) ->where('is_delete', '=', 0) ->count(); } - /** * 设置订单类型条件 * @param string $dataType @@ -257,7 +254,7 @@ class Order extends OrderModel case 'pay': $filter[] = ['pay_status', '=', PayStatusEnum::PENDING]; $filter[] = ['order_status', '=', OrderStatusEnum::NORMAL]; - break; + break; //待发货 case 'delivery': $filter = [ @@ -265,7 +262,7 @@ class Order extends OrderModel ['delivery_status', '<>', DeliveryStatusEnum::DELIVERED], ['order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]] ]; - break; + break; //待收货 case 'receipt': $filter = [ @@ -274,8 +271,8 @@ class Order extends OrderModel ['receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED], ['order_status', '=', OrderStatusEnum::NORMAL] ]; - break; - //待收货 + break; + //待收货 case 'received': $filter = [ ['pay_status', '=', PayStatusEnum::SUCCESS], @@ -302,7 +299,7 @@ class Order extends OrderModel ['order_status', '=', OrderStatusEnum::CANCELLED] ]; break; - //已评价 + //已评价 case 'comment': $filter = [ ['is_comment', '=', 0], @@ -313,6 +310,83 @@ class Order extends OrderModel return $filter; } + /** + * 设置订单类型条件(list查询用) + * @param string $dataType + * @return array + */ + private function getFilterDataTypeList(string $dataType): array + { + // 筛选条件 + $filter = []; + // 订单数据类型 + switch ($dataType) { + case 'all': + break; + case 'payment': + $filter[] = ['a.pay_status', '=', PayStatusEnum::PENDING]; + $filter[] = ['a.order_status', '=', OrderStatusEnum::NORMAL]; + break; + //待付款 + case 'pay': + $filter[] = ['a.pay_status', '=', PayStatusEnum::PENDING]; + $filter[] = ['a.order_status', '=', OrderStatusEnum::NORMAL]; + break; + //待发货 + case 'delivery': + $filter = [ + ['a.pay_status', '=', PayStatusEnum::SUCCESS], + ['a.delivery_status', '<>', DeliveryStatusEnum::DELIVERED], + ['a.order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]] + ]; + break; + //待收货 + case 'receipt': + $filter = [ + ['a.pay_status', '=', PayStatusEnum::SUCCESS], + ['a.delivery_status', '=', DeliveryStatusEnum::DELIVERED], + ['a.receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED], + ['a.order_status', '=', OrderStatusEnum::NORMAL] + ]; + break; + //待收货 + case 'received': + $filter = [ + ['a.pay_status', '=', PayStatusEnum::SUCCESS], + ['a.delivery_status', '=', DeliveryStatusEnum::DELIVERED], + ['a.receipt_status', '=', ReceiptStatusEnum::NOT_RECEIVED], + ['a.order_status', '=', OrderStatusEnum::NORMAL] + ]; + break; + //已完成 + case 'complete': + $filter = [ + ['a.order_status', '=', OrderStatusEnum::COMPLETED] + ]; + break; + //待取消 + case 'apply_cancel': + $filter = [ + ['a.order_status', '=', OrderStatusEnum::APPLY_CANCEL] + ]; + break; + //已取消 + case 'cancel': + $filter = [ + ['a.order_status', '=', OrderStatusEnum::CANCELLED] + ]; + break; + //已评价 + case 'comment': + $filter = [ + ['a.is_comment', '=', 0], + ['a.order_status', '=', OrderStatusEnum::COMPLETED] + ]; + break; + } + return $filter; + } + /** * 获取用户订单详情(含关联数据) * @param int $orderId 订单ID @@ -420,14 +494,35 @@ class Order extends OrderModel * @return array * @throws BaseException */ - public function getTodoCounts(): array + public function getTodoCounts($user_type): array { - return [ - 'payment' => $this->getCount('payment'), // 待付款的订单 - 'delivery' => $this->getCount('delivery'), // 待发货的订单 - 'received' => $this->getCount('received'), // 待收货的订单 - 'refund' => OrderRefundModel::getCountByUnderway(), // 进行中的售后单 - ]; + if ($user_type == OrderType::ORDER) {//商城 + return [ + 'payment_number' => $this->getCount('payment'), // 待付款的订单 + 'delivery_number' => $this->getCount('delivery'), // 待发货的订单 + 'received_number' => $this->getCount('received'), // 待收货的订单 + 'finish_number' => $this->getCount('complete'), // 已完成 + ]; + } elseif($user_type == OrderType::SERVER) {//服务 + $model = new Server\ServerOrder(); + return [ + 'confirm_number' => $model->getCount('confirm'), // 待确认的订单 + 'service_number' => $model->getCount('service'), // 待发货的订单 + 'payment_number' => $model->getCount('payment'), // 待收货的订单 + 'check_number' => $model->getCount('complete'), // 已完成的订单 + ]; + } elseif($user_type == OrderType::DEALER) {//分销 + $model = new dealer\Order(); + $dealer_order_ids = $model->where('user_id', UserService::getCurrentLoginUserId())->column('order_id'); + return [ + 'payment_number' => $this->getCount('payment', $dealer_order_ids), // 待付款的订单 + 'delivery_number' => $this->getCount('delivery', $dealer_order_ids), // 待发货的订单 + 'received_number' => $this->getCount('received', $dealer_order_ids), // 待收货的订单 + 'finish_number' => $this->getCount('complete', $dealer_order_ids), // 已完成的订单 + 'refund_number' => OrderRefundModel::getCountByUnderway($dealer_order_ids), // 进行中的售后单 + ]; + } + return []; } // 返回提示信息 @@ -476,4 +571,23 @@ class Order extends OrderModel { return static::updateOne(['order_source_id' => $soureId], $orderId); } + + /** + * 获取当前用户行为数量 + * @return array + * @throws BaseException + */ + public function getActionCounts(): array + { + return [ + 'reservation_number' => RecoveryOrder::getCount(), // 上门预约待服务订单总数 + 'view_number' => GoodsBrowseLog::getCount(), // 浏览记录 + 'send_number' => TransferRecord::getCount(), // 发货数量 + 'integral_number' => User::get(UserService::getCurrentLoginUserId())->points, // 积分数量 + 'coupon_number' => UserCoupon::getCount(), // 优惠券 + 'goods_collect_number' => 0, // 商品采集数量 + 'cart_number' => Cart::getCount(), // 购物车数量 + 'take_goods_number' => 0, // 发货记录&提货记录 + ]; + } } diff --git a/app/api/model/OrderRefund.php b/app/api/model/OrderRefund.php index ae21a059..566f85d1 100644 --- a/app/api/model/OrderRefund.php +++ b/app/api/model/OrderRefund.php @@ -14,6 +14,7 @@ namespace app\api\model; use app\api\service\User as UserService; use app\api\model\OrderGoods as OrderGoodsModel; +use app\common\enum\order\PayStatus; use app\common\model\OrderRefund as OrderRefundModel; use app\common\enum\order\refund\RefundType as RefundTypeEnum; use app\common\enum\order\refund\AuditStatus as AuditStatusEnum; @@ -126,11 +127,14 @@ class OrderRefund extends OrderRefundModel * @return int * @throws BaseException */ - public static function getCountByUnderway(): int + public static function getCountByUnderway($dealer_order_ids = []): int { $userId = UserService::getCurrentLoginUserId(); - return (new static)->where('user_id', '=', $userId) - ->where('status', '=', 0) + $query = (new static)->where('user_id', '=', $userId); + if ($dealer_order_ids) { + $query->whereIn('order_id', $dealer_order_ids); + } + return $query->where('status', '=', 0) ->count(); } diff --git a/app/api/model/RecoveryOrder.php b/app/api/model/RecoveryOrder.php index a1591d63..5fda5b6d 100644 --- a/app/api/model/RecoveryOrder.php +++ b/app/api/model/RecoveryOrder.php @@ -131,14 +131,13 @@ class RecoveryOrder extends BaseRecoveryOrder * 获取回收单记录 * @return int */ - public static function getCount() { + public static function getCount(): int { // 当前用户ID $userId = UserService::getCurrentLoginUserId(); // 查询数据 return self::where('user_id', '=', $userId) - ->where('order_status', '<>', 20) - ->where('is_delete', '=', 0) + ->where('order_status', '=', 10) ->count(); } } \ No newline at end of file diff --git a/app/api/model/Server/ServerOrder.php b/app/api/model/Server/ServerOrder.php index f7dd4c69..07e1b9ae 100644 --- a/app/api/model/Server/ServerOrder.php +++ b/app/api/model/Server/ServerOrder.php @@ -5,6 +5,7 @@ namespace app\api\model\Server; use app\api\model\Setting as SettingModel; use app\api\service\User as UserService; use app\common\enum\order\PayStatus; +use app\common\enum\order\PayStatus as PayStatusEnum; use app\common\enum\ServerEnum; use app\common\model\server\Order; use cores\exception\BaseException; @@ -203,4 +204,63 @@ class ServerOrder extends Order ]; } + /** + * 获取当前用户服务订单数量 + * @param string $dataType 订单类型 (all全部 confirm待确认 service待服务 payment待支付 complete 已完成) + * @return int + * @throws BaseException + */ + public function getCount(string $dataType = 'all'): int + { + // 设置订单类型条件 + $dataTypeFilter = $this->getFilterDataType($dataType); + // 当前用户ID + $userId = UserService::getCurrentLoginUserId(); + // 查询数据 + return $this->where('user_id', '=', $userId) + ->where($dataTypeFilter) + ->where('is_delete', '=', 0) + ->count(); + } + + /** + * 设置订单类型条件 + * @param string $dataType + * @return array + */ + private function getFilterDataType(string $dataType): array + { + // 筛选条件 + $filter = []; + // 订单数据类型 + switch ($dataType) { + case 'all': + break; + //待确认 + case 'confirm': + $filter[] = ['pay_status', '=', PayStatusEnum::SUCCESS]; + $filter[] = ['order_status', '=', ServerEnum::APPLYDISPATCH]; + break; + //待服务 + case 'service': + $filter[] = ['pay_status', '=', PayStatusEnum::SUCCESS]; + $filter[] = ['order_status', '=', ServerEnum::APPLYSERVER]; + break; + //待支付 + case 'payment': + $filter = [ + ['pay_status', '=', PayStatusEnum::PENDING], + ['order_status', '=', ServerEnum::APPLYPAY] + ]; + break; + //已完成 + case 'complete': + $filter = [ + ['order_status', '=', ServerEnum::COMPLETED] + ]; + break; + } + return $filter; + } + } \ No newline at end of file diff --git a/app/api/model/dealer/Order.php b/app/api/model/dealer/Order.php index 775b7870..5b9fc686 100644 --- a/app/api/model/dealer/Order.php +++ b/app/api/model/dealer/Order.php @@ -13,8 +13,12 @@ declare (strict_types=1); namespace app\api\model\dealer; use app\api\service\User as UserService; +use app\common\enum\dealer\DealerUserEnum; +use app\common\enum\order\PayStatus as PayStatusEnum; +use app\common\enum\ServerEnum; use app\common\model\Order as OrderModel; use app\common\model\dealer\Order as DealerOrderModel; +use cores\exception\BaseException; /** * 分销商订单模型 @@ -150,4 +154,66 @@ class Order extends DealerOrderModel } return $dealerUser; } + + /** + * 获取当前用户分销订单数量 + * @param string $dataType 订单类型 (all全部 payment待发货 service待服务 payment待支付 complete 已完成) + * @return int + * @throws BaseException + */ + public function getCount(string $dataType = 'all', $dealer_order_ids = []): int + { + // 设置订单类型条件 + $dataTypeFilter = $this->getFilterDataType($dataType); + // 当前用户ID + $userId = UserService::getCurrentLoginUserId(); + // 查询数据 + $query = $this->where('user_id', '=', $userId); + if ($dealer_order_ids) { + $query->whereIn('order_id', $dealer_order_ids); + } + return $query->where($dataTypeFilter) + ->where('is_delete', '=', 0) + ->count(); + } + + /** + * 设置订单类型条件 + * @param string $dataType + * @return array + */ + private function getFilterDataType(string $dataType): array + { + // 筛选条件 + $filter = []; + // 订单数据类型 + switch ($dataType) { + case 'all': + break; + //待确认 + case 'confirm': + $filter[] = ['pay_status', '=', PayStatusEnum::SUCCESS]; + $filter[] = ['order_status', '=', DealerUserEnum::NORMAL]; + break; + //待服务 + case 'service': + $filter[] = ['pay_status', '=', PayStatusEnum::SUCCESS]; + $filter[] = ['order_status', '=', ServerEnum::APPLYSERVER]; + break; + //待支付 + case 'payment': + $filter = [ + ['pay_status', '=', PayStatusEnum::PENDING], + ['order_status', '=', ServerEnum::APPLYPAY] + ]; + break; + //已完成 + case 'complete': + $filter = [ + ['order_status', '=', ServerEnum::COMPLETED] + ]; + break; + } + return $filter; + } } diff --git a/app/api/model/user/UserCoupon.php b/app/api/model/user/UserCoupon.php new file mode 100644 index 00000000..8c550ed8 --- /dev/null +++ b/app/api/model/user/UserCoupon.php @@ -0,0 +1,29 @@ +where('is_use', '=', 0) + ->where('is_expire', '=', 0) + ->count(); + } +} \ No newline at end of file diff --git a/app/common/model/TransferRecord.php b/app/common/model/TransferRecord.php index 445a2ce5..b1cafe7b 100644 --- a/app/common/model/TransferRecord.php +++ b/app/common/model/TransferRecord.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\common\model; +use app\api\service\User as UserService; use cores\BaseModel; use think\model\relation\BelongsTo; @@ -36,6 +37,13 @@ class TransferRecord extends BaseModel ->find(); } + public static function getCount() { + $userId = UserService::getCurrentLoginUserId(); + return self::where('user_id', '=', $userId) + ->where('status', '=', 1) + ->count(); + } + /** * 关联物流公司记录 * @return BelongsTo diff --git a/app/store/model/Order.php b/app/store/model/Order.php index e228cb9b..e15a481d 100644 --- a/app/store/model/Order.php +++ b/app/store/model/Order.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\store\model; +use app\api\service\User as UserService; use app\common\model\Order as OrderModel; use app\common\service\Order as OrderService; use app\common\service\order\Refund as RefundService; @@ -61,6 +62,10 @@ class Order extends OrderModel { // 检索查询条件 $filter = $this->getQueryFilter($param); + //不是店长查询当前用户订单 + if(!UserService::isStore()) { + $filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ]; + } $filterOr = []; if (!empty($param['searchValue']) && $param['searchType'] == 'all') { $filterOr = [ diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index c43c714f..4b00c60d 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\store\model; +use app\api\service\User as UserService; use app\store\model\User as UserModel; use app\common\model\OrderRefund as OrderRefundModel; use app\common\enum\order\refund\RefundType as RefundTypeEnum; @@ -36,6 +37,10 @@ class OrderRefund extends OrderRefundModel { // 检索查询条件 $filter = $this->getFilter($param); + //不是店长查询当前用户订单 + if(!UserService::isStore()) { + $filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ]; + } $filterOr = []; if (!empty($param['searchValue']) && $param['searchType'] == 'all') { $filterOr = [