Beispiel #1
0
 // Token: 0x0600041D RID: 1053 RVA: 0x0003C4B4 File Offset: 0x0003A6B4
 private void enterBtn_Click(object sender, EventArgs e)
 {
     this.enterBtn.Enabled = false;
     if (this.cce == null)
     {
         WMMessageBox.Show(this, "请先读取用户卡!");
         return;
     }
     if (this.parentForm != null)
     {
         ConsumeCardEntity consumeCardEntity = this.parseCard(false);
         if (consumeCardEntity != null)
         {
             if (this.cce.UserId != consumeCardEntity.UserId)
             {
                 WMMessageBox.Show(this, "与读取的卡片内容不符,请检查是否更换了卡片!");
                 return;
             }
             consumeCardEntity.DeviceHead.ChangeMeterFlag = 1U;
             consumeCardEntity.DeviceHead.DeviceIdFlag    = 1U;
             consumeCardEntity.DeviceHead.ConsumeFlag     = 0U;
             this.parentForm.writeCard(consumeCardEntity.getEntity());
             WMMessageBox.Show(this, "重置成功!");
         }
     }
 }
Beispiel #2
0
        public void PaySucceed(string result, JObject retQueryObj, JObject retQueryDetailObj, string out_order_no, string create_time)
        {
            this.timer1.Enabled = true;
            this.TimeOut        = this.MainFormTimeOut;
            this.timer1.Start();

            // 支付成功
            dbUtil.AddParameter("out_order_no", out_order_no);
            dbUtil.AddParameter("status", "2");
            dbUtil.AddParameter("query", result);
            dbUtil.ExecuteNonQuery("UPDATE he_ma_pay SET query=@query,status=@status WHERE out_order_no=@out_order_no");


            long num = 0L;
            ConsumeCardEntity consumeCardEntity = null;
            int num5 = isValidCard();

            double buyer_pay_amount = ConvertUtils.ToDouble(retQueryDetailObj["buyer_pay_amount"].ToString().Trim());

            if (num5 == 2)
            {
                consumeCardEntity = this.parseCard(false);
                if (consumeCardEntity == null)
                {
                    bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                    if (!refund_status)
                    {
                        WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                    }
                    return;
                }
            }
            if (consumeCardEntity == null)
            {
                bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                if (!refund_status)
                {
                    WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                }
                return;
            }
            if (consumeCardEntity != null)
            {
                if (consumeCardEntity != null && consumeCardEntity.DeviceHead.DeviceIdFlag == 0U)
                {
                    bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                    if (!refund_status)
                    {
                        WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                    }
                    WMMessageBox.Show(this, "此卡未开户,不能写入数据!");
                    return;
                }
                if (consumeCardEntity != null && consumeCardEntity.DeviceHead.ConsumeFlag == 0U)
                {
                    bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                    if (!refund_status)
                    {
                        WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                    }
                    WMMessageBox.Show(this, "此卡未刷卡,不能写入数据!");
                    return;
                }
            }
            string tagUserId = this.userIdTB.Text.Trim();

            if (!tagUserId.Equals(consumeCardEntity.UserId.ToString()))
            {
                bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                if (!refund_status)
                {
                    WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                }
                WMMessageBox.Show(this, "卡片与用户信息错误!");
                return;
            }
            ConsumeCardEntity consumeCardEntity2 = this.getConsumeCardEntity();

            consumeCardEntity2.DeviceHead.ConsumeFlag = 0U;
            consumeCardEntity2.ConsumeTimes          += 1U;
            if (consumeCardEntity != null)
            {
                consumeCardEntity2.DeviceHead.RefundFlag           = consumeCardEntity.DeviceHead.RefundFlag;
                consumeCardEntity2.DeviceHead.ValveCloseStatusFlag = consumeCardEntity.DeviceHead.ValveCloseStatusFlag;
                consumeCardEntity2.DeviceHead.ReplaceCardFlag      = consumeCardEntity.DeviceHead.ReplaceCardFlag;
                consumeCardEntity2.DeviceHead.SurplusNumH          = consumeCardEntity.DeviceHead.SurplusNumH;
                consumeCardEntity2.DeviceHead.SurplusNumL          = consumeCardEntity.DeviceHead.SurplusNumL;
            }
            // 开启非阻塞
            Program.MsgBoxNonBlocking = true;
            // 阻塞标记置为空
            Program.MsgBoxMessage = "";
            num = (long)this.writeCard(consumeCardEntity2.getEntity());
            // 关闭非阻塞
            Program.MsgBoxNonBlocking = false;
            // 阻塞标记不为空 执行响应的后续操作并提醒用户
            if (!string.IsNullOrWhiteSpace(Program.MsgBoxMessage))
            {
                bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                if (!refund_status)
                {
                    WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                }
                WMMessageBox.Show(this, Program.MsgBoxMessage);
                Program.MsgBoxMessage = "";
                return;
            }

            if (num == 0L)
            {
                dbUtil.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity2.UserId).ToString());
                DataRow dataRow = dbUtil.ExecuteRow("SELECT * FROM metersTable WHERE meterId=@userId");

                dbUtil.AddParameter("permanentUserId", dataRow["permanentUserId"].ToString());
                DataRow dataRow2 = dbUtil.ExecuteRow("SELECT * FROM usersTable WHERE permanentUserId=@permanentUserId");

                ulong num12 = ConvertUtils.ToUInt64(dataRow2["totalPursuitNum"].ToString());
                num12 += (ulong)consumeCardEntity2.TotalRechargeNumber;

                List <string> list = new List <string>();
                Dictionary <string, string> usersTableUpdate = new Dictionary <string, string>();
                usersTableUpdate.Add("totalPursuitNum", string.Concat(num12));
                usersTableUpdate.Add("userBalance", "0");
                // 用户信息更新语句拼接
                string usersUpdate = DictToMySqlUpdate(usersTableUpdate, "usersTable", "permanentUserId='" + dataRow["permanentUserId"].ToString() + "'");
                list.Add(usersUpdate);

                TimeSpan timeSpan = DateTime.Now - DT1970;
                Dictionary <string, string> userCardLogParam = new Dictionary <string, string>();
                userCardLogParam.Add("time", ConvertUtils.ToInt64(timeSpan.TotalSeconds).ToString());
                userCardLogParam.Add("userHead", ConvertUtils.ToInt64(consumeCardEntity2.CardHead.getEntity()).ToString());
                userCardLogParam.Add("deviceHead", ConvertUtils.ToInt64(consumeCardEntity2.DeviceHead.getEntity()).ToString());
                userCardLogParam.Add("userId", ConvertUtils.ToInt64(consumeCardEntity2.UserId).ToString());
                userCardLogParam.Add("pursuitNum", ConvertUtils.ToInt64(consumeCardEntity2.TotalRechargeNumber).ToString());
                userCardLogParam.Add("totalNum", ConvertUtils.ToInt64(consumeCardEntity2.TotalReadNum).ToString());
                userCardLogParam.Add("consumeTimes", ConvertUtils.ToInt64(consumeCardEntity2.ConsumeTimes).ToString());
                userCardLogParam.Add("operator", Program.staffId);
                userCardLogParam.Add("operateType", "1");
                userCardLogParam.Add("totalPayNum", string.Concat(buyer_pay_amount));
                userCardLogParam.Add("unitPrice", this.getPriceConsistValue().ToString("0.00"));
                userCardLogParam.Add("permanentUserId", dataRow["permanentUserId"].ToString());
                // 用户卡日志插入语句拼接
                string userCardLog = DictToMySqlInsert(userCardLogParam, "userCardLog");
                list.Add(userCardLog);

                // 用户卡日志插入的ID
                string selectNum2 = $"(SELECT MAX(operationId) FROM `usercardlog` WHERE userId = '{ConvertUtils.ToInt64(consumeCardEntity2.UserId).ToString()}' )";

                Dictionary <string, string> operationLogParam = new Dictionary <string, string>();
                operationLogParam.Add("userId", ConvertUtils.ToInt64(consumeCardEntity2.UserId).ToString());
                operationLogParam.Add("cardType", ConvertUtils.ToInt64(1.0).ToString());
                operationLogParam.Add("operationId", "operationIdParam123");
                operationLogParam.Add("operator", Program.staffId);
                operationLogParam.Add("time", ConvertUtils.ToInt64(timeSpan.TotalSeconds).ToString());

                // 用户操作日志插入语句拼接
                string operationLog = DictToMySqlInsert(operationLogParam, "operationLog");
                operationLog = operationLog.Replace("'operationIdParam123'", selectNum2);
                list.Add(operationLog);

                Dictionary <string, string> payLogTableParam = new Dictionary <string, string>();
                payLogTableParam.Add("userId", ConvertUtils.ToInt64(consumeCardEntity2.UserId).ToString());
                payLogTableParam.Add("userName", dataRow2["username"].ToString());
                payLogTableParam.Add("pursuitNum", ConvertUtils.ToInt64(consumeCardEntity2.TotalRechargeNumber).ToString());
                payLogTableParam.Add("unitPrice", this.getPriceConsistValue().ToString("0.00"));
                payLogTableParam.Add("totalPrice", string.Concat(buyer_pay_amount));
                payLogTableParam.Add("payType", string.Concat(1));
                payLogTableParam.Add("dealType", "0");
                payLogTableParam.Add("operator", Program.staffId);
                payLogTableParam.Add("operateTime", ConvertUtils.ToInt64(timeSpan.TotalSeconds).ToString() ?? "");
                payLogTableParam.Add("userCardLogId", "userCardLogIdParam123");
                payLogTableParam.Add("permanentUserId", dataRow["permanentUserId"].ToString());
                payLogTableParam.Add("realPayNum", string.Concat(buyer_pay_amount));
                // 支付日志插入语句拼接
                string payLogTable = DictToMySqlInsert(payLogTableParam, "payLogTable");
                payLogTable = payLogTable.Replace("'userCardLogIdParam123'", selectNum2);
                list.Add(payLogTable);
                // 执行SQL语句 -- 事务
                int count = dbUtil.ExecuteSqlTran(list);
                // 执行SQL语句失败
                if (count == 0)
                {
                    bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                    if (!refund_status)
                    {
                        WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                    }
                    // 取消写卡
                    long numx = (long)this.writeCard(consumeCardEntity.getEntity());
                    Console.WriteLine(numx + "数据存储失败! 写卡的数据恢复到写卡之前");
                    WMMessageBox.Show(this, "数据存储失败!");
                    return;
                }

                // 重新加载充值信息
                this.loadAllRegisterDGV(string.Concat(consumeCardEntity2.UserId));

                showPaySucceed();
            }
            else
            {
                bool refund_status = RefundRequest(out_order_no, create_time, buyer_pay_amount);
                if (!refund_status)
                {
                    WMMessageBox.Show(this, "退款失败,后台程序会继续尝试退款操作,如1天内还未退款,请按照本软件首页提示的方式联系管理员!");
                }
                return;
            }
        }
        // Token: 0x060003EC RID: 1004 RVA: 0x00035448 File Offset: 0x00033648
        private void writeCard()
        {
            ConsumeCardEntity consumeCardEntity = new ConsumeCardEntity();
            CardHeadEntity    cardHeadEntity    = new CardHeadEntity();

            cardHeadEntity.parseEntity(ConvertUtils.ToUInt32(this.lastPursuitInfo["userHead"].ToString()));
            consumeCardEntity.CardHead = cardHeadEntity;
            DeviceHeadEntity deviceHeadEntity = new DeviceHeadEntity();

            deviceHeadEntity.parseEntity(ConvertUtils.ToUInt32(this.lastPursuitInfo["deviceHead"].ToString()));
            deviceHeadEntity.ReplaceCardFlag = 1U;
            if (this.forceStatus_CB.SelectedIndex <= 0)
            {
                deviceHeadEntity.ForceStatus = 0U;
            }
            else
            {
                deviceHeadEntity.ForceStatus = (uint)this.forceStatus_CB.SelectedIndex;
            }
            consumeCardEntity.DeviceHead          = deviceHeadEntity;
            consumeCardEntity.UserId              = ConvertUtils.ToUInt32(this.lastPursuitInfo["userId"].ToString());
            consumeCardEntity.TotalRechargeNumber = ConvertUtils.ToUInt32(this.lastPursuitInfo["pursuitNum"].ToString());
            uint num = ConvertUtils.ToUInt32(this.lastPursuitInfo["operateType"].ToString());

            if (num == 3U)
            {
                uint num2 = ConvertUtils.ToUInt32(this.lastPursuitInfo["consumeTimes"].ToString());
                consumeCardEntity.ConsumeTimes = num2 - 1U;
            }
            else
            {
                consumeCardEntity.ConsumeTimes = ConvertUtils.ToUInt32(this.lastPursuitInfo["consumeTimes"].ToString());
            }
            if (num == 4U)
            {
                consumeCardEntity.DeviceHead.RefundFlag   = 1U;
                consumeCardEntity.DeviceHead.ConsumeFlag  = 1U;
                consumeCardEntity.DeviceHead.DeviceIdFlag = 1U;
            }
            long num3;

            if (!MainForm.DEBUG)
            {
                num3 = (long)this.parentForm.writeCard(consumeCardEntity.getEntity());
                if (num3 != 0L)
                {
                    WMMessageBox.Show(this, "写卡失败!");
                    return;
                }
            }
            DateTime now      = DateTime.Now;
            TimeSpan timeSpan = now - WMConstant.DT1970;
            long     num4     = (long)timeSpan.TotalSeconds;

            this.db.AddParameter("time", ConvertUtils.ToInt64(timeSpan.TotalSeconds).ToString());
            this.db.AddParameter("userHead", ConvertUtils.ToInt64(consumeCardEntity.CardHead.getEntity()).ToString());
            this.db.AddParameter("deviceHead", ConvertUtils.ToInt64(consumeCardEntity.DeviceHead.getEntity()).ToString());
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.AddParameter("pursuitNum", ConvertUtils.ToInt64(consumeCardEntity.TotalRechargeNumber).ToString());
            this.db.AddParameter("unitPrice", "0");
            this.db.AddParameter("totalNum", ConvertUtils.ToInt64(consumeCardEntity.TotalReadNum).ToString());
            this.db.AddParameter("consumeTimes", ConvertUtils.ToInt64(consumeCardEntity.ConsumeTimes).ToString());
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("operateType", "2");
            this.db.AddParameter("totalPayNum", "0");
            this.db.AddParameter("permanentUserId", this.lastPursuitInfo["permanentUserId"].ToString());
            num3 = this.db.ExecuteNonQueryAndReturnLastInsertRowId("INSERT INTO userCardLog(time, userHead, deviceHead, userId, pursuitNum, unitPrice, totalNum, consumeTImes, operator, operateType, totalPayNum, permanentUserId) VALUES (@time, @userHead, @deviceHead, @userId, @pursuitNum, @unitPrice, @totalNum, @consumeTImes, @operator, @operateType, @totalPayNum, @permanentUserId)");
            uint num5 = MainForm.DEBUG ? 123U : this.parentForm.getCardID();

            this.db.AddParameter("cardId", string.Concat(num5));
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.ExecuteNonQuery("UPDATE cardData SET cardId=@cardId WHERE userId=@userId");
            this.db.AddParameter("userId", ConvertUtils.ToInt64(consumeCardEntity.UserId).ToString());
            this.db.AddParameter("userName", this.nameTB.Text);
            this.db.AddParameter("pursuitNum", "0");
            this.db.AddParameter("unitPrice", "0");
            this.db.AddParameter("totalPrice", this.replaceCardFeeTB.Text.Trim());
            this.db.AddParameter("payType", "2");
            this.db.AddParameter("dealType", "0");
            this.db.AddParameter("operator", MainForm.getStaffId());
            this.db.AddParameter("operateTime", string.Concat(num4));
            this.db.AddParameter("userCardLogId", string.Concat(num3));
            this.db.AddParameter("permanentUserId", this.lastPursuitInfo["permanentUserId"].ToString());
            this.db.AddParameter("realPayNum", ConvertUtils.ToDouble(this.realPayNumTB.Text.Trim()).ToString("0.00") ?? "");
            this.db.ExecuteNonQuery("INSERT INTO payLogTable(userId,userName,pursuitNum,unitPrice,totalPrice,payType,dealType,operator,operateTime,userCardLogId, permanentUserId, realPayNum) VALUES (@userId,@userName,@pursuitNum,@unitPrice,@totalPrice,@payType,@dealType,@operator,@operateTime,@userCardLogId, @permanentUserId, @realPayNum)");
            this.clearAllBtn_Click(new object(), new EventArgs());
            WMMessageBox.Show(this, "补卡完成!");
        }