移动系统liao
2025-02-17 557c2711a3e103ebc3d0492344eca9730d5e92b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Repository.UnitOfWork;
using CoreCms.Net.Utility.Extensions;
using EC_SeckillInfo;
using Essensoft.Paylink.Alipay.Domain;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace CoreCms.Net.Task
{
    /// <summary>
    /// 自动关闭CY配送单,防止定位信息无效增长
    /// </summary>
    public class AutoCloseCYPeiSongJobs
    {
 
        private readonly ISqlSugarClient _CyDbClient;
 
 
        public AutoCloseCYPeiSongJobs(IUnitOfWork unitOfWork)
        {
            _CyDbClient = unitOfWork.GetDbClient().GetConnection(AppSettingsConstVars.CYDbDbID);
        }
        public async System.Threading.Tasks.Task Execute()
        {
          var ListData=  await  _CyDbClient.Queryable<CoreDeliverOrder>().Where(x => x.OrderState == CoreDeliverOrderType.Start).ToListAsync();
 
            await _CyDbClient.AsTenant().BeginTranAsync();
            try
            {
                foreach (var item in ListData)
                {
                  if(  item.StartTime.Value.AddDays(AppSettingsConstVars.CyDeliverOverTime.ToInt32OrDefault(5))<DateTime.Now)
                    {
                        item.OverTime= DateTime.Now;
                        item.OrderState = CoreDeliverOrderType.OverTime;
                        item.UpDataBy = "定时任务";
                        item.UpdataTime = DateTime.Now;
                        item.Remarke = "系统超时完结处理";
                      await   _CyDbClient.Updateable(item).ExecuteCommandAsync();
                    }
                }
                await _CyDbClient.AsTenant().CommitTranAsync();
            }
            catch (Exception)
            {
                await _CyDbClient.AsTenant().RollbackTranAsync();
                throw;
            }
        
 
        }
    }
}