Exemplo n.º 1
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));
        }