Esempio n. 1
0
 public PrintTickets(ChargeRecord chargeRecord, List <ChargeDetail> details)
 {
     BoldFont          = new iTextSharp.text.Font(baseFont, 16, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
     NormalFont        = new iTextSharp.text.Font(baseFont, 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
     this.chargeRecord = chargeRecord;
     this.details      = details;
 }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ChargeRecord chargeRecord = new ChargeRecord();

            chargeFiller.FillEntity(chargeRecord);
            chargeRecord.DateOfCharge = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            chargeRecord.ChagreUser   = AppHelper.UserName;
            List <ChargeDetail> details = GetChargeDetails(chargeRecord.PlateNo, chargeRecord.TestNo, out string testItem);

            chargeRecord.TestItem = testItem;

            ChargeApi chargeApi = new ChargeApi();

            chargeApi.SaveChargeDetails(details);

            var resp = chargeApi.SaveChargeRecord(chargeRecord);

            if (resp.Code == 1)
            {
                FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功", ContentAlignment.MiddleCenter);
            }
            else
            {
                FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败" + resp?.Message, ContentAlignment.MiddleCenter);
            }
        }
Esempio n. 3
0
 public Task <Tuple <bool, string> > SaveChargeRecord(ChargeRecord chargeRecord)
 {
     return(Task.Run(() => {
         var succ = true;
         var msg = "保存成功";
         try
         {
             var record = this.chargeContext.chargeRecords.AsNoTracking().Where(p => p.PlateNo == chargeRecord.PlateNo && p.TestNo == chargeRecord.TestNo).FirstOrDefault();
             if (record == null)
             {
                 this.chargeContext.chargeRecords.Add(chargeRecord);
             }
             else
             {
                 chargeRecord.ID = record.ID;
                 this.chargeContext.chargeRecords.Update(chargeRecord);
             }
             this.chargeContext.SaveChanges();
         }
         catch (Exception ex)
         {
             succ = false;
             msg = ex.Message;
         }
         return new Tuple <bool, string>(succ, msg);
     }));
 }
Esempio n. 4
0
        public void Charge(ChargeRecord model)
        {
            if (model.CardID == 0)
            {
                throw new Exception("card information error;");
            }
            var card = _chargeCardRep.GetById(model.CardID);

            if (card == null)
            {
                throw new Exception("card information error;");
            }
            model.Amount = card.Amount;
            //var user = _userRep.GetById(model.UserID);

            model.SubmitAt = DateTime.Now;
            model.PaySatus = EnumPayStatus.ToPay;
            //add record
            _chargeRecordRep.Add(model);
            //add order
            // pay
            //change status
            //paysuccess
            SaveAccount(model, card.Amount, card.GiftIntegral);
        }
Esempio n. 5
0
 public Task <ResponseModel> SaveChargeRecord(ChargeRecord chargeRecord)
 {
     return(Task.Run(async() =>
     {
         ResponseModel responseModel = new ResponseModel();
         var result = await chargeService.SaveChargeRecord(chargeRecord);
         responseModel.Code = result.Item1 ? 1 : 0;
         responseModel.Message = result.Item2;
         return responseModel;
     }));
 }
Esempio n. 6
0
        private void SaveAccount(ChargeRecord model, decimal cardAmount, decimal giftIntegral)
        {
            var userAccouts = _userAccountRep.FindBy(x => x.UserID == model.UserID);
            var balance     = userAccouts.FirstOrDefault(x => x.AccountType == (int)EnumAccountType.Balance);
            var integral    = userAccouts.FirstOrDefault(x => x.AccountType == (int)EnumAccountType.Integral);

            if (balance == null)
            {
                balance = new UserAccount();
            }
            if (integral == null)
            {
                integral = new UserAccount();
            }
            balance.Amount      += cardAmount;
            balance.AccountType  = (int)EnumAccountType.Balance;
            balance.UserID       = model.UserID;
            integral.AccountType = (int)EnumAccountType.Integral;
            integral.Amount     += giftIntegral;
            integral.UserID      = model.UserID;
            if (balance.ID == 0)
            {
                balance.CreatedAt  = DateTime.Now;
                balance.ModifiedAt = DateTime.Now;
                _userAccountRep.Add(balance);
            }
            else
            {
                balance.ModifiedAt = DateTime.Now;
                _userAccountRep.Update(balance);
            }
            if (integral.ID == 0)
            {
                integral.CreatedAt  = DateTime.Now;
                integral.ModifiedAt = DateTime.Now;
                _userAccountRep.Add(integral);
            }
            else
            {
                integral.ModifiedAt = DateTime.Now;
                _userAccountRep.Update(integral);
            }
            _uow.Commit();
            model.CurrentAmount = balance.Amount;
        }
Esempio n. 7
0
 public ActionResult Charge(string code, long cid = 0)
 {
     try
     {
         Code         = code;
         ViewBag.Code = Code;
         LoadMemberInfo();
         var chargeRecord = new ChargeRecord()
         {
             UserID = _user.ID, CardID = cid
         };
         _chargeSrv.Charge(chargeRecord);
         return(Json(new { success = true, data = "" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, msg = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 8
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     ControlHelper.ThreadRunExt(AppHelper.MainForm, () =>
     {
         try
         {
             ChargeRecord chargeRecord = new ChargeRecord();
             chargeFiller.FillEntity(chargeRecord);
             chargeRecord.DateOfCharge   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             chargeRecord.ChagreUser     = AppHelper.UserName;
             List <ChargeDetail> details = GetChargeDetails(chargeRecord.PlateNo, chargeRecord.TestNo, out string testItem);
             PrintTickets printTickets   = new PrintTickets(chargeRecord, details);
             printTickets.Print();
         }
         catch (Exception ex)
         {
             ControlHelper.ThreadInvokerControl(AppHelper.MainForm, () =>
             {
                 FrmTips.ShowTips(AppHelper.MainForm, $"打印异常{ex.Message}", 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 100), TipsState.Error);
             });
         }
     }, null, AppHelper.MainForm, true, "正在打印……", 200);
 }
Esempio n. 9
0
        public async Task <IActionResult> UnifiedOrder([FromQuery] int id, [FromBody] ChargeRecord record, [FromServices] AppData appData)
        {
            var member = await Service.GetAsync <WxMember>(id);

            var business = await Service.GetAsync <Business>(member.BusinessId);

            record.BusinessId = business.ID;
            record.Code       = $"{DateTime.Now:yyyyMMddHHmmss}0{UtilHelper.RandNum(8)}";
            record.RelativeId = member.ID;
            await Service.AddAsync(record);

            var option = new WxUnifiePayment
            {
                appid            = business.PayServerAppId,
                mch_id           = business.PayServerMchId,
                sub_appid        = business.WeChatAppId,
                sub_mch_id       = business.MchId,
                device_info      = "WEB",
                body             = $"{business.Name}-会员充值",
                attach           = record.ID.ToString(),
                out_trade_no     = record.Code,
                total_fee        = record.Amount,
                key              = business.PayServerKey,
                notify_url       = appData.Domain + "/api/card/paySuccess",
                spbill_create_ip = appData.HostIpAddress,
                sub_openid       = record.OpenId
            };

            Log.Debug(option.notify_url);
            if (appData.RunMode == "test" || business.ID == 1)
            {
                option.total_fee = 1;
            }
            option.Generator();
            var xml = string.Empty;

            using (var stream = new MemoryStream())
            {
                UtilHelper.XmlSerializeInternal(stream, option);
                stream.Position = 0;
                using (var reader = new StreamReader(stream))
                {
                    xml = reader.ReadToEnd();
                }
            }

            var ret = await WxHelper.UnifiedOrderAsync(xml);

            var result = new JsonData();

            if (ret.return_code == "FAIL")
            {
                result.Msg = ret.return_msg;
            }
            else if (ret.result_code == "FAIL")
            {
                result.Msg = ret.err_code_des;
            }
            else
            {
                result.Success = true;
                var payment = new WxPayment
                {
                    appId   = business.WeChatAppId,
                    package = "prepay_id=" + ret.prepay_id,
                    key     = business.PayServerKey
                };
                // 保存支付标识码
                record.PrepayId = ret.prepay_id;
                Service.Commit();
                payment.Generator();
                result.Data = payment;
            }
            return(Json(result));
        }
Esempio n. 10
0
 //保存收费记录
 public ResponseModel SaveChargeRecord(ChargeRecord chargeRecord)
 {
     return(apiHelper.ReqPost("Charge/SaveChargeRecord", chargeRecord));
 }
Esempio n. 11
0
        public ActionResult SaleSubmit(SMS.Model.EnterpriseUser eu)
        {
            try
            {
                var sr = new SMS.Model.RPCResult(false, "");

                string enterpriseCode      = Request["EnterpriseCode"];
                string enterpriseAccountID = Request["EnterpriseAccountID"];
                string agentAccountID      = Request["AgentAccountID"];
                string Description         = "企业新开充值";


                eu.AccountCode       = enterpriseCode;
                eu.AccountID         = enterpriseAccountID;
                eu.Name              = "";
                eu.IsAgent           = false;
                eu.IsOpen            = false;
                eu.FilterType        = (ushort)FilterType.Replace;
                eu.Audit             = AccountAuditType.Audit;
                eu.SMSType           = Util.SMSType;
                eu.StatusReport      = StatusReportType.Disable;
                eu.Enabled           = true;
                eu.RegisterDate      = DateTime.Now;
                eu.Password          = Util.GeneratePassword(8); //随机生成8位密码。
                eu.Channel           = Util.DefaultChannel;
                eu.ParentAccountCode = "-1";                     //无上级企业
                string spNumber = Util.GenSpNumber();            //随机算法生成
                var    entlist  = Util.SMSProxy.ISMPGetAllEnterprise().Value;
                //检验号码是否可用
                while (true)
                {
                    if (entlist.Any(e => e.SPNumber == spNumber))
                    {
                        spNumber = Util.GenSpNumber();//重新生成
                    }
                    else
                    {
                        break;
                    }
                }
                eu.SPNumber = spNumber;

                //检查企业是否已存在
                if (!entlist.Any(e => e.AccountCode == eu.AccountCode))
                {
                    //不存在,注册企业,不审核
                    sr = Util.SMSProxy.ISMPAddEnterprise(eu);
                    if (sr.Success)
                    {
                        try
                        {
                            //添加默认通讯录分组
                            bool resultAddContactGroup = PhoneAndGroupDB.GroupAdd(enterpriseCode, "0", "未分组");
                        }
                        catch (Exception ex)
                        {
                            Log4Logger.Error(ex);
                        }
                        //ISMP 订单
                        string url = Util.ISMPHost + "/CallBack/OpenProduct_CallBack?";
                        url += "Id=" + System.Web.HttpUtility.UrlEncode(System.Guid.NewGuid().ToString())
                               + "&EnterpriseAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID)
                               + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId)
                               + "&Description=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductName + "订单");

                        string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8);
                        var    o      = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty });
                        if (!o.success)
                        {
                            //需要通知运维进行处理或再次尝试
                            Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功,回调ISMP添加订单失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,添加订单失败原因【" + o.message + "】", "开通失败", CurrentUser);
                            return(GetActionResult(new RPC_Result(false, "添加短信订单失败,请联系客服")));
                        }
                        else
                        {
                            Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通产品", CurrentUser);
                        }
                    }
                    else
                    {
                        return(GetActionResult(sr));
                    }
                }
                else
                {
                    return(GetActionResult(new RPC_Result(false, "该企业已开通短信产品,不能重复开通!")));
                }

                var smsNumber = int.Parse(string.IsNullOrWhiteSpace(Request["smsNumber"]) ? "0" : Request["smsNumber"]);
                //开通同时给企业充值
                if (smsNumber > 0)
                {
                    ChargeRecord cr = new ChargeRecord();
                    cr.ChargeFlag      = 0;
                    cr.Money           = smsNumber * Util.SMSRate;
                    cr.SMSCount        = smsNumber;
                    cr.ThenRate        = Convert.ToDecimal(Util.SMSRate);
                    cr.OperatorAccount = CurrentUser.LoginName;
                    cr.PrepaidAccount  = enterpriseCode;
                    cr.PrepaidTime     = DateTime.Now;
                    cr.PrepaidType     = 1;

                    //ISMP 扣费
                    string url = Util.ISMPHost + "/CallBack/DeductForProduct?";
                    url += "DeductAccountId=" + System.Web.HttpUtility.UrlEncode(agentAccountID)
                           + "&RechargeAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID)
                           + "&Money=" + System.Web.HttpUtility.UrlEncode(Convert.ToString(cr.Money))
                           + "&Description=" + System.Web.HttpUtility.UrlEncode(Description)
                           + "&ProductPayType=" + System.Web.HttpUtility.UrlEncode("短信充值")
                           + "&ApplyAccountId=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorAccountId)
                           + "&ApplyName=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorName)
                           + "&Type=" + System.Web.HttpUtility.UrlEncode("21")
                           + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId);

                    string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8);
                    var    o      = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty });
                    if (o.success)
                    {
                        var r = Util.SMSProxy.AccountPrepaid(cr);
                        if (r.Success)
                        {
                            Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通完成,充值短信【" + smsNumber + "】条。", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "短信充值", CurrentUser);
                            return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。")));
                        }
                        else
                        {
                            //此处应记录日志和错误,并及时通知
                            //此处扣费成功但充值失败。

                            Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通且扣费成功,充值失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,充值失败原因【" + r.Message + "】", "短信充值失败", CurrentUser);
                            return(GetActionResult(new RPC_Result(false, "开通且扣费成功,充值失败,请联系客服")));
                        }
                    }
                    else
                    {
                        Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "注册完成,扣费失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,金额【" + cr.Money + "】,扣费失败原因【" + o.message + "】", "开通", CurrentUser);
                        return(GetActionResult(new RPC_Result(false, "注册完成,扣费失败,失败原因【" + o.message + "】")));
                    }
                }
                else
                {
                    Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "开通完成,充值短信【" + smsNumber + "】条", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通", CurrentUser);
                    return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。")));
                }

                //return GetActionResult(sr);
            }
            catch (Exception ex)
            {
                Log4Logger.Error(ex);
                return(GetActionResult(new RPC_Result(true, "操作异常")));
            }
        }
Esempio n. 12
0
        public ActionResult DoRecharge()
        {
            try
            {
                string enterpriseCode      = Request["EnterpriseCode"];
                string enterpriseAccountID = Request["EnterpriseAccountID"];
                string agentAccountID      = Request["AgentAccountID"];
                string Description         = Request["Description"];

                string IsGrant   = Request["IsGrant"];
                string Type      = "22";
                string GrantType = "";
                if (IsGrant == "1")
                {
                    //验证key
                    string key  = Request["key"];
                    var    skey = Session["key"];
                    if (skey != null && skey.ToString() == key)
                    {
                        GrantType = Request["GrantType"];
                        Type      = "2";
                    }
                    else
                    {
                        return(GetActionResult(new RPC_Result(false, "充值失败,请重新登录后操作")));
                    }
                }

                if (string.IsNullOrWhiteSpace("enterpriseCode") || string.IsNullOrWhiteSpace("enterpriseAccountID") || string.IsNullOrWhiteSpace("agentAccountID"))
                {
                    return(GetActionResult(new RPC_Result(false, "充值失败,缺少参数")));
                }


                var smsNumber = int.Parse(string.IsNullOrWhiteSpace(Request["smsNumber"]) ? "0" : Request["smsNumber"]);
                //给企业充值
                if (smsNumber > 0)
                {
                    ChargeRecord cr = new ChargeRecord();
                    cr.ChargeFlag      = 0;
                    cr.Money           = smsNumber * Util.SMSRate;
                    cr.SMSCount        = smsNumber;
                    cr.ThenRate        = Convert.ToDecimal(Util.SMSRate);
                    cr.OperatorAccount = CurrentUser.LoginName;
                    cr.PrepaidAccount  = enterpriseCode;
                    cr.PrepaidTime     = DateTime.Now;
                    cr.PrepaidType     = 1;

                    //ISMP 扣费
                    string url = Util.ISMPHost + "/CallBack/DeductForProduct?"
                                 + "DeductAccountId=" + System.Web.HttpUtility.UrlEncode(agentAccountID)
                                 + "&RechargeAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID)
                                 + "&Money=" + System.Web.HttpUtility.UrlEncode(Convert.ToString(cr.Money))
                                 + "&Description=" + System.Web.HttpUtility.UrlEncode(Description)
                                 + "&ProductPayType=" + System.Web.HttpUtility.UrlEncode("短信充值")
                                 + "&ApplyAccountId=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorAccountId)
                                 + "&ApplyName=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorName)
                                 + "&Type=" + System.Web.HttpUtility.UrlEncode(Type)
                                 + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId);
                    if (IsGrant == "1")
                    {
                        url += "&GrantType=" + System.Web.HttpUtility.UrlEncode(GrantType);
                    }
                    string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8);
                    var    o      = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty });
                    if (o.success)
                    {
                        var r = Util.SMSProxy.AccountPrepaid(cr);
                        if (r.Success)
                        {
                            Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "充值短信【" + smsNumber + "】条。", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】", "充值", CurrentUser);
                            return(GetActionResult(new RPC_Result(true, "充值成功,充值短信【" + smsNumber + "】条。")));
                        }
                        else
                        {
                            //此处应记录日志和错误,并及时通知
                            Util.SendAlertMessageByEmail(Util.SMSProductName + "产品充值扣费成功,充值失败:企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,充值失败原因【" + r.Message + "】");
                            //此处扣费成功但充值失败。
                            Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "扣费成功,充值失败", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,充值失败原因【" + r.Message + "】", "充值", CurrentUser);
                            return(GetActionResult(new RPC_Result(false, "给代理商扣费成功,充值失败,失败原因【" + r.Message + "】")));
                        }
                    }
                    else
                    {
                        Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "扣费失败", "企业AccountID【" + enterpriseAccountID + "】,代理商AccountID【" + agentAccountID + "】,金额【" + cr.Money + "】,扣费失败原因【" + o.message + "】", "充值", CurrentUser);
                        return(GetActionResult(new RPC_Result(false, "扣费失败,失败原因【" + o.message + "】")));
                    }
                }
                else
                {
                    return(GetActionResult(new RPC_Result(false, "请输入正确的充值条数")));
                }

                //return View();
            }
            catch (Exception ex)
            {
                Log4Logger.Error(ex);
                return(GetActionResult(new RPC_Result(false, "操作异常")));
            }
        }