Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
a7e50a4f
Commit
a7e50a4f
authored
Jan 30, 2024
by
吴春
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/mall.oytour.com
parents
1980c6b3
3dc5a19c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
15 deletions
+117
-15
ConvertHelper.cs
Mall.Common/Plugin/ConvertHelper.cs
+23
-0
ProductController.cs
Mall.WebApi/Controllers/Product/ProductController.cs
+94
-15
No files found.
Mall.Common/Plugin/ConvertHelper.cs
View file @
a7e50a4f
...
...
@@ -215,6 +215,29 @@ namespace Mall.Common
return
timeStr
;
}
/// <summary>
/// 获取时间格式(yyyy-MM)
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public
static
string
FormatYearMonth
(
this
object
time
)
{
string
timeStr
=
""
;
if
(
time
!=
null
)
{
try
{
timeStr
=
Convert
.
ToDateTime
(
time
.
ToString
()).
ToString
(
"yyyy-MM"
);
}
catch
{
}
}
return
timeStr
;
}
/// <summary>
/// 获取时间格式
/// </summary>
...
...
Mall.WebApi/Controllers/Product/ProductController.cs
View file @
a7e50a4f
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Mall.AOP
;
using
Mall.Common.API
;
using
Mall.Common.Enum.Goods
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.Product
;
using
Mall.Module.
User
;
using
Mall.Module.
Product
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Mall.Common.Plugin
;
using
Mall.Common.Enum.User
;
using
Mall.CacheManager.User
;
using
Newtonsoft.Json.Linq
;
using
Mall.Common
;
using
Mall.Module.Product
;
using
Mall.AOP
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Configuration.Json
;
using
Mall.Common.Enum.Goods
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Mall.WebApi.Controllers.MallBase
{
...
...
@@ -1831,7 +1824,7 @@ namespace Mall.WebApi.Controllers.MallBase
model
?.
goodsLogo
,
model
?.
GoodsEduType
,
model
?.
MaterialId
,
RelevanceList
=
model
?.
RelevanceList
.
Select
(
qitem
=>
new
{
qitem
.
RelevanceId
,
qitem
.
RelevanceName
,
qitem
.
RelevancePrice
,
qitem
.
Unit
})
RelevanceList
=
model
?.
RelevanceList
.
Select
(
qitem
=>
new
{
qitem
.
RelevanceId
,
qitem
.
RelevanceName
,
qitem
.
RelevancePrice
,
qitem
.
Unit
})
};
}
return
ApiResult
.
Success
(
""
,
obj
);
...
...
@@ -3247,5 +3240,91 @@ namespace Mall.WebApi.Controllers.MallBase
return
result
?
ApiResult
.
Success
(
""
)
:
ApiResult
.
Failed
(
"加入到商品列表失败"
);
}
#
endregion
/// <summary>
/// 把分享平台的商品加入商品列表
/// </summary>
/// <returns></returns>
public
ApiResult
CreateSkuCalendar
()
{
List
<
object
>
list
=
new
List
<
object
>();
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
string
startDate
=
parms
.
GetStringValue
(
"StartDate"
);
string
endDate
=
parms
.
GetStringValue
(
"EndDate"
);
if
(
string
.
IsNullOrEmpty
(
startDate
))
{
startDate
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
);
endDate
=
Common
.
ConvertHelper
.
FormatDate
(
DateTime
.
Now
.
AddMonths
(
1
));
}
DateTime
start
=
Convert
.
ToDateTime
(
startDate
);
DateTime
end
=
Convert
.
ToDateTime
(
endDate
);
List
<
StockItem
>
stockList
=
new
List
<
StockItem
>();
int
days
=
(
end
-
start
).
Days
;
DateTime
todayDate
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
DateTime
.
Now
.
Day
);
for
(
var
i
=
0
;
i
<=
days
;
i
++)
{
var
newDateTime
=
start
.
AddDays
(
i
);
stockList
.
Add
(
new
StockItem
()
{
Year
=
newDateTime
.
Year
,
Month
=
newDateTime
.
Month
,
Day
=
newDateTime
.
Day
,
DayStr
=
Common
.
ConvertHelper
.
FormatDate
(
newDateTime
),
YearMonth
=
Common
.
ConvertHelper
.
FormatYearMonth
(
newDateTime
),
IsEdit
=
newDateTime
>
todayDate
});
}
var
yearMonthList
=
stockList
?.
GroupBy
(
qitem
=>
new
{
qitem
.
Year
,
qitem
.
Month
,
qitem
.
YearMonth
})
?.
Select
(
qitem
=>
new
{
qitem
.
Key
.
Year
,
qitem
.
Key
.
Month
,
qitem
.
Key
.
YearMonth
});
foreach
(
var
rItem
in
yearMonthList
)
{
list
.
Add
(
new
{
rItem
.
YearMonth
,
DateList
=
stockList
?.
Where
(
qitem
=>
qitem
.
Year
==
rItem
.
Year
&&
qitem
.
Month
==
rItem
.
Month
)?.
ToList
()
??
new
List
<
StockItem
>()
});
}
return
ApiResult
.
Success
(
data
:
list
);
}
}
/// <summary>
/// 库存项
/// </summary>
public
class
StockItem
{
/// <summary>
/// 年
/// </summary>
public
int
Year
{
get
;
set
;
}
/// <summary>
/// 月
/// </summary>
public
int
Month
{
get
;
set
;
}
/// <summary>
/// 日
/// </summary>
public
int
Day
{
get
;
set
;
}
/// <summary>
/// yyyy-MM
/// </summary>
public
string
YearMonth
{
get
;
set
;
}
/// <summary>
/// 天
/// </summary>
public
string
DayStr
{
get
;
set
;
}
/// <summary>
/// 是否可编辑
/// </summary>
public
bool
IsEdit
{
get
;
set
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment