예제 #1
0
        //一键补货
        public ResultObj <int> PostFullFilByOneKey(string machineId)
        {
            // lstCommandModel的第一条消息为机器编号
            if (!MachineHelper.IsOnline(machineId))
            {
                return(Content(0));
            }

            IMachine _IMachine = new MachineService();
            int      result    = _IMachine.GetFullfilGood(machineId);

            if (result == 1)
            {
                List <CommandModel> lstCommand = new List <CommandModel>();
                lstCommand.Add(new CommandModel()
                {
                    Content = machineId,
                    Size    = 12
                });

                //var log = LogManager.GetLogger("FycnApi", "weixin");
                //log.Info("test");
                //log.Info(tradeNoNode.InnerText);
                SocketHelper.GenerateCommand(11, 13, 84, lstCommand);
            }
            return(Content(result));
        }
예제 #2
0
        //手机修改价格
        public ResultObj <int> PutPriceWithMobile([FromBody] List <TunnelInfoModel> lstTunnelInfo)
        {
            if (lstTunnelInfo.Count < 1)
            {
                return(Content(0));
            }

            if (!MachineHelper.IsOnline(lstTunnelInfo[0].MachineId))
            {
                return(Content(0));
            }
            IFullfilBill ifullfilBill = new TunnelInfoService();
            int          result       = ifullfilBill.UpdatePriceWithMobile(lstTunnelInfo);

            if (result == 1)
            {
                List <CommandModel> lstCommand = new List <CommandModel>();
                lstCommand.Add(new CommandModel()
                {
                    Content = lstTunnelInfo[0].MachineId,
                    Size    = 12
                });
                foreach (TunnelInfoModel tunnel in lstTunnelInfo)
                {
                    lstCommand.Add(new CommandModel()
                    {
                        Content = tunnel.TunnelId,
                        Size    = 5
                    });
                    int    price        = Convert.ToInt32(Decimal.Parse(tunnel.Price.ToString()) * 100);
                    string priceContent = price.ToString();
                    int    fillZero     = 5 - price.ToString().Length;
                    for (int i = 0; i < fillZero; i++)
                    {
                        priceContent = "0" + priceContent;
                    }
                    lstCommand.Add(new CommandModel()
                    {
                        Content = priceContent,
                        Size    = 5
                    });
                }

                SocketHelper.GenerateCommand(14, 13 + lstTunnelInfo.Count * 10, 82, lstCommand);
            }

            return(Content(result));
        }
예제 #3
0
        //手机补充库存
        public ResultObj <int> PutStockWithMobile([FromBody] List <TunnelInfoModel> lstTunnelInfo)
        {
            if (lstTunnelInfo.Count < 1)
            {
                return(Content(0));
            }

            if (!MachineHelper.IsOnline(lstTunnelInfo[0].MachineId))
            {
                return(Content(0));
            }

            IFullfilBill ifullfilBill = new TunnelInfoService();
            int          result       = ifullfilBill.UpdateStockWithMobile(lstTunnelInfo);

            if (result == 1)
            {
                List <CommandModel> lstCommand = new List <CommandModel>();
                lstCommand.Add(new CommandModel()
                {
                    Content = lstTunnelInfo[0].MachineId,
                    Size    = 12
                });
                foreach (TunnelInfoModel tunnel in lstTunnelInfo)
                {
                    lstCommand.Add(new CommandModel()
                    {
                        Content = tunnel.TunnelId,
                        Size    = 5
                    });
                    lstCommand.Add(new CommandModel()
                    {
                        Content = (tunnel.CurrStock > 10?tunnel.CurrStock.ToString():"0" + tunnel.CurrStock.ToString()),
                        Size    = 2
                    });
                }

                SocketHelper.GenerateCommand(12, 13 + lstTunnelInfo.Count * 7, 83, lstCommand);
            }
            return(Content(result));
        }
예제 #4
0
        //手机端设置最大库存
        public ResultObj <int> PostMaxStock([FromBody] List <PriceAndMaxStockModel> lstPriceAndStock, string machineId)
        {
            if (lstPriceAndStock.Count < 1)
            {
                return(Content(0));
            }

            if (!MachineHelper.IsOnline(machineId))
            {
                return(Content(0));
            }
            IMachine _IMachine = new MachineService();
            int      result    = _IMachine.PostMaxPuts(lstPriceAndStock, machineId);

            if (result == 1)
            {
                List <CommandModel> lstCommand = new List <CommandModel>();
                lstCommand.Add(new CommandModel()
                {
                    Content = machineId,
                    Size    = 12
                });
                foreach (PriceAndMaxStockModel tunnel in lstPriceAndStock)
                {
                    lstCommand.Add(new CommandModel()
                    {
                        Content = tunnel.tid,
                        Size    = 5
                    });
                    lstCommand.Add(new CommandModel()
                    {
                        Content = (tunnel.ms > 10?tunnel.ms.ToString():"0" + tunnel.ms.ToString()),
                        Size    = 2
                    });
                }

                SocketHelper.GenerateCommand(13, 13 + lstPriceAndStock.Count * 7, 86, lstCommand);
            }
            return(Content(result));
        }
예제 #5
0
        //支付宝支付结果

        /*
         * public ResultObj<int> PostPayResultA(List<ProductModel> listProductInfo)
         * {
         *
         *  IMachine _imachine = new MachineService();
         *  _imachine.PostPayResultA(listProductInfo);
         *  return Content(1);
         * }
         */
        public string PostPayResultA()
        {
            try
            {
                string outTradeNo = Fycn.Utility.HttpContext.Current.Request.Form["out_trade_no"].ToString().Trim();
                //RedisHelper helper = new RedisHelper(0);
                //log.Info(outTradeNo);
                //log.Info(helper.KeyExists(outTradeNo));

                /*
                 * if (!helper.KeyExists(outTradeNo))
                 * {
                 *  return "success";
                 * }
                 */
                /*
                 * IMachine _imachine = new MachineService();
                 * if (_imachine.GetCountByTradeNo(outTradeNo) > 0)
                 * {
                 *  return Content(1);
                 * }
                 */
                string tradeStatus = Fycn.Utility.HttpContext.Current.Request.Form["trade_status"].ToString().ToUpper();
                if (tradeStatus == "TRADE_SUCCESS")
                {
                    /*******************************放到微信支付通知参数里,因参数只支付最大128个字符长度,所以注释修改*****************************/
                    //string jsonProduct = Fycn.Utility.HttpContext.Current.Request.Form["body"];
                    //KeyJsonModel keyJsonModel = JsonHandler.GetObjectFromJson<KeyJsonModel>(jsonProduct);
                    string tradeNo  = Fycn.Utility.HttpContext.Current.Request.Form["trade_no"];
                    string sellerId = Fycn.Utility.HttpContext.Current.Request.Form["seller_id"];      //买家合作者id
                    string buyerId  = Fycn.Utility.HttpContext.Current.Request.Form["buyer_logon_id"]; //买家账号
                    //log.Info(Fycn.Utility.HttpContext.Current.Request.Form["passback_params"]);
                    //string jsonProduct = helper.StringGet(outTradeNo);
                    string jsonProduct = Fycn.Utility.HttpContext.Current.Request.Form["passback_params"];

                    //log.Info("test");
                    string gmtPayment = Fycn.Utility.HttpContext.Current.Request.Form["gmt_payment"]; //付款时间

                    //string jsonProduct = FileHandler.ReadFile("data/" + outTradeNo + ".wa");
                    //log.Info(gmtPayment);

                    KeyJsonModel keyJsonModel = JsonHandler.GetObjectFromJson <KeyJsonModel>(jsonProduct);
                    IMachine     _imachine    = new MachineService();
                    int          result       = _imachine.PostPayResultA(keyJsonModel, outTradeNo, tradeNo, sellerId, buyerId, gmtPayment);
                    if (result == 1)
                    {
                        //Fycn.Utility.HttpContext.Current.Response.Write("success");
                        //Response.WriteAsync("success");
                        List <CommandModel> lstCommand = new List <CommandModel>();
                        lstCommand.Add(new CommandModel()
                        {
                            Content = keyJsonModel.m,
                            Size    = 12
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = outTradeNo,
                            Size    = 22
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = keyJsonModel.t[0].tid,
                            Size    = 5
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = "4",
                            Size    = 1
                        });

                        SocketHelper.GenerateCommand(10, 41, 66, lstCommand);
                        //删除文件
                        //helper.KeyDelete(outTradeNo);
                        //FileHandler.DeleteFile("data/" + outTradeNo + ".wa");
                        if (sellerId == PathConfig.RootAliMchId)
                        {
                            IDistrubuteMoney imoney = new DistrubuteMoneyService();
                            imoney.PostMoney(outTradeNo);
                        }
                        return("success");
                    }
                }
                return("success");
            }
            catch (Exception ex)
            {
                return("success");
            }
        }
예제 #6
0
        // 微信支付结果
        public string PostPayResultW()
        {
            try
            {
                var    request = Fycn.Utility.HttpContext.Current.Request;
                int    len     = (int)request.ContentLength;
                byte[] b       = new byte[len];
                Fycn.Utility.HttpContext.Current.Request.Body.Read(b, 0, len);
                string      postStr = Encoding.UTF8.GetString(b);
                XmlDocument xmlDoc  = new XmlDocument();
                xmlDoc.LoadXml(postStr);
                // 商户交易号
                XmlNode tradeNoNode = xmlDoc.SelectSingleNode("xml/out_trade_no");

                /*
                 * RedisHelper helper = new RedisHelper(0);
                 *
                 * if (!helper.KeyExists(tradeNoNode.InnerText))
                 * {
                 *  return Content(1);
                 * }
                 */
                /*
                 * IMachine _imachine = new MachineService();
                 * if (_imachine.GetCountByTradeNo(tradeNoNode.InnerText) > 0)
                 * {
                 *  return Content(1);
                 * }
                 */


                //支付结果
                XmlNode payResultNode = xmlDoc.SelectSingleNode("xml/result_code");
                if (payResultNode.InnerText.ToUpper() == "SUCCESS")
                {
                    /*******************************放到微信支付通知参数里,因参数只支付最大128个字符长度,所以注释修改*****************************/
                    //XmlNode tunnelNode = xmlDoc.SelectSingleNode("xml/attach");
                    //KeyJsonModel keyJsonModel = JsonHandler.GetObjectFromJson<KeyJsonModel>(tunnelNode.InnerText);
                    XmlNode attachNode  = xmlDoc.SelectSingleNode("xml/attach");
                    string  jsonProduct = attachNode.InnerText;                        //helper.StringGet(tradeNoNode.InnerText);
                    XmlNode mchIdNode   = xmlDoc.SelectSingleNode("xml/mch_id");       // 商户号
                    XmlNode openidNode  = xmlDoc.SelectSingleNode("xml/openid");       //买家唯一标识
                    XmlNode isSubNode   = xmlDoc.SelectSingleNode("xml/is_subscribe"); // 是否为公众号关注者
                    XmlNode timeEndNode = xmlDoc.SelectSingleNode("xml/time_end");     // 是否为公众号关注者
                    //string jsonProduct = FileHandler.ReadFile("data/" + tradeNoNode.InnerText + ".wa");

                    KeyJsonModel keyJsonModel = JsonHandler.GetObjectFromJson <KeyJsonModel>(jsonProduct);
                    IMachine     _imachine    = new MachineService();
                    int          result       = _imachine.PostPayResultW(keyJsonModel, tradeNoNode.InnerText, mchIdNode.InnerText, openidNode.InnerText, isSubNode.InnerText, timeEndNode.InnerText);
                    if (result == 1)
                    {
                        List <CommandModel> lstCommand = new List <CommandModel>();
                        lstCommand.Add(new CommandModel()
                        {
                            Content = keyJsonModel.m,
                            Size    = 12
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = tradeNoNode.InnerText,
                            Size    = 22
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = keyJsonModel.t[0].tid,
                            Size    = 5
                        });
                        lstCommand.Add(new CommandModel()
                        {
                            Content = "3",
                            Size    = 1
                        });

                        //var log = LogManager.GetLogger("FycnApi", "weixin");
                        //log.Info("test");
                        //log.Info(tradeNoNode.InnerText);
                        SocketHelper.GenerateCommand(10, 41, 66, lstCommand);
                        //删除文件
                        //helper.KeyDelete(tradeNoNode.InnerText);
                        //FileHandler.DeleteFile("data/" + tradeNoNode.InnerText + ".wa");
                        if (mchIdNode.InnerText == PathConfig.RootWeixinMchId)
                        {
                            IDistrubuteMoney imoney = new DistrubuteMoneyService();
                            imoney.PostMoney(tradeNoNode.InnerText);
                        }
                    }
                }
                return("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
            }
            catch (Exception ex)
            {
                return("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }

            //File.WriteAllText(@"c:\text.txt", postStr);
        }