コード例 #1
0
        /// <summary>
        /// 异步回调后-->验证支付单状态-->如果正常,更新订单状态
        /// 多张订单在外层循环,这里只处理单订单
        /// </summary>
        /// <param name="mod">订单模型</param>
        /// <param name="paylogMod">订单支付日志模型</param>
        public static void FinalStep(M_Payment pinfo, M_OrderList mod, M_Order_PayLog paylogMod)
        {
            B_Order_PayLog paylogBll = new B_Order_PayLog();
            B_User         buser     = new B_User();

            //订单已处理,避免重复(如已处理过,则继续处理下一张订单)
            if (mod.OrderStatus >= 99)
            {
                ZLLog.L(Model.ZLEnum.Log.safe, new M_Log()
                {
                    Action  = "支付回调异常,订单状态已为99",
                    Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo
                });
                return;
            }
            //已经收到钱了,所以先执行(如多订单,则该值需要看支付单)
            orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + pinfo.MoneyTrue, mod.id);
            if (mod.Ordertype == (int)M_OrderList.OrderEnum.Domain)//域名订单
            {
                orderBll.UpOrderinfo("OrderStatus=1,PaymentNo='" + pinfo.PayNo + "'", mod.id);
                //Response.Redirect("~/Plugins/Domain/DomReg2.aspx?OrderNo=" + mod.OrderNo);
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.IDC)//IDC服务
            {
                B_Order_IDC idcBll = new B_Order_IDC();
                orderBll.FinishOrder(mod.id, pinfo);
                idcBll.UpdateEndTimeByNo(mod.OrderNo);
            }
            else if ((mod.Ordertype == (int)M_OrderList.OrderEnum.IDCRen))//IDC服务续费
            {
                B_Order_IDC idcBll = new B_Order_IDC();
                orderBll.FinishOrder(mod.id, pinfo);
                idcBll.RennewTime(mod);
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Purse)//余额充值,不支持银币
            {
                buser.ChangeVirtualMoney(mod.Userid, new M_UserExpHis()
                {
                    score     = mod.Ordersamount,
                    ScoreType = (int)M_UserExpHis.SType.Purse,
                    detail    = "余额充值,订单号:" + mod.OrderNo
                });
                orderBll.FinishOrder(mod.id, pinfo);                    //成功的订单
            }
            else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Cloud) //虚拟商品订单
            {
                orderBll.FinishOrder(mod.id, pinfo);
            }
            else//其他旅游订单等,只更新状态
            {
                orderBll.FinishOrder(mod.id, pinfo);//成功的订单
            }
            //-------支付成功处理,快照并写入日志
            SaveSnapShot(mod);
            paylogMod.Remind   += "订单" + mod.OrderNo + "购买生效";
            paylogMod.OrderID   = mod.id;
            paylogMod.PayMoney  = mod.Ordersamount;
            paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;//外部指定
            paylogMod.PayPlatID = pinfo.PayPlatID;
            paylogBll.insert(paylogMod);
            //------商品是否赠送积分
            {
                DataTable prodt = DBCenter.JoinQuery("A.ProID,B.PointVal", "ZL_CartPro", "ZL_Commodities", "A.ProID=B.ID", "A.OrderListID=" + mod.id);
                foreach (DataRow dr in prodt.Rows)
                {
                    double point = DataConvert.CDouble(dr["PointVal"]);
                    if (point > 0)
                    {
                        buser.AddMoney(mod.Userid, point, M_UserExpHis.SType.Point, "购买商品[" + dr["ProID"] + "],赠送积分");
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// 异步回调后-->验证支付单状态-->如果正常,更新订单状态
 /// 多张订单在外层循环,这里只处理单订单
 /// </summary>
 /// <param name="mod">订单模型</param>
 /// <param name="paylogMod">订单支付日志模型</param>
 public static void FinalStep(M_Payment pinfo, M_OrderList mod, M_Order_PayLog paylogMod)
 {
     //B_Order_PayLog paylogBll = new B_Order_PayLog();
     B_PayPlat platBll = new B_PayPlat();
     B_Payment payBll  = new B_Payment();
     B_User    buser   = new B_User();
     //[*]特殊处理,预付与尾款逻辑
     {
         #region
         if (pinfo.PayType == (int)M_OrderList.PayTypeEnum.PrePay)
         {
             M_PrePayinfo preInfo = new M_PrePayinfo(pinfo.PrePayInfo);
             preInfo.money_pre_payed = pinfo.MoneyTrue;
             preInfo.pre_payno       = pinfo.PayNo;
             preInfo.pre_payMethod   = platBll.GetPayPlatName(pinfo);
             pinfo.PrePayInfo        = JsonConvert.SerializeObject(preInfo);
             DBCenter.UpdateSQL(pinfo.TbName, "PrePayInfo=@preInfo", "PayMentID=" + pinfo.PaymentID,
                                new List <SqlParameter>()
             {
                 new SqlParameter("preInfo", pinfo.PrePayInfo)
             });
         }
         else if (pinfo.PayType == (int)M_OrderList.PayTypeEnum.AfterPay)
         {
             try
             {
                 M_OrderList realOrder = orderBll.SelModelByOrderNo(mod.Ordermessage);
                 M_Payment   preMod    = payBll.SelModelByPayNo(realOrder.PaymentNo);
                 //修改订单与支付单信息
                 M_PrePayinfo preInfo = new M_PrePayinfo(preMod.PrePayInfo);
                 preInfo.money_after_payed = pinfo.MoneyTrue;
                 preInfo.status            = (int)ZLEnum.ConStatus.Audited;
                 preInfo.after_payno       = pinfo.PayNo;
                 preInfo.after_payMethod   = platBll.GetPayPlatName(pinfo);
                 //修改二张订单与二张支付单的状态
                 realOrder.IsCount            = true;
                 realOrder.Ordersamount      += pinfo.MoneyTrue;
                 realOrder.Receivablesamount += pinfo.MoneyTrue;
                 orderBll.UpdateByID(realOrder);
                 mod.OrderStatus   = 99;
                 mod.Paymentstatus = 1;
                 mod.PaymentNo     = pinfo.PayNo;
                 orderBll.UpdateByID(mod);
                 DBCenter.UpdateSQL(preMod.TbName, "PrePayInfo=@preInfo", "PayMentID=" + preMod.PaymentID,
                                    new List <SqlParameter>()
                 {
                     new SqlParameter("preInfo", JsonConvert.SerializeObject(preInfo))
                 });
                 return;
             }
             catch (Exception ex)
             {
                 ZLLog.L(Model.ZLEnum.Log.pay, new M_Log()
                 {
                     Action  = "支付尾款异常",
                     Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo + ",原因:" + ex.Message
                 });
                 return;
             }
         }
         #endregion
     }
     //订单已处理,避免重复(如已处理过,则继续处理下一张订单)
     if (mod.OrderStatus >= 99)
     {
         ZLLog.L(Model.ZLEnum.Log.pay, new M_Log()
         {
             Action  = "支付回调异常,订单状态已为99",
             Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo
         });
         return;
     }
     //已经收到钱了,所以先执行(如多订单,则为订单金额)
     if (mod.Receivablesamount <= 0)
     {
         //DD201701112113293112618,DD201701112113293754790
         int orderNum = pinfo.PaymentNum.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length;
         if (orderNum == 1)
         {
             mod.Receivablesamount = pinfo.MoneyTrue;
         }
         else
         {
             //订单需要改进,支持优惠后的金额等,不能只以支付单中的为准,每张订单需要计算出自己的优惠额与积分支付额
             mod.Receivablesamount = mod.Ordersamount;
         }
     }
     orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + mod.Receivablesamount, mod.id);
     //if (mod.Ordertype == (int)M_OrderList.OrderEnum.Domain)//域名订单
     //{
     //    orderBll.UpOrderinfo("OrderStatus=1,PaymentNo='" + pinfo.PayNo + "'", mod.id);
     //    //Response.Redirect("~/Plugins/Domain/DomReg2?OrderNo=" + mod.OrderNo);
     //}
     //else if (mod.Ordertype == (int)M_OrderList.OrderEnum.IDC)//IDC服务
     //{
     //    B_Order_IDC idcBll = new B_Order_IDC();
     //    orderBll.FinishOrder(mod.id, pinfo);
     //    idcBll.UpdateEndTimeByNo(mod.OrderNo);
     //}
     //else if ((mod.Ordertype == (int)M_OrderList.OrderEnum.IDCRen))//IDC服务续费
     //{
     //    B_Order_IDC idcBll = new B_Order_IDC();
     //    orderBll.FinishOrder(mod.id, pinfo);
     //    idcBll.RennewTime(mod);
     //}
     if (mod.Ordertype == (int)M_OrderList.OrderEnum.Purse)//余额充值,不支持银币
     {
         buser.AddMoney(mod.Userid, mod.Ordersamount,
                        M_UserExpHis.SType.Purse, "余额充值,订单号:" + mod.OrderNo);
         //检测是否采用了充值赠送规则
         if (DataConvert.CLng(mod.Money_code) > 0)
         {
             B_Shop_MoneyRegular regBll = new B_Shop_MoneyRegular();
             M_Shop_MoneyRegular regMod = regBll.SelReturnModel(DataConvert.CLng(mod.Money_code));
             if (regMod.Purse > 0)
             {
                 buser.AddMoney(mod.Userid, regMod.Purse,
                                M_UserExpHis.SType.Purse, "余额充值--余额赠送,订单号:" + mod.OrderNo);
             }
             if (regMod.Sicon > 0)
             {
                 buser.AddMoney(mod.Userid, regMod.Sicon,
                                M_UserExpHis.SType.SIcon, "余额充值--银币赠送,订单号:" + mod.OrderNo);
             }
             if (regMod.Point > 0)
             {
                 buser.AddMoney(mod.Userid, regMod.Point,
                                M_UserExpHis.SType.Point, "余额充值--积分赠送,订单号:" + mod.OrderNo);
             }
         }
         orderBll.FinishOrder(mod.id, pinfo);                    //成功的订单
     }
     else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Cloud) //虚拟商品订单
     {
         orderBll.FinishOrder(mod.id, pinfo);
     }
     else//其他旅游订单等,只更新状态
     {
         orderBll.FinishOrder(mod.id, pinfo);//成功的订单
     }
     //-------支付成功处理,快照并写入日志
     SaveSnapShot(mod);
     //paylogMod.Remind += "订单" + mod.OrderNo + "购买生效";
     //paylogMod.UserID = mod.Userid;
     //paylogMod.OrderID = mod.id;
     //paylogMod.PayMoney = mod.Ordersamount;
     //paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;//外部指定
     //paylogMod.PayPlatID = pinfo.PayPlatID;
     //paylogBll.insert(paylogMod);
     //------商品是否赠送积分
     //{//好酒多积分不直接入账
     //    DataTable prodt = DBCenter.JoinQuery("A.ProID,A.Pronum,B.PointVal", "ZL_CartPro", "ZL_Commodities", "A.ProID=B.ID", "A.OrderListID=" + mod.id);
     //    foreach (DataRow dr in prodt.Rows)
     //    {
     //        double point = DataConvert.CDouble(dr["PointVal"])*Convert.ToInt32(dr["Pronum"]);
     //        if (point > 0)
     //        {
     //            buser.AddMoney(mod.Userid, point, M_UserExpHis.SType.Point, "购买商品[" + dr["ProID"] + "],赠送积分");
     //        }
     //    }
     //}
     if (OrderFinish_Event != null)
     {
         OrderFinish_Event(mod, pinfo);
     }
 }