Exemplo n.º 1
0
        public ActionResult Index()
        {
            int aid = Context.GetRequestInt("aid", 0);

            ViewBag.appId = aid;
            PlatStore  store  = PlatStoreBLL.SingleModel.GetModelByAId(aid);
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            //用户提现账户
            PlatUserCash model = PlatUserCashBLL.SingleModel.GetModelByUserId(myCard.AId, myCard.UserId);

            if (model == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            //平台提现设置
            PlatDrawConfig drawConfig = PlatDrawConfigBLL.SingleModel.GetModelByAId(myCard.AId);

            if (drawConfig == null)
            {
                drawConfig = new PlatDrawConfig();
            }
            model.Fee = drawConfig.Fee;
            if (string.IsNullOrEmpty(model.Name))
            {
                model.Name = "未绑定";
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Config()
        {
            int aid = Context.GetRequestInt("aid", 0);

            ViewBag.appId = aid;
            PlatDrawConfig model = PlatDrawConfigBLL.SingleModel.GetModelByAId(aid);

            if (model == null)
            {
                model = new PlatDrawConfig();
            }
            return(View(model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveInfo(int aid = 0, PlatDrawConfig model = null)
        {
            _returnData = new Return_Msg();

            if (model == null)
            {
                _returnData.Msg = "无效数据";
                return(Json(_returnData));
            }


            PlatDrawConfig tempModel = PlatDrawConfigBLL.SingleModel.GetModelByAId(aid);

            if (tempModel == null)
            {
                tempModel = new PlatDrawConfig();
            }

            tempModel.CommandTime = model.CommandTime;
            tempModel.DrawCashWay = model.DrawCashWay;
            tempModel.Fee         = model.Fee;
            tempModel.MinMoney    = model.MinMoney;
            tempModel.UpdateTime  = DateTime.Now;

            if (tempModel.Id == 0)
            {
                tempModel.AId     = aid;
                tempModel.AddTime = DateTime.Now;
                _returnData.isok  = Convert.ToInt32(PlatDrawConfigBLL.SingleModel.Add(tempModel)) > 0;
            }
            else
            {
                _returnData.isok = PlatDrawConfigBLL.SingleModel.Update(tempModel);
            }
            _returnData.Msg = _returnData.isok ? "保存成功" : "保存失败";
            return(Json(_returnData));
        }
Exemplo n.º 4
0
        public ActionResult GetData()
        {
            Return_Msg returnData = new Return_Msg();
            int        aid        = Context.GetRequestInt("aid", 0);

            if (aid <= 0)
            {
                returnData.Msg = "参数错误";
                return(Json(returnData));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                returnData.Msg = "无效模板";
                return(Json(returnData));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(aid);

            if (store == null)
            {
                returnData.Msg = "无效店铺";
                return(Json(returnData));
            }
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                returnData.Msg = "无效用户数据";
                return(Json(returnData));
            }
            PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(store.BindPlatAid, myCard.UserId);

            if (userCash == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            PlatDrawConfig platDrawConfig = PlatDrawConfigBLL.SingleModel.GetModelByAId(store.BindPlatAid);

            if (platDrawConfig == null)
            {
                platDrawConfig = new PlatDrawConfig();
            }

            //总访问量
            int sumPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid);
            //店铺概况
            //当天订单
            int newOrderCount = PlatChildGoodsOrderBLL.SingleModel.GetTodayOrderCount(aid);
            //总订单
            int orderCount = PlatChildGoodsOrderBLL.SingleModel.GetOrderSum(aid);
            //会员人数
            int userCount = C_UserInfoBLL.SingleModel.GetCountByAppid(xcxrelation.AppId);
            //领券人数
            int couponCount = CouponLogBLL.SingleModel.GetUserCount(aid);
            //上次访问时间
            string visiteTime = RedisUtil.Get <string>(string.Format(PlatStatisticalFlowBLL._redis_PlatVisiteTimeKey, aid));
            //平台订单数
            int platOrderNum = PlatChildGoodsOrderBLL.SingleModel.GetPlatOrderNum(store.BindPlatAid, store.Id);
            //平台交易总额
            int platSumPrice = PlatChildGoodsOrderBLL.SingleModel.GetPlatOrderSumPrice(store.BindPlatAid, store.Id);
            //已提现金额
            int drawedCashPrice = userCash.UseCashTotal;
            //可提现金额
            int canDrawCashPrice = userCash.UseCash;
            //提现手续费
            int drawCashServer = platDrawConfig.Fee;

            DateTime nowTime = DateTime.Now;
            //访问量(PV)
            //当天,昨天,近七天,近30天,总累计
            int todayPV     = 0;
            int yeastodayPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-1).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            int sevenDayPV  = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-7).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            int thirthDayPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-30).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            //近30天访问趋势统计
            List <PlatStatisticalFlow> list = PlatStatisticalFlowBLL.SingleModel.GetListByAid(aid, nowTime.AddDays(-30).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            List <string> labels            = new List <string>();
            List <int>    datas             = new List <int>();

            if (list != null && list.Count > 0)
            {
                foreach (PlatStatisticalFlow item in list)
                {
                    labels.Add(item.RefDate);
                    datas.Add(item.VisitPV);
                }
            }

            returnData.dataObj = new
            {
                sumpv         = sumPV,
                newordercount = newOrderCount,
                usercount     = userCount,
                ordercount    = orderCount,
                couponcount   = couponCount,
                todaypv       = todayPV,
                yeastodaypv   = yeastodayPV,
                sevendaypv    = sevenDayPV,
                thirthdaypv   = thirthDayPV,
                labels        = labels,
                datas         = datas,
                visitetime    = visiteTime,

                platordernum       = platOrderNum,
                platsumprice       = (platSumPrice * 0.01).ToString("0.00"),
                drawedcashprice    = (drawedCashPrice * 0.01).ToString("0.00"),
                candrawcashprice   = (canDrawCashPrice * 0.01).ToString("0.00"),
                isopendistribution = userCash.IsOpenDistribution,
                drawcashserver     = (drawCashServer * 0.01) + "%",
            };

            return(Json(returnData));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 申请提现
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="id">提现账号id(PlatUserCash)</param>
        /// <param name="drawcashmoney">提现金额(分)</param>
        /// <returns></returns>
        public string ApplyDrawCash(int aid = 0, int id = 0, int drawcashmoney = 0)
        {
            TransactionModel tran = new TransactionModel();

            if (id <= 0)
            {
                return("id不能为0");
            }
            if (drawcashmoney <= 0)
            {
                return("提现金额不能为0");
            }

            PlatUserCash usercash = PlatUserCashBLL.SingleModel.GetModel(id);

            if (usercash == null)
            {
                return("提现账号");
            }
            if (usercash.DrawCashWay == (int)DrawCashWay.银行卡人工提现 && string.IsNullOrEmpty(usercash.AccountBank))
            {
                return("请完善提现账号");
            }
            if (usercash.UseCash < drawcashmoney)
            {
                return("可提现金额不足");
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(usercash.AId);

            if (xcxrelation == null)
            {
                return("提现平台已过期");
            }
            if (string.IsNullOrEmpty(xcxrelation.AppId))
            {
                return("提现平台还未上线");
            }
            PlatDrawConfig drawconfig = PlatDrawConfigBLL.SingleModel.GetModelByAId(usercash.AId);

            if (drawconfig == null)
            {
                return("平台还未开启提现");
            }
            if (string.IsNullOrEmpty(drawconfig.DrawCashWay))
            {
                return("平台未开通提现方式");
            }
            //判断是否支持该提现方式
            DrawCashWayItem tempway = drawconfig.DrawCashWayList.FirstOrDefault(f => f.IsOpen == 1 && f.DrawCashWay == usercash.DrawCashWay);

            if (tempway == null)
            {
                return("平台不支持该提现方式");
            }
            if (drawconfig.MinMoney > drawcashmoney)
            {
                return($"提现金额不能低于{drawconfig.MinMoneyStr}元");
            }
            PlatMyCard mycard = PlatMyCardBLL.SingleModel.GetModelByUserId(usercash.UserId, usercash.AId);

            if (mycard == null)
            {
                return("无效提现账号");
            }

            int           serviceFee       = Convert.ToInt32((drawconfig.Fee * 0.01 * 0.01) * drawcashmoney);
            string        partner_trade_no = WxPayApi.GenerateOutTradeNo();
            DrawCashApply apply            = new DrawCashApply()
            {
                Aid              = usercash.AId,
                appId            = xcxrelation.AppId,
                partner_trade_no = partner_trade_no,
                userId           = usercash.UserId,
                applyMoney       = drawcashmoney,
                serviceMoney     = serviceFee,
                cashMoney        = drawcashmoney - serviceFee,
                useCash          = (usercash.UseCash - drawcashmoney).ToString(),
                BeforeApplyMoney = usercash.UseCash,
                AddTime          = DateTime.Now,
                remark           = "平台字模板店铺申请提现",
                hostIP           = WebHelper.GetIP(),
                state            = 0,
                drawState        = (int)DrawCashState.未开始提现,
                applyType        = (int)DrawCashApplyType.平台店铺提现,
                account          = usercash.DrawCashWay == (int)DrawCashWay.微信提现 ? mycard.Phone : usercash.AccountBank,
                accountName      = usercash.DrawCashWay == (int)DrawCashWay.微信提现 ? mycard.Name : usercash.Name,
                drawCashWay      = usercash.DrawCashWay,
            };

            tran.Add(base.BuildAddSql(apply));

            usercash.UseCash    = usercash.UseCash - drawcashmoney;
            usercash.UpdateTime = DateTime.Now;
            tran.Add(PlatUserCashBLL.SingleModel.BuildUpdateSql(usercash, "UseCash,UpdateTime"));

            if (!base.ExecuteTransactionDataCorect(tran.sqlArray))
            {
                return("申请提现失败");
            }
            return("");
        }