master
wufan 2 months ago
parent 0784e68a90
commit a2a6d4345c

@ -0,0 +1,42 @@
using System.Collections.Generic;
namespace TradeManageNew.Models.Shage
{
public class GetOrderUsedSaleDto
{
public int OrderId { get; set; }
/// <summary>
/// 订单号
/// </summary>
public string OrderCode { get; set; }
/// <summary>
/// sku明细
/// </summary>
public List<GetOrderUsedSaleItemDto> Items { get; set; } = new List<GetOrderUsedSaleItemDto>();
}
public class GetOrderUsedSaleItemDto
{
/// <summary>
/// 产品编码
/// </summary>
public string ProductCode { get; set; }
/// <summary>
/// 产品描述
/// </summary>
public string ProductDescription { get; set; }
/// <summary>
/// SKU ID
/// </summary>
public int GoodsDetailId { get; set; }
/// <summary>
/// sku编码
/// </summary>
public string SkuCode { get; set; }
}
}

@ -1,6 +1,6 @@
namespace TradeManageNew.Models.Shage namespace TradeManageNew.Models.Shage
{ {
public class GetOrderUsedSale public class GetOrderUsedSaleInput
{ {
/// <summary> /// <summary>
/// 跟踪号 /// 跟踪号

@ -1371,7 +1371,7 @@ namespace TradeManageNew.OuterService
md.Data = null; md.Data = null;
} }
} }
if (Method == "OrderUsedSaleEntry") if (Method == "PostOrderUsedSaleEntry")
{ {
var input = JsonConvert.DeserializeObject<OrderUsedSaleEntryInput>(ResponseContent); var input = JsonConvert.DeserializeObject<OrderUsedSaleEntryInput>(ResponseContent);
var validatedSuccess = true; var validatedSuccess = true;
@ -1442,7 +1442,7 @@ namespace TradeManageNew.OuterService
$"There is no product information with ID {orderItem.DetailId}"); $"There is no product information with ID {orderItem.DetailId}");
} }
//检查是否存在相同跟踪号不同订单号的订单 //检查是否存在相同跟踪号不同订单的情况
var repeatTrackingCodeOrderIds = db.DT_OrderUsedSaleEntry var repeatTrackingCodeOrderIds = db.DT_OrderUsedSaleEntry
.Where(x => x.TrackingCode == input.TrackingCode) .Where(x => x.TrackingCode == input.TrackingCode)
.Select(x => x.OrderId) .Select(x => x.OrderId)
@ -1458,7 +1458,7 @@ namespace TradeManageNew.OuterService
{ {
OrderId = order.OrderId, OrderId = order.OrderId,
OrderCode = order.OrderCode, OrderCode = order.OrderCode,
GoodsId = sku.DetailId, GoodsDetailId = sku.DetailId,
GoodsCode = sku.SKU1, GoodsCode = sku.SKU1,
Quantity = input.Quantity, Quantity = input.Quantity,
TrackingCode = input.TrackingCode, TrackingCode = input.TrackingCode,
@ -1478,7 +1478,7 @@ namespace TradeManageNew.OuterService
if (Method == "GetOrderUsedSale") if (Method == "GetOrderUsedSale")
{ {
var input = JsonConvert.DeserializeObject<GetOrderUsedSale>(ResponseContent); var input = JsonConvert.DeserializeObject<GetOrderUsedSaleInput>(ResponseContent);
if (string.IsNullOrWhiteSpace(input.TrackingCode)) if (string.IsNullOrWhiteSpace(input.TrackingCode))
{ {
md.Code = "400"; md.Code = "400";
@ -1488,174 +1488,61 @@ namespace TradeManageNew.OuterService
else else
{ {
input.TrackingCode = input.TrackingCode.Trim(); input.TrackingCode = input.TrackingCode.Trim();
//可能需要处理扫描面单匹配的问题
using (var db = new ErpDbContext()) using (var db = new ErpDbContext())
{ {
//此前已校验过一个跟踪号只能匹配相同的订单号
var orderUsedSaleEntryList = db.DT_OrderUsedSaleEntry var orderUsedSaleEntryList = db.DT_OrderUsedSaleEntry
.Where(x => x.TrackingCode == input.TrackingCode) .Where(x => x.TrackingCode == input.TrackingCode)
.ToList(); .ToList();
var groupOrderUsedSaleEntry = orderUsedSaleEntryList.GroupBy(x => x.GoodsId) if (!orderUsedSaleEntryList.Any())
{
throw new Exception($"Tracking number {input.TrackingCode} has no data");
}
var groupOrderUsedSaleEntry = orderUsedSaleEntryList.GroupBy(x => x.GoodsDetailId)
.Select(o => new .Select(o => new
{ {
o.Key, o.Key,
Quantity = o.Sum(x => x.Quantity) Quantity = o.Sum(x => x.Quantity)
}).ToList(); }).ToList();
var goodsDetailIds = groupOrderUsedSaleEntry.Select(x => x.Key).ToList();
var skus = db.HW_GoodsDetail.Where(x => goodsDetailIds.Contains(x.DetailId)).ToList();
var spuIds = skus.Select(x => x.GoodsId).Distinct().ToList();
var spus = db.HW_GoodsInfo.Where(x => spuIds.Contains(x.GoodsId));
var order = db.DT_OrderInfo.FirstOrDefault(x =>
x.OrderId == orderUsedSaleEntryList.First().OrderId);
var result = new GetOrderUsedSaleDto
{
OrderId = order.OrderId,
OrderCode = order.OrderCode,
Items = skus.Select(o =>
{
var spu = spus.FirstOrDefault(x => x.GoodsId == o.GoodsId);
return new GetOrderUsedSaleItemDto
{
ProductCode = spu?.GoodsCode,
ProductDescription = spu?.GoodsEnglisgName,
GoodsDetailId = o.DetailId,
SkuCode = o.SKU1
};
}).ToList()
};
md.Code = "100";
md.Result = "Success";
md.Data = JsonConvert.SerializeObject(result);
} }
} }
} }
// if (Method == "ReturnUsedSale")
// {
// var input = JsonConvert.DeserializeObject<Sync_ReturnGoodsSave>(ResponseContent);
// var validatedSuccess = true;
// if (string.IsNullOrEmpty(input.StoreCode))
// {
// md.Code = "400";
// md.Result = "Please enter storage Location";
// md.Data = null;
// validatedSuccess = false;
// }
// if (string.IsNullOrEmpty(input.TrackCode))
// {
// md.Code = "400";
// md.Result = "Please enter tracking code";
// md.Data = null;
// validatedSuccess = false;
// }
// if (string.IsNullOrEmpty(input.OrderCode))
// {
// md.Code = "400";
// md.Result = "Please enter order no";
// md.Data = null;
// validatedSuccess = false;
// }
// if (input.GoodsList==null || !input.GoodsList.Any())
// {
// md.Code = "400";
// md.Result = "Please enter goods information";
// md.Data = null;
// validatedSuccess = false;
// }
//
// if (validatedSuccess)
// {
// var detailIds = input.GoodsList.Select(x => x.GoodsId).ToList();
// using (var db = new ErpDbContext())
// {
// var orderReturns = db.DT_OrderReturn.Where(x =>
// x.tracking_id == input.TrackCode &&
// x.ordercode==input.OrderCode &&
// (string.IsNullOrEmpty(x.InType) || x.InType == "6") &&
// (string.IsNullOrEmpty(x.ScanState) || x.ScanState == "1") &&
// x.detailid != null && detailIds.Contains(x.detailid.Value))
// .ToList();
//
// var orderReturnIds = orderReturns.Select(x => x.id).ToList();
//
// if (!orderReturnIds.Any())
// {
// throw new Exception("Return order information not obtained");
// }
//
// //二手平台上架信息
// var orderReturnUsedSales = db.DT_OrderReturnUsedSale
// .Where(x => orderReturnIds.Contains(x.OrderReturnId))
// .ToList();
//
// foreach (var inputItem in input.GoodsList)
// {
// var returnItem = orderReturns.FirstOrDefault(x => x.detailid == inputItem.GoodsId);
//
// if (returnItem is null)
// {
// throw new Exception(
// $"Return order information not obtained. tracking id {input.TrackCode},order no {input.OrderCode},sku {inputItem.GoodsId}");
// }
//
// //已上架二手平台的数量
// var usedSalesQuantity = orderReturnUsedSales
// .Where(x => x.OrderReturnId == returnItem.id)
// .Sum(x => x.Quantity);
//
// //剩余可以上架二手平台的数量
// var remainingQuantity = returnItem.return_quantity - usedSalesQuantity;
//
// if (inputItem.GoodsNum > remainingQuantity)
// {
// throw new Exception(
// $"sku {returnItem.merchant_sku} submitted quantity {inputItem.GoodsNum} exceeds the remaining submittable quantity {remainingQuantity}");
// }
// }
//
// db.BeginTransaction();
//
// try
// {
// #region 插入二手商品信息
//
// foreach (var inputItem in input.GoodsList)
// {
// var returnItem = orderReturns.First(x => x.detailid == inputItem.GoodsId);
//
// //更新退货订单表数据
// db.DT_OrderReturn.Where(x => x.id == returnItem.id)
// .Set(x => x.InType, "6")
// .Set(x => x.ScanState, "1")
// .Set(x => x.ScanDate, DateTime.Now)
// .Set(x => x.ScanUserId, input.UserId)
// .Set(x => x.PostionCode, input.StoreCode)
// .Set(x => x.ImgUrl, input.Photo1)
// .Set(x => x.ImgUrl2, input.Photo2)
// .Set(x => x.ImgUrl3, input.Photo3)
// .Set(x => x.ImgUrl4, input.Photo4)
// .Set(x => x.ImgUrl5, input.Photo5)
// .Update();
//
// var newOrderReturnUsedSale =
// new TradeUsedSale.Repositories.Models.DT_OrderReturnUsedSale
// {
// OrderReturnId = returnItem.id,
// OrderId = returnItem.orderid,
// OrderCode = returnItem.ordercode,
// GoodsId = returnItem.detailid.Value,
// MerchantSku = returnItem.merchant_sku,
// Quantity = inputItem.GoodsNum,
// CreationTime = DateTime.Now,
// CreatorId = input.UserId
// };
//
// var newOrderReturnUsedSaleId =
// db.InsertWithInt32Identity(newOrderReturnUsedSale);
//
// for (var i = 1; i <= inputItem.GoodsNum; i++)
// {
// var newOrderReturnUsedSaleItem =
// new TradeUsedSale.Repositories.Models.DT_OrderReturnUsedSaleItem
// {
// OrderReturnUsedSaleId = newOrderReturnUsedSaleId,
// IsPublished = false,
// CreationTime = DateTime.Now,
// CreatorId = input.UserId,
// };
//
// db.InsertWithInt32Identity(newOrderReturnUsedSaleItem);
// }
// }
//
// #endregion
//
// db.CommitTransaction();
// }
// catch (Exception ex)
// {
// db.RollbackTransaction();
// throw;
// }
// }
// }
//
// }
} }
} }
catch (Exception ex) catch (Exception ex)

@ -2915,8 +2915,9 @@
<Compile Include="LXOpenApi.cs" /> <Compile Include="LXOpenApi.cs" />
<Compile Include="MicrosoftExcelNew.cs" /> <Compile Include="MicrosoftExcelNew.cs" />
<Compile Include="ModelNew.cs" /> <Compile Include="ModelNew.cs" />
<Compile Include="Models\Shage\GetOrderUsedSaleDto.cs" />
<Compile Include="Models\Shage\OrderUsedSaleEntryInput.cs" /> <Compile Include="Models\Shage\OrderUsedSaleEntryInput.cs" />
<Compile Include="Models\Shage\GetOrderUsedSale.cs" /> <Compile Include="Models\Shage\GetOrderUsedSaleInput.cs" />
<Compile Include="OrderAPI.ashx.cs"> <Compile Include="OrderAPI.ashx.cs">
<DependentUpon>OrderAPI.ashx</DependentUpon> <DependentUpon>OrderAPI.ashx</DependentUpon>
</Compile> </Compile>

@ -19,6 +19,7 @@ namespace TradeUsedSale.Repositories
} }
public ITable<DT_OrderInfo> DT_OrderInfo => this.GetTable<DT_OrderInfo>(); public ITable<DT_OrderInfo> DT_OrderInfo => this.GetTable<DT_OrderInfo>();
public ITable<DT_OrderGoods> DT_OrderGoods => this.GetTable<DT_OrderGoods>(); public ITable<DT_OrderGoods> DT_OrderGoods => this.GetTable<DT_OrderGoods>();
public ITable<HW_GoodsInfo> HW_GoodsInfo => this.GetTable<HW_GoodsInfo>();
public ITable<HW_GoodsDetail> HW_GoodsDetail => this.GetTable<HW_GoodsDetail>(); public ITable<HW_GoodsDetail> HW_GoodsDetail => this.GetTable<HW_GoodsDetail>();
public ITable<DT_OrderReturn> DT_OrderReturn => this.GetTable<DT_OrderReturn>(); public ITable<DT_OrderReturn> DT_OrderReturn => this.GetTable<DT_OrderReturn>();
public ITable<DT_OrderUsedSale> DT_OrderUsedSale => this.GetTable<DT_OrderUsedSale>(); public ITable<DT_OrderUsedSale> DT_OrderUsedSale => this.GetTable<DT_OrderUsedSale>();

@ -24,7 +24,7 @@ namespace TradeUsedSale.Repositories.Models
/// <summary> /// <summary>
/// SKU ID /// SKU ID
/// </summary> /// </summary>
public int GoodsId { get; set; } public int GoodsDetailId { get; set; }
/// <summary> /// <summary>
/// SKU Code /// SKU Code

@ -0,0 +1,247 @@
using System;
namespace TradeUsedSale.Repositories.Models
{
public class HW_GoodsInfo
{
public int GoodsId { get; set; }
/// <summary>
/// 货物编码
/// </summary>
public string GoodsCode { get; set; }
/// <summary>
/// 货物编码字母
/// </summary>
public string GoodsEg { get; set; }
/// <summary>
/// 货物编号序号
/// </summary>
public int? GoodsNo { get; set; }
/// <summary>
/// 货物原编码(在供应商那边的编码)
/// </summary>
public string GoodsOldCode { get; set; }
/// <summary>
/// 类别id
/// </summary>
public int? SortId { get; set; }
/// <summary>
/// 分类名称
/// </summary>
public string SortName { get; set; }
/// <summary>
/// 供应商id
/// </summary>
public string SupplierId { get; set; }
/// <summary>
/// 货物名称
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 货物英文名称
/// </summary>
public string GoodsEnglisgName { get; set; }
public int? GoodsNum { get; set; }
public int? GoodsLockNum { get; set; }
/// <summary>
/// 商品价格(第一批价格)
/// </summary>
public decimal? InPrice { get; set; }
/// <summary>
/// 商品价格(最近批次价格)
/// </summary>
public decimal? NowPrice { get; set; }
/// <summary>
/// 货物重量
/// </summary>
public decimal? Weight { get; set; }
/// <summary>
/// 重量单位
/// </summary>
public string WeightUnit { get; set; }
/// <summary>
/// 货物体积
/// </summary>
public decimal? Solid { get; set; }
/// <summary>
/// 体积单位
/// </summary>
public string SolidUnit { get; set; }
/// <summary>
/// 库位id
/// </summary>
public int? Position { get; set; }
public DateTime? InDate { get; set; }
public DateTime? UpdateDate { get; set; }
public string FirstImgUrl { get; set; }
public string GoodsImageIds { get; set; }
public int? CompanyId { get; set; }
/// <summary>
/// 货物计划购买数量
/// </summary>
public int? GoodsPlanNum { get; set; }
/// <summary>
/// 海外仓数量
/// </summary>
public int? GoodsOutNum { get; set; }
/// <summary>
/// 购买途中数量
/// </summary>
public int? GoodsInNum { get; set; }
/// <summary>
/// 安全库存
/// </summary>
public int? SafeNum { get; set; }
/// <summary>
/// 海关编码
/// </summary>
public string HGCode { get; set; }
/// <summary>
/// 海关单位编码
/// </summary>
public string HGCompanyCode { get; set; }
/// <summary>
/// 海关单位编码
/// </summary>
public string UpdateName { get; set; }
public string GoodsRemark { get; set; }
public int? AutoPlan { get; set; }
/// <summary>
/// 无货
/// </summary>
public int? NoGoods { get; set; }
/// <summary>
/// 平均到货天数
/// </summary>
public decimal? AvgTime { get; set; }
/// <summary>
/// 1正常0删除
/// </summary>
public int? State { get; set; }
public int? Supplier { get; set; }
/// <summary>
/// 事业部提醒备注
/// </summary>
public string DeptRemark { get; set; }
/// <summary>
/// 异常定期提醒0表示不提醒其它表示几天后提醒
/// </summary>
public int? NoticeDays { get; set; }
public string GoodsInfo { get; set; }
public string DefaultCity { get; set; }
public decimal? PageFee { get; set; }
public decimal? PostPrice { get; set; }
public string GoodsSupplyCode { get; set; }
public decimal? BGPrice { get; set; }
public string GoodNote { get; set; }
public string NoticeShop { get; set; }
public int? GoodsHJNum { get; set; }
public int? GoodsHJNum2 { get; set; }
public decimal? NetWeight { get; set; }
public decimal? Long { get; set; }
public decimal? Width { get; set; }
public decimal? Height { get; set; }
public int? BoxRate { get; set; }
public string Cert { get; set; }
public int? UpOff { get; set; }
public decimal? FeeRate { get; set; }
public decimal? JYPrice { get; set; }
public decimal? Long2 { get; set; }
public decimal? Width2 { get; set; }
public decimal? Height2 { get; set; }
public decimal? Weight2 { get; set; }
public int? GoodsInNum2 { get; set; }
public DateTime? LastOrderDate { get; set; }
public int? IsSure { get; set; }
public string IsBox { get; set; }
public int? BoxNum { get; set; }
public string BoxStoreCode { get; set; }
public int? IsEnd { get; set; }
public int? JHDays { get; set; }
public string KFName { get; set; }
public decimal? tcrate { get; set; }
public string KFName2 { get; set; }
public int? DonePlanNum { get; set; }
public decimal? SalePrice { get; set; }
public int? SortId1 { get; set; }
public string SortId2 { get; set; }
public string JYSales { get; set; }
public decimal? CKG { get; set; }
public string mname { get; set; }
public int? muserid { get; set; }
public DateTime? DHDate { get; set; }
public string groupname { get; set; }
public int? guserid { get; set; }
public string groupname_ebay { get; set; }
public string groupname_wlmart { get; set; }
public int? guserid_ebay { get; set; }
public int? guserid_wlmart { get; set; }
public string LeaveWord { get; set; }
public decimal? GoodsMonthHJPrice { get; set; }
public int? GoodsWeekHJNum { get; set; }
public decimal? GoodsWeekHJPrice { get; set; }
public int? GoodsHJNum3 { get; set; }
public int? GoodsHJNum4 { get; set; }
public int? guserid_shopify { get; set; }
public int? guserid_wayfair { get; set; }
public int? guserid_sheIn { get; set; }
public string groupname_shopify { get; set; }
public string groupname_wayfair { get; set; }
public string groupname_sheIn { get; set; }
public string LeaveWord_cg { get; set; }
public int? IsExamine { get; set; }
public string LeaveWord_ebay { get; set; }
public string LeaveWord_walmart { get; set; }
public string LeaveWord_shopify { get; set; }
public string LeaveWord_shein { get; set; }
public string LeaveWord_wayfair { get; set; }
public int? PlanCount { get; set; }
public int? IsYC { get; set; }
public int? EditPlanCount { get; set; }
/// <summary>
/// 公司为该产品卖出每个的补贴费用
/// </summary>
public decimal? SubsidyFee { get; set; }
public int? guserid_tiktok { get; set; }
public string groupname_tiktok { get; set; }
public int? guserid_temu { get; set; }
public string groupname_temu { get; set; }
public string LeaveWord_tiktok { get; set; }
public string LeaveWord_temu { get; set; }
}
}

@ -56,6 +56,7 @@
<Compile Include="Repositories\Models\DT_OrderUsedSaleEntry.cs" /> <Compile Include="Repositories\Models\DT_OrderUsedSaleEntry.cs" />
<Compile Include="Repositories\Models\DT_OrderUsedSalePlatform.cs" /> <Compile Include="Repositories\Models\DT_OrderUsedSalePlatform.cs" />
<Compile Include="Repositories\Models\HW_GoodsDetail.cs" /> <Compile Include="Repositories\Models\HW_GoodsDetail.cs" />
<Compile Include="Repositories\Models\HW_GoodsInfo.cs" />
<Compile Include="Repositories\Utils\ExpressionExtensions.cs" /> <Compile Include="Repositories\Utils\ExpressionExtensions.cs" />
<Compile Include="Repositories\Utils\LinqToDbExtensions.cs" /> <Compile Include="Repositories\Utils\LinqToDbExtensions.cs" />
<Compile Include="Repositories\Utils\ParameterRebinder.cs" /> <Compile Include="Repositories\Utils\ParameterRebinder.cs" />

Loading…
Cancel
Save