From 94d802d5dafde0fc44e082865c3a4267f6a20dd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9C=B1=E6=96=8C?= <1324361213@qq.com>
Date: Mon, 21 Jul 2025 16:52:17 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8E=A8=E9=80=81=E4=BA=91?=
=?UTF-8?q?=E6=98=9F=E7=A9=BA=E9=83=A8=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../KingDee/SaveModel/SaleOrderModel.cs | 17 +-
.../Response/KingDee/K3Result/K3ApiResult.cs | 17 +
.../KingDee/K3Result/Model/KingdeeResult.cs | 44 +++
.../KingDee/K3Result/Model/ResponseStatus.cs | 35 ++
.../KingDee/K3Result/Model/ResultInfo.cs | 21 ++
.../KingDee/K3Result/Model/SuccessEntity.cs | 25 ++
.../KingDee/K3Result/Model/SuccessMessage.cs | 10 +
.../Model/YTKJTShopParameter.cs | 331 +++++++++---------
.../MyCode.Project.Domain.csproj | 6 +
.../IKingDeeService.cs | 3 +-
.../Implementation/KingDeeService.cs | 99 +++---
.../Implementation/OrderPushService.cs | 79 +++--
12 files changed, 438 insertions(+), 249 deletions(-)
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/K3ApiResult.cs
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/KingdeeResult.cs
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResponseStatus.cs
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResultInfo.cs
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessEntity.cs
create mode 100644 Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessMessage.cs
diff --git a/Reportapi/MyCode.Project.Domain/Message/Request/KingDee/SaveModel/SaleOrderModel.cs b/Reportapi/MyCode.Project.Domain/Message/Request/KingDee/SaveModel/SaleOrderModel.cs
index 48af829..7386407 100644
--- a/Reportapi/MyCode.Project.Domain/Message/Request/KingDee/SaveModel/SaleOrderModel.cs
+++ b/Reportapi/MyCode.Project.Domain/Message/Request/KingDee/SaveModel/SaleOrderModel.cs
@@ -31,7 +31,7 @@ namespace MyCode.Project.Domain.Message.Request.KingDee.SaveModel
///
/// 客户
///
- public FCustId FCustId { get; set; }
+ public FCustomerId FCustId { get; set; }
///
/// 交货方式
///
@@ -190,13 +190,21 @@ namespace MyCode.Project.Domain.Message.Request.KingDee.SaveModel
public class FSaleOrgId
{
///
- ///
+ /// 编码
///
public string FNumber { get; set; }
+ ///
+ /// Id
+ ///
+ public string FOrgId { get; set; }
}
- public class FCustId
+ public class FCustomerId
{
+ ///
+ /// 客户ID
+ ///
+ public string FCustId { get; set; }
///
///
///
@@ -253,6 +261,7 @@ namespace MyCode.Project.Domain.Message.Request.KingDee.SaveModel
public class FSalerId
{
+ public long? FId { get; set; }
///
///
///
@@ -773,7 +782,7 @@ namespace MyCode.Project.Domain.Message.Request.KingDee.SaveModel
///
/// 税率%
///
- public int? FEntryTaxRate { get; set; }
+ public decimal? FEntryTaxRate { get; set; }
///
/// 批号
///
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/K3ApiResult.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/K3ApiResult.cs
new file mode 100644
index 0000000..2463dd4
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/K3ApiResult.cs
@@ -0,0 +1,17 @@
+
+
+using MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model;
+
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result
+{
+ ///
+ /// 金蝶云星空返回类
+ ///
+ public class K3ApiResult
+ {
+ ///
+ /// 返回对象
+ ///
+ public KingdeeResult Result { get; set; }
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/KingdeeResult.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/KingdeeResult.cs
new file mode 100644
index 0000000..d329956
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/KingdeeResult.cs
@@ -0,0 +1,44 @@
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model
+{
+ ///
+ /// 返回类
+ ///
+ public class KingdeeResult
+ {
+ ///
+ /// 响应对象
+ ///
+ public ResponseStatus ResponseStatus { get; set; }
+
+ ///
+ /// 转换响应对象
+ ///
+ public ResponseStatus ConvertResponseStatus { get; set; }
+
+ ///
+ /// 返回结果,用于查看单据
+ ///
+ public object Result { get; set; }
+
+ ///
+ /// 开始索引
+ ///
+ public long StartIndex { get; set; }
+ ///
+ /// 是否最后
+ ///
+ public bool IsLast { get; set; }
+ ///
+ /// 文件大小
+ ///
+ public long FileSize { get; set; }
+ ///
+ /// 文件名称
+ ///
+ public string FileName { get; set; }
+ ///
+ /// 文件内容(Base64)
+ ///
+ public string FilePart { get; set; }
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResponseStatus.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResponseStatus.cs
new file mode 100644
index 0000000..b54361b
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResponseStatus.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model
+{
+ ///
+ /// 响应对象
+ ///
+ public class ResponseStatus
+ {
+ ///
+ /// 错误代码
+ ///
+ public int ErrorCode { get; set; }
+ ///
+ /// 是否成功
+ ///
+ public bool IsSuccess { get; set; }
+ ///
+ /// 错误信息列表
+ ///
+ public List Errors { get; set; }
+ ///
+ /// 成功实体
+ ///
+ public List SuccessEntitys { get; set; }
+ ///
+ /// 成功消息
+ ///
+ public List SuccessMessages { get; set; }
+ ///
+ /// 消息代码
+ ///
+ public int MsgCode { get; set; }
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResultInfo.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResultInfo.cs
new file mode 100644
index 0000000..c4a22e5
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/ResultInfo.cs
@@ -0,0 +1,21 @@
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model
+{
+ ///
+ /// 金蝶云星空查看错误信息类
+ ///
+ public class ResultInfo
+ {
+ ///
+ /// 字段名称
+ ///
+ public string FieldName { get; set; }
+ ///
+ /// 错误信息
+ ///
+ public string Message { get; set; }
+ ///
+ /// 序号
+ ///
+ public int DIndex { get; set; }
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessEntity.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessEntity.cs
new file mode 100644
index 0000000..10c324d
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessEntity.cs
@@ -0,0 +1,25 @@
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model
+{
+ ///
+ /// 成功实体
+ ///
+ public class SuccessEntity
+ {
+ ///
+ /// 单据Id
+ ///
+ public int Id { get; set; }
+ ///
+ /// 单据编号
+ ///
+ public string Number { get; set; }
+ ///
+ /// 实体索引
+ ///
+ public int DIndex { get; set; }
+ ///
+ /// 分录Id
+ ///
+ public object EntryIds { get; set; }
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessMessage.cs b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessMessage.cs
new file mode 100644
index 0000000..64de959
--- /dev/null
+++ b/Reportapi/MyCode.Project.Domain/Message/Response/KingDee/K3Result/Model/SuccessMessage.cs
@@ -0,0 +1,10 @@
+namespace MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model
+{
+ ///
+ /// 成功信息
+ ///
+ public class SuccessMessage
+ {
+
+ }
+}
diff --git a/Reportapi/MyCode.Project.Domain/Model/YTKJTShopParameter.cs b/Reportapi/MyCode.Project.Domain/Model/YTKJTShopParameter.cs
index 7f9dfa9..a05008e 100644
--- a/Reportapi/MyCode.Project.Domain/Model/YTKJTShopParameter.cs
+++ b/Reportapi/MyCode.Project.Domain/Model/YTKJTShopParameter.cs
@@ -11,191 +11,200 @@ namespace MyCode.Project.Domain.Model
[SugarTable("YTKJ_t_ShopParameter")]
public partial class YTKJTShopParameter
{
- public YTKJTShopParameter(){
+ public YTKJTShopParameter()
+ {
- }
- ///
- /// Desc:
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(IsPrimaryKey=true)]
- public long FID {get;set;}
+ }
+ ///
+ /// Desc:
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public long FID { get; set; }
- ///
- /// Desc:
- /// Default:
- /// Nullable:False
- ///
- public string FBILLNO {get;set;}
+ ///
+ /// Desc:
+ /// Default:
+ /// Nullable:False
+ ///
+ public string FBILLNO { get; set; }
- ///
- /// Desc:审核状态 C=已审核
- /// Default:
- /// Nullable:False
- ///
- public string FDOCUMENTSTATUS {get;set;}
+ ///
+ /// Desc:审核状态 C=已审核
+ /// Default:
+ /// Nullable:False
+ ///
+ public string FDOCUMENTSTATUS { get; set; }
- ///
- /// Desc:门店编码
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_SHOPCODE")]
- public string FSHOPCODE {get;set;}
+ ///
+ /// Desc:门店编码
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_SHOPCODE")]
+ public string FSHOPCODE { get; set; }
- ///
- /// Desc:门店名称
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_SHOPNAME")]
- public string FSHOPNAME {get;set;}
+ ///
+ /// Desc:门店名称
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_SHOPNAME")]
+ public string FSHOPNAME { get; set; }
- ///
- /// Desc:
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_YTKJ_TEXT2")]
- public string FYTKJTEXT2 {get;set;}
+ ///
+ /// Desc:
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_YTKJ_TEXT2")]
+ public string FYTKJTEXT2 { get; set; }
- ///
- /// Desc:是否同步金蝶
- /// Default:1
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_SYNCHRONIZEKINGDEE")]
- public string FSYNCHRONIZEKINGDEE {get;set;}
+ ///
+ /// Desc:是否同步金蝶
+ /// Default:1
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_SYNCHRONIZEKINGDEE")]
+ public string FSYNCHRONIZEKINGDEE { get; set; }
- ///
- /// Desc:是否同步WMS
- /// Default:1
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_SYNCHRONIZEWMS")]
- public string FSYNCHRONIZEWMS {get;set;}
+ ///
+ /// Desc:是否同步WMS
+ /// Default:1
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_SYNCHRONIZEWMS")]
+ public string FSYNCHRONIZEWMS { get; set; }
- ///
- /// Desc:销售客户
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_SALESCUSTOMERS")]
- public int FSALESCUSTOMERS {get;set;}
+ ///
+ /// Desc:销售客户
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_SALESCUSTOMERS")]
+ public int FSALESCUSTOMERS { get; set; }
- ///
- /// Desc:发货仓库ID
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_WAREHOUSE")]
- public int FWAREHOUSE {get;set;}
+ ///
+ /// Desc:发货仓库ID
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_WAREHOUSE")]
+ public int FWAREHOUSE { get; set; }
- ///
- /// Desc:仓库货主
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_CANGKUHUOZHU")]
- public string FCANGKUHUOZHU {get;set;}
+ ///
+ /// Desc:仓库货主
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_CANGKUHUOZHU")]
+ public string FCANGKUHUOZHU { get; set; }
- ///
- /// Desc:公司ID
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_COMPANYID")]
- public string FCOMPANYID {get;set;}
+ ///
+ /// Desc:公司ID
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_COMPANYID")]
+ public string FCOMPANYID { get; set; }
- ///
- /// Desc:发货大仓
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_DACANG")]
- public string FDACANG {get;set;}
+ ///
+ /// Desc:发货大仓
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_DACANG")]
+ public string FDACANG { get; set; }
- ///
- /// Desc:税率
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_TAXRATE")]
- public decimal FTAXRATE {get;set;}
+ ///
+ /// Desc:税率
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_TAXRATE")]
+ public decimal FTAXRATE { get; set; }
- ///
- /// Desc:创建日期
- /// Default:
- /// Nullable:True
- ///
- [SugarColumn(ColumnName="F_YTKJ_CREATEDATE")]
- public DateTime? FYTKJCREATEDATE {get;set;}
+ ///
+ /// Desc:创建日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "F_YTKJ_CREATEDATE")]
+ public DateTime? FYTKJCREATEDATE { get; set; }
- ///
- /// Desc:修改日期
- /// Default:
- /// Nullable:True
- ///
- [SugarColumn(ColumnName="F_YTKJ_MODIFYDATE")]
- public DateTime? FYTKJMODIFYDATE {get;set;}
+ ///
+ /// Desc:修改日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "F_YTKJ_MODIFYDATE")]
+ public DateTime? FYTKJMODIFYDATE { get; set; }
- ///
- /// Desc:审核日期
- /// Default:
- /// Nullable:True
- ///
- [SugarColumn(ColumnName="F_AUDITDATE")]
- public DateTime? FAUDITDATE {get;set;}
+ ///
+ /// Desc:审核日期
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "F_AUDITDATE")]
+ public DateTime? FAUDITDATE { get; set; }
- ///
- /// Desc:创建人
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_YTKJ_CREATORID")]
- public int FYTKJCREATORID {get;set;}
+ ///
+ /// Desc:创建人
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_YTKJ_CREATORID")]
+ public int FYTKJCREATORID { get; set; }
- ///
- /// Desc:修改人
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_YTKJ_MODIFIERID")]
- public int FYTKJMODIFIERID {get;set;}
+ ///
+ /// Desc:修改人
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_YTKJ_MODIFIERID")]
+ public int FYTKJMODIFIERID { get; set; }
- ///
- /// Desc:审核人
- /// Default:0
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_AUDITOR")]
- public int FAUDITOR {get;set;}
+ ///
+ /// Desc:审核人
+ /// Default:0
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_AUDITOR")]
+ public int FAUDITOR { get; set; }
- ///
- /// Desc:仓库编码
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_WAREHOUSE_CODE")]
- public string FWAREHOUSECODE {get;set;}
+ ///
+ /// Desc:仓库编码
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_WAREHOUSE_CODE")]
+ public string FWAREHOUSECODE { get; set; }
- ///
- /// Desc:仓库名称
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(ColumnName="F_WAREHOUSE_NAME")]
- public string FWAREHOUSENAME {get;set;}
+ ///
+ /// Desc:仓库名称
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(ColumnName = "F_WAREHOUSE_NAME")]
+ public string FWAREHOUSENAME { get; set; }
- ///
- /// Desc:销售员ID
- /// Default:
- /// Nullable:True
- ///
- [SugarColumn(ColumnName="F_SALER")]
- public long? FSALER {get;set;}
+ ///
+ /// Desc:销售员ID
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "F_SALER")]
+ public long? FSALER { get; set; }
+
+ ///
+ /// Desc:销售员ID
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "F_SALE_ORGID")]
+ public long? FSaleOrgId { get; set; }
}
}
diff --git a/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj b/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj
index f7b103b..a6e50c6 100644
--- a/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj
+++ b/Reportapi/MyCode.Project.Domain/MyCode.Project.Domain.csproj
@@ -80,6 +80,12 @@
+
+
+
+
+
+
diff --git a/Reportapi/MyCode.Project.OutSideService/IKingDeeService.cs b/Reportapi/MyCode.Project.OutSideService/IKingDeeService.cs
index 228e03f..449ae8b 100644
--- a/Reportapi/MyCode.Project.OutSideService/IKingDeeService.cs
+++ b/Reportapi/MyCode.Project.OutSideService/IKingDeeService.cs
@@ -1,4 +1,5 @@
using MyCode.Project.Domain.Message.Request.KingDee;
+using MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model;
namespace MyCode.Project.OutSideService
{
@@ -10,7 +11,7 @@ namespace MyCode.Project.OutSideService
///
///
///
- string Save(string formId, BillSave billSave);
+ ResponseStatus Save(string formId, BillSave billSave);
}
diff --git a/Reportapi/MyCode.Project.OutSideService/Implementation/KingDeeService.cs b/Reportapi/MyCode.Project.OutSideService/Implementation/KingDeeService.cs
index d556f46..570c343 100644
--- a/Reportapi/MyCode.Project.OutSideService/Implementation/KingDeeService.cs
+++ b/Reportapi/MyCode.Project.OutSideService/Implementation/KingDeeService.cs
@@ -1,6 +1,7 @@
using Kingdee.CDP.WebApi.SDK;
using MyCode.Project.Domain.Message.Request.KingDee;
-using MyCode.Project.Domain.Message.Response.KingDee;
+using MyCode.Project.Domain.Message.Response.KingDee.K3Result;
+using MyCode.Project.Domain.Message.Response.KingDee.K3Result.Model;
using MyCode.Project.Infrastructure.Common;
using Newtonsoft.Json;
using System;
@@ -17,7 +18,7 @@ namespace MyCode.Project.OutSideService.Implementation
}
public static K3CloudApi staClient = null;
public static DateTime timeOut = DateTime.Now;
-
+
#region
///
@@ -77,12 +78,12 @@ namespace MyCode.Project.OutSideService.Implementation
-
-
-
-
+
+
+
+
#region 保存一个订单对象
///
/// 保存一个订单对象
@@ -90,40 +91,28 @@ namespace MyCode.Project.OutSideService.Implementation
///
///
///
- public string Save(string formId, BillSave billSave)
+ public ResponseStatus Save(string formId, BillSave billSave)
{
staClient = GetK3CloudClient();
- var datastr = JsonHelper.ToJson(billSave,false, false, true);
+ var datastr = JsonHelper.ToJson(billSave, false, false, true);
LogHelper.Info(datastr);
var resultString = staClient.Save(formId, datastr);
- if (resultString.Contains("ErrorCode"))
+ var result = JsonHelper.ToObject(resultString);
+ if (!result.Result.ResponseStatus.IsSuccess)
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
- //throw new Exception("单据在云星空已锁定,请联系采购员");
- string Message = "";
- try
- {
- ErrorResponse errorResponse = JsonHelper.ToObject(resultString);
- Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
- }
- catch (Exception ex)
- {
- string ds = ex.Message;
- throw new Exception("2云星空接口调用失败,请联系管理员,错误信息:" + resultString);
-
- }
- throw new Exception("1云星空接口调用失败,请联系管理员,错误信息:" + Message);
+ string Message = string.Join(",", result.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
+ throw new Exception("云星空接口调用失败,请联系管理员,错误信息:" + Message);
}
- var result = JsonHelper.ToObject>>(resultString);
- var data = result["Result"]["ResponseStatus"];
- return resultString;
+ var data = result.Result.ResponseStatus;
+ return data;
}
#endregion
-
-
+
+
#region Delete(删除某个订单)
///
/// 删除某个订单
@@ -133,34 +122,34 @@ namespace MyCode.Project.OutSideService.Implementation
///
///
- public dynamic Delete(string formId, BillDelete billdelete)
- {
- staClient = GetK3CloudClient();
- var datastr = JsonHelper.ToJson(billdelete);
- LogHelper.Info(datastr);
- var resultString = staClient.Delete(formId, datastr);
- if (resultString.Contains("ErrorCode"))
- {
- LogHelper.Error("金蝶云接口调用失败,请检查");
- LogHelper.Error(resultString);
- string Message = "";
- try
- {
- ErrorResponse errorResponse = JsonHelper.ToObject(resultString);
- Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
- }
- catch (Exception ex)
- {
- string ds = ex.Message;
- throw new Exception("2云星空接口调用失败,请联系管理员,错误信息:" + resultString);
+ //public dynamic Delete(string formId, BillDelete billdelete)
+ //{
+ // staClient = GetK3CloudClient();
+ // var datastr = JsonHelper.ToJson(billdelete);
+ // LogHelper.Info(datastr);
+ // var resultString = staClient.Delete(formId, datastr);
+ // if (resultString.Contains("ErrorCode"))
+ // {
+ // LogHelper.Error("金蝶云接口调用失败,请检查");
+ // LogHelper.Error(resultString);
+ // string Message = "";
+ // try
+ // {
+ // ErrorResponse errorResponse = JsonHelper.ToObject(resultString);
+ // Message = string.Join(",", errorResponse.Result.ResponseStatus.Errors.Select(t => t.Message).ToList());
+ // }
+ // catch (Exception ex)
+ // {
+ // string ds = ex.Message;
+ // throw new Exception("2云星空接口调用失败,请联系管理员,错误信息:" + resultString);
- }
- throw new Exception("1云星空接口调用失败,请联系管理员,错误信息:" + Message);
- }
- var result = JsonHelper.ToObject(resultString);
- var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
- return JsonHelper.ToJson(data);
- }
+ // }
+ // throw new Exception("1云星空接口调用失败,请联系管理员,错误信息:" + Message);
+ // }
+ // var result = JsonHelper.ToObject(resultString);
+ // var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
+ // return JsonHelper.ToJson(data);
+ //}
#endregion
}
diff --git a/Reportapi/MyCode.Project.Services/Implementation/OrderPushService.cs b/Reportapi/MyCode.Project.Services/Implementation/OrderPushService.cs
index c892ae1..cc1cc1e 100644
--- a/Reportapi/MyCode.Project.Services/Implementation/OrderPushService.cs
+++ b/Reportapi/MyCode.Project.Services/Implementation/OrderPushService.cs
@@ -157,34 +157,47 @@ namespace MyCode.Project.Services.Implementation
public void PushOrderToKingDee(string id)
{
- var orderSHeet = _pushKingDeeOrderRepository.Queryable().Where(t => id == t.Id.ToString()).First();
- if (orderSHeet.Status != 0)
+ var orderHead = _pushKingDeeOrderRepository.Queryable().Where(t => id == t.Id.ToString()).First();
+ if (orderHead.Status != 0)
{
throw new BaseException("单据已经下推.");
}
- var one = _yTKJTShopParameterRepository
+
+ var param = _yTKJTShopParameterRepository
.Queryable()
- //.Where(t => t.FSHOPCODE == orderSHeet.ShopCode)
- .Where(t => t.FSHOPCODE == "bybo")
+ .Where(t => t.FSHOPCODE == orderHead.ShopCode)
.First();
- if (one is null)
+ if (param is null)
{
- throw new BaseException($"门店编号:{orderSHeet.ShopCode},门店名称:{orderSHeet.ShopName},没有找到对应的门店参数 ");
+ throw new BaseException($"门店编号:{orderHead.ShopCode},门店名称:{orderHead.ShopName},没有找到对应的门店参数 ");
+ }
+ // 如果这个配置都没有勾选则直接报错
+ if (param.FSYNCHRONIZEKINGDEE == "0" && param.FSYNCHRONIZEWMS == "0")
+ {
+ throw new BaseException($"门店编号:{orderHead.ShopCode},门店名称:{orderHead.ShopName},参数配置错误,请联系管理员检查 ");
}
// TODO 如果是False则同步到云星空销售订单
- if (one.FSYNCHRONIZEWMS == "1")
+ //if (param.FSYNCHRONIZEWMS == "1")
+ if (param.FSYNCHRONIZEKINGDEE == "1")
{
- PushKingdeeSaleOrder(orderSHeet);
+ var response = PushKingdeeSaleOrder(orderHead, param);
+ // 如果保存成功,需要更新源单数据
+ if (response.IsSuccess)
+ {
+ orderHead.Status = 2;
+ _pushKingDeeOrderRepository.Update(orderHead);
+ }
}
// 如果为True则同步到WMS
- else
+ else if (param.FSYNCHRONIZEWMS == "1")
{
//wms
- PushWMSSaleOrder(orderSHeet);
+ PushWMSSaleOrder(orderHead, param);
}
}
- private string PushWMSSaleOrder(PushKingDeeOrder pushKingdeeOrder)
+
+ private string PushWMSSaleOrder(PushKingDeeOrder pushKingdeeOrder, YTKJTShopParameter param)
{
var itemList = _pushKingDeeOrderItemRepository
.Queryable()
@@ -195,13 +208,13 @@ namespace MyCode.Project.Services.Implementation
// 赋值
order.CreateTime = pushKingdeeOrder.CreateTime?.ToString("yyyy/MM/dd");
order.OrderNo = pushKingdeeOrder.Id.ToString();
- order.CompanyId = string.Empty; // 公司Id
- order.OrderType = pushKingdeeOrder.TradeType == 8 ? "8" : "4"; // 订单类型
- order.CustomerId = string.Empty; // 货主ID
+ order.CompanyId = param.FCOMPANYID; // 公司Id
+ order.OrderType = pushKingdeeOrder.TradeType == 8 ? "7" : "4"; // 订单类型
+ order.CustomerId = param.FCANGKUHUOZHU; // 货主ID
order.WarehouseId = pushKingdeeOrder?.WarehouseId;
order.OrderTime = pushKingdeeOrder.ConsignTime?.ToString("yyyy/MM/dd");
- order.Channel = string.Empty; // 下发系统
- order.ItemType = string.Empty; // 单据类型
+ order.Channel = "K3Cloud"; // 下发系统
+ order.ItemType = pushKingdeeOrder.TradeType == 8 ? "退货订单" : "标准销售订单"; // 单据类型
order.TotalQty = itemList.Sum(n => n.SellCount);
order.TotalMount = itemList.Sum(n => n.SellTotal);
order.CreateTime = pushKingdeeOrder.CreateTime?.ToString("yyyy/MM/dd");
@@ -220,7 +233,7 @@ namespace MyCode.Project.Services.Implementation
ItemId = n.GoodsId, // 商品
}).ToArray();
- var uri = "";
+ var uri = "http://172.16.42.45:9000";
var requestString = JsonHelper.ToJson(order, false, false, true);
var client = new RestClient($"{uri}/sale/order/return");
@@ -237,18 +250,27 @@ namespace MyCode.Project.Services.Implementation
return resultString;
}
- private string PushKingdeeSaleOrder(PushKingDeeOrder pushKingdeeOrder)
+ ///
+ /// 推送到金蝶云星空
+ ///
+ /// 源单信息
+ /// 门店配置
+ ///
+ private Domain.Message.Response.KingDee.K3Result.Model.ResponseStatus PushKingdeeSaleOrder(PushKingDeeOrder pushKingdeeOrder, YTKJTShopParameter param)
{
var itemList = _pushKingDeeOrderItemRepository.Queryable().Where(t => pushKingdeeOrder.Id == t.PushKingDeeOrderId).ToList();
// 遍历单体,构造单据体实体
var entryList = itemList.Select(n => new FSaleOrderEntryItem()
{
Fcode = n.Barcode, // 条码带出物料 、物料带出税额
+ //Fcode = "2120101128415", // 条码带出物料 、物料带出税额
+ FEntryTaxRate = param.FTAXRATE,
FQty = n.SellCount, // 销售数量
FTaxPrice = Math.Round(n.DivideSellTotal / n.SellCount, 10), // 含税单价等于 金额/总数
+
FSOStockId = new FSOStockId() // 仓库必填
{
- FNUMBER = pushKingdeeOrder.WarehouseCode
+ FNUMBER = param.FWAREHOUSECODE
},
}).ToList();
@@ -261,19 +283,20 @@ namespace MyCode.Project.Services.Implementation
// 1:零售业务7:售后发货;8:售后退货
FNUMBER = pushKingdeeOrder.TradeType == 8 ? "XSDD05_SYS" : "XSDD01_SYS"
},
- FOrdertype = pushKingdeeOrder.TradeType == 8 ? "8" : "4",
+ FOrdertype = pushKingdeeOrder.TradeType == 8 ? "7" : "4",
FDate = pushKingdeeOrder.ConsignTime?.ToString("yyyy/MM/dd"),
FSaleOrgId = new FSaleOrgId()
{
- FNumber = "" // 固定组织
+ FOrgId = param.FSaleOrgId.ToString() // 销售组织
},
- FCustId = new FCustId()
+ FCustId = new FCustomerId()
{
- FNumber = "", // 客户?
+ FCustId = param.FSALESCUSTOMERS.ToString(), // 客户?
},
FSalerId = new FSalerId()
{
- FNumber = "", // 销售员
+ FId = param.FSALER, // 销售员
+ //FNumber = "思迅销售员_GW000002_1", // 销售员
},
Foutlets = new Foutlets()
{
@@ -291,9 +314,9 @@ namespace MyCode.Project.Services.Implementation
};
SaleOrderModel fSaleOrderEntry = new SaleOrderModel();
- var resultString = _kingDeeService.Save("SAL_SaleOrder", billSave);
- LogHelper.Info(resultString);
- return resultString;
+ var responseStatus = _kingDeeService.Save("SAL_SaleOrder", billSave);
+ //LogHelper.Info();
+ return responseStatus;
}
}
}