public Respbase <UePayCallDto> OctoberActivityDosUEPrepare(OctoberActivityDosUEPrepareReq req)
        {
            var facade = new ActivityFacade();

            if (facade.OctoberActivityDosUEPrepare(req))
            {
                return(new Respbase <UePayCallDto> {
                    Data = facade.UEPayCallDto, Message = facade.PromptInfo.Message, Result = facade.PromptInfo.Result
                });
            }
            return(new Respbase <UePayCallDto> {
                Result = facade.PromptInfo.Result, Message = facade.PromptInfo.Message, Data = null
            });
        }
Beispiel #2
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        public bool OctoberActivityDosUEPrepare(OctoberActivityDosUEPrepareReq req)
        {
            log.Info($"十月送手机活动支付服务费,nodeid={req.Nodeid},服务费={req.Price}");
            var activity = db.TpxinActivitySet.FirstOrDefault(p => p.Id == req.ActivityId);

            if (activity == null)
            {
                Alert("找不到活动信息,请重试");
                return(false);
            }
            DateTime now = DateTime.Now;

            if (AppConfig.IsUseSms && !(now >= activity.PayStarttime && now <= activity.PayEndtime))
            {
                Alert("缴费时间已过期");
                return(false);
            }
            string[] ids = req.DataId.Split('_');
            if (req.PayType == 2)
            {
                if (ids.Length != 1)
                {
                    Alert("只能支付一个");
                    return(false);
                }
                var cnt = db.TpxinOctoberActivitySet.Count(x => x.Nodeid == req.Nodeid && x.Transferids != null && x.ActivityId == req.ActivityId);
                if (cnt > 0)
                {
                    Alert("已经存在缴过费的记录,只能支付一个");
                    return(false);
                }
            }
            foreach (string sid in ids)
            {
                int tid    = Convert.ToInt32(sid);
                var entity = db.TpxinOctoberActivitySet.FirstOrDefault(x => x.Id == tid);
                if (req.PayType == 1)
                {
                    if (!string.IsNullOrEmpty(entity.Ptransferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
                if (req.PayType == 2)
                {
                    if (!string.IsNullOrEmpty(entity.Transferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
            }

            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);

            TpcnUepayconfig ueConfig = db.TpcnUepayconfigSet.FirstOrDefault(a => a.Typeid == 1);

            if (ueConfig == null || ueConfig.Id <= 0)
            {
                Alert("获取UE支付配置失败");
                return(false);
            }
            Currency     currency = new Currency(CurrencyType.DOS_矿沙, req.Price);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis
            {
                Typeid         = 20008,
                Nodeid         = regInfo.Nodeid,
                BusinessParams = 10 + "|" + req.DataId + "|" + req.PayType + "|" + req.Nodeid + "|" + req.Price.ToString(),
                Amount         = total,
                Unit           = unit,
                Freezeids      = "",
                Createtime     = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("生成UE订单失败");
                return(false);
            }
            var charge = new ChargeDto
            {
                businesstypeid = 20008,
                amount         = total,
                unit           = unit,
                body           = "十月送手机活动支付服务费",
                subject        = "十月送手机活动支付服务费",
                orderno        = uePayHis.Id.ToString(),
                paycode        = ueConfig.Paycode,
                noticeurl      = Helper.DomainUrl + "/UENotice/Success",
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss")
            };

            UEPayCallDto         = new UePayCallDto();
            UEPayCallDto.Charge  = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(charge)));
            UEPayCallDto.sign    = Md5.SignString(UEPayCallDto.Charge + AppConfig.AppSecurityString);
            UEPayCallDto.orderno = uePayHis.Id.ToString();
            return(true);
        }