1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using MySystem.SpModels;
- using Library;
- using LitJson;
- namespace MySystem
- {
- public class SycnSpActiveService
- {
- public readonly static SycnSpActiveService Instance = new SycnSpActiveService();
- private SycnSpActiveService()
- { }
- public void Start(int Id = 0)
- {
- WebCMSEntities spdb = new WebCMSEntities();
- PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
- string Month = DateTime.Now.ToString("yyyyMM");
- string Date = DateTime.Now.ToString("yyyyMMdd");
- DateTime start = DateTime.Now.AddDays(-5);
- IQueryable<ActivateRecord> acts = spdb.ActivateRecord;
- if (Id > 0)
- {
- acts = acts.Where(m => m.Id == Id && m.Status == 1);
- }
- else
- {
- acts = acts.Where(m => m.ActivateDate >= start && m.Status == 1);
- }
- acts = acts.OrderByDescending(m => m.Id);
- foreach (ActivateRecord act in acts.ToList())
- {
- bool op = false;
- if (act.ActivateStatus == "00" && act.ProductType == "1")
- {
- op = true;
- }
- else if (act.ProductType == "2")
- {
- op = true;
- }
- if(op)
- {
- PxcModels.MachineForMerNo posFor = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == act.MerNo) ?? new PxcModels.MachineForMerNo();
- PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId);
- if (pos != null)
- {
- // pos.ActivationState = 1;
- // pos.ActivationTime = DateTime.Now;
- if (pos.BrandId == 2)
- {
- pos.SeoKeyword = act.SeoTitle;
- db.SaveChanges();
- RedisDbconn.Instance.Set("PosMachinesTwo:" + pos.Id, pos);
- RedisDbconn.Instance.Set("PosMachinesTwo:" + pos.PosSn, pos);
- }
- // PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
- // if (merchant != null)
- // {
- // merchant.ActiveStatus = 1;
- // merchant.MerStandardDate = DateTime.Now;
- // db.SaveChanges();
- // RedisDbconn.Instance.Set("PosMerchantInfo:" + merchant.Id, merchant);
- // }
- ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
- if (edit != null)
- {
- edit.Status = 2;
- }
- // 激活奖励
- // ProfitHelper.Instance.StartListenActiveDo(pos);
- }
- pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId && m.ActivationState == 1);
- if (pos != null)
- {
- ActivateRecord edit = spdb.ActivateRecord.FirstOrDefault(m => m.Id == act.Id);
- if (edit != null)
- {
- edit.Status = 2;
- }
- }
- }
- }
- spdb.SaveChanges();
- spdb.Dispose();
- db.SaveChanges();
- db.Dispose();
- }
- }
- }
|