Beispiel #1
0
        /// <summary>
        /// 订单合法性验证
        /// </summary>
        /// <UpdateBy>hulingbo</UpdateBy>
        /// <UpdateTime>20150515</UpdateTime>
        /// <param name="model"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        ResultModel <BusiOrderResultModel> Verification(BussinessOrderInfoPM model, out order order)
        {
            bool isOneKeyPubOrder         = false;
            BussinessStatusModel buStatus = iBusinessProvider.GetUserStatus(model.userId);

            if (buStatus != null && buStatus.OneKeyPubOrder == 1)
            {
                isOneKeyPubOrder = true;
            }

            order = null;
            var version = model.Version;

            if (string.IsNullOrWhiteSpace(version)) //版本号
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.NoVersion));
            }
            //if (!isOneKeyPubOrder && !StringHelper.CheckPhone(model.recevicePhone))
            //{
            //    return ResultModel<BusiOrderResultModel>.Conclude(PubOrderStatus.RecevicePhoneErr);
            //}
            if (!isOneKeyPubOrder && string.IsNullOrEmpty(model.recevicePhone))//手机号
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.RecevicePhoneIsNULL));
            }
            if (!isOneKeyPubOrder && string.IsNullOrEmpty(model.receviceAddress))
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.ReceviceAddressIsNULL));
            }

            if (!iBusinessProvider.HaveQualification(model.userId))//验证该商户有无发布订单资格
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.HadCancelQualification));
            }
            int orderChileCount = model.listOrderChlid.Count;

            if (orderChileCount >= 16 || orderChileCount <= 0)
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.OrderCountError));
            }
            decimal amount = 0;

            for (int i = 0; i < orderChileCount; i++)//子订单价格
            {
                if (model.listOrderChlid[i].GoodPrice < 5m)
                {
                    return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.AmountLessThanTen));
                }
                if (model.listOrderChlid[i].GoodPrice > 1000m)
                {
                    return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.AmountMoreThanFiveThousand));
                }
                amount += model.listOrderChlid[i].GoodPrice;
            }
            if (model.Amount != amount)
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.AmountIsNotEqual));
            }

            if (model.OrderCount <= 0 || model.OrderCount > 15) //判断录入订单数量是否符合要求
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.OrderCountError));
            }
            if (model.OrderCount != model.listOrderChlid.Count)//主订单与子订单数量
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.CountIsNotEqual));
            }
            BusListResultModel business = null;

            //= iBusinessProvider.GetBusiness(model.userId)

            order = iOrderProvider.TranslateOrder(model, out business);
            if (order.CommissionType == OrderCommissionType.FixedRatio.GetHashCode() && order.BusinessCommission < 10m) //商户结算比例不能小于10
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.BusiSettlementRatioError));
            }

            if (business == null)                                                                   //如果商户不允许可透支发单,验证余额是否满足结算费用,如果不满足,提示:“您的余额不足,请及时充值!”
            {
                return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.BusinessEmpty)); //未取到商户信息
            }
            if (buStatus.IsAllowOverdraft == 0)                                                     //0不允许透支
            {
                if (business.BalancePrice < order.SettleMoney)
                {
                    return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.BusiBalancePriceLack));
                }
            }
            return(ResultModel <BusiOrderResultModel> .Conclude(PubOrderStatus.VerificationSuccess));
        }