Ejemplo n.º 1
0
        // GET:
        public ActionResult Index()
        {
            int aid = Context.GetRequestInt("appId", 0);

            if (aid <= 0)
            {
                aid = Context.GetRequestInt("aid", 0);
            }
            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)
            {
                model            = new PlatUserCash();
                model.AddTime    = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                model.UserId     = myCard.UserId;
                model.AId        = myCard.AId;
                model.Id         = Convert.ToInt32(PlatUserCashBLL.SingleModel.Add(model));
            }
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            RedisUtil.Set <string>(string.Format(PlatStatisticalFlowBLL._redis_PlatVisiteTimeKey, aid), nowTime);
            return(View());
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 平台审核提现申请记录
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="state"></param>
        /// <param name="appId"></param>
        /// <param name="listDrawCashApply"></param>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public string UpdatePlatDrawCashApply(string ids, int state, int aid, string accountId)
        {
            //1.更新提现申请.如果为标记为审核不通过则需要将提现金额归还并且标记为提现失败,如果标记为审核通过则不需要归还,然后将其标记为提现中2.记录操作日志  两个都成功才算成功
            TransactionModel     tranModel        = new TransactionModel();
            DrawCashApplyLog     drawCashApplyLog = new DrawCashApplyLog();
            List <DrawCashApply> list             = GetListByIds(aid, ids);

            if (list == null || list.Count <= 0)
            {
                return("无效申请记录");
            }
            if (string.IsNullOrEmpty(accountId))
            {
                return("无效用户");
            }
            if (state == -1)
            {
                //表示审核不通过  要标记为提现失败  并且需要把提现金额归还  最后记录操作日志
                //标记为审核不通过以及提现失败
                tranModel.Add($"update drawcashapply set state=-1,drawState=-1,updatetime='{DateTime.Now}' where Id in({ids}) and aid={aid}");
                //之前扣的佣金归还
                foreach (DrawCashApply item in list)
                {
                    PlatUserCash usercase = PlatUserCashBLL.SingleModel.GetModelByUserId(aid, item.userId);
                    usercase.UseCash += item.applyMoney;
                    tranModel.Add(PlatUserCashBLL.SingleModel.BuildUpdateSql(usercase, "UseCash"));
                }

                drawCashApplyLog.remark = $"将提现申请记录id为{ids}设置为审核不通过";
            }
            else
            {
                //表示审核通过
                drawCashApplyLog.remark = $"将提现申请记录id为{ids}设置为审核通过";
                //标记为审核通过以及提现中,只有这样提现服务才会获取去提现
                tranModel.Add($"update drawcashapply set state=1,drawState=1,updatetime='{DateTime.Now}' where Id in({ids}) and aid={aid}");
            }

            drawCashApplyLog.accountid = accountId;
            drawCashApplyLog.appId     = aid;
            drawCashApplyLog.AddTime   = DateTime.Now;
            drawCashApplyLog.hostIP    = Utility.WebHelper.GetIP();
            //记录操作日志
            tranModel.Add(DrawCashApplyLogBLL.SingleModel.BuildAddSql(drawCashApplyLog));

            bool success = DrawCashApplyLogBLL.SingleModel.ExecuteTransactionDataCorect(tranModel.sqlArray);

            return(success ? "" : "操作失败");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存提现账号
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="accountbank"></param>
        /// <param name="customername"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult SaveBankInfo(string act = "bank", int aid = 0, string accountbank = "", string customername = "", int id = 0, int drawcashway = 0)
        {
            _returnData = new Return_Msg();

            string column = "UpdateTime";

            if (id <= 0)
            {
                _returnData.Msg = "无效账户ID";
                return(Json(_returnData));
            }
            if (act == "bank")
            {
                if (string.IsNullOrEmpty(customername))
                {
                    _returnData.Msg = "请输入客户账号";
                    return(Json(_returnData));
                }
                if (string.IsNullOrEmpty(accountbank))
                {
                    _returnData.Msg = "请输入提现账号";
                    return(Json(_returnData));
                }
                column += ",AccountBank,Name";
            }
            else
            {
                column += ",DrawCashWay";
            }

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

            if (userCash == null)
            {
                _returnData.Msg = "无效账户";
                return(Json(_returnData));
            }
            userCash.AccountBank = accountbank;
            userCash.Name        = customername;
            userCash.DrawCashWay = drawcashway;
            userCash.UpdateTime  = DateTime.Now;

            _returnData.isok = PlatUserCashBLL.SingleModel.Update(userCash, column);
            _returnData.Msg  = _returnData.isok ? "保存成功" : "保存失败";
            return(Json(_returnData));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新提现结果
        /// </summary>
        /// <param name="code">0提现失败 1提现成功</param>
        /// <param name="drawCashApplyId"></param>
        /// <param name="result">附加信息</param>
        /// <returns></returns>
        public string UpdatePlayDrawCashResult(int code, DrawCashApply drawCashApply, string result)
        {
            TransactionModel tranModel = new TransactionModel();

            PlatUserCash usercash = PlatUserCashBLL.SingleModel.GetModelByUserId(drawCashApply.Aid, drawCashApply.userId);

            if (usercash == null)
            {
                return("没有找到用户提现账号");
            }
            //if (drawCashApply.drawState != (int)DrawCashState.提现中)
            //{
            //    return "无效状态";
            //}
            if (code == 1)
            {
                //表示提现成功  1.将本次提现成功金额加入累计收益 2.更新提现记录为提现成功 3.追加提现记录备注 提现成功
                usercash.UseCashTotal  += drawCashApply.cashMoney + drawCashApply.serviceMoney;
                usercash.ServerCash    += drawCashApply.serviceMoney;
                drawCashApply.drawState = 2;
                drawCashApply.DrawTime  = DateTime.Now;
                drawCashApply.remark   += $" ;本次提现成功{DateTime.Now}";
                tranModel.Add(PlatUserCashBLL.SingleModel.BuildUpdateSql(usercash, "UseCashTotal,ServerCash"));
            }
            else
            {
                //表示提现失败 将提现金额返回给分销员
                usercash.UseCash       += drawCashApply.applyMoney;
                drawCashApply.drawState = -1;
                drawCashApply.DrawTime  = DateTime.Now;
                drawCashApply.remark    = $" ;本次提现失败{DateTime.Now},原因{result}";
                tranModel.Add(PlatUserCashBLL.SingleModel.BuildUpdateSql(usercash, "UseCash"));
            }

            tranModel.Add(base.BuildUpdateSql(drawCashApply, "drawState,DrawTime,remark"));

            bool success = base.ExecuteTransactionDataCorect(tranModel.sqlArray);

            return(success ? "" : "执行更新平台店铺提现结果失败");
        }
Ejemplo n.º 6
0
        public ActionResult OpenDistribution(int aid = 0, int isOpen = 0)
        {
            Return_Msg            returnData  = new Return_Msg();
            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)
            {
                returnData.Msg = "无效账号";
                return(Json(returnData));
            }
            userCash.IsOpenDistribution = isOpen;
            userCash.UpdateTime         = DateTime.Now;
            returnData.isok             = PlatUserCashBLL.SingleModel.Update(userCash, "IsOpenDistribution,UpdateTime");
            returnData.Msg = returnData.isok ? "保存成功" : "保存失败";

            return(Json(returnData));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 加提现金额
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="aid"></param>
        /// <param name="money"></param>
        public string AddDrawCash(long userid, int aid, int money, ref TransactionModel tran, bool getsql = false)
        {
            PlatUserCash usercash = PlatUserCashBLL.SingleModel.GetModelByUserId(aid, userid);

            if (usercash == null)
            {
                return($"店主账号无效【{userid}】");
            }
            usercash.UseCash   += money;
            usercash.UpdateTime = DateTime.Now;
            if (getsql)
            {
                tran.Add(PlatUserCashBLL.SingleModel.BuildUpdateSql(usercash, "UseCash,UpdateTime"));
            }
            else
            {
                if (!PlatUserCashBLL.SingleModel.Update(usercash, "UseCash,UpdateTime"))
                {
                    return($"店主提现账号增加提现金额失败【{userid}】");
                }
            }

            return("");
        }
Ejemplo n.º 8
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));
        }
Ejemplo n.º 9
0
        public ActionResult GetGoodInfo()
        {
            int pid    = Context.GetRequestInt("pid", 0);
            int userId = Context.GetRequestInt("userId", 0);

            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";

            if (pid == 0)
            {
                returnObj.Msg = "请选择产品";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatChildGoods goodModel = PlatChildGoodsBLL.SingleModel.GetModel(pid);

            if (goodModel == null || goodModel.State == 0)
            {
                returnObj.Msg = "产品不存在或已删除";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModelByAId(goodModel.AId);

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            if (!string.IsNullOrEmpty(goodModel.Plabels))
            {
                //goodModel.plabelstr = DAL.Base.SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"SELECT group_concat(name order by sort desc) from entgoodlabel where id in ({goodModel.plabels})").ToString();
                goodModel.PlabelStr      = PlatChildGoodsLabelBLL.SingleModel.GetEntGoodsLabelStr(goodModel.Plabels);
                goodModel.PlabelStr_Arry = goodModel.PlabelStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            #region 会员折扣显示
            //获取会员信息
            VipRelation vipInfo   = VipRelationBLL.SingleModel.GetModelByUserid(userId);
            VipLevel    levelinfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null;

            List <PlatChildGoods> list = new List <PlatChildGoods>();
            list.Add(goodModel);
            //  _miniappVipLevelBll.GetVipDiscount(ref list, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel = list.FirstOrDefault();

            #endregion 会员折扣显示

            //#region 会员打折
            List <PlatChildGoodsCart> carlist = new List <PlatChildGoodsCart>()
            {
                new PlatChildGoodsCart()
                {
                    GoodsId = goodModel.Id
                }
            };
            carlist.ForEach(g => g.OriginalPrice = g.Price);
            VipLevelBLL.SingleModel.GetVipDiscount(ref carlist, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel.Discount = carlist[0].Discount;
            //#endregion 会员打折

            if (!string.IsNullOrEmpty(goodModel.Img))
            {
                goodModel.Img = goodModel.Img.Replace("http://vzan-img.oss-cn-hangzhou.aliyuncs.com", "https://i.vzan.cc/");
            }

            List <GoodsSpecDetail> listGoodsSpecDetail = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GoodsSpecDetail> >(goodModel.SpecDetail);
            listGoodsSpecDetail.ForEach(x =>
            {
                if (x.Discount == 100)
                {
                    x.DiscountPrice = x.Price;
                }
            });

            goodModel.SpecDetail = JsonConvert.SerializeObject(listGoodsSpecDetail);
            goodModel.storeModel = new StoreModel()
            {
                StoreId = platStore.Id,
                Name    = platStore.Name,
                Img     = platStore.StoreHeaderImg,
                Loction = platStore.Location,
                Lng     = platStore.Lng,
                Lat     = platStore.Lat
            };

            PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId);
            if (platMyCard != null)
            {
                goodModel.storeOwner = new StoreOwner()
                {
                    UserId = platMyCard.UserId,
                    Name   = platMyCard.Name,
                    Avatar = platMyCard.ImgUrl
                };

                PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(platMyCard.AId, platMyCard.UserId);
                if (userCash != null)
                {
                    goodModel.storeOwner.IsOpenDistribution = userCash.IsOpenDistribution;
                }
            }

            returnObj.isok    = true;
            returnObj.dataObj = goodModel;
            returnObj.Msg     = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
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("");
        }