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
4b0641e3
Commit
4b0641e3
authored
Jun 10, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品导入调整
parent
c38f9893
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
302 additions
and
34 deletions
+302
-34
HttpHelper.cs
Mall.Common/Plugin/HttpHelper.cs
+96
-28
RB_Member_User_Extend.cs
Mall.Model/Extend/User/RB_Member_User_Extend.cs
+8
-0
ProductModule.cs
Mall.Module.Product/ProductModule.cs
+22
-3
UserModule.cs
Mall.Module.User/UserModule.cs
+117
-3
RB_GoodsRepository.cs
Mall.Repository/Product/RB_GoodsRepository.cs
+12
-0
AppletUserController.cs
Mall.WebApi/Controllers/User/AppletUserController.cs
+25
-0
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+22
-0
No files found.
Mall.Common/Plugin/HttpHelper.cs
View file @
4b0641e3
...
...
@@ -180,34 +180,6 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 把响应流转换为文本
/// </summary>
/// <param name="rsp"></param>
/// <param name="encoding"></param>
/// <returns></returns>
private
static
string
GetResponseAsStringBase64
(
HttpWebResponse
rsp
,
Encoding
encoding
)
{
System
.
IO
.
Stream
stream
=
null
;
try
{
// 以字符流的方式读取HTTP响应
stream
=
rsp
.
GetResponseStream
();
//return Common.Plugin.QRCodeHelper.ReadImageForStream(stream);//转成base 64返回
return
""
;
}
catch
(
Exception
)
{
return
""
;
}
finally
{
// 释放资源
if
(
stream
!=
null
)
stream
.
Close
();
if
(
rsp
!=
null
)
rsp
.
Close
();
}
}
/// <summary>
/// 把响应流转换为文本。
/// </summary>
...
...
@@ -288,5 +260,101 @@ namespace Mall.Common.Plugin
}
return
""
;
}
/// <summary>
/// 执行HTTP POST请求。
/// </summary>
/// <param name="url">请求地址</param>
/// <param name="postDataStr">请求地址</param>
/// <returns>HTTP响应</returns>
public
static
string
HttpPostForWXQRCode
(
string
url
,
string
postDataStr
)
{
HttpWebRequest
req
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
req
.
Method
=
"POST"
;
req
.
ContentType
=
"application/octet-stream"
;
req
.
ContentLength
=
Encoding
.
UTF8
.
GetByteCount
(
postDataStr
);
Stream
myRequestStream
=
req
.
GetRequestStream
();
StreamWriter
myStreamWriter
=
new
StreamWriter
(
myRequestStream
,
Encoding
.
GetEncoding
(
"gb2312"
));
myStreamWriter
.
Write
(
postDataStr
);
myStreamWriter
.
Close
();
HttpWebResponse
rsp
=
(
HttpWebResponse
)
req
.
GetResponse
();
if
(
string
.
IsNullOrWhiteSpace
(
rsp
.
CharacterSet
))
{
return
GetResponseAsStringBase64
(
rsp
,
Encoding
.
UTF8
);
}
else
{
Encoding
encoding
=
Encoding
.
GetEncoding
(
rsp
.
CharacterSet
);
return
GetResponseAsStringBase64
(
rsp
,
encoding
);
}
}
/// <summary>
/// 把响应流转换为文本
/// </summary>
/// <param name="rsp"></param>
/// <param name="encoding"></param>
/// <returns></returns>
private
static
string
GetResponseAsStringBase64
(
HttpWebResponse
rsp
,
Encoding
encoding
)
{
System
.
IO
.
Stream
stream
=
null
;
try
{
// 以字符流的方式读取HTTP响应
stream
=
rsp
.
GetResponseStream
();
return
ReadImageForStream
(
stream
);
//转成base 64返回
}
catch
{
return
""
;
}
finally
{
// 释放资源
if
(
stream
!=
null
)
stream
.
Close
();
if
(
rsp
!=
null
)
rsp
.
Close
();
}
}
/// <summary>
/// 获取
/// </summary>
/// <param name="imgstream"></param>
/// <returns></returns>
public
static
string
ReadImageForStream
(
Stream
imgstream
)
{
System
.
Drawing
.
Image
result
=
System
.
Drawing
.
Image
.
FromStream
(
imgstream
);
System
.
Drawing
.
Bitmap
bit
=
new
System
.
Drawing
.
Bitmap
(
result
);
return
bitmapToBase64
(
bit
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Png
);
}
/// <summary>
/// bitmap转 base64
/// </summary>
/// <param name="bmp1"></param>
/// <param name="imageFormat"></param>
/// <returns></returns>
public
static
string
bitmapToBase64
(
System
.
Drawing
.
Bitmap
bmp1
,
System
.
Drawing
.
Imaging
.
ImageFormat
imageFormat
)
{
string
UserPhoto
=
""
;
try
{
using
(
MemoryStream
ms1
=
new
MemoryStream
())
{
bmp1
.
Save
(
ms1
,
imageFormat
);
byte
[]
arr1
=
ms1
.
ToArray
();
UserPhoto
=
Convert
.
ToBase64String
(
arr1
);
}
}
catch
(
Exception
ex
)
{
UserPhoto
=
""
;
LogHelper
.
Write
(
ex
,
string
.
Format
(
"bitmapToBase64:"
));
}
return
UserPhoto
;
}
}
}
Mall.Model/Extend/User/RB_Member_User_Extend.cs
View file @
4b0641e3
...
...
@@ -46,6 +46,14 @@ namespace Mall.Model.Extend.User
/// 下线数量
/// </summary>
public
int
?
ReferralsNum
{
get
;
set
;
}
/// <summary>
/// 分销商名称
/// </summary>
public
string
DistributorName
{
get
;
set
;
}
/// <summary>
/// 分销商电话
/// </summary>
public
string
DistributorMobile
{
get
;
set
;
}
#
region
数据统计
-
分销排行字段
/// <summary>
...
...
Mall.Module.Product/ProductModule.cs
View file @
4b0641e3
...
...
@@ -4313,10 +4313,10 @@ namespace Mall.Module.Product
if
(
string
.
IsNullOrEmpty
(
item
.
Name
))
{
return
"有商品名称为空,无法导入"
;
}
if
((
item
.
OriginalPrice
??
0
)
<
=
0
)
{
if
((
item
.
OriginalPrice
??
0
)
<
0
)
{
return
"商品原价为空:"
+
item
.
Name
;
}
if
((
item
.
SellingPrice
??
0
)
<
=
0
)
{
if
((
item
.
SellingPrice
??
0
)
<
0
)
{
return
"商品售价为空:"
+
item
.
Name
;
}
if
(
string
.
IsNullOrEmpty
(
item
.
CoverImage
))
{
...
...
@@ -4409,7 +4409,7 @@ namespace Mall.Module.Product
item
.
GoodsNumbers
=
SpecificationPriceList
.
FirstOrDefault
()?.
no
??
""
;
item
.
GoodsWeight
=
SpecificationPriceList
.
FirstOrDefault
()?.
weight
??
0
;
}
//item.
Id = SpecificationPriceList.FirstOrDefault()?.goods_id ?? 0;
item
.
Goods
Id
=
SpecificationPriceList
.
FirstOrDefault
()?.
goods_id
??
0
;
}
catch
(
Exception
)
{
...
...
@@ -4438,6 +4438,21 @@ namespace Mall.Module.Product
{
return
"区域格式有误"
;
}
try
{
if
(
item
.
GoodsId
<=
0
)
{
return
"商品id不存在:"
+
item
.
Name
;
}
var
goodsModel
=
goodsRepository
.
GetEntity
(
item
.
GoodsId
);
if
(
goodsModel
!=
null
)
{
return
"商品id已存在:"
+
item
.
Name
+
" ,id:"
+
item
.
GoodsId
;
}
}
catch
(
Exception
)
{
return
"商品id获取出错了"
;
}
}
else
{
try
...
...
@@ -4655,6 +4670,10 @@ namespace Mall.Module.Product
bool
flag
=
Id
>
0
;
if
(
flag
)
{
if
(
demodel
.
GoodsId
>
0
)
{
goodsRepository
.
SetGoodsNewId
(
demodel
.
GoodsId
??
0
,
Id
,
trans
);
}
//插入分类
foreach
(
var
item
in
demodel
.
CategoryList
)
{
...
...
Mall.Module.User/UserModule.cs
View file @
4b0641e3
...
...
@@ -2025,7 +2025,7 @@ namespace Mall.Module.User
}
}
return
list
;
}
}
/// <summary>
/// 收货地址列表
...
...
@@ -2536,8 +2536,8 @@ namespace Mall.Module.User
}
//下线数量
int
oneNum
=
member_UserRepository
.
GetDistributorReferralsNumTwo
(
umodel
.
Id
,
1
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
int
twoNum
=
member_UserRepository
.
GetDistributorReferralsNumTwo
(
umodel
.
Id
,
1
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
int
threeNum
=
member_UserRepository
.
GetDistributorReferralsNumTwo
(
umodel
.
Id
,
1
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
int
twoNum
=
member_UserRepository
.
GetDistributorReferralsNumTwo
(
umodel
.
Id
,
2
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
int
threeNum
=
member_UserRepository
.
GetDistributorReferralsNumTwo
(
umodel
.
Id
,
3
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
var
CustomModel
=
distributor_CustomRepository
.
GetList
(
new
RB_Distributor_Custom_Extend
()
{
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
}).
FirstOrDefault
();
if
(
CustomModel
==
null
)
...
...
@@ -2596,6 +2596,13 @@ namespace Mall.Module.User
public
object
GetDistrbutorUpgradeConditions
(
AppletUserInfo
userInfo
)
{
var
model
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
UserId
=
userInfo
.
UserId
,
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
}).
FirstOrDefault
();
if
(
model
==
null
||
model
.
AuditStatus
!=
DistributorAuditStatusEnum
.
Audited
)
{
return
new
{
Status
=
2
,
GradeInfo
=
new
{
}
};
}
var
gmodel
=
distributor_GradeRepository
.
GetEntity
(
model
.
GradeId
);
var
upgmodel
=
distributor_GradeRepository
.
GetDistrbutorUpgrade
(
gmodel
?.
Grade
??
0
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
if
(
upgmodel
==
null
||
upgmodel
.
IsAutoUpGrade
!=
1
)
...
...
@@ -2631,6 +2638,75 @@ namespace Mall.Module.User
}
}
/// <summary>
/// 用户自行升级分销商等级
/// </summary>
/// <param name="gradeId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
string
SetUserDistrbutorUpgrade
(
int
gradeId
,
AppletUserInfo
userInfo
)
{
if
(
GetHpDistributorIsEnabled
(
userInfo
.
TenantId
,
userInfo
.
MallBaseId
)==
2
)
{
return
"和平分销无法自动升级"
;
}
var
model
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
UserId
=
userInfo
.
UserId
,
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
}).
FirstOrDefault
();
if
(
model
==
null
||
model
.
AuditStatus
!=
DistributorAuditStatusEnum
.
Audited
)
{
return
"您不是分销商,无法操作"
;
}
var
gmodel
=
distributor_GradeRepository
.
GetEntity
(
gradeId
);
if
(
gmodel
==
null
)
{
return
"该等级不存在,无法升级"
;
}
if
(
gmodel
.
IsAutoUpGrade
!=
1
)
{
return
"该等级不能自动升级"
;
}
if
(
gmodel
.
UpGradeCondition
==
DistrbutorGradeUpdateEnum
.
XXYHS
)
{
//验证下线数量
var
xxModel
=
member_UserRepository
.
GetDistributorReferralsNum
(
userInfo
.
UserId
.
ToString
(),
1
,
userInfo
.
TenantId
,
userInfo
.
MallBaseId
).
FirstOrDefault
();
if
(
xxModel
==
null
)
{
return
"您当前下线数量为0,无法升级"
;
}
if
((
xxModel
.
ReferralsNum
??
0
)
<
(
gmodel
.
ReferralsNumber
??
0
))
{
return
"您当前下线数量为"
+
(
xxModel
.
ReferralsNum
??
0
)
+
",无法升级"
;
}
}
else
if
(
gmodel
.
UpGradeCondition
==
DistrbutorGradeUpdateEnum
.
LJYJ
)
{
//验证累计佣金
if
((
model
.
TotalCommission
??
0
)
<
(
gmodel
.
TotalCommission
??
0
))
{
return
"您当前累计佣金为"
+
(
model
.
TotalCommission
??
0
)
+
",无法升级"
;
}
}
else
if
(
gmodel
.
UpGradeCondition
==
DistrbutorGradeUpdateEnum
.
YTXYJ
)
{
//验证已提现佣金
//已提现佣金 //未结算佣金
var
commModel
=
distributor_RemitRepository
.
GetDistributorCommissionStatiscs
(
userInfo
.
UserId
);
if
((
commModel
?.
TXCommission
??
0
)
<
(
gmodel
.
CommissionWithdrawn
??
0
))
{
return
"您当前已提现佣金为"
+
(
commModel
?.
TXCommission
??
0
)
+
",无法升级"
;
}
}
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Distributor_Info
.
GradeId
),
gradeId
},
{
nameof
(
RB_Distributor_Info
.
UpdateDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_Info
.
Id
),
FiledValue
=
gradeId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
distributor_InfoRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
return
""
;
}
return
"升级失败,请联系管理员"
;
}
/// <summary>
/// 获取提现余额
/// </summary>
...
...
@@ -3816,6 +3892,8 @@ namespace Mall.Module.User
foreach
(
var
item
in
list
)
{
var
disModel
=
DisList
.
Where
(
x
=>
x
.
UserId
==
item
.
Id
).
FirstOrDefault
();
//分销商信息
item
.
DistributorName
=
disModel
?.
Name
??
""
;
item
.
DistributorMobile
=
disModel
?.
Mobile
??
""
;
item
.
MemberGradeName
=
"默认等级"
;
if
(
HpEnabled
==
1
)
{
...
...
@@ -3845,6 +3923,8 @@ namespace Mall.Module.User
UserId
=
x
.
Id
,
x
.
Name
,
x
.
Moblie
,
x
.
DistributorName
,
x
.
DistributorMobile
,
GradeName
=
x
.
MemberGradeName
,
x
.
TotalCommission
,
CommissionWithdrawal
=
x
.
Price
,
...
...
@@ -3854,5 +3934,39 @@ namespace Mall.Module.User
}
#
endregion
#
region
获取小程序码
/// <summary>
/// 生成小程序码
/// </summary>
/// <param name="path"></param>
/// <param name="width"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
GetWeiXinQRCode
(
string
path
,
int
width
,
int
mallBaseId
)
{
var
appletWeChatModel
=
miniProgramRepository
.
GetEntity
(
mallBaseId
);
string
token
=
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Get
(
appletWeChatModel
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetLXYToken
(
token
,
appletWeChatModel
.
MiniAppId
,
appletWeChatModel
.
MiniAppSecret
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Set
(
appletWeChatModel
.
MiniAppId
,
token
));
}
if
(!
string
.
IsNullOrEmpty
(
token
))
{
string
GetImageUrl
=
"https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="
+
token
;
var
postData
=
new
{
path
,
width
};
var
Robj
=
HttpHelper
.
HttpPostForWXQRCode
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
));
var
Robj1
=
HttpHelper
.
HttpPost
(
GetImageUrl
,
JsonHelper
.
Serialize
(
postData
),
""
);
return
Robj
;
}
return
""
;
}
#
endregion
}
}
Mall.Repository/Product/RB_GoodsRepository.cs
View file @
4b0641e3
...
...
@@ -350,5 +350,17 @@ where {where} group by g.Id order by col.Id desc";
string
sql
=
$@"select g.Id,g. from RB_Goods g where
{
where
}
group by g.Id asc"
;
return
Get
<
RB_Goods_Extend
>(
sql
).
ToList
();
}
/// <summary>
/// 更新商品id
/// </summary>
/// <param name=""></param>
/// <param name="OldId"></param>
/// <returns></returns>
public
bool
SetGoodsNewId
(
int
newGoodsId
,
int
oldGoodsId
,
System
.
Data
.
IDbTransaction
trans
)
{
string
sql
=
$@"UPDATE rb_goods SET Id=
{
newGoodsId
}
WHERE Id=
{
oldGoodsId
}
"
;
return
Execute
(
sql
,
trans
)
>
0
;
}
}
}
Mall.WebApi/Controllers/User/AppletUserController.cs
View file @
4b0641e3
...
...
@@ -444,6 +444,31 @@ namespace Mall.WebApi.Controllers.User
return
ApiResult
.
Success
(
""
,
obj
);
}
/// <summary>
/// 设置用户自行升级分销商等级
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetUserDistrbutorUpgrade
()
{
var
userInfo
=
AppletUserInfo
;
var
req
=
RequestParm
;
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GradeId
=
prams
.
GetInt
(
"Id"
,
0
);
if
(
GradeId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
string
msg
=
userModule
.
SetUserDistrbutorUpgrade
(
GradeId
,
userInfo
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
/// <summary>
/// 获取提现余额
/// </summary>
...
...
Mall.WebApi/Controllers/User/UserController.cs
View file @
4b0641e3
...
...
@@ -2527,5 +2527,27 @@ namespace Mall.WebApi.Controllers.User
}
#
endregion
#
region
后台获取小程序码
/// <summary>
/// 获取微信小程序码
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetWeiXinQRCodeForHT
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
Path
=
parms
.
GetStringValue
(
"Path"
);
//路径
int
With
=
parms
.
GetInt
(
"With"
,
100
);
//大小
if
(
string
.
IsNullOrEmpty
(
Path
))
{
return
ApiResult
.
ParamIsNull
(
"请传递路径"
);
}
string
base64Img
=
userModule
.
GetWeiXinQRCode
(
Path
,
With
,
req
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
base64Img
);
}
#
endregion
}
}
\ 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