| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- using BizCom;
- using Newtonsoft.Json;
- using NPOI.POIFS.Properties;
- using NPOI.SS.Formula.Functions;
- using SiteCore.Handler;
- using SiteCore.taoObj;
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Data;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Reflection;
- using System.Runtime.Remoting.Messaging;
- using System.Runtime.Remoting.Metadata.W3cXsd2001;
- using System.Security.Policy;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Web;
- using static NHibernate.Linq.Visitors.LeftJoinDetector;
- using static SiteCore.taoObj.work_core_vo;
- namespace SiteCore.Handler
- {
- public class designHelper : 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
- {
- }
- }
- }
- static string pUrl = "http://47.122.60.212:8181/api/originalOrder/";
- //static string pUrl = "http://47.122.40.91:8181/api/originalOrder/";
- static HttpHelper tb_http = new HttpHelper();
- public static designApiResponseVo API_GetPrintData_CreateOrder(CeErpTradeCell ceErpTradeCell, string post = "")
- {
- if (ceErpTradeCell.IsSample == 2)
- {
- return new designApiResponseVo(-1, "补差价订单不需要过设计系统");
- }
- string post_url = pUrl + "add";
- CeErpOrderFormData formData = null;
- if (post != "SysAdmin" && post != "Summarize")
- {
- if (!ceErpTradeCell.ctid.Contains("S_"))
- {
- formData = CeErpOrderFormData.GetByTid(ceErpTradeCell.ctid.ToString());
- if (formData == null)
- {
- return new designApiResponseVo(-1, "请填写订单的手机号或者微信号才可指派到设计系统");
- }
- }
- }
- designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell, post);
- if (response.code != 200)
- {
- return response;
- }
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- //json参数
- NameValueCollection PostVars = getParams(ceErpTradeCell);
- if (ceErpTradeCell.CustomerUserId > 0)
- {
- string sql = "select top 1 Name,Mobile from view_ErpUser where ID = '" + ceErpTradeCell.CustomerUserId + "'";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- PostVars.Add("customerName", dt.Rows[0]["Name"].ToString());
- PostVars.Add("customerTel", dt.Rows[0]["Mobile"].ToString());
- }
- //{"msg":"推送成功","code":200,"success":true}
- string result = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
- result = "设计共创:失败-" + response.msg;
- if (response.code == 200)
- {
- result = "设计共创:成功";
- CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
- //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "API_GetPrintData_CreateOrder:" + ex.Message);
- }
- return new designApiResponseVo(200, result);
- }
- public static designApiResponseVo API_update_order(CeErpTradeCell ceErpTradeCell)
- {
- string post_url = pUrl + "workCore";
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- NameValueCollection PostVars = getParams(ceErpTradeCell);
- PostVars.Add("actionName", "orderRemarks");
- PostVars.Add("orderNumber", ceErpTradeCell.ctid);
- string result = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- string remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- designApiResponseVo response = JsonConvert.DeserializeObject<designApiResponseVo>(remoteInfo);
- result = "设计共创:失败-" + response.msg;
- if (response.code == 200)
- {
- result = "设计共创:成功";
- CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 2);
- //commonHelper.updateDataTradeCellDesignInfo(ceErpTradeCell.ctid);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "API_GetPrintData_CreateOrder:" + ex.Message);
- }
- return new designApiResponseVo(200, result);
- }
- private static NameValueCollection getParams(CeErpTradeCell ceErpTradeCell)
- {
- 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);
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
- //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());
- NameValueCollection PostVars = new NameValueCollection();
- PostVars.Add("outId", ceErpTradeCell.ID.ToString());
- PostVars.Add("productId", ceErpTradeCell.ProductId.ToString());
- PostVars.Add("payment", ceErpTradeCell.payment.ToString());
- PostVars.Add("isUrgent", ceErpTradeCell.IsUrgency.ToString());
- PostVars.Add("customerMemo", ceErpTradeCell.CustomerMemo);
- PostVars.Add("shopName", ceErpShop.ShopName);
- PostVars.Add("buyerNick", ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao");
- PostVars.Add("receiverName", ceErpTrade.receiver_name);
- PostVars.Add("receiverMobile", ceErpTrade.receiver_mobile);
- PostVars.Add("receiverState", ceErpTrade.receiver_state);
- PostVars.Add("receiverCity", ceErpTrade.receiver_city);
- PostVars.Add("receiverDistrict", ceErpTrade.receiver_district);
- PostVars.Add("receiverAddress", ceErpTrade.receiver_address);
- PostVars.Add("tids", ceErpTradeCell.ctid);
- PostVars.Add("isOldUser", isOldCustomerText.ToString());
- PostVars.Add("sellerMemo", ceErpTradeCell.seller_memo);
- PostVars.Add("orderRemarks", ceErpTradeCell.seller_memo);
- PostVars.Add("isChange", isGai.ToString());
- PostVars.Add("isBack", isReturn.ToString());
- PostVars.Add("tid", ceErpTradeCell.tid);
- PostVars.Add("isDianziOrder", ceErpTradeCell.isDianziOrder.ToString());
- PostVars.Add("orderUnique", ceErpTradeCell.OrderSn);
- PostVars.Add("ptid", ceErpTradeCell.ptid);
- PostVars.Add("SplitTag", ceErpTradeCell.SplitTag);
- PostVars.Add("remarkSign", ceErpTradeCell.MemoOpt.ToString());
- PostVars.Add("otherMemo", ceErpTradeCell.OtherMemo);
- PostVars.Add("parentSplitNo", ceErpTradeCell.ParentSplitNo);
- if (ceErpTradeCellExtend != null)
- {
- PostVars.Add("productFirName", ceErpTradeCellExtend.cate1);/// 分类1
- PostVars.Add("productFirId", ceErpTradeCellExtend.cate1Id);/// 分类id
- PostVars.Add("productSecName", ceErpTradeCellExtend.cate2);/// 分类2
- PostVars.Add("productSecId", ceErpTradeCellExtend.cate2Id);/// 分类id
- PostVars.Add("productThirdId", ceErpTradeCellExtend.cate3Id);/// 分类id
- PostVars.Add("sceneName", ceErpTradeCellExtend.scene); /// 场景
- PostVars.Add("sceneId", ceErpTradeCellExtend.sceneId); /// 场景id
- PostVars.Add("productSizeW", ceErpTradeCellExtend.length.ToString()); /// 长
- PostVars.Add("productSizeH", ceErpTradeCellExtend.height.ToString()); /// 高
- PostVars.Add("productSizeL", ceErpTradeCellExtend.width.ToString()); /// 宽
- PostVars.Add("productCraftName", ceErpTradeCellExtend.craft); /// 工艺
- PostVars.Add("offerAmount", ceErpTradeCellExtend.offerAmount.ToString()); /// 报价金额
- PostVars.Add("styleCount", ceErpTradeCellExtend.numbers.ToString()); /// 款数
- PostVars.Add("materialName", ceErpTradeCellExtend.material); /// 材质
- PostVars.Add("materialId", ceErpTradeCellExtend.materialId); /// 材质id
- PostVars.Add("stylePricing", ceErpTradeCellExtend.numberType); /// 多款类型
- PostVars.Add("productSceneName", ceErpTradeCellExtend.typeScene); /// 品类场景
- PostVars.Add("productSceneId", ceErpTradeCellExtend.typeSceneId); /// 品类场景id
- PostVars.Add("opScene", ceErpTradeCellExtend.opScene); /// 运营场景
- PostVars.Add("opSceneId", ceErpTradeCellExtend.opSceneId); /// 运营场景id
- PostVars.Add("quantity", ceErpTradeCellExtend.quantity.ToString()); /// 数量
- PostVars.Add("productUnit", ceErpTradeCellExtend.numberUnit); /// 数量单位
- PostVars.Add("spuId", ceErpTradeCellExtend.spu_id); /// spuid
- PostVars.Add("recSize", ceErpTradeCellExtend.recSize); /// 推荐尺寸
- PostVars.Add("productSizeUnit", ceErpTradeCellExtend.sizeUnit); /// 尺寸单位
- PostVars.Add("orderFrom", ceErpTradeCellExtend.orderFrom.ToString()); /// 【订单来源】"10":第三方平台"15":私域电商"20":ERP"30":售前系统
- PostVars.Add("orderType", ceErpTradeCellExtend.orderType.ToString()); /// 【订单类型】"10":线上单"15":线下单"20":补差单"30":售后单
- PostVars.Add("discountAmount", ceErpTradeCellExtend.discountAmount.ToString());//折扣金额
- PostVars.Add("differentAmount", ceErpTradeCellExtend.differentAmount.ToString());//补差金额
- PostVars.Add("differentSplitNo", ceErpTradeCellExtend.differentSplitNo);//补差识别号
- }
- return PostVars;
- }
- /**
- *actionName:
- * followRemarks 跟单备注
- * orderRemarks 修改订单备注
-
- * rebutDesign 下单部打回设计单
- * afterDesign 售后设计单
- * changeDesign 改稿/定稿/加急
- * remarkSign 1改稿2定稿3加急
- * closeDesign 关闭订单
- * resetDesign 重置订单
- * packageDesign 顺丰状态
- * finishDesign 顺丰状态
- * approveDesign 下单部通过
- **/
- public static void API_WorkCore(string orderNumber, string actionName, string orderRemarks = "", int remarkSign = 0, string reasonRemarks = "", string isSf = "", int demandExamine = 0)
- {
- string post_url = pUrl + "workCore";
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- NameValueCollection PostVars = new NameValueCollection();
- PostVars.Add("orderNumber", orderNumber);
- PostVars.Add("actionName", actionName);
- if (remarkSign > 0)
- {
- PostVars.Add("remarkSign", remarkSign.ToString());
- }
- if (orderRemarks != "")
- {
- PostVars.Add("orderRemarks", orderRemarks);
- }
- if (reasonRemarks != "")
- {
- PostVars.Add("reasonRemarks", reasonRemarks);
- }
- if (isSf != "")
- {
- PostVars.Add("packageSign", isSf);
- }
- if (demandExamine != 0)
- {
- PostVars.Add("demandExamine", demandExamine.ToString());
- }
- string remoteInfo = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
- }
- }
- /**
- *actionName:
- * followRemarks 跟单备注
- * orderRemarks 修改订单备注
-
- * rebutDesign 下单部打回设计单
- * afterDesign 售后设计单
- * changeDesign 改稿/定稿/加急
- * remarkSign 1改稿2定稿3加急
- * closeDesign 关闭订单
- * resetDesign 重置订单
- * packageDesign 顺丰状态
- * finishDesign 上传设计
- * repairDesign 补差金额
- * approveDesign 下单部通过
- * afterOver 售后结束
- **/
- public static void API_WorkCore(ApiVo vo)
- {
- string post_url = pUrl + "workCore";
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- NameValueCollection PostVars = new NameValueCollection();
- PostVars.Add("orderNumber", vo.orderNumber);
- PostVars.Add("actionName", vo.actionName);
- PostVars.Add("isDesign", vo.isDesign.ToString());
- PostVars.Add("isOriginal", vo.isOriginal.ToString());
- if (vo.remarkSign > 0)
- {
- PostVars.Add("remarkSign", vo.remarkSign.ToString());
- }
- if (vo.orderRemarks != "")
- {
- PostVars.Add("orderRemarks", vo.orderRemarks);
- }
- if (vo.reasonRemarks != "")
- {
- PostVars.Add("reasonRemarks", vo.reasonRemarks);
- }
- if (vo.isSf != "")
- {
- PostVars.Add("packageSign", vo.isSf);
- }
- if (vo.demandExamine != 0)
- {
- PostVars.Add("demandExamine", vo.demandExamine.ToString());
- }
- if (vo.payment != 0)
- {
- PostVars.Add("payment", vo.payment.ToString());
- }
- if (vo.designFree != 0)
- {
- PostVars.Add("designFree", vo.designFree.ToString());
- }
- if (vo.responsibleId != 0)
- {
- PostVars.Add("responsibleId", vo.responsibleId.ToString());
- }
- if (!string.IsNullOrEmpty(vo.afterFiles))
- {
- PostVars.Add("afterFiles", vo.afterFiles);
- }
- string remoteInfo = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- if ("orderRemarks".Equals(vo.actionName))
- {
- XLog.SaveLog(0, "API_WorkCore:" + remoteInfo + vo.actionName);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "API_WorkCore:" + ex.Message);
- }
- }
- public static void api_approveDesign(string orderNumber)
- {
- string post_url = pUrl + "approveDesign";
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- NameValueCollection PostVars = new NameValueCollection();
- PostVars.Add("orderNumber", orderNumber);
- string remoteInfo = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "api_approveDesign:" + ex.Message);
- }
- }
- /**
- *actionName:
- * refundIng 退款申请
- * refundEd 已退款
- * refundCancel 取消退款
- **/
- public static void API_refundOrder(string orderNumber, string actionName, string remark)
- {
- string post_url = pUrl + "refundOrder";
- WebClient wc = new WebClient();
- wc.Encoding = Encoding.GetEncoding("utf-8");
- NameValueCollection PostVars = new NameValueCollection();
- PostVars.Add("orderNumber", orderNumber);
- PostVars.Add("actionName", actionName);
- PostVars.Add("orderRemarks", remark);
- string remoteInfo = "";
- try
- {
- byte[] ret = wc.UploadValues(post_url, "POST", PostVars);
- remoteInfo = Encoding.GetEncoding("utf-8").GetString(ret);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "API_refundOrder:" + ex.Message);
- }
- }
- public static string API_GetPrintData_Refund(CeErpTradeCell ceErpTradeCell)
- {
- string post_url = pUrl + "refund";
- //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);
- var res_obj = new
- {
- outId = ceErpTradeCell.ID,
- productId = ceErpTradeCell.ProductId,
- payment = ceErpTradeCell.payment,
- isUrgent = ceErpTradeCell.IsUrgency,
- customerMemo = ceErpTradeCell.CustomerMemo,
- shopName = ceErpShop.ShopName,
- buyerNick = ceErpTrade.buyer_nick != "" ? ceErpTrade.buyer_nick : "lingtao",
- receiverName = ceErpTrade.receiver_name,
- receiverMobile = ceErpTrade.receiver_mobile,
- receiverState = ceErpTrade.receiver_state,
- receiverCity = ceErpTrade.receiver_city,
- receiverDistrict = ceErpTrade.receiver_district,
- receiverAddress = ceErpTrade.receiver_address,
- tids = ceErpTradeCell.ctid,
- isOldUser = isOldCustomerText,
- sellerMemo = ceErpTradeCell.seller_memo,
- isChange = isGai,
- isBack = isReturn,
- tid = ceErpTradeCell.tid
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- //;***************************************************
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- HttpItem item = new HttpItem()
- {
- URL = post_url,
- Method = "POST",
- 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 = "")
- {
- string post_url = pUrl + "modify";
- //json参数
- List<string> postLst = new List<string>();
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- CeErpShop ceErpShop = null;
- if (ceErpTradeCell != null)
- {
- ceErpShop = CeErpShop.Get(ceErpTradeCell.ShopId);
- }
- var res_obj = new
- {
- outId = tid,
- orderText = seller_memo,
- isChange = isGai,
- isBack = isReturn,
- returnReason = returnReason,
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- //***************************************************
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- HttpItem item = new HttpItem()
- {
- URL = post_url,
- Method = "POST",
- Postdata = ro_json
- };
- item.PostEncoding = Encoding.UTF8;
- HttpResult hResult = tb_http.GetHtml(item);
- return hResult.Html;
- }
- }
- }
|