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
7a6ccd88
Commit
7a6ccd88
authored
May 14, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序下单
parent
2ab772a8
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
939 additions
and
9 deletions
+939
-9
RB_Goods_Order.cs
Mall.Model/Entity/Product/RB_Goods_Order.cs
+8
-0
RB_DiscountCoupon_Extend.cs
....Model/Extend/MarketingCenter/RB_DiscountCoupon_Extend.cs
+4
-0
RB_Goods_OrderDetail_Extend.cs
Mall.Model/Extend/Product/RB_Goods_OrderDetail_Extend.cs
+24
-0
RB_Goods_Order_Extend.cs
Mall.Model/Extend/Product/RB_Goods_Order_Extend.cs
+2
-1
RB_Member_DiscountCoupon_Extend.cs
Mall.Model/Extend/User/RB_Member_DiscountCoupon_Extend.cs
+4
-0
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+825
-6
RB_DiscountCouponRepository.cs
...Repository/MarketingCenter/RB_DiscountCouponRepository.cs
+4
-0
RB_GoodsRepository.cs
Mall.Repository/Product/RB_GoodsRepository.cs
+24
-0
RB_Member_CouponRepository.cs
Mall.Repository/User/RB_Member_CouponRepository.cs
+38
-0
AppletOrderController.cs
Mall.WebApi/Controllers/Product/AppletOrderController.cs
+4
-1
OrderController.cs
Mall.WebApi/Controllers/Product/OrderController.cs
+2
-1
No files found.
Mall.Model/Entity/Product/RB_Goods_Order.cs
View file @
7a6ccd88
...
...
@@ -268,6 +268,14 @@ namespace Mall.Model.Entity.Product
/// </summary>
public
DateTime
?
ReceivingTime
{
get
;
set
;
}
/// <summary>
/// 完成时间
/// </summary>
public
DateTime
?
FinishTime
{
get
;
set
;
}
/// <summary>
/// 取消时间
/// </summary>
public
DateTime
?
CancelTime
{
get
;
set
;
}
/// <summary>
/// 是否申请取消订单 1是 2否
/// </summary>
public
int
?
IsApplyForCancel
{
get
;
set
;
}
...
...
Mall.Model/Extend/MarketingCenter/RB_DiscountCoupon_Extend.cs
View file @
7a6ccd88
...
...
@@ -27,6 +27,10 @@ namespace Mall.Model.Extend.MarketingCenter
/// 发放数量
/// </summary>
public
int
GrantNum
{
get
;
set
;
}
/// <summary>
/// 优惠卷ids
/// </summary>
public
string
CouponIds
{
get
;
set
;
}
/// <summary>
/// 会员等级
...
...
Mall.Model/Extend/Product/RB_Goods_OrderDetail_Extend.cs
View file @
7a6ccd88
...
...
@@ -29,5 +29,29 @@ namespace Mall.Model.Extend.Product
/// 是否已发货
/// </summary>
public
int
?
IsBindExpress
{
get
;
set
;
}
/// <summary>
/// 商品分类ids
/// </summary>
public
List
<
int
>
CategoryIdList
{
get
;
set
;
}
/// <summary>
/// 剩余库存
/// </summary>
public
int
InventoryNum
{
get
;
set
;
}
/// <summary>
/// 规格价格列表id
/// </summary>
public
int
SpeciPriceId
{
get
;
set
;
}
/// <summary>
/// 是否开启单独返佣 1是 2否
/// </summary>
public
int
?
SeparateDistribution
{
get
;
set
;
}
/// <summary>
/// 分销类型 1普通 2详细
/// </summary>
public
int
?
SeparateDistributionType
{
get
;
set
;
}
/// <summary>
/// 分销佣金类型 1百分比 2固定值
/// </summary>
public
int
?
SeparateDistributionMoneyType
{
get
;
set
;
}
}
}
Mall.Model/Extend/Product/RB_Goods_Order_Extend.cs
View file @
7a6ccd88
...
...
@@ -13,10 +13,11 @@ namespace Mall.Model.Extend.Product
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Goods_Order_Extend
:
RB_Goods_Order
{
public
int
?
IsFormShoppingCart
{
get
;
set
;
}
/// <summary>
/// 收货地址id
/// </summary>
public
int
?
Sh
i
ppingAddressId
{
get
;
set
;
}
public
int
?
Sh
o
ppingAddressId
{
get
;
set
;
}
/// <summary>
/// 商品id
/// </summary>
...
...
Mall.Model/Extend/User/RB_Member_DiscountCoupon_Extend.cs
View file @
7a6ccd88
...
...
@@ -53,5 +53,9 @@ namespace Mall.Model.Extend.User
/// 下单结束时间
/// </summary>
public
DateTime
?
EndDate
{
get
;
set
;
}
/// <summary>
/// 优惠卷ids
/// </summary>
public
string
CouponIds
{
get
;
set
;
}
}
}
Mall.Module.Product/OrderModule.cs
View file @
7a6ccd88
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.Enum.Goods
;
...
...
@@ -11,6 +12,7 @@ using Mall.Model.Extend.Product;
using
Mall.Model.Extend.User
;
using
Mall.Repository
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.MarketingCenter
;
using
Mall.Repository.Product
;
using
Mall.Repository.User
;
using
Newtonsoft.Json
;
...
...
@@ -55,6 +57,10 @@ namespace Mall.Module.Product
/// </summary>
private
readonly
RB_Distributor_GradeRepository
distributor_GradeRepository
=
new
RB_Distributor_GradeRepository
();
/// <summary>
/// 分销基础配置
/// </summary>
private
readonly
RB_Distributor_BasicsRepository
distributor_BasicsRepository
=
new
RB_Distributor_BasicsRepository
();
/// <summary>
/// 会员等级
/// </summary>
private
readonly
RB_Member_GradeRepository
member_GradeRepository
=
new
RB_Member_GradeRepository
();
...
...
@@ -120,7 +126,13 @@ namespace Mall.Module.Product
/// 收货地址
/// </summary>
private
readonly
RB_Member_ShippingAddressRepository
member_ShippingAddressRepository
=
new
RB_Member_ShippingAddressRepository
();
/// <summary>
/// 优惠卷
/// </summary>
private
readonly
RB_Member_CouponRepository
member_CouponRepository
=
new
RB_Member_CouponRepository
();
private
readonly
RB_DiscountCouponRepository
discountCouponRepository
=
new
RB_DiscountCouponRepository
();
private
readonly
RB_DiscountCoupon_ProductRepository
discountCoupon_ProductRepository
=
new
RB_DiscountCoupon_ProductRepository
();
#
region
购物车
...
...
@@ -383,7 +395,8 @@ namespace Mall.Module.Product
if
(
demodel
.
DetailList
.
Any
())
{
string
GoodsIds
=
string
.
Join
(
","
,
demodel
.
DetailList
.
Select
(
x
=>
x
.
GoodsId
));
var
gList
=
goodsRepository
.
GetList
(
new
RB_Goods_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
clist
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciList
=
goods_SpecificationRepository
.
GetList
(
new
RB_Goods_Specification_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciVList
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciPList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
...
...
@@ -420,6 +433,7 @@ namespace Mall.Module.Product
if
(
gmodel
==
null
||
gmodel
.
GoodsStatus
!=
1
)
{
continue
;
}
var
categoryList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
gmodel
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
...
...
@@ -568,7 +582,12 @@ namespace Mall.Module.Product
item
.
GoodsId
,
GoodsName
=
gmodel
.
Name
,
gmodel
.
CoverImage
,
CategoryList
=
categoryList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
CategoryName
}),
SpecificationList
=
gmodel
.
SpecificationNameList
,
item
.
SpecificationSort
,
item
.
Number
,
SellingPrice
=
(
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
),
MemberPrice
=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
),
...
...
@@ -612,7 +631,7 @@ namespace Mall.Module.Product
return
ApiResult
.
Failed
(
"用户不存在"
);
}
//获取用户的默认收货地址
var
defModel
=
member_ShippingAddressRepository
.
GetEntity
(
demodel
.
Sh
i
ppingAddressId
);
var
defModel
=
member_ShippingAddressRepository
.
GetEntity
(
demodel
.
Sh
o
ppingAddressId
);
List
<
int
>
disList
=
new
List
<
int
>();
if
(
defModel
==
null
)
{
...
...
@@ -802,17 +821,815 @@ namespace Mall.Module.Product
/// <returns></returns>
public
ApiResult
SetAppletGoodsOrderInfo
(
RB_Goods_Order_Extend
demodel
)
{
var
umodel
=
member_UserRepository
.
GetEntity
(
demodel
.
UserId
);
if
(
umodel
==
null
)
{
return
ApiResult
.
Failed
(
"用户不存在"
);
}
List
<
int
>
disList
=
new
List
<
int
>();
disList
.
Add
(
demodel
.
Province
??
0
);
disList
.
Add
(
demodel
.
City
??
0
);
disList
.
Add
(
demodel
.
District
??
0
);
decimal
TotalExpress
=
0
;
decimal
TotalMoney
=
0
;
string
GoodsIds
=
""
;
if
(
demodel
.
DetailList
.
Any
())
{
int
DefFreightId
=
0
;
//默认运费id
GoodsIds
=
string
.
Join
(
","
,
demodel
.
DetailList
.
Select
(
x
=>
x
.
GoodsId
));
var
gList
=
goodsRepository
.
GetList
(
new
RB_Goods_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
clist
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciPList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
mpriceList
=
goods_MemberPriceRepository
.
GetList
(
new
RB_Goods_MemberPrice_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
>
rulesList
=
new
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
>();
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
>
priceList
=
new
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
>();
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesRegion_Extend
>
regionList
=
new
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesRegion_Extend
>();
if
(
gList
.
Any
()
&&
demodel
.
DeliveryMethod
!=
OrderDeliveryMethodEnum
.
VerificationShop
)
{
List
<
int
>
FreightIdList
=
new
List
<
int
>();
if
(
gList
.
Where
(
x
=>
x
.
FreightId
>
0
).
Any
())
{
FreightIdList
.
AddRange
(
gList
.
Where
(
x
=>
x
.
FreightId
>
0
).
Select
(
x
=>
x
.
FreightId
??
0
).
ToList
());
}
if
(
gList
.
Where
(
x
=>
x
.
FreightId
==
0
).
Any
())
{
//查询默认
DefFreightId
=
logistics_RulesRepository
.
GetLogisticsRulesList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
()
{
IsDefault
=
1
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
()?.
ID
??
0
;
FreightIdList
.
Add
(
DefFreightId
);
}
if
(
FreightIdList
.
Any
())
{
rulesList
=
logistics_RulesRepository
.
GetLogisticsRulesList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
()
{
RulesIds
=
string
.
Join
(
","
,
FreightIdList
),
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
priceList
=
logistics_RulesPriceRepository
.
GetListRepository
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
RulesIds
=
string
.
Join
(
","
,
FreightIdList
)
});
if
(
priceList
.
Any
())
{
string
priceIds
=
string
.
Join
(
","
,
priceList
.
Select
(
x
=>
x
.
ID
));
regionList
=
logistics_RulesRegionRepository
.
GetListRepository
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesRegion_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
PriceIds
=
priceIds
});
}
}
}
foreach
(
var
item
in
demodel
.
DetailList
)
{
var
gmodel
=
gList
.
Where
(
x
=>
x
.
Id
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
gmodel
==
null
||
gmodel
.
GoodsStatus
!=
1
)
{
return
ApiResult
.
Failed
(
"有商品不存在或者商品已失效"
);
}
item
.
InventoryNum
=
gmodel
.
InventoryNum
??
0
;
item
.
CostMoney
=
gmodel
.
CostPrice
??
0
;
item
.
ProductCode
=
gmodel
.
GoodsNumbers
;
item
.
CategoryIdList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
Select
(
x
=>
x
.
CategoryId
??
0
).
ToList
();
int
GoodsWeight
=
gmodel
.
GoodsWeight
??
0
;
//商品重量
#
region
规格
//验证规格是否已失效
if
(
gmodel
.
IsCustomSpecification
==
1
)
{
if
(
string
.
IsNullOrEmpty
(
item
.
SpecificationSort
))
{
return
ApiResult
.
Failed
(
"有商品已失效,请重新下单"
);
}
if
(!
speciPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
).
Any
())
{
return
ApiResult
.
Failed
(
"有商品已失效,请重新下单"
);
}
}
else
{
if
(!
string
.
IsNullOrEmpty
(
item
.
SpecificationSort
))
{
return
ApiResult
.
Failed
(
"有商品已失效,请重新下单"
);
}
}
if
(
string
.
IsNullOrEmpty
(
item
.
SpecificationSort
))
{
var
speciPModel
=
speciPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
).
FirstOrDefault
();
gmodel
.
SellingPrice
=
speciPModel
?.
SellingPrice
??
0
;
gmodel
.
InventoryNum
=
speciPModel
?.
InventoryNum
??
0
;
GoodsWeight
=
speciPModel
?.
GoodsWeight
??
0
;
item
.
InventoryNum
=
speciPModel
?.
InventoryNum
??
0
;
item
.
SpeciPriceId
=
speciPModel
?.
Id
??
0
;
item
.
ProductCode
=
speciPModel
?.
GoodsNumbers
??
""
;
}
#
endregion
//会员价格
gmodel
.
MemberPrice
=
gmodel
.
SellingPrice
??
0
;
if
(
umodel
.
MemberGrade
>
0
)
{
if
(
gmodel
.
EnjoyMember
==
1
&&
gmodel
.
SeparateSetMember
==
1
)
{
gmodel
.
MemberPrice
=
mpriceList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
MemberGrade
==
umodel
.
MemberGrade
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
).
FirstOrDefault
()?.
MemberPrice
??
0
;
item
.
IsMemberPrice
=
1
;
}
else
{
//求会员等级折扣
var
gradeModel
=
member_GradeRepository
.
GetList
(
new
RB_Member_Grade_Extend
()
{
Grade
=
umodel
.
MemberGrade
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
gmodel
.
MemberPrice
=
Math
.
Round
((
gmodel
.
SellingPrice
??
0
)
*
(
gradeModel
?.
Discount
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
item
.
DiscountRate
=
gradeModel
?.
Discount
??
10
;
}
}
//运费
decimal
Express
=
0
;
if
(
demodel
.
DeliveryMethod
!=
OrderDeliveryMethodEnum
.
VerificationShop
)
{
int
FreightId2
=
gmodel
.
FreightId
??
0
;
if
(
gmodel
.
FreightId
==
0
)
{
FreightId2
=
DefFreightId
;
}
if
(
FreightId2
>
0
)
{
var
rulesModel
=
rulesList
.
Where
(
x
=>
x
.
ID
==
FreightId2
).
FirstOrDefault
();
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
>
priceList2
=
priceList
.
Where
(
x
=>
x
.
RulesId
==
FreightId2
).
ToList
();
if
(
priceList2
.
Any
())
{
var
priceIds
=
priceList2
.
Select
(
x
=>
x
.
ID
).
ToList
();
var
regionList2
=
regionList
.
Where
(
x
=>
priceIds
.
Contains
(
x
.
RulesPriceId
)).
ToList
();
var
regionModel
=
regionList2
.
Where
(
x
=>
disList
.
Contains
(
x
.
RegionId
)).
FirstOrDefault
();
if
(
regionModel
!=
null
)
{
var
pmodel
=
priceList2
.
Where
(
x
=>
x
.
ID
==
regionModel
.
RulesPriceId
).
FirstOrDefault
();
if
(
pmodel
!=
null
&&
rulesModel
!=
null
)
{
if
(
rulesModel
.
ChargeMode
==
Common
.
Enum
.
MallBase
.
ChargeModeEnum
.
Num
)
{
//按件计费
if
(
item
.
Number
<=
pmodel
.
First
)
{
Express
=
pmodel
.
FirstPrice
;
}
else
{
if
(
pmodel
.
Second
>
0
)
{
if
(((
item
.
Number
??
0
)
-
pmodel
.
First
)
%
pmodel
.
Second
==
0
)
{
Express
=
pmodel
.
FirstPrice
+
(((
item
.
Number
??
0
)
-
pmodel
.
First
)
/
pmodel
.
Second
)
*
pmodel
.
SecondPrice
;
}
else
{
Express
=
pmodel
.
FirstPrice
+
(((
item
.
Number
??
0
)
-
pmodel
.
First
)
/
pmodel
.
Second
+
1
)
*
pmodel
.
SecondPrice
;
}
}
else
{
Express
=
pmodel
.
FirstPrice
;
}
}
}
else
{
//重量计费
int
TotalW
=
(
item
.
Number
??
0
)
*
GoodsWeight
;
if
(
TotalW
<=
pmodel
.
First
)
{
Express
=
pmodel
.
FirstPrice
;
}
else
{
if
(
pmodel
.
Second
>
0
)
{
if
((
TotalW
-
pmodel
.
First
)
%
pmodel
.
Second
==
0
)
{
Express
=
pmodel
.
FirstPrice
+
((
TotalW
-
pmodel
.
First
)
/
pmodel
.
Second
)
*
pmodel
.
SecondPrice
;
}
else
{
Express
=
pmodel
.
FirstPrice
+
((
TotalW
-
pmodel
.
First
)
/
pmodel
.
Second
+
1
)
*
pmodel
.
SecondPrice
;
}
}
else
{
Express
=
pmodel
.
FirstPrice
;
}
}
}
}
}
}
}
}
TotalExpress
+=
Express
;
item
.
Unit_Price
=
gmodel
.
SellingPrice
??
0
;
item
.
Original_Price
=
(
item
.
Unit_Price
)
*
(
item
.
Number
);
if
(
umodel
.
MemberGrade
>
0
)
{
TotalMoney
+=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
);
item
.
Final_Price
=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
);
}
else
{
TotalMoney
+=
(
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
);
item
.
Final_Price
=
(
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
);
}
item
.
OrderType
=
gmodel
.
GoodsType
;
item
.
GoodsName
=
gmodel
.
Name
;
item
.
CoverImage
=
0
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
gmodel
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
}
item
.
SeparateDistribution
=
gmodel
.
SeparateDistribution
;
item
.
SeparateDistributionType
=
gmodel
.
SeparateDistributionType
;
item
.
SeparateDistributionMoneyType
=
gmodel
.
SeparateDistributionMoneyType
;
}
}
if
(
demodel
.
FreightMoney
!=
TotalExpress
)
{
return
ApiResult
.
Failed
(
"运费不正确"
);
}
//优惠卷验证
decimal
CouponsMoney
=
0
;
List
<
RB_Member_DiscountCoupon_Extend
>
cList
=
new
List
<
RB_Member_DiscountCoupon_Extend
>();
if
(
string
.
IsNullOrEmpty
(
demodel
.
CouponsIds
))
{
//验证优惠价金额
//demodel.CouponMoney;
cList
=
member_CouponRepository
.
GetList
(
new
RB_Member_DiscountCoupon_Extend
()
{
UseState
=
0
,
CouponIds
=
demodel
.
CouponsIds
,
UserId
=
umodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
string
[]
arr
=
demodel
.
CouponsIds
.
Split
(
","
);
foreach
(
var
item
in
arr
)
{
if
(!
string
.
IsNullOrEmpty
(
item
))
{
if
(!
cList
.
Where
(
x
=>
x
.
CouponId
==
Convert
.
ToInt32
(
item
)).
Any
())
{
return
ApiResult
.
Failed
(
"优惠券不存在,请核实后再试"
);
}
}
}
if
(
cList
.
Any
())
{
var
dcList
=
discountCouponRepository
.
GetDiscountCouponList
(
new
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
()
{
CouponIds
=
demodel
.
CouponsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
dcpList
=
discountCoupon_ProductRepository
.
GetListByDiscountCouponIds
(
new
Model
.
Entity
.
MarketingCenter
.
RB_DiscountCoupon
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
},
demodel
.
CouponsIds
);
foreach
(
var
item
in
arr
)
{
if
(!
string
.
IsNullOrEmpty
(
item
))
{
var
dcModel
=
dcList
.
Where
(
x
=>
x
.
ID
==
Convert
.
ToInt32
(
item
)).
FirstOrDefault
();
if
(
dcModel
==
null
)
{
return
ApiResult
.
Failed
(
"优惠卷不存在,亲核实后再试"
);
}
dcModel
.
DiscountsPrice
=
dcModel
.
DiscountsPrice
==
0
?
10
:
dcModel
.
DiscountsPrice
;
decimal
FinalMoney
=
0
;
if
(
dcModel
.
UseType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Category
)
//指定分类
{
var
categoryList
=
dcpList
.
Where
(
x
=>
x
.
DiscountCouponId
==
Convert
.
ToInt32
(
item
)
&&
x
.
DiscountCouponType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Category
).
Select
(
x
=>
x
.
ProductId
).
ToList
();
//获取特殊优惠卷
foreach
(
var
qitem
in
demodel
.
DetailList
)
{
if
(
qitem
.
CategoryIdList
.
Where
(
x
=>
categoryList
.
Contains
(
x
)).
Any
())
{
FinalMoney
+=
qitem
.
Final_Price
??
0
;
}
}
if
(
FinalMoney
<=
0
)
{
return
ApiResult
.
Failed
(
"Id"
+
item
+
"的优惠券,未匹配到适用类型的商品"
);
}
}
else
if
(
dcModel
.
UseType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Product
)
//指定商品
{
var
goodsList
=
dcpList
.
Where
(
x
=>
x
.
DiscountCouponId
==
Convert
.
ToInt32
(
item
)
&&
x
.
DiscountCouponType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Product
).
Select
(
x
=>
x
.
ProductId
).
ToList
();
//获取特殊优惠卷
if
(!
demodel
.
DetailList
.
Where
(
x
=>
goodsList
.
Contains
(
x
.
GoodsId
??
0
)).
Any
())
{
return
ApiResult
.
Failed
(
"Id"
+
item
+
"的优惠券,未匹配到适用的商品"
);
}
FinalMoney
=
demodel
.
DetailList
.
Where
(
x
=>
goodsList
.
Contains
(
x
.
GoodsId
??
0
)).
Sum
(
x
=>
x
.
Final_Price
??
0
);
}
else
{
FinalMoney
=
TotalMoney
;
}
if
(
dcModel
.
MinConsumePrice
>
0
)
{
if
(
FinalMoney
<
dcModel
.
MinConsumePrice
)
{
return
ApiResult
.
Failed
(
"Id"
+
item
+
"优惠卷未达到使用要求"
);
}
}
if
(
dcModel
.
CouponType
==
Common
.
Enum
.
MarketingCenter
.
CouponTypeEnum
.
FullReduction
)
{
CouponsMoney
+=
dcModel
.
DiscountsPrice
;
}
else
{
decimal
disMoney
=
Math
.
Round
(
FinalMoney
*
(
10
-
dcModel
.
DiscountsPrice
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
if
(
dcModel
.
MaxDiscountsPrice
>
0
&&
dcModel
.
MaxDiscountsPrice
<
disMoney
)
{
disMoney
=
dcModel
.
MaxDiscountsPrice
;
}
CouponsMoney
+=
disMoney
;
}
}
}
}
}
if
(
CouponsMoney
!=
demodel
.
CouponMoney
)
{
return
ApiResult
.
Failed
(
"优惠金额计算有误"
);
}
//验证运费
//验证总额
if
(
demodel
.
Income
!=
(
TotalMoney
-
(
demodel
.
CouponMoney
??
0
)
+
TotalExpress
))
{
return
ApiResult
.
Failed
(
"订单合计金额不正确"
);
}
demodel
.
PreferPrice
=
TotalMoney
;
var
trans
=
goods_OrderRepository
.
DbTransaction
;
try
{
int
OrderId
=
goods_OrderRepository
.
Insert
(
demodel
,
trans
);
if
(
OrderId
>
0
)
{
//插入订单明细+ 商品库存更新
InsertOrderDetail
(
demodel
,
trans
,
OrderId
);
//任务执行返佣 失败查看日志,手动返佣(空闲可增加手动返佣接口)
Task
.
Run
(()
=>
InsertOrderCommission
(
demodel
,
umodel
,
GoodsIds
,
OrderId
));
//用户订单数增加
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User_Extend
.
OrderNum
),(
umodel
.
OrderNum
??
0
)+
1
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_User_Extend
.
Id
),
FiledValue
=
umodel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
member_UserRepository
.
Update
(
keyValues
,
wheres
,
trans
);
//优惠券使用
if
(
cList
.
Any
())
{
foreach
(
var
item
in
cList
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UseDate
),
DateTime
.
Now
},
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UseState
),
1
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_DiscountCoupon_Extend
.
Id
),
FiledValue
=
item
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
member_CouponRepository
.
Update
(
keyValues1
,
wheres1
,
trans
);
}
}
//记录日志
Task
.
Run
(()
=>
goods_LogRepository
.
Insert
(
new
RB_Goods_Log
()
{
Id
=
0
,
Type
=
1
,
SourceId
=
OrderId
,
Content
=
"新增订单"
,
CreateDate
=
DateTime
.
Now
,
MallBaseId
=
demodel
.
MallBaseId
,
TenantId
=
demodel
.
TenantId
}));
}
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetAppletGoodsOrderInfo"
);
goods_OrderRepository
.
DBSession
.
Rollback
(
"SetAppletGoodsOrderInfo"
);
return
ApiResult
.
Failed
();
}
return
ApiResult
.
Success
();
}
/// <summary>
/// 插入返佣
/// </summary>
/// <param name="demodel"></param>
/// <param name="umodel"></param>
/// <param name="GoodsIds"></param>
/// <param name="OrderId"></param>
private
void
InsertOrderCommission
(
RB_Goods_Order_Extend
demodel
,
Model
.
Entity
.
User
.
RB_Member_User
umodel
,
string
GoodsIds
,
int
OrderId
)
{
var
trans
=
goods_OrderCommissionRepository
.
DbTransaction
;
try
{
var
dcList
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
basicModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
{
#
region
分销商
id
+
分销商等级
int
OneUserId
=
0
,
TwoUserId
=
0
,
ThreeUserId
=
0
;
int
OneDistributorGrade
=
0
,
TwoDistributorGrade
=
0
,
ThreeDistributorGrade
=
0
;
//获取多级 分销商id
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
{
for
(
int
i
=
1
;
i
<
basicModel
.
DistributorTier
+
1
;
i
++)
{
switch
(
i
)
{
case
1
:
if
(
umodel
.
IsDistributor
!=
1
)
{
OneUserId
=
umodel
.
SuperiorId
??
0
;
}
else
{
OneUserId
=
umodel
.
Id
;
}
break
;
case
2
:
if
(
umodel
.
IsDistributor
!=
1
)
{
TwoUserId
=
member_UserRepository
.
GetEntity
(
OneUserId
).
SuperiorId
??
0
;
}
else
{
TwoUserId
=
umodel
.
SuperiorId
??
0
;
}
break
;
case
3
:
ThreeUserId
=
member_UserRepository
.
GetEntity
(
TwoUserId
).
SuperiorId
??
0
;
break
;
}
}
}
if
(
OneUserId
>
0
)
{
OneDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
OneUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
TwoUserId
>
0
)
{
TwoDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
TwoUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
ThreeUserId
>
0
)
{
ThreeDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
ThreeUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
#
endregion
#
region
分销商等级列表
List
<
int
>
gradeIdlist
=
new
List
<
int
>();
if
(
OneDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
OneDistributorGrade
);
}
if
(
TwoDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
TwoDistributorGrade
);
}
if
(
ThreeDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
ThreeDistributorGrade
);
}
List
<
RB_Distributor_Grade_Extend
>
dgradeList
=
new
List
<
RB_Distributor_Grade_Extend
>();
if
(
gradeIdlist
.
Any
())
{
dgradeList
=
distributor_GradeRepository
.
GetList
(
new
RB_Distributor_Grade_Extend
()
{
GradeIds
=
string
.
Join
(
","
,
gradeIdlist
),
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
#
endregion
foreach
(
var
item
in
demodel
.
DetailList
)
{
//返佣
List
<
RB_Goods_OrderCommission
>
gocList
=
new
List
<
RB_Goods_OrderCommission
>();
for
(
int
i
=
1
;
i
<
basicModel
.
DistributorTier
+
1
;
i
++)
{
switch
(
i
)
{
case
1
:
decimal
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
OneCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
OneCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//获取分销商等级
if
(
OneDistributorGrade
>
0
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
OneDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
OneCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
OneCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
if
(
TwoUserId
==
0
&&
basicModel
.
IsCommissionResidue
==
1
)
{
//表示其为一级分销商 把后面的佣金都提完
TwoUserId
=
OneUserId
;
TwoDistributorGrade
=
OneDistributorGrade
;
}
RB_Goods_OrderCommission
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
umodel
.
IsDistributor
==
1
?
0
:
1
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
OneUserId
};
gocList
.
Add
(
gocModel
);
break
;
case
2
:
if
(
TwoUserId
>
0
)
{
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
TwoCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
TwoCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//获取分销商等级
if
(
TwoDistributorGrade
>
0
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
TwoDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
TwoCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
TwoCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
if
(
ThreeUserId
==
0
&&
basicModel
.
IsCommissionResidue
==
1
)
{
//表示其为二级分销商 把后面的佣金都提完
ThreeUserId
=
TwoUserId
;
ThreeDistributorGrade
=
TwoDistributorGrade
;
}
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
umodel
.
IsDistributor
==
1
?
TwoUserId
==
OneUserId
?
0
:
1
:
2
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
TwoUserId
};
gocList
.
Add
(
gocModel
);
}
break
;
case
3
:
if
(
ThreeUserId
>
0
)
{
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//获取分销商等级
if
(
ThreeDistributorGrade
>
0
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
ThreeDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
ThreeCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
ThreeCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
#
region
获取返佣等级
int
Grade
=
0
;
if
(
OneUserId
==
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
0
;
}
else
if
(
OneUserId
!=
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
1
;
}
else
{
Grade
=
2
;
}
if
(
umodel
.
IsDistributor
!=
1
)
{
Grade
++;
}
#
endregion
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
Grade
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
ThreeUserId
};
gocList
.
Add
(
gocModel
);
}
break
;
}
}
List
<
RB_Goods_OrderCommission
>
gocfulList
=
gocList
;
//gocList 合并用户金额
if
(
basicModel
.
IsCommissionResidue
==
1
)
{
gocfulList
=
new
List
<
RB_Goods_OrderCommission
>();
if
(
gocList
.
Count
()
!=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
Count
())
{
//说明有用户可以合并
var
userIdList
=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
ToList
();
foreach
(
var
qitem
in
userIdList
)
{
var
gocModel
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
FirstOrDefault
();
if
(
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Count
()
>
1
)
{
decimal
tcommission
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Sum
(
x
=>
x
.
Commission
??
0
);
gocModel
.
Commission
=
tcommission
;
gocModel
.
Remark
=
"多级全额返佣"
;
}
gocfulList
.
Add
(
gocModel
);
}
}
}
if
(
gocfulList
.
Any
())
{
foreach
(
var
qitem
in
gocfulList
)
{
goods_OrderCommissionRepository
.
Insert
(
qitem
,
trans
);
}
}
}
}
goods_OrderCommissionRepository
.
DBSession
.
Commit
();
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"InsertOrderCommission:"
+
OrderId
+
"订单返佣失败"
);
goods_OrderCommissionRepository
.
DBSession
.
Rollback
();
}
}
/// <summary>
/// 插入订单明细,以及更新商品库存
/// </summary>
/// <param name="demodel"></param>
/// <param name="trans"></param>
/// <param name="OrderId"></param>
private
void
InsertOrderDetail
(
RB_Goods_Order_Extend
demodel
,
System
.
Data
.
IDbTransaction
trans
,
int
OrderId
)
{
foreach
(
var
item
in
demodel
.
DetailList
)
{
//插入订单明细表
int
detailId
=
goods_OrderDetailRepository
.
Insert
(
new
RB_Goods_OrderDetail
()
{
Id
=
0
,
CostMoney
=
item
.
CostMoney
,
CoverImage
=
item
.
CoverImage
,
CreateDate
=
DateTime
.
Now
,
DiscountRate
=
item
.
DiscountRate
,
Final_Price
=
item
.
Final_Price
,
GoodsId
=
item
.
GoodsId
,
GoodsName
=
item
.
GoodsName
,
IsMemberPrice
=
item
.
IsMemberPrice
??
2
,
MallBaseId
=
demodel
.
MallBaseId
,
Number
=
item
.
Number
,
OrderId
=
OrderId
,
OrderType
=
item
.
OrderType
,
Original_Price
=
item
.
Original_Price
,
ProductCode
=
item
.
ProductCode
,
Specification
=
item
.
Specification
,
//前端传递过来
SpecificationSort
=
item
.
SpecificationSort
,
Unit_Price
=
item
.
Unit_Price
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
},
trans
);
item
.
Id
=
detailId
;
//更新商品数量
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
InventoryNum
),
item
.
InventoryNum
-(
item
.
Number
??
0
)}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
Id
),
FiledValue
=
item
.
GoodsId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
TenantId
),
FiledValue
=
demodel
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
MallBaseId
),
FiledValue
=
demodel
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flagg
=
goodsRepository
.
Update
(
keyValues
,
wheres
,
trans
);
if
(
flagg
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
SpecificationSort
)
&&
item
.
SpeciPriceId
>
0
)
{
//更新规格价格库存
Dictionary
<
string
,
object
>
keyValuesp
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_SpecificationPrice
.
InventoryNum
),
item
.
InventoryNum
-(
item
.
Number
??
0
)}
};
List
<
WhereHelper
>
wheresp
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_SpecificationPrice
.
Id
),
FiledValue
=
item
.
SpeciPriceId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods_SpecificationPrice
.
GoodsId
),
FiledValue
=
item
.
GoodsId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
TenantId
),
FiledValue
=
demodel
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Goods
.
MallBaseId
),
FiledValue
=
demodel
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
goods_SpecificationPriceRepository
.
Update
(
keyValuesp
,
wheresp
,
trans
);
}
//记录日志
Task
.
Run
(()
=>
goods_LogRepository
.
Insert
(
new
RB_Goods_Log
()
{
Id
=
0
,
Type
=
2
,
SourceId
=
item
.
GoodsId
,
Content
=
"新增订单,Key:"
+
item
.
SpecificationSort
+
",商品库存减少:"
+
item
.
Number
,
CreateDate
=
DateTime
.
Now
,
MallBaseId
=
demodel
.
MallBaseId
,
TenantId
=
demodel
.
TenantId
}));
}
}
}
#
endregion
#
region
订单管理
...
...
@@ -1525,6 +2342,8 @@ namespace Mall.Module.Product
PaymentTime
=
model
.
PaymentTime
.
HasValue
?
model
.
PaymentTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
DeliveryTime
=
model
.
DeliveryTime
.
HasValue
?
model
.
DeliveryTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
ReceivingTime
=
model
.
ReceivingTime
.
HasValue
?
model
.
ReceivingTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
FinishTime
=
model
.
FinishTime
.
HasValue
?
model
.
FinishTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
CancelTime
=
model
.
CancelTime
.
HasValue
?
model
.
CancelTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
model
.
Remark
,
model
.
PreferPrice
,
model
.
Income
,
...
...
Mall.Repository/MarketingCenter/RB_DiscountCouponRepository.cs
View file @
7a6ccd88
...
...
@@ -71,6 +71,10 @@ namespace Mall.Repository.MarketingCenter
{
builder
.
Append
(
$" AND
{
nameof
(
RB_DiscountCoupon_Extend
.
Name
)}
like '%
{
query
.
Name
}
%'"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
{
builder
.
Append
(
$" AND
{
nameof
(
RB_DiscountCoupon_Extend
.
ID
)}
in(
{
query
.
CouponIds
}
)"
);
}
}
return
Get
<
RB_DiscountCoupon_Extend
>(
builder
.
ToString
()).
ToList
();
}
...
...
Mall.Repository/Product/RB_GoodsRepository.cs
View file @
7a6ccd88
...
...
@@ -273,5 +273,29 @@ inner join rb_goods_category c on g.Id=c.GoodsId
where
{
where
}
group by g.Id order by col.Id desc"
;
return
GetPage
<
RB_Goods_Extend
>(
pageIndex
,
pageSize
,
out
rowCount
,
sql
).
ToList
();
}
public
List
<
RB_Goods_Extend
>
GetGoodsInventoryNumList
(
RB_Goods_Extend
dmodel
)
{
string
where
=
$" 1=1 and g.
{
nameof
(
RB_Goods_Extend
.
Status
)}
=0"
;
if
(
dmodel
.
TenantId
>
0
)
{
where
+=
$@" and g.
{
nameof
(
RB_Goods_Extend
.
TenantId
)}
=
{
dmodel
.
TenantId
}
"
;
}
if
(
dmodel
.
MallBaseId
>
0
)
{
where
+=
$@" and g.
{
nameof
(
RB_Goods_Extend
.
MallBaseId
)}
=
{
dmodel
.
MallBaseId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
GoodsIds
))
{
where
+=
$@" and g.
{
nameof
(
RB_Goods_Extend
.
Id
)}
in(
{
dmodel
.
GoodsIds
}
)"
;
}
if
(
dmodel
.
GoodsStatus
>
0
)
{
where
+=
$@" and g.
{
nameof
(
RB_Goods_Extend
.
GoodsStatus
)}
=
{
dmodel
.
GoodsStatus
}
"
;
}
string
sql
=
$@"select g.Id,g. from RB_Goods g where
{
where
}
group by g.Id asc"
;
return
Get
<
RB_Goods_Extend
>(
sql
).
ToList
();
}
}
}
Mall.Repository/User/RB_Member_CouponRepository.cs
View file @
7a6ccd88
...
...
@@ -30,6 +30,44 @@ namespace Mall.Repository.User
/// </summary>
public
string
OrderTableName
{
get
{
return
nameof
(
RB_Goods_Order
);
}
}
/// <summary>
/// 会员优惠券
/// </summary>
/// <returns></returns>
public
List
<
RB_Member_DiscountCoupon_Extend
>
GetList
(
RB_Member_DiscountCoupon_Extend
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
TenantId
)}
=
{
query
.
TenantId
}
"
);
}
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
);
}
if
(
query
.
PlatformType
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
PlatformType
)}
=
{
query
.
PlatformType
}
"
);
}
if
(
query
.
UserId
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UserId
)}
=
{
query
.
UserId
}
"
);
}
if
(
query
.
CouponId
>
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
CouponId
)}
=
{
query
.
CouponId
}
"
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
CouponIds
))
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
CouponId
)}
in (
{
query
.
CouponIds
}
)"
);
}
if
(
query
.
UseState
>=
0
)
{
builder
.
Append
(
$" AND a.
{
nameof
(
RB_Member_DiscountCoupon_Extend
.
UseState
)}
=
{
query
.
UseState
}
"
);
}
}
string
sql
=
@
$" select * FROM
{
TableName
}
AS a where 1=1
{
builder
.
ToString
()}
"
;
return
Get
<
RB_Member_DiscountCoupon_Extend
>(
sql
).
ToList
();
}
/// <summary>
/// 会员优惠券
...
...
Mall.WebApi/Controllers/Product/AppletOrderController.cs
View file @
7a6ccd88
...
...
@@ -191,7 +191,7 @@ namespace Mall.WebApi.Controllers.MallBase
var
req
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
RB_Goods_Order_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Goods_Order_Extend
>(
req
.
msg
.
ToString
());
if
((
demodel
.
Sh
i
ppingAddressId
??
0
)
<=
0
)
{
if
((
demodel
.
Sh
o
ppingAddressId
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递收货地址id"
);
}
if
(
demodel
.
DetailList
==
null
||
!
demodel
.
DetailList
.
Any
())
...
...
@@ -258,6 +258,9 @@ namespace Mall.WebApi.Controllers.MallBase
if
((
item
.
Number
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递商品数量"
);
}
if
(
string
.
IsNullOrEmpty
(
item
.
Specification
))
{
return
ApiResult
.
ParamIsNull
(
"请传递规格名"
);
}
}
demodel
.
BuyerMessage
??=
""
;
//买家留言
...
...
Mall.WebApi/Controllers/Product/OrderController.cs
View file @
7a6ccd88
...
...
@@ -84,6 +84,7 @@ namespace Mall.WebApi.Controllers.MallBase
PaymentTime
=
x
.
PaymentTime
.
HasValue
?
x
.
PaymentTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
DeliveryTime
=
x
.
DeliveryTime
.
HasValue
?
x
.
DeliveryTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
ReceivingTime
=
x
.
ReceivingTime
.
HasValue
?
x
.
ReceivingTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
FinishTime
=
x
.
FinishTime
.
HasValue
?
x
.
FinishTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
x
.
Country
,
x
.
Province
,
x
.
City
,
...
...
@@ -343,7 +344,7 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
var
omodel
=
orderModule
.
GetOrderInfo
(
demodel
.
OrderId
??
0
);
if
(
omodel
.
OrderStatus
!=
OrderStatusEnum
.
WaitSendGoods
)
{
if
(
omodel
.
OrderStatus
!=
OrderStatusEnum
.
WaitSendGoods
&&
omodel
.
OrderStatus
!=
OrderStatusEnum
.
WaitReceiving
)
{
return
ApiResult
.
ParamIsNull
(
"状态不对"
);
}
...
...
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