Exemplo n.º 1
0
        private void Run()
        {
            try
            {
                var vehicleProduct = RebateDal.GetRebateApplyConfigList();
                int dataCount      = vehicleProduct.Count();
                int updateCount    = 0;//实际更新数据条数

                Logger.Info($"朋友圈返现 - 16元返现车品订单历史数据关联安装门店JOB,需要关联安装门店的16元返现数据有{dataCount}条");

                //关联安装门店
                Parallel.ForEach(vehicleProduct, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 4
                }, (item) =>
                {
                    var order = OrderServiceProxy.FetchOrderInfoByID(item.OrderId);
                    if (order == null || order.PKID <= 0)
                    {
                        Logger.Error($"RebateRepairHistoricalDataJob,订单号:{item.OrderId}不存在");
                    }
                    else
                    {
                        var orderType     = OrderServiceProxy.CheckOrderProductTypeByOrderId(item.OrderId);
                        int installShopId = 0;
                        if (orderType.Contains("车品订单"))
                        {
                            var relatedOrderIds = OrderServiceProxy.GetRelatedSplitOrderIDs(item.OrderId, SplitQueryType.Full);
                            relatedOrderIds.RemoveAll(q => q == item.OrderId);
                            foreach (var orderItem in relatedOrderIds)
                            {
                                var relateOrderType = OrderServiceProxy.CheckOrderProductTypeByOrderId(orderItem);
                                if (relateOrderType.Contains("服务订单"))
                                {
                                    installShopId = OrderServiceProxy.FetchOrderInfoByID(orderItem)?.InstallShopId ?? 0;
                                }
                                if (installShopId != 0)
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            installShopId = order.InstallShopId ?? 0;
                        }
                        item.InstallShopId = installShopId;
                    }
                });

                //批量更新安装门店
                updateCount = RebateDal.BatchUpdateInstallShopId(vehicleProduct.Split(200));

                Logger.Info($"朋友圈返现 - 16元返现车品订单历史数据关联安装门店JOB,实际关联安装门店的16元返现数据有{updateCount}条");
            }
            catch (Exception ex)
            {
                Logger.Error($"RebateRepairHistoricalDataJob -> Run -> error ,异常消息:{ex.Message},堆栈信息:{ex.StackTrace}");
            }
        }
        private void Run()
        {
            try
            {
                Guid rebate16ActivityId = new Guid("060ce1df-ca85-4789-88e2-a27440475f14");
                Guid rebate25ActivityId = new Guid("e6cfad24-4c2d-4d69-ae0a-f54907f447c9");
                Guid aikaActivityId     = new Guid("31491a47-75a8-4ddd-98d1-b62397698e43");
                Guid carHouseActivityId = new Guid("4a10b0d6-18de-4df3-a9fb-5371022beb51");

                List <string> sourceList = new List <string> {
                    "Rebate16", "Rebate25", "爱卡", "汽车之家"
                };
                int updateCount     = 0;                                                      //实际关联活动id的条数
                var rebateApplyData = RebateDal.GetRebateApplyConfigListBySource(sourceList); //需要关联活动id的返现申请数据

                Logger.Info($"朋友圈返现 - 返现申请数据关联活动ID JOB,需要关联活动ID的返现数据有{rebateApplyData.Count}条");

                //关联活动id
                Parallel.ForEach(rebateApplyData, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 4
                }, (item) =>
                {
                    if (item.Source.Trim() == "Rebate16")
                    {
                        item.ActivityId = rebate16ActivityId;
                    }
                    if (item.Source.Trim() == "Rebate25")
                    {
                        item.ActivityId = rebate25ActivityId;
                    }
                    if (item.Source.Trim() == "爱卡")
                    {
                        item.ActivityId = aikaActivityId;
                    }
                    if (item.Source.Trim() == "汽车之家")
                    {
                        item.ActivityId = carHouseActivityId;
                    }
                });

                updateCount = RebateDal.BatchUpdateActivityId(rebateApplyData.Split(200));

                Logger.Info($"朋友圈返现 - 返现申请数据关联活动ID JOB,实际关联活动ID的返现数据有{updateCount}条");
            }
            catch (Exception ex)
            {
                Logger.Error($"RebateUpdateActivityIdJob -> Run -> error ,异常消息:{ex.Message},堆栈信息:{ex.StackTrace}");
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            int totalCount = RebateDal.GetRebateApplyCount(SyncAll);

            int pageNum = (totalCount + MaxSyncCount - 1) / MaxSyncCount;

            Logger.Info($"同步返现申请技师ID开始.一共{totalCount}条记录.一共{pageNum}批次.");

            int maxPkid = 0;

            for (int index = 0; index <= pageNum; index++)
            {
                var applys = RebateDal.GetRebateApplys(MaxSyncCount, ref maxPkid, SyncAll);
                if (applys != null && applys.Any())
                {
                    var orderIds   = applys.Select(x => (long)x.OrderId).ToArray();
                    var orderTechs = DispatchTechByOrder(orderIds);

                    applys.ForEach(x =>
                    {
                        var orderTech = orderTechs?.FirstOrDefault(o => o.OrderId == x.OrderId);
                        if (orderTech == null)
                        {
                            // 取拆单订单来查派工技师
                            var splitOrderIds = OrderQueryServiceProxy.GetRelatedSplitOrderIds(x.OrderId);
                            orderTech         = GetSplitOrderTech(splitOrderIds);
                        }
                        x.TechId = orderTech?.TechId;
                    });

                    var models = applys.Where(x => x.TechId.HasValue)
                                 .Select(x => new PkidWithTechId
                    {
                        PKID   = x.PKID,
                        TechId = (int)x.TechId
                    }).ToList();

                    if (models.Any())
                    {
                        RebateDal.BatchUpdateTechIds(models);
                    }
                }

                Logger.Info($"结束同步第{index}批次,一共{pageNum}批次.MaxPkid:{maxPkid}");
            }

            Logger.Info($"同步返现申请技师ID结束.");
        }
Exemplo n.º 4
0
        private void Run()
        {
            try
            {
                var needUpdateCount = 0;                                    //需要更新审核状态的数据条数
                var updateCount     = 0;                                    //实际更新审核状态的条数

                var rebateApllyingList = RebateDal.GetApplyingRebateList(); //获取所有待审核的数据
                var rebateActivityList = RebateDal.GetRebateApplyPageConfigList(rebateApllyingList?.Select(p => p.ActivityId)?.Distinct()?.ToList());

                //筛选出线上返现活动下的返现数据
                var rebateApplyingNewList = rebateApllyingList.Where(p => rebateActivityList.Exists(q => q.ActivityId == p.ActivityId))?.ToList();

                if (rebateApplyingNewList != null && rebateApplyingNewList.Any())
                {
                    var payList = new List <WxPayStatusItem>();
                    var batchRebateApplyingList = rebateApplyingNewList.Split(499).ToList();
                    Parallel.For(0, batchRebateApplyingList.Count, new ParallelOptions()
                    {
                        MaxDegreeOfParallelism = 4
                    }, (i) =>
                    {
                        var payInfo = PayServiceProxy.QueryWxPayStatus("途虎朋友圈点赞返现", "WX_QIYEFUKUAN", batchRebateApplyingList[i]?.Select(p => p.OrderId.ToString())?.ToList());

                        lock (payList)
                        {
                            payList.AddRange(payInfo);
                        }
                    });

                    var paySuccessRebate = rebateApplyingNewList.Where(p => payList.Exists(m => m.OrderNo == p.OrderId.ToString() && (m.PayStatus == 1 || m.PayStatus == 2)))?.ToList();
                    needUpdateCount = paySuccessRebate == null ? 0 : paySuccessRebate.Count;
                    Logger.Info($"朋友圈返现 - 支付状态为1或者2的返现数据的审核状态更新为已支付 JOB,需要更新审核状态的返现数据有{needUpdateCount}条");

                    if (paySuccessRebate != null && paySuccessRebate.Any())
                    {
                        updateCount = RebateDal.UpdateRebateStatus(paySuccessRebate.Select(p => p.PKID).Split(50));
                    }
                    Logger.Info($"朋友圈返现 - 支付状态为1或者2的返现数据的审核状态更新为已支付 JOB,实际更新审核状态的返现数据有{updateCount}条");
                }
            }
            catch (Exception ex)
            {
                Logger.Error($"RebateUpdateStatusJob -> Run -> error ,异常消息:{ex.Message},堆栈信息:{ex.StackTrace}");
            }
        }