Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pms
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
pms
Commits
34c41b40
提交
34c41b40
authored
7月 06, 2023
作者:
xiaowang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
返回规格价格
上级
47883ca3
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
71 行增加
和
26 行删除
+71
-26
ProductDao.java
src/main/java/com/mmc/pms/dao/ProductDao.java
+3
-1
PriceAcquisition.java
...ain/java/com/mmc/pms/model/lease/vo/PriceAcquisition.java
+4
-4
ProductServiceImpl.java
...ain/java/com/mmc/pms/service/impl/ProductServiceImpl.java
+41
-13
ProductDao.xml
src/main/resources/mapper/ProductDao.xml
+23
-8
没有找到文件。
src/main/java/com/mmc/pms/dao/ProductDao.java
浏览文件 @
34c41b40
...
@@ -86,7 +86,7 @@ public interface ProductDao {
...
@@ -86,7 +86,7 @@ public interface ProductDao {
List
<
InventorySpecDO
>
listInventorySpec
(
Integer
id
);
List
<
InventorySpecDO
>
listInventorySpec
(
Integer
id
);
BigDecimal
feignGetUnitPriceByTag
(
PriceAcquisition
priceAcquisition
);
List
<
BigDecimal
>
feignGetUnitPriceByTag
(
PriceAcquisition
priceAcquisition
);
List
<
MallGoodsSpecInfoDO
>
listProdSpecInfo
(
@Param
(
"prodIds"
)
Set
<
Integer
>
prodIds
);
List
<
MallGoodsSpecInfoDO
>
listProdSpecInfo
(
@Param
(
"prodIds"
)
Set
<
Integer
>
prodIds
);
...
@@ -121,4 +121,6 @@ public interface ProductDao {
...
@@ -121,4 +121,6 @@ public interface ProductDao {
@Param
(
"prodSkuSpecIds"
)
Set
<
Integer
>
prodSkuSpecIds
);
@Param
(
"prodSkuSpecIds"
)
Set
<
Integer
>
prodSkuSpecIds
);
int
countSpecByProdSkuId
(
Integer
id
);
int
countSpecByProdSkuId
(
Integer
id
);
BigDecimal
getMarketplacePrice
(
PriceAcquisition
priceAcquisition
);
}
}
src/main/java/com/mmc/pms/model/lease/vo/PriceAcquisition.java
浏览文件 @
34c41b40
...
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
...
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
/**
* @author 23214
* @author 23214
*/
*/
...
@@ -12,9 +14,6 @@ import lombok.NoArgsConstructor;
...
@@ -12,9 +14,6 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
public
class
PriceAcquisition
{
public
class
PriceAcquisition
{
@ApiModelProperty
(
value
=
"用户id"
)
private
Integer
userId
;
@ApiModelProperty
(
value
=
"规格id"
)
@ApiModelProperty
(
value
=
"规格id"
)
private
Integer
specsId
;
private
Integer
specsId
;
...
@@ -22,6 +21,6 @@ public class PriceAcquisition {
...
@@ -22,6 +21,6 @@ public class PriceAcquisition {
private
Integer
day
;
private
Integer
day
;
@ApiModelProperty
(
value
=
"渠道等级id"
)
@ApiModelProperty
(
value
=
"渠道等级id"
)
private
Integer
channelLevelId
;
private
List
<
Integer
>
channelLevelId
;
}
}
\ No newline at end of file
src/main/java/com/mmc/pms/service/impl/ProductServiceImpl.java
浏览文件 @
34c41b40
...
@@ -306,20 +306,48 @@ public class ProductServiceImpl implements ProductSkuService {
...
@@ -306,20 +306,48 @@ public class ProductServiceImpl implements ProductSkuService {
@Override
@Override
public
BigDecimal
feignGetUnitPriceByTag
(
PriceAcquisition
priceAcquisition
)
{
public
BigDecimal
feignGetUnitPriceByTag
(
PriceAcquisition
priceAcquisition
)
{
Map
<
Integer
,
Integer
>
dayMap
=
new
HashMap
<>();
List
<
Integer
>
channelLevelId
=
priceAcquisition
.
getChannelLevelId
();
dayMap
.
put
(
0
,
7
);
if
(
channelLevelId
==
null
){
dayMap
.
put
(
8
,
15
);
return
new
BigDecimal
(
0
);
dayMap
.
put
(
16
,
30
);
}
dayMap
.
put
(
31
,
Integer
.
MAX_VALUE
);
// 设置时间区间
int
dayRange
=
getDayRange
(
priceAcquisition
.
getDay
());
Integer
dayRange
=
dayMap
.
entrySet
().
stream
()
.
filter
(
entry
->
priceAcquisition
.
getDay
()
<=
entry
.
getKey
())
.
findFirst
()
.
map
(
Map
.
Entry
::
getValue
)
.
orElseThrow
(()
->
new
RuntimeException
(
"租赁期限错误错误!"
));
priceAcquisition
.
setDay
(
dayRange
);
priceAcquisition
.
setDay
(
dayRange
);
return
productDao
.
feignGetUnitPriceByTag
(
priceAcquisition
);
// 获取市场价
BigDecimal
marketplacePrice
=
productDao
.
getMarketplacePrice
(
priceAcquisition
);
if
(
marketplacePrice
==
null
)
{
return
new
BigDecimal
(
0
);
}
// 获取渠道价格
List
<
BigDecimal
>
price
=
productDao
.
feignGetUnitPriceByTag
(
priceAcquisition
);
if
(
price
.
size
()==
0
)
{
return
marketplacePrice
;
}
else
{
List
<
BigDecimal
>
sortedPrice
=
price
.
stream
()
.
sorted
(
Comparator
.
naturalOrder
())
.
collect
(
Collectors
.
toList
());
BigDecimal
bigDecimal
=
sortedPrice
.
get
(
0
);
if
(
bigDecimal
.
compareTo
(
marketplacePrice
)
<
0
){
return
bigDecimal
;
}
else
if
(
bigDecimal
.
compareTo
(
marketplacePrice
)
>
0
){
return
marketplacePrice
;
}
else
{
return
marketplacePrice
;
}
}
}
public
int
getDayRange
(
int
day
)
{
if
(
between
(
day
,
0
,
7
))
return
0
;
if
(
between
(
day
,
8
,
15
))
return
1
;
if
(
between
(
day
,
16
,
30
))
return
2
;
if
(
day
>
30
)
return
3
;
throw
new
RuntimeException
(
"租期有误!"
);
}
private
boolean
between
(
int
num
,
int
start
,
int
end
){
return
num
>=
start
&&
num
<=
end
;
}
}
@Override
@Override
...
...
src/main/resources/mapper/ProductDao.xml
浏览文件 @
34c41b40
...
@@ -319,14 +319,6 @@
...
@@ -319,14 +319,6 @@
AND mp.is_deleted = 0
AND mp.is_deleted = 0
AND gi.is_deleted = 0
AND gi.is_deleted = 0
</select>
</select>
<select
id=
"feignGetUnitPriceByTag"
resultType=
"java.math.BigDecimal"
>
select price
from product_spec_price
where product_spec_id = #{specsId}
and cooperation_tag = #{channelLevelId}
and `type` = 1
and lease_term = #{day}
</select>
<select
id=
"listProdSpecInfo"
resultType=
"com.mmc.pms.entity.MallGoodsSpecInfoDO"
>
<select
id=
"listProdSpecInfo"
resultType=
"com.mmc.pms.entity.MallGoodsSpecInfoDO"
>
SELECT
SELECT
gi.id, gi.directory_id, mpsip.id as mallSkuInfoSpecId, mpsip.is_deleted as sku_spec_deleted, ps.spec_name,
gi.id, gi.directory_id, mpsip.id as mallSkuInfoSpecId, mpsip.is_deleted as sku_spec_deleted, ps.spec_name,
...
@@ -528,4 +520,27 @@
...
@@ -528,4 +520,27 @@
where product_id = #{id}
where product_id = #{id}
and is_deleted = 0
and is_deleted = 0
</select>
</select>
<select
id=
"getMarketplacePrice"
resultType=
"java.math.BigDecimal"
>
select product_spec_id productSpecId,
cooperation_tag cooperationTag,
price,
lease_term
from product_spec_price
where `type` = 1
and lease_term = #{day}
and cooperation_tag = 0
and product_spec_id = #{specsId}
</select>
<select
id=
"feignGetUnitPriceByTag"
resultType=
"java.math.BigDecimal"
>
select price
from product_spec_price
<where>
product_spec_id = #{specsId}
and `type` = 1
and lease_term = #{day}
<foreach
collection=
"channelLevelId"
index=
"index"
separator=
","
open=
"and cooperation_tag in("
close=
")"
item=
"d"
>
#{d}
</foreach>
</where>
</select>
</mapper>
</mapper>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论