예제 #1
0
        public Respbase <dynamic> GetConfig(ReqConfig req)
        {
            PXinContext db        = HttpContext.Current.GetDbContext <PXinContext>();
            var         predicate = db.CreatePredicate <TappConfig>();

            predicate = predicate.And(c => c.Sid == req.Sid);
            //if (req.Updatetime.HasValue)
            //{
            //  predicate = predicate.And(c => c.Updatetime >= req.Updatetime.Value);
            //}
            List <TappConfig>            tappConfigs = db.TappConfigSet.AsNoTracking().Where(predicate).ToList();
            dynamic                      configData  = new ExpandoObject();
            IDictionary <string, object> dict        = configData as IDictionary <string, object>;
            List <TappH5Config>          h5Configs   = db.TappH5ConfigsSet.ToList();

            if (h5Configs != null && h5Configs.Count > 0)
            {
                dict.Add("h5config", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(h5Configs))));
            }

            if (tappConfigs.Count > 0)
            {
                foreach (var item in tappConfigs)
                {
                    if (req.Client == 3 && item.Propertyname.Equals("inviteurl", StringComparison.OrdinalIgnoreCase))
                    {
                        //ios 商店
                        dict.Add(item.Propertyname, "");
                    }
                    else
                    {
                        if (item.Propertyname == "FeeRules")
                        {
                            string[] rulesAttr = item.Propertyvalue.Split('-');
                            dict.Add("updatetime", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"));
                            dict.Add("wordpayunit", rulesAttr[0]);
                            dict.Add("picpayunit", rulesAttr[1]);
                            dict.Add("voicepayunit", rulesAttr[2]);
                            dict.Add("emojipayunit", rulesAttr[3]);
                            dict.Add("mappayunit", rulesAttr[4]);
                            dict.Add("sVideopayunit", rulesAttr[5]);
                            dict.Add("vCallpayunit", rulesAttr[6]);
                            dict.Add("videopayunit", rulesAttr[7]);
                            dict.Add("emoticonpayunit", rulesAttr[8]);
                            //语音通话: vCallPayUnit   小视频:sVideoPayUnit  视频通话:videoPayUnit
                        }
                        dict.Add(item.Propertyname, string.IsNullOrEmpty(item.Propertyvalue) ? null : Convert.ToBase64String(Encoding.UTF8.GetBytes(item.Propertyvalue)));
                    }
                }
                return(new Respbase <dynamic> {
                    Data = configData
                });
            }
            else
            {
                return(new Respbase <dynamic> {
                    Result = 1, Message = "成功"
                });
            }
        }
예제 #2
0
        public Respbase <List <MySvcDto> > GetMySvc(Reqbase req)
        {
            // tblc_centcard
            PXinContext db    = HttpContext.Current.GetDbContext <PXinContext>();
            var         query = from tc in db.TblcCentcardSet
                                where tc.Usenodeid == req.Nodeid && tc.Status == 1 && tc.Areaid == "1"
                                orderby tc.Createdtime descending
                                select new MySvcDto
            {
                Amount = (decimal)tc.Amount,
                Cardno = tc.Cardno,
                Areaid = tc.Areaid,
            };
            var result = query.ToList();

            if (result != null)
            {
                return(new Respbase <List <MySvcDto> > {
                    Data = result, Result = 1, Message = "成功"
                });
            }
            return(new Respbase <List <MySvcDto> > {
                Result = -1, Message = "未找到数据"
            });
        }
예제 #3
0
        /// <summary>
        /// 识别身份证照片
        /// </summary>
        public Respbase <IdentCard> IdCardPicRecognise(int imageActionType, string fullFileName)
        {
            PXinContext db = HttpContext.Current.GetDbContext <PXinContext>();

            IdCardPicRecognise picRec = new IdCardPicRecognise();
            IdentResult        result = picRec.Regcognise(fullFileName);

            if (result != null &&
                result.Success &&
                result.cards != null &&
                result.cards.Length >= 1)
            {
                if (imageActionType == 1 && (result.cards[0].side != "front" ||
                                             string.IsNullOrEmpty(result.cards[0].id_card_number) || result.cards[0].id_card_number.Length != 18 ||
                                             !CheckCard18(result.cards[0].id_card_number) ||
                                             string.IsNullOrEmpty(result.cards[0].name) || result.cards[0].name.Length < 2))
                {
                    return(new Respbase <IdentCard> {
                        Message = "身份证正面识别错误,请重新上传", Result = 0
                    });
                }
                else if (imageActionType == 2 && (result.cards[0].side != "back" ||
                                                  !IsValidDate(result.cards[0].valid_date)))
                {
                    return(new Respbase <IdentCard> {
                        Message = "身份证背面识别错误,请重新上传", Result = 0
                    });
                }
                else
                {
                    TzcIdcardrecLog recogniseLog = new TzcIdcardrecLog
                    {
                        Pic       = System.IO.Path.GetFileName(fullFileName),
                        Recresult = JsonConvert.SerializeObject(result)
                    };
                    db.TzcIdcardrecLogSet.Add(recogniseLog);
                    if (db.SaveChanges() <= 0)
                    {
                        return(new Respbase <IdentCard> {
                            Message = "保存识别结果失败", Result = 0
                        });
                    }
                    else
                    {
                        return(new Respbase <IdentCard> {
                            Message = "上传成功", Result = 1, Data = result.cards[0]
                        });
                    }
                }
            }
            else
            {
                return(new Respbase <IdentCard> {
                    Message = "上传照片识别失败,请重新上传清晰照片", Result = 0
                });
            }
        }
예제 #4
0
        public Respbase CheckVerificationCode(ReqVerificationCode req)
        {
            PXinContext db      = HttpContext.Current.GetDbContext <PXinContext>();
            var         regCode = db.TssoRegcodeSet.Where(c => c.Regcode == req.Mobileno && c.Authcode == req.Code && c.Status == 0 && c.Codetype == 2 && c.Indate >= DateTime.Now).OrderByDescending(c => c.Id).FirstOrDefault();

            if (regCode == null)
            {
                return(new Respbase {
                    Result = -1, Message = "验证码不正确或者失效"
                });
            }
            return(new Respbase());
        }
예제 #5
0
        /// <summary>
        /// 获取身份证识别结果
        /// </summary>
        public IdentResult GetRecResult(string pic)
        {
            pic = System.IO.Path.GetFileName(pic);

            PXinContext db           = HttpContext.Current.GetDbContext <PXinContext>();
            var         idcardrecLog = db.TzcIdcardrecLogSet.FirstOrDefault(x => x.Pic == pic);

            if (idcardrecLog != null)
            {
                return(JsonConvert.DeserializeObject <IdentResult>(idcardrecLog.Recresult));
            }
            return(null);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        public void Execute()
        {
            using (var db = new PXinContext())
            {
                var pushList = from push in db.TpxinPushDataSet
                               join chat in db.TchatUserSet on push.Nodeid equals chat.Nodeid
                               join pushkey in db.TnetReginfoExtSet on push.Nodeid equals pushkey.Nodeid
                               where push.Expecttime < DateTime.Now && push.Status == 0 && chat.IsSysNotice == 1
                               select new
                {
                    ID             = push.Id,
                    Typeid         = push.Typeid,
                    Nodeid         = push.Nodeid,
                    Title          = push.Title,
                    Content        = push.Content,
                    Url            = push.Url,
                    GTClientid     = pushkey.Gtclientid,
                    DeviceToken    = pushkey.Devicetoken,
                    IsNoticeDetail = chat.IsNoticeDetail,
                };
                string content = "";
                foreach (var item in pushList)
                {
                    string cnt = item.Content;
                    if (item.IsNoticeDetail == 0)
                    {
                        cnt = "您有一条新消息";
                    }
                    content = JsonConvert.SerializeObject(new
                    {
                        Type    = "APonitOut",//((BusinessCategoryEnum)item.Typeid).ToString(),
                        Title   = item.Title,
                        Content = cnt,
                        Url     = item.Url.Replace("{sign}", GetQueryString(item.Nodeid))
                    });
                    facade.GtPush(item.Nodeid, item.GTClientid, item.DeviceToken, item.Title, content);
                    facade.AddMessage(db, item.Nodeid, item.Content, item.Url, item.Title);

                    var pushData = db.TpxinPushDataSet.FirstOrDefault(f => f.Id == item.ID);
                    pushData.Pushtime = DateTime.Now;
                    pushData.Status   = 1;
                    if (db.SaveChanges() < 0)
                    {
                        log.Info("修改推送状态失败:ID=" + pushData.Id);
                    }
                }
            }
        }
예제 #7
0
        public Respbase <List <MySvchisDto> > GetMySvchis(HisReq req)
        {
            // tblc_centcard_his
            PXinContext db    = HttpContext.Current.GetDbContext <PXinContext>();
            var         query = from tc in db.TblcCentcardSet
                                join th in db.TblcCentcardHisSet on tc.Idno equals th.Idno
                                join tr in db.TnetReginfoSet on th.Nodeid equals tr.Nodeid into trdata
                                from trf in trdata.DefaultIfEmpty()
                                where tc.Usenodeid == req.Nodeid || th.Opnodeid == req.Nodeid
                                orderby th.Createtime descending
                                select new MySvchisDto
            {
                Amount     = (decimal)tc.Amount,
                Typeid     = th.Typeid == 1 && th.Nodeid == req.Nodeid ? 4 : th.Typeid,
                Note       = th.Note,
                CreateTime = th.Createtime,
                Cardno     = tc.Cardno,
                AmountType = "SV",
                NodeCode   = trf.Nodecode
            };
            List <MySvchisDto> result = null;

            if (req.TypeId != -1)
            {
                if (req.TypeId == 0)
                {
                    result = query.Where(c => c.Typeid == 0 || c.Typeid == 2 || c.Typeid == 3 || c.Typeid == 4 || c.Typeid == 7 || c.Typeid == 8 || c.Typeid == 9 || c.Typeid == 10 || c.Typeid == 11).Skip((req.PageNum - 1) * req.PageSize).Take(req.PageSize).ToList();
                }
                else
                {
                    result = query.Where(c => c.Typeid == req.TypeId).Skip((req.PageNum - 1) * req.PageSize).Take(req.PageSize).ToList();
                }
            }
            else
            {
                result = query.Skip((req.PageNum - 1) * req.PageSize).Take(req.PageSize).ToList();
            }

            if (result != null)
            {
                return(new Respbase <List <MySvchisDto> > {
                    Data = result, Result = 1, Message = "成功"
                });
            }
            return(new Respbase <List <MySvchisDto> > {
                Result = -1, Message = "未找到数据"
            });
        }
예제 #8
0
        public Respbase <List <AreaCodeDto> > GetAreaCode(AreaCodeReq req)
        {
            PXinContext db     = HttpContext.Current.GetDbContext <PXinContext>();
            var         result = db.TnetAreacodeSet.OrderBy(p => p.Id).Select(p => new AreaCodeDto
            {
                Id         = p.Id,
                Areaname   = p.Areaname,
                Code       = p.Code,
                Commonuse  = p.Commonuse,
                Country    = p.Country,
                Createtime = p.Createtime,
                EnCountry  = p.EnCountry,
                Remarks    = p.Remarks
            }).ToList();

            return(new Respbase <List <AreaCodeDto> > {
                Data = result
            });
        }
예제 #9
0
        public Respbase <H5ConfigDto> GetH5Config(ReqH5Config req)
        {
            PXinContext db = HttpContext.Current.GetDbContext <PXinContext>();

            req.Name = req.Name.ToLower();
            TappH5Config h5Config = db.TappH5ConfigsSet.FirstOrDefault(c => c.Name == req.Name);

            if (h5Config != null)
            {
                var result = new H5ConfigDto();
                result.ChargeStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(h5Config)));
                result.Sign      = Common.Mvc.Md5.SignString(result.ChargeStr + AppConfig.AppSecurityString).ToUpper();
                return(new Respbase <H5ConfigDto> {
                    Data = result
                });
            }
            return(new Respbase <H5ConfigDto> {
                Data = null
            });
        }
예제 #10
0
 public ActionResult Index()
 {
     try
     {
         NameValueCollection nameValues = new NameValueCollection(HttpContext.Request.QueryString);
         int id = 0;
         int.TryParse(nameValues["id"], out id);
         nameValues.Remove("id");
         string jumpUrl = "";
         using (var db = new PXinContext())
         {
             var tnetUrlJump = db.TnetUrlJumpSet.FirstOrDefault(f => f.Id == id);
             if (tnetUrlJump == null)
             {
                 return(Json(new Respbase()
                 {
                     Result = -1, Message = "ID:" + id + "-无跳转链接"
                 }));
             }
             jumpUrl = tnetUrlJump.Rule;
             if (jumpUrl.Contains("{domain}"))
             {
                 jumpUrl = jumpUrl.Replace("{domain}", "localhost".Equals(HttpContext.Request.Url.Host, StringComparison.OrdinalIgnoreCase) ? "mall2.ckv-test.sulink.cn" : HttpContext.Request.Url.Host);
             }
             if (jumpUrl.Contains("{sign}"))
             {
                 string queryString = "";
                 foreach (var key in nameValues.AllKeys)
                 {
                     queryString += "&" + key + "=" + nameValues[key];
                 }
                 jumpUrl = jumpUrl.Replace("{sign}", queryString.Substring(1));
             }
         }
         return(Redirect(jumpUrl));
     }
     catch (Exception)
     {
         return(Redirect("http://.global.xiang-xin.net/err.html?type=1&msg=系统异常,请稍后再试"));
     }
 }
예제 #11
0
        /// <summary>
        /// 注册通知服务
        /// </summary>
        public static void Register()
        {
            Thread thread = new Thread(() =>
            {
                log.Info($"Register {nameof(PxinSerivce)} Success");
                while (true)
                {
                    manualResetEvent.WaitOne();
                    while (serviceQueue.TryDequeue(out UeServiceData data))
                    {
                        log.Info($"Dequeue:{data.ServiceType + "_" + data.Id}");
                        if (data.ServiceType == PxinServiceType.MsgDispatch)
                        {
                            new MsgDispatchService().Execute(data.Id);
                        }
                        else if (data.ServiceType == PxinServiceType.CommentDispath)
                        {
                            new CommentDispatchService().Execute(data.Id);
                        }
                        else
                        {
                            new NoticeService().Execute(data.Id);
                        }
                    }
                    manualResetEvent.Reset();
                }
            })
            {
                IsBackground = true
            };

            thread.Start();
            System.Timers.Timer timer = new System.Timers.Timer
            {
                Enabled  = true,
                Interval = AppConfig.TimedPushTimeInterval * 60 * 1000
            };
            timer.Elapsed += Push;
            timer.Start();

            //定时器检查通知失败的数据
            int period = AppConfig.TimedPushTimeInterval * 60 * 1000;

            timer1 = new System.Threading.Timer((obj) =>
            {
                log.Info("定时器回调");
                timer1.Change(Timeout.Infinite, Timeout.Infinite);
                try
                {
                    DateTime dtToday   = DateTime.Now;
                    DateTime dtYestDay = DateTime.Now.AddDays(-2);
                    using (PXinContext db = new PXinContext())
                    {
                        var hisIds = db.TpcnThirdPayhisSet.Where(x => x.Storequest != 2 && x.Createtime >= dtYestDay && x.Nextnotifytime < dtToday).Select(x => x.Hisid)
                                     .OrderByDescending(x => x).ToList();
                        foreach (int hisId in hisIds)
                        {
                            EnqueueNotice(Convert.ToInt32(hisId));
                        }
                    }
                }
                catch (Exception exp)
                {
                    log.Info(exp.ToString());
                }
                timer1.Change(period, period);
            }, null, period, period);

            timer1.Change(0, period);
        }
예제 #12
0
        private bool PaySuccessNotice(PayHisDto apiueHis)
        {
            PXinContext ctx = HttpContext.GetDbContext <PXinContext>();

            //付款成功状态
            int          oid      = Convert.ToInt32(apiueHis.Orderno);
            TnetUepayhis uePayHis = ctx.TnetUepayhisSet.FirstOrDefault(c => c.Id == oid);

            if (uePayHis == null)
            {
                log.Info("orderid:" + apiueHis.Orderno + "不存在");
                Response.Write("fail");
                return(false);
            }
            if (uePayHis.Status != 0)
            {
                log.Info("orderid:" + apiueHis.Orderno + "已处理");
                return(false);
            }
            uePayHis.Ordernoue = apiueHis.OrdernoUE;
            //uePayHis.Status = 1;
            //if (ctx.SaveChanges() <= 0)
            //{
            //    log.Info("orderid=" + uePayHis.Id + ",更新订单状态失败");
            //    Response.Write("fail");
            //    return false;
            //}
            if (uePayHis.Typeid == 20001)
            {
                //13-充值V点
                FriFacade facade = new FriFacade();
                bool      result = facade.ChargeVDian_Notice(uePayHis);
                if (!result)
                {
                    log.Info("充值V点失败,原因" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20002)
            {
                //5-充值商新增代理人
                FbApFacade facade = new FbApFacade();
                bool       result = facade.AddUserJxs_Notice(uePayHis).Result;
                if (!result)
                {
                    log.Info("充值商新增代理人失败,原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20003 || uePayHis.Typeid == 20007)
            {
                //1-兑换充值码(进货)
                FbApFacade facade = new FbApFacade();
                bool       result = facade.ExChangeRechargeCode_Notice(uePayHis).Result;
                if (!result)
                {
                    log.Info("兑换充值码失败,原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20004)
            {
                //开通专属账号
                var facade = new ExchangeFacade();
                var result = facade.OpenInfo_Notice(uePayHis);
                if (!result)
                {
                    log.Info("开通专属账号失败原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20005)
            {
                //18-充值商续费
                FbApFacade facade = new FbApFacade();
                bool       result = facade.Renew_Notice(uePayHis).Result;
                if (!result)
                {
                    log.Info("充值商续费失败,原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20006)
            {
                //ue转账到相信
                var facade = new ExchangeFacade();
                var result = facade.UeTransferInDos_Notice(uePayHis);
                if (!result)
                {
                    log.Info("ue转账到相信失败原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20008)
            {
                //十月送手机活动
                var facade = new ActivityFacade();
                var result = facade.OctoberActivityDosUEPay_Notice(uePayHis);
                if (!result)
                {
                    log.Info("十月送手机活动支付服务费失败原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else if (uePayHis.Typeid == 20010)
            {
                //代开充值商
                var facade = new FbApFacade();
                var result = facade.OpenCzs_Notice(uePayHis).Result;
                if (!result)
                {
                    log.Info("代开充值商支付服务费失败,原因:" + facade.PromptInfo.Message);
                }
                return(result);
            }
            else
            {
                //未知业务类型
                log.Info("未知业务类型:" + JsonConvert.SerializeObject(apiueHis));
                return(false);
            }
        }
예제 #13
0
        public ActionResult Success()
        {
            string content = ApiAuth.GetRequestContent();

            log.Info("PayorderNotice:" + content);
            PXinContext     ctx      = HttpContext.GetDbContext <PXinContext>();
            TpcnUepayconfig ueConfig = ctx.TpcnUepayconfigSet.FirstOrDefault(c => c.Id == 1);

            if (ueConfig == null)
            {
                log.Info("获取UE支付配置失败");
                return(Content("failed"));
            }
            PayHisDto payHis = new PayHisDto();

            if (Request.Url.ToString().IndexOf("localhost") > 0)
            {
                #region 测试注释
                payHis.Paystatus = 1;//测试默认为1付款成功
                payHis.Orderno   = Request["orderno"];
                payHis.OrdernoUE = Request["orderue"];
                #endregion
            }
            else
            {
                #region 测试注释
                if (!ApiAuth.Verify(ueConfig.Accesssecret))
                {
                    log.Info("签名验证失败");
                    return(Content("failed"));
                }
                try
                {
                    payHis = UeApi.RequestDeserializeObject <PayHisDto>();
                }
                catch (Exception err)
                {
                    log.Info(err);
                    return(Content("failed"));
                }
                #endregion
            }
            if (payHis == null || string.IsNullOrEmpty(payHis.Orderno) || string.IsNullOrEmpty(payHis.OrdernoUE))
            {
                log.Info("订单数据异常:" + JsonConvert.SerializeObject(payHis));
                return(Content("fail"));
            }
            if (payHis.Paystatus == 1)
            {
                //付款成功状态
                if (!PaySuccessNotice(payHis))
                {
                    return(Content("fail"));
                }
            }
            else
            {
                //其它状态不处理
                log.Info("订单数据支付状态不等于1:" + JsonConvert.SerializeObject(payHis));
            }
            return(Content("OK"));
        }
예제 #14
0
        /// <summary>
        /// 上传文件
        /// </summary>
        private Respbase <IdCardUploadFileDto> UploadImg(ReqUploadFile req)
        {
            FileService fileService = new FileService();

            if (!fileService.SaveFile(req))
            {
                return(new Respbase <IdCardUploadFileDto> {
                    Result = -1, Message = "保存文件失败", Data = null
                });
            }

            if (req.ImageActionType == FileActionType.身份证正面图片 || req.ImageActionType == FileActionType.身份证反面图片)
            {
                IdCardService idCardService = new IdCardService();
                var           res           = idCardService.IdCardPicRecognise((int)req.ImageActionType, fileService.PhysicsFilePath);
                if (res.Result == 1)
                {
                    return(new Respbase <IdCardUploadFileDto>
                    {
                        Result = res.Result,
                        Data = new IdCardUploadFileDto
                        {
                            Url = fileService.FilePath,
                            IdentCard = res.Data
                        },
                        Message = res.Message
                    });
                }
                return(new Respbase <IdCardUploadFileDto> {
                    Result = res.Result, Data = new IdCardUploadFileDto {
                        Url = fileService.Image2FilePath,
                    }, Message = res.Message
                });
            }

            if (req.ImageActionType == FileActionType.驾驶证行驶证)
            {
                string photoPhysicalPath = FileService.GetPhysicsFilePath(fileService.FilePath);
                (bool success, string message, object result) = ScanLicense.GetInstance(LicenseTypeEnum.Driver).Execute(new ExecuteEntity()
                {
                    PhotoPhysicalPath = photoPhysicalPath
                });
                if (!success)
                {
                    return(new Respbase <IdCardUploadFileDto> {
                        Result = -1, Message = "识别驾驶证失败", Data = new IdCardUploadFileDto {
                            Url = fileService.Image2FilePath
                        }
                    });
                }
                DriverResult driResult    = ((DriverResp)result).words_result;
                PXinContext  db           = HttpContext.Current.GetDbContext <PXinContext>();
                var          tnetNodeInfo = db.TnetNodeinfoSet.FirstOrDefault(w => w.Nodeid == req.Nodeid);
                if (tnetNodeInfo == null)
                {
                    return(new Respbase <IdCardUploadFileDto> {
                        Result = -1, Message = "用户未进行身份认证", Data = new IdCardUploadFileDto {
                            Url = fileService.Image2FilePath
                        }
                    });
                }
                if (tnetNodeInfo.Name.Trim() != driResult.姓名.words.Trim() || tnetNodeInfo.Idcardno.Trim() != driResult.证号.words.Trim())
                {
                    return(new Respbase <IdCardUploadFileDto> {
                        Result = -1, Message = "驾驶证信息与身份证信息不一致", Data = new IdCardUploadFileDto {
                            Url = fileService.Image2FilePath
                        }
                    });
                }
            }

            return(new Respbase <IdCardUploadFileDto> {
                Data = new IdCardUploadFileDto {
                    Url = fileService.Image2FilePath
                }
            });
        }
예제 #15
0
        /// <summary>
        /// ue支付(调用ue客户端时使用)
        /// </summary>
        /// <param name="db">数据库上下文</param>
        /// <param name="userInfo">支付用户</param>
        /// <param name="uePayConfigTypeId">业务类型</param>
        /// <param name="currencyType">货币类型</param>
        /// <param name="amount">支付金额</param>
        /// <param name="uePayHisTypeId">业务类型</param>
        /// <param name="businessParams">业务相关参数</param>
        /// <param name="body">商品描述</param>
        /// <param name="subject">商品名称</param>
        /// <param name="freezeids">冻结ID列</param>
        /// <param name="pNodeId">父NodeId(eg:经销商支付时就需要要获取它的上级专营商的NodeId)</param>
        /// <returns></returns>
        public static async Task <DosWithUePayDto> DosWithUePay(
            PXinContext db, TnetReginfo userInfo,
            int uePayConfigTypeId, CurrencyType currencyType, decimal amount, int uePayHisTypeId, string businessParams,
            string body, string subject,
            string freezeids = "", int pNodeId = 0)
        {
            var ueConfig = await db.TpcnUepayconfigSet.FirstOrDefaultAsync(p => p.Typeid == uePayConfigTypeId);

            if (ueConfig == null)
            {
                log.Info("获取UE支付配置失败");
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "获取UE支付配置失败"
                });
            }
            Currency     currency = new Currency(currencyType, amount);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis {
                Typeid = uePayHisTypeId, Nodeid = userInfo.Nodeid, BusinessParams = businessParams, Amount = total, Unit = unit, Freezeids = freezeids, Createtime = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            var falg = await db.SaveChangesAsync() > 0;

            if (!falg)
            {
                log.Info("生成UE订单失败,NodeId=:" + uePayHis.Nodeid);
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "生成UE订单失败"
                });
            }
            var recvNodeCode = "";

            if (pNodeId > 0)//代理人支付时,获取充值商帐号(收钱帐号),向它支付
            {
                var parentUserInfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    RegInfoKey = pNodeId.ToString()
                });
                if (parentUserInfo == null)
                {
                    log.Info("获取上级用户信息失败,NodeId=:" + uePayHis.Nodeid);
                    return(new DosWithUePayDto()
                    {
                        IsSuccess = false, Message = "获取上级用户信息失败"
                    });
                }
                recvNodeCode = parentUserInfo.Nodecode;
            }
            var chargeDto = new ChargeDto
            {
                businesstypeid = uePayHisTypeId,
                amount         = total,
                unit           = unit,
                body           = body,
                subject        = subject,
                orderno        = uePayHis.Id.ToString(),
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss"),
                paycode        = ueConfig.Paycode,
                recvfromid     = pNodeId > 0 ? 6 : 0,
                recvaccount    = recvNodeCode,
                noticeurl      = Common.Facade.Helper.DomainUrl + "/UENotice/Success"
            };
            var chargeStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(chargeDto)));

            return(new DosWithUePayDto()
            {
                IsSuccess = true, ChargeStr = chargeStr, OrderNo = chargeDto.orderno
            });
        }
예제 #16
0
        public Respbase <UserInfoDto> GetUserInfo(ReqUser userinfo)
        {
            userinfo.Nodecode = userinfo.Nodecode.Trim();
            ////方法一,自己写SQL
            //UETokenContext db = HttpContext.Current.GetDbContext<UETokenContext>();
            //string sql = string.Format(@"select nodeid
            //            ,substr(nodecode,0,2)||'**'||substr(nodecode,7) nodecode
            //            ,substr(nodename,0,1)||'**' nodename
            //            ,case when mobileno is not null then substr(mobileno,0,3)||'****'||substr(mobileno,8) else '' end mobileno
            //            ,case when email is not null then substr(email,0,1)||'**'||substr(email,instr(email,'@')) else '' end email
            //            from tnet_reginfo
            //            where nodecode ={0}
            //            or mobileno = {0}
            //            or email = {0}", SqlHelper.ToSQLParamStr(userbaseinfo.Nodecode));
            //var reg = db.SqlQuery<UserInfo>(sql).FirstOrDefault();
            //if (reg == null)
            //    return Json(new Respbase<UserInfo> { Result = -1, Message = "用户不存在", Data = null });

            //return Json(new Respbase<UserInfo> { Data = reg });

            //方法二,通过LINQ获取数据,然后自己做判断
            PXinContext db           = HttpContext.Current.GetDbContext <PXinContext>();
            var         tnet_reginfo = db.TnetReginfoSet.Where(c => c.Nodecode == userinfo.Nodecode || c.Mobileno == userinfo.Nodecode || c.Email == userinfo.Nodecode).FirstOrDefault();

            if (tnet_reginfo != null)
            {
                string nodeNameFilter = Helper.FilterChar(tnet_reginfo.Nodename);
                //获取到主账号
                return(new Respbase <UserInfoDto>
                {
                    Data = new UserInfoDto
                    {
                        Nodeid = tnet_reginfo.Nodeid,
                        Nodecode = tnet_reginfo.Nodecode.Substring(0, 2) + "**" + (tnet_reginfo.Nodecode.Length <= 6 ? "" : tnet_reginfo.Nodecode.Substring(6)),
                        Nodename = nodeNameFilter.Length > 0 ? nodeNameFilter.Substring(0, 1) + "**" : "",
                        Mobileno = tnet_reginfo.Mobileno == null ? "" : tnet_reginfo.Mobileno.Substring(0, 3) + "****" + (tnet_reginfo.Mobileno.Length <= 7 ? "" : tnet_reginfo.Mobileno.Substring(7)),
                        Email = tnet_reginfo.Email == null ? "" : tnet_reginfo.Email.Substring(0, 1) + "**" + (tnet_reginfo.Email.IndexOf("@") <= 0 ? "" : tnet_reginfo.Email.Substring(tnet_reginfo.Email.IndexOf("@")))
                    }
                });
            }
            //没找到主账号
            if (userinfo.Purseid == 0)
            {
                return(new Respbase <UserInfoDto> {
                    Result = -1, Message = "用户不存在", Data = null
                });
            }
            else
            {
                //purseid 大于0,进一步判断其子账号
                var tblc_user_purse_sub = db.TblcUserPurseSub2Set.Where(c => c.Pursecode == userinfo.Nodecode).FirstOrDefault();
                if (tblc_user_purse_sub == null)
                {
                    //没找到子账号
                    return(new Respbase <UserInfoDto> {
                        Result = -1, Message = "子账号不存在", Data = null
                    });
                }
                List <TblcUserPurse> userPurses = db.TblcUserPurseSet.Where(c => c.Purseid == tblc_user_purse_sub.Purseid || c.Purseid == userinfo.Purseid).ToList();
                if (userPurses == null || userPurses.Count != 2 ||
                    userPurses[0].Pursetype != userPurses[1].Pursetype ||
                    userPurses[0].Ownerid != userPurses[1].Ownerid ||
                    userPurses[0].Subid != userPurses[1].Subid ||
                    userPurses[0].Currencytype != userPurses[1].Currencytype)
                {
                    return(new Respbase <UserInfoDto> {
                        Result = -1, Message = "用户不存在", Data = null
                    });
                }
                //找到子账号
                return(new Respbase <UserInfoDto>
                {
                    Data = new UserInfoDto
                    {
                        Nodeid = tblc_user_purse_sub.Nodeid,
                        Nodecode = tblc_user_purse_sub.Pursecode,
                        Nodename = tblc_user_purse_sub.Pursename,
                        Mobileno = "",
                        Email = ""
                    }
                });
            }
        }