Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
freemud.be.toolbox
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈宁
freemud.be.toolbox
Commits
6e379702
Commit
6e379702
authored
Jul 31, 2020
by
陈宁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# dev user coupons
parent
d9b78b9b
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
669 additions
and
11 deletions
+669
-11
Freemud.BE.Toolbox.Testing/GeneralTest.cs
+39
-0
Freemud.BE.Toolbox.WebApi/Freemud.BE.Toolbox.WebApi.csproj
+3
-1
Freemud.BE.Toolbox.WebApi/Model/Constants/ToolboxConstants.cs
+11
-0
Freemud.BE.Toolbox.WebApi/Model/Repository/UserIdentityInfo.cs
+16
-0
Freemud.BE.Toolbox.WebApi/Model/Request/GetUserCouponsRequest.cs
+15
-0
Freemud.BE.Toolbox.WebApi/Model/Response/UserCardAdapter.cs
+73
-0
Freemud.BE.Toolbox.WebApi/Model/ToolboxConfiguration.cs
+4
-0
Freemud.BE.Toolbox.WebApi/Proxy/FmCouponProxy.cs
+130
-0
Freemud.BE.Toolbox.WebApi/Repository/Dapper/BaseRepository.cs
+44
-0
Freemud.BE.Toolbox.WebApi/Repository/Dapper/UserRepository.cs
+30
-0
Freemud.BE.Toolbox.WebApi/Repository/EFCore/BEToolboxDbContext.cs
+13
-0
Freemud.BE.Toolbox.WebApi/Repository/EFCore/BaseRepository.cs
+17
-0
Freemud.BE.Toolbox.WebApi/Repository/EFCore/UserRepository.cs
+26
-0
Freemud.BE.Toolbox.WebApi/Repository/IUserRepository.cs
+19
-0
Freemud.BE.Toolbox.WebApi/Services/Impl/RequestResourceService.cs
+136
-4
Freemud.BE.Toolbox.WebApi/Startup.cs
+5
-0
Freemud.BE.Toolbox.WebApi/appsettings.json
+84
-2
freemud.be.toolboxview/src/views/requestresource/RequestResource.vue
+4
-4
No files found.
Freemud.BE.Toolbox.Testing/GeneralTest.cs
View file @
6e379702
...
...
@@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
using
System
;
using
System.Collections.Generic
;
using
System.Dynamic
;
using
System.Text.RegularExpressions
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -180,6 +181,44 @@ namespace Freemud.BE.Toolbox.Testing
Console
.
WriteLine
(
latitude
);
}
[
TestMethod
]
public
void
askldjaklsdjaklsjdkl
()
{
var
terms
=
"oOoAF0akswUMA732w-WnrBcKAXvI"
;
Console
.
WriteLine
(
DecideUserIdentityInfoTermsType
(
terms
));
terms
=
"oJeaRw1JJTcntaOESGvqj4owQuCE"
;
Console
.
WriteLine
(
DecideUserIdentityInfoTermsType
(
terms
));
terms
=
"13651812250"
;
Console
.
WriteLine
(
DecideUserIdentityInfoTermsType
(
terms
));
terms
=
"MEDDY981563130005221865"
;
Console
.
WriteLine
(
DecideUserIdentityInfoTermsType
(
terms
));
}
/// <summary>
/// 分析用户查询关键词类型
/// </summary>
/// <param name="terms"></param>
/// <returns></returns>
private
string
DecideUserIdentityInfoTermsType
(
string
terms
)
{
if
(
terms
.
StartsWith
(
"MEDDY"
))
return
"MemberId"
;
if
(
terms
.
StartsWith
(
"oJea"
))
return
"UnionId"
;
var
regex
=
new
Regex
(
"^1[34578]\\d{9}$"
);
if
(
regex
.
IsMatch
(
terms
))
return
"Mobile"
;
return
"Unknow"
;
}
}
public
class
Customer
...
...
Freemud.BE.Toolbox.WebApi/Freemud.BE.Toolbox.WebApi.csproj
View file @
6e379702
...
...
@@ -5,17 +5,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.35" />
<PackageReference Include="EasyCaching.InMemory" Version="0.8.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.6.20312.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RestSharp" Version="106.10.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
<PackageReference Include="UAParser" Version="3.1.44" />
</ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\Http\" />
<Folder Include="logs\" />
</ItemGroup>
</Project>
Freemud.BE.Toolbox.WebApi/Model/Constants/ToolboxConstants.cs
View file @
6e379702
...
...
@@ -16,5 +16,16 @@ namespace Freemud.BE.Toolbox.WebApi.Model.Constants
public
const
string
ENV_DEV
=
"dev"
;
public
const
string
ENV_PROD
=
"prod"
;
/// <summary>
/// 用户身份信息查询关键词类型枚举
/// </summary>
public
enum
UserIdentityInfoTermsEnum
{
Unknow
,
UnionId
,
MemberId
,
Mobile
}
}
}
Freemud.BE.Toolbox.WebApi/Model/Repository/UserIdentityInfo.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Model.Repository
{
public
class
UserIdentityInfo
{
public
string
UnionId
{
get
;
set
;
}
public
string
MemberId
{
get
;
set
;
}
public
string
Mobile
{
get
;
set
;
}
}
}
Freemud.BE.Toolbox.WebApi/Model/Request/GetUserCouponsRequest.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Model.Request
{
public
class
GetUserCouponsRequest
:
BaseRequestResourceRequest
{
/// <summary>
/// 手机号 / MemberId / UnionId
/// </summary>
public
string
Terms
{
get
;
set
;
}
}
}
Freemud.BE.Toolbox.WebApi/Model/Response/UserCardAdapter.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Model.Response
{
/// <summary>
/// 卡券适配类
/// </summary>
public
class
UserCardAdapter
{
/// <summary>
/// 券号
/// </summary>
public
string
Code
{
get
;
set
;
}
/// <summary>
/// 开始时间
/// </summary>
public
string
StartDate
{
get
;
set
;
}
/// <summary>
/// 结束时间
/// </summary>
public
string
EndDate
{
get
;
set
;
}
/// <summary>
/// 卡券Id
/// </summary>
public
string
CardId
{
get
;
set
;
}
/// <summary>
/// 卡券类型
/// 10:微信卡券
/// 20:ArchCard卡券
/// 30:Vendor卡券
/// </summary>
public
EnumCardType
CardType
{
get
;
set
;
}
/// <summary>
/// 是否权益卡(1 是权益卡)
/// </summary>
public
int
?
IsEquityCard
{
get
;
set
;
}
/// <summary>
/// ArchCard优惠券可用时段
/// </summary>
public
string
AvailableTimeDesc
{
get
;
set
;
}
public
UserCardAdapter
Clone
()
{
return
(
UserCardAdapter
)
MemberwiseClone
();
}
/// <summary>
/// 卡券类型
/// </summary>
public
enum
EnumCardType
{
/// <summary>
/// 微信卡券
/// </summary>
WeChat
=
10
,
/// <summary>
/// ArchCard卡券
/// </summary>
ArchCard
=
20
,
/// <summary>
/// 商家卡券
/// </summary>
VendorCard
=
30
}
}
}
Freemud.BE.Toolbox.WebApi/Model/ToolboxConfiguration.cs
View file @
6e379702
...
...
@@ -58,6 +58,10 @@ namespace Freemud.BE.Toolbox.WebApi.Model
public
string
CouponProd
{
get
;
set
;
}
public
string
ProductProd
{
get
;
set
;
}
public
string
DbConnectionDev
{
get
;
set
;
}
public
string
DbConnectionProd
{
get
;
set
;
}
}
public
class
RequestResourceConfiguration
...
...
Freemud.BE.Toolbox.WebApi/Proxy/FmCouponProxy.cs
View file @
6e379702
...
...
@@ -3,9 +3,12 @@ using Freemud.BE.Toolbox.WebApi.Model;
using
Freemud.BE.Toolbox.WebApi.Model.Constants
;
using
Freemud.BE.Toolbox.WebApi.Model.Request
;
using
Freemud.BE.Toolbox.WebApi.Model.Response
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Proxy
...
...
@@ -35,6 +38,112 @@ namespace Freemud.BE.Toolbox.WebApi.Proxy
}
}
private
Dictionary
<
string
,
object
>
GetArchCardRequestHeader
(
string
url
)
{
var
key
=
"Vo3R6t9oLjH3c"
;
var
headers
=
new
Dictionary
<
string
,
object
>();
headers
.
Add
(
"X-EACH-VENDOR-ID"
,
"105"
);
headers
.
Add
(
"X-EACH-APP-ID"
,
"member"
);
headers
.
Add
(
"X-EACH-SIGNATURE"
,
AES256
(
url
+
key
));
return
headers
;
}
private
Dictionary
<
string
,
object
>
GetWechatCardRequestHeader
(
string
url
,
string
content
)
{
var
key
=
"84Yex3c9mJU9c"
;
var
headers
=
new
Dictionary
<
string
,
object
>();
headers
.
Add
(
"X-EACH-VENDOR-ID"
,
"105"
);
headers
.
Add
(
"X-EACH-APP-ID"
,
"pickupcard"
);
headers
.
Add
(
"X-EACH-SIGNATURE"
,
AES256
(
url
+
content
+
key
));
return
headers
;
}
private
Dictionary
<
string
,
object
>
GetVendorCardRequestHeader
(
string
url
)
{
var
key
=
"84Yex3c9mJU9c"
;
var
headers
=
new
Dictionary
<
string
,
object
>();
headers
.
Add
(
"X-EACH-VENDOR-ID"
,
"105"
);
headers
.
Add
(
"X-EACH-APP-ID"
,
"pickupcard"
);
headers
.
Add
(
"X-EACH-SIGNATURE"
,
AES256
(
url
+
key
));
return
headers
;
}
/// <summary>
/// AES256 加密
/// </summary>
private
string
AES256
(
string
input
)
{
byte
[]
clearBytes
=
Encoding
.
UTF8
.
GetBytes
(
input
);
SHA256
sha256
=
new
SHA256Managed
();
sha256
.
ComputeHash
(
clearBytes
);
byte
[]
hashedBytes
=
sha256
.
Hash
;
sha256
.
Clear
();
string
output
=
BitConverter
.
ToString
(
hashedBytes
).
Replace
(
"-"
,
""
).
ToLower
();
return
output
;
}
/// <summary>
/// 获取用户麦钱包券
/// </summary>
/// <returns></returns>
public
async
Task
<
RequestResourceResponse
>
GetArchCardCoupons
(
string
env
,
string
channel
,
string
memberId
)
{
var
url
=
string
.
Format
(
GetUrl
(
env
,
"Archcard"
,
"getArchCardList"
),
memberId
,
channel
);
var
headers
=
GetArchCardRequestHeader
(
url
);
var
response
=
await
HttpHeper
.
Get
(
url
,
headers
);
return
new
RequestResourceResponse
{
Name
=
"趋佳麦钱包卡券列表查询"
,
Url
=
url
,
ResponseContent
=
response
.
Content
,
ResponseError
=
response
.
ErrorMessage
};
}
/// <summary>
/// 获取用户微信券
/// </summary>
/// <returns></returns>
public
async
Task
<
RequestResourceResponse
>
GetWechatCardCoupons
(
string
env
,
string
channel
,
string
unionid
)
{
var
url
=
string
.
Format
(
GetUrl
(
env
,
"WechatCard"
,
"coupon_list"
));
var
body
=
new
{
unionid
,
tag
=
channel
,
};
var
headers
=
GetWechatCardRequestHeader
(
url
,
JsonConvert
.
SerializeObject
(
body
));
var
response
=
await
HttpHeper
.
Post
(
url
,
headers
,
jsonBody
:
body
);
return
new
RequestResourceResponse
{
Name
=
"麦当劳微信卡券列表查询"
,
Url
=
url
,
ResponseContent
=
response
.
Content
,
ResponseError
=
response
.
ErrorMessage
};
}
/// <summary>
/// 获取用户商家券
/// </summary>
/// <returns></returns>
public
async
Task
<
RequestResourceResponse
>
GetVendorCardCoupons
(
string
env
,
string
channel
,
string
unionid
)
{
var
url
=
string
.
Format
(
GetUrl
(
env
,
"VendorCard"
,
"vendor_card_list"
),
unionid
,
channel
);
var
headers
=
GetVendorCardRequestHeader
(
url
);
var
response
=
await
HttpHeper
.
Get
(
url
,
headers
);
return
new
RequestResourceResponse
{
Name
=
"麦当劳商家卡券列表查询"
,
Url
=
url
,
ResponseContent
=
response
.
Content
,
ResponseError
=
response
.
ErrorMessage
};
}
/// <summary>
/// 查询券码信息
/// </summary>
...
...
@@ -70,5 +179,26 @@ namespace Freemud.BE.Toolbox.WebApi.Proxy
ResponseError
=
response
.
ErrorMessage
};
}
/// <summary>
/// 清空用户卡包(仅测试环境)
/// </summary>
/// <param name="memberId"></param>
/// <returns></returns>
public
async
Task
<
RequestResourceResponse
>
DeleteUserArchcards
(
string
memberId
)
{
var
url
=
GetUrl
(
ToolboxConstants
.
ENV_DEV
,
"Archcard"
,
"delUserCard"
);
var
body
=
new
{
user_id
=
memberId
};
var
response
=
await
HttpHeper
.
Post
(
url
,
jsonBody
:
body
);
return
new
RequestResourceResponse
{
Name
=
"清空用户卡包(仅测试环境)"
,
Url
=
url
,
RequestBody
=
body
,
ResponseContent
=
response
.
Content
,
ResponseError
=
response
.
ErrorMessage
};
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/Dapper/BaseRepository.cs
0 → 100644
View file @
6e379702
using
Freemud.BE.Toolbox.WebApi.Model
;
using
System
;
using
System.Data
;
using
System.Data.SqlClient
;
namespace
Freemud.BE.Toolbox.WebApi.Repository.Dapper
{
public
class
BaseRepository
{
private
readonly
ToolboxConfiguration
toolboxConfiguration
;
public
BaseRepository
(
ToolboxConfiguration
toolboxConfiguration
)
{
this
.
toolboxConfiguration
=
toolboxConfiguration
;
}
protected
IDbConnection
connection
{
get
{
return
GetConnection
(
string
.
Empty
);
}
}
protected
IDbConnection
GetConnection
(
string
env
)
{
var
connectionString
=
string
.
Empty
;
switch
(
env
)
{
case
"dev"
:
connectionString
=
toolboxConfiguration
.
Environments
.
DbConnectionDev
;
break
;
case
"prod"
:
connectionString
=
toolboxConfiguration
.
Environments
.
DbConnectionProd
;
break
;
default
:
throw
new
NotSupportedException
(
"数据库访问不支持"
);
}
return
new
SqlConnection
(
connectionString
);
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/Dapper/UserRepository.cs
0 → 100644
View file @
6e379702
using
Dapper
;
using
Freemud.BE.Toolbox.WebApi.Model
;
using
Freemud.BE.Toolbox.WebApi.Model.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Data.SqlClient
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Repository.Dapper
{
public
class
UserRepository
:
BaseRepository
,
IUserRepository
{
public
UserRepository
(
ToolboxConfiguration
toolboxConfiguration
)
:
base
(
toolboxConfiguration
)
{
}
/// <summary>
/// 根据用户 Mobile 或 MemberId 获取用户身份要素信息
/// </summary>
/// <param name="env">环境</param>
/// <param name="terms">关键词</param>
/// <returns></returns>
public
async
Task
<
UserIdentityInfo
>
GetUserIdentityInfo
(
string
env
,
string
terms
)
{
using
(
var
connection
=
GetConnection
(
env
))
{
return
await
connection
.
QueryFirstAsync
<
UserIdentityInfo
>(
"select top 1 u.UnionId, u.MemberId, u.Mobile from [User] u where u.Mobile = @terms or u.MemberId = @terms"
,
new
{
terms
});
}
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/EFCore/BEToolboxDbContext.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.EntityFrameworkCore
;
namespace
Freemud.BE.Toolbox.WebApi.Repository.EFCore
{
public
class
BEToolboxDbContext
:
DbContext
{
public
BEToolboxDbContext
(
DbContextOptions
<
BEToolboxDbContext
>
options
)
:
base
(
options
)
{
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/EFCore/BaseRepository.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Repository.EFCore
{
public
class
BaseRepository
{
protected
readonly
BEToolboxDbContext
dbContext
;
public
BaseRepository
(
BEToolboxDbContext
dbContext
)
{
this
.
dbContext
=
dbContext
;
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/EFCore/UserRepository.cs
0 → 100644
View file @
6e379702
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Data.SqlClient
;
using
System.Data
;
using
Freemud.BE.Toolbox.WebApi.Model.Repository
;
namespace
Freemud.BE.Toolbox.WebApi.Repository.EFCore
{
public
class
UserRepository
:
BaseRepository
,
IUserRepository
{
public
UserRepository
(
BEToolboxDbContext
dbContext
)
:
base
(
dbContext
)
{
}
/// <summary>
/// 根据用户 Mobile 或 MemberId 获取用户身份要素信息
/// </summary>
/// <param name="env">环境</param>
/// <param name="terms">关键词</param>
/// <returns></returns>
public
async
Task
<
UserIdentityInfo
>
GetUserIdentityInfo
(
string
env
,
string
terms
)
{
throw
new
NotImplementedException
();
}
}
}
Freemud.BE.Toolbox.WebApi/Repository/IUserRepository.cs
0 → 100644
View file @
6e379702
using
Freemud.BE.Toolbox.WebApi.Model.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Repository
{
public
interface
IUserRepository
{
/// <summary>
/// 根据用户 Mobile 或 MemberId 获取用户身份要素信息
/// </summary>
/// <param name="env">环境</param>
/// <param name="terms">关键词</param>
/// <returns></returns>
Task
<
UserIdentityInfo
>
GetUserIdentityInfo
(
string
env
,
string
terms
);
}
}
Freemud.BE.Toolbox.WebApi/Services/Impl/RequestResourceService.cs
View file @
6e379702
...
...
@@ -4,12 +4,14 @@ using Freemud.BE.Toolbox.WebApi.Model.Constants;
using
Freemud.BE.Toolbox.WebApi.Model.Request
;
using
Freemud.BE.Toolbox.WebApi.Model.Response
;
using
Freemud.BE.Toolbox.WebApi.Proxy
;
using
Freemud.BE.Toolbox.WebApi.Repository
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Services
...
...
@@ -17,13 +19,20 @@ namespace Freemud.BE.Toolbox.WebApi.Services
public
class
RequestResourceService
:
IRequestResourceService
{
private
readonly
ILogger
<
RequestResourceService
>
logger
;
private
readonly
IUserRepository
userRepository
;
private
readonly
FmCouponProxy
fmCouponProxy
;
private
readonly
FmProductProxy
fmProductProxy
;
private
readonly
FmStoreProxy
fmStoreProxy
;
public
RequestResourceService
(
ILogger
<
RequestResourceService
>
logger
,
FmCouponProxy
fmCouponProxy
,
FmProductProxy
fmProductProxy
,
FmStoreProxy
fmStoreProxy
)
public
RequestResourceService
(
ILogger
<
RequestResourceService
>
logger
,
IUserRepository
userRepository
,
FmCouponProxy
fmCouponProxy
,
FmProductProxy
fmProductProxy
,
FmStoreProxy
fmStoreProxy
)
{
this
.
logger
=
logger
;
this
.
userRepository
=
userRepository
;
this
.
fmCouponProxy
=
fmCouponProxy
;
this
.
fmProductProxy
=
fmProductProxy
;
this
.
fmStoreProxy
=
fmStoreProxy
;
...
...
@@ -65,12 +74,136 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
查询用户优惠券信息
/// <summary>
/// 分析用户查询关键词类型
/// </summary>
/// <param name="terms"></param>
/// <returns></returns>
private
ToolboxConstants
.
UserIdentityInfoTermsEnum
DecideUserIdentityInfoTermsType
(
string
terms
)
{
if
(
terms
.
StartsWith
(
"MEDDY"
))
return
ToolboxConstants
.
UserIdentityInfoTermsEnum
.
MemberId
;
//if (terms.StartsWith("oJea"))
// return ToolboxConstants.UserIdentityInfoTermsEnum.UnionId;
var
regex
=
new
Regex
(
"^1[34578]\\d{9}$"
);
if
(
regex
.
IsMatch
(
terms
))
return
ToolboxConstants
.
UserIdentityInfoTermsEnum
.
Mobile
;
return
ToolboxConstants
.
UserIdentityInfoTermsEnum
.
Unknow
;
}
/// <summary>
/// 获取用户优惠券信息
/// </summary>
/// <returns></returns>
public
async
Task
<
RequestResourceResponse
>
GetUserCoupons
()
public
async
Task
<
List
<
RequestResourceResponse
>>
GetUserCoupons
(
GetUserCouponsRequest
request
)
{
var
result
=
new
List
<
RequestResourceResponse
>();
var
termsType
=
DecideUserIdentityInfoTermsType
(
request
.
Terms
);
if
(
termsType
==
ToolboxConstants
.
UserIdentityInfoTermsEnum
.
Unknow
)
{
result
.
Add
(
new
RequestResourceResponse
{
Name
=
"查询词有误"
,
ResponseError
=
"查询关键词格式有误可接受: Mobile 或 MemberId"
});
}
else
{
var
userIdentityInfo
=
await
userRepository
.
GetUserIdentityInfo
(
request
.
Env
,
request
.
Terms
);
if
(
userIdentityInfo
==
null
)
{
result
.
Add
(
new
RequestResourceResponse
{
Name
=
"查询用户信息失败"
,
ResponseError
=
"查询用户信息失败"
});
}
else
{
logger
.
LogInformation
(
$"[GetUserCoupons] userIdentityInfo:
{
JsonConvert
.
SerializeObject
(
userIdentityInfo
)}
"
);
var
archCardsResponse
=
await
fmCouponProxy
.
GetArchCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
MemberId
);
var
wechatCardsResponse
=
await
fmCouponProxy
.
GetWechatCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
UnionId
);
var
vendorCardsResponse
=
await
fmCouponProxy
.
GetVendorCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
UnionId
);
var
userCards
=
new
List
<
UserCardAdapter
>();
// 麦钱包券
{
var
jo
=
JObject
.
Parse
(
archCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
var
data
=
JArray
.
Parse
(
jo
[
"data"
].
ToString
());
logger
.
LogInformation
(
$"[GetUserCoupons] archCardsResponse.data:
{
jo
[
"data"
].
ToString
()}
"
);
}
}
// 微信券
{
var
jo
=
JObject
.
Parse
(
wechatCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
var
data
=
JArray
.
Parse
(
jo
[
"data"
].
ToString
());
logger
.
LogInformation
(
$"[GetUserCoupons] wechatCardsResponse.data:
{
jo
[
"data"
].
ToString
()}
"
);
}
}
// 商家券
{
var
jo
=
JObject
.
Parse
(
vendorCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
var
data
=
JArray
.
Parse
(
jo
[
"data"
].
ToString
());
logger
.
LogInformation
(
$"[GetUserCoupons] vendorCardsResponse.data:
{
jo
[
"data"
].
ToString
()}
"
);
}
}
result
.
Add
(
archCardsResponse
);
result
.
Add
(
wechatCardsResponse
);
result
.
Add
(
vendorCardsResponse
);
}
}
return
result
;
}
/// <summary>
/// 删除用户麦钱包券(仅测试环境)
/// </summary>
/// <param name="terms">手机号 / MemberId</param>
/// <returns></returns>
public
async
Task
<
List
<
RequestResourceResponse
>>
DeleteUserArchCard
(
string
terms
)
{
throw
new
NotImplementedException
();
var
result
=
new
List
<
RequestResourceResponse
>();
var
termsType
=
DecideUserIdentityInfoTermsType
(
terms
);
if
(
termsType
==
ToolboxConstants
.
UserIdentityInfoTermsEnum
.
Unknow
)
{
result
.
Add
(
new
RequestResourceResponse
{
Name
=
"查询词有误"
,
ResponseError
=
"查询关键词格式有误可接受: Mobile 或 MemberId"
});
}
else
{
var
userIdentityInfo
=
await
userRepository
.
GetUserIdentityInfo
(
ToolboxConstants
.
ENV_DEV
,
terms
);
if
(
userIdentityInfo
==
null
)
{
result
.
Add
(
new
RequestResourceResponse
{
Name
=
"查询用户信息失败"
,
ResponseError
=
"查询用户信息失败"
});
}
else
{
var
response
=
await
fmCouponProxy
.
DeleteUserArchcards
(
userIdentityInfo
.
MemberId
);
result
.
Add
(
response
);
}
}
return
result
;
}
#
endregion
...
...
@@ -97,7 +230,6 @@ namespace Freemud.BE.Toolbox.WebApi.Services
public
async
Task
<
List
<
RequestResourceResponse
>>
GetStoreInfo
(
GetStoreInfoRequest
request
)
{
logger
.
LogInformation
(
"[GetStoreInfo] request: "
+
JsonConvert
.
SerializeObject
(
request
));
var
result
=
new
List
<
RequestResourceResponse
>();
var
storeCodes
=
string
.
Empty
;
var
isPosition
=
request
.
Terms
.
Contains
(
"."
);
...
...
Freemud.BE.Toolbox.WebApi/Startup.cs
View file @
6e379702
...
...
@@ -7,6 +7,8 @@ using Freemud.BE.Toolbox.WebApi.Middlewares;
using
Freemud.BE.Toolbox.WebApi.Model
;
using
Freemud.BE.Toolbox.WebApi.Model.Request
;
using
Freemud.BE.Toolbox.WebApi.Proxy
;
using
Freemud.BE.Toolbox.WebApi.Repository
;
using
Freemud.BE.Toolbox.WebApi.Repository.Dapper
;
using
Freemud.BE.Toolbox.WebApi.Services
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
...
...
@@ -47,6 +49,9 @@ namespace Freemud.BE.Toolbox.WebApi
services
.
AddSingleton
<
FmProductProxy
>();
services
.
AddSingleton
<
FmStoreProxy
>();
// Repositories
services
.
AddScoped
<
IUserRepository
,
UserRepository
>();
// Caching
services
.
AddEasyCaching
(
options
=>
options
.
UseInMemory
(
Configuration
,
"default"
,
"EasyCaching:InMemory"
));
services
.
AddSingleton
<
ICacheManager
,
MemoryCacheManager
>();
...
...
Freemud.BE.Toolbox.WebApi/appsettings.json
View file @
6e379702
...
...
@@ -49,7 +49,9 @@
"ProductDev"
:
"http://10.53.10.27:8092"
,
"ProductProd"
:
"http://10.52.16.40"
,
"CouponDev"
:
"http://10.53.10.10:12666"
,
"CouponProd"
:
"http://10.10.3.130"
"CouponProd"
:
"http://10.10.3.130"
,
"DbConnectionDev"
:
""
,
"DbConnectionProd"
:
""
},
"RequestResources"
:
[
{
...
...
@@ -113,6 +115,85 @@
"Description"
:
"根据经纬度返回餐厅门店"
}
]
},
{
"Name"
:
"Archcard"
,
"DevBaseUrl"
:
"https://debug.jaxcx.com"
,
"ProdBaseUrl"
:
"https://open.miniapp.mcdonalds.com.cn"
,
"Description"
:
"趋佳卡券"
,
"Resources"
:
[
{
"Name"
:
"getArchCardList"
,
"Path"
:
"/debug/mwallet/member/api/get_user_cards?member_no={0}&tag={1}"
,
"Description"
:
"趋佳麦钱包卡券列表查询"
},
{
"Name"
:
"getArchCardBrief"
,
"Path"
:
"/debug/mwallet/coupon/api/card_brief?card_id={0}"
,
"Description"
:
"趋佳麦钱包卡券元信息查询"
},
{
"Name"
:
"delUserCard"
,
"Path"
:
"/freemud/trial/delete_user_card"
,
"Description"
:
"清空用户卡包"
}
]
},
{
"Name"
:
"WechatCard"
,
"DevBaseUrl"
:
"https://flyer.jaxcx.com"
,
"ProdBaseUrl"
:
"https://flyer.jaxcx.com"
,
"Description"
:
"微信卡券"
,
"Resources"
:
[
{
"Name"
:
"coupon_list"
,
"Path"
:
"/api/wechat/user-cards"
,
"Description"
:
"麦当劳微信卡券列表查询"
},
{
"Name"
:
"coupon_info"
,
"Path"
:
"/api/wechat/cardcode-info"
,
"Description"
:
"麦当劳微信卡券详情查询"
},
{
"Name"
:
"fans_user_info"
,
"Path"
:
"/api/wechat/user-info?unionid={0}"
,
"Description"
:
"通过UnionId查询是否关注公众号(或粉丝情况)"
},
{
"Name"
:
"card-brief"
,
"Path"
:
"/api/wechat/card-brief?cardid={0}"
,
"Description"
:
"通过CardId查询卡券的使用须知、优惠说明、适用门店等信息"
}
]
},
{
"Name"
:
"VendorCard"
,
"DevBaseUrl"
:
"https://open.miniapp.mcdonalds.com.cn"
,
"ProdBaseUrl"
:
"https://open.miniapp.mcdonalds.com.cn"
,
"Description"
:
"商家券"
,
"Resources"
:
[
{
"Name"
:
"vendor_card_list"
,
"Path"
:
"/wechat/card/show_user_wallet?unionid={0}&tag={1}"
,
"Description"
:
"麦当劳商家卡券列表查询"
},
{
"Name"
:
"vendor_card_brief"
,
"Path"
:
"/wechat/card/get_card_brief?card_id={0}"
,
"Description"
:
"通过CardId查询卡券的使用须知、优惠说明、适用门店等信息"
},
{
"Name"
:
"vendor_card_info"
,
"Path"
:
"/wechat/card/get_code_info?unionid={0}&card_id={1}&code={2}"
,
"Description"
:
"麦当劳微信卡券详情查询"
},
{
"Name"
:
"vendor_decrypt_codes"
,
"Path"
:
"/wechat/card/decrypt_code"
,
"Description"
:
"卡券通过access_token解码多个加密code"
}
]
}
]
},
...
...
@@ -138,4 +219,4 @@
}
}
}
}
}
\ No newline at end of file
freemud.be.toolboxview/src/views/requestresource/RequestResource.vue
View file @
6e379702
...
...
@@ -8,10 +8,10 @@
<MenuItem
name=
"/coupon-product"
to=
"/request-resource/coupon-product"
>
<Icon
type=
"md-cube"
/>
码券商品信息
</MenuItem>
<
!--
<
MenuItem
name=
"/user-coupons"
to=
"/request-resource/user-coupons"
>
<MenuItem
name=
"/user-coupons"
to=
"/request-resource/user-coupons"
>
<Icon
type=
"md-cube"
/>
用户券数据
</MenuItem>
<MenuItem
name=
"/coupon-freeze"
to=
"/request-resource/coupon-freeze"
>
<
!--
<
MenuItem
name=
"/coupon-freeze"
to=
"/request-resource/coupon-freeze"
>
<Icon
type=
"md-cube"
/>
激活
&
冻结
</MenuItem>
-->
</MenuGroup>
...
...
@@ -20,11 +20,11 @@
<Icon
type=
"md-cube"
/>
商品信息查询
</MenuItem>
</MenuGroup>
<MenuGroup
title=
"订单"
>
<
!--
<
MenuGroup
title=
"订单"
>
<MenuItem
name=
"/order"
to=
"/request-resource/order"
>
<Icon
type=
"md-cube"
/>
根据订单编号查询订单
</MenuItem>
</MenuGroup>
</MenuGroup>
-->
<MenuGroup
title=
"门店"
>
<MenuItem
name=
"/candao-store"
to=
"/request-resource/candao-store"
>
<Icon
type=
"md-cube"
/>
门店信息
...
...
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