frmSynchronousData.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. using LYFZ.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.MicroApplet
  10. {
  11. public class frmSynchronousData:LYFZ.Software.MicroApplet.frmSynchronousData
  12. {
  13. public frmSynchronousData()
  14. {
  15. this.UcNavigationTool.LabTitle = "微信小程序同步数据";
  16. this.Shown += FrmSynchronousData_Shown;
  17. this.Load += FrmSynchronousData_Load;
  18. this.btnRefresh.Click += BtnRefresh_Click;
  19. this.btnSearch.Click += BtnSearch_Click;
  20. this.cmbStatus.SelectedIndexChanged += CmbStatus_SelectedIndexChanged;
  21. this.cbPutongDingDan.Click += CheckBoxEx_Click;
  22. this.cbPingTuandingdan.Click += CheckBoxEx_Click;
  23. this.cbMiaoShaDingDan.Click += CheckBoxEx_Click;
  24. this.btnUploadUerInfo.Click += BtnUploadUserInfo_Click;
  25. this.btnUploadTaoXi.Click += BtnUploadTaoXi_Click;
  26. this.dgvOrderViwe.CellContentClick += DgvOrderViwe_CellContentClick;
  27. this.comAccountList.SelectedIndexChanged += ComAccountList_SelectedIndexChanged;
  28. this.btnBatchSyncOrders.Click += BtnBatchSyncOrders_Click;
  29. this.chbWeiWanChengTongBuDingDan.Click += ChbWeiWanChengTongBuDingDan_Click;
  30. this.chbYiWanChengTongBuDingDan.Click += ChbYiWanChengTongBuDingDan_Click;
  31. }
  32. bool isChbYiWanChengTongBuDingDan = true;
  33. bool isChbWeiWanChengTongBuDingDan = true;
  34. /// <summary>
  35. /// 已完成同步订单
  36. /// </summary>
  37. /// <param name="sender"></param>
  38. /// <param name="e"></param>
  39. private void ChbYiWanChengTongBuDingDan_Click(object sender, EventArgs e)
  40. {
  41. this.isChbYiWanChengTongBuDingDan = this.chbYiWanChengTongBuDingDan.Checked;
  42. TempRefresh();
  43. BindOrderList();
  44. }
  45. /// <summary>
  46. /// 未完成同步订单
  47. /// </summary>
  48. /// <param name="sender"></param>
  49. /// <param name="e"></param>
  50. private void ChbWeiWanChengTongBuDingDan_Click(object sender, EventArgs e)
  51. {
  52. this.isChbWeiWanChengTongBuDingDan = this.chbWeiWanChengTongBuDingDan.Checked;
  53. TempRefresh();
  54. BindOrderList();
  55. }
  56. private void BtnBatchSyncOrders_Click(object sender, EventArgs e)
  57. {
  58. int rowIndex = 1;
  59. if (this.dgvOrderViwe.SelectedRows != null && this.dgvOrderViwe.SelectedRows.Count > 0)
  60. {
  61. foreach (DataGridViewRow row in this.dgvOrderViwe.SelectedRows)
  62. {
  63. DataGridViewCellEventArgs cellE = new DataGridViewCellEventArgs(13, row.Index);
  64. if (DgvOrderViwe_CellContentClick(null, cellE, rowIndex))
  65. {
  66. rowIndex++;
  67. }
  68. else {
  69. break;
  70. }
  71. }
  72. }
  73. else {
  74. MessageBoxCustom.Show("请选择要批量同步的订单");
  75. }
  76. }
  77. /// <summary>
  78. /// 是否初始化完成
  79. /// </summary>
  80. bool isInitialization = false;
  81. private void ComAccountList_SelectedIndexChanged(object sender, EventArgs e)
  82. {
  83. if (isInitialization)
  84. {
  85. if (this.comAccountList.SelectedItem != null)
  86. {
  87. frmMicroAppletAdmin.MicroAppToken = "";
  88. BLL.MicroApplet.MicroAppletAccount mAccount = (BLL.MicroApplet.MicroAppletAccount)((ItemValue)this.comAccountList.SelectedItem).Value;
  89. frmMicroAppletAdmin.CurrentMicroAppletShopID = mAccount.ShopID;
  90. LoadOrderList();
  91. }
  92. }
  93. }
  94. /// <summary>
  95. /// 获取订单
  96. /// </summary>
  97. static string getOrderData = String.Format("{0}/api.php/IvisionBackstage/getOrderData", frmMicroAppletAdmin.microAppInterfaceDomainName);
  98. /// <summary>
  99. /// 上传员工部门
  100. /// </summary>
  101. static string importUserGroup = String.Format("{0}/api.php/IvisionBackstage/importUserGroup", frmMicroAppletAdmin.microAppInterfaceDomainName);
  102. /// <summary>
  103. /// 上传员工信息
  104. /// </summary>
  105. static string importUserdata = String.Format("{0}/api.php/IvisionBackstage/importUserdata", frmMicroAppletAdmin.microAppInterfaceDomainName);
  106. /// <summary>
  107. /// 获取套系分类数据
  108. /// </summary>
  109. public static string categotyData = String.Format("{0}/api.php/IvisionBackstage/categoty", frmMicroAppletAdmin.microAppInterfaceDomainName);
  110. /// <summary>
  111. /// 上传套系数据
  112. /// </summary>
  113. public static string addSeriesData = String.Format("{0}/api.php/IvisionBackstage/addSeries", frmMicroAppletAdmin.microAppInterfaceDomainName);
  114. /// <summary>
  115. /// 上传图片
  116. /// </summary>
  117. public static string uploadImg= String.Format("{0}/api.php/MeiBackstage/uploadImg", frmMicroAppletAdmin.microAppInterfaceDomainName);
  118. /// <summary>
  119. /// 订单补齐余款
  120. /// </summary>
  121. static string orderReplenishment = String.Format("{0}/api.php/IvisionBackstage/orderReplenishment", frmMicroAppletAdmin.microAppInterfaceDomainName);
  122. /// <summary>
  123. /// 标记订单扩展数据
  124. /// </summary>
  125. static string orderSignData = String.Format("{0}/api.php/IvisionBackstage/orderSign", frmMicroAppletAdmin.microAppInterfaceDomainName);
  126. private void BtnUploadTaoXi_Click(object sender, EventArgs e)
  127. {
  128. frmPackagesUpload packUpload = new frmPackagesUpload();
  129. packUpload.AppLoginModel = appLoginModel;
  130. packUpload.Show();
  131. }
  132. private void BtnUploadUserInfo_Click(object sender, EventArgs e)
  133. {
  134. MicroAppReturn returnData = new MicroAppReturn();
  135. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  136. {
  137. try
  138. {
  139. backgroundWorker.ReportProgress(0, "正在上传员工信息...");
  140. returnData = UploadUserDepartment(appLoginModel);
  141. if (returnData.Code == 200)
  142. {
  143. returnData = UploadUserInfo(appLoginModel);
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. MessageBoxCustom.Show(String.Format("上传员工信息时错误:{0}", ex.Message));
  149. }
  150. });
  151. if (returnData.Code == 200)
  152. {
  153. MessageBoxCustom.Show(String.Format("员工信息已上传成功"));
  154. }
  155. else {
  156. MessageBoxCustom.Show(String.Format("上传员工信息时失败:{0}", returnData.Message));
  157. }
  158. }
  159. LYFZ.BLL.BLL_ErpDepartment department = new BLL.BLL_ErpDepartment();
  160. MicroAppReturn UploadUserDepartment(MicroAppLoginReturn appLogin)
  161. {
  162. List<LYFZ.Model.Model_ErpDepartment> departmentList= department.GetModelList("1=1");
  163. List<object> dempList = new List<object>();
  164. foreach (LYFZ.Model.Model_ErpDepartment demp in departmentList)
  165. {
  166. dempList.Add(new {
  167. user_group_id =demp.ID,
  168. group_name=demp.Dt_Name
  169. });
  170. }
  171. dynamic group_data = new {
  172. group_data=dempList.ToArray()
  173. };
  174. string postData = Newtonsoft.Json.JsonConvert.SerializeObject(group_data);
  175. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(importUserGroup, postData, appLogin, Encoding.UTF8);
  176. MicroAppReturn data = new MicroAppReturn();
  177. if (PostReturnString.IndexOf("{") == 0)
  178. {
  179. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  180. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  181. {
  182. data.Code = 200;
  183. data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  184. }
  185. else
  186. {
  187. data.Message = postReturnObj["meta"]["message"];
  188. }
  189. }
  190. else
  191. {
  192. data.Message = PostReturnString;
  193. }
  194. return data;
  195. }
  196. MicroAppReturn UploadUserInfo(MicroAppLoginReturn appLogin)
  197. {
  198. List<object> userList = new List<object>();
  199. foreach (DataRow row in LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows)
  200. {
  201. userList.Add(new
  202. {
  203. account_number= row["User_EmployeeID"],
  204. password = row["User_Password"],
  205. user_name= row["User_Name"],
  206. user_group_id= row["User_Department"]
  207. });
  208. }
  209. dynamic User_data = new
  210. {
  211. user_data = userList.ToArray()
  212. };
  213. string postData = Newtonsoft.Json.JsonConvert.SerializeObject(User_data);
  214. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(importUserdata, postData, appLogin, Encoding.UTF8);
  215. MicroAppReturn data = new MicroAppReturn();
  216. if (PostReturnString.IndexOf("{") == 0)
  217. {
  218. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  219. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  220. {
  221. data.Code = 200;
  222. data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  223. }
  224. else
  225. {
  226. data.Message = postReturnObj["meta"]["message"];
  227. }
  228. }
  229. else
  230. {
  231. data.Message = PostReturnString;
  232. }
  233. return data;
  234. }
  235. List<int> order_typeList = new List<int>(new Int32[] { 1,2,3});
  236. int order_state = -100;
  237. string keyWords = "";
  238. private void CheckBoxEx_Click(object sender, EventArgs e)
  239. {
  240. order_typeList.Clear();
  241. if (this.cbPutongDingDan.Checked)
  242. {
  243. order_typeList.Add(1);
  244. }
  245. if (this.cbPingTuandingdan.Checked)
  246. {
  247. order_typeList.Add(2);
  248. }
  249. if (this.cbMiaoShaDingDan.Checked)
  250. {
  251. order_typeList.Add(3);
  252. }
  253. TempRefresh();
  254. BindOrderList();
  255. }
  256. private void CmbStatus_SelectedIndexChanged(object sender, EventArgs e)
  257. {
  258. ItemValue item =(ItemValue) this.cmbStatus.SelectedItem;
  259. order_state =Convert.ToInt32(item.Value);
  260. TempRefresh();
  261. BindOrderList();
  262. }
  263. //是否需要刷新
  264. bool isRefresh = false;
  265. void TempRefresh()
  266. {
  267. if (isRefresh)
  268. {
  269. isRefresh = false;
  270. LoadOrderList();
  271. }
  272. }
  273. private void BtnSearch_Click(object sender, EventArgs e)
  274. {
  275. keyWords = this.txtKeyWords.Text.Trim();
  276. TempRefresh();
  277. BindOrderList();
  278. }
  279. private void BtnRefresh_Click(object sender, EventArgs e)
  280. {
  281. LoadOrderList();
  282. }
  283. private void FrmSynchronousData_Load(object sender, EventArgs e)
  284. {
  285. this.comAccountList.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletAccountSwicth);
  286. this.btnUploadUerInfo.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletUploadUser);
  287. this.btnUploadTaoXi.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletUploadTaoXi);
  288. BindOrderStatus();
  289. }
  290. void BindOrderStatus()
  291. {
  292. // -4后台取消 - 3取消订单 - 2退款 - 1待付款 1已付款 2服务中 3已付定金 4已付定金待成团 100已完成
  293. this.cmbStatus.Items.Clear();
  294. this.cmbStatus.Items.AddRange(new ItemValue[]{
  295. new ItemValue(-100,"全部订单"),
  296. new ItemValue(-1,"待付款"),
  297. new ItemValue(3,"已付定金"),
  298. new ItemValue(4,"已付定金待成团"),
  299. new ItemValue(1,"已付款"),
  300. new ItemValue(2,"服务中"),
  301. new ItemValue(-4,"后台取消"),
  302. new ItemValue(-3,"取消订单"),
  303. new ItemValue(-2,"退款"),
  304. new ItemValue(100,"已完成"),
  305. });
  306. this.cmbStatus.SelectedIndex = 0;
  307. }
  308. MicroAppLoginReturn appLoginModel = new MicroAppLoginReturn();
  309. //订单数据
  310. MicroAppReturn OrderData = new MicroAppReturn();
  311. private void FrmSynchronousData_Shown(object sender, EventArgs e)
  312. {
  313. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  314. {
  315. try
  316. {
  317. backgroundWorker.ReportProgress(0, "正在加载帐号信息...");
  318. if (frmMicroAppletAdmin.LoadMicroConfigure())
  319. {
  320. if (String.IsNullOrEmpty(frmMicroAppletAdmin.CurrentMicroAppletShopID))
  321. {
  322. frmMicroAppletAdmin.CurrentMicroAppletShopID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID;
  323. }
  324. if (frmMicroAppletAdmin._MicroAppletAccountList.Count > 0)
  325. {
  326. frmMicroAppletAdmin.BindMicroAppletAccountList(this.comAccountList, frmMicroAppletAdmin.CurrentMicroAppletShopID);
  327. }
  328. }
  329. }
  330. catch (Exception ex)
  331. {
  332. MessageBoxCustom.Show(String.Format("获取帐号信息时错误:{0}", ex.Message), backgroundWorker: backgroundWorker);
  333. }
  334. });
  335. LoadOrderList();
  336. }
  337. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  338. LYFZ.BLL.BLL_ErpPayment paymentBll = new BLL.BLL_ErpPayment();
  339. private void DgvOrderViwe_CellContentClick(object sender, DataGridViewCellEventArgs e)
  340. {
  341. this.DgvOrderViwe_CellContentClick(sender,e,0);
  342. }
  343. private bool DgvOrderViwe_CellContentClick(object sender, DataGridViewCellEventArgs e,int rowIndex)
  344. {
  345. if (e.RowIndex >= 0 && e.ColumnIndex == 13)
  346. {
  347. dynamic model = this.dgvOrderViwe.Rows[e.RowIndex].Tag;
  348. string recommend_id = LYFZ.BLL.BLL_ErpUser.Admin_20141125111443713;
  349. try
  350. {
  351. recommend_id = model["recommend_id"];
  352. }
  353. catch { }
  354. dynamic Order_Extra_data = model["extra_data"];
  355. //model["third_party_data"]
  356. dynamic third_party_data = model["third_party_data"];//Newtonsoft.Json.JsonConvert.DeserializeObject("{\"TaoXiBianMa\":\"TX20150508143954846\",\"TaoXiMingCheng\":\"超值宝贝688\",\"TaoXiJiaGe\":688.00,\"TaoXiLeiYongData\":{\"Stages\":[{\"ID\":\"1\",\"TaoXiNameSource\":\"\",\"PgmID\":\"104\",\"Tsc_Rating\":\"BEBBBCADAFBHBCHCI\",\"Sc_ClassName\":\"三级\",\"Tcs_Category\":\"0\",\"Tcs_CategoryText\":\"内景\",\"Tsc_CostPrice\":\"0.00\",\"Tsc_SalesPrice\":\"0.00\",\"Tsc_Remark\":\"个萨顶顶魔法师的高分低能噶问题的任何法无定法我很懦弱佟大为\",\"Pgm_ProductName\":\"第一次\",\"Pgm_GiveType\":\"3\",\"Pgm_IntoRegisterQuantity\":\"100\",\"Pgm_IntoBottomQuantity\":\"200\",\"Pgm_Quantity\":\"1\",\"StagesReservationPhotographyTime\":\"\"},{\"ID\":\"2\",\"TaoXiNameSource\":\"\",\"PgmID\":\"105\",\"Tsc_Rating\":\"BEBBBCADDEBFJDFFC\",\"Sc_ClassName\":\"一级\",\"Tcs_Category\":\"0\",\"Tcs_CategoryText\":\"内景\",\"Tsc_CostPrice\":\"0.00\",\"Tsc_SalesPrice\":\"0.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"第二次\",\"Pgm_GiveType\":\"3\",\"Pgm_IntoRegisterQuantity\":\"110\",\"Pgm_IntoBottomQuantity\":\"210\",\"Pgm_Quantity\":\"1\",\"StagesReservationPhotographyTime\":\"\"},{\"ID\":\"3\",\"TaoXiNameSource\":\"\",\"PgmID\":\"106\",\"Tsc_Rating\":\"BEBBBCADDEBFJDFFC\",\"Sc_ClassName\":\"一级\",\"Tcs_Category\":\"0\",\"Tcs_CategoryText\":\"内景\",\"Tsc_CostPrice\":\"0.00\",\"Tsc_SalesPrice\":\"0.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"第三次\",\"Pgm_GiveType\":\"3\",\"Pgm_IntoRegisterQuantity\":\"120\",\"Pgm_IntoBottomQuantity\":\"220\",\"Pgm_Quantity\":\"1\",\"StagesReservationPhotographyTime\":\"\"},{\"ID\":\"4\",\"TaoXiNameSource\":\"\",\"PgmID\":\"107\",\"Tsc_Rating\":\"BEBBBCADDEBFJDFFC\",\"Sc_ClassName\":\"一级\",\"Tcs_Category\":\"0\",\"Tcs_CategoryText\":\"内景\",\"Tsc_CostPrice\":\"0.00\",\"Tsc_SalesPrice\":\"0.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"第四次\",\"Pgm_GiveType\":\"3\",\"Pgm_IntoRegisterQuantity\":\"130\",\"Pgm_IntoBottomQuantity\":\"230\",\"Pgm_Quantity\":\"1\",\"StagesReservationPhotographyTime\":\"\"}],\"Sights\":[{\"ID\":\"10\",\"TaoXiNameSource\":\"\",\"PgmID\":\"65\",\"Tsc_Rating\":\"BEBBBCADEGBGAFFJC\",\"Sc_ClassName\":\"二级\",\"Tcs_Category\":\"1\",\"Tcs_CategoryText\":\"外景\",\"Tsc_CostPrice\":\"100.00\",\"Tsc_SalesPrice\":\"600.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"大亚湾\",\"Pgm_GiveType\":\"2\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_Quantity\":\"1\"},{\"ID\":\"7\",\"TaoXiNameSource\":\"\",\"PgmID\":\"72\",\"Tsc_Rating\":\"BEBBBCADDEBFJDFFC\",\"Sc_ClassName\":\"一级\",\"Tcs_Category\":\"1\",\"Tcs_CategoryText\":\"外景\",\"Tsc_CostPrice\":\"50.00\",\"Tsc_SalesPrice\":\"200.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"红花湖\",\"Pgm_GiveType\":\"2\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_Quantity\":\"1\"},{\"ID\":\"6\",\"TaoXiNameSource\":\"\",\"PgmID\":\"73\",\"Tsc_Rating\":\"BEBBBCADDEBFJDFFC\",\"Sc_ClassName\":\"一级\",\"Tcs_Category\":\"1\",\"Tcs_CategoryText\":\"外景\",\"Tsc_CostPrice\":\"500.00\",\"Tsc_SalesPrice\":\"500.00\",\"Tsc_Remark\":\"\",\"Pgm_ProductName\":\"西湖\",\"Pgm_GiveType\":\"2\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_Quantity\":\"2\"}],\"Service\":[{\"Prod_Number\":\"SP00379\",\"TaoXiNameSource\":\"\",\"PgmID\":\"79\",\"Pgm_ProductNumber\":\"SP00379\",\"Prod_Name\":\"男孩理发\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"30.00\",\"Prod_Class\":\"BFAFBCBACBFDAJDIB\",\"Prod_Unit\":\"次\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00379\",\"Pgm_ProductName\":\"男孩理发\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"1\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"1\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00381\",\"TaoXiNameSource\":\"\",\"PgmID\":\"32\",\"Pgm_ProductNumber\":\"SP00381\",\"Prod_Name\":\"拍摄服装2套\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"0.00\",\"Prod_Class\":\"BFAFBCBACBFDAJDIB\",\"Prod_Unit\":\"套\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00381\",\"Pgm_ProductName\":\"拍摄服装2套\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"1\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"1\",\"Pgm_ProductGroupName\":\"第一次\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"}],\"Product\":[{\"Prod_Number\":\"SP001\",\"TaoXiNameSource\":\"\",\"PgmID\":\"8\",\"Pgm_ProductNumber\":\"SP001\",\"Prod_Name\":\"6x6寸 白玉册\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"1.00\",\"Prod_SalesPrice\":\"3.00\",\"Prod_Class\":\"BFAFAHBADHDHICGBD\",\"Prod_Unit\":\"本\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP001\",\"Pgm_ProductName\":\"6x6寸 白玉册\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"第二次\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00353\",\"TaoXiNameSource\":\"\",\"PgmID\":\"6\",\"Pgm_ProductNumber\":\"SP00353\",\"Prod_Name\":\"BABY框\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"280.00\",\"Prod_Class\":\"BFAFBABIBIBAAEGFF\",\"Prod_Unit\":\"幅\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00353\",\"Pgm_ProductName\":\"BABY框\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"第一次\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00366\",\"TaoXiNameSource\":\"\",\"PgmID\":\"7\",\"Pgm_ProductNumber\":\"SP00366\",\"Prod_Name\":\"木马熊摆台\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"98.00\",\"Prod_Class\":\"BFAFBABICCEEJBIGJ\",\"Prod_Unit\":\"幅\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00366\",\"Pgm_ProductName\":\"木马熊摆台\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP0037\",\"TaoXiNameSource\":\"\",\"PgmID\":\"70\",\"Pgm_ProductNumber\":\"SP0037\",\"Prod_Name\":\"15x15寸 贝拉杂志册\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"0.00\",\"Prod_Class\":\"BFAFAHBAEBABHBIA\",\"Prod_Unit\":\"本\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP0037\",\"Pgm_ProductName\":\"15x15寸 贝拉杂志册\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"第三次\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP0037\",\"TaoXiNameSource\":\"\",\"PgmID\":\"71\",\"Pgm_ProductNumber\":\"SP0037\",\"Prod_Name\":\"15x15寸 贝拉杂志册\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"0.00\",\"Prod_Class\":\"BFAFAHBAEBABHBIA\",\"Prod_Unit\":\"本\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP0037\",\"Pgm_ProductName\":\"15x15寸 贝拉杂志册\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"第四次\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00387\",\"TaoXiNameSource\":\"\",\"PgmID\":\"55\",\"Pgm_ProductNumber\":\"SP00387\",\"Prod_Name\":\"钱包照\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"0.00\",\"Prod_Class\":\"BFAFBABIBIBAAEGFF\",\"Prod_Unit\":\"幅\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00387\",\"Pgm_ProductName\":\"钱包照\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00412\",\"TaoXiNameSource\":\"\",\"PgmID\":\"126\",\"Pgm_ProductNumber\":\"SP00412\",\"Prod_Name\":\"赠品摆台\",\"Prod_Batch\":\"1\",\"Prod_CostPrice\":\"0.00\",\"Prod_SalesPrice\":\"0.00\",\"Prod_Class\":\"BFAFBABICDCAGECIB\",\"Prod_Unit\":\"幅\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00412\",\"Pgm_ProductName\":\"赠品摆台\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00431\",\"TaoXiNameSource\":\"\",\"PgmID\":\"188\",\"Pgm_ProductNumber\":\"SP00431\",\"Prod_Name\":\"dds\",\"Prod_Batch\":\"0\",\"Prod_CostPrice\":\"22.00\",\"Prod_SalesPrice\":\"1230.00\",\"Prod_Class\":\"BFAFAHBADIDBDIBGB\",\"Prod_Unit\":\"副\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00431\",\"Pgm_ProductName\":\"dds\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00431\",\"TaoXiNameSource\":\"\",\"PgmID\":\"189\",\"Pgm_ProductNumber\":\"SP00431\",\"Prod_Name\":\"dds\",\"Prod_Batch\":\"0\",\"Prod_CostPrice\":\"22.00\",\"Prod_SalesPrice\":\"1230.00\",\"Prod_Class\":\"BFAFAHBADIDBDIBGB\",\"Prod_Unit\":\"副\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00431\",\"Pgm_ProductName\":\"dds\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"},{\"Prod_Number\":\"SP00431\",\"TaoXiNameSource\":\"\",\"PgmID\":\"190\",\"Pgm_ProductNumber\":\"SP00431\",\"Prod_Name\":\"dds\",\"Prod_Batch\":\"0\",\"Prod_CostPrice\":\"22.00\",\"Prod_SalesPrice\":\"1230.00\",\"Prod_Class\":\"BFAFAHBADIDBDIBGB\",\"Prod_Unit\":\"副\",\"Prod_Thumbnail\":\"\",\"Pgm_ProductNumber1\":\"SP00431\",\"Pgm_ProductName\":\"dds\",\"Pgm_IntoRegisterQuantity\":\"0\",\"Pgm_IntoBottomQuantity\":\"0\",\"Pgm_GiveType\":\"0\",\"Pgm_Quantity\":\"1\",\"Pgm_GiveType1\":\"0\",\"Pgm_ProductGroupName\":\"\",\"OPlist_IsExpedited\":\"\",\"OPlist_ExpeditedTime\":\"\",\"OPlist_OpenOrderRemark\":\"\"}]}}");
  357. if (third_party_data == null)
  358. {
  359. MessageBoxCustom.Show("此订单套系订单参数不正确,不能同步该订单");
  360. return false;
  361. }
  362. string TaoXiLieYongData = Newtonsoft.Json.JsonConvert.SerializeObject(third_party_data["TaoXiLeiYongData"]);
  363. LYFZ.Model.ModelFastOpenOrder openOrder = new Model.ModelFastOpenOrder();
  364. openOrder.OrderType = model["series_type"] == 1 ? 0 : model["series_type"] == 2 ? 1 : 2;
  365. openOrder.OrderClass = "微信小程序";
  366. openOrder.OrderClientSource = "微信小程序";
  367. openOrder.OrderPersonCode = String.Format("{0}|0", recommend_id);//LYFZ.BLL.BLL_ErpUser.Admin_20141125111443713
  368. openOrder.OrderPersonName = DAL.DAL_ErpUser.GetUserIDToUserName(recommend_id); //"管理员";//LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  369. openOrder.OrderTaoXiCode = third_party_data["TaoXiBianMa"];
  370. openOrder.OrderTaoXiName = third_party_data["TaoXiMingCheng"];
  371. try
  372. {
  373. openOrder.OrderTaoXiPrice = model["total"];//third_party_data["TaoXiJiaGe"];
  374. }
  375. catch (Exception ex)
  376. {
  377. MessageBoxCustom.Show("订单价格不正确:" + ex.Message);
  378. }
  379. if (model["series_type"] == 2)
  380. {
  381. if (model["baby_data"] != null && model["baby_data"].Count >= 1)
  382. {
  383. string birthday = "";
  384. try
  385. {
  386. if (model["baby_data"][0]["birthday"] != null)
  387. {
  388. if (!String.IsNullOrEmpty(model["baby_data"][0]["birthday"].ToString()))
  389. {
  390. birthday = model["baby_data"][0]["birthday"].ToString().Contains("0000") ? "" : model["baby_data"][0]["birthday"];
  391. }
  392. }
  393. }
  394. catch { }
  395. openOrder.CusList.Add(new LYFZ.Model.ModelCustomer()
  396. {
  397. CusSex = model["baby_data"][0]["gender"] == 1 ? false : true,
  398. CustomerName = model["baby_data"][0]["childname"] == "" ? "宝宝" : model["baby_data"][0]["childname"],
  399. CustomerBirthday = birthday,
  400. CusType = "儿童"
  401. });
  402. }
  403. else
  404. {
  405. openOrder.CusList.Add(new LYFZ.Model.ModelCustomer()
  406. {
  407. CusSex = true,
  408. CustomerName = "宝宝",
  409. CustomerBirthday = "",
  410. CusType = "儿童"
  411. });
  412. }
  413. }
  414. LYFZ.Model.ModelCustomer customer = new LYFZ.Model.ModelCustomer()
  415. {
  416. CusId = 0,
  417. CusSex = model["customer_gender"] == 1 ? false : true,
  418. CustomerName = model["customer_name"],
  419. CustomerTele = model["customer_mobile"],
  420. CusType = "成人"
  421. };
  422. //CusSex true 为男 false 女
  423. openOrder.CusList.Add(customer);
  424. /* openOrder.CusList.Add(new LYFZ.Model.ModelCustomer()
  425. {
  426. CusSex = false,
  427. CustomerName = "王爸爸",
  428. CustomerTele = "13556247022",
  429. CusType = "成人"
  430. });*/
  431. string xiaoChengXuOrder_id = model["order_id"];
  432. if (String.IsNullOrEmpty(xiaoChengXuOrder_id))
  433. {
  434. MessageBoxCustom.Show("获取的小程序订单号为空,不能同步该订单");
  435. return false;
  436. }
  437. LYFZ.Command.Result result = null;
  438. MicroAppReturn retData = new MicroAppReturn();
  439. string sysTempOrderNumber = "";
  440. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  441. {
  442. try
  443. {
  444. if (rowIndex > 0)
  445. {
  446. backgroundWorker.ReportProgress(0, "正在同步第 " + rowIndex.ToString() + " 订单...");
  447. }
  448. else
  449. {
  450. backgroundWorker.ReportProgress(0, "正在同步订单数据...");
  451. }
  452. LYFZ.Model.Model_ErpOrder orderModel = orbll.GetModel("Ord_MicroAppletOrderID", xiaoChengXuOrder_id);
  453. if (orderModel.ID <= 0)
  454. {
  455. bool tempIsCustomOrderNumber = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber;
  456. LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber = false;
  457. try
  458. {
  459. result = orbll.SaveFastOpenOrderData(openOrder, TaoXiLieYongData, xiaoChengXuOrder_id, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel, frmMicroAppletAdmin.CurrentMicroAppletShopID);
  460. }
  461. catch
  462. {
  463. }
  464. finally
  465. {
  466. LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber = tempIsCustomOrderNumber;
  467. }
  468. if (!result.Status)
  469. {
  470. if (result.StatusCode == -99)
  471. {
  472. if (MessageBoxCustom.Show(String.Format("系统检查到客户名:{0} 手机号为:{1} 的客户已经存在,是否直接使用已存在的客户同步此订单?", customer.CustomerName, customer.CustomerTele), msgBoxButton: MessageBoxButtons.YesNo) == DialogResult.Yes)
  473. {
  474. ///存在相同电话号码的客户列表
  475. DataTable resultData = ((LYFZ.Command.Result<DataTable>)result).Data;
  476. customer.CusId = Convert.ToInt32(resultData.Rows[0]["id"].ToString());
  477. result = orbll.SaveFastOpenOrderData(openOrder, TaoXiLieYongData, xiaoChengXuOrder_id, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel, frmMicroAppletAdmin.CurrentMicroAppletShopID);
  478. }
  479. else
  480. {
  481. return;
  482. }
  483. }
  484. else
  485. {
  486. MessageBoxCustom.Show(String.Format("同步订单验证客户数据时失败:{0}", result.StatusMsg));
  487. return;
  488. }
  489. }
  490. if (result.Status)
  491. {
  492. sysTempOrderNumber = ((LYFZ.Command.Result<string>)result).Data;
  493. retData = SynchronizePrepayment(sysTempOrderNumber, Order_Extra_data, model);
  494. isRefresh = true;
  495. }
  496. else
  497. {
  498. MessageBoxCustom.Show(String.Format("同步订单失败:{0}", result.StatusMsg));
  499. return;
  500. }
  501. }
  502. else
  503. {
  504. sysTempOrderNumber = orderModel.Ord_Number;
  505. retData = SynchronizePrepayment(sysTempOrderNumber, Order_Extra_data, model);
  506. }
  507. if (retData.Code == 200)
  508. {
  509. if (rowIndex <= 0)
  510. {
  511. MessageBoxCustom.Show("订单同步成功", backgroundWorker: backgroundWorker);
  512. }
  513. }
  514. else
  515. {
  516. MessageBoxCustom.Show("订单同步失败" + retData.Message, backgroundWorker: backgroundWorker);
  517. }
  518. }
  519. catch (Exception ex)
  520. {
  521. MessageBoxCustom.Show(String.Format("同步订单时错误:{0}", ex.Message), backgroundWorker: backgroundWorker);
  522. }
  523. });
  524. if (retData.Code == 200)
  525. {
  526. this.dgvOrderViwe.Rows[e.RowIndex].Cells[11].Value = sysTempOrderNumber;
  527. this.dgvOrderViwe.Rows[e.RowIndex].Cells[12].Value = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  528. return true;
  529. }
  530. else {
  531. return false;
  532. }
  533. }
  534. else {
  535. return false;
  536. }
  537. }
  538. /// <summary>
  539. /// 同订单收款
  540. /// </summary>
  541. /// <param name="sysOrderNumber"></param>
  542. /// <param name="received"></param>
  543. /// <param name="CreateDatetime"></param>
  544. /// <returns></returns>
  545. MicroAppReturn SynchronizePrepayment(string sysOrderNumber,dynamic Order_Extra_data, dynamic orderModel)
  546. {
  547. MicroAppReturn retData = new MicroAppReturn();
  548. string xiaoChengXuOrder_id = orderModel["order_id"];
  549. if (String.IsNullOrEmpty(xiaoChengXuOrder_id))
  550. {
  551. retData.Message = "获取的小程序订单号为空,不能同步该订单";
  552. MessageBoxCustom.Show(retData.Message);
  553. return retData;
  554. }
  555. //是否完成同步
  556. bool SynchronizationStatus = false;
  557. //系统订单号
  558. string sysTempOrderNumber = sysOrderNumber;
  559. //是否同步了订金
  560. bool isTongBuDingJing = false;
  561. if (Order_Extra_data != null)
  562. {
  563. if (Order_Extra_data["isTongBuDingJing"] == 1)
  564. {
  565. isTongBuDingJing = true;
  566. }
  567. if (Order_Extra_data["SynchronizationStatus"] == 1)
  568. {
  569. SynchronizationStatus = true;
  570. }
  571. }
  572. //小程序已收金额
  573. decimal received = orderModel["received"];
  574. //小程序总金额
  575. decimal total = orderModel["total"];
  576. //小程序收款时间
  577. string received_time = orderModel["create_time"];
  578. //小程序补款时间
  579. string balanc_time = orderModel["balanc_time"];
  580. Model.OrderEarlyPeriodReceipt orderPerReceipt = LYFZ.BLL.BLL_ErpOrder.GetOrderEarlyPeriodReceipt(sysOrderNumber);
  581. //小程序未同步的收款金额
  582. decimal unavailedAmount = received - orderPerReceipt.Sum_AmountOf;
  583. //本次收款时间
  584. string current_received_time = received_time;
  585. if (!String.IsNullOrEmpty(balanc_time))
  586. {
  587. current_received_time = received_time;
  588. }
  589. //如果没有同步定金,开始同步订金
  590. LYFZ.Command.Result result = new Command.Result();
  591. if (unavailedAmount>0)
  592. {
  593. result = paymentBll.SaveFastOrderPaymentData(
  594. new LYFZ.Model.ModelPaymentData()
  595. {
  596. AmountOf = unavailedAmount,
  597. CreateDatetime = current_received_time,
  598. OrdNumber = sysTempOrderNumber
  599. },
  600. LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel
  601. );
  602. isTongBuDingJing = result.Status;
  603. }
  604. if (total- received<=0)
  605. {
  606. SynchronizationStatus = true;
  607. }
  608. retData = SetOrderSignData(appLoginModel, xiaoChengXuOrder_id, sysTempOrderNumber, isTongBuDingJing, SynchronizationStatus, Order_Extra_data);
  609. return retData;
  610. }
  611. /// <summary>
  612. /// 同步后设置小程序订单扩展信息
  613. /// </summary>
  614. /// <param name="appLogin"></param>
  615. /// <returns></returns>
  616. MicroAppReturn SetOrderSignData(MicroAppLoginReturn appLogin,string orderid,string sysTempOrderNumber,bool isTongBuDingJing,bool isSynchronizationStatus, dynamic extra_data)
  617. {
  618. if (extra_data == null)
  619. {
  620. extra_data = new
  621. {
  622. orderNumber = sysTempOrderNumber,
  623. isTongBuDingJing = isTongBuDingJing ? 1 : 0,
  624. isTongBuQuanKuan = 0,
  625. SynchronizationStatus = isSynchronizationStatus ? 1 : 0,
  626. TongBuDateTime = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  627. };
  628. }
  629. else {
  630. extra_data["orderNumber"] = sysTempOrderNumber;
  631. extra_data["isTongBuDingJing"] = isTongBuDingJing ? 1 : 0;
  632. extra_data["isTongBuQuanKuan"] = 0;
  633. extra_data["SynchronizationStatus"] = isSynchronizationStatus ? 1 : 0;
  634. extra_data["TongBuDateTime"] = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  635. }
  636. List<object> orderList = new List<object>();
  637. orderList.Add(new {
  638. order_id= orderid,
  639. extra_data= extra_data
  640. });
  641. dynamic signData = new {
  642. order_list= orderList.ToArray()
  643. };
  644. string postData = Newtonsoft.Json.JsonConvert.SerializeObject(signData);
  645. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(orderSignData, postData, appLogin, Encoding.UTF8);
  646. MicroAppReturn data = new MicroAppReturn();
  647. if (PostReturnString.IndexOf("{") == 0)
  648. {
  649. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  650. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  651. {
  652. data.Code = 200;
  653. data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  654. }
  655. else
  656. {
  657. data.Message = postReturnObj["meta"]["message"];
  658. }
  659. }
  660. else
  661. {
  662. data.Message = PostReturnString;
  663. }
  664. return data;
  665. }
  666. /// <summary>
  667. /// 绑定订单
  668. /// </summary>
  669. void BindOrderList()
  670. {
  671. this.dgvOrderViwe.Rows.Clear();
  672. if (OrderData.Code == 200)
  673. {
  674. dynamic orderDataList = Newtonsoft.Json.JsonConvert.DeserializeObject(OrderData.Data);
  675. foreach (dynamic model in orderDataList)
  676. {
  677. try
  678. {
  679. if (model["series_type"] == null)
  680. {
  681. MessageBoxCustom.Show(String.Format("订单号为 “{0}”的订单缺少套系类型[series_type]的值为null", model["order_id"]));
  682. continue;
  683. }
  684. string customer_name = model["series_type"] == 2 ? String.Format("{0}{1}", model["customer_name"], GetCustomer_Name(model["baby_data"])) : String.Format("{0}", model["customer_name"]);
  685. string customer_mobile = model["customer_mobile"];
  686. dynamic extra_data = model["extra_data"];
  687. dynamic third_party_data = model["third_party_data"];
  688. if (third_party_data == null)
  689. {
  690. continue;
  691. }
  692. string extra_data_ToString = "";
  693. //是否完成同步
  694. bool SynchronizationStatus = false;
  695. if (extra_data != null)
  696. {
  697. extra_data_ToString = extra_data["orderNumber"];
  698. if (extra_data["SynchronizationStatus"] == 1)
  699. {
  700. SynchronizationStatus = true;
  701. }
  702. }
  703. // isChbYiWanChengTongBuDingDan ; 是否显示已完成同步的订单
  704. // isChbWeiWanChengTongBuDingDan ;是否显示未完成同步的订单
  705. if (!isChbYiWanChengTongBuDingDan)
  706. {
  707. if (SynchronizationStatus)
  708. {
  709. continue;
  710. }
  711. }
  712. if (!isChbWeiWanChengTongBuDingDan)
  713. {
  714. if (!SynchronizationStatus)
  715. {
  716. continue;
  717. }
  718. }
  719. if (!String.IsNullOrEmpty(this.keyWords.Trim()))
  720. {
  721. if (!customer_name.Contains(this.keyWords.Trim()) && !customer_mobile.Contains(this.keyWords.Trim()) && !extra_data_ToString.Contains(this.keyWords.Trim()))
  722. {
  723. continue;
  724. }
  725. }
  726. if (order_state > -100)
  727. {
  728. if (model["order_state"] != order_state)
  729. {
  730. continue;
  731. }
  732. }
  733. if (!this.order_typeList.Contains(Convert.ToInt32(model["order_type"])))
  734. {
  735. continue;
  736. }
  737. string TongBuDateTime = "";
  738. string TongBuDanHao = "";
  739. if (extra_data != null)
  740. {
  741. TongBuDanHao = extra_data["orderNumber"];
  742. TongBuDateTime = extra_data["TongBuDateTime"];
  743. }
  744. DataGridViewRow row = new DataGridViewRow();
  745. row.CreateCells(this.dgvOrderViwe);
  746. row.Cells[0].Value = model["order_id"];
  747. row.Cells[1].Value = customer_name;
  748. row.Cells[2].Value = model["customer_gender"] == 1 ? "男" : model["customer_gender"] == 2 ? "女" : "未知";
  749. row.Cells[3].Value = customer_mobile;
  750. row.Cells[4].Value = model["attach"];
  751. row.Cells[5].Value = model["received"];
  752. row.Cells[6].Value = model["total"];
  753. row.Cells[7].Value = (model["series_type"] == 1 ? "婚纱套系" : model["series_type"] == 2 ? "儿童套系" : "写真套系");
  754. row.Cells[8].Value = model["order_state_name"];
  755. row.Cells[9].Value = model["create_time"];
  756. row.Cells[10].Value = SynchronizationStatus?"已完成同步":"未完成同步";
  757. row.Cells[11].Value = TongBuDanHao;
  758. row.Cells[12].Value = TongBuDateTime;
  759. row.Cells[13].Value = "同步订单";
  760. row.Tag = model;
  761. this.dgvOrderViwe.Rows.Add(row);
  762. }
  763. catch//(Exception ex)
  764. {
  765. MessageBoxCustom.Show(String.Format("小程序订单数据不正确:{0}", model.ToString()));
  766. }
  767. }
  768. }
  769. }
  770. /// <summary>
  771. /// 获取儿童名字
  772. /// </summary>
  773. /// <param name="data"></param>
  774. /// <returns></returns>
  775. string GetCustomer_Name(dynamic data)
  776. {
  777. StringBuilder cusName = new StringBuilder();
  778. foreach (dynamic model in data)
  779. {
  780. cusName.Append(String.Format("/{0}",model[@"childname"]));
  781. }
  782. return cusName.ToString();
  783. }
  784. void LoadOrderList()
  785. {
  786. this.isInitialization = true;
  787. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  788. {
  789. try
  790. {
  791. backgroundWorker.ReportProgress(0, "正在获取订单...");
  792. BLL.MicroApplet.MicroAppletAccount mAccount = frmMicroAppletAdmin.GetMicroAppletAccount(frmMicroAppletAdmin.CurrentMicroAppletShopID);
  793. if (String.IsNullOrEmpty(mAccount.Account) || String.IsNullOrEmpty(mAccount.Password))
  794. {
  795. MessageBoxCustom.Show("您还没有开通“利亚方舟影楼版微信小程序”", backgroundWorker: backgroundWorker);
  796. return;
  797. }
  798. appLoginModel = frmMicroAppletAdmin.CompanyLoginReturnToken(mAccount.Account, mAccount.Password);
  799. if (appLoginModel.Code == 200)
  800. {
  801. OrderData = GetOrderDataList(appLoginModel);
  802. }
  803. else
  804. {
  805. MessageBoxCustom.Show(String.Format("获取订单失败:{0}", appLoginModel.Message), backgroundWorker: backgroundWorker);
  806. }
  807. }
  808. catch (Exception ex)
  809. {
  810. MessageBoxCustom.Show(String.Format("获取订单时错误:{0}", ex.Message), backgroundWorker: backgroundWorker);
  811. }
  812. });
  813. BindOrderList();
  814. }
  815. /// <summary>
  816. /// 获取订单信息
  817. /// </summary>
  818. /// <param name="appLogin"></param>
  819. /// <returns></returns>
  820. MicroAppReturn GetOrderDataList(MicroAppLoginReturn appLogin)
  821. {
  822. string postData = "order_type=0";
  823. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(getOrderData, postData, appLogin, Encoding.UTF8);
  824. MicroAppReturn data = new MicroAppReturn();
  825. if (PostReturnString.IndexOf("{") == 0)
  826. {
  827. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  828. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  829. {
  830. data.Code = 200;
  831. data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  832. }
  833. else {
  834. data.Message = postReturnObj["meta"]["message"];
  835. }
  836. }
  837. else {
  838. data.Message = PostReturnString;
  839. }
  840. return data;
  841. }
  842. }
  843. }