设置价格 折扣
This commit is contained in:
@@ -45,8 +45,10 @@ namespace Home.Controllers
|
||||
WxAppUserService m_WxAppUserService;
|
||||
UserService m_UserService;
|
||||
ProductUserPriceService m_ProductUserPriceService;
|
||||
ProductPriceSchemeService m_ProductPriceSchemeService;
|
||||
public productController(ProductService _ProductService
|
||||
, ProductOrderService _ProductOrderService
|
||||
, ProductPriceSchemeService _ProductPriceSchemeService
|
||||
, ProductPackageService _ProductPackageService
|
||||
, WxPayClient _WxPayClient
|
||||
,ProductAccountService _ProductAccountService
|
||||
@@ -57,6 +59,7 @@ namespace Home.Controllers
|
||||
{
|
||||
m_ProductService = _ProductService;
|
||||
m_ProductOrderService = _ProductOrderService;
|
||||
m_ProductPriceSchemeService = _ProductPriceSchemeService;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_Configuration = _Configuration;
|
||||
m_WxPayClient = _WxPayClient;
|
||||
@@ -86,26 +89,59 @@ namespace Home.Controllers
|
||||
//从user表获取用户信息
|
||||
var user_Info = await m_UserService.GetById(userInfo.UserId);
|
||||
var ProductAccountCount = user_Info.ProductAccountCount;
|
||||
var userPrices = await m_ProductUserPriceService.GetProductUserPrice(userInfo.UserId);
|
||||
|
||||
foreach(var product in respList)
|
||||
{
|
||||
product.Packages.ForEach(m => {
|
||||
|
||||
var userPrice = userPrices.FirstOrDefault(p => p.PackageId == m.Id && p.ProductId == m.ProductId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
m.Price = userPrice.UserPrice;
|
||||
}
|
||||
if (ProductAccountCount == 0 && m.DayCount == 1){
|
||||
m.Price = 0.1M;
|
||||
}
|
||||
});
|
||||
}
|
||||
if(user_Info.agent_id == 0||(user_Info.agent_id != 0 && user_Info.discount_id != 0)){
|
||||
//根据折扣设置价格
|
||||
|
||||
var discount = await m_ProductPriceSchemeService.GetById(user_Info.discount_id);
|
||||
var dis_price = 1000000.0M;
|
||||
foreach(var product in respList)
|
||||
{
|
||||
product.Packages.ForEach(m => {
|
||||
|
||||
if (discount != null)
|
||||
{
|
||||
dis_price = m.LinePrice * discount.discount / 100;
|
||||
}
|
||||
if(dis_price<m.Price){
|
||||
m.Price = dis_price;
|
||||
m.Title = discount.Remark;
|
||||
} else {
|
||||
m.Title = "9";
|
||||
}
|
||||
if (ProductAccountCount == 0 && m.DayCount == 1){
|
||||
m.Price = 0.1M;
|
||||
}
|
||||
if(m.Price<m.MinPrice){
|
||||
m.Price = m.MinPrice;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
//根据会员价
|
||||
var userPrices = await m_ProductUserPriceService.GetProductUserPrice(userInfo.UserId);
|
||||
|
||||
foreach(var product in respList)
|
||||
{
|
||||
product.Packages.ForEach(m => {
|
||||
m.Title = "9";
|
||||
|
||||
var userPrice = userPrices.FirstOrDefault(p => p.PackageId == m.Id && p.ProductId == m.ProductId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
m.Price = userPrice.UserPrice;
|
||||
}
|
||||
if (ProductAccountCount == 0 && m.DayCount == 1){
|
||||
m.Price = 0.1M;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach(var product in respList)
|
||||
{
|
||||
product.Packages.ForEach(m => {
|
||||
m.Title = "9";
|
||||
if ( m.DayCount == 1 ){
|
||||
m.Price = 0.1M;
|
||||
}
|
||||
@@ -676,14 +712,32 @@ namespace Home.Controllers
|
||||
var user_Info = await m_UserService.GetById(userId);
|
||||
var ProductAccountCount = user_Info.ProductAccountCount;
|
||||
|
||||
var userPrice = await m_ProductUserPriceService.GetPackageUserPrice(package.Id, userId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
package.Price = userPrice.UserPrice;
|
||||
var dis_price = 1000000M;
|
||||
if(user_Info.agent_id == 0||(user_Info.agent_id != 0 && user_Info.discount_id != 0)){
|
||||
//根据折扣设置价格
|
||||
var discount = await m_ProductPriceSchemeService.GetById(user_Info.discount_id);
|
||||
if (discount != null)
|
||||
{
|
||||
dis_price = package.LinePrice * discount.discount / 100;
|
||||
}
|
||||
} else {
|
||||
//根据会员价
|
||||
var userPrice = await m_ProductUserPriceService.GetPackageUserPrice(package.Id, userId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
dis_price = userPrice.UserPrice;
|
||||
}
|
||||
}
|
||||
if(dis_price<package.Price){
|
||||
package.Price = dis_price;
|
||||
}
|
||||
|
||||
if (ProductAccountCount == 0 && package.DayCount == 1){
|
||||
package.Price = 0.1M;
|
||||
}
|
||||
if(package.Price<package.MinPrice){
|
||||
package.Price = package.MinPrice;
|
||||
}
|
||||
|
||||
return View("buy", new PackageInfoResponse()
|
||||
{
|
||||
@@ -722,15 +776,50 @@ namespace Home.Controllers
|
||||
var userInfo = this.Request.GetUserInfo();
|
||||
if (userInfo != null)
|
||||
{
|
||||
var userPrices = await m_ProductUserPriceService.GetProductUserPrice(id, userInfo.UserId);
|
||||
respList.Packages.ForEach(m =>
|
||||
{
|
||||
var userPrice = userPrices.FirstOrDefault(p => p.PackageId == m.Id);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
|
||||
|
||||
//从user表获取用户信息
|
||||
var user_Info = await m_UserService.GetById(userInfo.UserId);
|
||||
|
||||
if(user_Info.agent_id == 0||(user_Info.agent_id != 0 && user_Info.discount_id != 0)){
|
||||
//根据折扣设置价格
|
||||
|
||||
var discount = await m_ProductPriceSchemeService.GetById(user_Info.discount_id);
|
||||
var dis_price = 1000000.0M;
|
||||
|
||||
respList.Packages.ForEach(m => {
|
||||
|
||||
if (discount != null)
|
||||
{
|
||||
dis_price = m.LinePrice * discount.discount / 100;
|
||||
}
|
||||
if(dis_price<m.Price){
|
||||
m.Price = dis_price;
|
||||
m.Title = discount.Remark;
|
||||
} else {
|
||||
m.Title = "9";
|
||||
}
|
||||
if(m.Price<m.MinPrice){
|
||||
m.Price = m.MinPrice;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
//根据会员价
|
||||
var userPrices = await m_ProductUserPriceService.GetProductUserPrice(id, userInfo.UserId);
|
||||
respList.Packages.ForEach(m =>
|
||||
{
|
||||
m.Price = userPrice.UserPrice;
|
||||
}
|
||||
});
|
||||
m.Title = "9";
|
||||
var userPrice = userPrices.FirstOrDefault(p => p.PackageId == m.Id);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
m.Price = userPrice.UserPrice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return View(respList);
|
||||
}
|
||||
@@ -753,11 +842,32 @@ namespace Home.Controllers
|
||||
var accountEntity = await m_ProductAccountService.GetProductAccountInfo(package.ProductId, account);
|
||||
|
||||
var userId = this.Request.GetUserInfo().UserId;
|
||||
var userPrice = await m_ProductUserPriceService.GetPackageUserPrice(packageId, userId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
package.Price = userPrice.UserPrice;
|
||||
|
||||
var user_Info = await m_UserService.GetById(userId);
|
||||
var dis_price = 1000000M;
|
||||
if(user_Info.agent_id == 0||(user_Info.agent_id != 0 && user_Info.discount_id != 0)){
|
||||
//根据折扣设置价格
|
||||
var discount = await m_ProductPriceSchemeService.GetById(user_Info.discount_id);
|
||||
if (discount != null)
|
||||
{
|
||||
dis_price = package.LinePrice * discount.discount / 100;
|
||||
}
|
||||
} else {
|
||||
//根据会员价
|
||||
var userPrice = await m_ProductUserPriceService.GetPackageUserPrice(packageId, userId);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
dis_price = userPrice.UserPrice;
|
||||
}
|
||||
}
|
||||
if(dis_price<package.Price){
|
||||
package.Price = dis_price;
|
||||
}
|
||||
|
||||
if(package.Price<package.MinPrice){
|
||||
package.Price = package.MinPrice;
|
||||
}
|
||||
|
||||
|
||||
var model = new PackageInfoResponse()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user