Exemplo n.º 1
0
        public ActionResult successPay(string ordernum)
        {
            var status = false;
            var openid = CommonMethod.getCookie("openid");
            var userid = CommonMethod.getCookie("userid");
            var type   = Request["paytype"];
            var user   = weiUserM.GetModelWithOutTrace(u => u.userNum == userid && u.openid == openid);

            if (user == null)
            {
                return(Content("对不起,请登陆系统!"));
            }

            var order = orderB.GetModelWithOutTrace(o => o.orderNum == ordernum);

            if (order == null)
            {
                return(Content("对不起,这个订单是错误的!"));
            }
            if (string.IsNullOrEmpty(type))
            {
                //添加交易记录
                TG_transactionLog transactionlog = new TG_transactionLog();
                transactionlog.userId      = userid;
                transactionlog.openid      = openid;
                transactionlog.tranCate    = 0;
                transactionlog.CateName    = "微信消费";
                transactionlog.tranMoney   = order.yunPrice;
                transactionlog.tranContent = "微信消费(订单号:" + ordernum + ")消费:" + order.total_fee + " 元,预付:" + order.yunPrice + " 元";
                transactionlog.orderNum    = ordernum;
                transactionlog.remark4     = "1001";
                transactionlog.AddTime     = DateTime.Now;
                transactionlogB.Add(transactionlog);
                YX_sysNews sysnew = new YX_sysNews();
                sysnew.userid      = userid;
                sysnew.orderId     = ordernum;
                sysnew.newsCate    = "订单提醒";
                sysnew.newsContent = "用户微信支付成功";
                sysnew.newsState   = 0;
                sysnew.Addtime     = DateTime.Now;
                OperateContext.Current.BLLSession.IYX_sysNews_MANAGER.Add(sysnew);
                Common.Tools.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + WeChatConfig.IsExistAccess_Token2(), WeChatConfig.GetSubcribePostData(openid, transactionlog.tranContent));
            }
            else if (user.isfenxiao >= 1 && user.userYongJin > order.total_fee)
            {
                order.ssh_status = 3;
                order.ispay      = 3;
                order.yunPrice   = order.total_fee;
                order.payTime    = DateTime.Now;
                orderB.Modify(order, "yunPrice", "payTime", "ispay", "ssh_status");
                //添加交易记录
                TG_transactionLog transactionlog = new TG_transactionLog();
                transactionlog.userId      = userid;
                transactionlog.openid      = openid;
                transactionlog.tranCate    = 0;
                transactionlog.CateName    = "微信消费";
                transactionlog.tranMoney   = order.total_fee;
                transactionlog.tranContent = "会员微信消费(订单号:" + ordernum + ")消费:" + order.total_fee + " 元";
                transactionlog.orderNum    = ordernum;
                transactionlog.remark4     = "1002";
                transactionlog.AddTime     = DateTime.Now;
                transactionlogB.Add(transactionlog);
                user.userYongJin = user.userYongJin - order.total_fee;
                weiUserM.Modify(user, "userYongJin");
                YX_sysNews sysnew = new YX_sysNews();
                sysnew.userid      = userid;
                sysnew.orderId     = ordernum;
                sysnew.newsCate    = "订单提醒";
                sysnew.newsContent = "用户微信支付成功";
                sysnew.newsState   = 0;
                sysnew.Addtime     = DateTime.Now;
                OperateContext.Current.BLLSession.IYX_sysNews_MANAGER.Add(sysnew);
                Common.Tools.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + WeChatConfig.IsExistAccess_Token2(), WeChatConfig.GetSubcribePostData(openid, transactionlog.tranContent));
            }
            else
            {
            }
            List <string> openids = new List <string>()
            {
                "oJUBAv7TVJBowlpJs58qBvCNCrAc", "oJUBAv1jDW_8IQyyvYyTjW2Q6o3w", "oJUBAv9bmEB2mFMSZyLkZBaTK540", "oJUBAv3rjppIvGenkn3h1MIo4wts", "oJUBAv7XiorX2muQXNft5ChU1OCk", "oJUBAv2Omhudt9cyqG_f2A1xMhUA"
            };

            foreach (var item in openids)
            {
                Common.Tools.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + WeChatConfig.IsExistAccess_Token2(), WeChatConfig.GetSubcribePostData(item, "用户: " + user.userRelname + "  已成功预约。\n预约订单号:" + order.orderNum + "\n预约时间:" + order.remark4 + "  " + order.remark5 + "\n 联系电话:" + user.userTel));
            }

            return(Redirect("/aoshacar/OrderDetail?orderid=" + ordernum));
        }
Exemplo n.º 2
0
        public ActionResult FinishOrder(VIEW_TG_order model)
        {
            var  order  = orderB.GetModelWithOutTrace(o => o.orderNum == model.orderNum);
            bool status = false;

            try
            {
                var user = userB.GetModelWithOutTrace(u => u.userNum == order.UserId);
                if (Request["ONLINE"] != null && order != null && user != null)
                {
                    if (model.total_fee <= 0)
                    {
                        return(this.JsonFormat("SYSERROR", status, "订单的金额不正确"));
                    }


                    if (user.userYongJin < model.total_fee)
                    {
                        return(this.JsonFormat("SYSERROR", status, "用户的余额不足"));
                    }
                    else if (order.ispay < 3)
                    {
                        order.total_fee  = model.total_fee;
                        order.yunPrice   = model.yunPrice;
                        order.ispay      = 3;
                        order.ssh_status = 3;
                        order.payTime    = DateTime.Now;
                        order.remark5    = model.remark5;
                        order.remark6    = model.remark6;
                        orderB.Modify(order, "total_fee", "yunPrice", "ispay", "ssh_status", "payTime", "remark5", "remark6");
                        user.userYongJin = user.userYongJin - order.total_fee;
                        userB.Modify(user, "userYongJin");
                        //添加交易记录
                        TG_transactionLog transactionlog = new TG_transactionLog();
                        transactionlog.userId      = user.userNum;
                        transactionlog.openid      = user.openid;
                        transactionlog.tranCate    = 0;
                        transactionlog.CateName    = "到店消费";
                        transactionlog.tranMoney   = order.total_fee;
                        transactionlog.tranContent = "到店消费(订单号:" + order.orderNum + ")消费:" + order.total_fee + " 元";
                        transactionlog.orderNum    = order.orderNum;
                        transactionlog.remark4     = "1003";
                        transactionlog.AddTime     = DateTime.Now;
                        transactionlogB.Add(transactionlog);
                        if (model.IsNotice)
                        {
                            Common.Tools.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + WeChatConfig.IsExistAccess_Token2(), WeChatConfig.GetSubcribePostData(user.openid, transactionlog.tranContent));
                        }
                        status = true;
                    }
                    else
                    {
                        status = true;
                        return(this.JsonFormat("/Admin/Order/OrderDetail?ordernum=" + model.orderNum, status, "该订单已经支付了!", true, "SYSSUCCESS"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(this.JsonFormat(status, !status, ex.Message + ex.StackTrace));
            }
            return(this.JsonFormat("/Admin/Order/OrderDetail?ordernum=" + model.orderNum, status, "支付成功!", true, "SYSSUCCESS"));
        }