|
|
|
@ -12,25 +12,18 @@ declare (strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace app\api\service; |
|
|
|
|
|
|
|
|
|
use app\api\model\Category as CategoryModel; |
|
|
|
|
use app\api\model\Goods as GoodsModel; |
|
|
|
|
use app\api\model\Setting as SettingModel; |
|
|
|
|
use app\api\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\api\model\Category as CategoryModel; |
|
|
|
|
use app\api\model\Setting as SettingModel; |
|
|
|
|
use app\api\model\UploadFile; |
|
|
|
|
use app\api\service\User as UserService; |
|
|
|
|
use app\common\enum\Setting as SettingEnum; |
|
|
|
|
use app\common\library\helper; |
|
|
|
|
use app\common\model\Help; |
|
|
|
|
use app\common\model\store\Shop as ShopModel; |
|
|
|
|
use app\common\model\goods\GoodsHotWord; |
|
|
|
|
use app\api\service\sharp\Active as ActiveService; |
|
|
|
|
use app\common\enum\Setting as SettingEnum; |
|
|
|
|
use app\common\model\store\Shop as ShopModel; |
|
|
|
|
use app\common\model\store\shop\Comment; |
|
|
|
|
use app\common\service\Goods as GoodsService; |
|
|
|
|
use app\api\model\sharp\Active as SharpActiveModel; |
|
|
|
|
use app\api\model\sharp\ActiveTime as ActiveTimeModel; |
|
|
|
|
use app\api\controller\sharp\Goods as miaosha; |
|
|
|
|
use app\store\model\goods\GoodsPrice as GoodsPriceModel; |
|
|
|
|
use app\common\model\store\ShopParking as ParkingModel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品服务类 |
|
|
|
@ -100,13 +93,14 @@ class Goods extends GoodsService |
|
|
|
|
/** |
|
|
|
|
* 获取(新品首发,大牌正品,新人首单)商铺的url |
|
|
|
|
*/ |
|
|
|
|
public function getStoreImgUrl($img_id){ |
|
|
|
|
public function getStoreImgUrl($img_id) |
|
|
|
|
{ |
|
|
|
|
$data = []; |
|
|
|
|
if(!empty($img_id)){ |
|
|
|
|
$img_ids = explode(",",$img_id); |
|
|
|
|
$infos = \app\common\model\UploadFile::where('file_id','in' ,$img_ids)->field('file_path,domain')->select(); |
|
|
|
|
if(!empty($infos)){ |
|
|
|
|
foreach($infos as $info){ |
|
|
|
|
if (!empty($img_id)) { |
|
|
|
|
$img_ids = explode(",", $img_id); |
|
|
|
|
$infos = \app\common\model\UploadFile::where('file_id', 'in', $img_ids)->field('file_path,domain')->select(); |
|
|
|
|
if (!empty($infos)) { |
|
|
|
|
foreach ($infos as $info) { |
|
|
|
|
$data[] = getUrl($info['file_path'], $info['domain']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -255,47 +249,35 @@ class Goods extends GoodsService |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
$info = $info->toArray(); |
|
|
|
|
//todo wmc |
|
|
|
|
$info['remark'] = json_decode($info['remark'],true); |
|
|
|
|
$arr = explode(" ", $info['shop_hours']); |
|
|
|
|
$arr = explode("-", $arr[1] ?? ""); |
|
|
|
|
$info['remark'] = json_decode($info['remark'], true); |
|
|
|
|
$info['is_open'] = 0; |
|
|
|
|
$info['service_num_for_me'] = 5; |
|
|
|
|
// if ($arr && count($arr) == 2) { |
|
|
|
|
// $start = explode(":", $arr[0]); |
|
|
|
|
// $end = explode(":", $arr[1]); |
|
|
|
|
// $start_time = ($start[0] ?? 0) |
|
|
|
|
// if ($start[0]) { |
|
|
|
|
// // code... |
|
|
|
|
// } |
|
|
|
|
// $info['is_open'] = 0; |
|
|
|
|
// } |
|
|
|
|
// $info['is_open'] = $arr && $arr[] |
|
|
|
|
// $info['fuwu_hours'] = 5; |
|
|
|
|
// $info['fuwu_num'] = 15; |
|
|
|
|
// $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png'; |
|
|
|
|
|
|
|
|
|
$info['history'] = json_decode($info['history'], true); |
|
|
|
|
|
|
|
|
|
$info['history'] = json_decode($info['history'], true); |
|
|
|
|
$info['evaluate'] = Comment::with('file') |
|
|
|
|
->field(['nickname,content,image_id']) |
|
|
|
|
->hidden(['file']) |
|
|
|
|
->where('is_delete', '=', 0) |
|
|
|
|
->where('shop_id','=', $info['shop_id']) |
|
|
|
|
->where('shop_id', '=', $info['shop_id']) |
|
|
|
|
->select(); |
|
|
|
|
$file = UploadFile::whereIn('file_id', explode(',', $info['shop_image_id']))->select(); |
|
|
|
|
$info['imageList'] = helper::getArrayColumn($file, 'preview_url'); |
|
|
|
|
$info['service_num_for_me'] = 0; |
|
|
|
|
//当前用户门店自提订单数 |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(false); |
|
|
|
|
if ($userId) { |
|
|
|
|
$info['service_num_for_me'] = (new \app\api\model\Order())->where(['user_id' => $userId, 'extract_shop_id' => $info['shop_id']])->count(); |
|
|
|
|
} |
|
|
|
|
return $info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function hotWord($page): array |
|
|
|
|
{ |
|
|
|
|
if(empty($page) || $page == 1){ |
|
|
|
|
if (empty($page) || $page == 1) { |
|
|
|
|
$offset = 0; |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
$offset = $page * 5; |
|
|
|
|
} |
|
|
|
|
return GoodsHotWord::order('sort desc')->limit($offset,5)->select()->toArray(); |
|
|
|
|
return GoodsHotWord::order('sort desc')->limit($offset, 5)->select()->toArray(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// //抢购会场列表 |
|
|
|
@ -338,7 +320,8 @@ class Goods extends GoodsService |
|
|
|
|
// return $list; |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
public static function getGoodsPrice($goods_id, $price, $cost_price){ |
|
|
|
|
public static function getGoodsPrice($goods_id, $price, $cost_price) |
|
|
|
|
{ |
|
|
|
|
$catService = new \app\store\model\GoodsCategoryRel(); |
|
|
|
|
$catIds = $catService->where(['goods_id' => $goods_id])->column('category_id'); |
|
|
|
|
if (UserService::isstore()) { |
|
|
|
@ -351,6 +334,7 @@ class Goods extends GoodsService |
|
|
|
|
} |
|
|
|
|
return $price; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 格式化商品列表 |
|
|
|
|
* @param $goodsList |
|
|
|
@ -358,7 +342,7 @@ class Goods extends GoodsService |
|
|
|
|
*/ |
|
|
|
|
private function newFormatGoodsList($goodsList): array |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = []; |
|
|
|
|
foreach ($goodsList as $goods) { |
|
|
|
|
$temp = [ |
|
|
|
@ -373,7 +357,7 @@ class Goods extends GoodsService |
|
|
|
|
'goods_sales' => $goods['goods_sales'], |
|
|
|
|
'remaizhishu' => $goods['remaizhishu'], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (UserService::isLogin()) { |
|
|
|
|
$catService = new \app\store\model\GoodsCategoryRel(); |
|
|
|
|
$catIds = $catService->where(['goods_id' => $goods['goods_id']])->column('category_id'); |
|
|
|
@ -381,7 +365,7 @@ class Goods extends GoodsService |
|
|
|
|
if (UserService::isstore()) { |
|
|
|
|
$temp['goods_price_min'] = $goods['cost_price_min']; |
|
|
|
|
} elseif (UserService::isPlusMember()) { |
|
|
|
|
$temp['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$temp['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$temp['goods_price_min'] = $priceArr['distributionPrice']; |
|
|
|
@ -391,6 +375,7 @@ class Goods extends GoodsService |
|
|
|
|
} |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 格式化商品列表 |
|
|
|
|
* @param $goodsList |
|
|
|
@ -426,10 +411,10 @@ class Goods extends GoodsService |
|
|
|
|
// // $price_list_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['goods_price_min']); |
|
|
|
|
// // $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']); |
|
|
|
|
// // } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //价格判断 |
|
|
|
|
// if (UserService::isstore()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
|
|
|
|
|
// // $temp['goods_price_min_plus'] = $priceArr['membershipPrice']; |
|
|
|
|