1.新增销售模块自动审核功能

This commit is contained in:
qmj
2025-09-25 00:03:24 +08:00
parent 858538df17
commit 5def74f70a
11 changed files with 199 additions and 98 deletions
@@ -48,7 +48,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA
return co;
}
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, VoucherTypeSA enmVoucherType, int VoucherState = 0, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled")
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, Dictionary<string, object> dictionary, string cardNumber, VoucherTypeSA enmVoucherType, int VoucherState = 0, bool bGetCode = false, string codeKey = null, bool? bVerify = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled")
{
try
{
@@ -114,90 +114,67 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA
var res = new BaseResult<string>();
_logInfo.Debug("开始保存...");
_logInfo.Debug("开始保存...");
errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId, ref domCur);
_logInfo.Debug("保存结束...");
_logInfo.Debug(errorMsg);
_logInfo.Debug($"{vouchId}");
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}");
if (!res.bSuccess)
{
if (!string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
}
if (!string.IsNullOrWhiteSpace(domMsg.xml))
{
throw new Exception(domMsg.xml);
}
if (!string.IsNullOrWhiteSpace(curDom.xml))
{
throw new Exception(curDom.xml);
}
throw new Exception("未知错误");
}
if (iswfcontrolled == false && VoucherState == 2)
{
var strSql = $"UPDATE {vouchers.cBTTblName} SET {cFlowFieldName} = 0 WHERE {vouchers.voucherIdFieldName}={vouchId}";
object rsts = new Recordset();
baseLogin.Connection.Execute(strSql, out rsts);
}
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
res.voucherId = $"{vouchId}";
res.result = errorMsg;
errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId, ref domCur);
_logInfo.Debug("保存结束...");
_logInfo.Debug(errorMsg);
_logInfo.Debug($"{vouchId}");
res.bSuccess = (string.IsNullOrWhiteSpace(errorMsg) && !string.IsNullOrWhiteSpace($"{vouchId}")) ||
(errorMsg == "True" && !string.IsNullOrWhiteSpace($"{vouchId}"));
if (!res.bSuccess)
{
res.message = "保存失败";
if (!string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
}
if (!string.IsNullOrWhiteSpace(domMsg.xml))
{
throw new Exception(domMsg.xml);
}
if (!string.IsNullOrWhiteSpace(curDom.xml))
{
throw new Exception(curDom.xml);
}
throw new Exception("未知错误");
return res;
}
//if (iswfcontrolled == false && VoucherState == 0)
//{
// var strSql = $"UPDATE {vouchers.cBTTblName} SET {cFlowFieldName} = 0 WHERE {vouchers.voucherIdFieldName}={vouchId}";
// object rsts = new Recordset();
// baseLogin.Connection.Execute(strSql, out rsts);
//}
res.voucherCode = CommonHelper.GetVoucherCode(baseLogin.Connection, vouchId, vouchers);
res.voucherId = $"{vouchId}";
res.result = errorMsg;
res.message = "保存成功";
_logInfo.Debug($"{baseLogin.Connection.State},{baseLogin.Connection.ConnectionString}");
var strWhere = CommonHelper.GetVoucherWhereSqlById(vouchers, vouchId);
if (res.bSuccess && bAudit)
if (res.bSuccess && bVerify == true)
{
try
{
errorMsg = VerifyVouch(co, baseLogin.Connection, enmVoucherType, res.voucherCode, res.voucherId, strWhere, true);
var verifyRes =await VerifyVouch(co, baseLogin.Connection, enmVoucherType, res.voucherCode, res.voucherId, strWhere, true);
if (!string.IsNullOrWhiteSpace(errorMsg))
{
throw new Exception(errorMsg);
}
}
catch (Exception)
{
res.bSuccess = false;
throw;
}
if (verifyRes.bSuccess == false)
{
return verifyRes;
}
}
_logInfo.Debug("提交事务...");
return res;
}
catch (Exception ex)
{
@@ -209,38 +186,60 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA
}
}
public async Task<BaseResult<string>> VerifyVouch(dynamic voucherCO, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere, bool bVerify)
/// <summary>
/// 审核单据
/// </summary>
/// <param name="voucherCo"></param>
/// <param name="conn"></param>
/// <param name="sVouchType"></param>
/// <param name="cCode"></param>
/// <param name="vouchId"></param>
/// <param name="strWhere"></param>
/// <param name="bVerify"></param>
/// <returns></returns>
public async Task<BaseResult<string>> VerifyVouch(dynamic voucherCo, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere, bool bVerify)
{
IXMLDOMDocument2 domHead = new DOMDocument();
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
_logInfo.Debug("开始获取单据数据...");
voucherCO.GetVoucherData(ref domHead, ref domBody, vouchId, true, strWhere);
var res = new BaseResult<string>
try
{
voucherCode = cCode,
voucherId = $"{vouchId}"
};
IXMLDOMDocument2 domHead = new DOMDocument();
IXMLDOMDocument2 domBody = new DOMDocument();
IXMLDOMDocument2 domMsg = new DOMDocument();
var errorMsg = voucherCO.VerifyVouch(ref domHead, bVerify);
_logInfo.Debug("开始获取单据数据...");
voucherCo.GetVoucherData(ref domHead, ref domBody, vouchId, true, strWhere);
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg);
var res = new BaseResult<string>
{
voucherCode = cCode,
voucherId = $"{vouchId}"
};
if (res.bSuccess)
{
res.message = "审核成功";
res.result = res.voucherId;
var errorMsg = voucherCo.VerifyVouch(ref domHead, bVerify);
res.bSuccess = string.IsNullOrWhiteSpace(errorMsg);
if (res.bSuccess)
{
res.message = "审核成功";
res.result = res.voucherId;
}
else
{
res.message = "审核失败";
res.result = string.IsNullOrWhiteSpace(errorMsg) ? domMsg.xml : errorMsg;
}
return res;
}
else
catch (Exception ex)
{
res.message = "审核失败";
res.result = string.IsNullOrWhiteSpace(errorMsg) ? domMsg.xml : errorMsg;
}
_logInfo.Error(ex.Message, ex);
return res;
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "审核失败", result = ex.Message };
}
}
}
}