frmThridPayConfig.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. using LYFZ.BLL;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.OAShopManagement
  11. {
  12. public partial class frmThridPayConfig : LYFZ.Software.UI.OAShopManagement.frmThridPayConfig
  13. {
  14. LYFZ.BLL.BLL_ErpSystemConfigure config = new BLL.BLL_ErpSystemConfigure();
  15. BLL.BLL_ErpSystemCategory categoryBll = new BLL.BLL_ErpSystemCategory();
  16. LYFZ.Model.Model_ErpSystemConfigure wxModConfig;
  17. LYFZ.Model.Model_ErpSystemConfigure alModConfig;
  18. string wxMchid = "";
  19. string aliMchid = "";
  20. public static string EncryptKey = "Ivz0IC3k";
  21. public frmThridPayConfig()
  22. {
  23. InitializeComponent();
  24. this.Shown += frmThridPayConfig_Shown;
  25. BindWXData();
  26. BindAliData();
  27. CheckPay();
  28. if(LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  29. {
  30. rdo_WXAgentBtn.Visible = false;
  31. rdo_WXAutonomyBtn.Visible = false;
  32. rdo_ZFBAgentBtn.Visible = false;
  33. rdo_ZFBAutonomyBtn.Visible = false;
  34. }
  35. }
  36. void frmThridPayConfig_Shown(object sender, EventArgs e)
  37. {
  38. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  39. VersionControl.VersionFunctionEnum.App和微信公众号扫码支付);
  40. if (!b)
  41. {
  42. this.Close();
  43. }
  44. }
  45. /// <summary>
  46. ///
  47. /// </summary>
  48. void CheckPay()
  49. {
  50. if(LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  51. {
  52. cb_MySaltCompanyPay.Visible = true;
  53. txt_MchId.Visible = false;
  54. txt_AliAppid.Enabled = false;
  55. txt_AliMchId.Enabled = false;
  56. txt_AliKey.Enabled = false;
  57. txt_AliPublicKey.Enabled = false;
  58. string PayData = "";
  59. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  60. {
  61. PayData = LYFZ.WinAPI.HttpClientHelper.GetResponse("http://webapi.lyfz.net/mapi.aspx?cname=CompanyPay");
  62. //Newtonsoft.Json.Linq.JArray payList = new Newtonsoft.Json.Linq.JArray(PayData);
  63. object tempJObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PayData);
  64. Newtonsoft.Json.Linq.JArray payList = (Newtonsoft.Json.Linq.JArray)tempJObj;
  65. for(int i=0;i<payList.Count;i++)
  66. {
  67. string type =((Newtonsoft.Json.Linq.JObject) payList[i]).GetValue("Type").ToString();
  68. string name=((Newtonsoft.Json.Linq.JObject) payList[i]).GetValue("Name").ToString();
  69. string MchId = ((Newtonsoft.Json.Linq.JObject)payList[i]).GetValue("MchId").ToString();
  70. if(type.Equals("WeiXin"))
  71. {
  72. PayItemData payItemData = new PayItemData()
  73. {
  74. Type = type,
  75. Name = name,
  76. jObject = ((Newtonsoft.Json.Linq.JObject)payList[i])
  77. };
  78. cb_MySaltCompanyPay.Items.Add(payItemData);
  79. wxMchid = "";
  80. if (txt_MchId.Text == MchId)
  81. {
  82. cb_MySaltCompanyPay.SelectedIndex = cb_MySaltCompanyPay.Items.Count - 1;
  83. }
  84. }
  85. else
  86. {
  87. PayItemData payItemData = new PayItemData()
  88. {
  89. Type = type,
  90. Name = name,
  91. jObject = ((Newtonsoft.Json.Linq.JObject)payList[i])
  92. };
  93. cb_AliPayAccount.Items.Add(payItemData);
  94. aliMchid = "";
  95. if (txt_AliMchId.Text == MchId)
  96. {
  97. cb_AliPayAccount.SelectedIndex = cb_AliPayAccount.Items.Count - 1;
  98. }
  99. }
  100. }
  101. });
  102. if (cb_MySaltCompanyPay.Items.Count > 0 && cb_MySaltCompanyPay.SelectedIndex==-1)
  103. {
  104. //cb_MySaltCompanyPay.SelectedIndex = 0;
  105. txt_AppId.Text = "";
  106. txt_Key.Text = "";
  107. txt_MchId.Text = "";
  108. }
  109. if (cb_AliPayAccount.Items.Count > 0 && cb_AliPayAccount.SelectedIndex == -1)
  110. {
  111. //cb_AliPayAccount.SelectedIndex = 0;
  112. txt_AliAppid.Text = "";
  113. txt_AliMchId.Text = "";
  114. txt_AliKey.Text = "";
  115. txt_AliPublicKey.Text = "";
  116. }
  117. cb_AliPayAccount.SelectedIndexChanged += cb_AliPayAccount_SelectedIndexChanged;
  118. cb_MySaltCompanyPay.SelectedIndexChanged += cb_MySaltCompanyPay_SelectedIndexChanged;
  119. }
  120. else
  121. {
  122. cb_MySaltCompanyPay.Visible = false;
  123. txt_MchId.Visible = true;
  124. txt_AliAppid.Enabled = true;
  125. txt_AliMchId.Enabled = true;
  126. txt_AliKey.Enabled = true;
  127. txt_AliPublicKey.Enabled = true;
  128. }
  129. }
  130. void cb_MySaltCompanyPay_SelectedIndexChanged(object sender, EventArgs e)
  131. {
  132. if (((PayItemData)cb_MySaltCompanyPay.SelectedItem) != null)
  133. {
  134. txt_AppId.Text = ((PayItemData)cb_MySaltCompanyPay.SelectedItem).jObject.GetValue("AppId").ToString();
  135. txt_Key.Text = ((PayItemData)cb_MySaltCompanyPay.SelectedItem).jObject.GetValue("Key").ToString();
  136. txt_MchId.Text = ((PayItemData)cb_MySaltCompanyPay.SelectedItem).jObject.GetValue("MchId").ToString();
  137. }
  138. else
  139. {
  140. txt_AppId.Text = "";
  141. txt_Key.Text = "";
  142. txt_MchId.Text = "";
  143. }
  144. }
  145. void cb_AliPayAccount_SelectedIndexChanged(object sender, EventArgs e)
  146. {
  147. if (((PayItemData)cb_AliPayAccount.SelectedItem)!=null)
  148. {
  149. txt_AliAppid.Text = ((PayItemData)cb_AliPayAccount.SelectedItem).jObject.GetValue("AppId").ToString();
  150. txt_AliMchId.Text = ((PayItemData)cb_AliPayAccount.SelectedItem).jObject.GetValue("MchId").ToString();
  151. txt_AliPublicKey.Text = ((PayItemData)cb_AliPayAccount.SelectedItem).jObject.GetValue("PublicKey").ToString();
  152. txt_AliKey.Text = ((PayItemData)cb_AliPayAccount.SelectedItem).jObject.GetValue("PrivateKey").ToString();
  153. }
  154. else
  155. {
  156. txt_AliAppid.Text = "";
  157. txt_AliMchId.Text = "";
  158. txt_AliPublicKey.Text = "";
  159. txt_AliKey.Text = "";
  160. }
  161. }
  162. /// <summary>
  163. /// 绑定微信配置信息
  164. /// </summary>
  165. void BindWXData()
  166. {
  167. DataSet ds = config.GetSystemConfigure("*", "WeiXinPayConfig");
  168. if (ds.Tables[0].Rows.Count == 0)
  169. {
  170. WXConfigData wxData = new WXConfigData()
  171. {
  172. AppId = LYFZ.WinAPI.SDKSecurity.DESEncrypt("wxe30d2c612847beeb", frmThridPayConfig.EncryptKey),
  173. MCHID = LYFZ.WinAPI.SDKSecurity.DESEncrypt("1454966002", frmThridPayConfig.EncryptKey),
  174. Key = LYFZ.WinAPI.SDKSecurity.DESEncrypt("VIst5wdcsILt3kgMImwa21z9XPIvz0IC", frmThridPayConfig.EncryptKey),
  175. SubMchId = "",
  176. Open = false
  177. };
  178. wxModConfig = new Model.Model_ErpSystemConfigure()
  179. {
  180. Sconfig_Code = "WeiXinPayConfig",
  181. Sconfig_Name = "微信支付账户",
  182. Sconfig_Value = Json.JsonTool.ObjectToJson(wxData)
  183. };
  184. config.Add(wxModConfig);
  185. txt_AppId.Text = wxData.AppId.Trim();
  186. txt_Key.Text = wxData.Key.Trim();
  187. txt_MchId.Text = wxData.SubMchId;
  188. wxMchid = wxData.MCHID.Trim();
  189. cb_Open.Checked = wxData.Open;
  190. }
  191. else
  192. {
  193. wxModConfig = config.DataRowToModel(ds.Tables[0].Rows[0]);
  194. WXConfigData data = new WXConfigData();
  195. data = (WXConfigData)Json.JsonTool.JsonToObject(wxModConfig.Sconfig_Value, data);
  196. txt_AppId.Text = data.AppId.Trim();
  197. txt_Key.Text = data.Key.Trim();
  198. txt_MchId.Text = data.SubMchId;
  199. wxMchid = data.MCHID.Trim();
  200. cb_Open.Checked = data.Open;
  201. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  202. {
  203. if(data.TypeData==0)
  204. {
  205. rdo_WXAgentBtn.Checked=true;
  206. }
  207. else
  208. {
  209. rdo_WXAutonomyBtn.Checked = true;
  210. }
  211. rdo_WXAgentBtn_Click(null, null);
  212. }
  213. }
  214. }
  215. /// <summary>
  216. /// 绑定支付宝配置信息
  217. /// </summary>
  218. void BindAliData()
  219. {
  220. DataSet ds = config.GetSystemConfigure("*", "AliPayConfig");
  221. if (ds.Tables[0].Rows.Count == 0)
  222. {
  223. AliConfigData aliData = new AliConfigData()
  224. {
  225. AppId = "",
  226. Key = "",
  227. MCHID = "",
  228. publicKey = "",
  229. SubMchId = LYFZ.WinAPI.SDKSecurity.DESEncrypt("2088621649564405", frmThridPayConfig.EncryptKey),
  230. Open = false,
  231. SignType =rdo_RSA.Checked?"RSA":"RSA2"
  232. };
  233. alModConfig = new Model.Model_ErpSystemConfigure()
  234. {
  235. Sconfig_Code = "AliPayConfig",
  236. Sconfig_Name = "支付宝账户",
  237. Sconfig_Value = Json.JsonTool.ObjectToJson(aliData)
  238. };
  239. config.Add(alModConfig);
  240. cb_AliOpen.Checked = aliData.Open;
  241. txt_AliAppid.Text = aliData.AppId.Trim();
  242. txt_AliMchId.Text = aliData.MCHID.Trim();
  243. aliMchid = aliData.SubMchId;
  244. txt_AliKey.Text = aliData.Key;
  245. txt_AliPublicKey.Text = aliData.publicKey;
  246. }
  247. else
  248. {
  249. alModConfig = config.DataRowToModel(ds.Tables[0].Rows[0]);
  250. AliConfigData data = new AliConfigData();
  251. data = (AliConfigData)Json.JsonTool.JsonToObject(alModConfig.Sconfig_Value, data);
  252. cb_AliOpen.Checked = data.Open;
  253. txt_AliAppid.Text = data.AppId.Trim();
  254. txt_AliMchId.Text = data.MCHID.Trim();
  255. aliMchid = data.SubMchId;
  256. if(string.IsNullOrEmpty(aliMchid))
  257. {
  258. aliMchid = LYFZ.WinAPI.SDKSecurity.DESEncrypt("2088621649564405", frmThridPayConfig.EncryptKey);
  259. }
  260. txt_AliKey.Text = data.Key;
  261. txt_AliPublicKey.Text = data.publicKey;
  262. if(string.IsNullOrEmpty(data.SignType)|| data.SignType.Equals("RSA"))
  263. {
  264. rdo_RSA.Checked = true;
  265. }
  266. else if(data.SignType.Equals("RSA2"))
  267. {
  268. rdo_RSA2.Checked = true;
  269. }
  270. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  271. {
  272. if (data.TypeData == 0)
  273. {
  274. rdo_ZFBAgentBtn.Checked = true;
  275. }
  276. else
  277. {
  278. rdo_ZFBAutonomyBtn.Checked = true;
  279. }
  280. }
  281. }
  282. }
  283. /// <summary>
  284. /// 取消操作
  285. /// </summary>
  286. /// <param name="sender"></param>
  287. /// <param name="e"></param>
  288. public override void btn_AliCancel_Click(object sender, EventArgs e)
  289. {
  290. this.Close();
  291. base.btn_AliCancel_Click(sender, e);
  292. }
  293. /// <summary>
  294. ///确定操作
  295. /// </summary>
  296. /// <param name="sender"></param>
  297. /// <param name="e"></param>
  298. public override void btn_AliOK_Click(object sender, EventArgs e)
  299. {
  300. SaveWXAndZFBData();
  301. MessageBoxCustom.Show("保存成功,付款方式自动创建微信刷卡支付和支付宝条码支付");
  302. }
  303. /// <summary>
  304. /// 保存微信支付宝子商户信息
  305. /// </summary>
  306. void SaveWXAndZFBData()
  307. {
  308. WXConfigData data = new WXConfigData()
  309. {
  310. AppId = txt_AppId.Text.Trim(),
  311. Key = txt_Key.Text.Trim(),
  312. MCHID = wxMchid.Trim(),
  313. SubMchId = txt_MchId.Text.Trim(),
  314. Open = cb_Open.Checked
  315. };
  316. if(rdo_WXAgentBtn.Checked)
  317. {
  318. data.TypeData = 0;
  319. }
  320. else if (rdo_WXAutonomyBtn.Checked)
  321. {
  322. data.TypeData = 1;
  323. data.MCHID = txt_MchId.Text.Trim();
  324. }
  325. string strJson = Json.JsonTool.ObjectToJson(data);
  326. wxModConfig.Sconfig_Value = strJson;
  327. config.Update((object)wxModConfig, " Sconfig_Code='WeiXinPayConfig' ", "ID");
  328. AliConfigData alData = new AliConfigData()
  329. {
  330. AppId = txt_AliAppid.Text.Trim(),
  331. MCHID = txt_AliMchId.Text.Trim(),
  332. Key = txt_AliKey.Text,
  333. publicKey = txt_AliPublicKey.Text,
  334. Open = cb_AliOpen.Checked,
  335. SubMchId = aliMchid == null ? "" : aliMchid.Trim(),
  336. SignType = rdo_RSA.Checked ? "RSA" : rdo_RSA2.Checked ? "RSA2" : ""
  337. };
  338. if (rdo_ZFBAgentBtn.Checked)
  339. {
  340. data.TypeData = 0;
  341. }
  342. else if (rdo_ZFBAutonomyBtn.Checked)
  343. {
  344. data.TypeData = 1;
  345. }
  346. strJson = Json.JsonTool.ObjectToJson(alData);
  347. alModConfig.Sconfig_Value = strJson;
  348. config.Update((object)alModConfig, " Sconfig_Code='AliPayConfig' ", "ID");
  349. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\alipay_rsa_public_key.pem", txt_AliPublicKey.Text);
  350. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_public_key.pem", txt_AliPublicKey.Text);
  351. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_private_key.pem", txt_AliKey.Text);
  352. //base.btn_AliOK_Click(sender, e);
  353. DataSet ds = categoryBll.GetList("Sc_ClassCode='WXSKZF' or Sc_ClassCode='ZFBTMZF' ");
  354. bool bWx = false;
  355. bool bZfb = false;
  356. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  357. {
  358. if (ds.Tables[0].Rows[i]["Sc_ClassCode"].ToString() == "WXSKZF")
  359. {
  360. bWx = true;
  361. }
  362. if (ds.Tables[0].Rows[i]["Sc_ClassCode"].ToString() == "ZFBTMZF")
  363. {
  364. bZfb = true;
  365. }
  366. }
  367. if (!bWx)
  368. {
  369. LYFZ.Model.Model_ErpSystemCategory category = new Model.Model_ErpSystemCategory()
  370. {
  371. Sc_ClassCode = "WXSKZF",
  372. Sc_ClassName = "微信刷卡支付",
  373. Sc_ClassParentID = 81,
  374. Sc_IsDisable = false,
  375. Sc_ClassRemark = "接口自动生成",
  376. Sc_IsReadOnly = true,
  377. Sc_URL = "",
  378. Sc_IsDelete = false,
  379. Sc_CreateDatetime = DateTime.Now,
  380. Sc_CreateName = "",
  381. Sc_IsEnabledURL = false,
  382. Sc_UpdateDatetime = DateTime.Now
  383. };
  384. categoryBll.Add(category);
  385. }
  386. if (!bZfb)
  387. {
  388. LYFZ.Model.Model_ErpSystemCategory category = new Model.Model_ErpSystemCategory()
  389. {
  390. Sc_ClassCode = "ZFBTMZF",
  391. Sc_ClassName = "支付宝条码支付",
  392. Sc_ClassParentID = 81,
  393. Sc_IsDisable = false,
  394. Sc_ClassRemark = "接口自动生成",
  395. Sc_IsReadOnly = true,
  396. Sc_URL = "",
  397. Sc_IsDelete = false,
  398. Sc_CreateDatetime = DateTime.Now,
  399. Sc_CreateName = "",
  400. Sc_IsEnabledURL = false,
  401. Sc_UpdateDatetime = DateTime.Now
  402. };
  403. categoryBll.Add(category);
  404. }
  405. string wxid = "";
  406. string zfbid = "";
  407. ds = categoryBll.GetList("Sc_ClassCode='WXSKZF' or Sc_ClassCode='ZFBTMZF' ");
  408. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  409. {
  410. if (ds.Tables[0].Rows[i]["Sc_ClassCode"].ToString() == "WXSKZF")
  411. {
  412. wxid = ds.Tables[0].Rows[i]["ID"].ToString();
  413. }
  414. if (ds.Tables[0].Rows[i]["Sc_ClassCode"].ToString() == "ZFBTMZF")
  415. {
  416. zfbid = ds.Tables[0].Rows[i]["ID"].ToString();
  417. }
  418. }
  419. //string strIDs = "";
  420. //if (!cb_Open.Checked)
  421. //{
  422. // strIDs = wxid;
  423. //}
  424. //if (!cb_AliOpen.Checked)
  425. //{
  426. // if (!string.IsNullOrEmpty(strIDs))
  427. // {
  428. // strIDs += ",";
  429. // }
  430. // strIDs += zfbid;
  431. //}
  432. //if (!string.IsNullOrEmpty(strIDs))
  433. //{
  434. // categoryBll.DeleteList(strIDs);
  435. //}
  436. }
  437. /// <summary>
  438. /// 测试支付宝条码支付
  439. /// </summary>
  440. /// <param name="sender"></param>
  441. /// <param name="e"></param>
  442. public override void btn_AliCheck_Click(object sender, EventArgs e)
  443. {
  444. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\alipay_rsa_public_key.pem", txt_AliPublicKey.Text);
  445. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_public_key.pem", txt_AliPublicKey.Text);
  446. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_private_key.pem", txt_AliKey.Text);
  447. frmActionPay frmPay = new frmActionPay();
  448. frmPay.signtype = rdo_RSA.Checked ? "RSA" : rdo_RSA2.Checked ? "RSA2" : "";
  449. frmPay.BindInfoData("支付宝条码支付", 0.01m, txt_AliAppid.Text.Trim(), txt_AliMchId.Text.Trim(), "", aliMchid, "", rdo_ZFBAgentBtn.Checked?"0":"1");
  450. frmPay.ShowDialog();
  451. base.btn_AliCheck_Click(sender, e);
  452. }
  453. /// <summary>
  454. /// 测试微信刷卡支付
  455. /// </summary>
  456. /// <param name="sender"></param>
  457. /// <param name="e"></param>
  458. public override void btn_Check_Click(object sender, EventArgs e)
  459. {
  460. frmActionPay frmPay = new frmActionPay();
  461. if(LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  462. {
  463. frmPay.BindInfoData("微信刷卡支付", 0.01m, txt_AppId.Text.Trim(), txt_MchId.Text.Trim(), txt_Key.Text.Trim(), "");
  464. }
  465. else{
  466. if(rdo_WXAgentBtn.Checked)
  467. {
  468. frmPay.BindInfoData("微信刷卡支付", 0.01m, txt_AppId.Text.Trim(), wxMchid, txt_Key.Text.Trim(), txt_MchId.Text.Trim(), "");
  469. }
  470. else
  471. {
  472. frmPay.BindInfoData("微信刷卡支付", 0.01m, txt_AppId.Text.Trim(), txt_MchId.Text.Trim(), txt_Key.Text.Trim(), "", "","1");
  473. }
  474. }
  475. frmPay.ShowDialog();
  476. base.btn_Check_Click(sender, e);
  477. }
  478. /// <summary>
  479. /// 更新网络上的支付宝微信的商家账号数据
  480. /// </summary>
  481. /// <param name="sender"></param>
  482. /// <param name="e"></param>
  483. public override void btn_Update_Click(object sender, EventArgs e)
  484. {
  485. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  486. {
  487. //base.btn_Update_Click(sender, e);
  488. string wxData = "";
  489. string zfbData = "";
  490. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  491. {
  492. wxData = LYFZ.WinAPI.HttpClientHelper.GetResponse("http://wx.lyfz.net/PaymentService/PaymentService.aspx?type=wx");
  493. zfbData = LYFZ.WinAPI.HttpClientHelper.GetResponse("http://wx.lyfz.net/PaymentService/PaymentService.aspx?type=zfb");
  494. });
  495. dynamic wxjsonDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject(wxData);
  496. dynamic zfbjsonDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject(zfbData);
  497. bool bwx = false;
  498. if (wxjsonDataObj["msg"] == "成功")
  499. {
  500. if (rdo_WXAgentBtn.Checked)
  501. {
  502. bwx = true;
  503. txt_AppId.Text = wxjsonDataObj["data"]["appid"];
  504. txt_Key.Text = wxjsonDataObj["data"]["key"];
  505. wxMchid = wxjsonDataObj["data"]["businessNumber"];
  506. }
  507. }
  508. bool bzfb = false;
  509. if (zfbjsonDataObj["msg"] == "成功")
  510. {
  511. if (rdo_ZFBAgentBtn.Checked)
  512. {
  513. bzfb = true;
  514. aliMchid = zfbjsonDataObj["data"]["CompanyPid"];
  515. }
  516. }
  517. if (bwx && bzfb)
  518. {
  519. MessageBoxCustom.Show("更新成功!!", "提示");
  520. }
  521. else if (!bwx && !bzfb)
  522. {
  523. MessageBoxCustom.Show("微信和支付宝更新失败", "提示");
  524. }
  525. else if (!bwx)
  526. {
  527. MessageBoxCustom.Show("微信更新失败", "提示");
  528. }
  529. else if (!bzfb)
  530. {
  531. MessageBoxCustom.Show("支付宝更新失败", "提示");
  532. }
  533. //btn_AliOK_Click(null, null);
  534. SaveWXAndZFBData();
  535. BindWXData();
  536. BindAliData();
  537. }
  538. }
  539. }
  540. public class PayItemData
  541. {
  542. public string Name { get; set; }
  543. public string Type { get; set; }
  544. public Newtonsoft.Json.Linq.JObject jObject { get; set; }
  545. public override string ToString()
  546. {
  547. return Name;
  548. }
  549. }
  550. }