Commit ad45c2a5 by 陶然

优化

parent a4129a2c
...@@ -216,4 +216,80 @@ namespace Njzj.Bocoms.Openapis ...@@ -216,4 +216,80 @@ namespace Njzj.Bocoms.Openapis
return rtns; return rtns;
} }
} }
[RequiresAnyRole(SystemRoles.Everyone)]
public class ReceiveCodeDelete : RestfulExecution<ReceiveCode>
{
public string PayMerTranNo { get; set; }
public List<string> PayMerTranNos { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
(PayMerTranNo.IsNullOrEmpty() && PayMerTranNos.IsNullOrEmpty()).ThrowIfTrue("请传入订单号!");
if (PayMerTranNos.IsNullOrEmpty()) PayMerTranNos = new List<string>();
if (!PayMerTranNos.IsNullOrEmpty()) PayMerTranNos.Add(PayMerTranNo);
var rtns = new RestfulExecutionResponse<ReceiveCode>();
rtns.Results = new List<ReceiveCode>();
var conn = KiviiContext.GetOpenedDbConnection<ReceiveCode>();
var existCodes = conn.Select<ReceiveCode>(o => Sql.In(o.pay_mer_tran_no, PayMerTranNos));
if (!existCodes.IsNullOrEmpty())
{
foreach (var existCode in existCodes)
{
if (existCode.tran_state.ToUpper() != "SUCCESS")//查出来已经成功付款了 直接返回
{
try
{
var order = Extension.GetReceiveCodeOrder(existCode.pay_mer_tran_no);
if (order.rsp_body.tran_state.ToUpper() == "SUCCESS")//成功付款的情况
{
existCode.tran_state = order.rsp_body.tran_state;
existCode.AddOnlyProperties(o => o.tran_state);
existCode.tran_state_code = order.rsp_body.tran_state_code;
existCode.AddOnlyProperties(o => o.tran_state_code);
existCode.tran_state_msg = order.rsp_body.tran_state_msg;
existCode.AddOnlyProperties(o => o.tran_state_msg);
existCode.mer_memo = order.rsp_body.mer_memo;
existCode.AddOnlyProperties(o => o.mer_memo);
existCode.total_amount = order.rsp_body.total_amount;
existCode.AddOnlyProperties(o => o.total_amount);
existCode.order_status = order.rsp_body.order_status;
existCode.AddOnlyProperties(o => o.order_status);
existCode.tran_content = order.rsp_body.tran_content;
existCode.AddOnlyProperties(o => o.tran_content);
conn.UpdateOnly(existCode);
existCode.RemoveAllOnlyProperties();
var th = KiviiContext.NewThread(() =>
{
existCode.ReceiveCodePaied();
});
th.Start();
throw new Exception("存在账单已经支付完成");
}
else if (order.rsp_body.tran_state.ToUpper() == "PROCESS")//仍然在操作中的情况
{
existCode.ReceiveCodeDelete();//超过6分钟 二维码已经过期,直接删除
rtns.Results.Add(existCode);
}
else//失败的情况
{
existCode.ReceiveCodeDelete();//超过6分钟 二维码已经过期,直接删除
rtns.Results.Add(existCode);
}
}
catch (Exception ex)
{
//existCode.ReceiveCodeDelete();
//rtns.Results.Add(existCode);
throw ex;
}
}
}
}
return rtns;
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment