コード例 #1
0
        public Tuple <bool, string> InsertRebateConfig(RebateConfigModel data, string user)
        {
            var result = 0;
            var msg    = string.Empty;

            try
            {
                dbScopeManager.Execute(conn =>
                {
                    var existedData = DALRebateConfig.SelectRebateApplyConfigByParam(conn, data);
                    existedData     = existedData.Where(_ => String.Equals(_.Source, "爱卡") || String.Equals(_.Source, "汽车之家")).ToList();
                    if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 ||
                        existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0)
                    {
                        msg = "每个客户只能参与一次(包含手机号、订单号、微信号)均视为同一客户";
                    }
                    else
                    {
                        data.RebateMoney = 58M;
                        data.Status      = Status.Applying;
                        result           = DALRebateConfig.InsertRebateConfig(conn, data);
                    }
                });
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            InsertLog(result.ToString(), "InsertRebateConfig", result > 0 ? "添加成功" : "添加失败", $"PKID:{result.ToString()},Status:Applying", string.Empty, string.Empty, user);
            return(Tuple.Create(result > 0, msg));
        }
コード例 #2
0
        public Tuple <bool, string> InsertRebateConfig(RebateConfigModel data, string user)
        {
            var result = 0;
            var msg    = string.Empty;

            try
            {
                dbScopeManager.CreateTransaction(conn =>
                {
                    var existedData = DALRebateConfig.SelectRebateApplyConfigByParam(conn, data);

                    if (String.Equals(data.Source, "Rebate25"))
                    {
                        existedData = existedData.Where(_ => String.Equals(_.Source, "Rebate25")).ToList();
                        if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 ||
                            existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0)
                        {
                            data.Remarks += "  重复返现";
                        }
                        data.RebateMoney   = 25M;
                        data.Status        = Status.Complete;
                        data.RebateTime    = DateTime.Now;
                        data.InstallShopId = OrderService.FetchOrderByOrderId(data.OrderId)?.InstallShopId ?? 0;
                        data.PKID          = DALRebateConfig.InsertRebateConfig(conn, data);
                        if (data.PKID > 0 && data.ImgList != null && data.ImgList.Any())
                        {
                            foreach (var item in data.ImgList)
                            {
                                DALRebateConfig.InsertRebateImgConfig(conn, data.PKID, item.ImgUrl, ImgSource.UserImg, string.Empty);
                            }
                        }
                        result = data.PKID;
                    }
                    else
                    {
                        existedData = existedData.Where(_ => String.Equals(_.Source, "爱卡") || String.Equals(_.Source, "汽车之家")).ToList();
                        if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 ||
                            existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0)
                        {
                            msg = "每个客户只能参与一次(包含手机号、订单号、微信号)均视为同一客户";
                        }
                        else
                        {
                            data.RebateMoney   = 58M;
                            data.Status        = Status.Applying;
                            data.InstallShopId = OrderService.FetchOrderByOrderId(data.OrderId)?.InstallShopId ?? 0;
                            result             = DALRebateConfig.InsertRebateConfig(conn, data);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            InsertLog(result.ToString(), "InsertRebateConfig", result > 0 ? "添加成功" : "添加失败", $"PKID:{result.ToString()},Status:Applying", string.Empty, string.Empty, user);
            return(Tuple.Create(result > 0, msg));
        }
コード例 #3
0
        public Tuple <bool, string> UpdateStatus(int pkid, Status status, string refusalReason, int pushBatchId, string user)
        {
            var result = false;
            var msg    = string.Empty;

            try
            {
                if (status == Status.Approved || status == Status.Unapprove)
                {
                    dbScopeManager.CreateTransaction(conn =>
                    {
                        var data = DALRebateConfig.SelectRebateConfigByPKID(conn, pkid);
                        if (status == Status.Approved)
                        {
                            var existedData = DALRebateConfig.SelectRebateApplyConfigByParam(conn, data);
                            if (String.Equals(data.Source, "Rebate25"))
                            {
                                existedData = existedData.Where(_ => String.Equals(_.Source, "Rebate25")).ToList();
                            }
                            else
                            {
                                existedData = existedData.Where(_ => String.Equals(_.Source, "爱卡") || String.Equals(_.Source, "汽车之家")).ToList();
                            }
                            if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 ||
                                existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0)
                            {
                                msg = "每个客户只能参与一次(包含手机号、订单号、微信号)均视为同一客户";
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(data.OpenId))
                                {
                                    if (data.Status == Status.Applying)
                                    {
                                        if (String.Equals(data.Source, "爱卡") || String.Equals(data.Source, "汽车之家"))
                                        {
                                            result = DALRebateConfig.UpdateStatusForCompleteV2(conn, pkid) > 0;
                                        }
                                        else
                                        {
                                            var getResult = SendRedBag(new WxSendRedBagRequest()
                                            {
                                                OrderNo = data.OrderId.ToString(),
                                                OpenId  = data.OpenId,
                                                PayWay  = "WX_QIYEFUKUAN",
                                                Money   = 2500M, //返现25元 单位:分
                                                Channel = "途虎朋友圈点赞返现",
                                                Remark  = "途虎25元集赞已返到零钱;参加58元发帖返现请添加微信号:tuhu24咨询。"
                                            });
                                            if (getResult.Item1)
                                            {
                                                var pushResult = PushService.PushWechatInfoByBatchId(3383, new PushTemplateLog()
                                                {
                                                    Target = data.OpenId
                                                });
                                                InsertLog(pkid.ToString(), "PushWechatInfo", pushResult ? "消息推送成功" : "消息推送失败", $"BatchId:{3383}", string.Empty, string.Empty, user);
                                                result = DALRebateConfig.UpdateStatusForCompleteV2(conn, pkid) > 0;
                                            }

                                            msg = getResult.Item2 ?? "返现失败";
                                            InsertLog(pkid.ToString(), "SendRedBag", getResult.Item1 ? "返现成功" : msg, $"OpenId:{data.OpenId},Money:{decimal.Parse("25.00")}", string.Empty, string.Empty, user);
                                        }
                                    }
                                    else
                                    {
                                        msg = $"审核状态异常,BeforeValue:{data.Status.ToString()},AfterValue:{status.ToString()}";
                                    }
                                }
                                else
                                {
                                    result = DALRebateConfig.UpdateStatus(conn, pkid, Status.Approved) > 0;
                                }
                            }
                        }
                        else
                        {
                            result = DALRebateConfig.UpdateStatus(conn, pkid, Status.Unapprove, refusalReason) > 0;
                            if (!string.IsNullOrEmpty(data.OpenId) && result && pushBatchId > 0 && data.Status == Status.Applying)
                            {
                                var pushResult = PushService.PushWechatInfoByBatchId(pushBatchId, new PushTemplateLog()
                                {
                                    Target = data.OpenId
                                });
                                InsertLog(pkid.ToString(), "PushWechatInfo", pushResult ? "消息推送成功" : "消息推送失败", $"BatchId:{pushBatchId}", string.Empty, string.Empty, user);
                            }
                            else
                            {
                                msg = $"审核状态异常,BeforeValue:{data.Status.ToString()},AfterValue:{status.ToString()}";
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                msg = "服务异常";
                logger.Error(ex);
            }
            InsertLog(pkid.ToString(), "UpdateStatus", result ? "审核成功" : msg, $"PKID:{pkid.ToString()},Status:{status.ToString()}", string.Empty, string.Empty, user);
            return(Tuple.Create(result, msg));
        }