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
bb9ba2d7
Commit
bb9ba2d7
authored
May 29, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下单调整
parent
2341cf77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
261 additions
and
78 deletions
+261
-78
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+261
-78
No files found.
Mall.Module.Product/OrderModule.cs
View file @
bb9ba2d7
...
...
@@ -1066,7 +1066,7 @@ namespace Mall.Module.Product
}
}
#
endregion
List
<
RB_Goods_CouponModel
>
GoodsCouponList
=
new
List
<
RB_Goods_CouponModel
>();
List
<
RB_Goods_CouponModel
>
GoodsCouponList
=
new
List
<
RB_Goods_CouponModel
>();
//商品优惠卷 价格(每个商品优惠的价格)
//初始化值
foreach
(
var
item
in
demodel
.
DetailList
)
{
...
...
@@ -1593,6 +1593,7 @@ namespace Mall.Module.Product
}
}
#
region
其他封装
List
<
object
>
mch_list
=
new
List
<
object
>();
var
minModel
=
miniProgramRepository
.
GetEntity
(
demodel
.
MallBaseId
);
...
...
@@ -1661,6 +1662,7 @@ namespace Mall.Module.Product
//hasCity= false,
template_message_list
=
new
List
<
string
>()
{
"WPELErDfYO3JnizA5Zikta6Y8qrBBAgecuj2aLoucuY"
,
"pCmTJwvTqNpyRREo7vvqIYBcrATNWoitfbLS61fLhzU"
,
"i6QPsaOHgfNwlIRMwmvFGSCqX28g0cRa8XaLZ5_gpgc"
}
};
#
endregion
return
ApiResult
.
Success
(
""
,
Robj
);
}
...
...
@@ -1894,8 +1896,49 @@ namespace Mall.Module.Product
decimal
TotalExpress
=
0
;
decimal
TotalMoney
=
0
;
string
GoodsIds
=
""
;
List
<
RB_Goods_CouponModel
>
GoodsCouponList
=
new
List
<
RB_Goods_CouponModel
>();
//商品优惠卷 价格(每个商品优惠的价格)
decimal
CouponsMoney
=
0
;
//优惠卷验证
#
region
优惠卷初始化
List
<
RB_Member_DiscountCoupon_Extend
>
cList
=
new
List
<
RB_Member_DiscountCoupon_Extend
>();
List
<
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
>
dcList
=
new
List
<
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
>();
List
<
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Product_Extend
>
dcpList
=
new
List
<
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Product_Extend
>();
demodel
.
CouponsIds
=
""
;
if
(
demodel
.
User_Coupon_Id
>
0
)
{
demodel
.
CouponsIds
=
demodel
.
User_Coupon_Id
.
ToString
();
if
(!
string
.
IsNullOrEmpty
(
demodel
.
CouponsIds
))
{
cList
=
member_CouponRepository
.
GetList
(
new
RB_Member_DiscountCoupon_Extend
()
{
UseState
=
0
,
Ids
=
demodel
.
CouponsIds
,
UserId
=
umodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
cList
.
Any
())
{
string
cIds
=
string
.
Join
(
","
,
cList
.
Select
(
x
=>
x
.
CouponId
).
Distinct
());
dcList
=
discountCouponRepository
.
GetDiscountCouponList
(
new
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
()
{
CouponIds
=
cIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
dcpList
=
discountCoupon_ProductRepository
.
GetListByDiscountCouponIds
(
new
Model
.
Entity
.
MarketingCenter
.
RB_DiscountCoupon
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
},
cIds
);
if
(
dcList
.
Any
())
{
foreach
(
var
item
in
cList
)
{
if
(
item
.
CouponId
>
0
)
{
if
(!
dcList
.
Where
(
x
=>
x
.
ID
==
item
.
CouponId
).
Any
())
{
return
ApiResult
.
Failed
(
"优惠券不存在,请核实后再试"
);
}
}
}
}
}
}
}
#
endregion
if
(
demodel
.
DetailList
.
Any
())
{
//积分
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
integralModel
=
new
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
();
if
(
demodel
.
Use_Integral
==
1
&&
umodel
.
Integral
>
0
)
{
integralModel
=
integral_SettingsRepository
.
GetIntegralSettingsList
(
new
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
}
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
});
...
...
@@ -1906,7 +1949,7 @@ namespace Mall.Module.Product
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
)
if
(
gList
.
Any
()
&&
demodel
.
DeliveryMethod
==
OrderDeliveryMethodEnum
.
ExpressDistribution
)
{
List
<
int
>
FreightIdList
=
new
List
<
int
>();
if
(
gList
.
Where
(
x
=>
x
.
FreightId
>
0
).
Any
())
...
...
@@ -1932,6 +1975,7 @@ namespace Mall.Module.Product
}
}
foreach
(
var
item
in
demodel
.
DetailList
)
{
var
gmodel
=
gList
.
Where
(
x
=>
x
.
Id
==
item
.
GoodsId
).
FirstOrDefault
();
...
...
@@ -1939,6 +1983,7 @@ namespace Mall.Module.Product
{
return
ApiResult
.
Failed
(
"有商品不存在或者商品已失效"
);
}
var
categoryList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
ToList
();
item
.
InventoryNum
=
gmodel
.
InventoryNum
??
0
;
item
.
CostMoney
=
gmodel
.
CostPrice
??
0
;
item
.
ProductCode
=
gmodel
.
GoodsNumbers
;
...
...
@@ -1986,7 +2031,7 @@ namespace Mall.Module.Product
}
}
#
endregion
//
会员价格
#
region
会员价格
gmodel
.
MemberPrice
=
gmodel
.
SellingPrice
??
0
;
if
(
umodel
.
MemberGrade
>
0
)
{
...
...
@@ -2003,9 +2048,10 @@ namespace Mall.Module.Product
item
.
DiscountRate
=
gradeModel
?.
Discount
??
10
;
}
}
//运费
#
endregion
#
region
运费
decimal
Express
=
0
;
if
(
demodel
.
DeliveryMethod
!=
OrderDeliveryMethodEnum
.
VerificationShop
)
if
(
demodel
.
DeliveryMethod
==
OrderDeliveryMethodEnum
.
ExpressDistribution
)
{
int
FreightId2
=
gmodel
.
FreightId
??
0
;
if
(
gmodel
.
FreightId
==
0
)
...
...
@@ -2086,113 +2132,250 @@ namespace Mall.Module.Product
}
}
TotalExpress
+=
Express
;
#
endregion
item
.
FreightMoney
=
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
);
item
.
Final_Price
=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
);
}
else
{
TotalMoney
+=
(
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
);
else
{
item
.
Final_Price
=
(
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
);
}
item
.
OrderType
=
gmodel
.
GoodsType
;
item
.
GoodsName
=
gmodel
.
Name
;
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
#
region
积分
if
(
umodel
.
Integral
>
0
&&
gmodel
.
PointsDeduction
>
0
&&
integralModel
.
IntegralNum
>
0
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
decimal
SingleMaxMoney
=
0
,
MultMaxMoney
=
0
;
if
(
gmodel
.
PointsDeductionType
==
1
)
{
SingleMaxMoney
=
Math
.
Round
(
gmodel
.
MemberPrice
*
(
gmodel
.
PointsDeduction
??
0
)
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
MultMaxMoney
=
Math
.
Round
(
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
)
*
(
gmodel
.
PointsDeduction
??
0
)
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
item
.
SeparateDistribution
=
gmodel
.
SeparateDistribution
;
item
.
SeparateDistributionType
=
gmodel
.
SeparateDistributionType
;
item
.
SeparateDistributionMoneyType
=
gmodel
.
SeparateDistributionMoneyType
;
item
.
IntegralPresent
=
gmodel
.
IntegralPresent
;
item
.
IntegralPresentType
=
gmodel
.
IntegralPresentType
;
if
(
gmodel
.
IsMultipleDeduction
==
1
)
{
//可以多件商品可累计抵扣
if
(
gmodel
.
PointsDeductionType
==
1
)
{
int
MaxInterral
=
Convert
.
ToInt32
(
MultMaxMoney
*
integralModel
.
IntegralNum
);
//最多可抵扣积分
if
(
umodel
.
Integral
>
MaxInterral
)
{
item
.
IntegralNumber
=
MaxInterral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
MaxInterral
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
-=
MaxInterral
;
}
else
{
item
.
IntegralNumber
=
umodel
.
Integral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
umodel
.
Integral
??
0
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
=
0
;
}
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
))
else
{
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
)
int
MaxInterral
=
Convert
.
ToInt32
((
gmodel
.
PointsDeduction
??
0
)
*
integralModel
.
IntegralNum
*
(
item
.
Number
??
0
)
);
//最多可抵扣积分
if
(
umodel
.
Integral
>
MaxInterral
)
{
if
(!
string
.
IsNullOrEmpty
(
item
))
item
.
IntegralNumber
=
MaxInterral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
MaxInterral
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
-=
MaxInterral
;
}
else
{
if
(!
cList
.
Where
(
x
=>
x
.
CouponId
==
Convert
.
ToInt32
(
item
)).
Any
())
item
.
IntegralNumber
=
umodel
.
Integral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
umodel
.
Integral
??
0
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
=
0
;
}
}
}
else
{
return
ApiResult
.
Failed
(
"优惠券不存在,请核实后再试"
);
//单件商品
if
(
gmodel
.
PointsDeductionType
==
1
)
{
int
MaxInterral
=
Convert
.
ToInt32
(
SingleMaxMoney
*
integralModel
.
IntegralNum
);
//最多可抵扣积分
if
(
umodel
.
Integral
>
MaxInterral
)
{
item
.
IntegralNumber
=
MaxInterral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
MaxInterral
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
-=
MaxInterral
;
}
else
{
item
.
IntegralNumber
=
umodel
.
Integral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
umodel
.
Integral
??
0
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
=
0
;
}
}
else
{
int
MaxInterral
=
Convert
.
ToInt32
((
gmodel
.
PointsDeduction
??
0
)
*
integralModel
.
IntegralNum
);
//最多可抵扣积分
if
(
umodel
.
Integral
>
MaxInterral
)
{
item
.
IntegralNumber
=
MaxInterral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
MaxInterral
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
-=
MaxInterral
;
}
if
(
cList
.
Any
())
else
{
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
))
item
.
IntegralNumber
=
umodel
.
Integral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
umodel
.
Integral
??
0
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
=
0
;
}
}
}
}
if
(
demodel
.
Use_Integral
==
1
)
{
item
.
Final_Price
-=
(
item
.
IntegralMoney
??
0
);
}
#
endregion
#
region
优惠券
//decimal CouponsMoney = 0;
if
(
demodel
.
User_Coupon_Id
>
0
)
{
var
ccmodel
=
cList
.
Where
(
x
=>
x
.
Id
==
demodel
.
User_Coupon_Id
).
FirstOrDefault
();
string
couponItem
=
(
ccmodel
?.
CouponId
??
0
).
ToString
();
if
(!
string
.
IsNullOrEmpty
(
couponItem
))
{
var
dcModel
=
dcList
.
Where
(
x
=>
x
.
ID
==
Convert
.
ToInt32
(
couponItem
)).
FirstOrDefault
();
if
(
dcModel
==
null
)
{
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
;
var
categoryList1
=
dcpList
.
Where
(
x
=>
x
.
DiscountCouponId
==
Convert
.
ToInt32
(
couponItem
)
&&
x
.
DiscountCouponType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Category
).
Select
(
x
=>
x
.
ProductId
).
ToList
();
//获取特殊优惠卷
if
(
categoryList
.
Select
(
x
=>
x
.
Id
).
Where
(
x
=>
categoryList1
.
Contains
(
x
)).
Any
())
{
GoodsCouponList
.
Add
(
new
RB_Goods_CouponModel
()
{
GoodsId
=
item
.
GoodsId
??
0
,
Key
=
item
.
SpecificationSort
,
TotalMoney
=
item
.
Final_Price
??
0
,
CouponMoney
=
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
(
couponItem
)
&&
x
.
DiscountCouponType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Product
).
Select
(
x
=>
x
.
ProductId
).
ToList
();
//获取特殊优惠卷
if
(
goodsList
.
Contains
(
item
.
GoodsId
??
0
))
{
GoodsCouponList
.
Add
(
new
RB_Goods_CouponModel
()
{
GoodsId
=
item
.
GoodsId
??
0
,
Key
=
item
.
SpecificationSort
,
TotalMoney
=
item
.
Final_Price
??
0
,
CouponMoney
=
0
});
}
}
else
if
(
dcModel
.
UseType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Product
)
//指定商品
else
{
GoodsCouponList
.
Add
(
new
RB_Goods_CouponModel
()
{
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
+
"的优惠券,未匹配到适用的商品"
);
GoodsId
=
item
.
GoodsId
??
0
,
Key
=
item
.
SpecificationSort
,
TotalMoney
=
item
.
Final_Price
??
0
,
CouponMoney
=
0
});
}
FinalMoney
=
demodel
.
DetailList
.
Where
(
x
=>
goodsList
.
Contains
(
x
.
GoodsId
??
0
)).
Sum
(
x
=>
x
.
Final_Price
??
0
);
}
else
{
FinalMoney
=
TotalMoney
;
}
#
endregion
TotalMoney
+=
(
item
.
Final_Price
??
0
);
item
.
OrderType
=
gmodel
.
GoodsType
;
item
.
GoodsName
=
gmodel
.
Name
;
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
}
item
.
SeparateDistribution
=
gmodel
.
SeparateDistribution
;
item
.
SeparateDistributionType
=
gmodel
.
SeparateDistributionType
;
item
.
SeparateDistributionMoneyType
=
gmodel
.
SeparateDistributionMoneyType
;
item
.
IntegralPresent
=
gmodel
.
IntegralPresent
;
item
.
IntegralPresentType
=
gmodel
.
IntegralPresentType
;
}
if
(
demodel
.
User_Coupon_Id
>
0
&&
GoodsCouponList
.
Any
())
{
decimal
FinalMoney
=
GoodsCouponList
.
Sum
(
x
=>
x
.
TotalMoney
);
var
ccmodel
=
cList
.
Where
(
x
=>
x
.
Id
==
demodel
.
User_Coupon_Id
).
FirstOrDefault
();
var
dcModel
=
dcList
.
Where
(
x
=>
x
.
ID
==
(
ccmodel
?.
CouponId
??
0
)).
FirstOrDefault
();
if
(
dcModel
==
null
)
{
return
ApiResult
.
Failed
(
"优惠卷不存在,亲核实后再试"
);
}
if
(
dcModel
.
MinConsumePrice
>
0
)
{
if
(
FinalMoney
<
dcModel
.
MinConsumePrice
)
{
return
ApiResult
.
Failed
(
"Id"
+
item
+
"优惠卷未达到使用要求"
)
;
FinalMoney
=
0
;
}
}
if
(
dcModel
.
CouponType
==
Common
.
Enum
.
MarketingCenter
.
CouponTypeEnum
.
FullReduction
)
if
(
dcModel
.
CouponType
==
Common
.
Enum
.
MarketingCenter
.
CouponTypeEnum
.
FullReduction
&&
FinalMoney
>
0
)
{
CouponsMoney
+
=
dcModel
.
DiscountsPrice
;
CouponsMoney
=
dcModel
.
DiscountsPrice
;
}
else
else
if
(
dcModel
.
CouponType
==
Common
.
Enum
.
MarketingCenter
.
CouponTypeEnum
.
Discount
&&
FinalMoney
>
0
)
{
decimal
disMoney
=
Math
.
Round
(
FinalMoney
*
(
10
-
dcModel
.
DiscountsPrice
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
if
(
dcModel
.
MaxDiscountsPrice
>
0
&&
dcModel
.
MaxDiscountsPrice
<
disMoney
)
{
if
(
dcModel
.
MaxDiscountsPrice
>
0
&&
dcModel
.
MaxDiscountsPrice
<
disMoney
)
{
disMoney
=
dcModel
.
MaxDiscountsPrice
;
}
CouponsMoney
+=
disMoney
;
CouponsMoney
=
disMoney
;
}
//每个商品优惠券分摊金额
if
(
CouponsMoney
>
0
)
{
foreach
(
var
item
in
GoodsCouponList
)
{
item
.
CouponMoney
=
Math
.
Round
((
item
.
TotalMoney
/
FinalMoney
)
*
CouponsMoney
,
2
,
MidpointRounding
.
AwayFromZero
);
}
if
(
CouponsMoney
!=
GoodsCouponList
.
Sum
(
x
=>
x
.
CouponMoney
))
{
//四舍五入存在差值
decimal
diffMoney
=
CouponsMoney
-
GoodsCouponList
.
Sum
(
x
=>
x
.
CouponMoney
);
var
gcModel
=
GoodsCouponList
.
OrderBy
(
x
=>
x
.
CouponMoney
).
Take
(
1
).
FirstOrDefault
();
gcModel
.
CouponMoney
+=
diffMoney
;
}
}
}
foreach
(
var
item
in
demodel
.
DetailList
)
{
var
gmodel
=
gList
.
Where
(
x
=>
x
.
Id
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
gmodel
==
null
||
gmodel
.
GoodsStatus
!=
1
)
{
continue
;
}
item
.
CouponMoney
=
0
;
var
couponModel
=
GoodsCouponList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
couponModel
!=
null
)
{
item
.
CouponMoney
=
couponModel
.
CouponMoney
;
TotalMoney
-=
(
item
.
CouponMoney
??
0
);
//总价格需减去优惠券金额
}
}
}
if
(
demodel
.
FreightMoney
!=
TotalExpress
)
{
return
ApiResult
.
Failed
(
"运费不正确"
);
}
if
(
CouponsMoney
!=
demodel
.
CouponMoney
)
{
return
ApiResult
.
Failed
(
"优惠金额计算有误"
);
...
...
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