|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Threading; |
|
|
|
using BWP.B3Frameworks; |
|
|
|
using BWP.B3Frameworks.BO; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
@ -22,8 +23,7 @@ namespace BWP.B3QingDaoWanFu.Tasks { |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(TrustPay))); |
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("PayState", 付款状态.请求支付)); |
|
|
|
query.Where.Conditions.Add(DQCondition.LessThanOrEqual("ReCheckTime", BLContext.Now)); |
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThan("CreateTime", BLContext.Now.AddHours(-5))); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("ReChecked", false)); |
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThan("CreateTime", BLContext.Now.AddHours(-3))); |
|
|
|
query.Where.Conditions.Add(DQCondition.LessThan("ReCheckCount", 6)); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("Gathering_ID"))); |
|
|
|
|
|
|
|
@ -53,7 +53,20 @@ namespace BWP.B3QingDaoWanFu.Tasks { |
|
|
|
_trustPayID = id; |
|
|
|
} |
|
|
|
|
|
|
|
volatile static object _lockObj = new object(); |
|
|
|
|
|
|
|
public void Execute() { |
|
|
|
if (!Monitor.TryEnter(_lockObj)) { |
|
|
|
throw new SameTaskNotFinishException(this); |
|
|
|
} |
|
|
|
try { |
|
|
|
DoExecute(); |
|
|
|
} finally { |
|
|
|
Monitor.Exit(_lockObj); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DoExecute() { |
|
|
|
if (_trustPayID == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
@ -62,19 +75,17 @@ namespace BWP.B3QingDaoWanFu.Tasks { |
|
|
|
trustPay = InnerBLUtil.GetSingleDmo<TrustPay>(session, "ID", _trustPayID); |
|
|
|
if (trustPay == null || trustPay.AccountCustomer_ID == null) |
|
|
|
return; |
|
|
|
trustPay.ID = _trustPayID; |
|
|
|
trustPay.ReCheckCount++; |
|
|
|
if (trustPay.Gathering_ID > 0) { |
|
|
|
if (!trustPay.ReChecked) { |
|
|
|
trustPay.ReChecked = true; |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "ReChecked", "ReCheckCount"); |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
trustPay.ID = _trustPayID; |
|
|
|
if (trustPay.Gathering_ID > 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
trustPay.ReCheckCount++; |
|
|
|
if (trustPay.PayState == 付款状态.请求支付) { |
|
|
|
if (!ABCPaySuccess(session, trustPay)) |
|
|
|
if (!ABCPaySuccess(trustPay)) { |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "ReCheckTime", "ReCheckCount" ); |
|
|
|
session.Commit(); |
|
|
|
return; |
|
|
|
} |
|
|
|
trustPay.PayState = 付款状态.付款成功; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -92,25 +103,22 @@ namespace BWP.B3QingDaoWanFu.Tasks { |
|
|
|
} |
|
|
|
if (gatheringID > 0) { |
|
|
|
trustPay.Gathering_ID = gatheringID; |
|
|
|
} |
|
|
|
} |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "Gathering_ID", "PayState", "ReCheckCount"); |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
//创建收款单成功且 状态修改了 以后 就直接返回
|
|
|
|
return; |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
msg = e.Message; |
|
|
|
} |
|
|
|
|
|
|
|
using (var session = Dmo.NewSession()) { |
|
|
|
trustPay.ReChecked = trustPay.Gathering_ID > 0; |
|
|
|
|
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "Gathering_ID", "PayState", "ReChecked", "ReCheckCount"); |
|
|
|
} catch (Exception e) { |
|
|
|
} |
|
|
|
using (var session = Dmo.NewSession()) { |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay , "PayState", "ReCheckCount"); |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(msg)) |
|
|
|
throw new ApplicationException(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static bool ABCPaySuccess(IDmoSessionWithTransaction session, TrustPay trustPay) { |
|
|
|
private static bool ABCPaySuccess(TrustPay trustPay) { |
|
|
|
var req = new B3QueryOrderRequest(); |
|
|
|
req.OrderNo = trustPay.ABCPay_No; |
|
|
|
var res = req.Submit(); |
|
|
|
@ -119,17 +127,10 @@ namespace BWP.B3QingDaoWanFu.Tasks { |
|
|
|
} |
|
|
|
if (res.StatusIsSuccess()) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (res.Status == "01" || res.Status == "02" || res.Status == "03") { |
|
|
|
trustPay.ReCheckTime = BLContext.Now.AddMinutes(5); |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "ReCheckTime", "ReCheckCount"); |
|
|
|
session.Commit(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
trustPay.ReChecked = true; |
|
|
|
InnerBLUtil.UpdateEntityProperties(session, trustPay, "ReChecked", "ReCheckCount"); |
|
|
|
session.Commit(); |
|
|
|
trustPay.ReCheckTime = BLContext.Now.AddMinutes(5); |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|