| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885 |
- using BizCom;
- using Newtonsoft.Json;
- using SiteCore.taobao;
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Net;
- using System.Reflection;
- using System.Security.Cryptography;
- using System.Text;
- using System.Web;
- using Utils;
- using static SiteCore.taoObj.work_core_vo;
- namespace SiteCore.Handler
- {
- public class apiDesign : BaseHandler, IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- if (UrlParmsCheck("t"))
- {
- String tname = GetString("t");
- MethodInfo method;
- Type type = this.GetType();
- method = type.GetMethod(tname);
- con = context;
- if (method == null)
- {
- conError("找不到对应方法,服务器返回错误");
- return;
- }
- successFlag = false;
- context.Response.ContentType = "application/json";
- context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
- try
- {
- method.Invoke(this, null);
- }
- catch (Exception ex)
- {
- conError("处理接口错误,服务器返回错误");
- }
- finally
- {
- //AfterInvoke(methodName);
- }
- //if (!successFlag) returnErrorMsg("服务器返回错误");
- }
- }
- static string appID = "1823193185001";
- //***************************************************
- //static string signkey = "fed5be35cf5bd04b14dcfff984f861dd";
- static HttpHelper tb_http = new HttpHelper();
- static string merSecret = "D8FF9498A5A2E6A6B4CB6EF88DB1DC35";
- static string pUrl = "https://front.lingtao8.com/designRest.htm";
- //static string pUrl = "http://localhost:8999/designRest.htm";
- //static string pUrl = "http://yi.yhmwacg.cn/designRest.htm";
- public static int DateTimeToUnixTime(DateTime dateTime)
- {
- return (int)(dateTime - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds;
- }
- //public static string ToUrlParams(object jsonObject)
- //{
- // var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty); // 遍历JSON对象的属性,并添加到查询字符串中
- // foreach (var property in jsonObject.GetType().GetProperties())
- // {
- // queryString[property.Name] = property.GetValue(jsonObject)?.ToString() ?? string.Empty;
- // }
- // return queryString.ToString();
- //}
- public static Dictionary<string, object> ToDictionary(object obj)
- {
- var type = obj.GetType();
- var properties = type.GetProperties();
- var dictionary = new Dictionary<string, object>();
- foreach (var property in properties)
- {
- var value = property.GetValue(obj);
- dictionary.Add(property.Name, value);
- }
- return dictionary;
- }
- public static string ToUrlParams(Dictionary<string, object> jsonObject)
- {
- var queryString = new System.Collections.Specialized.NameValueCollection();
- // 遍历JSON对象的属性,并添加到查询字符串中
- foreach (var property in jsonObject)
- {
- var value = property.Value;
- if (value != null)
- {
- // 如果属性值不为null,则添加到查询字符串中
- if (value is System.Collections.IEnumerable && !(value is string))
- {
- // 如果是数组或集合类型,需要进一步处理
- var index = 0;
- foreach (var item in (System.Collections.IEnumerable)value)
- {
- queryString.Add(property.Key + "[" + index + "]", item != null ? item.ToString() : string.Empty);
- index++;
- }
- }
- else
- {
- // 普通属性
- queryString.Add(property.Key, value.ToString());
- }
- }
- }
- // 获取最终的查询字符串
- return string.Join("&", queryString.AllKeys.Select(key => key + "=" + queryString[key]));
- }
- public static string createSignCode(string method, string timeStr, string design_app_id, string design_secret)
- {
- byte[] use_bytes;
- //query.Append(secret);
- //预留看一下到时候签名怎么用md5加密;***************************************************
- string encryStr = design_secret + method + timeStr + design_app_id + design_secret;
- MD5 md5 = MD5.Create();
- use_bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(encryStr));
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < use_bytes.Length; i++)
- {
- result.Append(use_bytes[i].ToString("x2"));
- }
- string singResult = result.ToString();
- return singResult.Replace("-", "");
- //return bytes.ToString();
- }
- public static string API_GetPrintData_CreateOrder(CeErpTradeCell ceErpTradeCell)
- {
- if (ceErpTradeCell.IsSample == 2)
- {
- return "补差价订单不需要过设计系统";
- }
- CeErpOrderFormData formData = null;
- formData = CeErpOrderFormData.GetByTid(ceErpTradeCell.ctid.ToString());
- if (formData == null)
- {
- /* CeErpMessageTip ceErpMessageTip = new CeErpMessageTip();
- ceErpMessageTip.tid = ceErpTradeCell.ctid;
- ceErpMessageTip.type = 2;
- ceErpMessageTip.userId = ceErpTradeCell.CustomerUserId;
- ceErpMessageTip.isVisit = false;
- ceErpMessageTip.content = "订单:" + ceErpTradeCell.ctid + "备注手机号或者微信号未填写!无法指派到设计系统!!请立马备注!!";
- ceErpMessageTip.Create();*/
- //return "请填写订单的手机号或者微信号才可指派到设计系统";
- }
- //json参数
- List<string> postLst = new List<string>();
- Boolean isOldCustomerText = false;
- Boolean isReturn = false;
- Boolean isGai = false;
- if (ceErpTradeCell.IsOldCustomer == 1)
- {
- isOldCustomerText = true;
- }
- if (ceErpTradeCell.IsReturn > 0)
- {
- isReturn = true;
- }
- if (ceErpTradeCell.MemoOpt == 1)
- {
- isGai = true;
- }
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- CeErpShop ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
- string design_app_id = ceErpShop.design_app_id;
- string design_secret = ceErpShop.design_secret;
- if (design_app_id == null || design_app_id == "")
- {
- design_app_id = appID;
- }
- if (design_secret == null || design_secret == "")
- {
- design_secret = merSecret;
- }
- string method = "design.order.create";
- string timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string sign = createSignCode(method, timeStr, design_app_id, design_secret);
- var res_obj = new
- {
- sign = sign,
- method = method,
- merchantId = design_app_id,
- appKey = design_app_id,
- outId = ceErpTradeCell.ID,
- designType = ceErpTradeCell.ProductId,
- draftType = 2,
- designPage = 1,
- afterNames = "null",
- printSpecial = "null",
- designWidth = 0,
- designHeight = 0,
- printKs = 1,
- printMs = 1,
- printWidth = 0,
- printHeight = 0,
- amount = ceErpTradeCell.payment,
- isUrgent = ceErpTradeCell.IsUrgency,
- userContact = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
- userMobile = "null",
- userQq = "null",
- userWx = "null",
- userText = "null",
- userNotice = "null",
- servicesMessage = ceErpTradeCell.CustomerMemo,
- shopNick = ceErpShop.ShopName,
- buyerNick = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
- apiFiles = new Array[1],
- receiverName = ceErpTrade.receiver_name,
- receiverMobile = ceErpTrade.receiver_mobile,
- receiverState = ceErpTrade.receiver_state,
- receiverCity = ceErpTrade.receiver_city,
- receiverDistrict = ceErpTrade.receiver_district,
- receiverAddress = ceErpTrade.receiver_address,
- expressCode = "null",
- creater = "null",
- orderSrc = "0",
- tids = ceErpTradeCell.ctid,
- isOnlyDesign = "false",
- isOldUser = isOldCustomerText,
- orderText = ceErpTradeCell.seller_memo,
- isChange = isGai,
- isBack = isReturn,
- tid = ceErpTradeCell.tid
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ro_json = ro_json.Replace("{", "");
- ro_json = ro_json.Replace("}", "");
- ro_json = ro_json.Replace("\"", "");
- ro_json = ro_json.Replace(",", "&");
- ro_json = ro_json.Replace(":", "=");
- ro_json = ro_json.Replace("+", "%2B");
- ro_json += "×tamp=" + timeStr;
- //;***************************************************
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- //Dictionary<string, object> dataDic = ToDictionary(ro_json);
- //string urlData = ToUrlParams(dataDic);
- string sql_pay = "INSERT INTO CE_ErpToDesignLog (ctid, ctime) VALUES ('" + ceErpTradeCell.ctid + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- HttpItem item = new HttpItem()
- {
- URL = pUrl,
- Method = "POST",
- ContentType = "application/x-www-form-urlencoded",
- Postdata = ro_json
- };
- item.PostEncoding = Encoding.UTF8;
- HttpResult hResult = tb_http.GetHtml(item);
- return hResult.Html;
- //string res = Base_Request_CreateOrder(ro_json, "design.order.create");
- //return res;
- }
- public static string API_GetPrintData_Refund(CeErpTradeCell ceErpTradeCell)
- {
- if (ceErpTradeCell == null)
- {
- return "";
- }
- //json参数
- List<string> postLst = new List<string>();
- Boolean isOldCustomerText = false;
- Boolean isReturn = false;
- Boolean isGai = false;
- if (ceErpTradeCell.IsOldCustomer == 1)
- {
- isOldCustomerText = true;
- }
- if (ceErpTradeCell.IsReturn > 0)
- {
- isReturn = true;
- }
- if (ceErpTradeCell.MemoOpt == 1)
- {
- isGai = true;
- }
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- CeErpShop ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
- string design_app_id = "";
- string design_secret = "";
- if (design_app_id == null || design_app_id == "")
- {
- design_app_id = appID;
- }
- if (design_secret == null || design_secret == "")
- {
- design_secret = merSecret;
- }
- string method = "design.order.refund";
- string timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string sign = createSignCode(method, timeStr, design_app_id, design_secret);
- var res_obj = new
- {
- sign = sign,
- method = method,
- merchantId = design_app_id,
- appKey = design_app_id,
- outId = ceErpTradeCell.ID,
- designType = ceErpTradeCell.ProductId,
- draftType = 2,
- designPage = 1,
- afterNames = "null",
- printSpecial = "null",
- designWidth = 0,
- designHeight = 0,
- printKs = 1,
- printMs = 1,
- printWidth = 0,
- printHeight = 0,
- amount = ceErpTradeCell.payment,
- isUrgent = ceErpTradeCell.IsUrgency,
- userContact = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
- userMobile = "null",
- userQq = "null",
- userWx = "null",
- userText = "null",
- userNotice = "null",
- servicesMessage = ceErpTradeCell.CustomerMemo,
- shopNick = "",
- buyerNick = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
- apiFiles = new Array[1],
- receiverName = ceErpTrade.receiver_name,
- receiverMobile = ceErpTrade.receiver_mobile,
- receiverState = ceErpTrade.receiver_state,
- receiverCity = ceErpTrade.receiver_city,
- receiverDistrict = ceErpTrade.receiver_district,
- receiverAddress = ceErpTrade.receiver_address,
- expressCode = "null",
- creater = "null",
- orderSrc = "0",
- tids = ceErpTradeCell.tid,
- isOnlyDesign = "false",
- isOldUser = isOldCustomerText,
- orderText = ceErpTradeCell.seller_memo,
- isChange = isGai,
- isBack = isReturn
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ro_json = ro_json.Replace("{", "");
- ro_json = ro_json.Replace("}", "");
- ro_json = ro_json.Replace("\"", "");
- ro_json = ro_json.Replace(",", "&");
- ro_json = ro_json.Replace(":", "=");
- ro_json += "×tamp=" + timeStr;
- //;***************************************************
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- //Dictionary<string, object> dataDic = ToDictionary(ro_json);
- //string urlData = ToUrlParams(dataDic);
- HttpItem item = new HttpItem()
- {
- URL = pUrl,
- Method = "POST",
- ContentType = "application/x-www-form-urlencoded",
- Postdata = ro_json
- };
- item.PostEncoding = Encoding.UTF8;
- HttpResult hResult = tb_http.GetHtml(item);
- return hResult.Html;
- //string res = Base_Request_CreateOrder(ro_json, "design.order.create");
- //return res;
- }
- //public static string Base_Request_CreateOrder(string jsonParams, string methodStr)
- //{
- // int sc = DateTimeToUnixTime(DateTime.Now);
- // Dictionary<string, string> postParamList = new Dictionary<string, string>();
- // postParamList.Add("sign", "fed5be35cf5bd04b14dcfff984f861dd");
- // postParamList.Add("method", methodStr);
- // postParamList.Add("merchantId", appid);
- // postParamList.Add("appKey", appid);
- // //json参数
- // List<string> postLst = new List<string>();
- // string ro_json = jsonParams;
- // //post参数
- // postLst.Add("method=" + methodStr);
- // postLst.Add("appKey=" + appid);
- // postLst.Add("timestamp=" + sc);
- // postLst.Add("sign=" + sign);
- // postLst.Add("merchantId=" + appid);
- // string pUrl = "http://127.0.0.1:8999/designRest.htm" + "?" + string.Join("&", postLst.ToArray());
- // HttpItem item = new HttpItem()
- // {
- // URL = pUrl,
- // Method = "POST",
- // ContentType = "application/x-www-form-urlencoded",
- // Postdata = ro_json
- // };
- // item.PostEncoding = Encoding.UTF8;
- // HttpResult hResult = tb_http.GetHtml(item);
- // return hResult.Html;
- //}
- public static string API_GetPrintData_ModifyOrder(string tid, string seller_memo, Boolean isGai, Boolean isReturn, string returnReason = "")
- {
- //json参数
- List<string> postLst = new List<string>();
- string method = "design.order.update.info";
- string timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- CeErpShop ceErpShop = null;
- if (ceErpTradeCell != null)
- {
- ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
- }
- string design_app_id = null;
- string design_secret = null;
- if (ceErpShop != null)
- {
- design_app_id = ceErpShop.design_app_id;
- design_secret = ceErpShop.design_secret;
- }
- if (design_app_id == null || design_app_id == "")
- {
- design_app_id = appID;
- }
- if (design_secret == null || design_secret == "")
- {
- design_secret = merSecret;
- }
- string sign = createSignCode(method, timeStr, design_app_id, design_secret);
- var res_obj = new
- {
- method = method,
- sign = sign,
- merchantId = design_app_id,
- appKey = design_app_id,
- outId = tid,
- orderText = seller_memo,
- isChange = isGai,
- isBack = isReturn,
- returnReason = returnReason,
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ro_json = ro_json.Replace("{", "");
- ro_json = ro_json.Replace("}", "");
- ro_json = ro_json.Replace("\"", "");
- ro_json = ro_json.Replace(",", "&");
- ro_json = ro_json.Replace(":", "=");
- ro_json = ro_json.Replace("+", "%2B");
- ro_json += "×tamp=" + timeStr;
- //***************************************************
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- HttpItem item = new HttpItem()
- {
- URL = pUrl,
- Method = "POST",
- Accept = "*/*",
- ContentType = "application/x-www-form-urlencoded",
- Postdata = ro_json
- };
- item.PostEncoding = Encoding.UTF8;
- HttpResult hResult = tb_http.GetHtml(item);
- return hResult.Html;
- //string res = Base_Request_ModifyOrder(ro_json, "design.order.update.info");
- //return res;
- }
- //public static string Base_Request_ModifyOrder(string jsonParams, string methodStr)
- //{
- // int sc = DateTimeToUnixTime(DateTime.Now);
- // Dictionary<string, string> postParamList = new Dictionary<string, string>();
- // //json参数
- // List<string> postLst = new List<string>();
- // string ro_json = jsonParams;
- // //post参数
- // postLst.Add("method=" + methodStr);
- // postLst.Add("appKey=" + appid);
- // postLst.Add("timestamp=" + sc);
- // postLst.Add("sign=" + sign);
- // postLst.Add("merchantId=" + appid);
- // string pUrl = "http://127.0.0.1:8999/designRest.htm" + "?" + string.Join("&", postLst.ToArray());
- // HttpItem item = new HttpItem()
- // {
- // URL = pUrl,
- // Method = "POST",
- // ContentType = "application/x-www-form-urlencoded",
- // Postdata = ro_json
- // };
- // item.PostEncoding = Encoding.UTF8;
- // HttpResult hResult = tb_http.GetHtml(item);
- // return hResult.Html;
- //}
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=DesignSys_AddLog post请求参数(参数放body中):string tid(淘宝订单号)string userName(操作用户)string con(日志内容)int orderState(订单状态)
- public void DesignSys_AddLog()
- {
- if (UrlPostParmsCheck("tid"))
- {
- try
- {
- //HttpContext.Current.Request.BinaryRead()
- string tid = GetPostString("tid");
- int userId = GetPostInt("userId");
- int orderState = GetPostInt("orderState");
- string con = GetPostString("con");
- if (userId == 0)
- {
- userId = 2125;
- }
- try
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- if (ceErpTradeCell != null)
- {
- LogHelper.addLog(tid, userId, con, orderState);
- return;
- }
- else
- {
- returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "xxxxx," + ex.Message);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, ex.Message);
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void DesignSys_AddStateLog()
- {
- if (UrlPostParmsCheck("tid"))
- {
- try
- {
- //HttpContext.Current.Request.BinaryRead()
- string tid = GetPostString("tid");
- int userId = GetPostInt("userId");
- int orderState = GetPostInt("orderState");
- string con = GetPostString("con");
- if (userId == 0)
- {
- userId = 2125;
- }
- try
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.OrderState = orderState;
- ceErpTradeCell.UpdateTime = DateTime.Now;
- LogHelper.addLog(tid, userId, con, orderState);
- return;
- }
- else
- {
- returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "xxxxx," + ex.Message);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, ex.Message);
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=DesignSys_OrderStateChange post请求参数(参数放body中):string tid(淘宝订单号)string userName(用户姓名)int orderState(订单状态)
- public void DesignSys_OrderStateChange()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string tid = GetPostString("tid");
- string userName = GetPostString("userName");
- int orderState = GetPostInt("orderState");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- if (ceErpTradeCell != null)
- {
- if (ceErpTradeCell.OrderState >= 5)
- {
- return;
- }
- if (userName != "")
- {
- CeErpUser ceErpUser = CeErpUser.GetByUserName(userName);
- if (ceErpUser != null)
- {
- }
- else
- {
- ceErpUser = CeErpUser.GetByUserName("外协设计-" + userName);
- if (ceErpUser == null)
- {
- returnErrorMsg("找不到对应用户");
- return;
- }
- }
- List<string> sqlList = new List<string>();
- sqlList.Add(" DesignUserId=" + ceErpUser.ID);
- sqlList.Add(" OrderState=" + orderState);
- if (orderState == 4)
- {
- sqlList.Add(" WaitDesignTime= GETDATE()");
- sqlList.Add(" StartDesignTime= GETDATE()");
- }
- sqlList.Add(" UpdateTime= GETDATE()");
- CeErpTradeCell.ExecuteNonQuery(string.Format("UPDATE CE_ErpTradeCell set {0} WHERE ctid = '{1}'", string.Join(",", sqlList), ceErpTradeCell.ctid));
- LogHelper.addLog(ceErpTradeCell.ctid, 3542, "接口请求:" + orderState, ceErpTradeCell.OrderState);
- commonHelper.UpdateRelationOrder(tid);
- return;
- }
- returnErrorMsg("找不到对应用户");
- }
- else
- {
- returnErrorMsg("找不到对应订单记录,核对淘宝订单号");
- return;
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=create_erp_account post请求参数(参数放body中):string name(用户姓名)string pwd(密码)
- public void create_erp_account()
- {
- if (UrlPostParmsCheck("name,pwd"))
- {
- string name = GetPostString("name");
- if (CeErpUser.Exists(" Account=?", name))
- {
- returnErrorMsg("该账户名已经存在,请更换!");
- return;
- }
- string pwd = SecurityHelper.EncryptSymmetric(GetPostString("pwd"));
- CeErpUser user = new CeErpUser();
- user.Account = name;
- user.Name = name;
- user.isOpen = false;
- user.CreateTime = DateTime.Now;
- user.PassWord = pwd;
- user.Create();
- returnSuccessMsg("保存成功!");
- }
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=change_order_price post请求参数(参数放body中):ctid content
- public void change_order_price()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string content = GetPostString("content");
- CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
- if (ce == null)
- {
- returnErrorMsg("找不到订单!");
- return;
- }
- CeErpMessageTip ct = new CeErpMessageTip();
- string sql_pay = string.Format("select top 1 * from CE_ErpMessageTip where tid = '{0}' and type = 2", ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql_pay).Tables[0];
- ct.tid = ctid;
- ct.sectionId = 0;
- ct.userId = ce.CustomerUserId;
- ct.type = 2;
- ct.isVisit = false;
- ct.content = content;
- if (dth.Rows.Count > 0)
- {
- ct.ID = Convert.ToInt32(dth.Rows[0]["ID"]);
- ct.Update();
- }
- else
- {
- ct.Create();
- }
- LogHelper.addLog(ce.ctid, 3542, "接口请求修改:" + content, ce.OrderState);
- returnSuccessMsg("保存成功!");
- }
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=change_order_price post请求参数(参数放body中):ctid content
- public void return_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string content = GetPostString("content");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity == null)
- {
- returnErrorMsg("找不到订单!");
- return;
- }
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- entity.IsReadTag = 1;
- entity.IsVerifyToSupplier = false;
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = 2;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = content;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, 3542, "接口打回:" + content, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("参数错误!");
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=handleAfterSale post请求参数(参数放body中):responsibleId-售后单id status-处理结果1同意2不同意 supmemo-理由
- public void handleAfterSale()
- {
- string responsibleId = GetString("responsibleId");
- int st = GetInt("status");
- string afmemo = GetString("supmemo");
- string id = "0";
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.Get(responsibleId);
- CeErpTradeCell entity = null;
- if (ceErpTradeResponsible != null)
- {
- id = ceErpTradeResponsible.ID.ToString();
- entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (ceErpTradeResponsible.VerifyState == 1)
- {
- returnErrorMsg("已超时自动认可");
- return;
- }
- }
- if (entity != null)
- {
- if (entity.AfterSaleState != 3 || ceErpTradeResponsible.VerifyState != 0)
- {
- returnErrorMsg("此单售后当前状态不可操作!");
- return;
- }
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- ceErpTradeResponsible.VerifyState = 1;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- if (entity.AfterSaleResSupId > 0)
- {
- entity.AfterSaleSupplierState = 1;
- }
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.Create();
- }
- entity.AfterSaleState = 2;
- }
- if (entity.AfterSaleState == 4)
- {
- LogHelper.addLog(entity.tid, 0, "设计共创接口完成售后", 0, 3);
- if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
- {
- LogHelper.addDesignerBillLog(entity.tid, 0, "设计共创接口售后取消设计费", "设计共创接口", 1);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, 0, "设计共创接口" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "设计共创" + (st == 1 ? "认可" : "不认可"), 0, st == 1 ? 0 : 1, afmemo);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- //http://47.114.150.226:88/Handler/apiDesign.ashx?t=getOrderLogs post请求参数(参数放body中):responsibleId-售后单id status-处理结果1同意2不同意 supmemo-理由
- public void getOrderLogs()
- {
- string ctid = GetPostString("ctid");
- if (string.IsNullOrEmpty(ctid))
- {
- returnErrorMsg("找不到订单记录");
- return;
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_erptradelog where tid='{0}' order by id;", ctid);
- DataTable ds = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(ds)) + "}");
- return;
- }
- }
- }
|