Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            config = bllWebSite.GetCompanyWebsiteConfig();
            if (config == null)
            {
                config = new CompanyWebsite_Config();
                config.WebsiteTitle       = "膏方专家预约平台";
                config.WebsiteDescription = "膏方专家预约平台";
            }



            if (string.IsNullOrEmpty(Request["id"]))
            {
                Response.Write("id 参数必传");
                Response.End();
            }
            model = bllMall.GetProduct(Request["id"]);
            if (model == null)
            {
                Response.Write("id 参数错误");
                Response.End();
            }
            config.WebsiteTitle = string.Format("中医专家-{0}-膏方预约平台已开通!", model.PName);
            if (model.IsOnSale == "0")
            {
                config.WebsiteTitle = string.Format("中医专家-{0}-膏方预约平台即将开通!", model.PName);
            }

            StringBuilder sbWhere = new StringBuilder();

            sbWhere.AppendFormat("  WebsiteOwner='{0}' And TableName ='ZCJ_WXMallOrderInfo' Order by Sort DESC", bllMall.WebsiteOwner);
            fieldList = bllMall.GetList <TableFieldMapping>(sbWhere.ToString());

            categoryList = bllMall.GetCategoryList().Where(p => p.PreID == 0).Where(p => p.Type == "BookingDoctorFuYou").ToList();

            if (!string.IsNullOrEmpty(model.CategoryId))
            {
                categoryId = model.CategoryId;
                WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoID={0}", model.CategoryId));
                if (category != null)
                {
                    if (category.PreID > 0)
                    {
                        categoryId = bllMall.Get <WXMallCategory>(string.Format(" AutoID={0}", category.PreID)).AutoID.ToString();
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string FieldUpdate(HttpContext context)
        {
            string            field         = context.Request["Field"];
            string            fieldShowName = context.Request["FieldShowName"];
            string            autoId        = context.Request["AutoId"];
            string            isNull        = context.Request["IsNull"];
            string            sort          = context.Request["Sort"];
            string            fieldType     = context.Request["FieldType"];
            string            options       = context.Request["Options"];
            string            isMultiline   = context.Request["IsMultiline"];
            TableFieldMapping model         = bllMall.Get <TableFieldMapping>(string.Format("AutoId={0}", autoId));

            model.Field       = field;
            model.MappingName = fieldShowName;
            model.FieldType   = fieldType;
            model.Options     = options;
            model.IsMultiline = int.Parse(isMultiline);
            if (!string.IsNullOrEmpty(isNull))
            {
                model.FieldIsNull = int.Parse(isNull);
            }
            if (!string.IsNullOrEmpty(sort))
            {
                model.Sort = int.Parse(sort);
            }
            if (bllMall.Update(model))
            {
                apiResp.status = true;
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Example #3
0
File: Get.ashx.cs Project: uvbs/mmp
 /// <summary>
 /// 是否需要继续支付
 /// </summary>
 /// <param name="orderInfo">团长订单</param>
 /// <returns>需要支付的订单号</returns>
 private string GetNeedPayOrderId(WXMallOrderInfo orderInfo)
 {
     if (GetGroupBuyStatus(orderInfo) == 0)//拼团中
     {
         var myOrderInfo = bllMall.Get <WXMallOrderInfo>(string.Format(" WebsiteOwner='{0}' And PaymentStatus=0 And GroupBuyParentOrderId='{1}' And OrderUserId='{2}'", bllMall.WebsiteOwner, orderInfo.OrderID, CurrentUserInfo.UserID));
         if (myOrderInfo != null)
         {
             return(myOrderInfo.OrderID);
         }
     }
     return("");
 }
Example #4
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string List(HttpContext context)
        {
            string promotionActivityId = context.Request["promotion_activity_id"];                                                          //限时特卖活动ID
            int    pageIndex           = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; //页码
            int    pageSize            = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10;  //页数

            pageSize = 1000;
            BLLJIMP.Model.PromotionActivity promotionActivity = new BLLJIMP.Model.PromotionActivity();
            if (!string.IsNullOrEmpty(promotionActivityId))
            {
                promotionActivity = bllMall.Get <BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", promotionActivityId));
            }
            int totalCount = 0;
            var sourceData = bllMall.GetPromotionProductList(context, out totalCount);
            //using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"D:\WXOpenOAuthDevLog.txt", true, System.Text.Encoding.GetEncoding("gb2312")))
            //{
            //    sw.WriteLine(string.Format("{0}\t{1}", DateTime.Now.ToString(), ZentCloud.Common.JSONHelper.ObjectToJson(sourceData)));
            //}
            var list = from p in sourceData
                       select new
            {
                product_id      = p.PID,
                category_id     = p.CategoryId,
                title           = p.PName,
                quote_price     = p.PreviousPrice,
                price           = bllMall.GetShowPrice(p),
                promotion_price = bllMall.GetMinPrommotionPrice(int.Parse(p.PID)),
                img_url         = bllMall.GetImgUrl(p.RecommendImg),
                is_onsale       = (!string.IsNullOrEmpty(p.IsOnSale) && p.IsOnSale == "1") ? 1 : 0,
                totalcount      = bllMall.GetProductTotalStockPromotion(int.Parse(p.PID)),
                tags            = p.Tags,
                promotion_count = bllMall.GetProductTotalPromotionSaleStock(int.Parse(p.PID)),
                //start_time = bllMall.Get<BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", p.PromotionActivityId)).StartTime,
                //stop_time = bllMall.Get<BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", p.PromotionActivityId)).StopTime,
                start_time            = promotionActivity.StartTime,
                stop_time             = promotionActivity.StopTime,
                is_sms_remind         = IsRemind(p.PromotionActivityId.ToString(), bllMall.GetCurrUserID()),
                is_collect            = IsCollectProduct(int.Parse(p.PID)),
                promotion_activity_id = p.PromotionActivityId
            };

            list       = list.Where(p => p.promotion_count > 0).ToList();
            totalCount = list.Count();
            // list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize);
            return(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                start_time = promotionActivity.StartTime,
                stop_time = promotionActivity.StopTime,
                totalcount = totalCount,
                list = list
            }));
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            string taskId = context.Request["task_id"];

            List <WXMallStatisticsOrder> list = new List <WXMallStatisticsOrder>();

            BLLJIMP.Model.WXMallStatisticsOrder model = bllMall.Get <BLLJIMP.Model.WXMallStatisticsOrder>(string.Format("TaskId='{0}' And WebsiteOwner='{1}'", taskId, bllMall.WebsiteOwner));
            list.Add(model);
            apiResp.status = true;
            apiResp.msg    = "ok";
            apiResp.result = new
            {
                totalcount = 1,
                list       = from p in list
                             select new {
                    insert_date         = p.InsertDate.ToString(),
                    from_date           = p.FromDate != null ? ((DateTime)p.FromDate).ToString("yyyy-MM-dd HH:mm:ss") : "",
                    to_date             = p.ToDate != null ? ((DateTime)p.ToDate).ToString("yyyy-MM-dd HH:mm:ss") : "",
                    total_count         = p.TotalCount,
                    total_amount        = p.TotalAmount,
                    base_total_amount   = p.BaseTotalAmount,
                    total_transport_fee = p.TotalTransportFee,
                    profit = p.Profit,
                    total_coupon_exchang_amount        = p.TotalCouponExchangAmount,
                    total_score_exchang_amount         = p.TotalScoreExchangAmount,
                    total_accountamount_exchang_amount = p.TotalAccountAmountExchangAmount,
                    total_storecard_exchang_amount     = p.TotalStorecardExchangAmount,
                    total_product_count           = p.TotalProductCount,
                    total_product_fee             = p.TotalProductFee,
                    total_refund_amount           = p.TotalRefundAmount,
                    task_id                       = p.TaskId,
                    should_commission_order_count = p.ShouldCommissionOrderCount,
                    real_commission_order_count   = p.RealCommissionOrderCount,
                    last_receiving_time           = p.LastReceivingTime,
                    refund_order_count            = p.RefundOrderCount,
                    wait_process_order_count      = p.WaitProcessOrderCount
                }
            };
            bllMall.ContextResponse(context, apiResp);
        }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            string             id        = context.Request["id"];
            string             productId = context.Request["product_id"];
            string             date      = context.Request["date"];
            string             price     = context.Request["price"];
            ProductPriceConfig model     = bllMall.Get <ProductPriceConfig>(string.Format(" AutoId={0} And WebsiteOwner='{1}'", id, bllMall.WebsiteOwner));

            model.ProductId = productId;
            model.Date      = date;
            model.Price     = decimal.Parse(price);
            if (bllMall.Update(model))
            {
                apiResp.status = true;
                apiResp.msg    = "ok";
            }
            else
            {
                apiResp.code = -1;
                apiResp.msg  = "操作失败";
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Example #7
0
        public void ProcessRequest(HttpContext context)
        {
            string settlementId = context.Request["settlement_id"];

            System.Text.StringBuilder sbSql = new System.Text.StringBuilder();

            sbSql.AppendFormat("Select ");

            sbSql.AppendFormat(" OrderId as [订单号],");

            sbSql.AppendFormat(" BaseAmount as [产品结算金额],");

            sbSql.AppendFormat(" TransportFee as [代收运费],");

            sbSql.AppendFormat(" SettlementAmount as [结算金额=产品结算金额+代收运费]");

            sbSql.AppendFormat(" from ZCJ_SupplierSettlementDetail ");
            sbSql.AppendFormat(" Where SettlementId='{0}'", settlementId);

            var settlement = bllMall.Get <BLLJIMP.Model.SupplierSettlement>(string.Format(" SettlementId='{0}'", settlementId));

            System.Data.DataTable dt = dt = ZentCloud.ZCBLLEngine.BLLBase.Query(sbSql.ToString()).Tables[0];
            DataLoadTool.ExportDataTable(dt, string.Format("{0}_{1}至{2}_结算单号{3}.xls", settlement.SupplierName, settlement.FromDate.ToString("yyyyMMdd"), settlement.ToDate.ToString("yyyyMMdd"), settlementId));
        }
Example #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //通知参数示例
         //sign=de7ab71a24075f3d96d2619fac60f16c
         //result_details=2017020721001004830269248522^0.01^SUCCESS
         //notify_time=2017-02-10 14:43:38
         //sign_type=MD5
         //notify_type=batch_refund_notify
         //notify_id=f87d0a63daa030e732173f3f568d6e4i0a
         //batch_no=201702101486709017
         //success_num=1
         Dictionary <string, string> parametersAll = bllMall.GetRequestParameter();
         StringBuilder sb = new StringBuilder();
         foreach (var item in parametersAll)
         {
             sb.AppendFormat(string.Format("{0}={1}&", item.Key, item.Value));
         }
         Tolog("退款通知参数:" + sb.ToString());
         if (parametersAll.Count > 0)//判断是否有带返回参数
         {
             Notify    aliNotify    = new Notify();
             PayConfig payConfig    = bllPay.GetPayConfig();
             bool      verifyResult = aliNotify.Verify(parametersAll, Request["sign"], payConfig.Partner, payConfig.PartnerKey);
             if (verifyResult)//验证成功
             {
                 Tolog("退款验签成功");
                 string       batchNo     = Request["batch_no"];    //退款批次号
                 string       successNum  = Request["success_num"]; //成功数
                 int          updateCount = 0;                      //更新条数
                 WXMallRefund refundInfo  = bllMall.Get <WXMallRefund>(string.Format("OutRefundId='{0}'", batchNo));
                 if (successNum == "1")
                 {
                     updateCount = bllMall.Update(refundInfo, string.Format("Status=6"), string.Format("RefundId='{0}'", refundInfo.RefundId));
                 }
                 else
                 {
                     updateCount = bllMall.Update(refundInfo, string.Format("Status=8"), string.Format("RefundId='{0}'", refundInfo.RefundId));
                 }
                 if (updateCount > 0)
                 {
                     Response.Write("success");
                 }
                 else
                 {
                     Response.Write("fail");
                 }
             }
             else//验证失败
             {
                 Tolog("退款验签失败");
                 Response.Write("fail");
             }
         }
         else
         {
             Response.Write("无通知参数");
         }
     }
     catch (Exception ex)
     {
         Tolog("退款异常:" + ex.ToString());
         Response.Write("fail");
     }
 }
Example #9
0
        /// <summary>
        /// 添加预约
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddOrder(HttpContext context)
        {
            try
            {
                string   id  = context.Request["id"]; //多个医生id
                string[] ids = new string[] { };      //多个医生id
                if (!string.IsNullOrEmpty(id))
                {
                    id  = id.TrimStart(',').TrimEnd(',');
                    ids = id.Split(',');
                }
                if (ids.Length >= 1)//检查是否可以预约
                {
                    foreach (var item in ids)
                    {
                        WXMallProductInfo productInfoCheck = bllMall.GetProduct(item);
                        if (productInfoCheck != null)
                        {
                            if (productInfoCheck.Stock <= 0)
                            {
                                apiResp.msg = string.Format("专家{0}的预约已满", productInfoCheck.PName);
                                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                            }
                        }
                    }
                }

                WXMallProductInfo productInfo = new WXMallProductInfo();
                WXMallOrderInfo   orderInfo   = bllMall.ConvertRequestToModel <WXMallOrderInfo>(new WXMallOrderInfo());
                if (string.IsNullOrEmpty(orderInfo.Consignee))
                {
                    apiResp.msg = "请填写姓名";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (string.IsNullOrEmpty(orderInfo.Ex1))
                {
                    apiResp.msg = "请填写年龄";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (string.IsNullOrEmpty(orderInfo.Ex2))
                {
                    apiResp.msg = "请选择性别";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (string.IsNullOrEmpty(orderInfo.Phone))
                {
                    apiResp.msg = "请填写手机号";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (!Common.MyRegex.PhoneNumLogicJudge(orderInfo.Phone))
                {
                    apiResp.msg = "请输入正确手机号";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }

                StringBuilder sbWhere = new StringBuilder();
                sbWhere.AppendFormat("  WebsiteOwner='{0}' And TableName ='ZCJ_WXMallOrderInfo' Order by Sort DESC", bllMall.WebsiteOwner);
                var fieldList = bllMall.GetList <TableFieldMapping>(sbWhere.ToString());
                if (fieldList != null && fieldList.Count > 0)
                {
                    Type type = orderInfo.GetType();
                    fieldList = fieldList.Where(p => p.FieldIsNull == 0).ToList();
                    foreach (var field in fieldList)
                    {
                        System.Reflection.PropertyInfo propertyInfo = type.GetProperty(field.Field); //获取指定名称的属性
                        var value = propertyInfo.GetValue(orderInfo, null);                          //获取属性值
                        if (value == null || string.IsNullOrEmpty(value.ToString()))
                        {
                            switch (field.FieldType)
                            {
                            case "text":
                                apiResp.msg = "请填写 " + field.MappingName;
                                break;

                            case "combox":    //下拉框
                                apiResp.msg = "请选择 " + field.MappingName;
                                break;

                            case "checkbox":    //下拉框
                                apiResp.msg = "请选择 " + field.MappingName;
                                break;

                            default:
                                break;
                            }

                            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                        }
                    }
                }



                orderInfo.OrderID      = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder);
                orderInfo.WebsiteOwner = bllMall.WebsiteOwner;
                orderInfo.InsertDate   = DateTime.Now;
                orderInfo.OrderUserID  = "defualt";
                orderInfo.Status       = "未确认";
                if (bllMall.IsLogin)
                {
                    orderInfo.OrderUserID = bllUser.GetCurrUserID();
                }
                if (!string.IsNullOrEmpty(orderInfo.Ex6))//科系
                {
                    //推荐
                    int categoryId;
                    if (int.TryParse(orderInfo.Ex6, out categoryId))
                    {
                        WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoId={0}", categoryId));
                        if (category != null)
                        {
                            orderInfo.Ex6 = category.CategoryName;
                        }
                    }
                }
                else
                {
                    //正常预约
                    if (ids.Length == 1)
                    {
                        productInfo = bllMall.GetProduct(ids[0]);
                        if (productInfo != null)
                        {
                            if (!string.IsNullOrEmpty(productInfo.CategoryId))
                            {
                                WXMallCategory category = bllMall.Get <WXMallCategory>(string.Format(" AutoId={0}", productInfo.CategoryId));
                                if (category != null)
                                {
                                    orderInfo.Ex6 = category.CategoryName;
                                }
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(orderInfo.Ex5))//医生 名字或多个Id
                {
                    orderInfo.Ex5 = orderInfo.Ex5.TrimStart(',').TrimEnd(',');
                    string names = "";
                    foreach (var item in orderInfo.Ex5.Split(','))
                    {
                        int pId;
                        if (int.TryParse(item, out pId))
                        {
                            productInfo = bllMall.GetProduct(pId.ToString());
                            if (productInfo != null)
                            {
                                names += productInfo.PName + ",";
                                if (productInfo.Stock <= 0)
                                {
                                    apiResp.msg = string.Format("专家{0}的预约已满", productInfo.PName);
                                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                                }
                            }
                        }
                    }
                    if (orderInfo.Ex5.Split(',').Length >= 1 && (!string.IsNullOrEmpty(names)))
                    {
                        orderInfo.Ex5 = names.TrimEnd(',');
                    }
                }

                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
                if (!bllMall.Add(orderInfo, tran))
                {
                    apiResp.msg = "操作失败";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (ids.Length > 0)
                {
                    if (bllMall.Update(productInfo, string.Format("Stock-=1,SaleCount+=1"), string.Format("PID in({0})", id)) < ids.Length)
                    {
                        tran.Rollback();
                        apiResp.msg = "操作失败";
                        return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                    }
                }

                tran.Commit();
                apiResp.status = true;
                bllWeixin.SendTemplateMessageToKefu("有新的预约", string.Format("姓名:{0}\\n手机:{1}", orderInfo.Consignee, orderInfo.Phone));
            }
            catch (Exception ex)
            {
                apiResp.msg = ex.Message;
            }

            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Tolog("进入支付回调");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                xmlDoc.Save(string.Format("C:\\WXPay\\Notify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));//写入日志
                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }
                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value);//全部参数排序
                orderInfo = bllMall.GetOrderInfo(parametersAll["out_trade_no"]);
                PayConfig payConfig = bllPay.GetPayConfig();
                if (!bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))//验证签名
                {
                    Tolog("验证签名出错");
                    Response.Write(failXml);
                    return;
                }
                if (orderInfo == null)
                {
                    Tolog("订单未找到");
                    Response.Write(failXml);
                    return;
                }
                if (orderInfo.PaymentStatus.Equals(1))
                {
                    //Tolog("已支付");
                    Response.Write(successXml);
                    return;
                }
                orderInfo.PaymentType = 2;

                //更新订单状态
                WXMallProductInfo tProductInfo = new WXMallProductInfo();
                if (parametersAll["return_code"].Equals("SUCCESS") && parametersAll["result_code"].Equals("SUCCESS")) //交易成功
                {
                    UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, bllUser.WebsiteOwner);        //下单用户信息
                    string   hasOrderIDs   = "";
                    int      maxCount      = 1;
                    //Tolog("准备检查更新订单状态");
                    if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                    {
                        //Tolog("预订类型");
                        #region 预约订单修改状态
                        orderInfo.PaymentStatus = 1;
                        orderInfo.PayTime       = DateTime.Now;
                        orderInfo.Status        = "预约成功";

                        #region 检查是否有预约成功的订单
                        List <WXMallOrderDetailsInfo> tDetailList = bllMall.GetOrderDetailsList(orderInfo.OrderID, null, orderInfo.ArticleCategoryType, null, null);
                        List <WXMallOrderDetailsInfo> oDetailList = bllMall.GetOrderDetailsList(null, tDetailList[0].PID, orderInfo.ArticleCategoryType, tDetailList.Min(p => p.StartDate), tDetailList.Max(p => p.EndDate));
                        tProductInfo = bllMall.GetByKey <WXMallProductInfo>("PID", tDetailList[0].PID);
                        maxCount     = tProductInfo.Stock;
                        List <string> hasOrderIDList = new List <string>();
                        foreach (var item in tDetailList)
                        {
                            List <WXMallOrderDetailsInfo> hasOrderDetailList = oDetailList.Where(p => !((item.StartDate >= p.EndDate && item.EndDate > p.EndDate) || (item.StartDate < p.StartDate && item.EndDate <= p.StartDate))).ToList();
                            if (hasOrderDetailList.Count >= maxCount)
                            {
                                hasOrderIDList.AddRange(hasOrderDetailList.Select(p => p.OrderID).Distinct());
                            }
                        }
                        hasOrderIDList = hasOrderIDList.Where(p => !p.Contains(orderInfo.OrderID)).ToList();
                        if (hasOrderIDList.Count > 0)
                        {
                            hasOrderIDList = hasOrderIDList.Distinct().ToList();
                            hasOrderIDs    = MyStringHelper.ListToStr(hasOrderIDList, "'", ",");
                        }
                        #endregion 检查是否有预约成功的订单

                        #endregion 预约订单修改状态
                    }
                    else
                    {
                        //Tolog("普通类型");
                        #region 原订单修改状态
                        orderInfo.PaymentStatus = 1;
                        orderInfo.Status        = "待发货";
                        orderInfo.PayTime       = DateTime.Now;
                        if (orderInfo.DeliveryType == 1)
                        {
                            orderInfo.Status = "待自提";
                        }
                        Tolog("更改状态start");
                        //if (bllMall.GetWebsiteInfoModelFromDataBase().IsDistributionMall.Equals(1))
                        //{
                        orderInfo.GroupBuyStatus     = "0";
                        orderInfo.DistributionStatus = 1;

                        //if (orderInfo.IsMain==1)
                        //{
                        //    bllMall.Update(orderInfo,string.Format(" DistributionStatus=1"),string.Format("ParentOrderId='{0}'",orderInfo.OrderID));
                        //}



                        #region 活动订单
                        if (orderInfo.OrderType == 4)
                        {
                            ActivityDataInfo data = bllMall.Get <ActivityDataInfo>(string.Format(" OrderId='{0}'", orderInfo.OrderID));
                            if (data != null)
                            {
                                bllMall.Update(data, string.Format(" PaymentStatus=1"), string.Format("  OrderId='{0}'", orderInfo.OrderID));
                            }
                        }
                        #endregion


                        bllMall.Update(orderInfo, string.Format("PaymentStatus=1,Status='待发货',PayTime=GETDATE(),DistributionStatus=1"), string.Format("ParentOrderId='{0}'", orderInfo.OrderID));


                        //}
                        #endregion 原订单修改状态

                        try
                        {
                            //设置交易流水号
                            orderInfo.PayTranNo = parametersAll["transaction_id"];
                        }
                        catch (Exception ex)
                        {
                            Tolog("设置交易流水号失败:" + ex.Message);
                        }
                    }
                    bool result = false;

                    if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                    {
                        if (string.IsNullOrWhiteSpace(hasOrderIDs))
                        {
                            hasOrderIDs = "'0'";
                        }
                        result = bllMall.Update(new WXMallOrderInfo(),
                                                string.Format("PaymentStatus={0},PayTime=GetDate(),Status='{1}'", 1, "预约成功"),
                                                string.Format("OrderID='{0}' and WebsiteOwner='{4}' AND (select count(1) from [ZCJ_WXMallOrderInfo] where Status='{3}' and WebsiteOwner='{4}' and  OrderID IN({1}))<{2}",
                                                              orderInfo.OrderID, hasOrderIDs, maxCount, "预约成功", bllMall.WebsiteOwner)
                                                ) > 0;
                        if (result)
                        {
                            // #region 交易成功加积分
                            //增加积分 (慧聚不需要)
                            //if (orderInfo.TotalAmount > 0)
                            //{
                            //    ScoreConfig scoreConfig = bllScore.GetScoreConfig();
                            //    int addScore = 0;
                            //    if (scoreConfig != null && scoreConfig.OrderAmount > 0 && scoreConfig.OrderScore > 0)
                            //    {
                            //        addScore = (int)(orderInfo.PayableAmount / (scoreConfig.OrderAmount / scoreConfig.OrderScore));
                            //    }
                            //    if (addScore > 0)
                            //    {
                            //        if (bllUser.Update(new UserInfo(),
                            //            string.Format(" TotalScore+={0},HistoryTotalScore+={0}", addScore),
                            //            string.Format(" UserID='{0}'", orderInfo.OrderUserID)) > 0)
                            //        {
                            //            UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                            //            scoreRecord.AddTime = DateTime.Now;
                            //            scoreRecord.Score = addScore;
                            //            scoreRecord.ScoreType = "OrderSuccess";
                            //            scoreRecord.UserID = orderInfo.OrderUserID;
                            //            scoreRecord.AddNote = "预约-交易成功获得积分";
                            //            bllMall.Add(scoreRecord);
                            //        }
                            //    }
                            //}
                            // #endregion

                            #region 修改其他预约订单为预约失败 返还积分

                            if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType) && !string.IsNullOrWhiteSpace(hasOrderIDs))
                            {
                                int tempCount = 0;
                                List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null,
                                                                                       null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs);
                                tempCount = tempCount + 1; //加上当前订单的数量
                                if (tempCount >= maxCount)
                                {
                                    tempList = bllMall.GetColOrderListInStatus("'待付款','待审核'", hasOrderIDs, "OrderID,OrderUserID,UseScore", bllMall.WebsiteOwner);
                                    if (tempList.Count > 0)
                                    {
                                        string stopOrderIds = MyStringHelper.ListToStr(tempList.Select(p => p.OrderID).ToList(), "'", ",");
                                        tempList = tempList.Where(p => p.UseScore > 0).ToList();
                                        foreach (var item in tempList)
                                        {
                                            orderUserInfo.TotalScore += item.UseScore;
                                            if (bllUser.Update(new UserInfo(), string.Format(" TotalScore+={0}", item.UseScore),
                                                               string.Format(" UserID='{0}'", item.OrderUserID)) > 0)
                                            {
                                                UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                                                scoreRecord.AddTime      = DateTime.Now;
                                                scoreRecord.Score        = item.UseScore;
                                                scoreRecord.TotalScore   = orderUserInfo.TotalScore;
                                                scoreRecord.ScoreType    = "OrderCancel";
                                                scoreRecord.UserID       = item.OrderUserID;
                                                scoreRecord.RelationID   = item.OrderID;
                                                scoreRecord.AddNote      = "预约-订单失败返还积分";
                                                scoreRecord.WebSiteOwner = item.WebsiteOwner;
                                                bllMall.Add(scoreRecord);
                                            }
                                        }
                                        bllMall.Update(new WXMallOrderInfo(),
                                                       string.Format("Status='{0}'", "预约失败"),
                                                       string.Format("OrderID In ({0}) and WebsiteOwner='{1}'", stopOrderIds, bllMall.WebsiteOwner));
                                    }
                                }
                                //Tolog("更改修改其他预约为预约失败");
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        result = bllMall.Update(orderInfo);
                    }
                    if (result)
                    {
                        #region 拼团订单
                        if (orderInfo.OrderType == 2)
                        {
                            try
                            {
                                if (!string.IsNullOrEmpty(orderInfo.GroupBuyParentOrderId))
                                {
                                    var parentOrderInfo = bllMall.GetOrderInfo(orderInfo.GroupBuyParentOrderId);

                                    if (parentOrderInfo.Ex10 == "1")
                                    {
                                        if (bllMall.GetCount <WXMallOrderInfo>(string.Format("PaymentStatus=1 And GroupBuyParentOrderId='{0}' ", parentOrderInfo.OrderID)) >= parentOrderInfo.PeopleCount)
                                        {
                                            bllMall.Update(new WXMallOrderInfo(), string.Format("Status='已取消'"), string.Format("  GroupBuyParentOrderId='{0}' And PaymentStatus=0", parentOrderInfo.OrderID));
                                            parentOrderInfo.GroupBuyStatus = "1";
                                            bllMall.Update(parentOrderInfo);
                                        }
                                    }
                                    else
                                    {
                                        if (bllMall.GetCount <WXMallOrderInfo>(string.Format("PaymentStatus=1 And GroupBuyParentOrderId='{0}' Or OrderId='{0}'", parentOrderInfo.OrderID)) >= parentOrderInfo.PeopleCount)
                                        {
                                            bllMall.Update(new WXMallOrderInfo(), string.Format("Status='已取消'"), string.Format("  GroupBuyParentOrderId='{0}' And PaymentStatus=0", parentOrderInfo.OrderID));
                                            parentOrderInfo.GroupBuyStatus = "1";
                                            bllMall.Update(parentOrderInfo);
                                        }
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        #endregion
                        Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(orderInfo.WebsiteOwner);

                        //Tolog("更改状态true");

                        #region Efast同步
                        //判读当前站点是否需要同步到驿氪和efast
                        if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncEfast, bllCommRelation.WebsiteOwner, ""))
                        {
                            try
                            {
                                Tolog("开始同步efast");

                                string outOrderId = string.Empty, msg = string.Empty;
                                var    syncResult = bllEfast.CreateOrder(orderInfo.OrderID, out outOrderId, out msg);
                                if (syncResult)
                                {
                                    orderInfo.OutOrderId = outOrderId;
                                    bllMall.Update(orderInfo);
                                }
                                Tolog(string.Format("efast订单同步结果:{0},订单号:{1},提示信息:{2}", syncResult, outOrderId, msg));
                            }
                            catch (Exception ex)
                            {
                                Tolog("efast订单同步异常:" + ex.Message);
                            }
                        }
                        #endregion

                        #region 驿氪同步
                        if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, bllCommRelation.WebsiteOwner, ""))
                        {
                            try
                            {
                                Tolog("开始同步驿氪");
                                //同步成功订单到驿氪

                                //UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID);
                                //if ((!string.IsNullOrEmpty(orderUserInfo.Ex1)) && (!string.IsNullOrEmpty(orderUserInfo.Ex2)) && (!string.IsNullOrEmpty(orderUserInfo.Phone)))
                                //{
                                //    client.BonusUpdate(orderUserInfo.Ex2, -(orderInfo.UseScore), "商城下单使用积分" + orderInfo.UseScore);

                                //}
                                var uploadOrderResult = yikeClient.OrderUpload(orderInfo);

                                Tolog(string.Format("驿氪订单同步结果:{0}", Common.JSONHelper.ObjectToJson(uploadOrderResult)));
                            }
                            catch (Exception ex)
                            {
                                Tolog("驿氪订单同步异常:" + ex.Message);
                            }
                        }
                        #endregion

                        #region 付款加积分
                        try
                        {
                            bllUser.AddUserScoreDetail(orderInfo.OrderUserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.OrderPay), bllMall.WebsiteOwner, null, null);
                        }
                        catch (Exception)
                        { }

                        #endregion


                        #region 消息通知
                        if (!BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                        {
                            try
                            {
                                var    productName = bllMall.GetOrderDetailsList(orderInfo.OrderID)[0].ProductName;
                                string remark      = "";
                                if (!string.IsNullOrEmpty(orderInfo.OrderMemo))
                                {
                                    remark = string.Format("客户留言:{0}", orderInfo.OrderMemo);
                                }
                                bllWeiXin.SendTemplateMessageToKefu("有新的订单", string.Format("订单号:{0}\\n订单金额:{1}元\\n收货人:{2}\\n电话:{3}\\n商品:{4}\\n{5}", orderInfo.OrderID, Math.Round(orderInfo.TotalAmount, 2), orderInfo.Consignee, orderInfo.Phone, productName, remark));
                                if (orderInfo.OrderType != 4)//付费的活动不发消息
                                {
                                    if (orderInfo.WebsiteOwner != "jikuwifi")
                                    {
                                        string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/orderDetail/{1}#/orderDetail/{1}", Request.Url.Host, orderInfo.OrderID);
                                        if (orderInfo.IsMain == 1)
                                        {
                                            url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/orderList#/orderList", Request.Url.Host);
                                        }
                                        bllWeiXin.SendTemplateMessageNotifyComm(orderUserInfo, "订单已成功支付,我们将尽快发货,请保持手机畅通等待物流送达!", string.Format("订单号:{0}\\n订单金额:{1}元\\n收货人:{2}\\n电话:{3}\\n商品:{4}...\\n查看详情", orderInfo.OrderID, Math.Round(orderInfo.TotalAmount, 2), orderInfo.Consignee, orderInfo.Phone, productName), url);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                            try
                            {
                                bllWeiXin.SendTemplateMessageToKefu(orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元\\n预约人:{3}\\n预约人手机:{4}", orderInfo.OrderID, orderInfo.TotalAmount, tProductInfo.PName, orderUserInfo.TrueName, orderUserInfo.Phone));
                                bllWeiXin.SendTemplateMessageNotifyComm(orderUserInfo, orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元", orderInfo.OrderID, orderInfo.TotalAmount, tProductInfo.PName));
                            }
                            catch (Exception)
                            {
                            }
                        }
                        #endregion
                        WebsiteInfo websiteInfo = bllMall.Get <WebsiteInfo>(string.Format(" WebsiteOwner='{0}'", orderInfo.WebsiteOwner));
                        #region 分销相关
                        try
                        {
                            if (bllMenuPermission.CheckUserAndPmsKey(websiteInfo.WebsiteOwner, BLLPermission.Enums.PermissionSysKey.OnlineDistribution, websiteInfo.WebsiteOwner))
                            {
                                if (string.IsNullOrWhiteSpace(orderUserInfo.DistributionOwner))
                                {
                                    if (websiteInfo.DistributionRelationBuildMallOrder == 1)
                                    {
                                        orderUserInfo.DistributionOwner = orderInfo.WebsiteOwner;
                                        bllMall.Update(orderUserInfo);
                                    }
                                }
                                bllDis.AutoUpdateLevel(orderInfo);
                                bllDis.TransfersEstimate(orderInfo);
                                bllDis.SendMessageToUser(orderInfo);
                                bllDis.UpdateDistributionSaleAmountUp(orderInfo);
                            }
                        }
                        catch (Exception ex)
                        {
                            Tolog("设置分销员异常:" + ex.Message + " 用户id:" + orderUserInfo.UserID);
                        }
                        #endregion


                        #region 宏巍通知
                        try
                        {
                            if (websiteInfo.IsUnionHongware == 1)
                            {
                                hongWareClient.OrderNotice(orderUserInfo.WXOpenId, orderInfo.OrderID);
                            }
                        }
                        catch (Exception)
                        {
                        }

                        #endregion

                        bllCard.Give(orderInfo.TotalAmount, orderUserInfo);


                        string v1ProductId = Common.ConfigHelper.GetConfigString("YGBV1ProductId");
                        string v2ProductId = Common.ConfigHelper.GetConfigString("YGBV2ProductId");
                        string v1CouponId  = Common.ConfigHelper.GetConfigString("YGBV1CouponId");
                        string v2CouponId  = Common.ConfigHelper.GetConfigString("YGBV2CouponId");

                        List <WXMallOrderDetailsInfo> orderDetailList = bllMall.GetOrderDetailsList(orderInfo.OrderID);
                        foreach (var item in orderDetailList)
                        {
                            item.IsComplete = 1;
                            bllMall.Update(item);

                            #region 购买指定商品发送指定的优惠券
                            if (!string.IsNullOrEmpty(v1ProductId) && !string.IsNullOrEmpty(v1CouponId) && item.PID == v1ProductId)
                            {
                                bllCard.SendCardCouponsByCurrUserInfo(orderUserInfo, v1CouponId);
                            }

                            if (!string.IsNullOrEmpty(v2ProductId) && !string.IsNullOrEmpty(v2CouponId) && item.PID == v2ProductId)
                            {
                                bllCard.SendCardCouponsByCurrUserInfo(orderUserInfo, v2CouponId);
                            }
                            #endregion
                        }

                        //更新销量
                        bllMall.UpdateProductSaleCount(orderInfo);
                        Response.Write(successXml);
                        return;
                    }
                    else
                    {
                        Tolog("更改状态false");
                        Response.Write(failXml);
                        return;
                    }
                }
                Tolog("返回信息有误");
                Response.Write(failXml);
            }
            catch (Exception ex)
            {
                Tolog("出错了:" + ex.Message);
                Response.Write(failXml);
            }
        }
Example #11
0
        public virtual void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            context.Response.Expires     = 0;
            string        keyWord   = context.Request["KeyWord"];
            string        fromDate  = context.Request["FromDate"];
            string        toDate    = context.Request["ToDate"];
            string        type      = context.Request["type"];
            string        status    = context.Request["status"];
            string        orderType = context.Request["orderType"];
            StringBuilder sbSql     = new StringBuilder();

            sbSql.AppendFormat("Select (Case When OrderType =5 Then '预约'  When OrderType=6 Then '推荐' When OrderType=7 Then '预约' When OrderType=8 Then '推荐' Else '' End) as 类型,");
            sbSql.AppendFormat(" Status as 确认状态,");
            sbSql.AppendFormat(" Consignee as 姓名,");
            sbSql.AppendFormat(" Phone as 手机号,");
            sbSql.AppendFormat(" Ex1 as 年龄,");
            sbSql.AppendFormat(" Ex2 as 性别,");
            sbSql.AppendFormat(" Ex3 as 症状描述,");
            sbSql.AppendFormat(" Ex5 as 专家,");
            sbSql.AppendFormat(" '' as 身份,");

            sbSql.AppendFormat(" Ex6 as 科室,");
            sbSql.AppendFormat(" InsertDate as 提交时间 ");


            var fieldList = bllMall.GetList <TableFieldMapping>(string.Format("WebsiteOwner='{0}' And TableName ='ZCJ_WXMallOrderInfo' Order by Sort DESC", bllMall.WebsiteOwner));

            if (fieldList.Count > 0)
            {
                for (int i = 0; i < fieldList.Count; i++)
                {
                    sbSql.AppendFormat(" ,{0} as {1}", fieldList[i].Field, fieldList[i].MappingName);
                }
            }

            sbSql.AppendFormat(" from ZCJ_WXMallOrderInfo  Where WebsiteOwner='{0}' ", bllMall.WebsiteOwner);
            if (string.IsNullOrEmpty(orderType))
            {
                sbSql.AppendFormat(" And OrderType in(5,6)", type);
            }
            else
            {
                sbSql.AppendFormat(" And OrderType in(7,8)", type);
            }
            if (!string.IsNullOrEmpty(type))
            {
                sbSql.AppendFormat("And OrderType={0}", type);
            }
            if (!string.IsNullOrEmpty(status))
            {
                sbSql.AppendFormat("And Status='{0}'", status);
            }
            if (!string.IsNullOrEmpty(keyWord))
            {
                sbSql.AppendFormat("And ( Consignee like'%{0}%' Or Ex5 like'%{0}%' Or Ex6  like'%{0}%')", keyWord);
            }
            if ((!string.IsNullOrEmpty(fromDate)))//大于开始时间
            {
                sbSql.AppendFormat("And InsertDate>='{0}'", Convert.ToDateTime(fromDate));
            }
            if ((!string.IsNullOrEmpty(toDate)))//小于结束时间
            {
                sbSql.AppendFormat("And InsertDate<'{0}'", Convert.ToDateTime(toDate).AddDays(1));
            }
            sbSql.AppendFormat(" Order By InsertDate DESC");
            var dataTable = ZentCloud.ZCBLLEngine.BLLBase.Query(sbSql.ToString()).Tables[0];

            foreach (System.Data.DataRow item in dataTable.Rows)
            {
                try
                {
                    if (!string.IsNullOrEmpty(item["专家"].ToString()))
                    {
                        string result         = "";
                        var    doctorNameList = item["专家"].ToString();
                        foreach (var doctorName in doctorNameList.Split(','))
                        {
                            WXMallProductInfo doctorInfo = bllMall.Get <WXMallProductInfo>(string.Format(" WebsiteOwner='{0}' And PName='{1}'", bllMall.WebsiteOwner, doctorName));
                            if (doctorInfo != null)
                            {
                                result += doctorInfo.ExArticleTitle_2 + ",";
                            }
                        }
                        result     = result.TrimEnd(',');
                        item["身份"] = result;
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }
            DataLoadTool.ExportDataTable(dataTable, string.Format("{0}_{1}_data.xls", "预约", DateTime.Now.ToString()));
        }
Example #12
0
        public void ProcessRequest(HttpContext context)
        {
            WebsiteInfo websiteInfo        = bllMall.GetWebsiteInfoModelFromDataBase();
            string      orderSn            = context.Request["order_sn"];
            string      expressCompanyCode = context.Request["express_company_code"];
            string      expressNumber      = context.Request["express_number"];

            if (string.IsNullOrEmpty(orderSn))
            {
                resp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.msg  = "order_sn 参数必传";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(expressCompanyCode))
            {
                resp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.msg  = "express_company_code 参数必传";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (string.IsNullOrEmpty(expressNumber))
            {
                resp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.msg  = "express_number 参数必传";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            var orderInfo = bllMall.GetOrderInfoByOutOrderId(orderSn);

            if (orderInfo == null)
            {
                resp.code = (int)APIErrCode.OperateFail;
                resp.msg  = "order_sn 不存在,请检查";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            ExpressInfo expressInfo = bllMall.Get <ExpressInfo>(string.Format(" ExpressCompanyCode='{0}'", expressCompanyCode));

            if (expressInfo == null)
            {
                resp.code = (int)APIErrCode.OperateFail;
                resp.msg  = "express_company_code 不支持";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            orderInfo.ExpressCompanyCode = expressCompanyCode;
            orderInfo.ExpressCompanyName = expressInfo.ExpressCompanyName;
            orderInfo.ExpressNumber      = expressNumber;
            orderInfo.DeliveryTime       = DateTime.Now;
            if (bllMall.WebsiteOwner == "jikuwifi")
            {
                orderInfo.Status = "待归还";
            }
            else
            {
                orderInfo.Status = "已发货";
            }

            orderInfo.LastUpdateTime = DateTime.Now;
            orderInfo.Ex18           = "";
            orderInfo.Ex19           = "";
            if (bllMall.Update(orderInfo))
            {
                resp.status = true;
                string msg = "";
                bllKuaidi100.Poll(orderInfo.ExpressCompanyCode, orderInfo.ExpressNumber, out msg);
            }
            else
            {
                resp.msg = "更新物流信息失败";
            }
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
Example #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     model = bllMall.Get <SupplierSettlement>(string.Format("SettlementId='{0}'", Request["settlement_id"]));
     SettlementOrderCount = bllMall.GetCount <SupplierSettlementDetail>(string.Format(" SettlementId='{0}'", model.SettlementId));
 }
Example #14
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                Tolog("京东支付通知start");
                var    payConfig = bllPay.GetPayConfig();
                byte[] byts      = new byte[context.Request.InputStream.Length];
                context.Request.InputStream.Read(byts, 0, byts.Length);
                string req = Encoding.UTF8.GetString(byts);
                Tolog("通知参数" + req);

                //var jdPubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCKE5N2xm3NIrXON8Zj19GNtLZ8xwEQ6uDIyrS3S03UhgBJMkGl4msfq4Xuxv6XUAN7oU1XhV3/xtabr9rXto4Ke3d6WwNbxwXnK5LSgsQc1BhT5NcXHXpGBdt7P8NMez5qGieOKqHGvT0qvjyYnYA29a8Z4wzNR7vAVHp36uD5RwIDAQAB";

                //req = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><jdpay><version>V2.0</version><merchant>110226843002</merchant><result><code>000000</code><desc>success</desc></result><encrypt>MDIxZjNkNjI1YjU1NzQ4MWE5N2ExMTg3YjkxNmQ4NzkxYzQyMmFjZjM4YTM1MjZjY2JjNzM1ZDkxY2Q5ZDNmMTMzMGFjYTBkNTI0MzYzNjc3MTVhODI3OWUzZTAxMmY5ODEyOTVmNDNiNWY5MDZhZGJiYTcwYTYyOTFlYzVmYTU2Y2EyN2U1YzhkNzllMGE3ZTUyNDE4NWU4OWMxNjIwNDFkODcyYzJiZDA4ZWY4YWEyMmY5ZWUxNDk3YTg3MTI3YmU1NTMxNjc5NWJiOTlmN2ZmNGU1MTc1YWJhNjNkYjUzYWUwZDQzOTk4ZjIzMjBiYmVkNGJkMDcxOWUzOThjZjU1ODUwNzM4Y2RiNzM2Njc1N2U2ZTcxN2Q0N2ZiYTZmN2M1YzBiYzRmMjc4ZThiZDNhYTkxZTExNzBiYjg2ZDNjNmQ3OWUyZTBlYjUzZWNlZjFjODQ2MzdiN2E5MTQxN2Y3NmRhZmNkNDdiMzMwNjc1MGRhYjhiYzg0NTFkOWNiY2QyMDZhOTJiYzU2YTFiOWEwMjRmNTZhMWZhNTVhNjlmYTA1ZDFlMmI0YTI4MGE1YTU0N2NlMjc3ZWMwM2QyNWE4ODdlOTA0ZGM3YTY2MDViY2I1OTI5MDBlYWU4MGU0Mzc4MmEwOWY3ZjEwZTk5MGZkOGUzYTA4MzNkNGMyZGZkNWM3MDhkOGU4N2NhMmQyZGM1MDgwYzUyOTg3OGNkMzFhZWRkMTE1NDM5ZjExYTM2OGM2OGE4MGZjZTYyMjJkNzlmODcwNGYyNDMzMTYyZThhZTBkODM2ODBjYzg5ZGRjMWY3ZGVmYzQzYjc4MDZiMDNhMTBmZTc2YjI3MThjYjQ0YjQwZDkyY2E3OGUzYmYzZmFlNjBlOTI4OGU1ODVkNjBjMWZiNDBmMjFjNzVmNDkxYmRkYWFlNzQ0YjZkYmU1ODNkOWQ4OGYwN2EyMDViOWQ5MGNjMzViMTE3MDQ4NWVlNTdlN2Y5MTRhZDM3YzFlODY1NDFiZmQyNDg1MzhlZGZiNDNiZWZmZjY3YmE3NWQ5YjI0MzE4ZDMzMDE5NTE3YWM4ZTJiMDZhZWYyM2NhNjMwODc3MDhkNTdkZWI3MWVhMmY2MzA2ZDliZjBmZGFlNzQ3ODgzODg0ZjVhOWFkODIxYWM0NGQ1ZDlmMGRlNDhkMjBiYTJjYmQ4NTlkMmU3NDMxZDExZmRjMzkxMDU3ZmE3NGE0Yzg2OThkMmY0ZWQ1ZjE3MjIwOWQ1ZTBmZGIzZjFhNGYwOTllZWY5YzRiMWYyZDAxZjlhNzhlYWY5ZjU0YmIyZjczNmUxMjJkNWY2NzhlMDFmYjU0YjY3NWRlYTc1ZWZkNmMwNTJhZmY3ZGVhMGM5NjAyMWQwMGQyMjI2NzdhM2RlNDdhMTdkMWI4ZWQxYmEyYWZlZDg1ZjI4NDk2ZmI2MGVjOTc5OTc4MjgzZTEyNzY2ZmI1OWUzZjY1MWI4OTVlMmQ4OGNlNGRhODg0NzJiNTFiN2RmZDc5NzdkNDk4NTY0NGU4ZjBmNGZjMTM3MmUzMGNhMTUwOTFkNDFhODIzMjZiODU0YjMzNmI1N2EwZDVjMjZjOWNjMzBlMjFjZjNkMDA0NjQ4Zjk0NjQzZWRhOTU1MmIyZjJkYzZjNGJmOTU5MDIzNTBlODlmOTNhZDRhYmEyMzZiY2E1OWE4NzY5Mjc0ZTcwN2MyNGFjNGJmOTU5MDIzNTBlODlmNDNlZGE5NTUyYjJmMmRjNjU0MTNlZjYxZTNlODc4MDk3MmNiYjg3NTVjNmU1NWNlZDljNWU0ZDE5ZTRmZjJjZTAxNmJiMGIzYWFlOTdlYTQzYmM5NWVmMGU0ZjUyNzY4NDNlZGE5NTUyYjJmMmRjNmMyOWRiYWZkYTNjYzQ1M2E3ZGJhZWNjZWJmNGIxZmQ5MTMxMmRiMzliOTU2YzBmNmNiODMxMDQ1ZDBiYjM1ZTNmMzlmMGE0ODNiN2M3ODYyZjNjMTFiN2ZiODljNDNkMjE4NGFlNzU5M2JhMmQ2YTJkOWMwMmYxYTBlNTg2MzhkYzU0NzE0NjExNzkyNGU4ZjQ4NDgzMTAyNDY5OGRlNGZiMDVmNGQzNzE3NGMwOGI2NGU2NjkxMmU2NGY5M2I0YjNiMThmMzZiZmY0NTgwN2FjMDAxOWRlY2ZkYTcyOGFmNzIyZTQwNjhlMTViM2UwMmQzMmRiYjJkOTE2MmQzNWMzZWM2OGRkZjJjMjdmOTRhZGNmYzEzOTdlOWY0NjQwODFiYWU0Y2E3Y2NjZDY0NjQzNGFmZWU4ODExYWRiZTBlY2MwY2JlOThmNDliMDZkYjE2YjNjNTZhOTRiOGZkMDU=</encrypt></jdpay>";

                //req = Regex.Replace(req, @"[\t\n\r]", "", RegexOptions.IgnoreCase);

                req = req.Replace("\r", "").Replace("\n", "").Replace("\t", "");

                AsynNotifyResponse anyResponse = Payment.JDPay.XMLUtil.decryptResXml <AsynNotifyResponse>(Payment.JDPay.Config.JDPubKey, payConfig.JDPayDESKey, req);
                // System.Diagnostics.Debug.WriteLine("异步通知订单号:" + anyResponse.tradeNum + ",状态:" + anyResponse.status);
                Tolog("异步通知订单号:" + anyResponse.tradeNum + ",状态:" + anyResponse.status);
                var orderId   = anyResponse.tradeNum;
                var orderInfo = bllMall.GetOrderInfo(orderId);
                if (orderInfo == null)
                {
                    //context.Response.Write("订单未找到");
                    context.Response.StatusCode = 500;
                    context.Response.Write(failStr);
                    return;
                }
                if (orderInfo.PaymentStatus.Equals(1))
                {
                    //Tolog("已支付");
                    // context.Response.Write("订单已支付");
                    context.Response.StatusCode = 200;
                    context.Response.Write(successStr);
                    return;
                }



                if (anyResponse.status == "2")
                {
                    orderInfo.PaymentType = 3;

                    //支付成功
                    WXMallProductInfo tProductInfo  = new WXMallProductInfo();
                    UserInfo          orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, orderInfo.WebsiteOwner);//下单用户信息
                    string            hasOrderIDs   = "";
                    int maxCount = 1;
                    //Tolog("准备检查更新订单状态");
                    if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                    {
                        //Tolog("预订类型");
                        #region 预约订单修改状态
                        orderInfo.PaymentStatus = 1;
                        orderInfo.PayTime       = DateTime.Now;
                        orderInfo.Status        = "预约成功";

                        #region 检查是否有预约成功的订单
                        List <WXMallOrderDetailsInfo> tDetailList = bllMall.GetOrderDetailsList(orderInfo.OrderID, null, orderInfo.ArticleCategoryType, null, null);
                        List <WXMallOrderDetailsInfo> oDetailList = bllMall.GetOrderDetailsList(null, tDetailList[0].PID, orderInfo.ArticleCategoryType, tDetailList.Min(p => p.StartDate), tDetailList.Max(p => p.EndDate));
                        tProductInfo = bllMall.GetByKey <WXMallProductInfo>("PID", tDetailList[0].PID);
                        maxCount     = tProductInfo.Stock;
                        List <string> hasOrderIDList = new List <string>();
                        foreach (var item in tDetailList)
                        {
                            List <WXMallOrderDetailsInfo> hasOrderDetailList = oDetailList.Where(p => !((item.StartDate >= p.EndDate && item.EndDate > p.EndDate) || (item.StartDate < p.StartDate && item.EndDate <= p.StartDate))).ToList();
                            if (hasOrderDetailList.Count >= maxCount)
                            {
                                hasOrderIDList.AddRange(hasOrderDetailList.Select(p => p.OrderID).Distinct());
                            }
                        }
                        hasOrderIDList = hasOrderIDList.Where(p => !p.Contains(orderInfo.OrderID)).ToList();
                        if (hasOrderIDList.Count > 0)
                        {
                            hasOrderIDList = hasOrderIDList.Distinct().ToList();
                            hasOrderIDs    = MyStringHelper.ListToStr(hasOrderIDList, "'", ",");
                        }
                        #endregion 检查是否有预约成功的订单

                        #endregion 预约订单修改状态
                    }
                    else
                    {
                        //Tolog("普通类型");
                        #region 原订单修改状态
                        orderInfo.PaymentStatus = 1;
                        orderInfo.Status        = "待发货";
                        orderInfo.PayTime       = DateTime.Now;
                        Tolog("更改状态start");
                        //if (bllMall.GetWebsiteInfoModelFromDataBase().IsDistributionMall.Equals(1))
                        //{
                        orderInfo.GroupBuyStatus     = "0";
                        orderInfo.DistributionStatus = 1;

                        #region 拼团订单
                        if (orderInfo.OrderType == 2)
                        {
                            try
                            {
                                if (!string.IsNullOrEmpty(orderInfo.GroupBuyParentOrderId))
                                {
                                    var parentOrderInfo = bllMall.GetOrderInfo(orderInfo.GroupBuyParentOrderId);

                                    if (bllMall.GetCount <WXMallOrderInfo>(string.Format("PaymentStatus=1 And GroupBuyParentOrderId='{0}' Or OrderId='{0}'", parentOrderInfo.OrderID)) >= parentOrderInfo.PeopleCount)
                                    {
                                        bllMall.Update(new WXMallOrderInfo(), string.Format("Status='已取消'"), string.Format("  GroupBuyParentOrderId='{0}' And PaymentStatus=0", parentOrderInfo.OrderID));
                                        parentOrderInfo.GroupBuyStatus = "1";
                                        bllMall.Update(parentOrderInfo);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        #endregion

                        #region 活动订单
                        if (orderInfo.OrderType == 4)
                        {
                            ActivityDataInfo data = bllMall.Get <ActivityDataInfo>(string.Format(" OrderId='{0}'", orderInfo.OrderID));
                            if (data != null)
                            {
                                bllMall.Update(data, string.Format(" PaymentStatus=1"), string.Format("  OrderId='{0}'", orderInfo.OrderID));
                            }
                        }
                        #endregion

                        bllMall.Update(orderInfo, string.Format("PaymentStatus=1,Status='待发货',PayTime=GETDATE(),DistributionStatus=1"), string.Format("ParentOrderId='{0}'", orderInfo.OrderID));

                        //}
                        #endregion 原订单修改状态

                        //orderInfo.PayTranNo = tradeNo;
                    }
                    bool result = false;

                    if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                    {
                        if (string.IsNullOrWhiteSpace(hasOrderIDs))
                        {
                            hasOrderIDs = "'0'";
                        }
                        result = bllMall.Update(new WXMallOrderInfo(),
                                                string.Format("PaymentStatus={0},PayTime=GetDate(),Status='{1}'", 1, "预约成功"),
                                                string.Format("OrderID='{0}' and WebsiteOwner='{4}' AND (select count(1) from [ZCJ_WXMallOrderInfo] where Status='{3}' and WebsiteOwner='{4}' and  OrderID IN({1}))<{2}",
                                                              orderInfo.OrderID, hasOrderIDs, maxCount, "预约成功", bllMall.WebsiteOwner)
                                                ) > 0;
                        if (result)
                        {
                            // #region 交易成功加积分
                            //增加积分 (慧聚不需要)
                            //if (orderInfo.TotalAmount > 0)
                            //{
                            //    ScoreConfig scoreConfig = bllScore.GetScoreConfig();
                            //    int addScore = 0;
                            //    if (scoreConfig != null && scoreConfig.OrderAmount > 0 && scoreConfig.OrderScore > 0)
                            //    {
                            //        addScore = (int)(orderInfo.PayableAmount / (scoreConfig.OrderAmount / scoreConfig.OrderScore));
                            //    }
                            //    if (addScore > 0)
                            //    {
                            //        if (bllUser.Update(new UserInfo(),
                            //            string.Format(" TotalScore+={0},HistoryTotalScore+={0}", addScore),
                            //            string.Format(" UserID='{0}'", orderInfo.OrderUserID)) > 0)
                            //        {
                            //            UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                            //            scoreRecord.AddTime = DateTime.Now;
                            //            scoreRecord.Score = addScore;
                            //            scoreRecord.ScoreType = "OrderSuccess";
                            //            scoreRecord.UserID = orderInfo.OrderUserID;
                            //            scoreRecord.AddNote = "预约-交易成功获得积分";
                            //            bllMall.Add(scoreRecord);
                            //        }
                            //    }
                            //}
                            // #endregion

                            #region 修改其他预约订单为预约失败 返还积分

                            if (BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType) && !string.IsNullOrWhiteSpace(hasOrderIDs))
                            {
                                int tempCount = 0;
                                List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null,
                                                                                       null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs);
                                tempCount = tempCount + 1; //加上当前订单的数量
                                if (tempCount >= maxCount)
                                {
                                    tempList = bllMall.GetColOrderListInStatus("'待付款','待审核'", hasOrderIDs, "OrderID,OrderUserID,UseScore", bllMall.WebsiteOwner);
                                    if (tempList.Count > 0)
                                    {
                                        string stopOrderIds = MyStringHelper.ListToStr(tempList.Select(p => p.OrderID).ToList(), "'", ",");
                                        tempList = tempList.Where(p => p.UseScore > 0).ToList();
                                        foreach (var item in tempList)
                                        {
                                            orderUserInfo.TotalScore += item.UseScore;
                                            if (bllUser.Update(new UserInfo(), string.Format(" TotalScore+={0}", item.UseScore),
                                                               string.Format(" UserID='{0}'", item.OrderUserID)) > 0)
                                            {
                                                UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                                                scoreRecord.AddTime      = DateTime.Now;
                                                scoreRecord.Score        = item.UseScore;
                                                scoreRecord.TotalScore   = orderUserInfo.TotalScore;
                                                scoreRecord.ScoreType    = "OrderCancel";
                                                scoreRecord.UserID       = item.OrderUserID;
                                                scoreRecord.RelationID   = item.OrderID;
                                                scoreRecord.AddNote      = "预约-订单失败返还积分";
                                                scoreRecord.WebSiteOwner = item.WebsiteOwner;
                                                bllMall.Add(scoreRecord);
                                            }
                                        }
                                        bllMall.Update(new WXMallOrderInfo(),
                                                       string.Format("Status='{0}'", "预约失败"),
                                                       string.Format("OrderID In ({0}) and WebsiteOwner='{1}'", stopOrderIds, bllMall.WebsiteOwner));
                                    }
                                }
                                //Tolog("更改修改其他预约为预约失败");
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        result = bllMall.Update(orderInfo);
                    }
                    if (result)
                    {
                        Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(orderInfo.WebsiteOwner);

                        //Tolog("更改状态true");

                        #region Efast同步
                        //判读当前站点是否需要同步到驿氪和efast
                        if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncEfast, bllCommRelation.WebsiteOwner, ""))
                        {
                            try
                            {
                                Tolog("开始同步efast");

                                string outOrderId = string.Empty, msg = string.Empty;
                                var    syncResult = bllEfast.CreateOrder(orderInfo.OrderID, out outOrderId, out msg);
                                if (syncResult)
                                {
                                    orderInfo.OutOrderId = outOrderId;
                                    bllMall.Update(orderInfo);
                                }
                                Tolog(string.Format("efast订单同步结果:{0},订单号:{1},提示信息:{2}", syncResult, outOrderId, msg));
                            }
                            catch (Exception ex)
                            {
                                Tolog("efast订单同步异常:" + ex.Message);
                            }
                        }
                        #endregion

                        #region 驿氪同步
                        if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, bllCommRelation.WebsiteOwner, ""))
                        {
                            try
                            {
                                Tolog("开始同步驿氪");
                                //同步成功订单到驿氪

                                //UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID);
                                //if ((!string.IsNullOrEmpty(orderUserInfo.Ex1)) && (!string.IsNullOrEmpty(orderUserInfo.Ex2)) && (!string.IsNullOrEmpty(orderUserInfo.Phone)))
                                //{
                                //    client.BonusUpdate(orderUserInfo.Ex2, -(orderInfo.UseScore), "商城下单使用积分" + orderInfo.UseScore);

                                //}
                                var uploadOrderResult = yikeClient.OrderUpload(orderInfo);

                                Tolog(string.Format("驿氪订单同步结果:{0}", Common.JSONHelper.ObjectToJson(uploadOrderResult)));
                            }
                            catch (Exception ex)
                            {
                                Tolog("驿氪订单同步异常:" + ex.Message);
                            }
                        }
                        #endregion

                        #region 付款加积分
                        try
                        {
                            bllUser.AddUserScoreDetail(orderInfo.OrderUserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.OrderPay), bllMall.WebsiteOwner, null, null);
                        }
                        catch (Exception)
                        { }

                        #endregion


                        #region 消息通知
                        if (!BLLJIMP.BLLMall.bookingList.Contains(orderInfo.ArticleCategoryType))
                        {
                            try
                            {
                                var    productName = bllMall.GetOrderDetailsList(orderInfo.OrderID)[0].ProductName;
                                string remark      = "";
                                if (!string.IsNullOrEmpty(orderInfo.OrderMemo))
                                {
                                    remark = string.Format("客户留言:{0}", orderInfo.OrderMemo);
                                }
                                bllWeiXin.SendTemplateMessageToKefu("有新的订单", string.Format("订单号:{0}\\n订单金额:{1}元\\n收货人:{2}\\n电话:{3}\\n商品:{4}\\n{5}", orderInfo.OrderID, orderInfo.TotalAmount, orderInfo.Consignee, orderInfo.Phone, productName, remark));
                                if (orderInfo.OrderType != 4)//付费的活动不发消息
                                {
                                    if (orderInfo.WebsiteOwner != "jikuwifi")
                                    {
                                        string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/orderDetail/{1}#/orderDetail/{1}", context.Request.Url.Host, orderInfo.OrderID);
                                        bllWeiXin.SendTemplateMessageNotifyComm(orderUserInfo, "订单已成功支付,我们将尽快发货,请保持手机畅通等待物流送达!", string.Format("订单号:{0}\\n订单金额:{1}元\\n收货人:{2}\\n电话:{3}\\n商品:{4}...\\n查看详情", orderInfo.OrderID, orderInfo.TotalAmount, orderInfo.Consignee, orderInfo.Phone, productName), url);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                            try
                            {
                                bllWeiXin.SendTemplateMessageToKefu(orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元\\n预约人:{3}\\n预约人手机:{4}", orderInfo.OrderID, orderInfo.TotalAmount, tProductInfo.PName, orderUserInfo.TrueName, orderUserInfo.Phone));
                                bllWeiXin.SendTemplateMessageNotifyComm(orderUserInfo, orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元", orderInfo.OrderID, orderInfo.TotalAmount, tProductInfo.PName));
                            }
                            catch (Exception)
                            {
                            }
                        }
                        #endregion
                        WebsiteInfo websiteInfo = bllMall.Get <WebsiteInfo>(string.Format(" WebsiteOwner='{0}'", orderInfo.WebsiteOwner));
                        #region 分销相关
                        try
                        {
                            if (bllMenuPermission.CheckUserAndPmsKey(websiteInfo.WebsiteOwner, BLLPermission.Enums.PermissionSysKey.OnlineDistribution, websiteInfo.WebsiteOwner))
                            {
                                if (string.IsNullOrWhiteSpace(orderUserInfo.DistributionOwner))
                                {
                                    if (websiteInfo.DistributionRelationBuildMallOrder == 1)
                                    {
                                        orderUserInfo.DistributionOwner = bllMall.WebsiteOwner;
                                        bllMall.Update(orderUserInfo);
                                    }
                                }

                                bllDis.AutoUpdateLevel(orderInfo);
                                bllDis.TransfersEstimate(orderInfo);
                                bllDis.SendMessageToUser(orderInfo);
                                bllDis.UpdateDistributionSaleAmountUp(orderInfo);
                            }
                        }
                        catch (Exception ex)
                        {
                            Tolog("设置分销员异常:" + ex.Message + " 用户id:" + orderUserInfo.UserID);
                        }
                        #endregion


                        #region 宏巍通知
                        try
                        {
                            if (websiteInfo.IsUnionHongware == 1)
                            {
                                hongWareClient.OrderNotice(orderUserInfo.WXOpenId, orderInfo.OrderID);
                            }
                        }
                        catch (Exception)
                        {
                        }

                        #endregion

                        bllCard.Give(orderInfo.TotalAmount, orderUserInfo);


                        string v1ProductId = Common.ConfigHelper.GetConfigString("YGBV1ProductId");
                        string v2ProductId = Common.ConfigHelper.GetConfigString("YGBV2ProductId");
                        string v1CouponId  = Common.ConfigHelper.GetConfigString("YGBV1CouponId");
                        string v2CouponId  = Common.ConfigHelper.GetConfigString("YGBV2CouponId");

                        List <WXMallOrderDetailsInfo> orderDetailList = bllMall.GetOrderDetailsList(orderInfo.OrderID);
                        foreach (var item in orderDetailList)
                        {
                            item.IsComplete = 1;
                            bllMall.Update(item);
                            #region 购买指定商品发送指定的优惠券
                            if (!string.IsNullOrEmpty(v1ProductId) && !string.IsNullOrEmpty(v1CouponId) && item.PID == v1ProductId)
                            {
                                bllCard.SendCardCouponsByCurrUserInfo(orderUserInfo, v1CouponId);
                            }

                            if (!string.IsNullOrEmpty(v2ProductId) && !string.IsNullOrEmpty(v2CouponId) && item.PID == v2ProductId)
                            {
                                bllCard.SendCardCouponsByCurrUserInfo(orderUserInfo, v2CouponId);
                            }
                            #endregion
                        }
                        //更新销量
                        bllMall.UpdateProductSaleCount(orderInfo);

                        context.Response.StatusCode = 200;
                        context.Response.Write(successStr);
                        Tolog("支付成功" + orderInfo.OrderID);
                        return;
                    }
                    else
                    {
                        Tolog("更改状态false");
                        context.Response.StatusCode = 500;
                        context.Response.Write(failStr);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                //error = "fail";
                Tolog("京东支付异常:" + ex.ToString());
            }

            context.Response.ContentType = "text/plain";
            context.Response.StatusCode  = 500;
            context.Response.Write(failStr);
        }
Example #15
0
        public void ProcessRequest(HttpContext context)
        {
            string         mType       = context.Request["module_type"]; //访问类型
            string         dTime       = context.Request["time"];        //时间类型
            var            monitorList = bllMonitor.GetMonitorStatisticsList(50, dTime, mType);
            List <dynamic> returnList  = new List <dynamic>();

            foreach (var item in monitorList)
            {
                string title = string.Empty;
                switch (mType)
                {
                case "activity":
                case "article":
                case "greetingcard":
                    JuActivityInfo jModel = bllMonitor.Get <JuActivityInfo>(string.Format(" WebsiteOwner='{0}' AND MonitorPlanID={1} ", bllMonitor.WebsiteOwner, item.MonitorPlanID));
                    if (jModel == null)
                    {
                        continue;
                    }
                    title = jModel.ActivityName;
                    returnList.Add(new
                    {
                        id    = jModel.JuActivityID,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "product":
                    WXMallProductInfo pModel = bllMall.GetProduct(item.MonitorPlanID.ToString());
                    if (pModel == null)
                    {
                        continue;
                    }
                    title = pModel.PName;
                    returnList.Add(new
                    {
                        id    = pModel.PID,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "question":
                    Questionnaire qModel = bllMall.Get <Questionnaire>(string.Format(" WebsiteOwner='{0}' AND QuestionnaireID={1}", bllMall.WebsiteOwner, item.MonitorPlanID));
                    if (qModel == null)
                    {
                        continue;
                    }
                    title = qModel.QuestionnaireName;
                    returnList.Add(new
                    {
                        id    = qModel.QuestionnaireID,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "questionnaireset":
                    BLLJIMP.Model.QuestionnaireSet sModel = bllMall.Get <BLLJIMP.Model.QuestionnaireSet>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bllMall.WebsiteOwner, item.MonitorPlanID));
                    if (sModel == null)
                    {
                        continue;
                    }
                    title = sModel.Title;
                    returnList.Add(new
                    {
                        id    = sModel.AutoID,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "thevote":
                    TheVoteInfo tModel = bllMall.Get <TheVoteInfo>(string.Format(" WebsiteOwner='{0}' AND AutoID={1}", bllMall.WebsiteOwner, item.MonitorPlanID));
                    if (tModel == null)
                    {
                        continue;
                    }
                    title = tModel.VoteName;
                    returnList.Add(new
                    {
                        id    = tModel.AutoId,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "scratch":
                case "shake":
                    WXLotteryV1 wModel = bllMall.Get <WXLotteryV1>(string.Format(" WebsiteOwner='{0}' AND LotteryID={1} ", bllMall.WebsiteOwner, item.MonitorPlanID));
                    if (wModel == null)
                    {
                        continue;
                    }
                    title = wModel.LotteryName;
                    returnList.Add(new
                    {
                        id    = wModel.LotteryID,
                        title = title,
                        count = item.tCount
                    });
                    break;

                case "wshow":
                    WXShowInfo xModel = bllMall.Get <WXShowInfo>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bllMall.WebsiteOwner, item.MonitorPlanID));
                    if (xModel == null)
                    {
                        continue;
                    }
                    title = xModel.ShowName;
                    returnList.Add(new
                    {
                        id    = xModel.AutoId,
                        title = title,
                        count = item.tCount
                    });

                    break;

                default:
                    break;
                }
            }

            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(returnList));
        }
Example #16
0
        /// <summary>
        /// 添加订单
        /// </summary>
        public void AddOrder(string oorderInfo, string websiteOwner)
        {
            OOrder          oorder    = ZentCloud.Common.JSONHelper.JsonToModel <OOrder>(oorderInfo);
            WXMallOrderInfo mallOrder = bllMall.Get <WXMallOrderInfo>(string.Format(" WebsiteOwner='{0}' AND OutOrderId='{1}'", websiteOwner, oorder.orderId));

            if (mallOrder == null)
            {
                mallOrder = new WXMallOrderInfo();
                ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZentCloud.ZCBLLEngine.BLLTransaction();
                mallOrder.OrderID      = bllMall.GetGUID(ZentCloud.BLLJIMP.TransacType.AddMallOrder);
                mallOrder.OutOrderId   = oorder.orderId;
                mallOrder.Address      = oorder.address;
                mallOrder.OrderType    = 8;
                mallOrder.WebsiteOwner = websiteOwner;
                mallOrder.TakeOutType  = "Eleme";
                mallOrder.OrderMemo    = oorder.description;
                if (!string.IsNullOrEmpty(oorder.createdAt))
                {
                    mallOrder.InsertDate = GetDate(oorder.createdAt);
                }
                if (!string.IsNullOrEmpty(oorder.activeAt))
                {
                    mallOrder.PayTime = GetDate(oorder.activeAt);
                }
                if (oorder.deliverFee.HasValue)
                {
                    mallOrder.Transport_Fee = (decimal)oorder.deliverFee;
                }
                if (!string.IsNullOrEmpty(oorder.deliverTime))
                {
                    mallOrder.Ex2 = GetDate(oorder.deliverTime).ToString();
                }
                mallOrder.Ex3 = oorder.invoice;
                mallOrder.Ex4 = oorder.book.ToString();
                mallOrder.Ex5 = oorder.onlinePaid.ToString();
                List <string> phoneList = oorder.phoneList;
                if (phoneList.Count > 0)
                {
                    for (int i = 0; i < phoneList.Count; i++)
                    {
                        if (i == 0)
                        {
                            mallOrder.Phone = phoneList[i];
                        }
                        mallOrder.Ex6 += phoneList[i] + ",";
                    }
                    mallOrder.Ex6 = mallOrder.Ex6.Remove(mallOrder.Ex6.Length - 1, 1);
                }
                mallOrder.Ex7         = oorder.shopId.ToString();
                mallOrder.Ex9         = oorder.shopName;
                mallOrder.OrderUserID = oorder.userId.ToString();
                if (oorder.totalPrice.HasValue)
                {
                    mallOrder.TotalAmount = (decimal)oorder.totalPrice;
                }
                if (oorder.originalPrice.HasValue)
                {
                    mallOrder.Ex10 = oorder.originalPrice.ToString();
                }
                mallOrder.Consignee = oorder.consignee;
                mallOrder.Ex11      = oorder.deliveryGeo;
                mallOrder.Ex12      = oorder.deliveryPoiAddress;
                mallOrder.Ex13      = oorder.invoiced.ToString();
                if (oorder.income.HasValue)
                {
                    mallOrder.Ex14 = oorder.income.ToString();
                }
                if (oorder.serviceRate.HasValue)
                {
                    mallOrder.Ex15 = oorder.serviceRate.ToString();
                }
                if (oorder.serviceFee.HasValue)
                {
                    mallOrder.Ex16 = oorder.serviceFee.ToString();
                }
                if (oorder.hongbao.HasValue)
                {
                    mallOrder.Ex17 = oorder.hongbao.ToString();
                }
                if (oorder.packageFee.HasValue)
                {
                    mallOrder.Ex18 = oorder.packageFee.ToString();
                }
                if (oorder.activityTotal.HasValue)
                {
                    mallOrder.Ex19 = oorder.activityTotal.ToString();
                }
                if (oorder.shopPart.HasValue)
                {
                    mallOrder.Ex20 = oorder.shopPart.ToString();
                }
                if (oorder.elemePart.HasValue)
                {
                    mallOrder.Ex21 = oorder.elemePart.ToString();
                }
                if (mallOrder.TotalAmount > 0)
                {
                    mallOrder.PaymentStatus = 1;
                }
                mallOrder.Ex22            = oorder.downgraded.ToString();
                mallOrder.OutOrderStatus  = GetOrderStatus(oorder.status);
                mallOrder.Status          = "待发货";
                mallOrder.OutRefundStatus = GetRefStatus(oorder.refundStatus);
                mallOrder.Ex8             = oorder.openId;
                if (oorder.vipDeliveryFeeDiscount.HasValue)
                {
                    mallOrder.Ex10 = oorder.vipDeliveryFeeDiscount.ToString();
                }
                if (!bllWebsite.Add(mallOrder, tran))
                {
                    tran.Rollback();
                    resp.msg = "添加订单出错";
                    Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                    return;
                }
                List <OGoodsGroup> goodsGroupList = oorder.groups;
                foreach (var item in goodsGroupList)
                {
                    WXMallOrderDetailsInfo oorderDetail = new WXMallOrderDetailsInfo();
                    oorderDetail.Ex1     = item.name;
                    oorderDetail.Ex2     = item.type;
                    oorderDetail.OrderID = mallOrder.OrderID;
                    List <OGoodsItem> goodItems = item.items;
                    foreach (var good in goodItems)
                    {
                        oorderDetail.PID         = good.id.ToString();
                        oorderDetail.Ex3         = good.id.ToString();
                        oorderDetail.Ex9         = good.skuId.ToString();
                        oorderDetail.ProductName = good.name;
                        oorderDetail.Ex4         = good.categoryId.ToString();
                        if (good.price.HasValue)
                        {
                            oorderDetail.OrderPrice = (decimal)good.price;
                        }
                        oorderDetail.TotalCount = good.quantity;
                        if (good.total.HasValue)
                        {
                            oorderDetail.TotalPrice = (decimal)good.total;
                        }
                        oorderDetail.Ex7 = good.extendCode;
                        oorderDetail.Ex8 = good.barCode;
                        if (good.userPrice.HasValue)
                        {
                            oorderDetail.Ex10 = good.userPrice.ToString();
                        }
                        if (good.shopPrice.HasValue)
                        {
                            oorderDetail.Ex11 = good.shopPrice.ToString();
                        }
                        if (good.weight.HasValue)
                        {
                            oorderDetail.Wegith = (decimal)good.weight;
                        }
                        oorderDetail.Unit = "元";
                        if (good.newSpecs != null)
                        {
                            List <OGroupItemSpec> specList = good.newSpecs;
                            oorderDetail.Ex5 = ZentCloud.Common.JSONHelper.ListToJson <OGroupItemSpec>(specList);
                        }
                        if (good.attributes != null)
                        {
                            List <OGroupItemAttribute> attrList = good.attributes;
                            oorderDetail.Ex6 = ZentCloud.Common.JSONHelper.ListToJson <OGroupItemAttribute>(attrList);
                        }
                        if (!bllWebsite.Add(oorderDetail, tran))
                        {
                            tran.Rollback();
                            resp.msg = "添加商品出错";
                            Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                            return;
                        }
                    }
                }
                tran.Commit();
            }
        }