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
1e0c950a
Commit
1e0c950a
authored
May 13, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交小程序直播
parent
e6f22bc0
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1117 additions
and
52 deletions
+1117
-52
Config.cs
Mall.Common/Config.cs
+10
-1
StringHelper.cs
Mall.Common/Plugin/StringHelper.cs
+16
-14
WeiXinHelper.cs
Mall.Common/Plugin/WeiXinHelper.cs
+1
-1
RB_Live_House.cs
Mall.Model/Entity/AppletWeChat/RB_Live_House.cs
+70
-0
RB_Member_Subscription.cs
Mall.Model/Entity/User/RB_Member_Subscription.cs
+64
-0
RB_Live_House_Extend.cs
Mall.Model/Extend/AppletWeChat/RB_Live_House_Extend.cs
+26
-0
RB_Member_Subscription_Extend.cs
Mall.Model/Extend/User/RB_Member_Subscription_Extend.cs
+21
-0
Mall.Model.csproj
Mall.Model/Mall.Model.csproj
+0
-2
CouponModule.cs
Mall.Module.MarketingCenter/CouponModule.cs
+23
-11
MiniProgramModule.cs
Mall.Module.User/MiniProgramModule.cs
+430
-11
RB_Live_HouseRepository.cs
Mall.Repository/AppletWeChat/RB_Live_HouseRepository.cs
+68
-0
Mall.Repository.csproj
Mall.Repository/Mall.Repository.csproj
+0
-4
RB_Member_SubscriptionRepository.cs
Mall.Repository/User/RB_Member_SubscriptionRepository.cs
+62
-0
PublishController.cs
Mall.WebApi/Controllers/AppletWeChat/PublishController.cs
+316
-6
mall.oytour.com.pubxml.user
...pi/Properties/PublishProfiles/mall.oytour.com.pubxml.user
+5
-0
appsettings.json
Mall.WebApi/appsettings.json
+2
-1
web.config
Mall.WebApi/web.config
+3
-1
No files found.
Mall.Common/Config.cs
View file @
1e0c950a
...
...
@@ -308,6 +308,15 @@ namespace Mall.Common
return
new
ConfigurationBuilder
().
Add
(
new
JsonConfigurationSource
{
Path
=
"appsettings.json"
}).
Build
().
GetSection
(
"DeveloperKitsPort"
).
Value
;
}
}
/// <summary>
/// 小程序生成二维码跳转地址
/// </summary>
public
static
string
FirstPage
{
get
{
return
new
ConfigurationBuilder
().
Add
(
new
JsonConfigurationSource
{
Path
=
"appsettings.json"
}).
Build
().
GetSection
(
"FirstPage"
).
Value
;
}
}
}
}
\ No newline at end of file
Mall.Common/Plugin/StringHelper.cs
View file @
1e0c950a
...
...
@@ -194,6 +194,7 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 获取年份月份中的最后一天
/// </summary>
...
...
@@ -510,7 +511,8 @@ namespace Mall.Common.Plugin
{
TotalDay
=
Saturday
+
Sunday
+
2
;
}
else
{
else
{
TotalDay
=
Saturday
+
Sunday
+
1
;
}
}
...
...
@@ -567,22 +569,22 @@ namespace Mall.Common.Plugin
}
}
#
endregion
#
endregion
#
region
字符转换
#
region
字符转换
/// <summary>
/// 为字符串左边填充字符
/// <example>
/// 111 LPAD(,'0',8) --> 00000111
/// </example>
/// </summary>
/// <param name="str">字符串</param>
/// <param name="swap">替换的字符</param>
/// <param name="length">长度</param>
/// <returns></returns>
public
static
string
LPAD
(
object
str
,
string
swap
,
int
length
)
/// <summary>
/// 为字符串左边填充字符
/// <example>
/// 111 LPAD(,'0',8) --> 00000111
/// </example>
/// </summary>
/// <param name="str">字符串</param>
/// <param name="swap">替换的字符</param>
/// <param name="length">长度</param>
/// <returns></returns>
public
static
string
LPAD
(
object
str
,
string
swap
,
int
length
)
{
string
s
=
str
.
ToString
();
...
...
Mall.Common/Plugin/WeiXinHelper.cs
View file @
1e0c950a
...
...
@@ -6,7 +6,7 @@ namespace Mall.Common.Plugin
{
public
class
WeiXinHelper
{
}
/// <summary>
...
...
Mall.Model/Entity/AppletWeChat/RB_Live_House.cs
0 → 100644
View file @
1e0c950a
using
Mall.Common.AOP
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Entity.AppletWeChat
{
/// <summary>
/// 直播房间信息
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Live_House
{
/// <summary>
/// 房间号
/// </summary>
public
int
ID
{
get
;
set
;
}
/// <summary>
/// 商户id
/// </summary>
public
int
TenantId
{
get
;
set
;
}
/// <summary>
/// 小程序id
/// </summary>
public
int
MallBaseId
{
get
;
set
;
}
public
DateTime
CreateDate
{
get
;
set
;
}
/// <summary>
/// 房间名
/// </summary>
public
string
name
{
get
;
set
;
}
/// <summary>
/// 房间id
/// </summary>
public
string
roomid
{
get
;
set
;
}
/// <summary>
/// 直播间背景墙
/// </summary>
public
string
cover_img
{
get
;
set
;
}
/// <summary>
/// 直播状态
/// </summary>
public
string
live_status
{
get
;
set
;
}
/// <summary>
/// 直播计划开始时间
/// </summary>
public
string
start_time
{
get
;
set
;
}
/// <summary>
/// 直播计划结束时间
/// </summary>
public
string
end_time
{
get
;
set
;
}
/// <summary>
/// 主播名
/// </summary>
public
string
anchor_name
{
get
;
set
;
}
/// <summary>
/// 主播图片
/// </summary>
public
string
anchor_img
{
get
;
set
;
}
}
}
Mall.Model/Entity/User/RB_Member_Subscription.cs
0 → 100644
View file @
1e0c950a
using
Mall.Common.AOP
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Entity.User
{
/// <summary>
/// 会员订阅消息实体表
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Member_Subscription
{
/// <summary>
/// 编号
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 会员id
/// </summary>
public
int
?
UserId
{
get
;
set
;
}
/// <summary>
/// 订阅模板id
/// </summary>
public
string
TempleteId
{
get
;
set
;
}
/// <summary>
/// OpenId
/// </summary>
public
string
OpenId
{
get
;
set
;
}
/// <summary>
/// 类型 1赞羊
/// </summary>
public
int
?
Type
{
get
;
set
;
}
/// <summary>
/// 删除
/// </summary>
public
int
Status
{
get
;
set
;
}
/// <summary>
/// 次数
/// </summary>
public
int
?
Count
{
get
;
set
;
}
/// <summary>
/// 商户号id
/// </summary>
public
int
TenantId
{
get
;
set
;
}
/// <summary>
/// 小程序id
/// </summary>
public
int
MallBaseId
{
get
;
set
;
}
}
}
Mall.Model/Extend/AppletWeChat/RB_Live_House_Extend.cs
0 → 100644
View file @
1e0c950a
using
Mall.Model.Entity.AppletWeChat
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Extend.AppletWeChat
{
public
class
RB_Live_House_Extend
{
/// <summary>
/// errcode = 0 代表成功;errcode = 1 代表未创建直播房间
/// </summary>
public
string
errcode
{
get
;
set
;
}
public
string
errmsg
{
get
;
set
;
}
public
List
<
RB_Live_House
>
room_info
{
get
;
set
;
}
/// <summary>
/// 房间总数
/// </summary>
public
string
total
{
get
;
set
;
}
}
}
Mall.Model/Extend/User/RB_Member_Subscription_Extend.cs
0 → 100644
View file @
1e0c950a
using
Mall.Common.AOP
;
using
Mall.Model.Entity.User
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Extend.User
{
/// <summary>
/// 订阅消息扩展表
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Member_Subscription_Extend
:
RB_Member_Subscription
{
/// <summary>
/// 模板ids
/// </summary>
public
List
<
string
>
TempleteIdList
{
get
;
set
;
}
}
}
Mall.Model/Mall.Model.csproj
View file @
1e0c950a
...
...
@@ -10,8 +10,6 @@
<ItemGroup>
<Folder Include="CacheEntity\" />
<Folder Include="Entity\AppletWeChat\" />
<Folder Include="Extend\AppletWeChat\" />
</ItemGroup>
<ItemGroup>
...
...
Mall.Module.MarketingCenter/CouponModule.cs
View file @
1e0c950a
...
...
@@ -191,23 +191,35 @@ namespace Mall.Module.MarketingCenter
{
id
=
model
.
ID
;
flag
=
discountCouponRepository
.
Update
(
model
,
trans
);
var
listProduct
=
productRepository
.
GetCouponProductList
(
new
RB_DiscountCoupon_Product
{
TenantId
=
model
.
TenantId
,
MallBaseId
=
model
.
MallBaseId
,
DiscountCouponId
=
id
});
if
(
listProduct
!=
null
&&
listProduct
.
Any
())
{
foreach
(
var
item
in
model
.
ProductList
)
{
IDictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
IDictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_DiscountCoupon_Product
.
Status
),
1
},
{
nameof
(
RB_DiscountCoupon_Product
.
UpdateDate
),
model
.
UpdateDate
},
};
IList
<
WhereHelper
>
whereHelpers
=
new
List
<
WhereHelper
>()
IList
<
WhereHelper
>
whereHelpers
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_DiscountCoupon_Product
.
ID
),
FiledValue
=
item
.
ID
,
OperatorEnum
=
OperatorEnum
.
Equal
}
new
WhereHelper
(){
FiledName
=
nameof
(
RB_DiscountCoupon_Product
.
DiscountCouponId
),
FiledValue
=
id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
productRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
}
}
productRepository
.
Update
(
fileds
,
whereHelpers
,
trans
);
////var listProduct = productRepository.GetCouponProductList(new RB_DiscountCoupon_Product { TenantId = model.TenantId, MallBaseId = model.MallBaseId, DiscountCouponId = id });
////if (listProduct != null && listProduct.Any())
////{
//// foreach (var item in listProduct)
//// {
//// IDictionary<string, object> fileds = new Dictionary<string, object>()
//// {
//// { nameof(RB_DiscountCoupon_Product.Status),1},
//// { nameof(RB_DiscountCoupon_Product.UpdateDate),model.UpdateDate},
//// };
//// IList<WhereHelper> whereHelpers = new List<WhereHelper>()
//// {
//// new WhereHelper (){ FiledName=nameof(RB_DiscountCoupon_Product.ID),FiledValue=item.ID,OperatorEnum=OperatorEnum.Equal}
//// };
//// flag = productRepository.Update(fileds, whereHelpers, trans);
//// }
////}
if
(
model
.
ProductList
!=
null
&&
model
.
ProductList
.
Any
())
{
...
...
Mall.Module.User/MiniProgramModule.cs
View file @
1e0c950a
...
...
@@ -9,6 +9,7 @@ using Mall.CacheManager.AppletWeChat;
using
Newtonsoft.Json.Linq
;
using
Newtonsoft.Json
;
using
Mall.Common.Plugin
;
using
NPOI.SS.Formula.Functions
;
namespace
Mall.Module.User
{
...
...
@@ -32,6 +33,20 @@ namespace Mall.Module.User
/// </summary>
private
Repository
.
User
.
RB_MiniProgram_UserCenterMenuRepository
centerMenuRepository
=
new
Repository
.
User
.
RB_MiniProgram_UserCenterMenuRepository
();
/// <summary>
/// 会员订阅消息仓储层对象
/// </summary>
private
Repository
.
User
.
RB_Member_SubscriptionRepository
subscriptionRepository
=
new
Repository
.
User
.
RB_Member_SubscriptionRepository
();
/// <summary>
/// 会员仓储层对象
/// </summary>
private
Repository
.
User
.
RB_Member_UserRepository
userRepository
=
new
Repository
.
User
.
RB_Member_UserRepository
();
/// <summary>
/// 直播房间仓储层对象
/// </summary>
private
Repository
.
AppletWeChat
.
RB_Live_HouseRepository
liveHouseRepository
=
new
Repository
.
AppletWeChat
.
RB_Live_HouseRepository
();
#
region
小程序
/// <summary>
/// 根据查询条件获取小程序列表
...
...
@@ -205,7 +220,7 @@ namespace Mall.Module.User
/// <param name="isGetNav">是否获取顶部底部配置+底部标签导航(0-不获取,1-获取)</param>
/// <param name="isGetUserCenterMenu">是否获取用户中心菜单</param>
/// <returns></returns>
public
RB_MiniProgram_Extend
GetMiniProgramModule
(
object
MallBaseId
,
int
isGetNav
=
0
,
bool
isGetUserCenterMenu
=
false
)
public
RB_MiniProgram_Extend
GetMiniProgramModule
(
object
MallBaseId
,
int
isGetNav
=
0
,
bool
isGetUserCenterMenu
=
false
)
{
RB_MiniProgram_Extend
extModel
=
programRepository
.
GetEntity
<
RB_MiniProgram_Extend
>(
MallBaseId
);
if
(
extModel
==
null
)
...
...
@@ -490,6 +505,8 @@ namespace Mall.Module.User
#
endregion
#
region
微信小程序基础配置
...
...
@@ -518,6 +535,83 @@ namespace Mall.Module.User
#
region
发送小程序订阅信息
/// <summary>
/// 用户订阅消息
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
bool
SetMemberSubscribe
(
RB_Member_Subscription_Extend
demodel
)
{
var
gmodel
=
userRepository
.
GetEntity
(
demodel
.
UserId
);
if
(
gmodel
==
null
)
{
return
false
;
}
var
trans
=
subscriptionRepository
.
DbTransaction
;
try
{
foreach
(
var
item
in
demodel
.
TempleteIdList
)
{
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
demodel
.
OpenId
,
Type
=
1
,
TempleteId
=
item
,
MallBaseId
=
demodel
.
MallBaseId
,
TenantId
=
demodel
.
TenantId
});
if
(!
list
.
Any
())
{
subscriptionRepository
.
Insert
(
new
RB_Member_Subscription
()
{
UserId
=
demodel
.
UserId
,
Id
=
0
,
OpenId
=
demodel
.
OpenId
,
Status
=
0
,
TempleteId
=
item
,
Type
=
1
,
Count
=
1
,
MallBaseId
=
gmodel
.
MallBaseId
,
TenantId
=
gmodel
.
TenantId
},
trans
);
}
else
{
// 增加订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
++}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
,
trans
);
}
}
subscriptionRepository
.
DBSession
.
Commit
();
return
true
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetLXYGuestSubscribe"
);
subscriptionRepository
.
DBSession
.
Rollback
();
return
false
;
}
}
/// <summary>
/// 获取订阅模板数量
/// </summary>
/// <param name="openId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public
List
<
RB_Member_Subscription_Extend
>
GetLXYSubscribeCountList
(
string
openId
,
int
MallBaseId
,
int
TenantId
)
{
return
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
openId
,
Type
=
1
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
}
/// <summary>
/// 下单成功发送订阅消息
/// </summary>
...
...
@@ -570,7 +664,8 @@ namespace Mall.Module.User
{
value
=
GoodsName
}
}
},
miniprogram_state
=
"developer"
};
wenXinResult
=
HttpHelper
.
HttpPost
(
Url
,
JsonHelper
.
Serialize
(
postdata
),
""
);
...
...
@@ -578,7 +673,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
OrderSuccessTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -650,7 +762,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
OrderCancelTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -724,7 +853,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
OrderDeliverGoodsTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -796,7 +942,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
RefundTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -863,7 +1026,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
ActiveStateTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -933,7 +1113,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
AuditResultTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -1004,7 +1201,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
ReflectSuccessTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -1065,7 +1279,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
MallBaseId
=
MallBaseId
,
TempleteId
=
appletWeChatModel
.
ReflectFailTpl
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -1126,7 +1357,24 @@ namespace Mall.Module.User
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
{
//成功
var
list
=
subscriptionRepository
.
GetList
(
new
RB_Member_Subscription_Extend
()
{
OpenId
=
OpenId
,
Type
=
1
,
TempleteId
=
appletWeChatModel
.
MembersLevelChangeTpl
,
MallBaseId
=
MallBaseId
,
TenantId
=
TenantId
});
if
(
list
.
Any
())
{
// 减少订阅次数
var
model
=
list
.
FirstOrDefault
();
Dictionary
<
string
,
object
>
files
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_Subscription
.
Count
),
model
.
Count
>
0
?(
model
.
Count
--):
0
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Subscription
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
subscriptionRepository
.
Update
(
files
,
wheres
);
}
return
true
;
}
else
...
...
@@ -1167,7 +1415,178 @@ namespace Mall.Module.User
/// <summary>
/// 检查是否返回图片路径
/// </summary>
/// <param name="picStr"></param>
/// <param name="TCID"></param>
/// <param name="ConfigId"></param>
/// <returns></returns>
public
string
CheckWeiXinShareImg
(
string
picStr
,
RB_MiniProgram_Extend
model
,
string
jumpUrl
)
{
if
(
string
.
IsNullOrWhiteSpace
(
picStr
))
{
string
token
=
WeiXinReidsCache
.
Get
(
model
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
GetLXYToken
(
token
,
model
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
WeiXinReidsCache
.
Set
(
model
.
MiniAppId
,
token
));
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
return
""
;
}
picStr
=
GetWeiXinShare
(
model
,
jumpUrl
);
}
return
picStr
;
}
/// <summary>
/// 获取微信小程序分享
/// </summary>
/// <returns></returns>
public
string
GetWeiXinShare
(
RB_MiniProgram_Extend
model
,
string
jumpUrl
)
{
string
access_TokenStr
=
WeiXinReidsCache
.
Get
(
model
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
access_TokenStr
))
{
access_TokenStr
=
GetLXYToken
(
access_TokenStr
,
model
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
WeiXinReidsCache
.
Set
(
model
.
MiniAppId
,
access_TokenStr
));
}
string
picStr
=
string
.
Empty
;
if
(!
string
.
IsNullOrWhiteSpace
(
access_TokenStr
))
{
string
GetImageUrl
=
"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="
+
access_TokenStr
;
var
postData
=
new
{
scene
=
""
,
page
=
jumpUrl
,
width
=
"100"
,
is_hyaline
=
true
};
picStr
=
HttpHelper
.
HttpPost
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
));
//if (string.IsNullOrWhiteSpace(picStr))
//{
// picStr = CheckWeiXinShareImg(picStr, model, jumpUrl);
//}
}
return
picStr
;
}
#
endregion
#
region
小程序直播房间信息
/// <summary>
/// 获取直播房间信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public
bool
GetLiveInfo
(
RB_MiniProgram_Extend
model
)
{
string
token
=
WeiXinReidsCache
.
Get
(
model
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
GetLXYToken
(
token
,
model
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
WeiXinReidsCache
.
Set
(
model
.
MiniAppId
,
token
));
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
return
false
;
}
string
wenXinResult
=
string
.
Empty
;
if
(!
string
.
IsNullOrWhiteSpace
(
token
))
{
string
Url
=
" http://api.weixin.qq.com/wxa/business/getliveinfo?access_token="
+
token
;
var
postdata
=
new
{
start
=
0
,
limit
=
100
};
wenXinResult
=
HttpHelper
.
HttpPost
(
Url
,
JsonHelper
.
Serialize
(
postdata
),
""
);
var
newLiveHouse
=
JsonConvert
.
DeserializeObject
<
Model
.
Extend
.
AppletWeChat
.
RB_Live_House_Extend
>(
wenXinResult
);
//JObject jo = (JObject)JsonConvert.DeserializeObject(wenXinResult);
//int errcode = Convert.ToInt32(jo["errcode"].ToString());
if
(
newLiveHouse
.
errcode
==
"0"
)
{
newLiveHouse
.
room_info
.
ForEach
(
x
=>
x
.
TenantId
=
model
.
TenantId
??
0
);
newLiveHouse
.
room_info
.
ForEach
(
x
=>
x
.
MallBaseId
=
model
.
MallBaseId
);
newLiveHouse
.
room_info
.
ForEach
(
x
=>
x
.
CreateDate
=
System
.
DateTime
.
Now
);
AddLiveHouse
(
newLiveHouse
.
room_info
,
new
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
{
TenantId
=
model
.
TenantId
??
0
,
MallBaseId
=
model
.
MallBaseId
});
return
true
;
}
else
{
LogHelper
.
Write
(
string
.
Format
(
"SendMemberLevelMsg:wenXinResult:{0}"
,
wenXinResult
));
}
}
return
false
;
}
/// <summary>
/// 获取直播房间
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
>
GetLiveHouseListRepository
(
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
query
)
{
return
liveHouseRepository
.
GetLiveHouseListRepository
(
query
);
}
/// <summary>
/// 获取直播房间
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
>
GetLiveHousePageList
(
int
pageIndex
,
int
pageSize
,
out
long
rowCount
,
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
query
)
{
return
liveHouseRepository
.
GetLiveHousePageList
(
pageIndex
,
pageSize
,
out
rowCount
,
query
);
}
/// <summary>
/// 获取直播房间信息
/// </summary>
/// <param name="list"></param>
/// <param name="query"></param>
/// <returns></returns>
public
bool
AddLiveHouse
(
List
<
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
>
list
,
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
query
)
{
try
{
var
oldList
=
liveHouseRepository
.
GetLiveHouseListRepository
(
query
);
//获取之前的
if
(
oldList
!=
null
&&
oldList
.
Any
())
{
liveHouseRepository
.
DeleteBatch
(
oldList
);
}
if
(
list
!=
null
&&
list
.
Any
())
{
liveHouseRepository
.
InsertBatch
(
list
);
}
return
true
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"AddLiveHouse"
);
return
false
;
}
}
#
endregion
}
}
Mall.Repository/AppletWeChat/RB_Live_HouseRepository.cs
0 → 100644
View file @
1e0c950a
using
Mall.Model.Entity.AppletWeChat
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Mall.Repository.AppletWeChat
{
/// <summary>
/// 直播房间仓储层
/// </summary>
public
class
RB_Live_HouseRepository
:
RepositoryBase
<
RB_Live_House
>
{
/// <summary>
/// 表名称
/// </summary>
public
string
TableName
{
get
{
return
nameof
(
RB_Live_House
);
}
}
/// <summary>
/// 获取直播房间
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_Live_House
>
GetLiveHouseListRepository
(
RB_Live_House
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
$" SELECT * FROM
{
TableName
}
WHERE 1=1"
);
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Live_House
.
TenantId
)}
=
{
query
.
TenantId
}
"
);
}
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Live_House
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
);
}
}
return
Get
<
RB_Live_House
>(
builder
.
ToString
()).
ToList
();
}
/// <summary>
/// 获取直播房间
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_Live_House
>
GetLiveHousePageList
(
int
pageIndex
,
int
pageSize
,
out
long
rowCount
,
RB_Live_House
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
$" SELECT * FROM
{
TableName
}
WHERE 1=1"
);
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Live_House
.
TenantId
)}
=
{
query
.
TenantId
}
"
);
}
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Live_House
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
);
}
}
return
GetPage
<
RB_Live_House
>(
pageIndex
,
pageSize
,
out
rowCount
,
builder
.
ToString
()).
ToList
();
}
}
}
Mall.Repository/Mall.Repository.csproj
View file @
1e0c950a
...
...
@@ -21,8 +21,4 @@
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="AppletWeChat\" />
</ItemGroup>
</Project>
Mall.Repository/User/RB_Member_SubscriptionRepository.cs
0 → 100644
View file @
1e0c950a
using
Mall.Model.Entity.User
;
using
Mall.Model.Extend.User
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Mall.Repository.User
{
/// <summary>
/// 会员订阅微信消息仓储层
/// </summary>
public
class
RB_Member_SubscriptionRepository
:
RepositoryBase
<
RB_Member_Subscription
>
{
/// <summary>
/// 表名称
/// </summary>
public
string
TableName
{
get
{
return
nameof
(
RB_Member_Subscription
);
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public
List
<
RB_Member_Subscription_Extend
>
GetList
(
RB_Member_Subscription_Extend
where
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
Append
(
$@"SELECT * from
{
TableName
}
where Status=0"
);
if
(
where
!=
null
)
{
if
(
where
.
MallBaseId
>
0
)
{
sb
.
AppendFormat
(
" and MallBaseId={0}"
,
where
.
MallBaseId
);
}
if
(
where
.
TenantId
>
0
)
{
sb
.
AppendFormat
(
" and TenantId={0}"
,
where
.
TenantId
);
}
if
(
where
.
UserId
>
0
)
{
sb
.
AppendFormat
(
" and UserId={0}"
,
where
.
UserId
);
}
if
(
where
.
Type
>
0
)
{
sb
.
AppendFormat
(
" and Type={0}"
,
where
.
Type
);
}
if
(!
string
.
IsNullOrEmpty
(
where
.
TempleteId
))
{
sb
.
AppendFormat
(
" and TempleteId ='{0}'"
,
where
.
TempleteId
);
}
if
(!
string
.
IsNullOrEmpty
(
where
.
OpenId
))
{
sb
.
AppendFormat
(
" and OpenId ='{0}'"
,
where
.
OpenId
);
}
}
return
Get
<
RB_Member_Subscription_Extend
>(
sb
.
ToString
()).
ToList
();
}
}
}
Mall.WebApi/Controllers/AppletWeChat/PublishController.cs
View file @
1e0c950a
...
...
@@ -3,12 +3,16 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Google.Protobuf.WellKnownTypes
;
using
Mall.CacheManager.AppletWeChat
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.User
;
using
Mall.Module.User
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.AppletWeChat
...
...
@@ -23,7 +27,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
private
MiniProgramModule
appletWeChatModule
=
new
MiniProgramModule
();
string
projectUrl
=
Mall
.
Common
.
Config
.
ProjectUrl
;
string
developerKitsPort
=
Mall
.
Common
.
Config
.
DeveloperKitsPort
;
string
FirstPage
=
Mall
.
Common
.
Config
.
FirstPage
;
/// <summary>
/// 发布微信小程序获取登录二维码
...
...
@@ -71,14 +75,17 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{
string
URL
=
$"http://127.0.0.1:
{
developerKitsPort
}
/v2/preview?project=
{
Mall
.
Common
.
Plugin
.
StringHelper
.
UrlEncode
(
projectUrl
)}
&qr-format=base64"
;
string
result
=
Mall
.
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
URL
,
Encoding
.
UTF8
,
""
);
JObject
parmsJob
=
JObject
.
Parse
(
result
);
if
(
parmsJob
.
ContainsKey
(
"code"
))
if
(
result
.
Length
>
200
&&
!
result
.
Contains
(
"data:image/png;base64,"
))
{
re
turn
ApiResult
.
Failed
(
parmsJob
.
GetValue
(
"message"
).
ToString
())
;
re
sult
=
"data:image/png;base64,"
+
result
;
}
if
(!
result
.
Contains
(
"data:image/png;base64,"
))
else
{
result
=
"data:image/png;base64,"
+
result
;
JObject
parmsJob
=
JObject
.
Parse
(
result
);
if
(
parmsJob
.
ContainsKey
(
"code"
))
{
return
ApiResult
.
Failed
(
parmsJob
.
GetValue
(
"message"
).
ToString
());
}
}
return
ApiResult
.
Success
(
"获取成功"
,
result
);
}
...
...
@@ -122,5 +129,308 @@ namespace Mall.WebApi.Controllers.AppletWeChat
return
ApiResult
.
Failed
(
"上传失败"
);
}
}
/// <summary>
/// 获取微信小程序分享
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
virtual
ApiResult
GetWeiXinShare
()
{
var
parms
=
RequestParm
;
var
query
=
new
RB_MiniProgram_Extend
();
query
.
TenantId
=
UserInfo
.
TenantId
;
query
.
MallBaseId
=
parms
.
MallBaseId
;
var
appletWeChatModel
=
appletWeChatModule
.
GetTenantListModule
(
query
).
FirstOrDefault
();
string
imgBase64
=
appletWeChatModule
.
GetWeiXinShare
(
appletWeChatModel
,
FirstPage
);
return
ApiResult
.
Success
(
""
,
imgBase64
);
}
/// <summary>
/// 订阅消息推送
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetLXYSubscribeSend
()
{
var
parmsInfo
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
string
code
=
parms
.
GetStringValue
(
"code"
);
if
(
string
.
IsNullOrWhiteSpace
(
code
))
{
return
ApiResult
.
Failed
(
"请传递code参数"
);
}
var
appletWeChatModel
=
appletWeChatModule
.
GetTenantListModule
(
new
RB_MiniProgram_Extend
{
TenantId
=
Convert
.
ToInt32
(
parmsInfo
.
uid
),
MallBaseId
=
parmsInfo
.
MallBaseId
}).
FirstOrDefault
();
string
OpenId
=
"ow_7I5XC1-RGwwk8QANBmWKYKmOc"
;
//GetHelpByWx(code, appletWeChatModel);
bool
flag
=
appletWeChatModule
.
SendOrderSucceedMsg
(
Convert
.
ToInt32
(
parmsInfo
.
uid
),
parmsInfo
.
MallBaseId
,
OpenId
,
"1176"
,
"2020-05-12 14:01:12"
,
"微信"
,
"测试商品请勿购买"
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
/// <summary>
/// 设置客户订阅信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetGuestSubscribe
()
{
RB_Member_Subscription_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Member_Subscription_Extend
>(
RequestParm
.
msg
.
ToString
());
if
((
demodel
.
UserId
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递会员id"
);
}
if
(
string
.
IsNullOrEmpty
(
demodel
.
OpenId
))
{
return
ApiResult
.
ParamIsNull
(
"请传递微信openid"
);
}
if
(
demodel
.
TempleteIdList
==
null
||
!
demodel
.
TempleteIdList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递会员订阅的模板id"
);
}
bool
flag
=
appletWeChatModule
.
SetMemberSubscribe
(
demodel
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
/// <summary>
/// 获取订阅模块列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetSubscribeTempleteList
(
RequestParm
request
)
{
List
<
object
>
tlist
=
GetTempleteList
();
return
ApiResult
.
Success
(
""
,
tlist
);
}
/// <summary>
/// 获取templete
/// </summary>
/// <returns></returns>
private
static
List
<
object
>
GetTempleteList
()
{
return
new
List
<
object
>()
{
new
{
TempleteId
=
"WPELErDfYO3JnizA5Zikta6Y8qrBBAgecuj2aLoucuY"
,
Name
=
"下单成功提醒"
},
new
{
TempleteId
=
"pCmTJwvTqNpyRREo7vvqIYBcrATNWoitfbLS61fLhzU"
,
Name
=
"订单取消通知"
},
new
{
TempleteId
=
"i6QPsaOHgfNwlIRMwmvFGSCqX28g0cRa8XaLZ5_gpgc"
,
Name
=
"订单发货通知"
},
new
{
TempleteId
=
"o_zwbbXqC5nJLEzXVVvgCT3LUHnBCkxWxkT6D1HhQXU"
,
Name
=
"退款通知"
},
new
{
TempleteId
=
"nwYnuXeMF-XuUHkf_MgJFdfy9Gic1jnj6lYR6W9KOnQ"
,
Name
=
"活动状态通知"
},
new
{
TempleteId
=
"mUcV9nOOZ-MrcUmXH157YRdnFEh8_Tcz8lWhjgeHhHE"
,
Name
=
"审核结果通知"
},
new
{
TempleteId
=
"STLsTw3R86aMtVbcYgU_UZbxj_Tn0h3rIJwZRSrLmGQ"
,
Name
=
"提现成功通知"
},
new
{
TempleteId
=
"fqwGB0769qgJYQOaqqE1uKC6PS3Vp47J3jGMW3BXBrw"
,
Name
=
"提现失败通知"
},
new
{
TempleteId
=
"8QhIQmzdDXDxKWMnE6aa_t3VPxah0EGTmLhA-JQcSwc"
,
Name
=
"会员等级变更通知"
}
};
}
/// <summary>
/// 订阅剩余次数
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetSubscribeCountList
()
{
var
parms
=
RequestParm
;
JObject
parmsJob
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
string
OpenId
=
parmsJob
.
GetStringValue
(
"OpenId"
);
var
query
=
new
RB_Member_Subscription_Extend
();
query
.
TenantId
=
UserInfo
.
TenantId
;
query
.
MallBaseId
=
parms
.
MallBaseId
;
if
(
string
.
IsNullOrEmpty
(
OpenId
))
{
return
ApiResult
.
Failed
();
}
var
tlist
=
GetTempleteList
();
var
list
=
appletWeChatModule
.
GetLXYSubscribeCountList
(
OpenId
,
query
.
MallBaseId
,
query
.
TenantId
);
List
<
object
>
robj
=
new
List
<
object
>();
foreach
(
var
item
in
tlist
)
{
JObject
parm
=
JObject
.
Parse
(
JsonConvert
.
SerializeObject
(
item
));
string
TempleteId
=
parm
.
GetStringValue
(
"TempleteId"
);
string
Name
=
parm
.
GetStringValue
(
"Name"
);
var
model
=
list
.
Where
(
x
=>
x
.
TempleteId
==
TempleteId
).
FirstOrDefault
();
robj
.
Add
(
new
{
Name
,
TempleteId
,
Count
=
model
?.
Count
??
0
,
});
}
return
ApiResult
.
Success
(
""
,
robj
);
}
#
region
微信获取
openid
//微信也不给个c#调用的例子
/// <summary>
/// 根据code 获取微信信息
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public
string
GetHelpByWx
(
string
code
,
RB_MiniProgram_Extend
model
)
{
string
Appid
=
model
.
MiniAppId
;
string
Secret
=
model
.
MiniAppSecret
;
string
grant_type
=
"authorization_code"
;
//向微信服务端 使用登录凭证 code 获取 session_key 和 openid
string
url
=
"https://api.weixin.qq.com/sns/jscode2session?appid="
+
Appid
+
"&secret="
+
Secret
+
"&js_code="
+
code
+
"&grant_type="
+
grant_type
;
string
type
=
"utf-8"
;
GetUsersHelper
GetUsersHelper
=
new
GetUsersHelper
();
string
wenXinResult
=
string
.
Empty
;
JObject
jo
=
null
;
result
res
=
new
result
();
try
{
wenXinResult
=
GetUsersHelper
.
GetUrltoHtml
(
url
,
type
);
//获取微信服务器返回字符串
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
//将字符串转换为json格式
//微信服务器验证成功
res
.
openid
=
jo
[
"openid"
].
ToString
();
res
.
session_key
=
jo
[
"session_key"
].
ToString
();
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetWx:wenXinResult:{0},code:{1}"
,
wenXinResult
,
code
));
//微信服务器验证失败
res
.
errcode
=
jo
[
"errcode"
].
ToString
();
res
.
errmsg
=
jo
[
"errmsg"
].
ToString
();
}
return
res
.
openid
;
}
#
endregion
#
region
获取微信直播房间信息
/// <summary>
/// 获取直播房间列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetLiveInfo
()
{
var
parmsInfo
=
RequestParm
;
var
appletWeChatModel
=
appletWeChatModule
.
GetTenantListModule
(
new
RB_MiniProgram_Extend
{
TenantId
=
Convert
.
ToInt32
(
parmsInfo
.
uid
),
MallBaseId
=
parmsInfo
.
MallBaseId
}).
FirstOrDefault
();
bool
flag
=
appletWeChatModule
.
GetLiveInfo
(
appletWeChatModel
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
[
HttpPost
]
public
ApiResult
GetLiveHousePageList
()
{
var
parms
=
RequestParm
;
ResultPageModel
pagelist
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
RequestParm
.
msg
.
ToString
());
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
demodel
=
JsonConvert
.
DeserializeObject
<
Model
.
Entity
.
AppletWeChat
.
RB_Live_House
>(
RequestParm
.
msg
.
ToString
());
demodel
.
TenantId
=
UserInfo
.
TenantId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
appletWeChatModule
.
GetLiveHousePageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
demodel
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
.
Select
(
x
=>
new
{
x
.
ID
,
x
.
roomid
,
x
.
name
,
x
.
anchor_img
,
x
.
anchor_name
,
x
.
cover_img
,
x
.
live_status
,
start_time
=
GetTime
(
x
.
start_time
),
end_time
=
GetTime
(
x
.
end_time
),
});
return
ApiResult
.
Success
(
""
,
pagelist
);
}
/// <summary>
/// 时间戳转为C#格式时间
/// </summary>
/// <param name="timeStamp">Unix时间戳格式</param>
/// <returns>C#格式时间</returns>
public
static
string
GetTime
(
string
timeStamp
)
{
try
{
DateTime
dtStart
=
TimeZone
.
CurrentTimeZone
.
ToLocalTime
(
new
DateTime
(
1970
,
1
,
1
));
long
lTime
=
long
.
Parse
(
timeStamp
+
"0000000"
);
TimeSpan
toNow
=
new
TimeSpan
(
lTime
);
return
dtStart
.
Add
(
toNow
).
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
}
catch
(
Exception
)
{
return
""
;
}
}
#
endregion
}
}
\ No newline at end of file
Mall.WebApi/Properties/PublishProfiles/mall.oytour.com.pubxml.user
View file @
1e0c950a
...
...
@@ -8,4 +8,9 @@
<TimeStampOfAssociatedLegacyPublishXmlFile
/>
<_PublishTargetUrl>
F:\网站发布\Mall.oytour.com
</_PublishTargetUrl>
</PropertyGroup>
<ItemGroup>
<File
Include=
"run.cmd"
>
<publishTime>
04/22/2020 10:26:33
</publishTime>
</File>
</ItemGroup>
</Project>
\ No newline at end of file
Mall.WebApi/appsettings.json
View file @
1e0c950a
...
...
@@ -22,7 +22,8 @@
"Mongo"
:
"mongodb://192.168.2.214:27017"
,
"MongoDBName"
:
"Mall"
,
"ProjectUrl"
:
"D:/project/GitProject/tripfriend"
,
"DeveloperKitsPort"
:
"54333"
,
"DeveloperKitsPort"
:
"63994"
,
"FirstPage"
:
"pages/index/index.html"
,
"RedisSetting"
:
{
"RedisServer"
:
"192.168.2.214"
,
"RedisPort"
:
"6379"
,
...
...
Mall.WebApi/web.config
View file @
1e0c950a
...
...
@@ -5,9 +5,11 @@
<
handlers
>
<
add
name
=
"aspNetCore"
path
=
"*"
verb
=
"*"
modules
=
"AspNetCoreModuleV2"
resourceType
=
"Unspecified"
/>
</
handlers
>
<
aspNetCore
processPath
=
"
.\Mall.WebApi.exe"
arguments
=
".\Mall.WebApi.dll"
stdoutLogEnabled
=
"false"
stdoutLogFile
=
".\logs\stdout"
hostingModel
=
"OutOf
Process"
>
<
aspNetCore
processPath
=
"
%LAUNCHER_PATH%"
arguments
=
"%LAUNCHER_ARGS%"
stdoutLogEnabled
=
"false"
stdoutLogFile
=
".\logs\stdout"
hostingModel
=
"In
Process"
>
<
environmentVariables
>
<
environmentVariable
name
=
"ASPNETCORE_ENVIRONMENT"
value
=
"Development"
/>
<
environmentVariable
name
=
"ASPNETCORE_HTTPS_PORT"
value
=
"44370"
/>
<
environmentVariable
name
=
"COMPLUS_ForceENC"
value
=
"1"
/>
</
environmentVariables
>
</
aspNetCore
>
</
system
.
webServer
>
...
...
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