154 lines
6.3 KiB
C#
154 lines
6.3 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Model;
|
|
using Chat.Framework.WXSdk;
|
|
using Chat.Framework.WXSdk.Implement;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using UI.Framework.Forms;
|
|
|
|
namespace FLSystem.Forms
|
|
{
|
|
public partial class set_weixin_password : BaseForm
|
|
{
|
|
public set_weixin_password(WXClientImpl_IPAD ipad)
|
|
{
|
|
InitializeComponent();
|
|
this.ipad = ipad;
|
|
this.textEdit1.Text = ipad.User.Username;
|
|
this.textEdit2.Text = ipad.User.Nick;
|
|
}
|
|
WXClientImpl_IPAD ipad = null;
|
|
|
|
private void set_weixin_password_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var list = ipad.FindBankCar();
|
|
|
|
var session = ApiClient.GetSession();
|
|
robot = session.FindRobotInfo(ipad.WeixinHao, Api.Framework.SDK.ChatType.微信);
|
|
var entity = session.FindWeixinpassword(robot.id);
|
|
if (entity != null)
|
|
this.textEdit3.Text = entity.password;
|
|
int index = 0;
|
|
foreach (var item in list)
|
|
{
|
|
index++;
|
|
this.comboBoxEdit1.Properties.Items.Add(item);
|
|
if (entity != null && item.bank_name == entity.bank_name)
|
|
this.comboBoxEdit1.SelectedIndex = index;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ShowError(ex);
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
Dictionary<string, object> obj = new Dictionary<string, object>();
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
simpleButton1.Enabled = false;
|
|
if (string.IsNullOrEmpty(this.textEdit3.Text)) throw new Exception("您尚未设置,支付密码!");
|
|
if (string.IsNullOrEmpty(this.textEdit4.Text)) throw new Exception("您尚未填写,测试用户wxid!");
|
|
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
BankCar bank = null;
|
|
if (this.comboBoxEdit1.SelectedIndex != 0)
|
|
bank = this.comboBoxEdit1.EditValue as BankCar;
|
|
|
|
if (!string.IsNullOrEmpty(this.textEdit5.Text))
|
|
{
|
|
if (obj.ContainsKey("reqKey"))
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
try
|
|
{
|
|
ipad.SnsVerify(this.textEdit5.Text, false, obj["reqKey"].ToString(), bank, obj["token"].ToString(), obj["pass"].ToString());
|
|
this.textEdit5.Text = "";
|
|
ShowSuccess("已提交,请检查是否支付成功!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseForm.ShowError(ex.Message);
|
|
}
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
textEdit5.Text = string.Empty;
|
|
ShowSuccessAutoClose("支付异常应该已经解除,请重新再试");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var result = ipad.SendPay(this.textEdit4.Text, "测试", 1, this.textEdit3.Text, 1, this.radioGroup1.EditValue.ToString() == "1" ? Chat.Framework.WXSdk.IPAD.PayType.红包 : Chat.Framework.WXSdk.IPAD.PayType.转账, bank, obj);
|
|
if (result == null)
|
|
{
|
|
ShowSuccessAutoClose("您的支付异常已解除!");
|
|
return;
|
|
}
|
|
|
|
var r = CsharpHttpHelper.HttpExtend.JsonToDictionary(result);
|
|
if (result.Contains("本次交易需要短信验证") || result.Contains("收不到验证码") || (r != null && r.ContainsKey("token") && r.ContainsKey("balance_mobile")))
|
|
{
|
|
string token = r["token"].ToString();
|
|
obj["token"] = token;
|
|
string phone = r["balance_mobile"].ToString();
|
|
ShowSuccessAutoClose("向您手机“" + phone + "”已发送短信,请注意查收!");
|
|
}
|
|
else
|
|
ShowSuccessAutoClose(result + "\r\n无法确定异常信息,请检查手机是否收到验证码!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed) ShowError(ex);
|
|
}
|
|
finally
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
simpleButton1.Enabled = true;
|
|
}));
|
|
}
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed) ShowError(ex);
|
|
}
|
|
}
|
|
fl_robot_info robot = null;
|
|
private void set_weixin_password_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
|
|
var entity = session.FindWeixinpassword(robot.id);
|
|
if (entity == null) entity = new fl_weixin_password() { robot_id = robot.id };
|
|
var bank = this.comboBoxEdit1.EditValue as BankCar;
|
|
entity.SetBank(bank);
|
|
entity.password = this.textEdit3.Text;
|
|
session.SaveOrUpdate(entity);
|
|
session.FindWeixinpasswords(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed) ShowError(ex);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |