12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using MySystem.PxcModels;
- using Library;
- using LitJson;
- namespace MySystem
- {
- public class AlipayPayBackService
- {
- public readonly static AlipayPayBackService Instance = new AlipayPayBackService();
- private AlipayPayBackService()
- { }
- public void Start()
- {
- try
- {
- dosomething();
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "支付回调异常");
- }
- }
- private void dosomething()
- {
- bool op = true;
- while (op)
- {
- string content = RedisDbconn.Instance.RPop<string>("PayCallBack");
- if (!string.IsNullOrEmpty(content))
- {
- JsonData jsonObj = JsonMapper.ToObject(content);
- string OrderNo = jsonObj["out_trade_no"].ToString();
- string TradeNo = jsonObj["transaction_id"].ToString();
- decimal TotalFee = decimal.Parse(function.CheckNum(jsonObj["total_fee"].ToString()));
- WebCMSEntities db = new WebCMSEntities();
- ConsumerOrderForNo forNo = db.ConsumerOrderForNo.FirstOrDefault(m => m.OrderNo == OrderNo);
- if (forNo != null)
- {
- ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == forNo.OrderIds && m.Status == 0);
- if (order != null)
- {
- order.Status = 1;
- order.UpdateDate = DateTime.Now;
- order.PayMoney = order.PayMoney;
- order.MaxDivi = order.MaxDivi;
- db.SaveChanges();
- RedisDbconn.Instance.AddList("ConsumerOrdersStat", order.Id);
- RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
- RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.MerchantId, order);
- // ConsumerOrdersStatService.Instance.Stat(order);
- }
- }
- db.Dispose();
- }
- else
- {
- op = false;
- }
- }
- }
- }
- }
|