|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
using Library;
|
|
|
using LitJson;
|
|
|
using System.Linq;
|
|
|
+using System.Threading;
|
|
|
using MySystem.PxcModels;
|
|
|
|
|
|
namespace MySystem
|
|
@@ -13,31 +14,11 @@ namespace MySystem
|
|
|
private ConsumerOrdersReturnDoService()
|
|
|
{ }
|
|
|
|
|
|
- public void Start(JobMqMsg jobInfo)
|
|
|
+ public void Start()
|
|
|
{
|
|
|
- string content = "";
|
|
|
- try
|
|
|
- {
|
|
|
- DoRefund();
|
|
|
- // string Msg = "success";
|
|
|
- // jobInfo.Status = Msg == "success" ? 1 : 0;
|
|
|
- // jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
|
|
|
- // RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(content))
|
|
|
- {
|
|
|
- Dictionary<string, string> data = new Dictionary<string, string>();
|
|
|
- data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
- data.Add("ErrMsg", ex.ToString());
|
|
|
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(data), "public_err");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
|
|
|
- }
|
|
|
- }
|
|
|
+ Thread th = new Thread(DoRefund);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
}
|
|
|
|
|
|
private void DoRefund()
|
|
@@ -48,45 +29,52 @@ namespace MySystem
|
|
|
RefundItem item = RedisDbconn.Instance.RPop<RefundItem>("ConsumerOrdersStat");
|
|
|
if (item != null)
|
|
|
{
|
|
|
- bool success = false;
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
- if (item.PayMode == 1)
|
|
|
- {
|
|
|
- string resultString = new AlipayFunction().Refund(item.TradeNo, item.RefundMoney.ToString("f2"), "202202BB4fc8c2c03c914f2f87b6c678a77d7C03");
|
|
|
- JsonData jsonObj = JsonMapper.ToObject(resultString);
|
|
|
- if (jsonObj["alipay_trade_refund_response"]["code"].ToString() == "10000")
|
|
|
- {
|
|
|
- success = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (item.PayMode == 2)
|
|
|
+ try
|
|
|
{
|
|
|
- string AppId = "wxe2c051b3e46c0f6f";
|
|
|
- string MchId = "1611167423";
|
|
|
- MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == item.MerchantId) ?? new MerchantAddInfo();
|
|
|
- MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == item.MerchantId) ?? new MerchantInfo();
|
|
|
- string SubMchId = merchantAdd.SubMchid;
|
|
|
- string Description = merchant.Name;
|
|
|
- string RefundNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
- Dictionary<string, string> dic = new WeChatFunction().Refund(AppId, MchId, SubMchId, item.RefundMoney, item.TotalMoney, item.TradeNo, RefundNo);
|
|
|
- if (dic.ContainsKey("status"))
|
|
|
+ bool success = false;
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ if (item.PayMode == 1)
|
|
|
{
|
|
|
- if (dic["status"] == "SUCCESS")
|
|
|
+ string resultString = new AlipayFunction().Refund(item.TradeNo, item.RefundMoney.ToString("f2"), "202202BB4fc8c2c03c914f2f87b6c678a77d7C03");
|
|
|
+ JsonData jsonObj = JsonMapper.ToObject(resultString);
|
|
|
+ if (jsonObj["alipay_trade_refund_response"]["code"].ToString() == "10000")
|
|
|
{
|
|
|
success = true;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (success)
|
|
|
- {
|
|
|
- ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == item.ProfitId);
|
|
|
- if (order != null)
|
|
|
+ else if (item.PayMode == 2)
|
|
|
{
|
|
|
- order.Status = 1;
|
|
|
- db.SaveChanges();
|
|
|
+ string AppId = "wxe2c051b3e46c0f6f";
|
|
|
+ string MchId = "1611167423";
|
|
|
+ MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == item.MerchantId) ?? new MerchantAddInfo();
|
|
|
+ MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == item.MerchantId) ?? new MerchantInfo();
|
|
|
+ string SubMchId = merchantAdd.SubMchid;
|
|
|
+ string Description = merchant.Name;
|
|
|
+ string RefundNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
+ Dictionary<string, string> dic = new WeChatFunction().Refund(AppId, MchId, SubMchId, item.RefundMoney, item.TotalMoney, item.TradeNo, RefundNo);
|
|
|
+ if (dic.ContainsKey("status"))
|
|
|
+ {
|
|
|
+ if (dic["status"] == "SUCCESS")
|
|
|
+ {
|
|
|
+ success = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == item.ProfitId);
|
|
|
+ if (order != null)
|
|
|
+ {
|
|
|
+ order.Status = 2;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "退款返现队列异常");
|
|
|
}
|
|
|
- db.Dispose();
|
|
|
}
|
|
|
else
|
|
|
{
|