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
614ece43
Commit
614ece43
authored
Sep 03, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品详情
parent
6ea9bf02
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
775 additions
and
0 deletions
+775
-0
GuideCarModule.cs
Mall.Module.Product/GuideCarModule.cs
+710
-0
AppletGCOrderController.cs
Mall.WebApi/Controllers/Product/AppletGCOrderController.cs
+65
-0
No files found.
Mall.Module.Product/GuideCarModule.cs
View file @
614ece43
...
@@ -5,6 +5,7 @@ using System.Text;
...
@@ -5,6 +5,7 @@ using System.Text;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
using
Mall.AOP.CustomerAttribute
;
using
Mall.AOP.CustomerAttribute
;
using
Mall.Common.API
;
using
Mall.Common.API
;
using
Mall.Common.Enum.Goods
;
using
Mall.Common.Plugin
;
using
Mall.Common.Plugin
;
using
Mall.Model.Entity.BaseSetUp
;
using
Mall.Model.Entity.BaseSetUp
;
using
Mall.Model.Entity.GuideCar
;
using
Mall.Model.Entity.GuideCar
;
...
@@ -17,6 +18,7 @@ using Mall.Model.Extend.User;
...
@@ -17,6 +18,7 @@ using Mall.Model.Extend.User;
using
Mall.Model.Query
;
using
Mall.Model.Query
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.GuideCar
;
using
Mall.Repository.GuideCar
;
using
Mall.Repository.MarketingCenter
;
using
Mall.Repository.Product
;
using
Mall.Repository.Product
;
using
Mall.Repository.User
;
using
Mall.Repository.User
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
...
@@ -157,6 +159,32 @@ namespace Mall.Module.Product
...
@@ -157,6 +159,32 @@ namespace Mall.Module.Product
/// 车辆颜色
/// 车辆颜色
/// </summary>
/// </summary>
private
RB_GuideCar_CarColorRepository
CarColorRepository
=
new
RB_GuideCar_CarColorRepository
();
private
RB_GuideCar_CarColorRepository
CarColorRepository
=
new
RB_GuideCar_CarColorRepository
();
/// <summary>
/// 积分规则
/// </summary>
private
readonly
RB_Integral_SettingsRepository
integral_SettingsRepository
=
new
RB_Integral_SettingsRepository
();
/// <summary>
/// 小程序基础
/// </summary>
private
readonly
RB_MallBaseRepository
mallBaseRepository
=
new
RB_MallBaseRepository
();
/// <summary>
/// 小程序
/// </summary>
private
readonly
RB_MiniProgramRepository
miniProgramRepository
=
new
RB_MiniProgramRepository
();
/// <summary>
/// 运费
/// </summary>
private
readonly
RB_Logistics_RulesRepository
logistics_RulesRepository
=
new
RB_Logistics_RulesRepository
();
private
readonly
RB_Logistics_RulesRegionRepository
logistics_RulesRegionRepository
=
new
RB_Logistics_RulesRegionRepository
();
/// <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
基础配置
#
region
基础配置
/// <summary>
/// <summary>
...
@@ -1718,6 +1746,688 @@ namespace Mall.Module.Product
...
@@ -1718,6 +1746,688 @@ namespace Mall.Module.Product
#
endregion
#
endregion
}
}
/// <summary>
/// 获取小程序司导商品结算页面详情
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
ApiResult
GetAppletSDGoodsSettlementInfo
(
RB_Goods_Order_Extend
demodel
)
{
var
umodel
=
member_UserRepository
.
GetEntity
(
demodel
.
UserId
);
if
(
umodel
==
null
)
{
return
ApiResult
.
Failed
(
"用户不存在"
);
}
if
(
demodel
.
SmallShopsId
==
0
)
{
demodel
.
SmallShopsId
=
umodel
.
SmallShopId
;
}
//积分
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
integralModel
=
new
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
();
if
(
umodel
.
Integral
>
0
)
{
integralModel
=
integral_SettingsRepository
.
GetIntegralSettingsList
(
new
Model
.
Entity
.
MarketingCenter
.
RB_Integral_Settings
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
}
//快递默认
demodel
.
DeliveryMethod
??=
OrderDeliveryMethodEnum
.
VerificationShop
;
#
region
区域
var
disList
=
new
List
<
int
>
{
demodel
.
District
??
0
,
demodel
.
City
??
0
,
demodel
.
Province
??
0
};
#
endregion
List
<
object
>
DList
=
new
List
<
object
>();
decimal
TotalGoodsMoney
=
0
,
TotalGoodsOriginalMoney
=
0
,
TotalGoodsSellMoney
=
0
;
//总商品价格 总原价 总售价
decimal
member_discount
=
0
;
//总会员优惠
decimal
Total_integral_price
=
0
;
//总积分金额
int
Total_use_integral
=
0
;
//总积分
decimal
CouponsMoney
=
0
;
//优惠总金额
bool
IsPointsDeduction
=
false
;
//是否有商品可使用积分抵扣
bool
address_enable
=
true
;
//地址Ok
List
<
object
>
goods_list
=
new
List
<
object
>();
if
(
demodel
.
DetailList
.
Any
())
{
string
GoodsIds
=
string
.
Join
(
","
,
demodel
.
DetailList
.
Select
(
x
=>
x
.
GoodsId
));
var
gList
=
goodsRepository
.
GetListForCar
(
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
mpriceList
=
goods_MemberPriceRepository
.
GetList
(
new
RB_Goods_MemberPrice_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
//区域
var
AreaList
=
goods_AreaRepository
.
GetList
(
new
RB_Goods_Area_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
#
region
查询司导信息
string
siteIds
=
string
.
Join
(
","
,
gList
.
Select
(
x
=>
x
.
SiteId
));
var
sitelist
=
SiteRepository
.
GetGuideCarSiteList
(
new
RB_GuideCar_Site_Extend
()
{
SiteIds
=
siteIds
});
string
guideIds
=
string
.
Join
(
","
,
gList
.
Select
(
x
=>
x
.
GuideId
));
var
guidelist
=
GuideRepository
.
GetGuideCarGuideList
(
new
RB_GuideCar_Guide_Extend
()
{
GuideIds
=
guideIds
});
string
carids
=
string
.
Join
(
","
,
gList
.
Select
(
x
=>
x
.
CarId
));
var
carlist
=
GuideCarRepository
.
GetGuideCarCarList
(
new
RB_GuideCar_Car_Extend
()
{
GuideCarIds
=
carids
});
string
colorIds
=
string
.
Join
(
","
,
gList
.
Select
(
x
=>
x
.
CarColorId
));
var
carcolorlist
=
CarColorRepository
.
GetCarColorList
(
new
RB_GuideCar_CarColor_Extend
()
{
CarColorIds
=
colorIds
});
#
endregion
#
region
查询外部设置区域限购
List
<
int
>
RAreaList
=
new
List
<
int
>();
var
RulesAreaModel
=
logistics_RulesRepository
.
GetLogisticsRulesList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
()
{
RulesType
=
Common
.
Enum
.
MallBase
.
RulesTypeEnum
.
AreaBuy
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
if
(
RulesAreaModel
!=
null
&&
RulesAreaModel
.
IsOpenMinPrice
==
1
)
{
var
RegionAreaList
=
logistics_RulesRegionRepository
.
GetListForSingle
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesRegion_Extend
()
{
RulesPriceId
=
RulesAreaModel
.
ID
,
RulesType
=
Common
.
Enum
.
MallBase
.
RulesTypeEnum
.
AreaBuy
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
RegionAreaList
.
Any
())
{
//允许以下区域购买
RAreaList
=
RegionAreaList
.
Select
(
x
=>
x
.
RegionId
).
Distinct
().
ToList
();
}
}
#
endregion
//返佣
var
DistributionCommissionList
=
new
List
<
RB_Goods_DistributionCommission_Extend
>();
if
(
demodel
.
DetailList
.
Where
(
x
=>
x
.
SeparateDistribution
==
1
).
Any
())
{
string
goodsIds
=
string
.
Join
(
","
,
demodel
.
DetailList
.
Where
(
x
=>
x
.
SeparateDistribution
==
1
).
Select
(
x
=>
x
.
GoodsId
));
DistributionCommissionList
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
#
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
>();
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
},
true
);
dcpList
=
discountCoupon_ProductRepository
.
GetListByDiscountCouponIds
(
new
Model
.
Entity
.
MarketingCenter
.
RB_DiscountCoupon
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
},
cIds
,
true
);
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
List
<
RB_Goods_CouponModel
>
GoodsCouponList
=
new
List
<
RB_Goods_CouponModel
>();
//商品优惠卷 价格(每个商品优惠的价格)
#
region
微店价格
RB_SmallShops_Info_Extend
smallModel
=
new
RB_SmallShops_Info_Extend
();
List
<
RB_SmallShops_Price_Extend
>
smallPList
=
new
List
<
RB_SmallShops_Price_Extend
>();
if
(
demodel
.
SmallShopsId
>
0
)
{
smallModel
=
smallShops_InfoRepository
.
GetEntity
<
RB_SmallShops_Info_Extend
>(
demodel
.
SmallShopsId
);
smallPList
=
smallShops_PriceRepository
.
GetList
(
new
RB_SmallShops_Price_Extend
()
{
SmallShopsId
=
demodel
.
SmallShopsId
,
GoodsIds
=
GoodsIds
});
}
#
endregion
//初始化值
foreach
(
var
item
in
demodel
.
DetailList
)
{
var
gmodel
=
gList
.
Where
(
x
=>
x
.
Id
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
gmodel
==
null
||
gmodel
.
GoodsStatus
!=
1
||
gmodel
.
GoodsClassify
!=
1
)
{
continue
;
}
var
categoryList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
ToList
();
#
region
图片
gmodel
.
CoverImage
=
""
;
//轮播
gmodel
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//轮播图
foreach
(
var
qitem
in
CarouselIdList
)
{
gmodel
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
0
,
Name
=
""
,
Path
=
qitem
});
}
//封面图
gmodel
.
CoverImage
=
CarouselIdList
[
0
];
}
#
endregion
#
region
微店价格
if
(
demodel
.
SmallShopsId
>
0
)
{
if
((
smallModel
.
UpPrice
??
0
)
>
0
||
smallPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
UpPrice
>
0
).
Any
())
{
var
sspModel
=
smallPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationKey
==
""
).
FirstOrDefault
();
if
(
sspModel
!=
null
)
{
//单商品设置的
if
(
sspModel
.
PriceType
==
1
)
{
gmodel
.
SellingPrice
+=
Math
.
Ceiling
((
gmodel
.
SellingPrice
??
0
)
*
(
sspModel
.
UpPrice
??
0
)
/
100
);
}
else
if
(
sspModel
.
PriceType
==
2
)
{
gmodel
.
SellingPrice
+=
(
sspModel
.
UpPrice
??
0
);
}
}
else
{
if
((
smallModel
.
UpPrice
??
0
)
>
0
)
{
if
(
smallModel
.
PriceType
==
1
)
{
gmodel
.
SellingPrice
+=
Math
.
Ceiling
((
gmodel
.
SellingPrice
??
0
)
*
(
smallModel
.
UpPrice
??
0
)
/
100
);
}
else
if
(
smallModel
.
PriceType
==
2
)
{
gmodel
.
SellingPrice
+=
(
smallModel
.
UpPrice
??
0
);
}
}
}
}
}
#
endregion
#
region
会员价格
gmodel
.
MemberPrice
=
gmodel
.
SellingPrice
??
0
;
List
<
object
>
discounts
=
new
List
<
object
>();
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
;
if
(
demodel
.
SmallShopsId
>
0
)
{
if
((
smallModel
.
UpPrice
??
0
)
>
0
||
smallPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
UpPrice
>
0
).
Any
())
{
var
sspModel
=
smallPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationKey
==
item
.
SpecificationSort
).
FirstOrDefault
();
if
(
sspModel
!=
null
)
{
//单商品设置的
if
(
sspModel
.
PriceType
==
1
)
{
gmodel
.
MemberPrice
+=
Math
.
Ceiling
((
gmodel
.
MemberPrice
)
*
(
sspModel
.
UpPrice
??
0
)
/
100
);
}
else
if
(
sspModel
.
PriceType
==
2
)
{
gmodel
.
MemberPrice
+=
(
sspModel
.
UpPrice
??
0
);
}
}
else
{
if
((
smallModel
.
UpPrice
??
0
)
>
0
)
{
if
(
smallModel
.
PriceType
==
1
)
{
gmodel
.
MemberPrice
+=
Math
.
Ceiling
((
gmodel
.
MemberPrice
)
*
(
smallModel
.
UpPrice
??
0
)
/
100
);
}
else
if
(
smallModel
.
PriceType
==
2
)
{
gmodel
.
MemberPrice
+=
(
smallModel
.
UpPrice
??
0
);
}
}
}
}
}
}
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
);
}
discounts
.
Add
(
new
{
name
=
"会员优惠价格"
,
value
=
(
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
))
-
((
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
))
});
member_discount
+=
(
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
))
-
((
gmodel
.
SellingPrice
??
0
)
*
(
item
.
Number
??
0
));
}
#
endregion
item
.
Final_Price
=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
);
item
.
NorGoodsMoney
=
item
.
Final_Price
??
0
;
//计算运费用
#
region
积分
if
(
umodel
.
Integral
>
0
&&
gmodel
.
PointsDeduction
>
0
&&
integralModel
.
IntegralNum
>
0
)
{
IsPointsDeduction
=
true
;
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
);
}
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
;
}
}
else
{
int
MaxInterral
=
Convert
.
ToInt32
((
gmodel
.
PointsDeduction
??
0
)
*
integralModel
.
IntegralNum
*
(
item
.
Number
??
0
));
//最多可抵扣积分
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
{
//单件商品
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
;
}
else
{
item
.
IntegralNumber
=
umodel
.
Integral
;
item
.
IntegralMoney
=
Math
.
Round
(
Convert
.
ToDecimal
(
umodel
.
Integral
??
0
)
/
integralModel
.
IntegralNum
,
2
,
MidpointRounding
.
AwayFromZero
);
umodel
.
Integral
=
0
;
}
}
}
}
decimal
integral_price
=
0
;
int
use_integral
=
0
;
if
(
demodel
.
Use_Integral
==
1
)
{
integral_price
=
item
.
IntegralMoney
??
0
;
use_integral
=
item
.
IntegralNumber
??
0
;
item
.
Final_Price
-=
integral_price
;
}
#
endregion
#
region
优惠券
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
)
{
return
ApiResult
.
Failed
(
"优惠卷不存在,亲核实后再试"
);
}
dcModel
.
DiscountsPrice
=
dcModel
.
DiscountsPrice
==
0
?
10
:
dcModel
.
DiscountsPrice
;
if
(
dcModel
.
UseType
==
Common
.
Enum
.
MarketingCenter
.
UseTypeEnum
.
Category
)
//指定分类
{
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
});
}
}
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
{
GoodsCouponList
.
Add
(
new
RB_Goods_CouponModel
()
{
GoodsId
=
item
.
GoodsId
??
0
,
Key
=
item
.
SpecificationSort
,
TotalMoney
=
item
.
Final_Price
??
0
,
CouponMoney
=
0
});
}
}
}
#
endregion
Total_integral_price
+=
(
item
.
IntegralMoney
??
0
);
Total_use_integral
+=
(
item
.
IntegralNumber
??
0
);
TotalGoodsMoney
+=
item
.
Final_Price
??
0
;
TotalGoodsOriginalMoney
+=
(
gmodel
.
OriginalPrice
??
0
)
*
(
item
.
Number
??
0
);
TotalGoodsSellMoney
+=
gmodel
.
MemberPrice
*
(
item
.
Number
??
0
);
item
.
Unit_Price
=
gmodel
.
SellingPrice
??
0
;
item
.
Original_Price
=
gmodel
.
OriginalPrice
??
0
;
item
.
MemberPrice
=
gmodel
.
MemberPrice
;
item
.
IntegralMoney
=
integral_price
;
item
.
IntegralNumber
=
use_integral
;
item
.
Discounts
=
discounts
;
item
.
CategoryIdList
=
categoryList
.
Select
(
x
=>
x
.
CategoryId
??
0
).
ToList
();
}
//优惠分摊
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
)
{
FinalMoney
=
0
;
}
}
if
(
dcModel
.
CouponType
==
Common
.
Enum
.
MarketingCenter
.
CouponTypeEnum
.
FullReduction
&&
FinalMoney
>
0
)
{
CouponsMoney
=
dcModel
.
DiscountsPrice
;
}
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
)
{
disMoney
=
dcModel
.
MaxDiscountsPrice
;
}
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
||
gmodel
.
GoodsClassify
!=
1
)
{
continue
;
}
decimal
couponMoney
=
0
;
//优惠金额
var
couponModel
=
GoodsCouponList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
couponModel
!=
null
)
{
couponMoney
=
couponModel
.
CouponMoney
;
TotalGoodsMoney
-=
couponMoney
;
//总价格需减去优惠券金额
}
var
areaGoods
=
AreaList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
ToList
();
bool
address_disabled
=
false
;
if
(
gmodel
.
IsAreaBuy
==
1
&&
areaGoods
.
Any
())
{
if
(!
areaGoods
.
Where
(
x
=>
disList
.
Contains
(
x
.
AreaId
??
0
)).
Any
())
{
address_disabled
=
true
;
address_enable
=
false
;
}
}
else
{
//验证基础设置区域购买
if
(
RAreaList
.
Any
())
{
if
(!
RAreaList
.
Where
(
x
=>
disList
.
Contains
(
x
)).
Any
())
{
address_disabled
=
true
;
address_enable
=
false
;
}
}
}
#
region
司导信息
string
SiteName
=
sitelist
.
Where
(
x
=>
x
.
ID
==
gmodel
.
SiteId
).
FirstOrDefault
()?.
SiteName
??
""
;
string
GuideName
=
guidelist
.
Where
(
x
=>
x
.
ID
==
gmodel
.
GuideId
).
FirstOrDefault
()?.
Name
??
""
;
decimal
GuideScore
=
guidelist
.
Where
(
x
=>
x
.
ID
==
gmodel
.
GuideId
).
FirstOrDefault
()?.
Score
??
0
;
string
CarName
=
carlist
.
Where
(
x
=>
x
.
ID
==
gmodel
.
CarId
).
FirstOrDefault
()?.
Name
??
""
;
string
CarColorName
=
carcolorlist
.
Where
(
x
=>
x
.
ID
==
gmodel
.
CarColorId
).
FirstOrDefault
()?.
ColorName
??
""
;
#
endregion
goods_list
.
Add
(
new
{
id
=
gmodel
.
Id
,
name
=
gmodel
.
Name
,
categoryIdList
=
item
.
CategoryIdList
,
num
=
item
.
Number
,
forehead_integral
=
gmodel
.
PointsDeduction
,
forehead_integral_type
=
gmodel
.
PointsDeductionType
,
accumulative
=
gmodel
.
IsMultipleDeduction
,
//累计多件抵扣
address_disabled
,
unit_price
=
item
.
Unit_Price
,
total_original_price
=
(
item
.
Original_Price
??
0
)
*
(
item
.
Number
??
0
),
total_price
=
(
item
.
Unit_Price
??
0
)
*
(
item
.
Number
??
0
),
//优惠券(有平摊情况) 积分抵扣 (默认从第一个商品抵扣)
goods_attr
=
new
{
id
=
0
,
goods_id
=
gmodel
.
Id
,
sign_id
=
item
.
SpecificationSort
,
stock
=
gmodel
.
InventoryNum
,
price
=
item
.
Unit_Price
??
0
,
original_price
=
item
.
Original_Price
??
0
,
pic_url
=
gmodel
.
CoverImage
,
individual_share
=
umodel
?.
IsDistributor
??
2
,
// 是否分销商
share_type
=
gmodel
.
SeparateDistributionMoneyType
,
//分销佣金类型,
member_price
=
item
.
MemberPrice
,
integral_price
=
demodel
.
Use_Integral
==
1
?
item
.
IntegralMoney
:
0
,
//积分抵扣金额
use_integral
=
demodel
.
Use_Integral
==
1
?
item
.
IntegralNumber
:
0
,
couponMoney
,
name
=
gmodel
.
Name
,
cover_pic
=
gmodel
.
CoverImage
,
detail
=
gmodel
.
GoodsDetails
,
pic_list
=
gmodel
.
CarouselImageList
.
Select
(
x
=>
new
{
id
=
x
.
Id
,
pic_url
=
x
.
Path
}),
number
=
item
.
Number
,
goods_share_level
=
DistributionCommissionList
.
Where
(
x
=>
x
.
GoodsId
==
gmodel
.
Id
).
Select
(
x
=>
new
{
share_commission_first
=
x
.
OneCommission
,
share_commission_second
=
x
.
TwoCommission
,
share_commission_third
=
x
.
ThreeCommission
,
level
=
x
.
DistributorGrade
}),
attr_setting_type
=
gmodel
.
SeparateDistributionType
,
site_name
=
SiteName
,
site_id
=
gmodel
.
SiteId
,
guide_name
=
GuideName
,
guide_id
=
gmodel
.
GuideId
,
car_name
=
CarName
,
car_id
=
gmodel
.
CarId
,
carcolor_name
=
CarColorName
,
carcolor_id
=
gmodel
.
CarColorId
,
car_number
=
gmodel
.
CarNumber
,
car_buyyear
=
gmodel
.
CarBuyYear
,
car_type
=
gmodel
.
CarType
,
car_type_name
=
gmodel
.
CarType
.
GetEnumName
(),
use_day
=
gmodel
.
UseDay
,
line_name
=
gmodel
.
LineName
,
is_spell
=
gmodel
.
IsSpell
,
ride_num
=
gmodel
.
RideNum
,
advance_day
=
gmodel
.
AdvanceDay
,
},
discounts
=
item
.
Discounts
,
member_discount
=
((
item
.
Unit_Price
??
0
)
*
(
item
.
Number
??
0
))
-
(
item
.
MemberPrice
*
(
item
.
Number
??
0
)),
cover_pic
=
gmodel
.
CoverImage
,
is_level_alone
=
gmodel
.
SeparateSetMember
,
//是否单独设置会员价
is_level
=
gmodel
.
EnjoyMember
,
//是否销售会员价格
sign
=
""
,
marketingLogo
=
gmodel
.
MarketingLogo
});
}
}
#
region
其他封装
List
<
object
>
mch_list
=
new
List
<
object
>();
var
minModel
=
miniProgramRepository
.
GetEntity
(
demodel
.
MallBaseId
);
//积分
var
IntegralObj
=
new
{
can_use
=
IsPointsDeduction
,
use
=
demodel
.
Use_Integral
==
1
?
true
:
false
,
use_num
=
Total_use_integral
,
deduction_price
=
Total_integral_price
};
#
region
提示无上级不返佣
bool
PromptNoSuperiorFY
=
false
;
var
disbaseModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
if
((
disbaseModel
?.
IsEnableFXGrade
??
2
)
==
1
&&
(
disbaseModel
?.
IsEnableNoSuperiorFY
??
1
)
==
2
)
{
if
((
umodel
.
SuperiorId
??
0
)
==
0
)
{
PromptNoSuperiorFY
=
true
;
}
}
#
endregion
mch_list
.
Add
(
new
{
mch
=
new
{
id
=
minModel
?.
MallBaseId
??
0
,
name
=
minModel
?.
MallName
??
""
},
goods_list
,
remark
=
""
,
total_goods_price
=
TotalGoodsSellMoney
,
total_goods_original_price
=
TotalGoodsOriginalMoney
,
member_discount
,
coupon
=
new
{
enabled
=
true
,
use
=
demodel
.
User_Coupon_Id
>
0
?
true
:
false
,
coupon_discount
=
CouponsMoney
,
user_coupon_id
=
demodel
.
User_Coupon_Id
??
0
},
integral
=
IntegralObj
,
total_price
=
TotalGoodsMoney
,
});
//订阅
List
<
string
>
template_message_list
=
new
List
<
string
>();
if
(
minModel
!=
null
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
minModel
.
OrderSuccessTpl
))
{
template_message_list
.
Add
(
minModel
.
OrderSuccessTpl
);
}
if
(!
string
.
IsNullOrWhiteSpace
(
minModel
.
OrderCancelTpl
))
{
template_message_list
.
Add
(
minModel
.
OrderCancelTpl
);
}
if
(!
string
.
IsNullOrWhiteSpace
(
minModel
.
OrderDeliverGoodsTpl
))
{
template_message_list
.
Add
(
minModel
.
OrderDeliverGoodsTpl
);
}
}
var
Robj
=
new
{
mch_list
,
promptNoSuperiorFY
=
PromptNoSuperiorFY
,
total_price
=
TotalGoodsMoney
,
price_enable
=
true
,
address
=
new
{
demodel
.
District
,
demodel
.
City
,
demodel
.
Province
,
demodel
.
ShoppingAddress
},
address_enable
,
template_message_list
};
#
endregion
return
ApiResult
.
Success
(
""
,
Robj
);
}
#
endregion
#
endregion
#
region
站点配置
#
region
站点配置
...
...
Mall.WebApi/Controllers/Product/AppletGCOrderController.cs
0 → 100644
View file @
614ece43
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.GuideCar
;
using
Mall.Model.Extend.Product
;
using
Mall.Module.Product
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.Product
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
AppletGCOrderController
:
BaseController
{
private
readonly
GuideCarModule
guideCarModule
=
new
GuideCarModule
();
#
region
订单信息
/// <summary>
/// 司导商品结算页面详情
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetAppletSDGoodsSettlementInfo
()
{
var
req
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
RB_Goods_Order_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Goods_Order_Extend
>(
req
.
msg
.
ToString
());
if
(
demodel
.
DetailList
==
null
||
!
demodel
.
DetailList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递商品信息"
);
}
foreach
(
var
item
in
demodel
.
DetailList
)
{
if
((
item
.
GoodsId
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递商品id"
);
}
if
((
item
.
Number
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递商品数量"
);
}
}
demodel
.
TenantId
=
userInfo
.
TenantId
;
demodel
.
MallBaseId
=
userInfo
.
MallBaseId
;
demodel
.
UserId
=
userInfo
.
UserId
;
demodel
.
SmallShopsId
=
req
.
SmallShopsId
;
return
guideCarModule
.
GetAppletSDGoodsSettlementInfo
(
demodel
);
}
#
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