|
@@ -134,8 +134,8 @@ class GoodsService extends BaseService
|
|
|
$item['supply_name'] = isset($supplyList[$item['supply_type']]) ? $supplyList[$item['supply_type']] : '';
|
|
|
$item['usdt_price'] = $usdtPrice;
|
|
|
$item['xd_price_rate'] = $xdPrice;
|
|
|
- $item['original_price'] = $item['retail_price'];
|
|
|
- $item['retail_price'] = $usdtPrice > 0 ? moneyFormat($item['retail_price'] / $usdtPrice * $xdPrice, 2) : $item['retail_price'];
|
|
|
+ $item['retail_price1'] = $item['retail_price'];
|
|
|
+ $item['retail_price'] = $this->getRealSalePrice($item['cost_price']);
|
|
|
}
|
|
|
unset($item);
|
|
|
} else {
|
|
@@ -184,7 +184,8 @@ class GoodsService extends BaseService
|
|
|
$info['xd_price'] = $xdPrice;
|
|
|
$info['custom_uid'] = ConfigService::make()->getConfigByCode('xl_custom_id',100001);
|
|
|
if(isset($info['retail_price']) && $info['retail_price']){
|
|
|
- $info['retail_price'] = moneyFormat($info['retail_price']/$usdtPrice * $xdPrice,2);
|
|
|
+ $info['retail_price1'] =$info['retail_price'];
|
|
|
+ $info['retail_price'] = $this->getRealSalePrice($info['cost_price']);
|
|
|
}
|
|
|
|
|
|
if(isset($info['sku_list']) && $info['sku_list']){
|
|
@@ -192,7 +193,8 @@ class GoodsService extends BaseService
|
|
|
$v['detail_img'] = $v['detail_img']? json_decode($v['detail_img'], true) : [];
|
|
|
$v['attr'] = $v['attr']? json_decode($v['attr'], true) : [];
|
|
|
$v['main_img'] = $v['main_img']? get_image_url($v['main_img']) : '';
|
|
|
- $v['retail_price'] = $v['retail_price']? moneyFormat($v['retail_price']/$usdtPrice * $xdPrice,2) : $info['retail_price'];
|
|
|
+ $v['retail_price_1'] = $v['retail_price'];
|
|
|
+ $v['retail_price'] = $this->getRealSalePrice($v['plat_price']);
|
|
|
|
|
|
}
|
|
|
unset($v);
|
|
@@ -209,6 +211,29 @@ class GoodsService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 实际售价
|
|
|
+ * @param $price 成本价或其他价格
|
|
|
+ * @param bool $float 是否浮动转换,1-浮动转换,2-不浮动转换,3-浮动不转换
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getRealSalePrice($price, $float=1)
|
|
|
+ {
|
|
|
+ $usdtPrice = RedisService::get("caches:wallets:usdt_rate");
|
|
|
+ if($usdtPrice<=0){
|
|
|
+ $usdtCnyPrice = ConfigService::make()->getConfigByCode('usdt_cny_price', 7.2);
|
|
|
+ $usdtPrice = $usdtCnyPrice>0 && $usdtCnyPrice< 100? $usdtCnyPrice : 0;
|
|
|
+ }
|
|
|
+ $xdPrice = ConfigService::make()->getConfigByCode('xd_price', 100);
|
|
|
+ $xdPrice = $xdPrice > 0 && $xdPrice <= 10000 ? $xdPrice : 100;
|
|
|
+ $floatRate = ConfigService::make()->getConfigByCode('goods_price_float_rate', 0);
|
|
|
+ $floatRate = $floatRate>0 && $floatRate<100? $floatRate : 0;
|
|
|
+ $price = $float == 2? $price : floatval($price * (1 + ($floatRate/100)));
|
|
|
+ if($float==3){
|
|
|
+ return $price;
|
|
|
+ }
|
|
|
+ return $usdtPrice > 0 ? moneyFormat($price / $usdtPrice * $xdPrice, 2) : $price;
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 获取要购买或结算的商品列表
|
|
|
* @param $userId
|
|
|
* @param array $params
|
|
@@ -254,9 +279,10 @@ class GoodsService extends BaseService
|
|
|
$info['num'] = $num;
|
|
|
$info['sku_id'] = $skuId;
|
|
|
$skuInfo = GoodsSkuModel::where(['goods_id'=> $goodsId,'sku_id'=> $skuId,'mark'=>1])->first();
|
|
|
- $retailPrice = isset($skuInfo['retail_price'])? $skuInfo['retail_price'] : 0;
|
|
|
- if($retailPrice){
|
|
|
- $info['retail_price'] = $usdtPrice > 0 ? moneyFormat($retailPrice / $usdtPrice * $xdPrice, 2) : $retailPrice;
|
|
|
+ $price = isset($skuInfo['plat_price'])? $skuInfo['plat_price'] : 0;
|
|
|
+ if($price){
|
|
|
+ $info['retail_price1'] = $info['retail_price'];
|
|
|
+ $info['retail_price'] = $this->getRealSalePrice($price);
|
|
|
}
|
|
|
|
|
|
if(isset($skuInfo['attr']) && $skuInfo['attr']){
|
|
@@ -293,17 +319,17 @@ class GoodsService extends BaseService
|
|
|
$item['supply_name'] = isset($supplyList[$item['supply_type']]) ? $supplyList[$item['supply_type']] : '';
|
|
|
$item['usdt_price'] = $usdtPrice;
|
|
|
$item['xd_price_rate'] = $xdPrice;
|
|
|
- $item['original_price'] = $item['retail_price'];
|
|
|
+ $item['retail_price1'] = $item['retail_price'];
|
|
|
$skuInfo = isset($item['sku'])? $item['sku'] : [];
|
|
|
if(isset($skuInfo['attr']) && $skuInfo['attr']){
|
|
|
$skuInfo['attr'] = json_decode($skuInfo['attr'], true);
|
|
|
}
|
|
|
$item['sku'] = $skuInfo;
|
|
|
- $retailPrice = isset($skuInfo['retail_price'])? $skuInfo['retail_price'] : 0;
|
|
|
- if($retailPrice){
|
|
|
- $item['retail_price'] = $usdtPrice > 0 ? moneyFormat($retailPrice / $usdtPrice * $xdPrice, 2) : $retailPrice;
|
|
|
+ $price = isset($skuInfo['plat_price'])? $skuInfo['plat_price'] : 0;
|
|
|
+ if($price){
|
|
|
+ $item['retail_price'] = $this->getRealSalePrice($price);
|
|
|
}else{
|
|
|
- $item['retail_price'] = $usdtPrice > 0 ? moneyFormat($item['retail_price'] / $usdtPrice * $xdPrice, 2) : $item['retail_price'];
|
|
|
+ $item['retail_price'] = $this->getRealSalePrice($item['cost_price']);
|
|
|
}
|
|
|
$skuList[$item['goods_id']] = [
|
|
|
'sku_id'=> $item['sku_id'],
|
|
@@ -341,7 +367,7 @@ class GoodsService extends BaseService
|
|
|
->whereIn('a.goods_id',$ids)
|
|
|
->where(['a.status' => 1, 'a.mark' => 1])
|
|
|
->where('a.retail_price', '>', 0)
|
|
|
- ->select(['a.goods_id','a.merch_id','a.goods_name','a.cate_id','a.supply_type','a.main_img','a.retail_price'])
|
|
|
+ ->select(['a.goods_id','a.merch_id','a.goods_name','a.cate_id','a.supply_type','a.main_img','a.cost_price','a.retail_price'])
|
|
|
->get();
|
|
|
$goods = $goods? $goods->toArray() : [];
|
|
|
if($goods){
|
|
@@ -433,13 +459,13 @@ class GoodsService extends BaseService
|
|
|
$item['supply_name'] = isset($supplyList[$item['supply_type']]) ? $supplyList[$item['supply_type']] : '';
|
|
|
$item['usdt_price'] = $usdtPrice;
|
|
|
$item['xd_price_rate'] = $xdPrice;
|
|
|
- $item['original_price'] = $item['retail_price'];
|
|
|
+ $item['retail_price1'] = $item['retail_price'];
|
|
|
$skuInfo = isset($item['sku'])? $item['sku'] : [];
|
|
|
- $retailPrice = isset($skuInfo['retail_price'])? $skuInfo['retail_price'] : 0;
|
|
|
- if($retailPrice){
|
|
|
- $item['retail_price'] = $usdtPrice > 0 ? moneyFormat($retailPrice / $usdtPrice * $xdPrice, 2) : $retailPrice;
|
|
|
+ $price = isset($skuInfo['plat_price'])? $skuInfo['plat_price'] : 0;
|
|
|
+ if($price){
|
|
|
+ $item['retail_price'] = $this->getRealSalePrice($price);
|
|
|
}else{
|
|
|
- $item['retail_price'] = $usdtPrice > 0 ? moneyFormat($item['retail_price'] / $usdtPrice * $xdPrice, 2) : $item['retail_price'];
|
|
|
+ $item['retail_price'] = $this->getRealSalePrice($item['cost_price']);
|
|
|
}
|
|
|
}
|
|
|
unset($item);
|
|
@@ -469,7 +495,7 @@ class GoodsService extends BaseService
|
|
|
->leftJoin('goods as b','b.goods_id','=','a.goods_id')
|
|
|
->where(['a.status' => 1, 'a.mark' => 1,'b.status'=>1,'b.mark'=>1])
|
|
|
->where('a.num', '>', 0)
|
|
|
- ->where('b.retail_price', '>', 0)
|
|
|
+ ->where('b.cost_price', '>', 0)
|
|
|
->count('a.id');
|
|
|
if($data){
|
|
|
RedisService::set($cacheKey, $data, rand(300, 600));
|
|
@@ -639,6 +665,8 @@ class GoodsService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ $size = ConfigService::make()->getConfigByCode('goods_update_limit', 0);
|
|
|
+ $pageSize = $size>10 && $size < 500? $size : $pageSize;
|
|
|
$page = RedisService::get($cacheKey . '_page');
|
|
|
$page = $page ? $page + 1 : 1;
|
|
|
$lastTime = $this->model->where(['mark' => 1])->orderBy('create_time', 'desc')->value('create_time');
|