fixed 修改细节

This commit is contained in:
AERWEN\26795 2023-10-13 13:36:46 +08:00
parent ee4e6ce009
commit 2ea11afe9d
14 changed files with 240 additions and 61 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ARW.Model.Models.Business.GoodsManager.Goodss;
namespace ARW.Model.Dto.Api.GoodsManager.Goodss
{
/// <summary>
/// 商品查询对象Api
///
/// @author lwh
/// @date 2023-07-09
/// </summary>
public class GoodsFreightDto
{
/// <summary>
/// 待结算商品
/// </summary>
public List<GoodsRequest> GoodsRequestList { get; set; }
/// <summary>
/// 地址guid
/// </summary>
public long CustomerAddressGuid { get; set; }
}
public class GoodsRequest
{
/// <summary>
/// 商品Id
/// </summary>
public long SpuId { get; set; }
/// <summary>
/// 商品SkuId
/// </summary>
public int SkuId { get; set; }
/// <summary>
/// 购买数量
/// </summary>
public int Quantity { get; set; }
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ARW.Model.Models.Business.Carts;
namespace ARW.Model.Dto.Api.Carts
namespace ARW.Model.Dto.Api.Pay
{
/// <summary>

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ARW.Model.Models.Business.Carts;
namespace ARW.Model.Dto.Api.Carts
namespace ARW.Model.Dto.Api.Pay
{
/// <summary>
@ -29,18 +29,6 @@ namespace ARW.Model.Dto.Api.Carts
/// </summary>
public string OpenId { get; set; }
/// <summary>
/// 核销前价格
/// </summary>
public decimal BeforeMoney { get; set; }
/// <summary>
/// 核销后价格/操作金额
/// </summary>
public decimal Money { get; set; }
/// <summary>
/// 留言
/// </summary>
@ -51,5 +39,10 @@ namespace ARW.Model.Dto.Api.Carts
/// </summary>
public int CouponId { get; set;}
/// <summary>
/// 待结算购物车商品
/// </summary>
public List<GoodsRequest> GoodsRequestList { get; set; }
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ARW.Model.Models.Business.Carts;
namespace ARW.Model.Dto.Api.Carts
namespace ARW.Model.Dto.Api.Pay
{
/// <summary>
@ -19,28 +19,5 @@ namespace ARW.Model.Dto.Api.Carts
/// </summary>
public int CartId { get; set; }
/// <summary>
/// 购物车加入时间
/// </summary>
public DateTime JoinCartTime { get; set; }
/// <summary>
/// 小程序用户OpenId
/// </summary>
public string openId { get; set; }
/// <summary>
/// 待结算的商品集合
/// </summary>
public string goodsRequestList { get; set; }
/// <summary>
/// 发票信息
/// </summary>
public string invoiceRequest { get; set; }
}
}

View File

@ -22,6 +22,13 @@ using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
using ARW.Repository.Business.GoodsManager.GoodsCategorys;
using System;
using ARW.Common;
using Microsoft.AspNetCore.Components.Forms;
using ARW.Repository.Business.LogisticsManage.Deliverys;
using ARW.Repository.Business.Custom.CustomerAddresses;
using ARW.Repository.Business.LogisticsManage.DeliveryRules;
using Infrastructure;
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
using ARW.Model.Vo.Business.GoodsManager.Goodss;
namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
{
@ -40,9 +47,12 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
private readonly SpecValueRepository _SpecValueRepository;
private readonly GoodsSkuRepository _GoodsSkuRepository;
private readonly GoodsCategoryRepository _GoodsCategoryRepository;
private readonly DeliveryRepository _DeliveryRepository;
private readonly DeliveryRuleRepository _DeliveryRuleRepository;
private readonly CustomerAddressRepository _CustomerAddressRepository;
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository)
public GoodsServiceImplApi(GoodsRepository GoodsRepository, GoodsSpecRelRepository goodsSpecRelRepository, SpecRepository specRepository, SpecValueRepository specValueRepository, GoodsSkuRepository goodsSkuRepository, GoodsCategoryRepository goodsCategoryRepository, DeliveryRepository deliveryRepository, CustomerAddressRepository customerAddressRepository, DeliveryRuleRepository deliveryRuleRepository)
{
this._GoodsRepository = GoodsRepository;
_GoodsSpecRelRepository = goodsSpecRelRepository;
@ -50,6 +60,9 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
_SpecValueRepository = specValueRepository;
_GoodsSkuRepository = goodsSkuRepository;
_GoodsCategoryRepository = goodsCategoryRepository;
_DeliveryRepository = deliveryRepository;
_CustomerAddressRepository = customerAddressRepository;
_DeliveryRuleRepository = deliveryRuleRepository;
}
#region Api接口代码
@ -87,18 +100,18 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
predicate = predicate.AndIF(parm.MaxPrice != 0, s => s.GoodsPriceLowest <= parm.MaxPrice);
var sortType = OrderByType.Asc;
if(parm.GoodsSortType == 1) sortType = OrderByType.Desc;
if (parm.GoodsSortType == 1) sortType = OrderByType.Desc;
var query = _GoodsRepository
.Queryable()
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
.Where(predicate.ToExpression())
.WhereIF(parm.GoodsCategoryGuid != null, (s,c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid)
.WhereIF(parm.GoodsCategoryGuid != null, (s, c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid)
//.WhereIF(parm.GoodsCategoryGuid != null, (s, c) => c.ShopBusinessCategoryGuid == parm.GoodsCategoryGuid || goodsCategoryArr.Contains(c.ShopBusinessCategoryGuid.ToString()))
.Where(s => s.GoodsShelfStatus == 1)
.OrderByIF(parm.GoodsSort == 0 , s => s.GoodsSort, OrderByType.Asc)
.OrderByIF(parm.GoodsSort == 1 , s => s.GoodsPriceLowest, sortType)
.OrderByIF(parm.GoodsSort == 2 , s => s.GoodsSalesInitial + s.GoodsSalesActual, sortType)
.OrderByIF(parm.GoodsSort == 0, s => s.GoodsSort, OrderByType.Asc)
.OrderByIF(parm.GoodsSort == 1, s => s.GoodsPriceLowest, sortType)
.OrderByIF(parm.GoodsSort == 2, s => s.GoodsSalesInitial + s.GoodsSalesActual, sortType)
//.OrderBy(s => s.GoodsSort, OrderByType.Desc)
.Select((s, c) => new GoodsVoApi
{
@ -160,7 +173,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
});
var list = await query.ToListAsync();
var list = await query.ToListAsync();
foreach (var item in list)
{
@ -170,6 +183,65 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
return list;
}
/// <summary>
/// 获取商品运费(Api)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public async Task<decimal> GetGoodsFreight(GoodsFreightDto parm)
{
decimal freight = 0;
foreach (var item in parm.GoodsRequestList)
{
var goods = await _GoodsRepository.GetFirstAsync(s => s.GoodsGuid == item.SpuId);
var delivery = await _DeliveryRepository.GetFirstAsync(s => s.DeliveryGuid == goods.DeliveryGuid);
var deliveRule = await _DeliveryRuleRepository.GetFirstAsync(s => s.DeliveryGuid == delivery.DeliveryGuid);
var adress = await _CustomerAddressRepository.GetFirstAsync(s => s.CustomerAddressGuid == parm.CustomerAddressGuid);
// 判断是否在配送范围
var regionIdList = Tools.SpitIntArrary(deliveRule.DeliveryRuleRegion).ToList();
if (regionIdList.Contains(adress.CustomerAddressCityId))
{
// 判断是否免运费
if (deliveRule.DeliveryRuleFirstFee == 0)
return freight;
// 按件计费
if (delivery.DeliveryBillingMethod == 1)
{
freight += CalculateFreight(item.Quantity, deliveRule);
}
// 按重量计费
if (delivery.DeliveryBillingMethod == 2)
{
// 是否有sku
if (item.SkuId != 0)
{
var sku = await _GoodsSkuRepository.GetFirstAsync(s => s.GoodsSkuId == item.SkuId);
if (sku == null) return freight;
var skuWeight = sku.GoodsSkuWeight * item.Quantity;
freight += CalculateFreight(skuWeight, deliveRule);
}
else
{
var allWeight = goods.GoodsWeight * item.Quantity;
freight += CalculateFreight(allWeight, deliveRule);
}
}
}
else
{
throw new CustomException($"{goods.GoodsName} 不在配送范围内");
}
}
return Math.Round(freight, 2); ;
}
/// <summary>
/// 查询商品详情(Api)
/// </summary>
@ -182,7 +254,7 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
.Queryable()
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
.Where(s => s.GoodsGuid == parm.SpuId)
.Select((s,c) => new GoodsApiDetailsVo
.Select((s, c) => new GoodsApiDetailsVo
{
SpuId = s.GoodsGuid,
ShopGuid = s.ShopGuid,
@ -364,6 +436,30 @@ namespace ARW.Service.Api.BusinessService.GoodsManager.Goodss
return resList;
}
/// <summary>
/// 计算运费
/// </summary>
/// <param name="parm"></param>
/// <param name="deliveRule"></param>
/// <returns></returns>
public decimal CalculateFreight(decimal parm, DeliveryRule deliveRule)
{
decimal freight = 0;
// 是否超过首件/首重
if (parm >= deliveRule.DeliveryRuleFirst)
{
freight += deliveRule.DeliveryRuleFirstFee;
if (parm > deliveRule.DeliveryRuleFirst)
{
var additionalCount = parm - deliveRule.DeliveryRuleFirst;
var additionalFee = additionalCount / deliveRule.DeliveryRuleAdditional * deliveRule.DeliveryRuleAdditionalFee;
freight += additionalFee;
}
}
return freight;
}
#endregion
}

View File

@ -16,6 +16,7 @@ using ARW.Model.Dto.Api.Carts;
using ARW.Repository.Business.Marketing.CouponManage.Coupons;
using Org.BouncyCastle.Crypto.Prng;
using Aliyun.Acs.Core.Logging;
using ARW.Model.Dto.Api.Pay;
namespace ARW.Service.Api.BusinessService.PaymentManage
{
@ -35,9 +36,10 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
private readonly PaymentRepository _PaymentRepository;
private readonly CouponRepository _CouponRepository;
private readonly SenparcHttpClient _httpClient;
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public PayServiceApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository, OrderRepository orderRepository, PaymentRepository paymentRepository, CouponRepository couponRepository)
public PayServiceApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository, OrderRepository orderRepository, PaymentRepository paymentRepository, CouponRepository couponRepository, SenparcHttpClient httpClient)
{
this._ShopRepository = ShopRepository;
_GoodsCategoryRepository = goodsCategoryRepository;
@ -45,6 +47,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
_OrderRepository = orderRepository;
_PaymentRepository = paymentRepository;
_CouponRepository = couponRepository;
_httpClient = httpClient;
}
#region Api接口代码
@ -140,11 +143,13 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
GoodsTotalAmoun = parm.BeforeMoney,
OrderAmount = parm.Money,
PayPrice = parm.Money,
OrderRemark = parm.Remark,
OrderRemark = parm?.Remark,
PayType = parm.PayType,
PayStatus = 1,
};
// 计算总额
// 优惠券减免价格
if (parm.CouponId != 0)
{

View File

@ -33,6 +33,15 @@ namespace ARW.Service.Api.IBusinessService.GoodsManager.Goodss
/// <returns></returns>
Task<List<GoodsVoApi>> GetGoodsApi(GoodsQueryDtoApi parm);
/// <summary>
/// 获取商品运费(Api)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
Task<decimal> GetGoodsFreight(GoodsFreightDto parm);
/// <summary>
/// 获取商品详情(Api)
/// </summary>

View File

@ -1,5 +1,6 @@
using System.Threading.Tasks;
using ARW.Model.Dto.Api.Carts;
using ARW.Model.Dto.Api.Pay;
using ARW.Model.Models.Business.Payments;
using static Infrastructure.WeChat.TenPay.Pay;

View File

@ -44,7 +44,7 @@ namespace ARW.WebApi.Controllers.Api.GoodsManager.Goodss
/// 获取商品列表(Api)
/// </summary>
/// <param name="parm">查询参数</param>
/// <returns></returns>
/// <returns></returns>z
[HttpGet("getGoodsList")]
public async Task<IActionResult> GetGoodsListApi([FromQuery] GoodsQueryDtoApi parm)
{
@ -52,6 +52,19 @@ namespace ARW.WebApi.Controllers.Api.GoodsManager.Goodss
return SUCCESS(res);
}
/// <summary>
/// 获取商品运费(Api)
/// </summary>
/// <param name="parm">查询参数</param>
/// <returns></returns>
[HttpPost("getGoodsFreight")]
public async Task<IActionResult> GetGoodsFreight([FromBody] GoodsFreightDto parm)
{
var res = await _GoodsServiceApi.GetGoodsFreight(parm);
return SUCCESS(res);
}
/// <summary>
/// 获取Goods详情(Api)
/// </summary>

View File

@ -14,6 +14,7 @@ using ARW.Service.Business.IBusinessService.Custom.Customers;
using ARW.Service.Api.IBusinessService.PayManage;
using ARW.Service.Api.BusinessService.PaymentManage;
using ARW.Model.Dto.Api.Carts;
using ARW.Model.Dto.Api.Pay;
namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
{

View File

@ -2,7 +2,7 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 8888
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
@ -14,6 +14,8 @@ COPY ["ARW.Model/ARW.Model.csproj", "ARW.Model/"]
COPY ["ARW.Common/ARW.Common.csproj", "ARW.Common/"]
COPY ["ARW.Service/ARW.Service.csproj", "ARW.Service/"]
COPY ["ARW.Tasks/ARW.Tasks.csproj", "ARW.Tasks/"]
RUN mkdir /app/bin/Debug/net6.0
RUN cp ARW.WebApi/bin/Debug/net6.0/ARW.Model.dll /app/bin/Debug/net6.0
RUN dotnet restore "ARW.WebApi/ARW.WebApi.csproj"
COPY . .
WORKDIR "/src/ARW.WebApi"

View File

@ -1,12 +1,9 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 8888
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o publish
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build /src/publish ./
ENTRYPOINT ["dotnet", "ARW.WebApi.dll"]
COPY ../

32
Dockerfile Normal file
View File

@ -0,0 +1,32 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 8888
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["ARW.WebApi/ARW.WebApi.csproj", "ARW.WebApi/"]
COPY ["ARW.CodeGenerator/ARW.CodeGenerator.csproj", "ARW.CodeGenerator/"]
COPY ["ARW.Repository/ARW.Repository.csproj", "ARW.Repository/"]
COPY ["Infrastructure/Infrastructure.csproj", "Infrastructure/"]
COPY ["ARW.Model/ARW.Model.csproj", "ARW.Model/"]
COPY ["ARW.Common/ARW.Common.csproj", "ARW.Common/"]
COPY ["ARW.Service/ARW.Service.csproj", "ARW.Service/"]
COPY ["ARW.Tasks/ARW.Tasks.csproj", "ARW.Tasks/"]
RUN dotnet restore "ARW.WebApi/ARW.WebApi.csproj"
COPY . .
WORKDIR "/src/ARW.WebApi"
RUN dotnet build "ARW.WebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ARW.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
RUN mkdir bin
RUN mkdir ./bin/Debug
RUN mkdir ./bin/Debug/net6.0
RUN cp ARW.Model.dll ./bin/Debug/net6.0
ENTRYPOINT ["dotnet", "ARW.WebApi.dll"]