public ActionResult ModifyPreOrder(long?orderId, string express, int?deleteTag)
        {
            var result = new Result <PreSaleOrder>();

            if (orderId.HasValue)
            {
                //var preSaleOrder = new PreSaleOrder() {OrderId = orderId.Value,  Status = 2};
                var preSaleOrder = PreSaleOrderService.GetPreSaleOrder(orderId.Value);
                preSaleOrder.Status = 2;
                if (deleteTag.HasValue)
                {
                    preSaleOrder.DeleteTag = deleteTag.Value;
                }
                if (!string.IsNullOrEmpty(express))
                {
                    preSaleOrder.ExpressDelivery = express;
                }
                var flag = PreSaleOrderService.ModifyPreOrder(preSaleOrder);
                if (flag)
                {
                    SMSService.SendSMSPreOrderSendProduct(preSaleOrder.Phone, preSaleOrder.OrderId.ToString());
                }
                result.Data   = PreSaleOrderService.GetPreSaleOrder(orderId.Value);
                result.Status = new Status()
                {
                    Code = flag?"1":"0", Message = flag?"成功": "失败"
                };
            }
            return(Content(JsonHelper.ToJson(result), "application/javascript"));
        }
Esempio n. 2
0
        public ContentResult WexinPayNotify()
        {
            ResponseHandler resHandler = new ResponseHandler(null);

            string return_code = resHandler.GetParameter("return_code");
            string return_msg  = resHandler.GetParameter("return_msg");

            resHandler.SetKey(PayKey);
            string res = null;

            //TODO:这里需要验证签名

            ////验证请求是否从微信发过来(安全)
            //logger.Info("IsTenpaySign:" + resHandler.IsTenpaySign());
            if (resHandler.IsTenpaySign())
            {
                try
                {
                    //订单处理
                    if (return_code.ToLower() == "SUCCESS".ToLower())
                    {
                        string out_trade_no = resHandler.GetParameter("out_trade_no");
                        long   orderId      = 0;
                        if (!string.IsNullOrEmpty(out_trade_no))
                        {
                            orderId = Convert.ToInt64(out_trade_no);
                        }
                        logger.Info("orderId:" + orderId + "|out_trade_no=" + out_trade_no);
                        //判断老订单和预售订单
                        var flag = OrderService.CheckOrderExist(orderId);
                        if (flag)
                        {
                            OrderService.UpdateOrderPay(new OrderPayModel()
                            {
                                OrdeId = orderId,
                                //long.Parse(resHandler.GetParameter("out_trade_no")),
                                Status = OrderStatus.Paid.GetHashCode()
                            });
                        }
                        else
                        {
                            PreSaleOrderService.ModifyPreOrder(new PreSaleOrder()
                            {
                                OrderId = orderId, Status = 1
                            });
                            var preOrder = PreSaleOrderService.GetPreSaleOrder(orderId);
                            var mobile   = preOrder.Phone;
                            SMSService.SendSMSPreOrderCreated(mobile, "12月19日");
                        }
                    }

                    res = "SUCCESS";
                }
                catch (Exception e)
                {
                    logger.Error("微信支付回调错误:" + e);
                    res = "FAIL";
                }
                string xml = string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>",
                                           res, return_msg);
                return(Content(xml, "text/xml"));
            }
            else
            {
                return(Content(""));
            }
        }