private void btnOrderPay_Click(object sender, EventArgs e)
 {
     if (oiBll.PayOrder(oi, cbkMoney.Checked))
     {
         MessageBox.Show("结账成功");
         this.Close();
         ChangeTabPageImage?.Invoke();
     }
     else
     {
         MessageBox.Show("结账失败,请稍后再试!");
     }
 }
Пример #2
0
        public string AckPayOrder(request <Entity.SRequest.ackPayOrder> ackPayOrder)
        {
            if (ackPayOrder == null)
            {
                return(RsXmlHelper.ResXml(-1, "XML格式错误"));
            }

            var feeInfo = feeinfoBLL.Get(ackPayOrder.model.agtOrdNum);

            if (feeInfo != null)
            {
                return(XMLHelper.XmlSerialize(new response <Entity.SResponse.ackPayOrder>()
                {
                    model = new Entity.SResponse.ackPayOrder()
                    {
                        resultCode = 0,
                        resultMessage = "",
                        hisOrdNum = feeInfo.feeid.ToString(),
                        hisMessage = "支付成功"
                    }
                }));
            }

            var orderList = orderInfoBLL.GetHasOrderByRegid(ackPayOrder.model.mzFeeIdList);

            if (!orderList) //判断是否有医嘱单号
            {
                return(RsXmlHelper.ResXml(1, "暂无缴费订单"));
            }

            var orderInfoList = new List <order_info>();

            if (!string.IsNullOrWhiteSpace(ackPayOrder.model.recipeNo))
            {
                orderInfoList = orderInfoBLL.GetMZFeeByBillids(ackPayOrder.model.recipeNo);
            }
            else
            {
                orderInfoList = orderInfoBLL.GetOrderByRegId(Convert.ToInt32(ackPayOrder.model.mzFeeIdList));
            }

            var totalAmount = 0M;

            if (orderInfoList.Where(x => x.feestatus == "未收费").Count() > 0)
            {
                totalAmount = Convert.ToDecimal(orderInfoList.Sum(x => x.totprice));
            }

            if (Convert.ToDecimal(ackPayOrder.model.totalAmout) / 100 != totalAmount)
            {
                return(RsXmlHelper.ResXml(1, "支付金额小于订单总金额"));
            }

            orderInfoBLL.PayOrder(orderInfoList.Select(x => x.billid).ToArray());
            var orderfeeList = orderfeedetailBLL.GetOrder_Feedetails(orderInfoList.Select(x => x.billid).ToArray());

            var regInfo = reginfoBLL.GetReg_Info(Convert.ToInt32(orderInfoList.FirstOrDefault().regid));//挂号信息

            ImmunityBLL immunityBLL = new ImmunityBLL();
            IvfBLL      ivfBLL      = new IvfBLL();

            foreach (var orderInfo in orderInfoList)
            {
                orderInfo.feetime   = DateTime.Now;
                orderInfo.feestatus = "已收费";
                if (orderInfo.extern_source == "ivf")
                {
                    ivfBLL.SetIvfToll(orderInfo.billid, orderInfo.extern_source);
                }
                else if (orderInfo.extern_source == "immunity")
                {
                    immunityBLL.SetImmunityToll(orderInfo.billid, orderInfo.extern_source);
                }
            }
            orderInfoBLL.Updates(orderInfoList);

            var feeid = feeinfoBLL.AddReturnId(new fee_info()
            {
                mzno      = regInfo.mzno,
                pid       = regInfo.pid,
                regid     = regInfo.regid,
                ftype     = 0,
                amountrec = orderInfoList.Sum(x => x.totprice),
                amountcol = Convert.ToDecimal(ackPayOrder.model.totalAmout) / 100,
                userid    = 89757,
                username  = "******",
                addtime   = DateTime.Now,
                printqty  = 0,
                status    = 0,
                del       = false
            });

            List <fee_infodetail> fee_Infodetails = new List <fee_infodetail>();

            foreach (var order_Feedetail in orderfeeList)
            {
                fee_Infodetails.Add(new fee_infodetail()
                {
                    billid     = order_Feedetail.billid,
                    bdid       = order_Feedetail.bdid,
                    dgid       = order_Feedetail.dgid?.ToString(),
                    itemid     = order_Feedetail.itemid,
                    itemname   = order_Feedetail.itemname,
                    spec       = order_Feedetail.spec,
                    itemtype   = order_Feedetail.itemtype,
                    unit       = order_Feedetail.dpunit,
                    prices     = order_Feedetail.prices,
                    qty        = order_Feedetail.total,
                    feetype    = regInfo.feetype,
                    totalprice = order_Feedetail.totalprices,
                    bdfeeid    = order_Feedetail.bdfeeid,
                    execdept   = order_Feedetail.dept,
                    status     = 0,
                    addtime    = DateTime.Now,
                    addperson  = "自助机",
                    del        = false,
                    dosage     = order_Feedetail.dosage,
                    ybname     = order_Feedetail.ybname,
                    feeid      = feeid
                });
            }
            feeInfodetailBLL.Adds(fee_Infodetails);

            feeinfoBLL.AddFeechannel(new fee_channel()
            {
                feeid   = feeid,
                chnn    = ackPayOrder.model.payMode,
                amount  = Convert.ToDecimal(ackPayOrder.model.totalAmout) / 100,
                del     = false,
                chnnsno = ackPayOrder.model.psOrdNum
            });

            if (!string.IsNullOrWhiteSpace(ackPayOrder.model.ybjmc) && !string.IsNullOrWhiteSpace(ackPayOrder.model.mzlsh))  //医保
            {
                feeinfoBLL.AddFeechannel(new fee_channel()
                {
                    feeid   = feeid,
                    chnn    = "医疗保险",
                    amount  = (Convert.ToDecimal(ackPayOrder.model.totalAmout) - Convert.ToDecimal(ackPayOrder.model.payAmout)) / 100,
                    del     = false,
                    chnnsno = ackPayOrder.model.mzlsh
                });
            }
            return(XMLHelper.XmlSerialize(new response <Entity.SResponse.ackPayOrder>()
            {
                model = new Entity.SResponse.ackPayOrder()
                {
                    resultCode = 0,
                    resultMessage = "",
                    hisOrdNum = feeid.ToString(),
                    hisMessage = "支付成功"
                }
            }));
        }