241 lines
6.8 KiB
C#
241 lines
6.8 KiB
C#
using AllBase;
|
|
using AllBase.Model.Result;
|
|
using AllBase.Model.Result.WXResult;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using TemuKJD.BaseForms;
|
|
using TemuKJD.ToolForms;
|
|
using Work;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace TemuKJD.WXForms.AdminForms
|
|
{
|
|
/// <summary>
|
|
/// OEM提现审核窗体
|
|
/// 同意:需上传打款凭证图片;拒绝:需填写拒绝理由
|
|
/// </summary>
|
|
public partial class WXAdminOemWithdrawalAuditForm : BaseGeneralForm
|
|
{
|
|
/// <summary>当前审核的提现记录</summary>
|
|
private readonly WXOemWithdrawalInfo withdrawalInfo;
|
|
|
|
/// <summary>打款凭证图片(base64)</summary>
|
|
private string payImageBase64 = "";
|
|
|
|
public WXAdminOemWithdrawalAuditForm(WXOemWithdrawalInfo withdrawalInfo)
|
|
{
|
|
InitializeComponent();
|
|
this.withdrawalInfo = withdrawalInfo;
|
|
}
|
|
|
|
private void WXAdminOemWithdrawalAuditForm_Load(object sender, EventArgs e)
|
|
{
|
|
// 默认同意模式
|
|
this.rbAgree.Checked = true;
|
|
UpdateMode();
|
|
|
|
if (this.withdrawalInfo == null)
|
|
return;
|
|
|
|
this.lblNo.Text = this.withdrawalInfo.withdrawal_no;
|
|
this.lblOem.Text = this.withdrawalInfo.oem_name;
|
|
this.lblType.Text = this.withdrawalInfo.withdrawal_type_string;
|
|
this.lblAccount.Text = this.withdrawalInfo.account_no;
|
|
// 金额(分) → 元
|
|
this.lblAmount.Text = (this.withdrawalInfo.amount / 100m).ToString("F2");
|
|
|
|
// 凭证图片占位
|
|
this.pictureBox1.Image = Properties.Resources.nopic;
|
|
|
|
// 已审核完毕:仅展示审核内容,不允许二次修改和提交
|
|
if (this.withdrawalInfo.status != (int)OemWithdrawalStatus.Pending)
|
|
ShowAuditedView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审核已完毕:仅展示审核内容(审核结果/拒绝理由/打款凭证),禁止再次修改与提交
|
|
/// </summary>
|
|
private void ShowAuditedView()
|
|
{
|
|
int status = this.withdrawalInfo.status;
|
|
if (status == (int)OemWithdrawalStatus.Rejected)
|
|
{
|
|
// 拒绝:展示拒绝理由
|
|
this.rbReject.Checked = true;
|
|
this.txtRejectReason.Text = this.withdrawalInfo.audit_remark ?? "";
|
|
}
|
|
else
|
|
{
|
|
// 同意(审核通过及其后续打款状态):展示打款凭证图片
|
|
this.rbAgree.Checked = true;
|
|
// 路径拼接规则与"收款账号-查看"一致:LoginApiUrl + 字段,字段为 pay_trade_no
|
|
if (!string.IsNullOrEmpty(this.withdrawalInfo.pay_trade_no))
|
|
LoadVoucherImage(BaseClass.LoginApiUrl + this.withdrawalInfo.pay_trade_no);
|
|
}
|
|
UpdateMode();
|
|
|
|
// 禁止二次修改与提交
|
|
this.rbAgree.Enabled = false;
|
|
this.rbReject.Enabled = false;
|
|
this.btnUploadImg.Visible = false;
|
|
this.txtRejectReason.ReadOnly = true;
|
|
this.btnSubmit.Visible = false;
|
|
|
|
this.Text = "审核详情";
|
|
this.TitleText = "审核详情";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载打款凭证图片
|
|
/// </summary>
|
|
private void LoadVoucherImage(string voucherUrl)
|
|
{
|
|
try
|
|
{
|
|
if (voucherUrl.Contains("wxapp"))
|
|
{
|
|
string getImgError = "";
|
|
Image img = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(voucherUrl, out getImgError);
|
|
this.pictureBox1.Image = img ?? Properties.Resources.nopic;
|
|
}
|
|
else
|
|
{
|
|
this.pictureBox1.ImageLocation = voucherUrl.Replace("https", "http");
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
this.pictureBox1.Image = Properties.Resources.nopic;
|
|
}
|
|
}
|
|
|
|
/// <summary>根据选择的模式切换 同意/拒绝 面板</summary>
|
|
private void UpdateMode()
|
|
{
|
|
bool agree = this.rbAgree.Checked;
|
|
this.pnlAgree.Visible = agree;
|
|
this.pnlReject.Visible = !agree;
|
|
}
|
|
|
|
private void rbAgree_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
UpdateMode();
|
|
}
|
|
|
|
/// <summary>上传打款凭证图片</summary>
|
|
private void btnUploadImg_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
openFileDialog.Multiselect = false;
|
|
openFileDialog.Filter = "图片文件 (*.jpeg;*.jpg;*.png)|*.jpeg;*.jpg;*.png|All files (*.*)|*.*";
|
|
if (openFileDialog.ShowDialog() != DialogResult.OK)
|
|
return;
|
|
|
|
try
|
|
{
|
|
using (Image imageSource = Image.FromFile(openFileDialog.FileName))
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream())
|
|
{
|
|
// 统一转成 jpg 压缩后提交,避免原图过大
|
|
Image image = new Bitmap(imageSource);
|
|
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
image.Dispose();
|
|
byte[] imageBytes = memoryStream.ToArray();
|
|
payImageBase64 = Convert.ToBase64String(imageBytes);
|
|
}
|
|
this.pictureBox1.Image = new Bitmap(imageSource);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
payImageBase64 = "";
|
|
this.pictureBox1.Image = Properties.Resources.nopic;
|
|
BaseMsgForm.ShowError("打开凭证图片失败 " + ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>提交审核</summary>
|
|
private void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.withdrawalInfo == null)
|
|
{
|
|
BaseMsgForm.ShowError("提现记录数据异常,请重试!");
|
|
return;
|
|
}
|
|
|
|
bool agree = this.rbAgree.Checked;
|
|
string rejectReason = this.txtRejectReason.Text.Trim();
|
|
|
|
if (agree && string.IsNullOrEmpty(payImageBase64))
|
|
{
|
|
BaseMsgForm.ShowError("请先上传打款凭证图片!");
|
|
return;
|
|
}
|
|
if (!agree && string.IsNullOrEmpty(rejectReason))
|
|
{
|
|
BaseMsgForm.ShowError("请填写拒绝理由!");
|
|
return;
|
|
}
|
|
|
|
if (BaseMsgForm.ShowConfirm(agree ? "确定审核通过该提现申请?" : "确定拒绝该提现申请?", "提示").DialogResult != DialogResult.OK)
|
|
return;
|
|
|
|
this.btnSubmit.Enabled = false;
|
|
try
|
|
{
|
|
var obj = UserLogin.GetSignPostData(new
|
|
{
|
|
withdrawal_no= withdrawalInfo.withdrawal_no,
|
|
audit_result = (agree ? 1 : 2),
|
|
pay_trade_no = payImageBase64,
|
|
audit_remark= GetHtml.UrlEncodeUtf8(rejectReason)
|
|
});
|
|
string data = JsonHelper.SerializeObject(obj);
|
|
var url = BaseClass.BuildObjString("user/oem_audit_withdrawal");
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
var ret = JsonConvert.DeserializeObject<Result<OemAuditResult>>(html);
|
|
if (ret.Code != 200)
|
|
{
|
|
BaseMsgForm.ShowError("审核提交失败:" + ret.Msg);
|
|
return;
|
|
}
|
|
|
|
BaseMsgForm.ShowInfo(agree ? "审核通过成功!" : "已拒绝该提现申请!");
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseMsgForm.ShowError("审核提交异常:" + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
this.btnSubmit.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
{
|
|
ShowImgForm img = new ShowImgForm(BaseClass.LoginApiUrl + withdrawalInfo.account_no);
|
|
img.ShowDialog();
|
|
}
|
|
|
|
class OemAuditResult
|
|
{
|
|
public string withdrawal_no { get; set; }
|
|
public int status { get; set; }
|
|
}
|
|
}
|
|
}
|