lqmac 9 months ago
commit 9796022bcc
  1. 7
      app/api/controller/Goods.php
  2. 8
      app/api/model/Cart.php
  3. 5
      app/api/model/Order.php
  4. 20
      app/store/model/Order.php
  5. 13
      app/store/model/OrderRefund.php
  6. 9
      app/store/service/order/Delivery.php

@ -16,6 +16,7 @@ use app\api\model\{Goods as GoodsModel};
use app\api\service\{Goods as GoodsService, User as UserService}; use app\api\service\{Goods as GoodsService, User as UserService};
use app\common\service\qrcode\Goods as GoodsPoster; use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\facade\Cache;
use think\response\Json; use think\response\Json;
/** /**
@ -187,7 +188,13 @@ class Goods extends Controller
public function recommended(): Json public function recommended(): Json
{ {
$service = new GoodsService; $service = new GoodsService;
$cache_key = "goods_recommended".$this->storeId;
if(Cache::has($cache_key)) {
$goodsList = Cache::get($cache_key);
return $this->renderSuccess(compact('goodsList'));
}
$goodsList = $service->recommended(); $goodsList = $service->recommended();
Cache::set($cache_key, $goodsList, 60*60);
return $this->renderSuccess(compact('goodsList')); return $this->renderSuccess(compact('goodsList'));
} }

@ -178,4 +178,12 @@ class Cart extends CartModel
->where('is_delete', '=', 0) ->where('is_delete', '=', 0)
->sum('goods_num'); ->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');
}
} }

@ -497,6 +497,7 @@ class Order extends OrderModel
*/ */
public function getTodoCounts($user_type): array public function getTodoCounts($user_type): array
{ {
if ($user_type == OrderType::ORDER) {//商城 if ($user_type == OrderType::ORDER) {//商城
return [ return [
'payment_number' => $this->getCount('payment'), // 待付款的订单 'payment_number' => $this->getCount('payment'), // 待付款的订单
@ -580,11 +581,13 @@ class Order extends OrderModel
*/ */
public function getActionCounts(): array public function getActionCounts(): array
{ {
$userId = UserService::getCurrentLoginUserId();
return [ return [
'reservation_number' => RecoveryOrder::getCount(), // 上门预约待服务订单总数 'reservation_number' => RecoveryOrder::getCount(), // 上门预约待服务订单总数
'view_number' => GoodsBrowseLog::getCount(), // 浏览记录 'view_number' => GoodsBrowseLog::getCount(), // 浏览记录
'send_number' => TransferRecord::getCount(), // 发货数量 'send_number' => TransferRecord::getCount(), // 发货数量
'integral_number' => User::get(UserService::getCurrentLoginUserId())->points, // 积分数量 'integral_number' => User::get($userId)->points, // 积分数量
'coupon_number' => UserCoupon::getCount(), // 优惠券 'coupon_number' => UserCoupon::getCount(), // 优惠券
'goods_collect_number' => 0, // 商品采集数量 'goods_collect_number' => 0, // 商品采集数量
'cart_number' => Cart::getCount(), // 购物车数量 'cart_number' => Cart::getCount(), // 购物车数量

@ -68,11 +68,14 @@ class Order extends OrderModel
} }
$filterOr = []; $filterOr = [];
if (!empty($param['searchValue']) && $param['searchType'] == 'all') { if (!empty($param['searchValue']) && $param['searchType'] == 'all') {
// $filterOr = [
// ['order.order_no', 'like', "%{$param['searchValue']}%"],
// ['user.nick_name', 'like', "%{$param['searchValue']}%"],
// ['address.name', 'like', "%{$param['searchValue']}%"],
// ['address.phone', 'like', "%{$param['searchValue']}%"],
// ];
$filterOr = [ $filterOr = [
['order.order_no', 'like', "%{$param['searchValue']}%"], ['order.order_no|user.nick_name|address.name|address.phone', 'like', "%{$param['searchValue']}%"]
['user.nick_name', 'like', "%{$param['searchValue']}%"],
['address.name', 'like', "%{$param['searchValue']}%"],
['address.phone', 'like', "%{$param['searchValue']}%"],
]; ];
} }
@ -88,7 +91,8 @@ class Order extends OrderModel
->where($filter) ->where($filter)
->where('order.is_delete', '=', 0); ->where('order.is_delete', '=', 0);
if (!empty($filterOr)) { if (!empty($filterOr)) {
$query = $query->whereOr($filterOr); // $query = $query->whereOr($filterOr);
$query = $query->where($filterOr);
} }
$list = $query->order(['order.create_time' => 'desc']) $list = $query->order(['order.create_time' => 'desc'])
->paginate(10); ->paginate(10);
@ -191,7 +195,8 @@ class Order extends OrderModel
$filter = [ $filter = [
['pay_status', '=', PayStatusEnum::SUCCESS], ['pay_status', '=', PayStatusEnum::SUCCESS],
['delivery_status', '<>', DeliveryStatusEnum::DELIVERED], ['delivery_status', '<>', DeliveryStatusEnum::DELIVERED],
['order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]] // ['order_status', 'in', [OrderStatusEnum::NORMAL, OrderStatusEnum::APPLY_CANCEL]]
['order_status', 'in', [OrderStatusEnum::NORMAL]]
]; ];
break; break;
case DataTypeEnum::RECEIPT: case DataTypeEnum::RECEIPT:
@ -222,7 +227,8 @@ class Order extends OrderModel
public function updatePrice(array $data): bool public function updatePrice(array $data): bool
{ {
if ($this['pay_status'] != PayStatusEnum::PENDING) { if ($this['pay_status'] != PayStatusEnum::PENDING) {
$this->error = '该订单不合法'; // $this->error = '该订单不合法';
$this->error = '该订单已支付,无法修改价格';
return false; return false;
} }
// 实际付款金额 // 实际付款金额

@ -43,10 +43,14 @@ class OrderRefund extends OrderRefundModel
} }
$filterOr = []; $filterOr = [];
if (!empty($param['searchValue']) && $param['searchType'] == 'all') { if (!empty($param['searchValue']) && $param['searchType'] == 'all') {
// $filterOr = [
// ['order.order_no', 'like', "%{$param['searchValue']}%"],
// ['user.nick_name', 'like', "%{$param['searchValue']}%"],
// ['order.user_id', '=', (int)$param['searchValue']]
// ];
$filterOr = [ $filterOr = [
['order.order_no', 'like', "%{$param['searchValue']}%"], ['order.order_no|user.nick_name|order.user_id', 'like', "%{$param['searchValue']}%"]
['user.nick_name', 'like', "%{$param['searchValue']}%"],
['order.user_id', '=', (int)$param['searchValue']]
]; ];
} }
@ -57,7 +61,8 @@ class OrderRefund extends OrderRefundModel
->join('user', 'user.user_id = order.user_id') ->join('user', 'user.user_id = order.user_id')
->where($filter); ->where($filter);
if(!empty($filterOr)){ if(!empty($filterOr)){
$query = $query->whereOr($filterOr); // $query = $query->whereOr($filterOr);
$query = $query->where($filterOr);
} }
$list = $query->order(['refund.create_time' => 'desc', 'refund.' . $this->getPk()]) $list = $query->order(['refund.create_time' => 'desc', 'refund.' . $this->getPk()])
->paginate(10); ->paginate(10);

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace app\store\service\order; namespace app\store\service\order;
use app\common\enum\dealer\withdraw\PayType;
use think\facade\Db; use think\facade\Db;
use app\store\model\Order as OrderModel; use app\store\model\Order as OrderModel;
use app\store\model\Express as ExpressModel; use app\store\model\Express as ExpressModel;
@ -49,6 +50,14 @@ class Delivery extends BaseService
*/ */
public function delivery(int $orderId, array $param): bool public function delivery(int $orderId, array $param): bool
{ {
if(empty($param['expressId'])) {
$this->error = '物流公司不能为空';
return false;
}
if (empty($param['expressNo'])) {
$this->error = '物流单号不能为空';
return false;
}
// 设置默认的参数 // 设置默认的参数
$param = $this->buildParam($param); $param = $this->buildParam($param);
// 获取订单详情 // 获取订单详情

Loading…
Cancel
Save