/// <summary> /// api获取当前门店核销过的电子券 /// </summary> protected override GetApiCouponUserListRD ProcessRequest(DTO.Base.APIRequest <GetCouponUseRP> pRequest) { var rd = new GetApiCouponUserListRD(); var para = pRequest.Parameters; var CouponUseBLL = new CouponUseBLL(CurrentUserInfo); var VipBLL = new VipBLL(CurrentUserInfo); var CouponBLL = new CouponBLL(CurrentUserInfo); var UserBLL = new T_UserBLL(CurrentUserInfo); //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; #region 门店条件处理 string UnitId = ""; if (CurrentUserInfo.CurrentUserRole != null) { if (!string.IsNullOrWhiteSpace(CurrentUserInfo.CurrentUserRole.UnitId)) { UnitId = CurrentUserInfo.CurrentUserRole.UnitId; } } if (!string.IsNullOrWhiteSpace(UnitId)) { complexCondition.Add(new EqualsCondition() { FieldName = "UnitID", Value = CurrentUserInfo.CurrentUserRole.UnitId }); } else { return(rd); } #endregion //排序参数 List <OrderBy> lstOrder = new List <OrderBy> { }; lstOrder.Add(new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc }); var Result = CouponUseBLL.PagedQuery(complexCondition.ToArray(), lstOrder.ToArray(), para.pageSize, para.pageIndex); rd.TotalPageCount = Result.PageCount; rd.TotalCount = Result.RowCount; rd.ApiCouponDataList = Result.Entities.Select(t => new CouponUserData() { VipID = t.VipID, VipName = "", CreateTime = t.CreateTime.ToString(), CouponID = t.CouponID, CouponName = "", CouponCode = "", CreateBy = t.CreateBy }).ToList(); foreach (var item in rd.ApiCouponDataList) { //会员名称 var VipData = VipBLL.GetByID(item.VipID); if (VipData != null) { item.VipName = VipData.VipName ?? ""; item.HeadImgUrl = VipData.HeadImgUrl ?? ""; } //券名称,券号 var CouponData = CouponBLL.GetByID(item.CouponID); if (CouponData != null) { item.CouponName = CouponData.CouponName ?? ""; item.CouponCode = CouponData.CouponCode ?? ""; } //员工名称 var UserData = UserBLL.GetByID(item.CreateBy); if (UserData != null) { item.CreateByName = UserData.user_name ?? ""; } } return(rd); }
protected override GetReceiveAmountOrderRD ProcessRequest(APIRequest <GetReceiveAmountOrderRP> pRequest) { GetReceiveAmountOrderRP rp = pRequest.Parameters; GetReceiveAmountOrderRD rd = new GetReceiveAmountOrderRD(); ReceiveAmountOrderBLL receiveAmountOrderBll = new ReceiveAmountOrderBLL(CurrentUserInfo); var couponUseBll = new CouponUseBLL(CurrentUserInfo); var couponBll = new CouponBLL(CurrentUserInfo); var paymentBll = new T_Payment_TypeBLL(CurrentUserInfo); //收款业务 if (rp.Type == 1) { if (!string.IsNullOrEmpty(rp.TimeStamp)) { var receiveAmountOrderEntity = receiveAmountOrderBll.QueryByEntity(new ReceiveAmountOrderEntity() { TimeStamp = rp.TimeStamp }, null).FirstOrDefault(); if (receiveAmountOrderEntity != null) { rd.TotalAmount = receiveAmountOrderEntity.TotalAmount ?? 0; rd.PayPoints = receiveAmountOrderEntity.PayPoints ?? 0; rd.AmountAcctPay = receiveAmountOrderEntity.AmountAcctPay ?? 0; rd.PayStatus = receiveAmountOrderEntity.PayStatus; rd.VipId = receiveAmountOrderEntity.VipId; rd.TransAmount = (receiveAmountOrderEntity.TransAmount ?? 0) - (receiveAmountOrderEntity.AmountAcctPay ?? 0); rd.OrderNo = receiveAmountOrderEntity.OrderNo; rd.vipDiscount = receiveAmountOrderEntity.VipDiscount ?? 100; //优惠券使用 var couponUseEntity = couponUseBll.QueryByEntity(new CouponUseEntity() { OrderID = receiveAmountOrderEntity.OrderId.ToString() }, null).FirstOrDefault(); if (couponUseEntity != null) { var couponEntity = couponBll.GetByID(couponUseEntity.CouponID); if (couponEntity != null) { rd.CouponName = couponEntity.CoupnName; var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); rd.CouponAmount = couponTypeEntity.ParValue ?? 0; } } //支付方式 var paymentEntity = paymentBll.GetByID(receiveAmountOrderEntity.PayTypeId); if (paymentEntity != null) { rd.PayTypeName = paymentEntity.Payment_Type_Name; } } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } else { //收款订单 if (!string.IsNullOrEmpty(rp.OrderId)) { var receiveAmountOrderEntity = receiveAmountOrderBll.GetByID(rp.OrderId); rd.TotalAmount = receiveAmountOrderEntity.TotalAmount ?? 0; rd.PayPoints = receiveAmountOrderEntity.PayPoints ?? 0; rd.AmountAcctPay = receiveAmountOrderEntity.AmountAcctPay ?? 0; rd.PayStatus = receiveAmountOrderEntity.PayStatus; rd.TransAmount = (receiveAmountOrderEntity.TransAmount ?? 0) - (receiveAmountOrderEntity.AmountAcctPay ?? 0); rd.OrderNo = receiveAmountOrderEntity.OrderNo; rd.vipDiscount = receiveAmountOrderEntity.VipDiscount ?? 100; //优惠券使用 var couponUseEntity = couponUseBll.QueryByEntity(new CouponUseEntity() { OrderID = rp.OrderId }, null).FirstOrDefault(); if (couponUseEntity != null) { var couponEntity = couponBll.GetByID(couponUseEntity.CouponID); if (couponEntity != null) { rd.CouponName = couponEntity.CoupnName; var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); rd.CouponAmount = couponTypeEntity.ParValue ?? 0; } } //支付方式 var paymentEntity = paymentBll.GetByID(receiveAmountOrderEntity.PayTypeId); if (paymentEntity != null) { rd.PayTypeName = paymentEntity.Payment_Type_Name; } } } } //充值业务 if (rp.Type == 2) { var rechargeOrderBll = new RechargeOrderBLL(CurrentUserInfo); var rechargeOrderEntity = rechargeOrderBll.GetByID(rp.OrderId); if (rechargeOrderEntity != null) { rd.PayStatus = rechargeOrderEntity.Status.ToString(); rd.VipId = rechargeOrderEntity.VipID; rd.ReturnAmount = rechargeOrderEntity.ReturnAmount ?? 0; } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } //订单业务 if (rp.Type == 3) { var inoutBll = new T_InoutBLL(CurrentUserInfo); var inoutEntity = inoutBll.GetByID(rp.OrderId); if (inoutEntity != null) { rd.PayStatus = inoutEntity.Field1; rd.VipId = inoutEntity.vip_no; } else { throw new APIException("没有找到此订单") { ErrorCode = 200 }; } } return(rd); }
protected override SetReceiveAmountOrderRD ProcessRequest(APIRequest <SetReceiveAmountOrderRP> pRequest) { SetReceiveAmountOrderRP rp = pRequest.Parameters; SetReceiveAmountOrderRD rd = new SetReceiveAmountOrderRD(); var receiveAmountOrderBll = new ReceiveAmountOrderBLL(CurrentUserInfo); var sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo); //获取折扣表 var vipBLL = new VipBLL(CurrentUserInfo); var unitBLL = new t_unitBLL(CurrentUserInfo); var vipInfo = vipBLL.GetByID(pRequest.UserID); //获取会员信息 if (vipInfo == null) { throw new APIException("没有会员信息") { ErrorCode = 101 }; } var unitInfo = unitBLL.GetByID(rp.UnitId); if (unitInfo == null) { throw new APIException("没有服务门店信息") { ErrorCode = 101 }; } decimal discountAmount = 0; //抵扣金额汇总 decimal couponAmount = 0; //优惠券抵用金额 decimal endAmount = rp.VipEndAmount; //余额 decimal integralAmount = rp.Integral; //获取订单号 TUnitExpandBLL serviceUnitExpand = new TUnitExpandBLL(CurrentUserInfo); string orderNo = serviceUnitExpand.GetUnitOrderNo(); //折扣 decimal discount = 1; if (rp.VipDiscount > 0) { discount = sysVipCardGradeBLL.GetVipDiscount() / 10;//会员折扣 } decimal tempAmount = Math.Round((discount == 0 ? 1 : discount) * rp.TotalAmount, 2, MidpointRounding.AwayFromZero); Guid orderId = Guid.NewGuid(); //积分处理 if (rp.IntegralFlag == 1) { //加入折扣金额 discountAmount = discountAmount + rp.IntegralAmount; } else { integralAmount = 0; } //使用优惠券 if (rp.CouponFlag == 1) { #region 判断优惠券是否是该会员的 var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo); var vipcouponmappingList = vipcouponMappingBll.QueryByEntity(new VipCouponMappingEntity() { VIPID = vipInfo.VIPID, CouponID = rp.CouponId }, null); if (vipcouponmappingList == null || vipcouponmappingList.Length == 0) { throw new APIException("此张优惠券不是该会员的") { ErrorCode = 103 }; } #endregion #region 判断优惠券是否有效 var couponBll = new CouponBLL(CurrentUserInfo); var couponEntity = couponBll.GetByID(rp.CouponId); if (couponEntity == null) { throw new APIException("无效的优惠券") { ErrorCode = 103 }; } if (couponEntity.Status == 1) { throw new APIException("优惠券已使用") { ErrorCode = 103 }; } if (couponEntity.EndDate < DateTime.Now) { throw new APIException("优惠券已过期") { ErrorCode = 103 }; } var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); if (couponTypeEntity == null) { throw new APIException("无效的优惠券类型") { ErrorCode = 103 }; } #endregion discountAmount = discountAmount + couponTypeEntity.ParValue ?? 0; couponAmount = couponTypeEntity.ParValue ?? 0; //更新使用记录 var couponUseBll = new CouponUseBLL(CurrentUserInfo); 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); //更新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 (rp.VipEndAmountFlag == 1) { var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { //判断该会员账户是否被冻结 if (vipAmountEntity.IsLocking == 1) { throw new APIException("账户已被冻结,请先解冻") { ErrorCode = 103 } } ; //判断该会员的账户余额是否大于本次使用的余额 if (vipAmountEntity.EndAmount < rp.VipEndAmount) { throw new APIException(string.Format("账户余额不足,当前余额为【{0}】", vipAmountEntity.EndAmount)) { ErrorCode = 103 } } ; //所剩余额大于商品价格,扣除余额的数量为商品价格 if (tempAmount < rp.VipEndAmount) { rp.VipEndAmount = endAmount = Convert.ToDecimal(tempAmount); } } } //不使用余额,余额为0 else { endAmount = 0; } //实付金额 decimal transAmount = tempAmount - discountAmount; //支付状态 string payStatus = "0"; //支付时间 DateTime?PayDatetTime = null; //实付金额全是由余额支付,支付状态和支付时间全部更新,积分扣减、余额扣减、优惠券使用 if (transAmount == endAmount || transAmount == 0) { payStatus = "10"; PayDatetTime = DateTime.Now; //处理积分抵扣 if (rp.IntegralFlag == 1) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); string sourceId = "20"; //积分抵扣 var IntegralDetail = new VipIntegralDetailEntity() { Integral = -Convert.ToInt32(rp.Integral), IntegralSourceID = sourceId, ObjectId = 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, CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo); } } } //处理余额抵扣 if (rp.VipEndAmountFlag == 1) { var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { var detailInfo = new VipAmountDetailEntity() { Amount = -rp.VipEndAmount, AmountSourceId = "1", ObjectId = orderId.ToString() }; var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage(orderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo); } } } } //收款订单 ReceiveAmountOrderEntity receiveAmountOrderEntity = new ReceiveAmountOrderEntity() { OrderId = orderId, OrderNo = orderNo, VipId = vipInfo.VIPID, ServiceUnitId = unitInfo.unit_id, ServiceUserId = rp.EmployeeID, TotalAmount = rp.TotalAmount, VipDiscount = discount * 100, TransAmount = transAmount, PayPoints = integralAmount, AmountFromPayPoints = rp.IntegralAmount, CouponUsePay = couponAmount, AmountAcctPay = endAmount, PayStatus = payStatus, TimeStamp = rp.TimeStamp, PayDatetTime = PayDatetTime, CustomerId = CurrentUserInfo.ClientID }; receiveAmountOrderBll.Create(receiveAmountOrderEntity); //订单奖励 if (transAmount == endAmount || transAmount == 0) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); vipIntegralBll.OrderReward(receiveAmountOrderEntity, null); } rd.orderId = orderId.ToString(); return(rd); } } }
//<summary> //Pos订单入库 //</summary> //<param name="pRequest"></param> //<returns></returns> protected override SetPosOrderRD ProcessRequest(APIRequest <SetPosOrderRP> pRequest) { //请求参数 var rp = pRequest.Parameters; //返回参数 var rd = new SetPosOrderRD(); //订单 var inoutBll = new T_InoutBLL(CurrentUserInfo); var inoutDetail = new T_Inout_DetailBLL(CurrentUserInfo); //商品 var itemCategoryBll = new T_Item_CategoryBLL(CurrentUserInfo); var itemBll = new T_ItemBLL(CurrentUserInfo); var porpBll = new T_PropBLL(CurrentUserInfo); var itemSkuPropBll = new T_ItemSkuPropBLL(CurrentUserInfo); var skuBll = new T_SkuBLL(CurrentUserInfo); var skuPriceBll = new T_Sku_PriceBLL(CurrentUserInfo); var skuProperty = new T_Sku_PropertyBLL(CurrentUserInfo); //获取会员信息 var vipBll = new VipBLL(CurrentUserInfo); var vipInfo = vipBll.GetByID(pRequest.UserID); var vipCardVipMappingBll = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBll = new VipCardBLL(CurrentUserInfo); var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipInfo.VIPID, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); string VipCardTypeID = ""; //卡类型Id if (vipCardVipMappingEntity != null) { var vipCardEntity = vipCardBll.GetByID(vipCardVipMappingEntity.VipCardID); VipCardTypeID = vipCardEntity.VipCardTypeID.ToString(); } //员工 var userBll = new T_UserBLL(CurrentUserInfo); //获取门店信息 var unitBll = new t_unitBLL(CurrentUserInfo); t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(rp.UnitCode)) { unitInfo = unitBll.QueryByEntity(new t_unitEntity() { unit_code = rp.UnitCode, customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (unitInfo == null) { throw new APIException("请在正念商户后台录入相应门店") { ErrorCode = 100 }; } } else { throw new APIException("缺少请求参数:门店编码") { ErrorCode = 102 }; } //获取员工信息 T_UserEntity userEntity = null; if (!string.IsNullOrEmpty(rp.MobliePhone)) { userEntity = userBll.QueryByEntity(new T_UserEntity() { user_telephone = rp.MobliePhone, customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); //没有员工,新增默认员工(店员APP) if (userEntity == null) { var roleBll = new T_RoleBLL(CurrentUserInfo); var roleEntity = roleBll.QueryByEntity(new T_RoleEntity() { role_code = "clerkAPP", customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (roleEntity == null) { throw new APIException("请在正念商户后台录入相应角色") { ErrorCode = 100 }; } userEntity = new T_UserEntity(); userEntity.user_telephone = rp.MobliePhone; userEntity.user_code = rp.UserCode; userEntity.user_name = rp.UserCode; userEntity.user_birthday = rp.Birthday; userEntity.user_email = rp.EmailAddress; userEntity.user_address = rp.Address; userEntity.user_postcode = rp.Zip; userBll.AddUser(ref userEntity, unitInfo, roleEntity); } } else { throw new APIException("缺少请求参数:员工手机号") { ErrorCode = 102 }; } //获取会员折扣 var sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo); decimal vipDiscount = sysVipCardGradeBLL.GetVipDiscount() * 10; //订单号 string orderId = BaseService.NewGuidPub(); T_InoutEntity tInoutEntity = new T_InoutEntity(); tInoutEntity.order_id = orderId; tInoutEntity.order_no = rp.OrderNo; //拼接ItemCodes //StringBuilder ItemCodes = new StringBuilder(); //for (int j = 0; j < pRequest.Parameters.OrderDetailList.Count(); j++) //{ // if (j != 0) // { // ItemCodes.Append(","); // } // ItemCodes.Append(string.Format("{0}", pRequest.Parameters.OrderDetailList[j].ItemCode)); //} ////通过itemCodes取出商品价格 //SkuPriceService skuPriceService = new SkuPriceService(CurrentUserInfo); //List<SkuPrice> skuPriceList = skuPriceService.GetPriceListByItemCodes(ItemCodes.ToString(), CurrentUserInfo.ClientID); //if(skuPriceList.Count == 0) //{ // throw new APIException("未找到商品") { ErrorCode = 100 }; //} //订单总金额 decimal totalAmount = rp.TotalAmount; //订单实付金额 decimal ActualAmount = rp.DiscountAmount; //订单折扣后金额 decimal DiscountAmount = rp.DiscountAmount; //订单明细显示顺序 int i = 1; //商品价格重新计算 foreach (var item in pRequest.Parameters.OrderDetailList) { T_ItemEntity itemEntity = null; //商品 T_SkuEntity skuEntity = null; //sku if (!string.IsNullOrEmpty(item.ItemCode)) { itemEntity = itemBll.QueryByEntity(new T_ItemEntity() { item_code = item.ItemCode, CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (itemEntity == null) { if (string.IsNullOrEmpty(item.ItemCategoryCode)) { throw new APIException("缺少参数:商品类别名称") { ErrorCode = 200 }; } itemEntity = new T_ItemEntity(); itemEntity.item_code = item.ItemCode; itemEntity.item_name = item.ItemName; itemBll.AddItem(itemEntity, out skuEntity, item.ItemCategoryName, item.ItemCategoryCode, item.SkuOriginPrice, item.SkuSalesPrice); } else { skuEntity = skuBll.QueryByEntity(new T_SkuEntity() { item_id = itemEntity.item_id }, null).FirstOrDefault(); } } else { throw new APIException("缺少参数:商品编码") { ErrorCode = 300 }; } //订单明细相关处理 T_Inout_DetailBLL inoutDetailBll = new T_Inout_DetailBLL(CurrentUserInfo); T_Inout_DetailEntity inoutDetailEntity = new T_Inout_DetailEntity() { order_detail_id = BaseService.NewGuidPub(), order_id = orderId, //订单Id sku_id = skuEntity.sku_id, //skuId unit_id = unitInfo.unit_id, //门店Id order_qty = item.Qty, //订单qty enter_qty = item.Qty, //实际qty enter_price = item.price, //折扣价 enter_amount = item.price * item.Qty, //折扣价 std_price = item.price, //原价 discount_rate = vipDiscount, //折扣 retail_price = item.price * item.Qty, //零售价 retail_amount = item.price * item.Qty, //零售价 order_detail_status = "1", display_index = i, if_flag = 0 }; inoutDetailBll.Create(inoutDetailEntity); i++; } //优惠券使用 if (!string.IsNullOrEmpty(rp.CouponId)) { #region 判断优惠券是否是该会员的 var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo); var vipcouponmappingList = vipcouponMappingBll.QueryByEntity(new VipCouponMappingEntity() { VIPID = pRequest.UserID, CouponID = rp.CouponId }, null); if (vipcouponmappingList == null || vipcouponmappingList.Length == 0) { throw new APIException("此张优惠券不是该会员的") { ErrorCode = 103 }; } #endregion #region 判断优惠券是否有效 var couponBll = new CouponBLL(CurrentUserInfo); var couponEntity = couponBll.GetByID(rp.CouponId); if (couponEntity == null) { throw new APIException("无效的优惠券") { ErrorCode = 103 }; } if (couponEntity.Status == 1) { throw new APIException("优惠券已使用") { ErrorCode = 103 }; } if (couponEntity.EndDate < DateTime.Now) { throw new APIException("优惠券已过期") { ErrorCode = 103 }; } var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); if (couponTypeEntity == null) { throw new APIException("无效的优惠券类型") { ErrorCode = 103 }; } #endregion #region 优惠券核销 var couponUseBll = new CouponUseBLL(CurrentUserInfo); var couponUseEntity = new CouponUseEntity() { CouponUseID = Guid.NewGuid(), CouponID = rp.CouponId, VipID = pRequest.UserID, UnitID = unitInfo.unit_id, OrderID = orderId, Comment = "商城使用电子券", CustomerID = pRequest.CustomerID, CreateBy = pRequest.UserID, CreateTime = DateTime.Now, LastUpdateBy = pRequest.UserID, LastUpdateTime = DateTime.Now, IsDelete = 0 }; couponUseBll.Create(couponUseEntity); #endregion #region 更新CouponType数量 var conponTypeBll = new CouponTypeBLL(CurrentUserInfo); var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = pRequest.CustomerID }, null).FirstOrDefault(); conponTypeEntity.IsVoucher += 1; conponTypeBll.Update(conponTypeEntity); #endregion #region 更新优惠券状态 couponEntity.Status = 1; couponBll.Update(couponEntity); #endregion ActualAmount -= couponTypeEntity.ParValue ?? 0; } #region 使用积分 //使用积分 if (rp.IntegralFlag == 1) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); string sourceId = "20"; //积分抵扣 var IntegralDetail = new VipIntegralDetailEntity() { Integral = -Convert.ToInt32(rp.Integral), IntegralSourceID = sourceId, ObjectId = orderId }; if (IntegralDetail.Integral != 0) { //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo); } } tInoutEntity.pay_points = rp.Integral; tInoutEntity.receive_points = rp.Integral; ActualAmount -= rp.IntegralAmount; } #endregion #region 余额和返现修改 var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = pRequest.UserID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { //判断该会员账户是否被冻结 if (vipAmountEntity.IsLocking == 1) { throw new APIException("账户已被冻结,请先解冻") { ErrorCode = 103 } } ; //判断该会员的账户余额是否大于本次使用的余额 if (vipAmountEntity.EndAmount < rp.EndAmount) { throw new APIException(string.Format("账户余额不足,当前余额为【{0}】", vipAmountEntity.EndAmount)) { ErrorCode = 103 } } ; } //使用余额 if (rp.EndAmountFlag == 1) { var detailInfo = new VipAmountDetailEntity() { Amount = -rp.EndAmount, AmountSourceId = "1", ObjectId = orderId }; var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage(tInoutEntity.order_no, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo); } tInoutEntity.Field3 = rp.EndAmount.ToString(); } #endregion //订单主表更新 tInoutEntity.VipCardCode = vipInfo.VipCardCode;//会员卡号 tInoutEntity.order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5"; tInoutEntity.order_type_id = "1F0A100C42484454BAEA211D4C14B80F"; tInoutEntity.warehouse_id = "67bb4c12785c42d4912aff7d34606592"; tInoutEntity.data_from_id = ""; tInoutEntity.red_flag = "1"; tInoutEntity.order_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //订单时间 tInoutEntity.create_unit_id = unitInfo.unit_id; //门店 tInoutEntity.unit_id = unitInfo.unit_id; //门店 tInoutEntity.sales_unit_id = unitInfo.unit_id; //门店 tInoutEntity.purchase_unit_id = unitInfo.unit_id; tInoutEntity.sales_user = userEntity.user_id; tInoutEntity.total_amount = totalAmount; //订单金额 tInoutEntity.discount_rate = vipDiscount; //会员折扣 tInoutEntity.actual_amount = ActualAmount; //实付金额 tInoutEntity.total_qty = rp.qty; tInoutEntity.total_retail = totalAmount; //订单金额 tInoutEntity.vip_no = vipInfo.VIPID; tInoutEntity.Field6 = vipInfo.Phone; tInoutEntity.Field14 = vipInfo.VipName; tInoutEntity.Field17 = VipCardTypeID; tInoutEntity.Field12 = DiscountAmount.ToString(); tInoutEntity.Field11 = "知行易"; tInoutEntity.customer_id = CurrentUserInfo.ClientID; tInoutEntity.Field1 = "1"; //支付完成 tInoutEntity.Field7 = "700"; //已完成 tInoutEntity.status = "700"; //已完成 tInoutEntity.status_desc = "已完成"; tInoutEntity.Field10 = "已完成"; rd.Amount = ActualAmount - rp.EndAmount; inoutBll.Create(tInoutEntity); //订单奖励 new SendOrderRewardMsgBLL().OrderReward(tInoutEntity, this.CurrentUserInfo, null);//存入到缓存 rd.orderId = orderId; return(rd); } } }
/// <summary> /// 核销优惠劵 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> private string BestowCoupon(string pRequest) { RespData respData = new RespData(); try { var reqObj = pRequest.DeserializeJSONTo <reqConunbondata>(); if (string.IsNullOrEmpty(reqObj.userId)) { respData.ResultCode = "103"; respData.Message = "登陆用户不能为空"; } if (string.IsNullOrEmpty(reqObj.Parameters.doorID)) { respData.ResultCode = "103"; respData.Message = "此APP版本无法核销,请升级到新版本。"; return(respData.ToJSON()); } var loggingSessionInfo = Default.GetBSLoggingSession(reqObj.customerId, reqObj.userId); var couponUseBll = new CouponUseBLL(loggingSessionInfo); //优惠券使用BLL实例化 var vcmBll = new VipCouponMappingBLL(loggingSessionInfo); //优惠券BLL实例化 var couponTypeBll = new CouponTypeBLL(loggingSessionInfo); //优惠券类型 var mappingBll = new CouponTypeUnitMappingBLL(loggingSessionInfo); //优惠券和门店映射 //var vcmEntity = new VipCouponMappingEntity(); CouponBLL bll = new CouponBLL(loggingSessionInfo); //判断是否有权限核销优惠券 CouponEntity couponEntity = null; if (!string.IsNullOrEmpty(reqObj.Parameters.couponCode)) { CouponEntity[] couponEntityArray = bll.QueryByEntity(new CouponEntity() { CouponCode = reqObj.Parameters.couponCode, CustomerID = reqObj.customerId }, null); if (couponEntityArray.Length != 0) { couponEntity = couponEntityArray[0]; } } else { couponEntity = bll.GetByID(reqObj.Parameters.cuponID); } if (couponEntity != null) { List <IWhereCondition> wheresOrderNo = new List <IWhereCondition>(); wheresOrderNo.Add(new EqualsCondition() { FieldName = "CouponID", Value = couponEntity.CouponID }); var resultCouponVipID = vcmBll.Query(wheresOrderNo.ToArray(), null); var couponTypeInfo = couponTypeBll.GetByID(couponEntity.CouponTypeID); if (couponTypeInfo != null) { if (couponTypeInfo.SuitableForStore == 2)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用 { var couponTypeUnitMapping = mappingBll.QueryByEntity(new CouponTypeUnitMappingEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID.ToString()), ObjectID = reqObj.Parameters.doorID }, null).FirstOrDefault(); if (couponTypeUnitMapping == null) { respData.ResultCode = "104"; respData.Message = "请到指定门店/分销商使用"; return(respData.ToJSON()); } } if (couponTypeInfo.SuitableForStore == 3)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用 { //doorid必须是获取,分销商如果没数据,就报错。 RetailTraderBLL _RetailTraderBLL = new RetailTraderBLL(loggingSessionInfo); RetailTraderEntity en = _RetailTraderBLL.GetByID(reqObj.Parameters.doorID); if (en == null) { respData.ResultCode = "104"; respData.Message = "请到指定分销商使用"; return(respData.ToJSON()); } } if (couponTypeInfo.SuitableForStore == 1)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用 { //doorid必须是获取,门店如果没有数据,就报错。 TUnitBLL _TUnitBLL = new TUnitBLL(loggingSessionInfo); TUnitEntity en = _TUnitBLL.GetByID(reqObj.Parameters.doorID); if (en == null) { respData.ResultCode = "104"; respData.Message = "请到指定门店使用"; return(respData.ToJSON()); } } int res = bll.BestowCoupon(couponEntity.CouponID, reqObj.Parameters.doorID); if (res > 0) //如果没有影响一行,所以Coupon表里这条记录的status=1了,不能被使用了。 { InoutService server = new InoutService(loggingSessionInfo); var tran = server.GetTran(); using (tran.Connection)//事务 { #region 优惠券使用记录 var couponUseEntity = new CouponUseEntity() { CouponID = couponEntity.CouponID, VipID = resultCouponVipID.Length == 0 ? "" : resultCouponVipID[0].VIPID, UnitID = reqObj.Parameters.doorID, //OrderID = orderEntity.OrderID.ToString(), //CreateBy = reqObj.userId, Comment = "核销电子券", CustomerID = reqObj.customerId }; couponUseBll.Create(couponUseEntity);//生成优惠券使用记录 #endregion //#region 修改优惠券数量 2016-06-03 使用了redis不用在这里更新数量 //couponTypeInfo.IsVoucher = couponTypeInfo.IsVoucher == null ? 1 : couponTypeInfo.IsVoucher + 1; //couponTypeBll.Update(couponTypeInfo, tran); //#endregion respData.ResultCode = "200"; respData.Message = "优惠劵使用成功"; tran.Commit(); } } else { respData.ResultCode = "103"; respData.Message = "优惠劵已使用"; } } } else { respData.ResultCode = "104"; respData.Message = "没有找到对应券。"; return(respData.ToJSON()); } } catch (Exception) { respData.ResultCode = "103"; respData.Message = "数据库操作失败"; } return(respData.ToJSON()); }
protected override GetOrderDetailRD ProcessRequest(DTO.Base.APIRequest <GetOrderDetailRP> pRequest) { GetOrderDetailRD rd = new GetOrderDetailRD(); string orderId = pRequest.Parameters.OrderId; rd.OrderListInfo = new OrderListInfo(); #region 获取订单列表 T_InoutBLL orderBll = new T_InoutBLL(this.CurrentUserInfo); var orderList = orderBll.QueryByEntity(new T_InoutEntity() { order_id = orderId }, null); #endregion #region 获取会员信息 string vipNo = orderList[0].vip_no; VipBLL vipBll = new VipBLL(this.CurrentUserInfo); var vipList = vipBll.QueryByEntity(new VipEntity() { VIPID = vipNo }, null); #endregion #region 获取配方式 //Bear 20160928 注释 更具商品信息获取对应配送 string deliveryId = orderList[0].Field8; DeliveryBLL deliverBll = new DeliveryBLL(this.CurrentUserInfo); var deliverList = deliverBll.QueryByEntity(new DeliveryEntity() { DeliveryId = deliveryId }, null); #endregion #region 获取门店信息 string storeId = orderList[0].sales_unit_id; if (!string.IsNullOrEmpty(orderList[0].purchase_unit_id))//如果有发货门店,则显示发货门店信息 { storeId = orderList[0].purchase_unit_id; } TInoutBLL tInoutBll = new TInoutBLL(this.CurrentUserInfo); //string storeName = tInoutBll.GetStoreName(storeId); DataSet storeDs = tInoutBll.GetStoreInfo(storeId); rd.OrderListInfo.StoreID = storeId; #endregion //配送商 string carrierId = orderList[0].carrier_id; //DataSet carrierDs = tInoutBll.GetStoreInfo(carrierId); //if (carrierDs.Tables[0].Rows.Count > 0) //{ // rd.OrderListInfo.CarrierID = carrierId; // rd.OrderListInfo.CarrierName = carrierDs.Tables[0].Rows[0]["unit_name"].ToString(); //} if (!string.IsNullOrEmpty(carrierId)) { //配送方式 1.送货到家;2.到店提货 if (deliveryId == "1") { var logisticsCompanyBLL = new T_LogisticsCompanyBLL(this.CurrentUserInfo); Guid m_carrierId = Guid.Parse(carrierId); var logCompInfo = logisticsCompanyBLL.GetByID(m_carrierId); if (logCompInfo != null) { rd.OrderListInfo.CarrierID = carrierId; rd.OrderListInfo.CarrierName = logCompInfo.LogisticsName; } } else if (deliveryId == "2") { var unitBLL = new t_unitBLL(this.CurrentUserInfo); var unitInfo = unitBLL.GetByID(carrierId); if (unitInfo != null) { rd.OrderListInfo.CarrierID = carrierId; rd.OrderListInfo.CarrierName = unitInfo.unit_name; } } else if (deliveryId == "4") { var unitBLL = new t_unitBLL(this.CurrentUserInfo); var unitInfo = unitBLL.GetByID(carrierId); if (unitInfo != null) { rd.OrderListInfo.CarrierID = carrierId; rd.OrderListInfo.CarrierName = unitInfo.unit_name; } } } rd.OrderListInfo.CourierNumber = orderList[0].Field2; //配送单号 rd.OrderListInfo.Invoice = orderList[0].Field19 == null ? "" : orderList[0].Field19; //发票信息 if (vipList.Count() > 0) { rd.OrderListInfo.VipID = vipList[0].VIPID; rd.OrderListInfo.Phone = vipList[0].Phone; rd.OrderListInfo.UserName = vipList[0].VipName; rd.OrderListInfo.VipRealName = vipList[0].VipRealName; rd.OrderListInfo.VipLevelDesc = vipList[0].VipLevelDesc; rd.OrderListInfo.VipCode = vipList[0].VipCode; rd.OrderListInfo.Email = vipList[0].Email; rd.OrderListInfo.VipLevel = Convert.ToInt32(vipList[0].VipLevel); } if (storeDs.Tables[0].Rows.Count > 0) { rd.OrderListInfo.StoreName = storeDs.Tables[0].Rows[0]["unit_name"].ToString(); rd.OrderListInfo.StoreAddress = storeDs.Tables[0].Rows[0]["unit_address"].ToString(); rd.OrderListInfo.StoreTel = storeDs.Tables[0].Rows[0]["unit_tel"].ToString(); } if (orderList.Count() > 0) { rd.OrderListInfo.discount_rate = orderList[0].discount_rate ?? 100;//订单折扣 rd.OrderListInfo.OrderID = orderList[0].order_id; rd.OrderListInfo.OrderCode = orderList[0].order_no; rd.OrderListInfo.OrderDate = orderList[0].order_date; rd.OrderListInfo.ReceiverName = orderList[0].Field14; //收件人 rd.OrderListInfo.TotalQty = Convert.ToDecimal(orderList[0].total_qty); string TotalAmount = String.Format("{0:F}", orderList[0].total_amount ?? 0); rd.OrderListInfo.TotalAmount = TotalAmount; rd.OrderListInfo.Total_Retail = Convert.ToDecimal(orderList[0].total_retail); rd.OrderListInfo.Remark = orderList[0].remark; rd.OrderListInfo.Status = orderList[0].status; rd.OrderListInfo.OrderStatus = int.Parse(orderList[0].Field7); rd.OrderListInfo.StatusDesc = orderList[0].status_desc; rd.OrderListInfo.DeliveryAddress = orderList[0].Field4; rd.OrderListInfo.DeliveryTime = orderList[0].Field9; rd.OrderListInfo.ClinchTime = orderList[0].create_time; rd.OrderListInfo.ReceiptTime = orderList[0].accpect_time; rd.OrderListInfo.CouponsPrompt = orderList[0].Field16; rd.OrderListInfo.DeliveryID = orderList[0].Field8; rd.OrderListInfo.IsPayment = orderList[0].Field1; rd.OrderListInfo.ReceivePoints = orderList[0].receive_points; rd.OrderListInfo.PaymentTime = orderList[0].Field1 == "1" ? orderList[0].complete_date : null; rd.OrderListInfo.OrderReasonTypeId = orderList[0].order_reason_id; rd.OrderListInfo.ActualDecimal = orderList[0].actual_amount ?? 0; rd.OrderListInfo.PaymentTypeCode = orderList[0].Payment_Type_Code; rd.OrderListInfo.PaymentTypeName = orderList[0].Payment_Type_Name; rd.OrderListInfo.ReserveTime = orderList[0].reserveDay + " " + orderList[0].reserveQuantum; var deliveryBll = new TOrderCustomerDeliveryStrategyMappingBLL(this.CurrentUserInfo); rd.OrderListInfo.DeliveryAmount = deliveryBll.GetDeliverAmount(orderId); //配送费 add by henry*** if (!string.IsNullOrEmpty(orderList[0].Field15) && orderList[0].Field15 != "0") //是否是团购商品 add by Henry 2014-12-22 { rd.OrderListInfo.IsEvent = 1; //团购商品 } else { rd.OrderListInfo.IsEvent = 0; //普通商品 } #region update by changjian.tian rd.OrderListInfo.Mobile = orderList[0].Field6; //配送联系电话 rd.OrderListInfo.DeliveryRemark = orderList[0].remark; rd.OrderListInfo.IsEvaluation = orderList[0].IsEvaluation == null ? 0 : orderList[0].IsEvaluation.Value;//评论 #endregion } if (deliverList.Count() > 0) { rd.OrderListInfo.DeliveryName = deliverList[0].DeliveryName; } T_Inout_DetailBLL orderDetailBll = new T_Inout_DetailBLL(this.CurrentUserInfo); //退换货Bll实例化 T_SalesReturnBLL salesReturnBll = new T_SalesReturnBLL(this.CurrentUserInfo); var orderDetailList = orderDetailBll.QueryByEntity(new T_Inout_DetailEntity() { order_id = orderId }, null); var inoutService = new InoutService(this.CurrentUserInfo); #region 根据订单ID获取订单明细 var ds = inoutService.GetOrderDetailByOrderId(orderId); #endregion #region 获取订单详细列表中的商品规格 var ggDs = inoutService.GetInoutDetailGgByOrderId(orderId); #endregion if (ds.Tables[0].Rows.Count > 0) { string ItemIdList = ds.Tables[0].AsEnumerable().Aggregate("", (x, j) => { x += string.Format("'{0}',", j["item_id"].ToString()); return(x); }).Trim(','); TInoutDetailBLL tInoutDetailBll = new TInoutDetailBLL(this.CurrentUserInfo); //获取商品的图片 DataSet imageDs = tInoutDetailBll.GetOrderDetailImageList(ItemIdList); var tmp = ds.Tables[0].AsEnumerable().Select(t => new OrderDetailEntity() { ItemID = t["item_id"].ToString(), ItemName = t["item_name"].ToString(), SkuID = t["sku_id"].ToString(), SalesReturnFlag = salesReturnBll.CheckSalesReturn(orderId, t["sku_id"].ToString()),//是否可申请退换货 //GG = t["prop_1_detail_name"].ToString()+t["prop_2_detail_name"].ToString()+t["prop_3_detail_name"].ToString() //+t["prop_4_detail_name"].ToString()+t["prop_5_detail_name"].ToString(), Field9 = t["Field9"].ToString(), isGB = Convert.ToInt32(t["isGB"]), GG = ggDs.Tables[0].AsEnumerable() .Where(tt => tt["sku_id"].ToString() == t["sku_id"].ToString()) .Select(tt => new GuiGeInfo { PropName1 = tt["prop_1_name"].ToString(), PropDetailName1 = tt["prop_1_detail_name"].ToString(), PropName2 = tt["prop_2_name"].ToString(), PropDetailName2 = tt["prop_2_detail_name"].ToString(), PropName3 = tt["prop_3_name"].ToString(), PropDetailName3 = tt["prop_3_detail_name"].ToString(), PropName4 = tt["prop_4_name"].ToString(), PropDetailName4 = tt["prop_4_detail_name"].ToString(), PropName5 = tt["prop_5_name"].ToString(), PropDetailName5 = tt["prop_5_detail_name"].ToString() }).FirstOrDefault(), SalesPrice = Convert.ToDecimal(t["enter_price"]), //DiscountRate = Convert.ToDecimal(t["discount_rate"]), DiscountRate = Convert.ToDecimal(t["order_discount_rate"]), ItemCategoryName = t["itemCategoryName"].ToString(), BeginDate = t["Field1"].ToString(), EndDate = t["Field2"].ToString(), DayCount = Convert.ToInt32(t["DayCount"]), Qty = Convert.ToDecimal(t["enter_qty"]), ImageInfo = imageDs.Tables[0].AsEnumerable() .Where(c => c["ObjectId"].ToString() == t["item_id"].ToString()) .OrderBy(c => c["displayIndex"]) .Select(c => new OrderDetailImage { ImageID = c["imageId"].ToString(), ImageUrl = ImagePathUtil.GetImagePathStr(c["imageUrl"].ToString(), "240") }).ToArray(), IfService = Convert.ToInt32(t["IfService"]) }); int tempCount = 0; foreach (var i in tmp) { if (i.IfService == 0) { tempCount++; } } if (tempCount == 0) { rd.OrderListInfo.IsAllService = 3; // 3-全部为虚拟商品 } else if (tempCount == tmp.Count()) { rd.OrderListInfo.IsAllService = 1; // 1-全部为实物商品 } else { rd.OrderListInfo.IsAllService = 2; // 2-包含实物商品和虚拟商品 } #region 根据商品获取配送方式 var deliveryIds = new List <int?>(); if (rd.OrderListInfo.IsAllService == 3) { deliveryIds.Add(1); deliveryIds.Add(2); deliveryIds.Add(4); rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds; } else { T_Item_Delivery_MappingBLL mappingBll = new T_Item_Delivery_MappingBLL(this.CurrentUserInfo); var complexCondition = new List <IWhereCondition> { }; var itemIdArray = ItemIdList.Replace("'", "").Split(','); complexCondition.Add(new InCondition <string>() { FieldName = "Item_Id", Values = itemIdArray }); var itemDeliveryList = mappingBll.Query(complexCondition.ToArray(), null); bool needAddDelivery4 = false; bool needAddDelivery2 = false; if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 4) != null) { needAddDelivery4 = true; } else { if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 2) != null) { needAddDelivery2 = true; } } var itemDeliveryGroupList = itemDeliveryList.GroupBy(d => d.Item_Id); var index = 0; foreach (var info in itemDeliveryGroupList) { var tmpList = info.ToList <T_Item_Delivery_MappingEntity>(); //分组后的集合 if (index == 0) { deliveryIds.AddRange(tmpList.Select(d => d.DeliveryId)); index++; continue; } deliveryIds = deliveryIds.Intersect(tmpList.Select(d => d.DeliveryId)).ToList(); if (deliveryIds.Count <= 0) { break; // 后面的不用求了 } index++; } if (!deliveryIds.Contains(4) && needAddDelivery4) { deliveryIds.Add(4); } if (!deliveryIds.Contains(2) && needAddDelivery2) { deliveryIds.Add(2); } rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds.OrderBy(t => t.Value).ToList(); } #endregion rd.OrderListInfo.OrderDetailInfo = tmp.ToArray(); } var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo); // var integral = vipIntegralDetailBll.GetVipIntegralByOrder(orderId, pRequest.UserID); //使用积分 rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralDetailBll.GetVipIntegralByOrder(orderId, vipNo)); //积分抵扣金额 add by Henry 2014-10-8 //decimal integralAmountPre = vipBll.GetIntegralAmountPre(this.CurrentUserInfo.ClientID);//获取积分金额比例 //rd.OrderListInfo.UseIntegralToAmount =rd.OrderListInfo.OrderIntegral*(integralAmountPre>0?integralAmountPre:0.01M); rd.OrderListInfo.UseIntegralToAmount = vipBll.GetAmountByIntegralPer(CurrentUserInfo.ClientID, rd.OrderListInfo.OrderIntegral); var couponUseBll = new CouponUseBLL(this.CurrentUserInfo); var couponParValue = couponUseBll.GetCouponParValue(orderId); rd.OrderListInfo.CouponAmount = couponParValue; var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo); //使用的账户余额 rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 1)); //使用余额,将余额从实付款中分开 if (rd.OrderListInfo.VipEndAmount != 0) { rd.OrderListInfo.ActualDecimal = rd.OrderListInfo.ActualDecimal - rd.OrderListInfo.VipEndAmount; } //使用的返现金额 rd.OrderListInfo.ReturnAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 13)); //使用阿拉币和阿拉币抵扣 add by Henry 2014-10-13 if (pRequest.ChannelId == "4")//阿拉丁APP调用 { decimal aldAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 11)); rd.OrderListInfo.ALDAmount = aldAmount; rd.OrderListInfo.ALDAmountMoney = aldAmount * 0.01M; } #region 获取订单积分,优惠券金额,使用余额 //var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo); //var vipIntegralList = vipIntegralDetailBll.QueryByEntity(new VipIntegralDetailEntity() //{ // VIPID = pRequest.UserID, // ObjectId = orderId //}, null); //if (vipIntegralList != null && vipIntegralList.Length > 0) //{ // rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralList[0].Integral??0); //} //var tOrderCouponMappingBll = new TOrderCouponMappingBLL(this.CurrentUserInfo); //var tOrderCouponMappingList = tOrderCouponMappingBll.QueryByEntity(new TOrderCouponMappingEntity() //{ // OrderId = orderId //}, null); //if (tOrderCouponMappingList != null && tOrderCouponMappingList.Length > 0) //{ // var couponId = tOrderCouponMappingList[0].CouponId; // var couponBll = new CouponBLL(this.CurrentUserInfo); // var couponEntity = couponBll.GetByID(couponId); // if (couponEntity != null) // { // var couponTypeId = couponEntity.CouponTypeID; // var couponTypeBll = new CouponTypeBLL(this.CurrentUserInfo); // var couponTypeEntity = couponTypeBll.GetByID(couponTypeId); // if (couponTypeEntity != null) // { // rd.OrderListInfo.CouponAmount = couponTypeEntity.ParValue ?? 0; // } // } //} //var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo); //var vipAmountDetailList = vipAmountDetailBll.QueryByEntity(new VipAmountDetailEntity() //{ // VipId = pRequest.UserID, // ObjectId = orderId //}, null); //if (vipAmountDetailList != null && vipAmountDetailList.Length > 0) //{ // rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailList[0].Amount ?? 0); //} #endregion return(rd); }