コード例 #1
0
        /// <summary>
        /// 判断是否重复配置同类型支付信息
        /// </summary>
        public void CheckCustomerMapping(string paymentTypeId)
        {
            var loggingSessionInfo             = new SessionManager().CurrentUserLoginInfo;
            var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo);
            var tPaymentTypeBll = new T_Payment_TypeBLL(loggingSessionInfo);

            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            //商户条件
            //complexCondition.Add(new EqualsCondition() { FieldName = "customerid", Value = loggingSessionInfo.ClientID });
            complexCondition.Add(new DirectCondition("Payment_Type_Code in ('CCAlipayWap','AlipayWap')"));
            var paymentTypeList        = tPaymentTypeBll.Query(complexCondition.ToArray(), null); //支付宝支付和平台支付宝支付配置信息
            var currentPaymentTypeInfo = tPaymentTypeBll.GetByID(paymentTypeId);                  //当前支付方式信息

            foreach (var paymentType in paymentTypeList)
            {
                var ptCustomerMapping = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity()
                {
                    CustomerId = loggingSessionInfo.ClientID, PaymentTypeID = paymentType.Payment_Type_Id
                }, null).FirstOrDefault();
                if (ptCustomerMapping != null && ptCustomerMapping.PaymentTypeID != paymentTypeId && currentPaymentTypeInfo.Payment_Type_Code != "WXJS" && currentPaymentTypeInfo.Payment_Type_Code != "GetToPay")
                {
                    throw new APIException("同类型的支付方式只能启用一个.")
                          {
                              ErrorCode = 121
                          }
                }
                ;
            }
        }
コード例 #2
0
        public string GetMapingbyPayMentTypeId(HttpRequest requst)
        {
            string paymentTypeId = requst.Form["paymentTypeId"];

            if (string.IsNullOrWhiteSpace(paymentTypeId))
            {
                paymentTypeId = requst.QueryString["paymentTypeId"].ToString();
            }


            TPaymentTypeCustomerMappingBLL    server = new TPaymentTypeCustomerMappingBLL(this.CurrentUserInfo);
            TPaymentTypeCustomerMappingEntity entity = new TPaymentTypeCustomerMappingEntity();

            entity.IsDelete      = 0;
            entity.PaymentTypeID = paymentTypeId;
            entity.CustomerId    = this.CurrentUserInfo.ClientID;
            TPaymentTypeCustomerMappingEntity[] entitylist = server.QueryByEntity(entity, null);
            if (entitylist != null && entitylist.Length > 0)
            {
                entitylist[0].url = ConfigurationManager.AppSettings["payMentUrl"];
                return(entitylist[0].ToJSON());
            }
            else
            {
                entity.url = ConfigurationManager.AppSettings["payMentUrl"];
                return(entity.ToJSON());
            }
            return("");
        }
コード例 #3
0
        protected override SetRewardOrderRD ProcessRequest(DTO.Base.APIRequest <SetRewardOrderRP> pRequest)
        {
            var    rd         = new SetRewardOrderRD();
            string customerId = CurrentUserInfo.ClientID;
            var    trrBll     = new T_RewardRecordBLL(CurrentUserInfo);

            var tptcmBll = new TPaymentTypeCustomerMappingBLL(CurrentUserInfo);

            var employeeId   = pRequest.Parameters.EmployeeID;//员工ID
            var rewardAmount = pRequest.Parameters.RewardAmount;

            if (string.IsNullOrEmpty(employeeId))
            {
                throw new APIException("员工ID无效")
                      {
                          ErrorCode = 121
                      };
            }

            //生成打赏单
            var trrEntity = new T_RewardRecordEntity()
            {
                RewardId = Guid.NewGuid(),
                //RewardCode = "哪来的?",
                RewardOPType   = 1,               //会员(打赏人)
                RewardOP       = pRequest.UserID, //会员ID
                RewardedOPType = 2,               //员工(被打赏人)
                RewardedOP     = employeeId,
                RewardAmount   = rewardAmount,
                //Remark = string.Empty,
                PayStatus  = 0, //默认未支付,等待支付回调接口来修改
                RewardType = 1, //1=现金,2=积分
                CustomerId = customerId
            };

            trrBll.Create(trrEntity);//创建打赏单

            rd.RewardOrderID = "REWARD|" + trrEntity.RewardId;

            var tptcmEntity = tptcmBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity()
            {
                PaymentTypeID = "DFD3E26D5C784BBC86B075090617F44B", CustomerId = customerId
            }, null).FirstOrDefault();

            rd.paymentId = tptcmEntity != null ? tptcmEntity.PaymentTypeID : string.Empty;

            return(rd);
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
            JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
            {
                Message = "支付通知接口被调用"
            });


            #region 获取url参数
            //签名类型,取值: MD5MD5 、RSA RSA,默认: MD5
            var signType = context.Request.QueryString["sign_type"];
            //版本号,默认为 1.0
            var serviceVersion = context.Request.QueryString["service_version"];
            //字符编码 ,取值: GBKGBK 、UTFUTFUTF-8,默认: GBKGBK 。
            var inputCharset = context.Request.QueryString["input_charset"];
            //签名
            var sign = context.Request.QueryString["sign"];
            //多密钥支持的序号,默认 1
            var signKeyIndex = context.Request.QueryString["sign_key_index"];
            //1-即时到账 其他保留
            var tradeMode = context.Request.QueryString["trade_mode"];
            //支付结果:0—成功 其他保留
            var tradeState = context.Request.QueryString["trade_state"];
            //支付结果信息,成功时为空
            var payInfo = context.Request.QueryString["pay_info"];
            //商户号,也即之前步骤的 商户号,也即之前步骤的 partnerid,由微信统一分配的 10 位正整数 (120XXXXXXX)号
            var partner = context.Request.QueryString["partner"];
            //银行类型,在微信中使用 WX
            var bankType = context.Request.QueryString["bank_type"];
            //银行订单号
            var bankBillno = context.Request.QueryString["bank_billno"];
            //支付金额,单位为分如果 支付金额,单位为分如果 支付金额,单位为分如果 discount 有值,通知的 total_fee + discount = 请求的 total_fee
            var totalFee = context.Request.QueryString["total_fee"];
            //现金支付币种 ,目前只支持人民币 默认值是 1-人民币
            var feeType = context.Request.QueryString["fee_type"];
            //支付结果通知 id ,对于某些特定商 户,只返回通知 id ,要求商户据此查询交易结果
            var notifyId = context.Request.QueryString["notify_id"];
            //交易号, 28 位长的数值,其中前 位长的数值,其中前 10 位为商户号,之后 8位为订单产生 的日期,如 20090415,最后 10 位是流水号。
            var transactionId = context.Request.QueryString["transaction_id"];
            //商户系统的订单号,与请求一致。
            var outTradeNo = context.Request.QueryString["out_trade_no"];
            //商户 数据包,原样返回
            var attach = context.Request.QueryString["attach"];
            //支付完成时间,格式为yyyyMMddhhmmss ,如 2009 年 12 月 27 日 9点 10 分 10 秒表示为 秒表示为 20091227091010。时区为 GMT+8 beijing
            var timeEnd = context.Request.QueryString["time_end"];
            //物流费用,单位分默认0。如果有值,必须保证 transport_fee + product_fee = total_fee
            var transportFee = context.Request.QueryString["transport_fee"];
            //物品费用,单位分。如果有值必须保证 transport_fee + product_fee = total_fee
            var productFee = context.Request.QueryString["product_fee"];
            //折扣价格,单位分.如果有值,通知的 total_fee + discount =  请求的 total_fee
            var discount = context.Request.QueryString["discount"];
            //对应买家账号的一个加密串
            var buyerAlias = context.Request.QueryString["buyer_alias"];

            #endregion



            var appSignature = string.Empty;
            var appId        = string.Empty;
            var isSubscribe  = string.Empty;
            var timeStamp    = string.Empty;
            var nonceStr     = string.Empty;
            var openID       = string.Empty;

            using (var stream = context.Request.InputStream)
            {
                using (var rd = new StreamReader(stream, Encoding.UTF8))
                {
                    var xmlStr = rd.ReadToEnd();
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "传入内容:" + xmlStr
                    });
                    var doc = new XmlDocument();
                    doc.LoadXml(xmlStr);
                    nonceStr     = doc.SelectSingleNode("xml/NonceStr").InnerText;
                    appSignature = doc.SelectSingleNode("xml/AppSignature").InnerText;
                    appId        = doc.SelectSingleNode("xml/AppId").InnerText;
                    isSubscribe  = doc.SelectSingleNode("xml/IsSubscribe").InnerText;
                    timeStamp    = doc.SelectSingleNode("xml/TimeStamp").InnerText;
                    openID       = doc.SelectSingleNode("xml/OpenId").InnerText;
                }
            }

            #region

            var customerWxMappingBll = new TCustomerWeiXinMappingBLL(Default.GetAPLoggingSession(""));

            var customerId = customerWxMappingBll.GetCustomerIdByAppId(appId);

            if (customerId == "")
            {
                throw new APIException("客户ID为空")
                      {
                          ErrorCode = 121
                      };
            }


            var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");


            var wxPayNoticeEntity = new WXPayNoticeEntity
            {
                SignType       = signType,
                Sign           = sign,
                ServiceVersion = serviceVersion,
                InputCharset   = inputCharset,
                SignKeyIndex   = Convert.ToInt32(signKeyIndex),
                TradeMode      = Convert.ToInt32(tradeMode),
                TradeState     = Convert.ToInt32(tradeState),
                PayInfo        = payInfo,
                Partner        = partner,
                BankType       = bankType,
                BankBillno     = bankBillno,
                TotalFee       = Convert.ToInt32(totalFee),
                FeeType        = Convert.ToInt32(feeType),
                NotifyId       = notifyId,
                TransactionId  = transactionId,
                OutTradeNo     = outTradeNo,
                Attach         = attach,
                TimeEnd        = timeEnd,
                TransportFee   = Convert.ToInt32(transportFee),
                ProductFee     = Convert.ToInt32(productFee),
                Discount       = Convert.ToInt32(discount),
                BuyerAlias     = buyerAlias,
                AppId          = appId,
                TimeStamp      = Convert.ToInt32(timeStamp),
                NonceStr       = nonceStr,
                OpenId         = openID,
                AppSignature   = appSignature,
                IsSubscribe    = 1,
                CustomerId     = customerId
            };

            var wxPayNoticeBll = new WXPayNoticeBLL(currentUserInfo);

            var entity = wxPayNoticeBll.QueryByEntity(new WXPayNoticeEntity()
            {
                OutTradeNo = outTradeNo,
                OpenId     = openID
            }, null);
            if (entity != null)
            {
                wxPayNoticeBll.Delete(entity);
            }
            wxPayNoticeBll.Create(wxPayNoticeEntity);

            //将请求数据记录到表中、方便维权的时候试用
            //1.向表中记录该笔支付是否成功,如不成功,将失败原因记录下来【status = 1 成功 0 失败 2 支付金额与订单金额不符】

            //2.判断支付是否成功
            //if (tradeState == "0")//成功
            //{
            //    //3.根据订单号查询该笔订单的金额是否相符,如不符合,记录信息,查看原因

            //}
            //else//失败
            //{
            //    //
            //}

            if (tradeState == "0")
            {
                //根据customerid获取channelid;
                var channelBll = new TPaymentTypeCustomerMappingBLL(currentUserInfo);
                var channelId  = channelBll.GetChannelIdByCustomerId(customerId);

                var paras = "ChannelID=" + channelId + "&outTradeNo=" + outTradeNo;

                var url = System.Configuration.ConfigurationManager.AppSettings["wxNativePayNotifyUrl"];
                JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                {
                    Message = url + "?" + paras
                });
                var response = JIT.Utility.Web.HttpClient.PostQueryString(url, paras);
                JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                {
                    Message = response
                });
            }

            #region 向表中记录调用的微信接口

            var wxInterfaceLogBll    = new WXInterfaceLogBLL(currentUserInfo);
            var wxInterfaceLogEntity = new WXInterfaceLogEntity();
            wxInterfaceLogEntity.LogId        = Guid.NewGuid();
            wxInterfaceLogEntity.InterfaceUrl = System.Configuration.ConfigurationManager.AppSettings["wxNativePayNotifyUrl"];
            wxInterfaceLogEntity.AppId        = appId;
            wxInterfaceLogEntity.OpenId       = openID;
            wxInterfaceLogEntity.RequestParam = wxPayNoticeEntity.ToJSON();
            wxInterfaceLogEntity.IsSuccess    = 1;
            wxInterfaceLogBll.Create(wxInterfaceLogEntity);

            #endregion


            context.Response.Write("success");


            #endregion
        }
コード例 #5
0
        /// <summary>
        /// 设置商户自己的支付方式
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string SetPayChannel(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SetPayChannel> >();

            if (rp.Parameters.AddPayChannelData.Length == 0)
            {
                throw new APIException("请求参数中缺少AddPayChannelData或值为空.")
                      {
                          ErrorCode = 121
                      };
            }
            var paymentTypeId = rp.Parameters.AddPayChannelData[0].PaymentTypeId;

            CheckCustomerMapping(paymentTypeId);//判断是否重复配置同类型支付信息

            var loggingSessionInfo             = new SessionManager().CurrentUserLoginInfo;
            var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo);

            var customerId = loggingSessionInfo.ClientID;


            //获取该支付通道的信息
            var tPaymeentTypeCusMapEntity = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity()
            {
                ChannelId  = Convert.ToString(rp.Parameters.AddPayChannelData[0].ChannelId),
                CustomerId = customerId
            }, null);

            //if (tPaymeentTypeCusMapEntity != null && tPaymeentTypeCusMapEntity.Length > 0)
            //{
            //    var payDeloyType = tPaymeentTypeCusMapEntity[0].PayDeplyType;

            //    //如果该支付通道之前为默认配置,将channelId设置为0,这样支付中心会生成一条新的数据
            //    if (payDeloyType == 0)
            //    {
            //        rp.Parameters.AddPayChannelData[0].ChannelId = 0;
            //    }
            //}

            var tPaymentTypeCustomerMappingEntityList =
                tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity()
            {
                PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId,
                CustomerId    = customerId
            }, null);

            if (rp.Parameters.AddPayChannelData[0].PayType > 0) //非货到付款
            {
                var paychannelUrl = ConfigurationManager.AppSettings["payChannelUrl"];

                string reqs = "request" + pRequest;

                string str = "{\"ClientID\":\"" + loggingSessionInfo.ClientID + "\","
                             + "\"UserID\":\"" + loggingSessionInfo.UserID + "\","
                             + "\"Token\":null,\"AppID\":1,"
                             + "\"Parameters\":" + rp.Parameters.ToJSON() + "}";
                var result = HttpWebClient.DoHttpRequest(paychannelUrl + "Gateway.ashx?action=SetPayChannel", "request=" +
                                                         HttpUtility.UrlEncode(str));

                string loggerStr = paychannelUrl + "Gateway.ashx?action=SetPayChannel&" +
                                   str;
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = loggerStr
                });

                var channelList = result.DeserializeJSONTo <PayChannelReturnResult>();

                if (channelList.Datas == null)
                {
                    throw new APIException("创建失败:" + result)
                          {
                              ErrorCode = 122
                          };
                }

                if (channelList.Datas.PayChannelIdList[0].ChannelId == 0)
                {
                    throw new APIException("创建失败:" + result)
                          {
                              ErrorCode = 122
                          };
                }
                else
                {
                    if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0)
                    {
                        tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList);
                    }


                    var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity();

                    tPaymentTypeCustomerMappingEntity.MappingId     = Guid.NewGuid();
                    tPaymentTypeCustomerMappingEntity.CustomerId    = loggingSessionInfo.ClientID;
                    tPaymentTypeCustomerMappingEntity.PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId;
                    tPaymentTypeCustomerMappingEntity.APPId         = "1";
                    tPaymentTypeCustomerMappingEntity.Currency      = 1;
                    tPaymentTypeCustomerMappingEntity.PayDeplyType  = 1;

                    tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity);


                    var payTypeId = rp.Parameters.AddPayChannelData[0].PayType;

                    var updateSql = "";
                    if (payTypeId == 1 || payTypeId == 2)
                    {
                        var unionPayData = rp.Parameters.AddPayChannelData[0].UnionPayData;

                        var merchantId                 = unionPayData.MerchantID;
                        var certificateFilePath        = unionPayData.CertificateFilePath;
                        var certificateFilePassword    = unionPayData.CertificateFilePassword;
                        var decryptCertificateFilePath = unionPayData.DecryptCertificateFilePath;
                        var packetEncryptKey           = unionPayData.PacketEncryptKey;

                        updateSql = "PayAccountNumber = '" + merchantId + "',"
                                    + "EncryptionCertificate = '" + certificateFilePath + "',"
                                    + "EncryptionPwd ='" + certificateFilePassword + "',"
                                    + "DecryptionCertificate ='" + decryptCertificateFilePath + "',"
                                    + "DecryptionPwd ='" + packetEncryptKey + "',"
                                    + "PayDeplyType=1";
                    }
                    if (payTypeId == 3 || payTypeId == 4)
                    {
                        var wapData = rp.Parameters.AddPayChannelData[0].WapData;

                        var partner           = wapData.Partner;
                        var sellerAccountName = wapData.SellerAccountName;
                        var RSA_PublicKey     = wapData.RSA_PublicKey;
                        var RSA_PrivateKey    = wapData.RSA_PrivateKey;
                        var MD5Key            = wapData.MD5Key;
                        var SCAN_AppID        = wapData.SCAN_AppID;
                        var PayEncryptedPwd   = wapData.PayEncryptedPwd;


                        updateSql = "PayAccountNumber ='" + partner + "',"
                                    + "PayAccounPublic='" + RSA_PublicKey + "',"
                                    + "PayPrivate='" + RSA_PrivateKey + "',"
                                    + "SalesTBAccess='" + sellerAccountName + "',"
                                    + "ApplyMD5Key='" + MD5Key + "',"
                                    + "EncryptionCertificate='" + SCAN_AppID + "',"
                                    + "PayEncryptedPwd='" + PayEncryptedPwd + "',"
                                    + "PayDeplyType=1";
                    }
                    if (payTypeId == 5 || payTypeId == 6)
                    {
                        var wxData = rp.Parameters.AddPayChannelData[0].WxPayData;
                        var appID  = wxData.AppID;
                        //var appSecret = wxData.AppSecret;
                        //var parnterID = wxData.ParnterID;
                        //var parnterKey = wxData.ParnterKey;
                        //var PaySignKey = wxData.PaySignKey;
                        var mch_id  = wxData.Mch_ID;
                        var signKey = wxData.SignKey;

                        updateSql = "AccountIdentity='" + appID + "',"
                                    //+ "PublicKey='" + appSecret + "',"
                                    //+ "TenPayIdentity='" + parnterID + "',"
                                    //+ "TenPayKey='" + parnterKey + "',"
                                    //+ "PayEncryptedPwd='" + PaySignKey + "',"
                                    + "TenPayIdentity='" + mch_id + "',"
                                    + "TenPayKey='" + signKey + "',"
                                    + "PayDeplyType=1";
                    }

                    tPaymentTypeCustomerMappingBll.UpdatePaymentMap(updateSql, channelList.Datas.PayChannelIdList[0].ChannelId + 1
                                                                    , rp.Parameters.AddPayChannelData[0].PaymentTypeId, customerId);
                }
            }
            else //货到付款
            {
                if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0)
                {
                    tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList);
                }


                var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity();

                tPaymentTypeCustomerMappingEntity.MappingId     = Guid.NewGuid();
                tPaymentTypeCustomerMappingEntity.CustomerId    = loggingSessionInfo.ClientID;
                tPaymentTypeCustomerMappingEntity.PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId;
                tPaymentTypeCustomerMappingEntity.APPId         = "1";
                tPaymentTypeCustomerMappingEntity.Currency      = 1;
                tPaymentTypeCustomerMappingEntity.PayDeplyType  = 1;

                tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity);
            }
            var rd  = new EmptyResponseData();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
コード例 #6
0
        /// <summary>
        /// 启用连锁掌柜默认的支付方式
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string SetDefaultPayChannel(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SetPayChannel> >();

            if (rp.Parameters.AddPayChannelData.Length == 0)
            {
                throw new APIException("请求参数中缺少AddPayChannelData或值为空.")
                      {
                          ErrorCode = 121
                      };
            }
            var paymentTypeId = rp.Parameters.AddPayChannelData[0].PaymentTypeId;

            CheckCustomerMapping(paymentTypeId);//判断是否重复配置同类型支付信息
            var loggingSessionInfo             = new SessionManager().CurrentUserLoginInfo;
            var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo);
            var customerId = loggingSessionInfo.ClientID;

            //获取要修改的支付方式
            var tPaymentTypeCustomerMappingEntityList =
                tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity()
            {
                PaymentTypeID = rp.Parameters.AddPayChannelData[0].PaymentTypeId,
                CustomerId    = customerId
            }, null);

            //从ap库里面获取该支付方式的channelID
            var channelId = tPaymentTypeCustomerMappingBll.GetChannelIdByPaymentTypeAndCustomer(paymentTypeId, customerId);

            if (channelId == "-1")
            {
                throw new APIException("未找到默认的支付通道.")
                      {
                          ErrorCode = 122
                      };
            }
            else
            {
                //逻辑删除原有配置
                if (tPaymentTypeCustomerMappingEntityList != null && tPaymentTypeCustomerMappingEntityList.Length > 0)
                {
                    tPaymentTypeCustomerMappingBll.Delete(tPaymentTypeCustomerMappingEntityList);
                }
                //重新启用
                var tPaymentTypeCustomerMappingEntity = new TPaymentTypeCustomerMappingEntity();
                tPaymentTypeCustomerMappingEntity.MappingId     = Guid.NewGuid();
                tPaymentTypeCustomerMappingEntity.PaymentTypeID = paymentTypeId;
                tPaymentTypeCustomerMappingEntity.CustomerId    = customerId;
                tPaymentTypeCustomerMappingEntity.ChannelId     = channelId;
                tPaymentTypeCustomerMappingEntity.APPId         = "1";
                tPaymentTypeCustomerMappingEntity.Currency      = 1;
                tPaymentTypeCustomerMappingEntity.PayDeplyType  = 0;
                tPaymentTypeCustomerMappingBll.Create(tPaymentTypeCustomerMappingEntity);
                //设置默认的channelID数据,不需要设置
                //string updateSql =  " PayDeplyType=0 ";
                //tPaymentTypeCustomerMappingBll.UpdatePaymentMap(updateSql, Convert.ToInt32(channelId)
                //   , paymentTypeId, customerId);
            }


            var rd  = new EmptyResponseData();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
コード例 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var OrderID     = context.Request["OrderID"];
            var OrderStatus = context.Request["OrderStatus"];
            var CustomerID  = context.Request["CustomerID"];
            var UserID      = context.Request["UserID"];
            var ChannelID   = context.Request["ChannelID"];
            var SerialPay   = context.Request["SerialPay"];

            try
            {
                if (string.IsNullOrEmpty(OrderID) || string.IsNullOrEmpty(OrderStatus) || string.IsNullOrEmpty(CustomerID) || string.IsNullOrEmpty(UserID) || string.IsNullOrEmpty(ChannelID))
                {
                    throw new Exception("参数不全:OrderID,OrderStatus,CustomerID,UserID");
                }
                else
                {
                    if (OrderStatus == "2")
                    {
                        //支付成功,更新卡的支付状态
                        //OrderID就是VIPCardID
                        //
                        //var rp = pRequest.DeserializeJSONTo<APIRequest<SetVipCardRP>>();

                        //if (string.IsNullOrEmpty(rp.Parameters.PayID))
                        //{
                        //    throw new APIException("缺少参数【PayID】或参数值为空") { ErrorCode = 135 };
                        //}
                        var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, UserID);
                        //会员
                        var vipBll               = new VipBLL(loggingSessionInfo);
                        var vipAmountBll         = new VipAmountBLL(loggingSessionInfo);
                        var vipCardVipMappingBll = new VipCardVipMappingBLL(loggingSessionInfo);
                        //支付
                        var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo);
                        var tPaymentTypeBll  = new T_Payment_TypeBLL(loggingSessionInfo);
                        var paymentDetailBll = new T_Payment_detailBLL(loggingSessionInfo);
                        //门店
                        var unitBLL = new t_unitBLL(loggingSessionInfo);
                        //商品订单支付
                        //更新积分和状态
                        //var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, "1");
                        var inoutBll = new T_InoutBLL(loggingSessionInfo);//订单业务对象实例化

                        var trrBll = new T_RewardRecordBLL(loggingSessionInfo);
                        //辨别打赏订单
                        var rewardOrderPrefix = "REWARD|";
                        if (OrderID.Contains(rewardOrderPrefix))
                        {
                            OrderID = OrderID.Substring(rewardOrderPrefix.Length, OrderID.Length - rewardOrderPrefix.Length);
                            var trrEntity = trrBll.GetByID(OrderID);
                            trrEntity.PayStatus      = 2;
                            trrEntity.LastUpdateTime = DateTime.Now;
                            trrEntity.LastUpdateBy   = loggingSessionInfo.UserID;
                            trrBll.Update(trrEntity);

                            #region 员工余额变更--需要独立出来处理
                            var userAmountBll = new VipAmountBLL(loggingSessionInfo);                                 //作为员工余额使用
                            var employeeId    = trrEntity.RewardedOP;
                            var rewardAmount  = trrEntity.RewardAmount == null ? 0 : (decimal)trrEntity.RewardAmount; //转为非null的decimal类型
                            //门店
                            var unitService = new UnitService(loggingSessionInfo);
                            var unitInfo    = unitService.GetUnitByUser(CustomerID, employeeId).FirstOrDefault();//获取员工所属门店

                            var tran = userAmountBll.GetTran();
                            using (tran.Connection)//事务
                            {
                                try
                                {
                                    var userAmountEntity = userAmountBll.GetByID(trrEntity.RewardedOP);
                                    if (userAmountEntity == null)
                                    {
                                        //创建
                                        userAmountEntity = new VipAmountEntity
                                        {
                                            VipId                  = employeeId,//员工ID
                                            VipCardCode            = string.Empty,
                                            BeginAmount            = 0,
                                            InAmount               = rewardAmount,
                                            OutAmount              = 0,
                                            EndAmount              = rewardAmount,
                                            TotalAmount            = rewardAmount,
                                            BeginReturnAmount      = 0,
                                            InReturnAmount         = 0,
                                            OutReturnAmount        = 0,
                                            ReturnAmount           = 0,
                                            ImminentInvalidRAmount = 0,
                                            InvalidReturnAmount    = 0,
                                            ValidReturnAmount      = 0,
                                            TotalReturnAmount      = 0,
                                            IsLocking              = 0,
                                            CustomerID             = CustomerID
                                        };
                                        userAmountBll.Create(userAmountEntity, tran);//创建员工余额表
                                    }
                                    else
                                    {
                                        //修改
                                        if (rewardAmount > 0)
                                        {
                                            userAmountEntity.InAmount    = (userAmountEntity.InAmount == null ? 0 : userAmountEntity.InAmount.Value) + rewardAmount;
                                            userAmountEntity.TotalAmount = (userAmountEntity.TotalAmount == null ? 0 : userAmountEntity.TotalAmount.Value) + rewardAmount;
                                        }
                                        else
                                        {
                                            userAmountEntity.OutAmount = (userAmountEntity.OutAmount == null ? 0 : userAmountEntity.OutAmount.Value) + Math.Abs(rewardAmount);
                                        }
                                        userAmountEntity.EndAmount = (userAmountEntity.EndAmount == null ? 0 : userAmountEntity.EndAmount.Value) + rewardAmount;

                                        userAmountBll.Update(userAmountEntity, tran);//更新余额
                                    }

                                    var vipamountDetailBll    = new VipAmountDetailBLL(loggingSessionInfo);
                                    var vipAmountDetailEntity = new VipAmountDetailEntity
                                    {
                                        VipAmountDetailId = Guid.NewGuid(),
                                        VipCardCode       = string.Empty,
                                        VipId             = employeeId,//员工ID
                                        UnitID            = unitInfo != null ? unitInfo.unit_id : string.Empty,
                                        UnitName          = unitInfo != null ? unitInfo.Name : string.Empty,
                                        Amount            = rewardAmount,
                                        UsedReturnAmount  = 0,
                                        EffectiveDate     = DateTime.Now,
                                        DeadlineDate      = Convert.ToDateTime("9999-12-31 23:59:59"),
                                        AmountSourceId    = "26",
                                        Reason            = "Reward",
                                        CustomerID        = CustomerID
                                    };
                                    vipamountDetailBll.Create(vipAmountDetailEntity, tran); //创建余额详情

                                    tran.Commit();                                          //提交事务
                                }
                                catch (Exception ex)
                                {
                                    tran.Rollback();
                                    Loggers.Debug(new DebugLogInfo()
                                    {
                                        Message = "异常-->支付成功回调时更新会员打赏金额出错(PayNotify.ashx):" + ex
                                    });
                                }
                            }
                            #endregion

                            if (trrEntity != null)
                            {
                                context.Response.Write("SUCCESS");
                            }
                            else
                            {
                                context.Response.Write("FAIL");
                            }
                            return;
                        }
                        //获取会员信息
                        var vipInfo = vipBll.GetByID(loggingSessionInfo.UserID);
                        //支付信息 Bear
                        //var tPaymentTypeCustomerMappingEntity = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity(){ChannelId = ChannelID,CustomerId = loggingSessionInfo.ClientID },null).FirstOrDefault();
                        var paymentTypeList = tPaymentTypeBll.GetAll();
                        var tPaymentType    =
                            paymentTypeList.ToList()
                            .Find(t => t.Payment_Type_Code == "WXJS");

                        //var tPaymentType = tPaymentTypeBll.GetByID(tPaymentTypeCustomerMappingEntity.PaymentTypeID);
                        //获取订单信息
                        var inoutInfo = inoutBll.GetByID(OrderID);
                        if (inoutInfo != null)
                        {
                            var    bll = new TInOutStatusNodeBLL(loggingSessionInfo);
                            string msg;
                            if (!bll.SetOrderPayment(OrderID, out msg, ChannelID, SerialPay))
                            //if (!bll.SetOrderPayment(OrderID, out msg, ChannelID))
                            {
                                throw new Exception(msg);
                            }
                            else if (string.IsNullOrEmpty(inoutInfo.Field17) && string.IsNullOrEmpty(inoutInfo.Field18))
                            {
                                #region 发送订单支付成功微信模板消息
                                var SuccessCommonBLL = new CommonBLL();
                                //SuccessCommonBLL.SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId,vipInfo.VIPID, loggingSessionInfo);
                                new SendOrderPaySuccessMsgBLL().SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                #endregion
                                Loggers.Debug(new DebugLogInfo()
                                {
                                    Message = "调用SetOrderPayment方法更新订单成功"
                                });
                            }
                            //获取订单信息,根据Field3==1判断,如果是ALD订单,则调用ALD接口更新ALD订单的状态
                            #region 更新ALD状态
                            //var orderbll = new InoutService(loggingSessionInfo);
                            //var orderInfo = orderbll.GetInoutInfoById(OrderID);
                            //if (orderInfo.Field3 == "1")
                            //{
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新O2OMarketing订单状态成功[OrderID={0}].", OrderID) });
                            //    //更新阿拉丁的订单状态
                            //    JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatus aldChangeOrder = new data.DataOnlineShoppingHandler.ALDChangeOrderStatus();
                            //    if (string.IsNullOrEmpty(orderInfo.vip_no))
                            //        throw new Exception("会员ID不能为空,OrderID:" + OrderID);
                            //    aldChangeOrder.MemberID = new Guid(orderInfo.vip_no);
                            //    aldChangeOrder.SourceOrdersID = OrderID;
                            //    aldChangeOrder.Status = int.Parse(orderInfo.status);
                            //    aldChangeOrder.IsPaid = true;
                            //    JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest aldRequest = new data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest();
                            //    aldRequest.BusinessZoneID = 1;//写死
                            //    aldRequest.Locale = 1;

                            //    aldRequest.UserID = new Guid(orderInfo.vip_no);
                            //    aldRequest.Parameters = aldChangeOrder;
                            //    var url = ConfigurationManager.AppSettings["ALDGatewayURL"];
                            //    var postContent = string.Format("Action=ChangeOrderStatus&ReqContent={0}", aldRequest.ToJSON());
                            //    Loggers.Debug(new DebugLogInfo() { Message = "通知ALD更改状态:" + postContent });
                            //    var strAldRsp = HttpWebClient.DoHttpRequest(url, postContent);
                            //    var aldRsp = strAldRsp.DeserializeJSONTo<JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDResponse>();
                            //    if (!aldRsp.IsSuccess())
                            //    {
                            //        Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新阿拉丁订单状态失败[Request ={0}][Response={1}]", aldRequest.ToJSON(), strAldRsp) });
                            //    }
                            //}
                            #endregion

                            #region 格力推送通知
                            //try
                            //{
                            //    GLServiceOrderBLL glsobll = new GLServiceOrderBLL(loggingSessionInfo);
                            //    if (glsobll.ValidateGree(CustomerID, "cpos_bs_lj"))//先写死
                            //        glsobll.GreePushPaymentOorder(CustomerID, OrderID, loggingSessionInfo);
                            //}
                            //catch (Exception ex)
                            //{
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("付款推送评价师傅链接失败[OrderID={0}].", OrderID) });
                            //}
                            #endregion

                            #region ALD生活服务处理
                            //var rechargeBll = new RechargeStrategyBLL(loggingSessionInfo);
                            //var vipAmountBll = new VipAmountBLL(loggingSessionInfo);
                            //var couponBll = new CouponBLL(loggingSessionInfo);
                            //var vipCouponMappingBll = new VipCouponMappingBLL(loggingSessionInfo);
                            //var unitBll = new UnitBLL(loggingSessionInfo);
                            //DataSet dsOrderInfo = rechargeBll.GetInoutOrderItems(OrderID);
                            //int itemSort = 0;            //商品业务分类
                            //string skuId = string.Empty; //商品SkuId
                            //string vipId = string.Empty; //会员ID
                            //string itemId = string.Empty;//商品ID
                            //string couponId = string.Empty;//优惠券ID
                            //if (dsOrderInfo.Tables[0].Rows.Count > 0)
                            //{
                            //    //if (dsOrderInfo.Tables[0].Rows[0]["ItemSort"] != DBNull.Value && Convert.ToString(dsOrderInfo.Tables[0].Rows[0]["ItemSort"]) != "0")
                            //    itemSort = int.Parse(dsOrderInfo.Tables[0].Rows[0]["ItemSort"].ToString());
                            //    switch (itemSort)
                            //    {
                            //        case 2://充
                            //            #region 充值金额处理

                            //            VipAmountDetailBLL vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);

                            //            List<IWhereCondition> complexCondition = new List<IWhereCondition> { };
                            //            complexCondition.Add(new EqualsCondition() { FieldName = "ObjectId", Value = OrderID });

                            //            var vipAmountDetal = vipAmountDetailBll.Query(complexCondition.ToArray(), null);
                            //            if (vipAmountDetal.Count() == 0)//确认没有多次执行回调
                            //            {
                            //                ////查询
                            //                //RechargeStrategyEntity[] rechargeList = rechargeBll.Query(complexCondition.ToArray(), lstOrder.ToArray());

                            //                skuId = dsOrderInfo.Tables[0].Rows[0]["SkuId"].ToString();
                            //                //RechargeStrategyEntity rechargeEntity = rechargeBll.GetByID(skuId);
                            //                DataSet dsSkuPirce = unitBll.GetSkuPirce(skuId);
                            //                decimal salePrice = 0;//购买金额
                            //                decimal returnCash = 0;//奖励金额
                            //                if (dsSkuPirce.Tables[0].Rows.Count > 0)
                            //                {
                            //                    salePrice = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["SalesPrice"].ToString());
                            //                    returnCash = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["ReturnCash"].ToString());
                            //                    InoutService server = new InoutService(loggingSessionInfo);
                            //                    #region 充值金额
                            //                    var tran = server.GetTran();
                            //                    using (tran.Connection)//事物
                            //                    {
                            //                        try
                            //                        {
                            //                            //充值金额
                            //                            vipAmountBll.AddVipEndAmount(UserID, salePrice, tran, "4", OrderID, loggingSessionInfo);//4=充值
                            //                            tran.Commit();
                            //                        }
                            //                        catch (Exception)
                            //                        {
                            //                            tran.Rollback();
                            //                            throw;
                            //                        }
                            //                    }
                            //                    #endregion

                            //                    #region 奖励金额
                            //                    var tran2 = server.GetTran();
                            //                    using (tran2.Connection)//事物
                            //                    {
                            //                        try
                            //                        {
                            //                            //奖励金额
                            //                            vipAmountBll.AddVipEndAmount(UserID, returnCash, tran2, "6", OrderID, loggingSessionInfo);//6=奖励金额
                            //                            tran2.Commit();
                            //                        }
                            //                        catch (Exception)
                            //                        {
                            //                            tran2.Rollback();
                            //                            throw;
                            //                        }
                            //                    }
                            //                    #endregion
                            //                }
                            //            }
                            //            #endregion
                            //            break;
                            //        case 3://券
                            //            #region 券类商品绑定到会员
                            //            itemId = dsOrderInfo.Tables[0].Rows[0]["ItemId"].ToString();
                            //            vipId = dsOrderInfo.Tables[0].Rows[0]["VipId"].ToString();
                            //            couponId = couponBll.GetCouponByItemId(itemId);
                            //            if (!string.IsNullOrEmpty(couponId))
                            //            {
                            //                VipCouponMappingEntity coupon = new VipCouponMappingEntity
                            //                {
                            //                    VIPID = vipId,
                            //                    CouponID = couponId,
                            //                };
                            //                vipCouponMappingBll.Create(coupon);
                            //            }
                            //            #endregion
                            //            break;
                            //        default:
                            //            break;
                            //    }
                            //}

                            #endregion

                            #region 订单与分润关系处理 add by Henry 2014-10-10
                            //var orderSubBll = new OrderOrderSubRunObjectMappingBLL(loggingSessionInfo);
                            //dynamic o = orderSubBll.SetOrderSub(CustomerID, OrderID);
                            //Type t = o.GetType();
                            //var Desc = t.GetProperty("Desc").GetValue(o, null).ToString();
                            //var IsSuccess = t.GetProperty("IsSuccess").GetValue(o, null).ToString();
                            //if (int.Parse(IsSuccess.ToString()) == 0) //失败
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("订单与分润关系处理失败:{0}", Desc) });
                            #endregion

                            CustomerBasicSettingBLL customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
                            string AfterPaySetStock = customerBasicSettingBll.GetSettingValueByCode("AfterPaySetStock");
                            if (AfterPaySetStock == "1")
                            {
                                var inoutServiceBLL = new InoutService(loggingSessionInfo);
                                var inoutDetailList = inoutServiceBLL.GetInoutDetailInfoByOrderId(OrderID);
                                inoutBll.SetStock(OrderID, inoutDetailList, 1, loggingSessionInfo);
                            }
                            ///超级分销商订单入队列
                            if (inoutInfo.data_from_id == "35" || inoutInfo.data_from_id == "36")
                            {
                                BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL bllSuperRetailTraderOrder = new BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL();
                                bllSuperRetailTraderOrder.SetRedisToSuperRetailTraderOrder(loggingSessionInfo, inoutInfo);
                            }

                            //购卡
                            if (!string.IsNullOrEmpty(inoutInfo.Field17) && !string.IsNullOrEmpty(inoutInfo.Field18))
                            {
                                //更新订单状态
                                inoutInfo             = inoutBll.GetByID(OrderID);
                                inoutInfo.Field7      = "700";
                                inoutInfo.status      = "700";
                                inoutInfo.status_desc = "已完成";
                                inoutInfo.Field10     = "已完成";
                                inoutBll.Update(inoutInfo);
                                //会员卡升级
                                vipCardVipMappingBll.BindVirtualItem(vipInfo.VIPID, vipInfo.VipCode, inoutInfo.sales_unit_id, Convert.ToInt32(inoutInfo.Field18), orderId: inoutInfo.order_id);

                                //分润计算
                                RedisSalesVipCardOrderBLL redisSalesVipCardOrderBll = new RedisSalesVipCardOrderBLL();
                                redisSalesVipCardOrderBll.SetRedisSalesVipCardOrder(loggingSessionInfo, inoutInfo);

                                //售卡处理积分、返现、佣金[完成订单]
                                new SendOrderRewardMsgBLL().OrderReward(inoutInfo, loggingSessionInfo, null);//存入到缓存
                            }
                            else
                            {
                                //订单入队列
                                RedisCalculateVipConsumeForUpgrade redisCalculateVipConsumeForUpgrade = new RedisCalculateVipConsumeForUpgrade();
                                redisCalculateVipConsumeForUpgrade.SetVipConsumeForUpgradeList(loggingSessionInfo, inoutInfo);
                            }

                            // add by liangx 2016-09-27 获取订单中的虚拟商品 start
                            CouponTypeBLL            couponTypeBLL            = new CouponTypeBLL(loggingSessionInfo);
                            RedisVipMappingCouponBLL redisVipMappingCouponBLL = new RedisVipMappingCouponBLL();

                            var couponTypes = couponTypeBLL.GetVirtualItemCouponTypes(inoutInfo.order_id);

                            if (couponTypes.Any())
                            {
                                redisVipMappingCouponBLL.SetVipMappingCoupon(couponTypes, "", couponTypes.FirstOrDefault().VipId, "PayVirtualItem");
                            }

                            // add by liangx 2016-09-27 获取订单中的虚拟商品 end

                            //获取门店信息
                            t_unitEntity unitInfo = null;
                            if (!string.IsNullOrEmpty(inoutInfo.sales_unit_id))
                            {
                                unitInfo = unitBLL.GetByID(inoutInfo.sales_unit_id);
                            }
                            //入支付明细表
                            var paymentDetail = new T_Payment_detailEntity()
                            {
                                Payment_Id        = Guid.NewGuid().ToString(),
                                Inout_Id          = inoutInfo.order_id,
                                UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                Price             = inoutInfo.actual_amount,
                                Total_Amount      = inoutInfo.total_amount,
                                Pay_Points        = inoutInfo.pay_points,
                                CustomerId        = loggingSessionInfo.ClientID
                            };
                            paymentDetailBll.Create(paymentDetail);

                            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                            };
                            complexCondition.Add(new EqualsCondition()
                            {
                                FieldName = "Inout_Id", Value = inoutInfo.order_id
                            });
                            var paymentDetailList = paymentDetailBll.Query(complexCondition.ToArray(), null);

                            try
                            {
                                var msgRabbitMQ = new EventContract
                                {
                                    Operation  = OptEnum.Create,
                                    EntityType = EntityTypeEnum.Order,
                                    Id         = inoutInfo.order_id
                                };
                                var service = new EventService();
                                service.PublishMsg(msgRabbitMQ);

                                foreach (var detail in paymentDetailList)
                                {
                                    var paymentMQ = new EventContract
                                    {
                                        Operation  = OptEnum.Create,
                                        EntityType = EntityTypeEnum.OrderPayment,
                                        Id         = detail.Payment_Id
                                    };
                                    service.PublishMsg(paymentMQ);
                                }
                            }
                            catch (Exception)
                            {
                                throw new Exception("RabbitMQ Error");
                            }
                        }
                        else//充值订单
                        {
                            var rechargeOrderBll   = new RechargeOrderBLL(loggingSessionInfo);
                            var vipamountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);
                            var rechargeOrderInfo  = rechargeOrderBll.GetByID(OrderID);
                            if (rechargeOrderInfo != null)
                            {
                                //获取门店信息
                                t_unitEntity unitInfo = null;
                                if (!string.IsNullOrEmpty(rechargeOrderInfo.UnitId))
                                {
                                    unitInfo = unitBLL.GetByID(rechargeOrderInfo.UnitId);
                                }
                                //充值
                                rechargeOrderBll.Recharge(rechargeOrderInfo, vipInfo, unitInfo, tPaymentType.Payment_Type_Id);
                                //入支付明细表
                                var paymentDetail = new T_Payment_detailEntity()
                                {
                                    Payment_Id        = Guid.NewGuid().ToString(),
                                    Inout_Id          = rechargeOrderInfo.OrderID.ToString(),
                                    UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                    Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                    Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                    Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                    Price             = rechargeOrderInfo.ActuallyPaid,
                                    Total_Amount      = rechargeOrderInfo.TotalAmount,
                                    Pay_Points        = rechargeOrderInfo.PayPoints,
                                    CustomerId        = loggingSessionInfo.ClientID
                                };
                                paymentDetailBll.Create(paymentDetail);
                            }
                            else
                            {
                                var receiveAmountOrderBll    = new ReceiveAmountOrderBLL(loggingSessionInfo);
                                var receiveAmountOrderEntity = receiveAmountOrderBll.GetByID(OrderID);



                                //更新订单状态
                                if (receiveAmountOrderEntity != null)
                                {
                                    VipIntegralBLL vipIntegralBll = new VipIntegralBLL(loggingSessionInfo);
                                    //更新订单
                                    receiveAmountOrderEntity.PayStatus = "10";
                                    // Bear
                                    //receiveAmountOrderEntity.PayTypeId = tPaymentTypeCustomerMappingEntity.PaymentTypeID;
                                    receiveAmountOrderEntity.PayTypeId    = tPaymentType.Payment_Type_Id;
                                    receiveAmountOrderEntity.PayDatetTime = DateTime.Now;
                                    receiveAmountOrderBll.Update(receiveAmountOrderEntity);

                                    //获取门店信息
                                    t_unitEntity unitInfo = null;
                                    if (!string.IsNullOrEmpty(receiveAmountOrderEntity.ServiceUnitId))
                                    {
                                        unitInfo = unitBLL.GetByID(receiveAmountOrderEntity.ServiceUnitId);
                                    }


                                    //使用过积分,处理积分
                                    if (receiveAmountOrderEntity.PayPoints != 0 && receiveAmountOrderEntity.PayPoints != null)
                                    {
                                        string sourceId       = "20"; //积分抵扣
                                        var    IntegralDetail = new VipIntegralDetailEntity()
                                        {
                                            Integral         = -Convert.ToInt32(receiveAmountOrderEntity.PayPoints),
                                            IntegralSourceID = sourceId,
                                            ObjectId         = receiveAmountOrderEntity.OrderId.ToString()
                                        };
                                        if (IntegralDetail.Integral != 0)
                                        {
                                            //变动前积分
                                            string OldIntegral = (vipInfo.Integration ?? 0).ToString();
                                            //变动积分
                                            string ChangeIntegral      = (IntegralDetail.Integral ?? 0).ToString();
                                            var    vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, loggingSessionInfo);
                                            //发送微信积分变动通知模板消息
                                            if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                                            {
                                                var CommonBLL = new CommonBLL();
                                                CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo);
                                            }
                                        }
                                    }
                                    //if (receiveAmountOrderEntity.CouponUsePay != 0 || receiveAmountOrderEntity.CouponUsePay != null)
                                    //{
                                    //    //更新使用记录
                                    //    var couponUseBll = new CouponUseBLL(loggingSessionInfo);
                                    //    var couponUseEntity = new CouponUseEntity()
                                    //    {
                                    //        CouponUseID = Guid.NewGuid(),
                                    //        CouponID = rp.CouponId,
                                    //        VipID = vipInfo.VIPID,
                                    //        UnitID = rp.UnitId,
                                    //        OrderID = orderId.ToString(),
                                    //        Comment = "商城使用电子券",
                                    //        CustomerID = CurrentUserInfo.ClientID,
                                    //        CreateBy = CurrentUserInfo.UserID,
                                    //        CreateTime = DateTime.Now,
                                    //        LastUpdateBy = CurrentUserInfo.UserID,
                                    //        LastUpdateTime = DateTime.Now,
                                    //        IsDelete = 0
                                    //    };
                                    //    couponUseBll.Create(couponUseEntity);

                                    //    var couponBll = new CouponBLL(CurrentUserInfo);
                                    //    var couponEntity = couponBll.GetByID(rp.CouponId);

                                    //    //更新CouponType数量
                                    //    var conponTypeBll = new CouponTypeBLL(CurrentUserInfo);
                                    //    var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault();
                                    //    conponTypeEntity.IsVoucher += 1;
                                    //    conponTypeBll.Update(conponTypeEntity);

                                    //    //停用该优惠券
                                    //    couponEntity.Status = 1;
                                    //    couponBll.Update(couponEntity);
                                    //}

                                    //处理余额
                                    if (receiveAmountOrderEntity.AmountAcctPay != null && receiveAmountOrderEntity.AmountAcctPay != 0)
                                    {
                                        var vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);

                                        var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity()
                                        {
                                            VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
                                        }, null).FirstOrDefault();
                                        if (vipAmountEntity != null)
                                        {
                                            var detailInfo = new VipAmountDetailEntity()
                                            {
                                                Amount         = -receiveAmountOrderEntity.AmountAcctPay,
                                                AmountSourceId = "1",
                                                ObjectId       = receiveAmountOrderEntity.OrderId.ToString()
                                            };
                                            var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, loggingSessionInfo);
                                            if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                                            {//发送微信账户余额变动模板消息
                                                var CommonBLL = new CommonBLL();
                                                CommonBLL.BalanceChangedMessage(receiveAmountOrderEntity.OrderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                            }
                                        }
                                    }


                                    //收款订单积分奖励

                                    vipIntegralBll.OrderReward(receiveAmountOrderEntity, null);


                                    var paymentDetail = new T_Payment_detailEntity()
                                    {
                                        Payment_Id        = Guid.NewGuid().ToString(),
                                        Inout_Id          = receiveAmountOrderEntity.OrderId.ToString(),
                                        UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                        Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                        Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                        Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                        Price             = receiveAmountOrderEntity.TransAmount,
                                        Total_Amount      = receiveAmountOrderEntity.TotalAmount,
                                        Pay_Points        = receiveAmountOrderEntity.PayPoints,
                                        CustomerId        = loggingSessionInfo.ClientID
                                    };
                                    paymentDetailBll.Create(paymentDetail);
                                }
                            }
                        }
                        context.Response.Write("SUCCESS");
                    }
                }
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                context.Response.Write("ERROR:" + ex.Message);
            }
        }