Ejemplo n.º 1
0
        /// <summary>
        /// Request Nodes
        /// </summary>
        /// <param name="nodes">nodes</param>
        private void RequestNodes(List <NodeInfo> nodes)
        {
            try {
                var orders = new List <OrderInfo>();
                foreach (var node in nodes)
                {
                    var order = new OrderInfo();
                    order.LscID      = node.LscID;
                    order.TargetID   = node.NodeID;
                    order.TargetType = node.NodeType;
                    order.OrderType  = EnmActType.RequestNode;
                    order.RelValue1  = WebUtility.DefaultString;
                    order.RelValue2  = WebUtility.DefaultString;
                    order.RelValue3  = WebUtility.DefaultString;
                    order.RelValue4  = WebUtility.DefaultString;
                    order.RelValue5  = WebUtility.DefaultString;
                    order.UpdateTime = DateTime.Now;
                    orders.Add(order);
                }

                if (orders.Count > 0)
                {
                    var orderEntity = new BOrder();
                    orderEntity.AddOrders(orders);
                }
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }
Ejemplo n.º 2
0
        private void CashFlowCheck()
        {
            //取得所有「報名未繳」資料

            List <MOrder> li = new BOrder().GetByCheck();

            int i = 1;

            foreach (MOrder mod in li)
            {
                if (i % 10 == 0)
                {
                    Thread.Sleep(10000);
                }
                else
                {
                    DateTime dtDeadLine = Convert.ToDateTime(mod.DeadlineDate).AddDays(3);
                    //判斷是否超過繳費期限 (入帳時間最多3天)
                    if (dtDeadLine < DateTime.Now)
                    {
                        //只能重傳結果
                        SmesCheck(mod.TradeNo, mod.MerchantTradeNo);
                    }
                }
                Thread.Sleep(5000);
                //現在能分成兩個部份
                i++;
            }
            //AllPayCheck("1406171555482979");
            //textBox1.Text = "done";
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Restart Button Click
        /// </summary>
        protected void RestartBtn_Click(object sender, DirectEventArgs e)
        {
            try {
                var order = new OrderInfo();
                order.LscID      = -1;
                order.TargetID   = -1;
                order.TargetType = EnmNodeType.Null;
                order.OrderType  = EnmActType.Restart;
                order.RelValue1  = Page.User.Identity.Name;
                order.RelValue2  = WebUtility.GetClientIP();
                order.RelValue3  = WebUtility.DefaultString;
                order.RelValue4  = WebUtility.DefaultString;
                order.RelValue5  = WebUtility.DefaultString;
                order.UpdateTime = DateTime.Now;

                var orderEntity = new BOrder();
                orderEntity.AddOrder(order);
                var duration = Int32.Parse(WebConfigurationManager.AppSettings["SyncSettingInterval"]) * 1000;
                Thread.Sleep(duration);
                WebUtility.ShowMessage(EnmErrType.Info, "重启服务命令已下发,请重新登录以获取最新数据!");
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }
Ejemplo n.º 4
0
        public void DelLsc(int lscId)
        {
            try {
                var lscEntity = new BLsc();
                lscEntity.DelLsc(lscId);

                var order = new OrderInfo();
                order.LscID      = lscId;
                order.TargetID   = -1;
                order.TargetType = EnmNodeType.Null;
                order.OrderType  = EnmActType.DeleteLsc;
                order.RelValue1  = Page.User.Identity.Name;
                order.RelValue2  = WebUtility.GetClientIP();
                order.RelValue3  = WebUtility.DefaultString;
                order.RelValue4  = WebUtility.DefaultString;
                order.RelValue5  = WebUtility.DefaultString;
                order.UpdateTime = DateTime.Now;

                var orderEntity = new BOrder();
                orderEntity.AddOrder(order);
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Query Button Click
        /// </summary>
        protected void QueryBtn_Click(object sender, DirectEventArgs e)
        {
            try {
                var nodes = AddDataToCache();
                if (nodes != null && nodes.Count > 0)
                {
                    var orders = new List <OrderInfo>();
                    foreach (var node in nodes)
                    {
                        var order = new OrderInfo();
                        order.LscID      = node.LscID;
                        order.TargetID   = node.NodeID;
                        order.TargetType = node.NodeType;
                        order.OrderType  = EnmActType.RequestNode;
                        order.RelValue1  = WebUtility.DefaultString;
                        order.RelValue2  = WebUtility.DefaultString;
                        order.RelValue3  = WebUtility.DefaultString;
                        order.RelValue4  = WebUtility.DefaultString;
                        order.RelValue5  = WebUtility.DefaultString;
                        order.UpdateTime = DateTime.Now;
                        orders.Add(order);
                    }

                    var orderEntity = new BOrder();
                    orderEntity.AddOrders(orders);
                    var duration = Int32.Parse(WebConfigurationManager.AppSettings["NodesRequstInterval"]) * 1000;
                    Thread.Sleep(duration);
                    AddDataToCache();
                }
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 訂單檢查是否逾期
        /// </summary>
        private void CashFlowCheck2()
        {
            EventLog.WriteEntry("FoodOrg CashFlowCheck Service", "Service Stop", EventLogEntryType.Information, 202);
            //取得所有「未繳」資料

            List <MOrder> li = new BOrder().GetByCheck();

            int i = 1;

            foreach (MOrder mod in li)
            {
                if (i % 10 == 0)
                {
                    Thread.Sleep(10000);
                }
                else
                {
                    //DateTime dtDeadLine = Convert.ToDateTime(mod.DeadlineDate).AddDays(3);
                    DateTime dtDeadLine = mod.DeadlineDate;
                    //判斷是否超過繳費期限
                    if (dtDeadLine < DateTime.Now)
                    {
                        //只能重傳結果
                        SmesCheck(mod.TradeNo, mod.MerchantTradeNo);
                    }
                }
                Thread.Sleep(5000);

                i++;
            }
        }
Ejemplo n.º 7
0
        public BOrder CreateOrder(DateTime dateTime)
        {
            currOrder = new BOrder(dateTime);
            OrderController orderController = new OrderController();

            orderController.CreateOrder(dateTime);
            return(currOrder);
        }
Ejemplo n.º 8
0
 public BOrder CreateOrder(DateTime dateTime)
 {
     currOrder = new BOrder(dateTime);
     //DBOrder dBOrder = new DBOrder();
     currOrder.DateTime = DateTime.Now;
     //dBOrder.CreateOrder(currOrder);
     return(currOrder);
 }
Ejemplo n.º 9
0
        public void SetAocParms()
        {
            try {
                if (String.IsNullOrEmpty(SettingWindowHF.Text.Trim()))
                {
                    var warningMsg = "获取AO参数时发生错误,设置失败!";
                    WebUtility.WriteLog(EnmSysLogLevel.Warn, EnmSysLogType.Operating, warningMsg, Page.User.Identity.Name);
                    WebUtility.ShowMessage(EnmErrType.Warning, warningMsg);
                    return;
                }

                var ids = WebUtility.ItemSplit(SettingWindowHF.Text.Trim());
                if (ids.Length != 3)
                {
                    var warningMsg = "AO参数格式错误,设置失败!";
                    WebUtility.WriteLog(EnmSysLogLevel.Warn, EnmSysLogType.Operating, warningMsg, Page.User.Identity.Name);
                    WebUtility.ShowMessage(EnmErrType.Warning, warningMsg);
                    return;
                }

                var lscId       = Int32.Parse(ids[0]);
                var nodeId      = Int32.Parse(ids[1]);
                var nodeType    = Int32.Parse(ids[2]);
                var enmNodeType = Enum.IsDefined(typeof(EnmNodeType), nodeType) ? (EnmNodeType)nodeType : EnmNodeType.Null;
                var lscUser     = UserData.LscUsers.Find(lu => { return(lu.LscID == lscId); });
                if (lscUser == null)
                {
                    var warningMsg = "无法获取用户信息,设置失败!";
                    WebUtility.WriteLog(EnmSysLogLevel.Warn, EnmSysLogType.Operating, warningMsg, Page.User.Identity.Name);
                    WebUtility.ShowMessage(EnmErrType.Warning, warningMsg);
                    return;
                }

                var order = new OrderInfo();
                order.LscID      = lscId;
                order.TargetID   = nodeId;
                order.TargetType = enmNodeType;
                order.OrderType  = EnmActType.SetAoc;
                order.RelValue1  = (double.MinValue == SettingSpinnerField.Number ? 0 : SettingSpinnerField.Number).ToString("0.000");
                order.RelValue2  = lscId.ToString();
                order.RelValue3  = lscUser.UserID.ToString();
                order.RelValue4  = lscUser.UserName;
                order.RelValue5  = WebUtility.DefaultString;
                order.UpdateTime = DateTime.Now;

                var orderEntity = new BOrder();
                orderEntity.AddOrder(order);
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
            } finally {
                SettingSpinnerField.Number = 0;
                SettingWindow.Hide();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 支付回调
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPayResult()
        {
            string resultFromWx = getPostStr();

            if (string.IsNullOrEmpty(resultFromWx))
            {
                return(View());
            }
            //string path = Path.Combine(Server.MapPath("~/data"), "data" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt");
            //FileInfo f = new FileInfo(path);
            //if (!Directory.Exists(f.DirectoryName))
            //    Directory.CreateDirectory(f.DirectoryName);
            //using (StreamWriter writer = new StreamWriter(path))
            //{
            //    writer.Write(resultFromWx);
            //}

            var res = XDocument.Parse(resultFromWx);

            //通信成功
            try
            {
                if (res.Element("xml").Element("return_code").Value == "SUCCESS")
                {
                    if (res.Element("xml").Element("result_code").Value == "SUCCESS")
                    {
                        //交易成功
                        string transaction_id = res.Element("xml").Element("transaction_id").Value; //微信订单号
                        string trade_no       = res.Element("xml").Element("out_trade_no").Value;   //商户订单号

                        //查询订单是否存在
                        OrderViewModel model = BOrder.SearchByTradeNo(trade_no);
                        if (model != null)
                        {
                            //存在
                            BOrder.Update("update Orders set LocalStatus='已付款' where Id=" + model.Id);
                        }
                        return(Content(CallWxSuccess()));
                    }
                    else
                    {
                        return(Content("支付出现问题,请返回重试"));
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(Content("failed"));
        }
Ejemplo n.º 11
0
        public IActionResult Update(string id, BOrder borderIn)
        {
            var gdata = Newtonsoft.Json.JsonConvert.SerializeObject(borderIn);

            Console.WriteLine(gdata);

            var border = _borderService.Get(id);

            if (border == null)
            {
                return(NotFound());
            }

            _borderService.Update(id, borderIn);


            return(NoContent());
        }
Ejemplo n.º 12
0
        public JsonResult GetOrders(int limit, int offset, string departmentname)
        {
            List <OrderViewModel> lstRes = null;

            if (!string.IsNullOrEmpty(departmentname))
            {
                lstRes = BOrder.SearchByContact(departmentname);
            }
            else
            {
                lstRes = BOrder.SearchAll();
            }

            var total = lstRes.Count;
            var rows  = lstRes.Skip(offset).Take(limit).ToList();

            return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
        public ActionResult KaMiList()
        {
            //查询卡密,并显示
            string         tNo   = Request.QueryString["tNo"];
            OrderViewModel order = BOrder.SearchByTradeNo(tNo);

            if (order == null)
            {
                return(View());
            }

            Dictionary <int, string> kamis = BKaMi.SearchKamiByTrade(order);

            #region 更新卡密状态为已使用
            List <KaMiViewModel> models = new List <KaMiViewModel>();
            foreach (var item in kamis)
            {
                KaMiViewModel ka = new KaMiViewModel();
                ka.Id       = item.Key;
                ka.Remark   = order.Remark;
                ka.Trade_No = tNo;
                models.Add(ka);
            }
            BKaMi.UpdateBySql(models);
            #endregion

            string dir  = Server.MapPath("~/Files");
            string path = dir + "/" + tNo + ".csv";
            using (StreamWriter writer = new StreamWriter(path, true, Encoding.UTF8))
            {
                string title = "订单号,卡密内容,联系方式\r\n";
                writer.Write(title);

                string content = "";

                foreach (var item in kamis)
                {
                    content += tNo + "," + item.Value + "," + order.Remark + "\r\n";
                }
                writer.Write(content);
            }
            ViewBag.tNo = tNo;
            return(View(kamis));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Request Node
        /// </summary>
        /// <param name="node">node</param>
        private void RequestNode(NodeInfo node)
        {
            try {
                var order = new OrderInfo();
                order.LscID      = node.LscID;
                order.TargetID   = node.NodeID;
                order.TargetType = node.NodeType;
                order.OrderType  = EnmActType.RequestNode;
                order.RelValue1  = WebUtility.DefaultString;
                order.RelValue2  = WebUtility.DefaultString;
                order.RelValue3  = WebUtility.DefaultString;
                order.RelValue4  = WebUtility.DefaultString;
                order.RelValue5  = WebUtility.DefaultString;
                order.UpdateTime = DateTime.Now;

                var orderEntity = new BOrder();
                orderEntity.AddOrder(order);
            } catch { throw; }
        }
Ejemplo n.º 15
0
        public BOrder CreateOrder(BOrder currOrder)
        {
            int oId = 0;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdInsertProd = connection.CreateCommand())
                {
                    cmdInsertProd.CommandText = "INSERT INTO BOrder(orderDate) output INSERTED.ID VALUES(@orderDate)";
                    cmdInsertProd.Parameters.AddWithValue("orderDate", currOrder.DateTime);
                    oId = (int)cmdInsertProd.ExecuteScalar();
                }
            }
            DBOrderLine       dbOrderline = new DBOrderLine();
            List <BOrderLine> ols         = dbOrderline.SaveOrderLines(oId, currOrder.GetOrderLines());

            //currOrder.SetOrderLines(ols);
            return(currOrder);
        }
Ejemplo n.º 16
0
        public ActionResult Delete()
        {
            string name = Request.Form["pId"];

            List <DeleteId> models = LitJson.JsonMapper.ToObject <List <DeleteId> >(name);

            if (models == null)
            {
                return(Content(ReturnMsg.fail.ToString()));
            }

            bool isSucc = BOrder.Delete(models.Select(_ => _.Id).ToList());

            if (isSucc)
            {
                return(Content(ReturnMsg.success.ToString()));
            }
            else
            {
                return(Content(ReturnMsg.fail.ToString()));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 主動檢查訂單是否已繳費
        /// </summary>
        private void CashFlowCheck1()
        {
            //取得所有「報名未繳」資料
            List <MOrder> li = new BOrder().GetByCheck();

            int i = 1;

            foreach (MOrder mod in li)
            {
                if (i % 10 == 0)
                {
                    Thread.Sleep(10000);
                }
                else
                {
                    //只能重傳結果
                    SmesCheck(mod.TradeNo, mod.MerchantTradeNo);
                }
                Thread.Sleep(5000);

                i++;
            }
        }
Ejemplo n.º 18
0
        public JsonResult CheckPayResult()
        {
            string tradeNo = Request["trade_no"];
            string payType = Request["payway"];

            OrderViewModel model = BOrder.SearchByTradeNo(tradeNo);

            if (model == null)
            {
                var result = new { code = "-2", msg = "not exists" };
                return(Json(LitJson.JsonMapper.ToJson(result)));
            }

            if (model.LocalStatus != "已付款")
            {
                var result = new { code = "-1", msg = "wait for pay" };
                return(Json(LitJson.JsonMapper.ToJson(result)));
            }
            else
            {
                var result = new { code = "1", msg = "success" };
                return(Json(LitJson.JsonMapper.ToJson(result)));
            }
        }
Ejemplo n.º 19
0
 public BOrder Create(BOrder border)
 {
     _border.InsertOne(border);
     return(border);
 }
Ejemplo n.º 20
0
        public void CreateOrderLineTable(BOrder currOrder)
        {
            OrderController orderController = new OrderController();

            orderController.CreateOrderLineTable(currOrder);
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                //Notify aliNotify = new Notify();
                Notify aliNotify = new Notify(Config.charset, Config.sign_type, Config.pid, Config.mapiUrl, Config.alipay_public_key);

                //对异步通知进行验签
                bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
                //对验签结果
                //bool isSign = Aop.Api.Util.AlipaySignature.RSACheckV2(sPara, Config.alipay_public_key ,Config.charset,Config.sign_type,false );

                if (verifyResult && CheckParams()) //验签成功 && 关键业务参数校验成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                    //商户订单号
                    string out_trade_no = Request.Form["out_trade_no"];


                    //支付宝交易号
                    string trade_no = Request.Form["trade_no"];

                    //交易状态
                    //在支付宝的业务通知中,只有交易通知状态为TRADE_SUCCESS或TRADE_FINISHED时,才是买家付款成功。
                    string trade_status = Request.Form["trade_status"];

                    if (trade_status.ToUpper() == "TRADE_SUCCESS" || trade_status.ToUpper() == "TRADE_FINISHED")
                    {
                        //查询订单是否存在
                        OrderViewModel model = BOrder.SearchByTradeNo(out_trade_no);
                        if (model != null)
                        {
                            //存在
                            BOrder.Update("update Orders set LocalStatus='已付款' where Id=" + model.Id);
                        }
                    }
                    //判断是否在商户网站中已经做过了这次通知返回的处理
                    //如果没有做过处理,那么执行商户的业务程序
                    //如果有做过处理,那么不执行商户的业务程序

                    Response.Write("success");  //请不要修改或删除

                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 构造支付请求数据
        /// </summary>
        /// <returns>请求数据集</returns>
        private AlipayTradePrecreateContentBuilder BuildPrecreateContent()
        {
            //线上联调时,请输入真实的外部订单号。
            string out_trade_no = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "0000" + (new Random()).Next(1, 10000).ToString();
            string total_fee    = "1";
            string subject      = "test";

            if (!string.IsNullOrEmpty(Request.QueryString["tid"]))
            {
                out_trade_no = Request.QueryString["tid"];
            }

            OrderViewModel order = BOrder.SearchByTradeNo(out_trade_no);

            if (order != null)
            {
                subject   = BProduct.ExecuteSql("select Name from Products where Id=" + order.Product_Id).ToString();
                total_fee = (order.Price * order.Count).ToString();
            }
            //if (String.IsNullOrEmpty(WIDout_request_no.Text.Trim()))
            //{
            //    out_trade_no = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "0000" + (new Random()).Next(1, 10000).ToString();
            //}
            //else
            //{
            //out_trade_no = "WF87212910290";
            //}

            AlipayTradePrecreateContentBuilder builder = new AlipayTradePrecreateContentBuilder();

            //收款账号
            builder.seller_id = Config.pid;
            //订单编号
            builder.out_trade_no = out_trade_no;
            //订单总金额
            builder.total_amount = total_fee;
            //参与优惠计算的金额
            //builder.discountable_amount = "";
            //不参与优惠计算的金额
            //builder.undiscountable_amount = "";
            //订单名称
            builder.subject = subject;
            //自定义超时时间
            builder.timeout_express = "5m";
            //订单描述
            builder.body = "";
            //门店编号,很重要的参数,可以用作之后的营销
            builder.store_id = "test store id";
            //操作员编号,很重要的参数,可以用作之后的营销
            builder.operator_id = "test";

            //传入商品信息详情
            List <GoodsInfo> gList = new List <GoodsInfo>();

            if (order != null)
            {
                GoodsInfo goods = new GoodsInfo();
                goods.goods_id   = order.Product_Id.ToString();
                goods.goods_name = subject;
                goods.price      = order.Price.ToString();
                goods.quantity   = order.Count.ToString();;
                gList.Add(goods);
            }
            else
            {
                GoodsInfo goods = new GoodsInfo();
                goods.goods_id   = "520";
                goods.goods_name = "捐助";
                goods.price      = "0.1";
                goods.quantity   = "1";
                gList.Add(goods);
            }

            builder.goods_detail = gList;

            //系统商接入可以填此参数用作返佣
            //ExtendParams exParam = new ExtendParams();
            //exParam.sysServiceProviderId = "20880000000000";
            //builder.extendParams = exParam;

            return(builder);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        private List <BSale> SyncTrades(DateTime?sDate, DateTime?eDate, string status, long page, out long totalTrades, out bool hasNextPage, bool onlyReFound = false)
        {
            totalTrades = 0;
            hasNextPage = false;
            TradesSoldGetRequest req = new TradesSoldGetRequest();

            req.Fields  = "total_fee,buyer_nick,created,tid,status, payment, discount_fee, adjust_fee, post_fee,price,adjust_fee,receiver_city,receiver_district,receiver_name,receiver_state,receiver_mobile,receiver_phone,received_payment";
            req.Fields += ",orders.title,orders.pic_path,orders.price,orders.num,orders.iid,orders.num_iid,orders.sku_id,orders.refund_status,orders.status,orders.oid,orders.total_fee,orders.payment,orders.discount_fee,orders.adjust_fee,orders.sku_properties_name,orders.item_meal_name,orders.buyer_rate,orders.seller_rate,orders.outer_iid,orders.outer_sku_id,orders.refund_id,orders.seller_type";

            if (sDate != null)
            {
                req.StartCreated = sDate;
            }

            if (eDate != null)
            {
                req.EndCreated = eDate;
            }

            if (!string.IsNullOrEmpty(status))
            {
                req.Status = status;
            }
            //req.BuyerNick = "zhangsan";
            //req.Type = "game_equipment";
            //req.ExtType = "service";
            //req.RateStatus = "RATE_UNBUYER";
            //req.Tag = "time_card";
            req.PageNo     = page;
            req.PageSize   = 50L;
            req.UseHasNext = true;
            TradesSoldGetResponse response = client.Execute(req, this.Access_Token.Access_Token1);

            List <BSale> sales = new List <BSale>();

            if (response.IsError)
            {
                throw new KMJXCTaobaoException(response.ErrCode, response.SubErrMsg);
            }

            if (response.Trades != null)
            {
                hasNextPage = response.HasNext;
                totalTrades = response.TotalResults;
                foreach (TB.Trade trade in response.Trades)
                {
                    if (trade.Tid <= 0)
                    {
                        continue;
                    }
                    var existedSales = from esale in sales where esale.Sale_ID == trade.Tid.ToString() select esale;
                    if (existedSales.Count() > 0)
                    {
                        continue;
                    }

                    bool  containRefound = false;
                    BSale sale           = new BSale();
                    sale.Status       = trade.Status;
                    sale.SaleDateTime = DateTimeUtil.ConvertDateTimeToInt(Convert.ToDateTime(trade.Created));
                    sale.Sale_ID      = trade.Tid.ToString();
                    sale.Orders       = new List <BOrder>();
                    sale.Synced       = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                    if (!string.IsNullOrEmpty(trade.PostFee))
                    {
                        sale.Post_Fee = double.Parse(trade.PostFee);
                    }
                    if (!string.IsNullOrEmpty(trade.Payment))
                    {
                        sale.Amount = double.Parse(trade.Payment);
                    }

                    sale.Province = new Common_District()
                    {
                        name = trade.ReceiverState
                    };
                    sale.City = new Common_District()
                    {
                        name = trade.ReceiverState
                    };
                    sale.Buyer = new BCustomer()
                    {
                        Type = new BMallType()
                        {
                            ID = this.Mall_Type_ID
                        }, Mall_ID = trade.BuyerNick, Name = trade.ReceiverName, Address = trade.ReceiverAddress, Phone = trade.ReceiverMobile, Province = new Common_District {
                            name = trade.ReceiverState
                        }, City = new Common_District()
                        {
                            name = trade.ReceiverCity
                        }
                    };
                    if (trade.Orders != null)
                    {
                        foreach (TB.Order o in trade.Orders)
                        {
                            if (o.Oid <= 0)
                            {
                                continue;
                            }

                            var existedOrders = from so in sale.Orders where so.Order_ID == o.Oid.ToString() select so;
                            if (existedOrders.Count() > 0)
                            {
                                continue;
                            }

                            //if (string.IsNullOrEmpty(o.OuterIid))
                            //{
                            //    continue;
                            //}
                            BOrder order = new BOrder();
                            if (!string.IsNullOrEmpty(o.Title))
                            {
                                order.Title = o.Title;
                            }

                            if (!string.IsNullOrEmpty(o.Payment))
                            {
                                order.Amount = double.Parse(o.Payment);
                            }

                            if (!string.IsNullOrEmpty(o.Price))
                            {
                                order.Price = double.Parse(o.Price);
                            }

                            order.Quantity = int.Parse(o.Num.ToString());
                            order.Status   = o.Status;
                            order.Status1  = 0;
                            if (!string.IsNullOrEmpty(o.RefundStatus) && o.RefundStatus == "SUCCESS")
                            {
                                containRefound = true;
                                order.Refound  = true;
                                sale.Amount    = sale.Amount - order.Amount;
                            }
                            order.StockStatus = 0;
                            order.Discount    = string.IsNullOrEmpty(o.DiscountFee) ? double.Parse(o.DiscountFee) : 0;
                            order.Order_ID    = o.Oid.ToString();
                            order.Mall_PID    = o.NumIid.ToString();

                            if (!string.IsNullOrEmpty(o.OuterIid))
                            {
                                int pid = 0;
                                int.TryParse(o.OuterIid, out pid);
                                order.Parent_Product_ID = pid;

                                if (!string.IsNullOrEmpty(o.SkuId))
                                {
                                    int pcid = 0;
                                    int.TryParse(o.OuterSkuId, out pcid);
                                    order.Product_ID = pcid;
                                    order.Mall_SkuID = o.SkuId;
                                }
                                else
                                {
                                    order.Mall_SkuID = "";
                                    order.Product_ID = order.Parent_Product_ID;
                                }
                            }
                            order.ImageUrl = "";
                            if (!string.IsNullOrEmpty(o.PicPath))
                            {
                                order.ImageUrl = o.PicPath;
                            }

                            sale.Orders.Add(order);
                        }
                    }

                    sale.HasRefound = containRefound;

                    if (onlyReFound)
                    {
                        if (containRefound)
                        {
                            sales.Add(sale);
                        }
                    }
                    else
                    {
                        sales.Add(sale);
                    }
                }
            }
            return(sales);
        }
Ejemplo n.º 24
0
 public void FinishOrder(BOrder currOrder)
 {
     CreateOrder(currOrder);
 }
Ejemplo n.º 25
0
 public BOrderLine CreateOrderLineFood(int quantity, BFood bFood, BOrder bOrder)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 订单生成
        /// </summary>
        /// <returns></returns>
        public ActionResult Order()
        {
            string proId = Request.Form["proId"];
            string name  = Request.Form["proName"];
            string price = Request.Form["price"];
            string num   = Request.Form["num"];
            string email = Request.Form["email"];

            ProductViewModel model = BProduct.SearchById(proId);

            if (model == null)
            {
                return(Content("订单生成异常"));
            }

            double _price = Convert.ToDouble(price);
            int    _num   = Convert.ToInt32(num);

            if (model.Price != _price)
            {
                return(Content("订单生成异常(金额不符)"));
            }
            if (model.Name != name)
            {
                return(Content("订单生成异常(名称不符)"));
            }

            double totalPrice = _price * _num;
            string orderNo    = DTHelper.GetCurrentTimeOrderNo();
            //订单生成
            OrderViewModel orderModel = new OrderViewModel();

            orderModel.Count       = _num;
            orderModel.NO          = orderNo;
            orderModel.Price       = _price;
            orderModel.Product_Id  = Convert.ToInt32(proId);
            orderModel.Remark      = email;
            orderModel.Type        = Request.Form["paytype"];
            orderModel.LocalStatus = "待支付";
            orderModel.UpdateTime  = DateTime.Now;
            BOrder.Insert(orderModel);

            string url = "";

            if (orderModel.Type == "1")
            {
                NativePay nativePay = new NativePay();

                //转化为以分为单位的金额
                int money = Convert.ToInt32(totalPrice * 100);
                //生成扫码支付模式二url
                url = "https://www.baifubao.com/o2o/0/qrcode?size=4&text=" + nativePay.GetPayUrl(proId, money, name, orderNo);
            }
            else if (orderModel.Type == "2")
            {
                url = "/Zhifu/precreate.aspx?tid=" + orderNo;
            }
            else
            {
            }

            ViewBag.QR_url  = url;
            ViewBag.Name    = name;
            ViewBag.Num     = _num;
            ViewBag.Total   = totalPrice;
            ViewBag.tNo     = orderNo;
            ViewBag.payType = Request.Form["paytype"];
            return(View());
        }
Ejemplo n.º 27
0
        public ActionResult <BOrder> Create(BOrder border)
        {
            _borderService.Create(border);

            return(CreatedAtRoute("GetOrder", new { id = border.oid.ToString() }, border));
        }
Ejemplo n.º 28
0
        public void CreateOrderLineTable(BOrder currOrder)
        {
            DBOrder dbOrder = new DBOrder();

            dbOrder.FinishOrder(currOrder);
        }
Ejemplo n.º 29
0
 public void Remove(BOrder borderIn) =>
 _border.DeleteOne(order => order.oid == borderIn.oid);
Ejemplo n.º 30
0
 public void Update(string id, BOrder orderIn) =>
 _border.ReplaceOne(order => order.oid == id, orderIn);