This commit is contained in:
2025-04-24 18:31:27 +08:00
commit 9340f5253e
2796 changed files with 1387124 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.OutSideService
{
public interface IDingDingService
{
/// <summary>
/// 发送消息
/// </summary>
/// <param name="content"></param>
void SendMsg(string content);
}
}

View File

@@ -0,0 +1,57 @@
using MyCode.Project.Domain.Message.Response.EnterpriseWechat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.OutSideService
{
public interface IEnterpriseWechatService
{
/// <summary>
/// 得到AccessToken有效期7200秒
/// </summary>
/// <param name="corpId">企业id</param>
/// <param name="secret"></param>
/// <returns></returns>
string GetAccessToken(string corpId, string secret);
/// <summary>
/// 取得通讯录的部门列表
/// </summary>
/// <param name="accessToken"></param>
/// <returns></returns>
List<DepartmentHasChild> GetDepartmentList(string accessToken, string corpId = "", string secret = "");
/// <summary>
/// 得到部门的员工列表
/// </summary>
/// <param name="accessToken">通讯录的token</param>
/// <param name="departmentId">部门id</param>
/// <param name="fetch_child">是否递归获取子部门下面的成员1-递归获取0-只获取本部门</param>
/// <returns></returns>
List<DepartmentMemberInfo> GetDepartmentMemberList(string accessToken, long departmentId, string corpId = "", string secret = "", int fetch_child = 0);
/// <summary>
/// 获取员工信息
/// </summary>
/// <param name="userId">员工id</param>
/// <returns></returns>
EnterpriseEmployeeInfo GetEmployeeInfo(string userId, string corpId, string secret);
/// <summary>
/// userid转openid
/// </summary>
/// <param name="userId"></param>
/// <param name="corpId"></param>
/// <param name="secret"></param>
/// <returns></returns>
UserIdChangeOpenIdResp GetOpenidByUserid(string userId, string corpId = "", string secret = "");
}
}

View File

@@ -0,0 +1,71 @@
using Kingdee.CDP.WebApi.SDK;
using MyCode.Project.Domain.Message.Act.PurchaseOrder;
using MyCode.Project.Domain.Message.Request.KingDee;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.OutSideService
{
public interface IKingDeeService
{
/// <summary>
/// 获取一个K3客户端
/// </summary>
/// <param name="content"></param>
K3CloudApi GetK3CloudClient();
/// <summary>
/// 获取供应商
/// </summary>
/// <returns></returns>
string GetBDSupplier();
/// <summary>
/// 获取采购组织
/// </summary>
/// <returns></returns>
string GetFPurchaseOrgList();
string QueryList(BillQuery queryParam);
/// <summary>
/// 保存一个订单对象
/// </summary>
/// <param name="formId"></param>
/// <param name="billSave"></param>
/// <returns></returns>
string Save(string formId, BillSave billSave);
/// <summary>
/// 下推订单
/// </summary>
/// <param name="formId"></param>
/// <param name="billPush"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
string Push(string formId, BillPush billPush);
/// <summary>
/// 批量新增条码档案的接口
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
string AddTiaoMa(string json);
/// <summary>
/// 删除某个订单
/// </summary>
/// <param name="formId"></param>
/// <param name="billdelete"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
dynamic Delete(string formId, BillDelete billdelete);
}
}

View File

@@ -0,0 +1,33 @@
using MyCode.Project.Domain.Config;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.WebPost;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.OutSideService.Implementation
{
public class DingDingService:IDingDingService
{
public DingDingService()
{
}
#region SendMsg()
public void SendMsg(string content)
{
var url = SystemConfig.DingDingApiUrl;
WebUtils webUtils = new WebUtils();
var jsonObject = new { msgtype = "text", text = new { content = SystemConfig.DingDingTxt+ content } };
var jsonStr = JsonHelper.ToJson(jsonObject);
var result = webUtils.DoPostJson(url, jsonStr);
}
#endregion
}
}

View File

@@ -0,0 +1,474 @@
using MyCode.Project.Domain.Message.Response.EnterpriseWechat;
using MyCode.Project.Domain.Message.Response.Wechat;
using MyCode.Project.Infrastructure.Cache;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Constant;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Infrastructure.WebPost;
using Senparc.CO2NET.Extensions;
using Senparc.Weixin;
using Senparc.Weixin.MP.Entities;
using Senparc.Weixin.MP.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace MyCode.Project.OutSideService.Implementation
{
public class EnterpriseWechatService : IEnterpriseWechatService
{
private readonly string apiUrl = "https://qyapi.weixin.qq.com/";
private readonly IMyCodeCacheService _myCodeCacheService;
public EnterpriseWechatService(
IMyCodeCacheService myCodeCacheService
)
{
_myCodeCacheService = myCodeCacheService;
}
#region
#region Get(Get方法)
/// <summary>
/// 进一步封装Get方法
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="url"></param>
/// <returns></returns>
private T Get<T>(string url) where T : BaseEnterpriseResp
{
var webUtils = new WebUtils();
var resp = webUtils.DoGet<T>(url, null);
resp.CheckResult();
return resp;
}
#endregion
#region ToDepartmentHasChild()
public List<DepartmentHasChild> ToDepartmentHasChild(List<DepartmentInfo> listDepartmentInfo)
{
if (listDepartmentInfo == null || listDepartmentInfo.Count == 0) { return null; }
//公司节点
var rootList = listDepartmentInfo.FindAll(p => p.Parentid == 0);
var returnList = new List<DepartmentHasChild>();
//子节点
foreach (var root in rootList)
{
var item = new DepartmentHasChild
{
Id = root.Id,
Name = root.Name,
Parentid = root.Parentid
};
item.ListChild = GetDepartmentChild(listDepartmentInfo, root.Id);
returnList.Add(item);
}
return returnList;
}
#endregion
#region GetDepartmentChild()
/// <summary>
/// 得到子节点
/// </summary>
/// <param name="listDepartmentInfo"></param>
/// <param name="parentId"></param>
/// <returns></returns>
public List<DepartmentHasChild> GetDepartmentChild(List<DepartmentInfo> listDepartmentInfo, int parentId)
{
var list = listDepartmentInfo.FindAll(p => p.Parentid == parentId);
var returnList = new List<DepartmentHasChild>();
if (list == null || list.Count == 0) { return new List<DepartmentHasChild> { }; }
foreach (var child in list)
{
var item = new DepartmentHasChild
{
Id = child.Id,
Name = child.Name,
Parentid = child.Parentid,
Order = child.Order
};
item.ListChild = GetDepartmentChild(listDepartmentInfo, child.Id);
returnList.Add(item);
}
return returnList;
}
#endregion
#endregion
#region GetAccessToken(AccessToken7200)
/// <summary>
/// 得到AccessToken有效期7200秒
/// </summary>
/// <param name="corpId">企业id</param>
/// <param name="secret"></param>
/// <returns></returns>
public string GetAccessToken(string corpId, string secret)
{
var cacheKey = $"{CacheKey.EnterpriseWechatTokenKey}{corpId}{secret}";
if (_myCodeCacheService.Exists(cacheKey))
{
return _myCodeCacheService.Get<string>(cacheKey);
}
var url = $"{apiUrl}cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";
var resp = Get<GetTokenResp>(url);
var token = resp.Access_token;
_myCodeCacheService.Set(cacheKey, token, new TimeSpan(1, 0, 0));
return token;
}
#endregion
#region GetTicket(Ticket)
/// <summary>
/// 获取企业微信Ticket
/// </summary>
/// <param name="accessToken">对应的应用的token</param>
/// <returns></returns>
private string GetTicket(string accessToken)
{
var cacheKey = $"{accessToken}";
if (_myCodeCacheService.Exists(cacheKey))
{
return _myCodeCacheService.Get<string>(cacheKey);
}
var url = string.Format(apiUrl + "cgi-bin/get_jsapi_ticket?access_token={0}", accessToken.AsUrlData());
JsApiTicketResult result = Senparc.CO2NET.HttpUtility.Get.GetJson<JsApiTicketResult>(url);
if (result.errcode != ReturnCode.) { throw new BaseException(result.ToJson()); }
_myCodeCacheService.Set(cacheKey, result.ticket, new TimeSpan(1, 0, 0));
return result.ticket;
}
#endregion
#region GetApplicationTicket(jsapi_ticket)
/// <summary>
/// 应用的jsapi_ticket
/// </summary>
/// <param name="accessToken">对应的应用的token</param>
/// <returns></returns>
private string GetApplicationTicket(string accessToken)
{
var cacheKey = $"{accessToken}2";
if (_myCodeCacheService.Exists(cacheKey))
{
return _myCodeCacheService.Get<string>(cacheKey);
}
var url = string.Format(apiUrl + "cgi-bin/ticket/get?access_token={0}&type=agent_config", accessToken.AsUrlData());
JsApiTicketResult result = Senparc.CO2NET.HttpUtility.Get.GetJson<JsApiTicketResult>(url);
if (result.errcode != ReturnCode.) { throw new BaseException(result.ToJson()); }
_myCodeCacheService.Set(cacheKey, result.ticket, new TimeSpan(1, 0, 0));
return result.ticket;
}
#endregion
#region GetJsSdk(JsSdk相关参数值)
/// <summary>
/// 取得微信JsSdk相关参数值
/// </summary>
/// <param name="appId">微信应用ID</param>
/// <param name="ticket">JsTicket</param>
/// <param name="url">需要授权Url地址</param>
/// <returns></returns>
private JsSdkResp GetJsSdk(string appId, string ticket, string url)
{
var decodeUrl = HttpUtility.UrlDecode(url);
string timeStamp = JSSDKHelper.GetTimestamp();
string nonceStr = JSSDKHelper.GetNoncestr();
string signature = "";
var paySignReqHandler = new Senparc.Weixin.TenPay.V2.RequestHandler(null);
paySignReqHandler.SetParameter("jsapi_ticket", ticket);
paySignReqHandler.SetParameter("noncestr", nonceStr);
paySignReqHandler.SetParameter("timestamp", timeStamp);
paySignReqHandler.SetParameter("url", decodeUrl);
signature = paySignReqHandler.CreateSHA1Sign();
return new JsSdkResp
{
AppId = appId,
Timestamp = timeStamp,
NonceStr = nonceStr,
Signature = signature
};
}
#endregion
#region JS-SDK权限验证的签名Signature
/// <summary>
/// 获取企业微信的JS-SDK权限验证的签名Signature
/// </summary>
/// <param name="jsapi_ticket">jsapi_ticket</param>
/// <param name="noncestr">随机字符串(必须与wx.config中的nonceStr相同)</param>
/// <param name="timestamp">时间戳(必须与wx.config中的timestamp相同)</param>
/// <param name="url">当前网页的URL不包含#及其后面部分(必须是调用JS接口页面的完整URL)</param>
/// <returns></returns>
private string GetSignature(string jsapi_ticket, string noncestr, long timestamp, string url)
{
StringBuilder sb = new StringBuilder();
sb.Append("jsapi_ticket=").Append(jsapi_ticket).Append("&")
.Append("noncestr=").Append(noncestr).Append("&")
.Append("timestamp=").Append(timestamp).Append("&")
.Append("url=").Append(url.IndexOf("#") >= 0 ? url.Substring(0, url.IndexOf("#")) : url);
string dddd = sb.ToString();
LogHelper.Info("Signature: " + dddd);
return Senparc.CO2NET.Helpers.EncryptHelper.GetSha1(sb.ToString()).ToLower();
}
#endregion
//#region GetJsSdk(取得企业微信某个应用的JsSdk相关参数值)
///// <summary>
///// 取得企业微信某个应用的JsSdk相关参数值
///// </summary>
///// <param name="url"></param>
///// <param name="tokenType">第一步传 1 第二步传2</param>
///// <returns></returns>
//public EnterpriseWechatJsSdkResp GetJsSdk(string url, int tokenType = 1)
//{
// EnterpriseWechatJsSdkResp result = new EnterpriseWechatJsSdkResp();
// string corpId = companyConfig.Corpid;
// string agentId = companyConfig.CustomerAgentidId.Replace("\r\n", "");
// string secret = companyConfig.CustomerDetailSecret;
// string ticket = "";
// string token = GetAccessToken(corpId, secret);
// long timeStamp = 0;
// string nonceStr = "";
// if (tokenType == 1)
// {
// ticket = GetTicket(token);
// timeStamp = long.Parse(JSSDKHelper.GetTimestamp());
// nonceStr = JSSDKHelper.GetNoncestr();
// }
// else if (tokenType == 2)
// {
// result = _myCodeCacheService.Get<EnterpriseWechatJsSdkResp>(companyConfig.Corpid + "1");
// ticket = GetApplicationTicket(token);
// timeStamp = long.Parse(result.Timestamp);
// nonceStr = result.NonceStr;
// }
// else
// {
// return null;
// }
// //var decodeUrl = HttpUtility.UrlDecode(url);
// string signature = GetSignature(ticket, nonceStr, timeStamp, url);
// result.CorpId = corpId;
// result.AgentId = agentId;
// result.NonceStr = nonceStr;
// result.Signature = signature;
// result.Timestamp = timeStamp.ToString();
// //LogHelper.Info("result:");
// //LogHelper.Info(result);
// _myCodeCacheService.Set(cacheKey, result, new TimeSpan(1, 0, 0));
// return result;
//}
//#endregion
#region GetDepartmentList()
/// <summary>
/// 取得通讯录的部门列表使用通讯录Token
/// </summary>
/// <param name="accessToken">Token</param>
/// <returns></returns>
public List<DepartmentHasChild> GetDepartmentList(string accessToken, string corpId, string secret)
{
if (string.IsNullOrWhiteSpace(accessToken))
{
accessToken = GetAccessToken(corpId, secret);
}
var url = $"{apiUrl}cgi-bin/department/list?access_token={accessToken}";
var resp = Get<DepartmentResp>(url);
if (resp.Department == null || resp.Department.Count == 0) { return new List<DepartmentHasChild> { }; }
return GetDepartmentChild(resp.Department, 0);
}
#endregion
#region GetDepartmentMemberList()
/// <summary>
/// 得到部门的员工列表
/// </summary>
/// <param name="accessToken">通讯录的token</param>
/// <param name="departmentId">部门id</param>
/// <param name="fetch_child">是否递归获取子部门下面的成员1-递归获取0-只获取本部门</param>
/// <returns></returns>
public List<DepartmentMemberInfo> GetDepartmentMemberList(string accessToken, long departmentId, string corpId, string secret, int fetch_child = 0)
{
//if (departmentId == 0) { throw new BaseException("部门id不能为0"); }
if (string.IsNullOrWhiteSpace(accessToken))
{
accessToken = GetAccessToken(corpId, secret);
}
var url = $"{apiUrl}cgi-bin/user/simplelist?access_token={accessToken}&department_id={departmentId}&fetch_child={fetch_child}";//是否递归获取子部门下面的成员1-递归获取0-只获取本部门
var resp = Get<DepartmentMemberInfoResp>(url);
if (resp.Userlist == null || resp.Userlist.Count == 0) { return new List<DepartmentMemberInfo> { }; }
return resp.Userlist;
}
#endregion
#region GetEmployeeInfo()
/// <summary>
/// 获取员工信息
/// </summary>
/// <param name="userId">员工id</param>
/// <returns></returns>
public EnterpriseEmployeeInfo GetEmployeeInfo(string userId, string corpId, string secret)
{
if (string.IsNullOrWhiteSpace(userId)) { throw new BaseException("员工id不能为空"); }
var accessToken = GetAccessToken(corpId, secret);
var url = $"{apiUrl}/cgi-bin/user/get?access_token={accessToken}&userid={userId}";
var webUtils = new WebUtils();
var resp = webUtils.DoGet<EnterpriseEmployeeInfo>(url, null);
return resp;
}
#endregion
//#region GetLoginUserInfo(获取登录用户信息)
///// <summary>
///// 获取登录用户信息
///// </summary>
///// <param name="code"></param>
///// <param name="corpId"></param>
///// <param name="secret">自建应用secret</param>
///// <returns></returns>
//public UserInfoResp GetLoginUserInfo(string code, string corpId = "", string secret = "")
//{
// var accessToken = GetAccessToken(corpId, secret);
// var url = $"{apiUrl}/cgi-bin/user/getuserinfo?access_token={accessToken}&code={code}";
// var result = Get<UserInfoResp>(url);
// return result;
//}
//#endregion
#region url读取内容到内存Stream流中
/// <summary>
/// 从url读取内容到内存Stream流中
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public Stream DownLoadFielToStream(string url)
{
var wreq = HttpWebRequest.Create(url) as HttpWebRequest;
HttpWebResponse response = wreq.GetResponse() as HttpWebResponse;
MemoryStream ms = null;
using (var stream = response.GetResponseStream())
{
Byte[] buffer = new Byte[response.ContentLength];
int offset = 0, actuallyRead = 0;
do
{
actuallyRead = stream.Read(buffer, offset, buffer.Length - offset);
offset += actuallyRead;
}
while (actuallyRead > 0);
ms = new MemoryStream(buffer);
}
response.Close();
return ms;
}
#endregion
//#region openid转userid
///// <summary>
///// openid转userid
///// </summary>
///// <param name="openid"></param>
///// <param name="corpId"></param>
///// <param name="secret">通讯录secret</param>
///// <returns></returns>
//public OpenIdChangeUseridResp GetUseridByOpenid(string openid, string corpId = "", string secret = "")
//{
// var accessToken = GetAccessToken(corpId, secret);
// var url = $"{apiUrl}cgi-bin/user/convert_to_userid?access_token={accessToken}";
// var webUtils = new WebUtils();
// var resp = webUtils.DoGet<OpenIdChangeUseridResp>(url, null);
// return resp;
//}
//#endregion
#region userid转openid
/// <summary>
/// userid转openid
/// </summary>
/// <param name="openid"></param>
/// <param name="corpId"></param>
/// <param name="secret">通讯录secret</param>
/// <returns></returns>
public UserIdChangeOpenIdResp GetOpenidByUserid(string userId, string corpId = "", string secret = "")
{
var accessToken = GetAccessToken(corpId, secret);
var url = $"{apiUrl}cgi-bin/user/convert_to_openid?access_token={accessToken}";
string json = $@"{{
""userid"": ""{userId}""
}}";
var webUtils = new WebUtils();
var resp = webUtils.DoPostJson(url, json);
UserIdChangeOpenIdResp resut = JsonHelper.ToObject<UserIdChangeOpenIdResp>(resp);
return resut;
}
#endregion
}
}

View File

@@ -0,0 +1,303 @@
using Kingdee.CDP.WebApi.SDK;
using Kingdee.CDP.WebApi.SDK.DataEntify;
using MyCode.Project.Domain.Config;
using MyCode.Project.Domain.Message.Act.PurchaseOrder;
using MyCode.Project.Domain.Message.Request.KingDee;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Infrastructure.WebPost;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MyCode.Project.OutSideService.Implementation
{
public class KingDeeService: IKingDeeService
{
public KingDeeService()
{
}
public static K3CloudApi staClient = null;
public static DateTime timeOut = DateTime.Now;
public string AddTiaoMaUrl = "api/UHIK_BD_BarCodeMainFile/Save";
#region
/// <summary>
/// 获取一个K3客户端
/// </summary>
/// <returns></returns>
public K3CloudApi GetK3CloudClient()
{
/***
* "Kingdee": {
"Default": {
//第三方系统登录授权的账套ID
"AcctID": "65edc24ab975db",
//第三方系统登录授权的应用ID
"AppID": "302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv",
//第三方系统登录授权的应用密钥
"AppSec": "5e38f16711514126ae1511ca4ead3232",
//第三方系统登录授权的用户
"UserName": "ERP1",
//账套语系默认2052
"LCID": 2052,
//服务Url地址 (只有私有云用户需要配置Serverurl,公有云用户走网关不需要配置)
"ServerUrl": "http://8.138.110.197/K3Cloud",
// 时间
"Timestamp": 30
}
}
*
*
* */
if (staClient == null || DateTime.Now>timeOut)
{
string AppID = ConfigurationManager.AppSettings.Get("X-KDApi-AppID");
string UserName = ConfigurationManager.AppSettings.Get("X-KDApi-UserName");
string AcctID = ConfigurationManager.AppSettings.Get("X-KDApi-AcctID");
string AppSec = ConfigurationManager.AppSettings.Get("X-KDApi-AppSec");
string LCID = ConfigurationManager.AppSettings.Get("X-KDApi-LCID");
string ServerUrl = ConfigurationManager.AppSettings.Get("X-KDApi-ServerUrl");
staClient = new K3CloudApi(ServerUrl);
timeOut = DateTime.Now.AddMinutes(5);
//staClient.InitClient(AcctID, AppID, AppSec, UserName,int.Parse(LCID), "100", ServerUrl);
//staClient.InitClient("65edc24ab975db", "302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv", "5e38f16711514126ae1511ca4ead3232", "ERP1", 2052, "100", "http://8.138.110.197/k3cloud/");
}
return staClient;
}
#endregion
#region
/// <summary>
/// 获取供应商
/// </summary>
/// <returns></returns>
public string GetBDSupplier()
{
//GetK3CloudClient2();
var staClient2 = GetK3CloudClient();
//staClient.InitClient("65edc24ab975db", "302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv", "5e38f16711514126ae1511ca4ead3232", "ERP1", 2052, "100", "http://8.138.110.197/k3cloud/");
BillQuery billQuery = new BillQuery();
billQuery = new BillQuery()
{
FormId = "BD_Supplier",
FieldKeys = "FNumber,FCountry,FName",
Limit = 200,
StartRow = 0,
};
string json = JsonHelper.ToJson(billQuery);
var sds= staClient2.BillQuery(json);
//string resultJson = JsonHelper.ToJson(sds);
return sds;
}
#endregion
#region
/// <summary>
/// 获取采购组织
/// </summary>
/// <returns></returns>
public string GetFPurchaseOrgList()
{
//GetK3CloudClient2();
var staClient2 = GetK3CloudClient();
//staClient.InitClient("65edc24ab975db", "302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv", "5e38f16711514126ae1511ca4ead3232", "ERP1", 2052, "100", "http://8.138.110.197/k3cloud/");
BillQuery billQuery = new BillQuery();
billQuery = new BillQuery()
{
FormId = "ORG_Organizations",
FieldKeys = "FNumber,FName,FORGID",
Limit = 200,
StartRow = 0,
};
string json = JsonHelper.ToJson(billQuery);
var sds = staClient2.BillQuery(json);
//string resultJson = JsonHelper.ToJson(sds);
return sds;
}
#endregion
public string QueryList(BillQuery queryParam)
{
staClient = GetK3CloudClient();
//staClient.InitClient("65edc24ab975db", "302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv", "5e38f16711514126ae1511ca4ead3232", "ERP1", 2052, "100", "http://8.138.110.197/k3cloud/");
//BillQuery billQuery = new BillQuery();
//FieldKeys = "FID,FBillNo,FDate,FBILLTYPEID,FSUPPLIERID,FName,FSupplierId,FModifyDate,FPurchaserId,FMaterialId,FQty,FEntryNote,FBillAllAmount_LC",
//billQuery = new BillQuery()
//{
// FormId = "PUR_PurchaseOrder",
// FieldKeys = "FID,FBillNo,FDate,FBILLTYPEID,FSUPPLIERID,FSupplierId.FNAME,FSupplierId,FModifyDate,FPurchaserId,FMaterialId,FQty,FEntryNote,FBillAllAmount_LC",
// Limit = 20,
// StartRow = 0,
//};
var datastr =JsonHelper.ToJson(queryParam);
var resultString = staClient.BillQuery(datastr);
// 包含ErrorCode认定为失败
if (resultString.Contains("ErrorCode"))
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
}
//List<dynamic> result = JsonSerializer.Deserialize<List<dynamic>>(resultString);
//var total = this.GetTotal(queryParam);
//return new ViewListOutput(result, total);
return resultString;
}
#region
/// <summary>
/// 保存一个订单对象
/// </summary>
/// <param name="formId"></param>
/// <param name="billSave"></param>
/// <returns></returns>
public string Save(string formId, BillSave billSave)
{
staClient = GetK3CloudClient();
var datastr = JsonHelper.ToJson(billSave);
//LogHelper.Info(datastr);
var resultString = staClient.Save(formId, datastr);
if (resultString.Contains("ErrorCode"))
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
}
var result = JsonHelper.ToObject<Dictionary<string, Dictionary<string, dynamic>>>(resultString);
var data = result["Result"]["ResponseStatus"];
return resultString;
}
#endregion
#region Push()
/// <summary>
/// 下推订单
/// </summary>
/// <param name="formId"></param>
/// <param name="billPush"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public string Push(string formId, BillPush billPush)
{
staClient = GetK3CloudClient();
var datastr = JsonHelper.ToJson(billPush);
LogHelper.Info(datastr);
var resultString = staClient.Push(formId, datastr);
if (resultString.Contains("ErrorCode"))
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(resultString);
throw new Exception("单据在云星空已锁定,请联系采购员");
}
var result = JsonHelper.ToObject<dynamic>(resultString);
var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
return JsonHelper.ToJson( data);
}
#endregion
#region AddTiaoMa()
/// <summary>
/// 批量新增条码档案的接口
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public string AddTiaoMa(string json)
{
List<AddTiaoMa> list = JsonHelper.ToObject<List<AddTiaoMa>>(json);
AddTiaoMaConfig addconfig = new AddTiaoMaConfig();
addconfig.Key = "qwe123!@#";
addconfig.Items = list;
WebUtils webUtils = new WebUtils();
string json2 = JsonHelper.ToJson(addconfig);
string ServerUrl = ConfigurationManager.AppSettings.Get("TiaoMaUrl");
string url = ServerUrl + AddTiaoMaUrl;
LogHelper.Info("批量新增条码档案的接口");
LogHelper.Info(url);
LogHelper.Info(json2);
try
{
var resultString = webUtils.DoPostJson(url, json2);
LogHelper.Info(resultString);
var result = JsonHelper.ToObject<dynamic>(resultString);
var code = result["code"];
if (code != "200")
{
LogHelper.Error("金蝶云接口调用失败,请检查");
LogHelper.Error(result["msg"]);
throw new BaseException("金蝶云接口调用失败,请检查"+ result["msg"]);
}
//if (resultString.Contains("ErrorCode"))
//{
// LogHelper.Error("金蝶云接口调用失败,请检查");
// LogHelper.Error(resultString);
// throw new Exception("金蝶云接口调用失败,请检查");
//}
//var result = JsonHelper.ToObject<dynamic>(resultString);
//var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
//return JsonHelper.ToJson(data);
return resultString;
}
catch (Exception ex)
{
LogHelper.Error("批量新增条码档案的接口出错");
LogHelper.Error(ex);
throw new BaseException(ex.Message);
}
}
#endregion
#region Delete()
/// <summary>
/// 删除某个订单
/// </summary>
/// <param name="formId"></param>
/// <param name="billdelete"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
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);
throw new Exception("单据在云星空已锁定,请联系采购员");
}
var result = JsonHelper.ToObject<dynamic>(resultString);
var data = result["Result"]["ResponseStatus"]["SuccessEntitys"];
return JsonHelper.ToJson(data);
}
#endregion
}
}

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BC7E3726-8F90-4CA9-9269-731987907051}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyCode.Project.OutSideService</RootNamespace>
<AssemblyName>MyCode.Project.OutSideService</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kingdee.CDP.WebApi.SDK">
<HintPath>..\Lib\Kingdee.CDP.WebApi.SDK.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\Microsoft.Practices.Unity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity.Interception, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\Microsoft.Practices.Unity.Interception.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Qiniu">
<HintPath>..\Lib\Qiniu.dll</HintPath>
</Reference>
<Reference Include="Senparc.CO2NET, Version=0.4.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.0.4.4\lib\net45\Senparc.CO2NET.dll</HintPath>
</Reference>
<Reference Include="Senparc.CO2NET.APM, Version=0.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.APM.0.2.2\lib\net45\Senparc.CO2NET.APM.dll</HintPath>
</Reference>
<Reference Include="Senparc.NeuChar, Version=0.5.5.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.NeuChar.0.5.5.2\lib\net45\Senparc.NeuChar.dll</HintPath>
</Reference>
<Reference Include="Senparc.Weixin, Version=6.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.Weixin.6.3.4\lib\net45\Senparc.Weixin.dll</HintPath>
</Reference>
<Reference Include="Senparc.Weixin.MP, Version=16.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.Weixin.MP.16.6.0\lib\net45\Senparc.Weixin.MP.dll</HintPath>
</Reference>
<Reference Include="Senparc.Weixin.TenPay, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.Weixin.TenPay.1.1.2\lib\net45\Senparc.Weixin.TenPay.dll</HintPath>
</Reference>
<Reference Include="Senparc.Weixin.WxOpen, Version=3.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\Senparc.Weixin.WxOpen.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IKingDeeService.cs" />
<Compile Include="IEnterpriseWechatService.cs" />
<Compile Include="Implementation\KingDeeService.cs" />
<Compile Include="Implementation\EnterpriseWechatService.cs" />
<Compile Include="IDingDingService.cs" />
<Compile Include="Implementation\DingDingService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyCode.Project.Domain\MyCode.Project.Domain.csproj">
<Project>{83c7dd85-ca0f-4250-a4ad-b31dd56b14f1}</Project>
<Name>MyCode.Project.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\MyCode.Project.Infrastructure\MyCode.Project.Infrastructure.csproj">
<Project>{b047e3d9-bc3b-4926-954a-0085ad847e75}</Project>
<Name>MyCode.Project.Infrastructure</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("MyCode.Project.OutSideService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CHINA")]
[assembly: AssemblyProduct("MyCode.Project.OutSideService")]
[assembly: AssemblyCopyright("Copyright © CHINA 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bc7e3726-8f90-4ca9-9269-731987907051")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- 当前使用的 账套ID(即数据中心id) --><!--
--><!-- 第三方系统登录授权的账套ID即open.kingdee.com网站的第三方系统登录授权中的数据中心标识--><!--
--><!-- 在第三方系统登录授权页面点击“生成测试链接”按钮后即可查看 --><!--
<add key="X-KDApi-AcctID" value="65edc24ab975db"/>
--><!-- 第三方系统登录授权的 集成用户名称 --><!--
--><!-- 补丁版本为PT-146894 [7.7.0.202111]及后续的版本,则为指定用户登录列表中任一用户 --><!--
--><!-- 若第三方系统登录授权已勾选“允许全部用户登录”,则无以上限制 --><!--
<add key="X-KDApi-UserName" value="ERP1" />
--><!-- 第三方系统登录授权的 应用ID --><!--
<add key="X-KDApi-AppID" value="302967_20fp7YsL2kpWR9VG5Y3LSbUHzv3/SDmv"/>
--><!-- 第三方系统登录授权的 应用密钥 --><!--
<add key="X-KDApi-AppSec" value="5e38f16711514126ae1511ca4ead3232"/>
--><!-- 账套语系默认2052 --><!--
<add key="X-KDApi-LCID" value="2052"/>
--><!-- 组织编码,启用多组织时配置对应的组织编码才有效 --><!--
--><!--<add key="X-KDApi-OrgNum" value="*****"/>--><!--
--><!-- 服务Url地址(私有云和公有云都须配置金蝶云星空产品地址K3Cloud/结尾)--><!--
<add key="X-KDApi-ServerUrl" value="http://8.138.110.197/K3Cloud"/>-->
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
<package id="Senparc.CO2NET" version="0.4.4" targetFramework="net461" />
<package id="Senparc.CO2NET.APM" version="0.2.2" targetFramework="net461" />
<package id="Senparc.NeuChar" version="0.5.5.2" targetFramework="net461" />
<package id="Senparc.Weixin" version="6.3.4" targetFramework="net461" />
<package id="Senparc.Weixin.MP" version="16.6.0" targetFramework="net461" />
<package id="Senparc.Weixin.TenPay" version="1.1.2" targetFramework="net461" />
<package id="Senparc.Weixin.WxOpen" version="3.3.0" targetFramework="net461" />
</packages>