|
|
|
@ -8,7 +8,7 @@ |
|
|
|
|
// +---------------------------------------------------------------------- |
|
|
|
|
// | Author: 萤火科技 <admin@yiovo.com> |
|
|
|
|
// +---------------------------------------------------------------------- |
|
|
|
|
declare (strict_types=1); |
|
|
|
|
declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace app\api\model; |
|
|
|
|
|
|
|
|
@ -318,7 +318,6 @@ class Goods extends GoodsModel |
|
|
|
|
$v['image'] = getUrl($file_path['file_path'], $file_path['domain']); |
|
|
|
|
//$v['end_time'] = strtotime($info->p_time) - time(); |
|
|
|
|
$v['end_time'] = $info->p_time ? strtotime($info->p_time) - time() : 0; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return $list; |
|
|
|
|
} |
|
|
|
@ -400,7 +399,6 @@ class Goods extends GoodsModel |
|
|
|
|
} |
|
|
|
|
$goodsInfo->goods_images = $goods_images; |
|
|
|
|
$goodsInfo->goods_image = $res['mainImageList'][0]; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($res['infoImageList']) { |
|
|
|
@ -410,7 +408,6 @@ class Goods extends GoodsModel |
|
|
|
|
} |
|
|
|
|
$goodsInfo->content = $content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'sn': |
|
|
|
@ -420,7 +417,6 @@ class Goods extends GoodsModel |
|
|
|
|
// code... |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -478,7 +474,7 @@ class Goods extends GoodsModel |
|
|
|
|
$goodsInfo['merchant'] = null; |
|
|
|
|
//商户信息 |
|
|
|
|
if ($goodsInfo['merchant_id'] && !in_array($goodsInfo['channel'], config('app.not_show_merchant'))) { |
|
|
|
|
//if ($goodsInfo['merchant_id']) { |
|
|
|
|
//if ($goodsInfo['merchant_id']) { |
|
|
|
|
$merchant = \app\common\model\Merchant::detail($goodsInfo['merchant_id'], $goodsInfo->store_id); |
|
|
|
|
if ($merchant) { |
|
|
|
|
if ($merchant['license_img_id']) { |
|
|
|
@ -497,7 +493,7 @@ class Goods extends GoodsModel |
|
|
|
|
$goodsInfo['merchant_id'] = 0; |
|
|
|
|
} |
|
|
|
|
//处理苏宁商品,京东价拖的问题 |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn','sn1']) && $goodsInfo['link_other']) { |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn', 'sn1']) && $goodsInfo['link_other']) { |
|
|
|
|
$goodsInfo['link'] = $goodsInfo['link_other']; |
|
|
|
|
$goodsInfo['goods_no'] = $goodsInfo['goods_no_other']; |
|
|
|
|
} |
|
|
|
@ -582,7 +578,7 @@ class Goods extends GoodsModel |
|
|
|
|
$goodsInfo = static::detail($goodsId, $with); |
|
|
|
|
//处理子商户的成本价 |
|
|
|
|
if ($storeInfo && $storeInfo['p_store_id'] > 0) { |
|
|
|
|
$goodsInfo->cost_price_min = round($goodsInfo->cost_price_min / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
$goodsInfo->cost_price_min = round($goodsInfo->cost_price_min / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
} |
|
|
|
|
//单规格和多规格处理不一致 |
|
|
|
|
$goodsInfo->skuList = $goodsInfo->skuList1 ? $goodsInfo->skuList1 : $goodsInfo->skuList; |
|
|
|
@ -593,12 +589,12 @@ class Goods extends GoodsModel |
|
|
|
|
} |
|
|
|
|
foreach ($goodsInfo->skuList as &$value) { |
|
|
|
|
//处理苏宁商品,京东价拖的问题 |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn','sn1']) && $goodsInfo['link_other'] && $value->goods_id == $goodsId) { |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn', 'sn1']) && $goodsInfo['link_other'] && $value->goods_id == $goodsId) { |
|
|
|
|
$value->goods_sku_no = $goodsInfo['goods_no_other']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($storeInfo && $storeInfo['p_store_id'] > 0) { |
|
|
|
|
$value->cost_price = round($value->cost_price / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
$value->cost_price = round($value->cost_price / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//使用总后台的商品的图片作为商城商品的图片 |
|
|
|
@ -617,7 +613,7 @@ class Goods extends GoodsModel |
|
|
|
|
} |
|
|
|
|
//是否展示看同款按钮 |
|
|
|
|
$goodsInfo->is_show_ktk = 1; |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn','sn1']) && !$goodsInfo['link_other']) { |
|
|
|
|
if (in_array($goodsInfo['channel'], ['sn', 'sn1']) && !$goodsInfo['link_other']) { |
|
|
|
|
$goodsInfo->is_show_ktk = 0; |
|
|
|
|
} |
|
|
|
|
// 判断商品是否存在 |
|
|
|
@ -646,7 +642,7 @@ class Goods extends GoodsModel |
|
|
|
|
foreach ($data as $key => &$goods) { |
|
|
|
|
//处理子商户的成本价 |
|
|
|
|
if ($storeInfo && $storeInfo['p_store_id'] > 0) { |
|
|
|
|
$goods->cost_price_min = round($goods->cost_price_min / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
$goods->cost_price_min = round($goods->cost_price_min / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 整理列表数据并返回 |
|
|
|
@ -666,20 +662,20 @@ class Goods extends GoodsModel |
|
|
|
|
$goods['skuInfo'] = GoodsService::getSkuInfo($goods['goods_id'], $goodsSkuId); |
|
|
|
|
//处理子商户的成本价 |
|
|
|
|
if ($storeInfo && $storeInfo['p_store_id'] > 0) { |
|
|
|
|
$goods->skuInfo->cost_price = round($goods->skuInfo->cost_price / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
$goods->skuInfo->cost_price = round($goods->skuInfo->cost_price / (1 - $storeInfo['markup_rate'] * 0.01)); |
|
|
|
|
} |
|
|
|
|
//$enableGradeMoney && (new static)->setGoodsGradeMoney($goodsInfo); |
|
|
|
|
|
|
|
|
|
// $catService = new GoodsCategoryRel(); |
|
|
|
|
// $catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id'); |
|
|
|
|
$catIds = GoodsCategoryRel::withoutGlobalScope()->where(['goods_id' => $goods->goods_id])->column('category_id'); |
|
|
|
|
$user = UserService::getCurrentLoginUser(); |
|
|
|
|
$currtime = time(); |
|
|
|
|
if ($goods->getAttr('skuInfo')) { |
|
|
|
|
if (UserService::isPlusMember()) { |
|
|
|
|
$goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds); |
|
|
|
|
|
|
|
|
|
$goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds,$user->store_id); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds,$user->store_id); |
|
|
|
|
$goods['skuInfo']['goods_price'] = $priceArr['distributionPrice']; |
|
|
|
|
} |
|
|
|
|
//处理店长临时设置的秒杀价 |
|
|
|
@ -734,32 +730,33 @@ class Goods extends GoodsModel |
|
|
|
|
$goods['line_price_min'] = $goods['goods_price_min']; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$user = UserService::getCurrentLoginUser(); |
|
|
|
|
$currtime = time(); |
|
|
|
|
// $catService = new GoodsCategoryRel(); |
|
|
|
|
// $catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id'); |
|
|
|
|
$catIds = GoodsCategoryRel::withoutGlobalScope()->where(['goods_id' => $goods->goods_id])->column('category_id'); |
|
|
|
|
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价 |
|
|
|
|
$goods['line_price_min'] = $goods['goods_price_min']; //划线价格等于市场价 |
|
|
|
|
$goods['discount'] = 0.0; |
|
|
|
|
|
|
|
|
|
//价格判断 |
|
|
|
|
if (UserService::isstore()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds, $user->store_id); |
|
|
|
|
$goods_price_min = $goods['goods_price_min']; |
|
|
|
|
$goods['goods_price_min_plus'] = $priceArr['membershipPrice']; |
|
|
|
|
$goods['goods_price_min_dealer'] = $priceArr['distributionPrice']; |
|
|
|
|
$goods['goods_price_min'] = $goods['goods_price_min_plus'];//$goods['cost_price_min'];//店长售价,展示为成本价 |
|
|
|
|
$goods['goods_price_min'] = $goods['goods_price_min_plus']; //$goods['cost_price_min'];//店长售价,展示为成本价 |
|
|
|
|
$goods['discount'] = $goods_price_min > 0 ? bcdiv((string)($priceArr['membershipPrice'] * 10), (string)$goods_price_min, 1) : 0; |
|
|
|
|
} elseif (UserService::isPlusMember()) { |
|
|
|
|
$membershipPrice = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$membershipPrice = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds, $user->store_id); |
|
|
|
|
$goods['discount'] = $goods['goods_price_min'] > 0 ? bcdiv((string)($membershipPrice * 10), (string)$goods['goods_price_min'], 1) : 0; |
|
|
|
|
$goods['goods_price_min'] = $membershipPrice; |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds, $user->store_id); |
|
|
|
|
$goods['discount'] = $goods['goods_price_min'] > 0 ? bcdiv((string)($priceArr['distributionPrice'] * 10), (string)$goods['goods_price_min'], 1) : 0; |
|
|
|
|
//$goods['goods_price_min'] = $membershipPrice; |
|
|
|
|
$goods['goods_price_min'] = $priceArr['distributionPrice']; |
|
|
|
|
} |
|
|
|
|
//处理店长临时设置的秒杀价 |
|
|
|
|
//处理店长临时设置的秒杀价 |
|
|
|
|
if ($goods['sec_start_time'] && strtotime($goods['sec_start_time']) <= $currtime && (strtotime($goods['sec_start_time']) + 24 * 3600) >= $currtime) { |
|
|
|
|
$goods['goods_price_min'] = $goods['seckill_price']; |
|
|
|
|
} |
|
|
|
@ -782,21 +779,19 @@ class Goods extends GoodsModel |
|
|
|
|
|
|
|
|
|
//价格判断 |
|
|
|
|
if (UserService::isstore()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
$skuItem['goods_price'] = $skuItem['cost_price'];//店长售价,展示为成本价 |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds,$user->store_id); |
|
|
|
|
$skuItem['goods_price'] = $skuItem['cost_price']; //店长售价,展示为成本价 |
|
|
|
|
} elseif (UserService::isPlusMember()) { |
|
|
|
|
$skuItem['goods_price'] = \app\common\model\PriceSet::membershipPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
$skuItem['goods_price'] = \app\common\model\PriceSet::membershipPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds,$user->store_id); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds,$user->store_id); |
|
|
|
|
$skuItem['goods_price'] = $priceArr['distributionPrice']; |
|
|
|
|
} |
|
|
|
|
//处理店长临时设置的秒杀价 |
|
|
|
|
if ($skuItem['sec_start_time'] && strtotime($skuItem['sec_start_time']) <= $currtime && (strtotime($skuItem['sec_start_time']) + 24 * 3600) >= $currtime) { |
|
|
|
|
$skuItem['goods_price'] = $skuItem['seckill_price']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 折扣价: 已选择的商品sku(用于购物车) |
|
|
|
@ -808,15 +803,14 @@ class Goods extends GoodsModel |
|
|
|
|
// $sku_price_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['skuInfo']['goods_price']); |
|
|
|
|
// } |
|
|
|
|
// $goods['skuInfo']['goods_price'] = min($sku_price_plus); |
|
|
|
|
$goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds); |
|
|
|
|
|
|
|
|
|
$goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds,$user->store_id); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
// $sku_price_dealer = []; |
|
|
|
|
// foreach ($catIds as $k => $v) { |
|
|
|
|
// $sku_price_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['skuInfo']['goods_price']); |
|
|
|
|
// } |
|
|
|
|
//$goods['skuInfo']['goods_price'] = min($sku_price_dealer); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds); |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds, $user->store_id); |
|
|
|
|
$goods['skuInfo']['goods_price'] = $priceArr['distributionPrice']; |
|
|
|
|
} |
|
|
|
|
//处理店长临时设置的秒杀价 |
|
|
|
@ -933,9 +927,9 @@ class Goods extends GoodsModel |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//批量修改秒杀价格 |
|
|
|
|
// var_dump($data['sku_id']); |
|
|
|
|
// var_dump($data['sku_id']); |
|
|
|
|
$sku_id = $data['sku_id']; |
|
|
|
|
// foreach ($sku_ids as $sku_id) { |
|
|
|
|
// foreach ($sku_ids as $sku_id) { |
|
|
|
|
$skuData = GoodsSkuModel::get(['id' => $sku_id, 'goods_id' => $data['goods_id']]); |
|
|
|
|
if ($skuData) { |
|
|
|
|
$up_data = [ |
|
|
|
@ -949,7 +943,7 @@ class Goods extends GoodsModel |
|
|
|
|
$skuData->save($up_data); |
|
|
|
|
GoodsModel::where('goods_id', $data['goods_id'])->update($up_data); |
|
|
|
|
} |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|