sync.initorder.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. namespace SiteCore.Handler
  6. {
  7. public partial class sync
  8. {
  9. //订单-原始订单 接口---------------------------------------------
  10. public void get_erp_initorderlist()
  11. {
  12. DataStruct dStruct = GetPostStruct();
  13. List<string> lw = new List<string>();
  14. string tid = GetPostString("tid");
  15. string date1 = GetPostString("date1");
  16. string date2 = GetPostString("date2");
  17. string buyernick = GetPostString("buyer_nick");
  18. if (tid.Length > 0)
  19. {
  20. lw.Add(string.Format("tid = '{0}'", tid));
  21. }
  22. if (date1.Length > 0)
  23. {
  24. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  25. if (dw.Length > 0) lw.Add(dw);
  26. }
  27. if (buyernick.Length > 0)
  28. {
  29. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  30. }
  31. string deliverydate1 = GetPostString("deliverydate1");
  32. string deliverydate2 = GetPostString("deliverydate2");
  33. if (tid.Length == 0 && date1.Length == 0 && buyernick.Length == 0 && deliverydate1.Length == 0)
  34. {
  35. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  36. }
  37. if (deliverydate1.Length > 0)
  38. {
  39. string dw = GetDateMinuteWhere("delivery_time", deliverydate1, deliverydate2);
  40. if (dw.Length > 0) lw.Add(dw);
  41. }
  42. string shopname = GetPostString("shopname");
  43. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  44. string address = GetPostString("address");
  45. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  46. string sellermemo = GetPostString("seller_memo");
  47. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  48. string price1 = GetPostString("price1");
  49. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  50. string price2 = GetPostString("price2");
  51. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  52. dStruct.Order = "pay_time desc";
  53. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  54. DataTable dt = WebCache.GetData("ce_erptrade", dStruct);
  55. writeGridDataTableJson(dStruct.TotalCount, dt);
  56. }
  57. //订单管理-备注 接口---------------------------------------------
  58. public void save_erp_initsellermemo()
  59. {
  60. if (UrlPostParmsCheck("seller_memo"))
  61. {
  62. string tid = GetPostString("tid");
  63. CeErpTrade entity = null;
  64. if (tid != "") entity = CeErpTrade.Get(tid);
  65. if (entity != null)
  66. {
  67. entity.seller_memo = GetPostString("seller_memo");
  68. entity.Update();
  69. returnSuccessMsg("保存成功!");
  70. return;
  71. }
  72. returnErrorMsg("找不到记录");
  73. }
  74. }
  75. //手动拆分原订单到订单列表 ,备注只有一个的就一个,2个的就拆分
  76. public void set_erp_splitorder()
  77. {
  78. if (UrlPostParmsCheck("tid"))
  79. {
  80. string tid = GetPostString("tid");
  81. CeErpTrade entity = null;
  82. if (tid != "") entity = CeErpTrade.Get(tid);
  83. if (entity != null)
  84. {
  85. LogHelper.addLog(entity.tid, CurrentUser.UserID, "点击强制生成", 0);
  86. tmcHelper.createCellOrder(entity, entity.tid, entity.seller_memo, entity.buyer_nick, true);//最后加上true跳过阻止直接拆分创建cell子单
  87. returnSuccessMsg("保存成功!");
  88. return;
  89. }
  90. returnErrorMsg("找不到记录");
  91. }
  92. }
  93. //订单-老系统数据---------------------------------------------
  94. public void get_erp_olddatalist()
  95. {
  96. DataStruct dStruct = GetPostStruct();
  97. List<string> lw = new List<string>();
  98. string tid = GetPostString("tid");
  99. string date1 = GetPostString("date1");
  100. string date2 = GetPostString("date2");
  101. if (tid.Length > 0 || date1.Length > 0)
  102. {
  103. lw.Add(string.Format("order_no like '%{0}%'", tid));
  104. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  105. if (dw.Length > 0) lw.Add(dw);
  106. }
  107. //else
  108. //{
  109. // lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  110. //}
  111. string shopname = GetPostString("shopname");
  112. if (shopname.Length > 0) lw.Add(string.Format("company_name like '%{0}%'", shopname));
  113. string buyernick = GetPostString("buyer_nick");
  114. if (buyernick.Length > 0) lw.Add(string.Format("customer_name like '%{0}%'", buyernick));
  115. string sellermemo = GetPostString("seller_memo");
  116. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  117. string price1 = GetPostString("price1");
  118. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  119. string price2 = GetPostString("price2");
  120. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  121. dStruct.Order = "pay_time desc";
  122. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  123. DataTable dt = WebCache.GetData("Sheet2$", dStruct);
  124. writeGridDataTableJson(dStruct.TotalCount, dt);
  125. }
  126. //订单-手提袋列表接口---------------------------------------------
  127. public void get_erp_bagorderlist()
  128. {
  129. DataStruct dStruct = GetPostStruct();
  130. List<string> lw = new List<string>();
  131. string tid = GetPostString("tid");
  132. string date1 = GetPostString("date1");
  133. string date2 = GetPostString("date2");
  134. if (tid.Length > 0 || date1.Length > 0)
  135. {
  136. lw.Add(string.Format("tid like '%{0}%'", tid));
  137. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  138. if (dw.Length > 0) lw.Add(dw);
  139. }
  140. else
  141. {
  142. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  143. }
  144. string shopname = GetPostString("shopname");
  145. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  146. string buyernick = GetPostString("buyer_nick");
  147. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  148. string address = GetPostString("address");
  149. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  150. string sellermemo = GetPostString("seller_memo");
  151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  152. string price1 = GetPostString("price1");
  153. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  154. string price2 = GetPostString("price2");
  155. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  156. lw.Add(string.Format("isBagOrder=1"));
  157. dStruct.Order = "pay_time desc";
  158. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  159. DataTable dt = WebCache.GetData("view_erptradeorder", dStruct);
  160. writeGridDataTableJson(dStruct.TotalCount, dt);
  161. }
  162. //订单-商品列表接口---------------------------------------------
  163. public void get_erp_goodslist()
  164. {
  165. DataStruct dStruct = GetPostStruct();
  166. List<string> lw = new List<string>();
  167. string tid = GetPostString("tid");
  168. string date1 = GetPostString("date1");
  169. string date2 = GetPostString("date2");
  170. string end_time1 = GetPostString("end_time1");
  171. string end_time2 = GetPostString("end_time2");
  172. if (tid.Length > 0)
  173. {
  174. lw.Add(string.Format("tid = '{0}'", tid));
  175. }
  176. if (tid.Length == 0 && date1.Length == 0 && end_time1.Length == 0)
  177. {
  178. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  179. }
  180. if (date1.Length > 0)
  181. {
  182. lw.Add(string.Format("pay_time > '{0}'", date1));
  183. }
  184. if (date2.Length > 0)
  185. {
  186. lw.Add(string.Format("pay_time < '{0}'", date2));
  187. }
  188. if (end_time1.Length > 0)
  189. {
  190. lw.Add(string.Format("end_time > '{0}'", end_time1));
  191. }
  192. if (end_time2.Length > 0)
  193. {
  194. lw.Add(string.Format("end_time < '{0}'", end_time2));
  195. }
  196. string shopname = GetPostString("shopname");
  197. if (shopname.Length > 0) lw.Add(string.Format("seller_nick like '%{0}%'", shopname));
  198. string buyernick = GetPostString("buyer_nick");
  199. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  200. string address = GetPostString("address");
  201. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  202. //string sellermemo = GetPostString("seller_memo");
  203. //if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  204. string price1 = GetPostString("price1");
  205. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  206. string price2 = GetPostString("price2");
  207. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  208. string goodsId = GetPostString("goodsId");
  209. bool tradeOrder = false;
  210. if (goodsId.Length > 0)
  211. {
  212. lw.Add(string.Format("spu_id like '%{0}%'", goodsId));
  213. tradeOrder = true;
  214. }
  215. //lw.Add(string.Format("isBagOrder=1"));
  216. dStruct.Order = "pay_time desc";
  217. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  218. string tableName = "view_ErpTradeOrder_trade";
  219. if (tradeOrder)
  220. {
  221. tableName = "view_ErpTradeOrder";
  222. }
  223. DataTable dt = WebCache.GetData(tableName, dStruct);
  224. writeGridDataTableJson(dStruct.TotalCount, dt);
  225. }
  226. //修改地址
  227. public void ins_erp_modifyaddress()
  228. {
  229. if (UrlPostParmsCheck("tid"))
  230. {
  231. string eid = GetPostString("tid");
  232. CeErpTrade entity = null;
  233. if (eid != "") entity = CeErpTrade.Get(eid);
  234. if (entity != null)
  235. {
  236. entity.receiver_name = GetPostString("receiver_name");
  237. entity.receiver_mobile = GetPostString("receiver_mobile");
  238. entity.receiver_state = GetPostString("receiver_state");
  239. entity.receiver_city = GetPostString("receiver_city");
  240. entity.receiver_district = GetPostString("receiver_district");
  241. entity.receiver_address = GetPostString("receiver_address");
  242. if (entity.receiver_state == "" || entity.receiver_city == "" || entity.receiver_name == "" || entity.receiver_mobile == "" || entity.receiver_address == "")
  243. {
  244. returnErrorMsg("不能为空");
  245. return;
  246. }
  247. entity.Update();
  248. returnSuccessMsg("修改成功!");
  249. return;
  250. }
  251. returnErrorMsg("找不到记录");
  252. }
  253. }
  254. //管理员强制修改数据接口
  255. public void save_admin_info()
  256. {
  257. string optype = GetPostString("optype");
  258. if (optype == "1")
  259. {
  260. string orderstate = GetPostString("orderstate");
  261. string eid = GetPostString("ctid");
  262. CeErpTradeCell entity = null;
  263. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  264. if (entity != null)
  265. {
  266. entity.OrderState = Convert.ToInt32(orderstate);
  267. entity.Update();
  268. returnSuccessMsg("操作成功!");
  269. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改状态为:" + orderstate, entity.OrderState, 0);
  270. return;
  271. }
  272. returnErrorMsg("找不到订单记录");
  273. }
  274. else if (optype == "2")
  275. {
  276. string isdianzi = GetPostString("isdianzi");
  277. string eid = GetPostString("ctid");
  278. CeErpTradeCell entity = null;
  279. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  280. if (entity != null)
  281. {
  282. entity.isDianziOrder = Convert.ToInt32(isdianzi);
  283. entity.Update();
  284. returnSuccessMsg("操作成功!");
  285. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改是否电子稿:" + isdianzi, entity.OrderState, 0);
  286. return;
  287. }
  288. returnErrorMsg("找不到订单记录");
  289. }
  290. else if (optype == "3")
  291. {
  292. string issample = GetPostString("issample");
  293. string eid = GetPostString("ctid");
  294. CeErpTradeCell entity = null;
  295. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  296. if (entity != null)
  297. {
  298. entity.IsSample = Convert.ToInt32(issample);
  299. entity.Update();
  300. returnSuccessMsg("操作成功!");
  301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改是否补差价:" + issample, entity.OrderState, 0);
  302. return;
  303. }
  304. returnErrorMsg("找不到订单记录");
  305. }
  306. else if (optype == "4")
  307. {
  308. string eid = GetPostString("ctid");
  309. CeErpTradeCell entity = null;
  310. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  311. if (entity != null)
  312. {
  313. string outsid = entity.OutSid;
  314. string[] outList = outsid.Split(',');
  315. if (outList.Length > 0)
  316. {
  317. if (outList[outList.Length - 1] != "")
  318. {
  319. entity.OutSid = outList[outList.Length - 1];
  320. }
  321. }
  322. entity.Update();
  323. returnSuccessMsg("操作成功!");
  324. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改快递单号记录outsid:" + entity.OutSid, entity.OrderState, 0);
  325. return;
  326. }
  327. returnErrorMsg("找不到订单记录");
  328. }
  329. else if (optype == "5")
  330. {
  331. string eid = GetPostString("ctid");
  332. string productId = GetPostString("productId");
  333. CeErpTradeCell entity = null;
  334. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  335. if (entity != null)
  336. {
  337. entity.ProductId = Convert.ToInt32(productId);
  338. entity.Update();
  339. returnSuccessMsg("操作成功!");
  340. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "强制修改商品ProductId:" + entity.ProductId, entity.OrderState, 0);
  341. return;
  342. }
  343. returnErrorMsg("找不到订单记录");
  344. }
  345. }
  346. }
  347. }