pull/1/head
lqmac 9 months ago
parent c6eb85e852
commit e167dba8f4
  1. 14
      app/api/controller/Goods.php
  2. 13
      app/api/model/Goods.php
  3. 6
      app/api/model/Order.php

@ -18,7 +18,8 @@ use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\facade\Cache; use think\facade\Cache;
use think\response\Json; use think\response\Json;
use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel;
/** /**
* 商品控制器 * 商品控制器
* Class Goods * Class Goods
@ -99,8 +100,15 @@ class Goods extends Controller
{ {
$param = $this->request->param(); $param = $this->request->param();
$model = new GoodsModel; $model = new GoodsModel;
$list = $model->presaleList($param); $list = $model->presaleList($param)->toArray();
if (!$list) {
return $this->renderSuccess(compact('list'));
}
foreach ($list['data'] as $key => &$value) {
$goods_image = GoodsImageModel::where('goods_id', $value['goods_id'])->find();
$file_path = UploadFileModel::where('file_id', $goods_image['image_id'])->find();
$value['image'] = getUrl($file_path['file_path'], $file_path['domain']);
}
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }

@ -117,21 +117,22 @@ class Goods extends GoodsModel
return $this->setGoodsListDataFromApi($list); return $this->setGoodsListDataFromApi($list);
} }
public function presale() public function presale($param)
{ {
$userId = UserService::getCurrentLoginUserId(true); $userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([ $info = PreSaleLog::where([
'user_id' => $userId, 'user_id' => $userId,
'store_id' => request()->header()['storeid'], 'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'], 'goods_id' => $param['goods_id'] ?? 0,
])->find(); ])->find();
if (!$info) { if (!$info) {
PreSaleLog::insert([ PreSaleLog::insert([
'user_id' => $userId, 'user_id' => $userId,
'store_id' => request()->header()['storeid'], 'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'], 'pre_id' => $param['pre_id'] ?? 0,
'goods_id' => $param['goods_id'] ?? 0,
'ctime' => date('Y-m-d H:i:s') 'ctime' => date('Y-m-d H:i:s')
]); ]);
return true; return true;
@ -224,7 +225,7 @@ class Goods extends GoodsModel
->where([ ->where([
'a.store_id' => request()->header()['storeid'], 'a.store_id' => request()->header()['storeid'],
'a.user_id' => $userId, 'a.user_id' => $userId,
])->field('c.goods_name,c.goods_price_min,a.id,b.p_time')->paginate(15); ])->field('c.goods_name,c.goods_price_min,a.id,b.p_time,c.goods_id')->paginate(15);
return $info; return $info;
} }
@ -302,11 +303,11 @@ class Goods extends GoodsModel
return array_values($uniqueArray); return array_values($uniqueArray);
} }
public function canlpresale() public function canlpresale($param)
{ {
$userId = UserService::getCurrentLoginUserId(true); $userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([ $info = PreSaleLog::where([
'id' => $_POST['id'], 'id' => $param['id'],
'user_id' => $userId 'user_id' => $userId
])->delete(); ])->delete();

@ -28,7 +28,7 @@ use app\common\enum\{OrderType,
use app\api\service\Store as StoreService; use app\api\service\Store as StoreService;
use app\common\library\helper; use app\common\library\helper;
use cores\exception\BaseException; use cores\exception\BaseException;
use app\api\model\PreSaleLog;
/** /**
* 订单模型 * 订单模型
* Class Order * Class Order
@ -584,14 +584,14 @@ class Order extends OrderModel
$userId = UserService::getCurrentLoginUserId(); $userId = UserService::getCurrentLoginUserId();
return [ return [
'reservation_number' => RecoveryOrder::getCount(), // 上门预约待服务订单总数 'reservation_number' => PreSaleLog::where('user_id', $userId)->count(), // 上门预约待服务订单总数
'view_number' => GoodsBrowseLog::getCount(), // 浏览记录 'view_number' => GoodsBrowseLog::getCount(), // 浏览记录
'send_number' => TransferRecord::getCount(), // 发货数量 'send_number' => TransferRecord::getCount(), // 发货数量
'integral_number' => User::get($userId)->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(), // 购物车数量
'take_goods_number' => 0, // 发货记录&提货记录 'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type',20)->count(), // 发货记录&提货记录
]; ];
} }
} }

Loading…
Cancel
Save