Exemple #1
0
        public override string ProcessJavascript(Order order)
        {
            byte[] orderJson = Encoding.UTF8.GetBytes(GetOrderJson(order, PartnerId));
            string base64    = Convert.ToBase64String(orderJson);

            var sb = new StringBuilder();

            sb.Append("<script type=\"text/javascript\"> ");
            sb.AppendFormat("$.getScript(\"https://{0}/widget/vkredit.js\", function() {{ \r\n",
                            Sandbox ? "kupivkredit-test-fe.tcsbank.ru:8100" : "www.kupivkredit.ru");

            sb.AppendFormat("vkredit = new VkreditWidget({0}, {1}, ", 1, OrderSum.ToString("F2").Replace(",", "."));
            sb.AppendFormat("{{ order:\"{0}\", sig: \"{1}\" }}); ", base64, GetSign(base64, SecretKey));


            sb.Append("}); ");
            sb.Append("</script>");

            return(sb.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 获取分销员的订单统计数据
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="salesManRecordIds"></param>
        /// <param name="state">0表示人工结算 1表示自动结算</param>
        /// <returns></returns>
        public OrderSum GetOrderSum(int appId, string salesManRecordIds, int state)
        {
            OrderSum orderSum = new OrderSum();

            if (!string.IsNullOrEmpty(salesManRecordIds))
            {
                string sql = $"select count(Id) as PayOrderCount,sum(orderMoney) as PayOrderTotalPrice,sum(cpsMoney) as PayOrderTotalCpsMoney from SalesManRecordOrder where appId={appId} and salesManRecordId in({salesManRecordIds}) and state={state}";

                using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql))
                {
                    while (dr.Read())
                    {
                        orderSum.payOrderCount         = Convert.ToInt32(dr["PayOrderCount"]);
                        orderSum.payOrderTotalCpsMoney = (dr["PayOrderTotalCpsMoney"] == DBNull.Value ? 0 : Convert.ToDouble(dr["PayOrderTotalCpsMoney"]) * 0.01).ToString("0.00");
                        orderSum.payOrderTotalPrice    = (dr["PayOrderTotalPrice"] == DBNull.Value ? 0 : Convert.ToDouble(dr["PayOrderTotalPrice"]) * 0.01).ToString("0.00");
                    }
                }
            }
            return(orderSum);
        }
Exemple #3
0
        /// <summary>
        /// 根据分销员分组获取其订单数据统计
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="strOrder"></param>
        /// <returns></returns>
        public List <SalesMan> GetSalesManRecordOrdersGroupBySalesMan(int appId, string strWhere, int pageIndex = 1, int pageSize = 10, string strOrder = "Id desc")
        {
            string sql = $"select o.Id,o.TelePhone,o.Remark,u.NickName,o.AddTime from SalesMan o LEFT join C_UserInfo u on o.UserId=u.Id  where {strWhere}  order by {strOrder} LIMIT {(pageIndex - 1) * pageSize},{pageSize}";

            using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql))
            {
                List <SalesMan> listSalesMan = new List <SalesMan>();

                while (dr.Read())
                {
                    SalesMan salesMan = SalesManBLL.SingleModel.GetModel(dr);

                    if (salesMan != null)
                    {
                        string salesManRecordIds = string.Join(",", GetSalesManRecordIds(salesMan.Id, appId));

                        OrderSum orderSumPeople = GetOrderSum(appId, salesManRecordIds, 0);
                        OrderSum orderSumAuto   = GetOrderSum(appId, salesManRecordIds, 1);
                        salesMan.Remark   = Convert.ToString(dr["Remark"]);
                        salesMan.nickName = Convert.ToString(dr["NickName"]);
                        if (!string.IsNullOrEmpty(salesMan.Remark))
                        {
                            salesMan.nickName += $"({salesMan.Remark})";
                        }

                        salesMan.autoPayOrderCount         = orderSumAuto.payOrderCount;
                        salesMan.autoPayOrderTotalCpsMoney = orderSumAuto.payOrderTotalCpsMoney;
                        salesMan.autoPayOrderTotalPrice    = orderSumAuto.payOrderTotalPrice;

                        salesMan.peoplePayOrderCount         = orderSumPeople.payOrderCount;
                        salesMan.peoplePayOrderTotalCpsMoney = orderSumPeople.payOrderTotalCpsMoney;
                        salesMan.peoplePayOrderTotalPrice    = orderSumPeople.payOrderTotalPrice;
                        listSalesMan.Add(salesMan);
                    }
                }
                return(listSalesMan.Count > 0 ? listSalesMan : null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 专业版小程序端接口调用申请提现
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="userId"></param>
        /// <param name="drawCashMoney"></param>
        /// <param name="partner_trade_no"></param>
        /// <returns></returns>
        public int AddDistributionDrawCashApply(int appId, int userId, int drawCashMoney, string partner_trade_no)
        {
            SalesMan salesMan = SalesManBLL.SingleModel.GetModel($"appId={appId} and userId={userId}");

            if (salesMan == null)
            {
                return(-1);//表示申请提现的分销员不存在
            }
            if (salesMan.useCash < drawCashMoney)
            {
                return(-2);//表示本次申请的提现金额小于账号可提现金额
            }
            //后续加入提现黑名单

            //int countNowDay = 0;//当天提现申请记录
            // string sql = $"SELECT COUNT(*)  FROM DrawCashApply WHERE  TO_DAYS(AddTime)=TO_DAYS(NOW()) and userId={salesMan.UserId}";
            //object obj = SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql);
            //if (obj != null)
            //{
            //    countNowDay = Convert.ToInt32(obj);
            //}

            //if (countNowDay > 3)
            //    return -3;//当天提现次数超标



            DrawCashApply drawCashApply = new DrawCashApply();

            TransactionModel tranModel = new TransactionModel();

            drawCashApply.partner_trade_no = partner_trade_no;
            drawCashApply.userId           = userId;
            drawCashApply.AddTime          = DateTime.Now;
            drawCashApply.Aid        = appId;
            drawCashApply.applyType  = 0;
            drawCashApply.cashMoney  = drawCashMoney;
            drawCashApply.hostIP     = Utility.WebHelper.GetIP();
            drawCashApply.UpdateTime = DateTime.Now;

            //提现金额需要进行审核
            drawCashApply.state     = 0;
            drawCashApply.drawState = 0;



            string   salesManRecordIds = string.Join(",", SalesManRecordOrderBLL.SingleModel.GetSalesManRecordIds(salesMan.Id, appId));
            OrderSum orderSumPeople    = SalesManRecordOrderBLL.SingleModel.GetOrderSum(appId, salesManRecordIds, 0);
            OrderSum orderSumAuto      = SalesManRecordOrderBLL.SingleModel.GetOrderSum(appId, salesManRecordIds, 1);

            drawCashApply.orderCount         = orderSumPeople.payOrderCount + orderSumAuto.payOrderCount;
            drawCashApply.orderTotalCpsMoney = (Convert.ToDouble(orderSumPeople.payOrderTotalCpsMoney) + Convert.ToDouble(orderSumAuto.payOrderTotalCpsMoney)).ToString();
            drawCashApply.orderTotalMoney    = (Convert.ToDouble(orderSumPeople.payOrderTotalPrice) + Convert.ToDouble(orderSumAuto.payOrderTotalPrice)).ToString();
            int afterUseCash = salesMan.useCash - drawCashMoney;

            drawCashApply.useCash = (afterUseCash * 0.01).ToString("0.00");


            salesMan.useCash    = afterUseCash;
            salesMan.UpdateTime = DateTime.Now;

            tranModel.Add(base.BuildAddSql(drawCashApply));

            tranModel.Add(SalesManBLL.SingleModel.BuildUpdateSql(salesMan));

            if (tranModel.sqlArray.Length > 0 && SalesManBLL.SingleModel.ExecuteTransactionDataCorect(tranModel.sqlArray))
            {
                return(1);//表示加入申请提现记录成功并且更新了分销员的提现金额
            }
            else
            {
                return(0);//表示执行事务失败
            }
        }