erp接口

This commit is contained in:
qianjiawei
2023-12-11 17:30:42 +08:00
parent 3a7a0dd572
commit d4d62c3e09
2 changed files with 200 additions and 0 deletions

View File

@@ -208,5 +208,75 @@ namespace Tnb.WarehouseMgr
await db.Insertable(WmsSaleH).ExecuteCommandAsync();
await db.Insertable(WmsSaleDs).ExecuteCommandAsync();
}
/// <summary>
/// 销售退货单
/// </summary>
public async Task SaleReturn(SaleReturnInput input)
{
var db = _repository.AsSugarClient();
WmsInstockH WmsInstockH = new WmsInstockH();
string Code = await _billRuleService.GetBillNumber("WmsInStock");
WmsInstockH.bill_code = Code;
WmsInstockH.bill_date = DateTime.Now;
WmsInstockH.bill_type = "25103434001429";//销售退货单
WmsInstockH.biz_type = "26191496816421";//一般入库
WmsInstockH.status = "25065138925589";//新增
WmsInstockH.generate_type = "1";//0人工 1自动
WmsInstockH.create_time = DateTime.Now;
WmsInstockH.source_id = input.source_id;
WmsInstockH.source_code = input.source_code;
WmsInstockH.source_line = input.source_line;
WmsInstockH.source_detail_id = input.source_detail_id;
WmsInstockH.is_check = 1;
WmsInstockH.purchase_code = input.purchase_code;
WmsInstockH.sync_status = "26191359047461";//无需同步
WmsInstockH.print_status = "26191366982437";//未打印
WmsInstockH.create_id = "";
WmsInstockH.create_time = DateTime.Now;
var location = await db.Queryable<BasLocation>().Where(p => p.location_code == input.location).FirstAsync();
if (location != null)
WmsInstockH.location_id = location.id;
var warehouse = await db.Queryable<BasWarehouse>().Where(p => p.whcode == input.warehouse).FirstAsync();
if (warehouse != null)
WmsInstockH.warehouse_id = warehouse.id;
WmsInstockH.supplier_code = input.supplier_code;
var supplier = await db.Queryable<BasSupplier>().Where(p => p.supplier_code == input.supplier_code).FirstAsync();
if (supplier != null)
{
WmsInstockH.supplier_id = supplier.id;
WmsInstockH.supplier_name = supplier.supplier_name;
}
List<WmsInstockD> WmsInstockDs = new List<WmsInstockD>();
foreach (var detail in input.details)
{
WmsInstockD WmsInstockD = new WmsInstockD();
WmsInstockD.bill_id = WmsInstockH.id;
WmsInstockD.line_status = "25065138925589";//新增
WmsInstockD.pr_qty = detail.pr_qty;
WmsInstockD.qty = detail.qty;
WmsInstockD.reason = detail.reason;
WmsInstockD.price = detail.price;
WmsInstockD.tax_price = detail.tax_price;
WmsInstockD.amount = detail.amount;
WmsInstockD.all_amount = detail.all_amount;
WmsInstockD.print_qty = 0;
WmsInstockD.scan_qty = 0;
WmsInstockD.code_batch = detail.code_batch;
WmsInstockD.container_no = detail.container_no;
var detailwarehouse = await db.Queryable<BasWarehouse>().Where(p => p.whcode == input.warehouse).FirstAsync();
if (detailwarehouse != null)
WmsInstockD.warehouse_id = detailwarehouse.id;
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
if (material != null)
{
WmsInstockD.material_id = material.id;
WmsInstockD.unit_id = material.unit_id;
}
WmsInstockDs.Add(WmsInstockD);
}
await db.Insertable(WmsInstockH).ExecuteCommandAsync();
await db.Insertable(WmsInstockDs).ExecuteCommandAsync();
}
}
}