using LYFZ.Model; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.MicroApplet { public class frmSynchronousData:LYFZ.Software.MicroApplet.frmSynchronousData { public frmSynchronousData() { this.UcNavigationTool.LabTitle = "微信小程序同步数据"; this.Shown += FrmSynchronousData_Shown; this.Load += FrmSynchronousData_Load; this.btnRefresh.Click += BtnRefresh_Click; this.btnSearch.Click += BtnSearch_Click; this.cmbStatus.SelectedIndexChanged += CmbStatus_SelectedIndexChanged; this.cbPutongDingDan.Click += CheckBoxEx_Click; this.cbPingTuandingdan.Click += CheckBoxEx_Click; this.cbMiaoShaDingDan.Click += CheckBoxEx_Click; this.btnUploadUerInfo.Click += BtnUploadUserInfo_Click; this.btnUploadTaoXi.Click += BtnUploadTaoXi_Click; this.dgvOrderViwe.CellContentClick += DgvOrderViwe_CellContentClick; this.comAccountList.SelectedIndexChanged += ComAccountList_SelectedIndexChanged; this.btnBatchSyncOrders.Click += BtnBatchSyncOrders_Click; this.chbWeiWanChengTongBuDingDan.Click += ChbWeiWanChengTongBuDingDan_Click; this.chbYiWanChengTongBuDingDan.Click += ChbYiWanChengTongBuDingDan_Click; } bool isChbYiWanChengTongBuDingDan = true; bool isChbWeiWanChengTongBuDingDan = true; /// /// 已完成同步订单 /// /// /// private void ChbYiWanChengTongBuDingDan_Click(object sender, EventArgs e) { this.isChbYiWanChengTongBuDingDan = this.chbYiWanChengTongBuDingDan.Checked; TempRefresh(); BindOrderList(); } /// /// 未完成同步订单 /// /// /// private void ChbWeiWanChengTongBuDingDan_Click(object sender, EventArgs e) { this.isChbWeiWanChengTongBuDingDan = this.chbWeiWanChengTongBuDingDan.Checked; TempRefresh(); BindOrderList(); } private void BtnBatchSyncOrders_Click(object sender, EventArgs e) { int rowIndex = 1; if (this.dgvOrderViwe.SelectedRows != null && this.dgvOrderViwe.SelectedRows.Count > 0) { foreach (DataGridViewRow row in this.dgvOrderViwe.SelectedRows) { DataGridViewCellEventArgs cellE = new DataGridViewCellEventArgs(13, row.Index); if (DgvOrderViwe_CellContentClick(null, cellE, rowIndex)) { rowIndex++; } else { break; } } } else { MessageBoxCustom.Show("请选择要批量同步的订单"); } } /// /// 是否初始化完成 /// bool isInitialization = false; private void ComAccountList_SelectedIndexChanged(object sender, EventArgs e) { if (isInitialization) { if (this.comAccountList.SelectedItem != null) { frmMicroAppletAdmin.MicroAppToken = ""; BLL.MicroApplet.MicroAppletAccount mAccount = (BLL.MicroApplet.MicroAppletAccount)((ItemValue)this.comAccountList.SelectedItem).Value; frmMicroAppletAdmin.CurrentMicroAppletShopID = mAccount.ShopID; LoadOrderList(); } } } /// /// 获取订单 /// static string getOrderData = String.Format("{0}/api.php/IvisionBackstage/getOrderData", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 上传员工部门 /// static string importUserGroup = String.Format("{0}/api.php/IvisionBackstage/importUserGroup", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 上传员工信息 /// static string importUserdata = String.Format("{0}/api.php/IvisionBackstage/importUserdata", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 获取套系分类数据 /// public static string categotyData = String.Format("{0}/api.php/IvisionBackstage/categoty", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 上传套系数据 /// public static string addSeriesData = String.Format("{0}/api.php/IvisionBackstage/addSeries", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 上传图片 /// public static string uploadImg= String.Format("{0}/api.php/MeiBackstage/uploadImg", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 订单补齐余款 /// static string orderReplenishment = String.Format("{0}/api.php/IvisionBackstage/orderReplenishment", frmMicroAppletAdmin.microAppInterfaceDomainName); /// /// 标记订单扩展数据 /// static string orderSignData = String.Format("{0}/api.php/IvisionBackstage/orderSign", frmMicroAppletAdmin.microAppInterfaceDomainName); private void BtnUploadTaoXi_Click(object sender, EventArgs e) { frmPackagesUpload packUpload = new frmPackagesUpload(); packUpload.AppLoginModel = appLoginModel; packUpload.Show(); } private void BtnUploadUserInfo_Click(object sender, EventArgs e) { MicroAppReturn returnData = new MicroAppReturn(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在上传员工信息..."); returnData = UploadUserDepartment(appLoginModel); if (returnData.Code == 200) { returnData = UploadUserInfo(appLoginModel); } } catch (Exception ex) { MessageBoxCustom.Show(String.Format("上传员工信息时错误:{0}", ex.Message)); } }); if (returnData.Code == 200) { MessageBoxCustom.Show(String.Format("员工信息已上传成功")); } else { MessageBoxCustom.Show(String.Format("上传员工信息时失败:{0}", returnData.Message)); } } LYFZ.BLL.BLL_ErpDepartment department = new BLL.BLL_ErpDepartment(); MicroAppReturn UploadUserDepartment(MicroAppLoginReturn appLogin) { List departmentList= department.GetModelList("1=1"); List dempList = new List(); foreach (LYFZ.Model.Model_ErpDepartment demp in departmentList) { dempList.Add(new { user_group_id =demp.ID, group_name=demp.Dt_Name }); } dynamic group_data = new { group_data=dempList.ToArray() }; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(group_data); string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(importUserGroup, postData, appLogin, Encoding.UTF8); MicroAppReturn data = new MicroAppReturn(); if (PostReturnString.IndexOf("{") == 0) { dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString); if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200) { data.Code = 200; data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]); } else { data.Message = postReturnObj["meta"]["message"]; } } else { data.Message = PostReturnString; } return data; } MicroAppReturn UploadUserInfo(MicroAppLoginReturn appLogin) { List userList = new List(); foreach (DataRow row in LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows) { userList.Add(new { account_number= row["User_EmployeeID"], password = row["User_Password"], user_name= row["User_Name"], user_group_id= row["User_Department"] }); } dynamic User_data = new { user_data = userList.ToArray() }; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(User_data); string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(importUserdata, postData, appLogin, Encoding.UTF8); MicroAppReturn data = new MicroAppReturn(); if (PostReturnString.IndexOf("{") == 0) { dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString); if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200) { data.Code = 200; data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]); } else { data.Message = postReturnObj["meta"]["message"]; } } else { data.Message = PostReturnString; } return data; } List order_typeList = new List(new Int32[] { 1,2,3}); int order_state = -100; string keyWords = ""; private void CheckBoxEx_Click(object sender, EventArgs e) { order_typeList.Clear(); if (this.cbPutongDingDan.Checked) { order_typeList.Add(1); } if (this.cbPingTuandingdan.Checked) { order_typeList.Add(2); } if (this.cbMiaoShaDingDan.Checked) { order_typeList.Add(3); } TempRefresh(); BindOrderList(); } private void CmbStatus_SelectedIndexChanged(object sender, EventArgs e) { ItemValue item =(ItemValue) this.cmbStatus.SelectedItem; order_state =Convert.ToInt32(item.Value); TempRefresh(); BindOrderList(); } //是否需要刷新 bool isRefresh = false; void TempRefresh() { if (isRefresh) { isRefresh = false; LoadOrderList(); } } private void BtnSearch_Click(object sender, EventArgs e) { keyWords = this.txtKeyWords.Text.Trim(); TempRefresh(); BindOrderList(); } private void BtnRefresh_Click(object sender, EventArgs e) { LoadOrderList(); } private void FrmSynchronousData_Load(object sender, EventArgs e) { this.comAccountList.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletAccountSwicth); this.btnUploadUerInfo.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletUploadUser); this.btnUploadTaoXi.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MicroAppletManage, CustomAttributes.OperatingAuthority.MicroAppletUploadTaoXi); BindOrderStatus(); } void BindOrderStatus() { // -4后台取消 - 3取消订单 - 2退款 - 1待付款 1已付款 2服务中 3已付定金 4已付定金待成团 100已完成 this.cmbStatus.Items.Clear(); this.cmbStatus.Items.AddRange(new ItemValue[]{ new ItemValue(-100,"全部订单"), new ItemValue(-1,"待付款"), new ItemValue(3,"已付定金"), new ItemValue(4,"已付定金待成团"), new ItemValue(1,"已付款"), new ItemValue(2,"服务中"), new ItemValue(-4,"后台取消"), new ItemValue(-3,"取消订单"), new ItemValue(-2,"退款"), new ItemValue(100,"已完成"), }); this.cmbStatus.SelectedIndex = 0; } MicroAppLoginReturn appLoginModel = new MicroAppLoginReturn(); //订单数据 MicroAppReturn OrderData = new MicroAppReturn(); private void FrmSynchronousData_Shown(object sender, EventArgs e) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在加载帐号信息..."); if (frmMicroAppletAdmin.LoadMicroConfigure()) { if (String.IsNullOrEmpty(frmMicroAppletAdmin.CurrentMicroAppletShopID)) { frmMicroAppletAdmin.CurrentMicroAppletShopID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID; } if (frmMicroAppletAdmin._MicroAppletAccountList.Count > 0) { frmMicroAppletAdmin.BindMicroAppletAccountList(this.comAccountList, frmMicroAppletAdmin.CurrentMicroAppletShopID); } } } catch (Exception ex) { MessageBoxCustom.Show(String.Format("获取帐号信息时错误:{0}", ex.Message), backgroundWorker: backgroundWorker); } }); LoadOrderList(); } LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpPayment paymentBll = new BLL.BLL_ErpPayment(); private void DgvOrderViwe_CellContentClick(object sender, DataGridViewCellEventArgs e) { this.DgvOrderViwe_CellContentClick(sender,e,0); } private bool DgvOrderViwe_CellContentClick(object sender, DataGridViewCellEventArgs e,int rowIndex) { if (e.RowIndex >= 0 && e.ColumnIndex == 13) { dynamic model = this.dgvOrderViwe.Rows[e.RowIndex].Tag; string recommend_id = LYFZ.BLL.BLL_ErpUser.Admin_20141125111443713; try { recommend_id = model["recommend_id"]; } catch { } dynamic Order_Extra_data = model["extra_data"]; //model["third_party_data"] 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\":\"\"}]}}"); if (third_party_data == null) { MessageBoxCustom.Show("此订单套系订单参数不正确,不能同步该订单"); return false; } string TaoXiLieYongData = Newtonsoft.Json.JsonConvert.SerializeObject(third_party_data["TaoXiLeiYongData"]); LYFZ.Model.ModelFastOpenOrder openOrder = new Model.ModelFastOpenOrder(); openOrder.OrderType = model["series_type"] == 1 ? 0 : model["series_type"] == 2 ? 1 : 2; openOrder.OrderClass = "微信小程序"; openOrder.OrderClientSource = "微信小程序"; openOrder.OrderPersonCode = String.Format("{0}|0", recommend_id);//LYFZ.BLL.BLL_ErpUser.Admin_20141125111443713 openOrder.OrderPersonName = DAL.DAL_ErpUser.GetUserIDToUserName(recommend_id); //"管理员";//LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; openOrder.OrderTaoXiCode = third_party_data["TaoXiBianMa"]; openOrder.OrderTaoXiName = third_party_data["TaoXiMingCheng"]; try { openOrder.OrderTaoXiPrice = model["total"];//third_party_data["TaoXiJiaGe"]; } catch (Exception ex) { MessageBoxCustom.Show("订单价格不正确:" + ex.Message); } if (model["series_type"] == 2) { if (model["baby_data"] != null && model["baby_data"].Count >= 1) { string birthday = ""; try { if (model["baby_data"][0]["birthday"] != null) { if (!String.IsNullOrEmpty(model["baby_data"][0]["birthday"].ToString())) { birthday = model["baby_data"][0]["birthday"].ToString().Contains("0000") ? "" : model["baby_data"][0]["birthday"]; } } } catch { } openOrder.CusList.Add(new LYFZ.Model.ModelCustomer() { CusSex = model["baby_data"][0]["gender"] == 1 ? false : true, CustomerName = model["baby_data"][0]["childname"] == "" ? "宝宝" : model["baby_data"][0]["childname"], CustomerBirthday = birthday, CusType = "儿童" }); } else { openOrder.CusList.Add(new LYFZ.Model.ModelCustomer() { CusSex = true, CustomerName = "宝宝", CustomerBirthday = "", CusType = "儿童" }); } } LYFZ.Model.ModelCustomer customer = new LYFZ.Model.ModelCustomer() { CusId = 0, CusSex = model["customer_gender"] == 1 ? false : true, CustomerName = model["customer_name"], CustomerTele = model["customer_mobile"], CusType = "成人" }; //CusSex true 为男 false 女 openOrder.CusList.Add(customer); /* openOrder.CusList.Add(new LYFZ.Model.ModelCustomer() { CusSex = false, CustomerName = "王爸爸", CustomerTele = "13556247022", CusType = "成人" });*/ string xiaoChengXuOrder_id = model["order_id"]; if (String.IsNullOrEmpty(xiaoChengXuOrder_id)) { MessageBoxCustom.Show("获取的小程序订单号为空,不能同步该订单"); return false; } LYFZ.Command.Result result = null; MicroAppReturn retData = new MicroAppReturn(); string sysTempOrderNumber = ""; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { if (rowIndex > 0) { backgroundWorker.ReportProgress(0, "正在同步第 " + rowIndex.ToString() + " 订单..."); } else { backgroundWorker.ReportProgress(0, "正在同步订单数据..."); } LYFZ.Model.Model_ErpOrder orderModel = orbll.GetModel("Ord_MicroAppletOrderID", xiaoChengXuOrder_id); if (orderModel.ID <= 0) { bool tempIsCustomOrderNumber = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber; LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber = false; try { result = orbll.SaveFastOpenOrderData(openOrder, TaoXiLieYongData, xiaoChengXuOrder_id, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel, frmMicroAppletAdmin.CurrentMicroAppletShopID); } catch { } finally { LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber = tempIsCustomOrderNumber; } if (!result.Status) { if (result.StatusCode == -99) { if (MessageBoxCustom.Show(String.Format("系统检查到客户名:{0} 手机号为:{1} 的客户已经存在,是否直接使用已存在的客户同步此订单?", customer.CustomerName, customer.CustomerTele), msgBoxButton: MessageBoxButtons.YesNo) == DialogResult.Yes) { ///存在相同电话号码的客户列表 DataTable resultData = ((LYFZ.Command.Result)result).Data; customer.CusId = Convert.ToInt32(resultData.Rows[0]["id"].ToString()); result = orbll.SaveFastOpenOrderData(openOrder, TaoXiLieYongData, xiaoChengXuOrder_id, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel, frmMicroAppletAdmin.CurrentMicroAppletShopID); } else { return; } } else { MessageBoxCustom.Show(String.Format("同步订单验证客户数据时失败:{0}", result.StatusMsg)); return; } } if (result.Status) { sysTempOrderNumber = ((LYFZ.Command.Result)result).Data; retData = SynchronizePrepayment(sysTempOrderNumber, Order_Extra_data, model); isRefresh = true; } else { MessageBoxCustom.Show(String.Format("同步订单失败:{0}", result.StatusMsg)); return; } } else { sysTempOrderNumber = orderModel.Ord_Number; retData = SynchronizePrepayment(sysTempOrderNumber, Order_Extra_data, model); } if (retData.Code == 200) { if (rowIndex <= 0) { MessageBoxCustom.Show("订单同步成功", backgroundWorker: backgroundWorker); } } else { MessageBoxCustom.Show("订单同步失败" + retData.Message, backgroundWorker: backgroundWorker); } } catch (Exception ex) { MessageBoxCustom.Show(String.Format("同步订单时错误:{0}", ex.Message), backgroundWorker: backgroundWorker); } }); if (retData.Code == 200) { this.dgvOrderViwe.Rows[e.RowIndex].Cells[11].Value = sysTempOrderNumber; this.dgvOrderViwe.Rows[e.RowIndex].Cells[12].Value = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return true; } else { return false; } } else { return false; } } /// /// 同订单收款 /// /// /// /// /// MicroAppReturn SynchronizePrepayment(string sysOrderNumber,dynamic Order_Extra_data, dynamic orderModel) { MicroAppReturn retData = new MicroAppReturn(); string xiaoChengXuOrder_id = orderModel["order_id"]; if (String.IsNullOrEmpty(xiaoChengXuOrder_id)) { retData.Message = "获取的小程序订单号为空,不能同步该订单"; MessageBoxCustom.Show(retData.Message); return retData; } //是否完成同步 bool SynchronizationStatus = false; //系统订单号 string sysTempOrderNumber = sysOrderNumber; //是否同步了订金 bool isTongBuDingJing = false; if (Order_Extra_data != null) { if (Order_Extra_data["isTongBuDingJing"] == 1) { isTongBuDingJing = true; } if (Order_Extra_data["SynchronizationStatus"] == 1) { SynchronizationStatus = true; } } //小程序已收金额 decimal received = orderModel["received"]; //小程序总金额 decimal total = orderModel["total"]; //小程序收款时间 string received_time = orderModel["create_time"]; //小程序补款时间 string balanc_time = orderModel["balanc_time"]; Model.OrderEarlyPeriodReceipt orderPerReceipt = LYFZ.BLL.BLL_ErpOrder.GetOrderEarlyPeriodReceipt(sysOrderNumber); //小程序未同步的收款金额 decimal unavailedAmount = received - orderPerReceipt.Sum_AmountOf; //本次收款时间 string current_received_time = received_time; if (!String.IsNullOrEmpty(balanc_time)) { current_received_time = received_time; } //如果没有同步定金,开始同步订金 LYFZ.Command.Result result = new Command.Result(); if (unavailedAmount>0) { result = paymentBll.SaveFastOrderPaymentData( new LYFZ.Model.ModelPaymentData() { AmountOf = unavailedAmount, CreateDatetime = current_received_time, OrdNumber = sysTempOrderNumber }, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel ); isTongBuDingJing = result.Status; } if (total- received<=0) { SynchronizationStatus = true; } retData = SetOrderSignData(appLoginModel, xiaoChengXuOrder_id, sysTempOrderNumber, isTongBuDingJing, SynchronizationStatus, Order_Extra_data); return retData; } /// /// 同步后设置小程序订单扩展信息 /// /// /// MicroAppReturn SetOrderSignData(MicroAppLoginReturn appLogin,string orderid,string sysTempOrderNumber,bool isTongBuDingJing,bool isSynchronizationStatus, dynamic extra_data) { if (extra_data == null) { extra_data = new { orderNumber = sysTempOrderNumber, isTongBuDingJing = isTongBuDingJing ? 1 : 0, isTongBuQuanKuan = 0, SynchronizationStatus = isSynchronizationStatus ? 1 : 0, TongBuDateTime = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; } else { extra_data["orderNumber"] = sysTempOrderNumber; extra_data["isTongBuDingJing"] = isTongBuDingJing ? 1 : 0; extra_data["isTongBuQuanKuan"] = 0; extra_data["SynchronizationStatus"] = isSynchronizationStatus ? 1 : 0; extra_data["TongBuDateTime"] = SDateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } List orderList = new List(); orderList.Add(new { order_id= orderid, extra_data= extra_data }); dynamic signData = new { order_list= orderList.ToArray() }; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(signData); string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(orderSignData, postData, appLogin, Encoding.UTF8); MicroAppReturn data = new MicroAppReturn(); if (PostReturnString.IndexOf("{") == 0) { dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString); if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200) { data.Code = 200; data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]); } else { data.Message = postReturnObj["meta"]["message"]; } } else { data.Message = PostReturnString; } return data; } /// /// 绑定订单 /// void BindOrderList() { this.dgvOrderViwe.Rows.Clear(); if (OrderData.Code == 200) { dynamic orderDataList = Newtonsoft.Json.JsonConvert.DeserializeObject(OrderData.Data); foreach (dynamic model in orderDataList) { try { if (model["series_type"] == null) { MessageBoxCustom.Show(String.Format("订单号为 “{0}”的订单缺少套系类型[series_type]的值为null", model["order_id"])); continue; } 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"]); string customer_mobile = model["customer_mobile"]; dynamic extra_data = model["extra_data"]; dynamic third_party_data = model["third_party_data"]; if (third_party_data == null) { continue; } string extra_data_ToString = ""; //是否完成同步 bool SynchronizationStatus = false; if (extra_data != null) { extra_data_ToString = extra_data["orderNumber"]; if (extra_data["SynchronizationStatus"] == 1) { SynchronizationStatus = true; } } // isChbYiWanChengTongBuDingDan ; 是否显示已完成同步的订单 // isChbWeiWanChengTongBuDingDan ;是否显示未完成同步的订单 if (!isChbYiWanChengTongBuDingDan) { if (SynchronizationStatus) { continue; } } if (!isChbWeiWanChengTongBuDingDan) { if (!SynchronizationStatus) { continue; } } if (!String.IsNullOrEmpty(this.keyWords.Trim())) { if (!customer_name.Contains(this.keyWords.Trim()) && !customer_mobile.Contains(this.keyWords.Trim()) && !extra_data_ToString.Contains(this.keyWords.Trim())) { continue; } } if (order_state > -100) { if (model["order_state"] != order_state) { continue; } } if (!this.order_typeList.Contains(Convert.ToInt32(model["order_type"]))) { continue; } string TongBuDateTime = ""; string TongBuDanHao = ""; if (extra_data != null) { TongBuDanHao = extra_data["orderNumber"]; TongBuDateTime = extra_data["TongBuDateTime"]; } DataGridViewRow row = new DataGridViewRow(); row.CreateCells(this.dgvOrderViwe); row.Cells[0].Value = model["order_id"]; row.Cells[1].Value = customer_name; row.Cells[2].Value = model["customer_gender"] == 1 ? "男" : model["customer_gender"] == 2 ? "女" : "未知"; row.Cells[3].Value = customer_mobile; row.Cells[4].Value = model["attach"]; row.Cells[5].Value = model["received"]; row.Cells[6].Value = model["total"]; row.Cells[7].Value = (model["series_type"] == 1 ? "婚纱套系" : model["series_type"] == 2 ? "儿童套系" : "写真套系"); row.Cells[8].Value = model["order_state_name"]; row.Cells[9].Value = model["create_time"]; row.Cells[10].Value = SynchronizationStatus?"已完成同步":"未完成同步"; row.Cells[11].Value = TongBuDanHao; row.Cells[12].Value = TongBuDateTime; row.Cells[13].Value = "同步订单"; row.Tag = model; this.dgvOrderViwe.Rows.Add(row); } catch//(Exception ex) { MessageBoxCustom.Show(String.Format("小程序订单数据不正确:{0}", model.ToString())); } } } } /// /// 获取儿童名字 /// /// /// string GetCustomer_Name(dynamic data) { StringBuilder cusName = new StringBuilder(); foreach (dynamic model in data) { cusName.Append(String.Format("/{0}",model[@"childname"])); } return cusName.ToString(); } void LoadOrderList() { this.isInitialization = true; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在获取订单..."); BLL.MicroApplet.MicroAppletAccount mAccount = frmMicroAppletAdmin.GetMicroAppletAccount(frmMicroAppletAdmin.CurrentMicroAppletShopID); if (String.IsNullOrEmpty(mAccount.Account) || String.IsNullOrEmpty(mAccount.Password)) { MessageBoxCustom.Show("您还没有开通“利亚方舟影楼版微信小程序”", backgroundWorker: backgroundWorker); return; } appLoginModel = frmMicroAppletAdmin.CompanyLoginReturnToken(mAccount.Account, mAccount.Password); if (appLoginModel.Code == 200) { OrderData = GetOrderDataList(appLoginModel); } else { MessageBoxCustom.Show(String.Format("获取订单失败:{0}", appLoginModel.Message), backgroundWorker: backgroundWorker); } } catch (Exception ex) { MessageBoxCustom.Show(String.Format("获取订单时错误:{0}", ex.Message), backgroundWorker: backgroundWorker); } }); BindOrderList(); } /// /// 获取订单信息 /// /// /// MicroAppReturn GetOrderDataList(MicroAppLoginReturn appLogin) { string postData = "order_type=0"; string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(getOrderData, postData, appLogin, Encoding.UTF8); MicroAppReturn data = new MicroAppReturn(); if (PostReturnString.IndexOf("{") == 0) { dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString); if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200) { data.Code = 200; data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]); } else { data.Message = postReturnObj["meta"]["message"]; } } else { data.Message = PostReturnString; } return data; } } }