コード例 #1
0
ファイル: DsReturnDaoImpl.cs プロジェクト: KqSMea8/HS.Admin
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns></returns>
 /// <remarks>2013-09-25  朱成果 创建</remarks>
 public override void Update(DsReturn entity)
 {
     Context.Update("DsReturn", entity)
     .AutoMap(o => o.SysNo)
     .Where("SysNo", entity.SysNo)
     .Execute();
 }
コード例 #2
0
ファイル: DsReturnDaoImpl.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 插入主表
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>sysNo</returns>
        /// <remarks>2013-09-12 朱家宏 创建</remarks>
        public override int Insert(DsReturn model)
        {
            var sysNo = Context.Insert("DsReturn", model)
                        .AutoMap(o => o.SysNo)
                        .ExecuteReturnLastId <int>("SysNo");

            return(sysNo);
        }
コード例 #3
0
ファイル: DsReturnBo.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 创建分销商退换货单及明细
        /// </summary>
        /// <param name="dsReturn">主表实体</param>
        /// <param name="returnItems">副表实体</param>
        /// <returns>主表编号</returns>
        /// <remarks>2013-09-12 朱家宏 创建</remarks>
        public int Create(DsReturn dsReturn, List <DsReturnItem> returnItems)
        {
            if (dsReturn == null || returnItems == null || !returnItems.Any())
            {
                throw new ArgumentNullException();
            }

            var mainSysNo = IDsReturnDao.Instance.Insert(dsReturn);

            if (mainSysNo > 0)
            {
                foreach (var item in returnItems)
                {
                    item.DsReturnSysNo = mainSysNo;
                    IDsReturnDao.Instance.InsertItem(item);
                }
            }

            return(mainSysNo);
        }
コード例 #4
0
        /// <summary>
        /// 获取分销商退换货单
        /// </summary>
        /// <param name="shopAccount">账户</param>
        /// <param name="mallTypeSysNo">类型</param>
        /// <param name="top">取前几条</param>
        /// <param name="isFinish">退款完成</param>
        /// <returns>分销商退换货单列表</returns>
        /// <remarks>2013-09-10 黄志勇 创建</remarks>
        public Result <List <DsReturn> > GetReturnInfo(string shopAccount, int mallTypeSysNo, int top, bool?isFinish)
        {
            var model = BLL.MallSeller.DsOrderBo.Instance.GetReturn(shopAccount, mallTypeSysNo, top, isFinish);
            var list  = new List <DsReturn>();

            if (model != null && model.Count > 0)
            {
                foreach (var cbDsReturn in model)
                {
                    var info = new DsReturn();
                    Hyt.Util.Reflection.ReflectionUtils.Transform(cbDsReturn, info);
                    list.Add(info);
                }
            }
            var result = new Result <List <DsReturn> >
            {
                Data   = list,
                Status = true
            };

            return(result);
        }
コード例 #5
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="entity">数据实体</param>
 /// <returns></returns>
 /// <remarks>2013-09-25  朱成果 创建</remarks>
 public abstract void Update(DsReturn entity);
コード例 #6
0
 /// <summary>
 /// 插入主表
 /// </summary>
 /// <param name="model">实体</param>
 /// <returns>sysNo</returns>
 /// <remarks>2013-09-12 朱家宏 创建</remarks>
 public abstract int Insert(DsReturn model);
コード例 #7
0
        /// <summary>
        /// 商城退货单导入商城
        /// </summary>
        /// <param name="mallRma">退货单实体</param>
        /// <returns>处理结果</returns>
        /// <remarks>2013-8-29 陶辉 创建</remarks>
        /// <remarks>2013-09-10 朱家宏 实现</remarks>
        /// <remarks>2013-10-21 黄志勇 修改退换货子表实退商品金额</remarks>
        public Result ImportMallRma(UpGradeRma mallRma)
        {
            //直接申请退换单,根据原订单匹配成功的商品明细进行退货
            var result = new Result();

            try
            {
                //升舱订单数据
                var dsOrder      = BLL.MallSeller.DsOrderBo.Instance.GetDsOrderByMallOrderId(mallRma.MallOrderId);
                var dsOrderItems = BLL.MallSeller.DsOrderBo.Instance.GetDsOrderItems(dsOrder.SysNo);


                //HYT订单主表数据
                var soOrder =
                    DataAccess.Order.ISoOrderDao.Instance.GetByTransactionSysNo(dsOrder.OrderTransactionSysNo);

                if (soOrder.Status != (int)Model.WorkflowStatus.OrderStatus.销售单状态.已完成)
                {
                    result.Message    = "未完成的订单不允许做此操作。";
                    result.Status     = false;
                    result.StatusCode = -1;
                    return(result);
                }

                //订单明细数据
                var soOrderItems = BLL.Order.SoOrderBo.Instance.GetOrderItemsByOrderId(soOrder.SysNo);

                if (soOrderItems == null)
                {
                    throw new ArgumentNullException();
                }

                //退换货明细
                var rcReturnItems = new List <RcReturnItem>();
                foreach (var item in mallRma.RmaItems)
                {
                    var         outitem     = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWhStockOutItem(item.StockOutItemSysNo);
                    SoOrderItem soOrderItem = null;
                    if (outitem != null)
                    {
                        soOrderItem = soOrderItems.FirstOrDefault(m => m.SysNo == outitem.OrderItemSysNo);
                    }
                    if (soOrderItem != null)
                    {
                        var rcReturnItem = new RcReturnItem
                        {
                            OriginPrice         = soOrderItem.OriginalPrice,
                            ProductName         = soOrderItem.ProductName,
                            ProductSysNo        = int.Parse(item.HytProductCode),
                            ReturnPriceType     = (int)Model.WorkflowStatus.RmaStatus.商品退款价格类型.自定义价格,
                            ReturnType          = (int)Model.WorkflowStatus.RmaStatus.商品退换货类型.新品,
                            RmaQuantity         = item.MallQuantity,
                            RmaReason           = "",
                            StockOutItemSysNo   = item.StockOutItemSysNo,
                            RefundProductAmount = Math.Round(outitem.RealSalesAmount * ((decimal)item.MallQuantity / (decimal)outitem.ProductQuantity), 2)
                        };
                        rcReturnItems.Add(rcReturnItem);
                    }
                }

                var refundProductAmount = rcReturnItems.Sum(o => o.RefundProductAmount); //退款金额合计

                var rcReturn = new CBRcReturn
                {
                    CreateBy            = soOrder.CustomerSysNo,
                    CreateDate          = DateTime.Now,
                    CustomerSysNo       = soOrder.CustomerSysNo,
                    HandleDepartment    = (int)Model.WorkflowStatus.RmaStatus.退换货处理部门.客服中心,
                    InvoiceSysNo        = soOrder.InvoiceSysNo,
                    LastUpdateBy        = soOrder.OrderCreatorSysNo,
                    LastUpdateDate      = DateTime.Now,
                    OrderSysNo          = soOrder.SysNo,
                    ReceiveAddressSysNo = soOrder.ReceiveAddressSysNo,
                    RMARemark           = "",
                    RmaType             = (int)Model.WorkflowStatus.RmaStatus.RMA类型.售后退货,
                    Source                = (int)Model.WorkflowStatus.RmaStatus.退换货申请单来源.分销商,
                    Status                = (int)Model.WorkflowStatus.RmaStatus.退换货状态.待审核,
                    WarehouseSysNo        = soOrder.DefaultWarehouseSysNo,
                    RMAItems              = rcReturnItems,
                    DeductedInvoiceAmount = 0,
                    InternalRemark        = mallRma.BuyerRmaReason,//退款说明
                    IsPickUpInvoice       = 0,
                    OrginAmount           = refundProductAmount,
                    OrginPoint            = (int)refundProductAmount,
                    RefundPoint           = (int)refundProductAmount,
                    PickUpAddressSysNo    = 0,
                    PickUpTime            = "",
                    PickupTypeSysNo       = 0,
                    RedeemAmount          = 0,
                    RefundAccount         = "",
                    RefundAccountName     = "",
                    RefundBank            = "",
                    RefundBy              = 0,
                    ShipTypeSysNo         = 0,
                    RefundDate            = DateTime.Now,
                    RefundProductAmount   = refundProductAmount,
                    RefundTotalAmount     = refundProductAmount,
                    RefundType            = (int)Hyt.Model.WorkflowStatus.RmaStatus.退换货退款方式.分销商预存
                };

                //当前操作用户
                var htyUserSysNo = IDsOrderDao.Instance.GetDealer(mallRma.DealerSysNo).UserSysNo;
                var syUser       = BLL.Sys.SyUserBo.Instance.GetSyUser(htyUserSysNo);
                var pickaddress  = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(soOrder.ReceiveAddressSysNo);//收货地址变成取件地址
                pickaddress.SysNo = 0;
                using (var tran = new TransactionScope())
                {
                    //创建rma单
                    var rmaSysNo = BLL.RMA.RmaBo.Instance.InsertRMA(rcReturn, pickaddress, null, syUser);
                    var htyRma   = BLL.RMA.RmaBo.Instance.GetRcReturnEntity(rmaSysNo);
                    //分销商退换货单
                    var dsReturn = new DsReturn
                    {
                        ApplicationTime        = mallRma.ApplyTime,
                        BuyerNick              = mallRma.MallBuyerName,
                        RmaRemark              = mallRma.BuyerRmaReason,
                        DealerMallSysNo        = mallRma.DealerMallSysNo,
                        MallOrderId            = mallRma.MallOrderId,
                        MallReturnAmount       = mallRma.MallRefundFee,
                        MallReturnId           = mallRma.MallRmaId,
                        BuyerRemark            = mallRma.MallRmaMessage,
                        RmaType                = (int)Model.WorkflowStatus.RmaStatus.RMA类型.售后退货,
                        RcReturnSysNo          = rmaSysNo,
                        ReturnTransactionSysNo = htyRma.TransactionSysNo
                    };



                    var dsReturnItems = new List <DsReturnItem>();
                    foreach (var rmaItem in mallRma.RmaItems)
                    {
                        var         myid        = BLL.MallSeller.DsOrderBo.Instance.GetDsOrderItemAssociationByOutStockItemNo(rmaItem.StockOutItemSysNo).Select(m => m.DsOrderItemSysNo).FirstOrDefault();
                        DsOrderItem dsOrderItem = dsOrderItems.FirstOrDefault(m => m.SysNo == myid);
                        if (dsOrderItem == null)
                        {
                            dsOrderItem = new DsOrderItem();
                        }
                        dsReturnItems.Add(new DsReturnItem
                        {
                            Amount = rmaItem.HytRmaAmount,
                            MallProductAttribute = dsOrderItem.MallProductAttribute,
                            MallProductId        = dsOrderItem.MallProductId,
                            MallProductName      = dsOrderItem.MallProductName,
                            Quantity             = rmaItem.MallQuantity
                        });
                    }

                    //创建『分销商退换货单』
                    BLL.MallSeller.DsReturnBo.Instance.Create(dsReturn, dsReturnItems);

                    if (!string.IsNullOrEmpty(mallRma.ImgPaths))
                    {
                        string[] paths = mallRma.ImgPaths.Split(',');
                        foreach (string str in paths)
                        {
                            BLL.RMA.RmaBo.Instance.InsertRMAImg(new RcReturnImage()
                            {
                                ImageUrl    = str,
                                ReturnSysNo = rmaSysNo
                            });
                        }
                    }

                    result.Message    = "操作成功。";
                    result.Status     = true;
                    result.StatusCode = rmaSysNo;

                    tran.Complete();
                }
            }
            catch
            {
                result.Message    = "操作失败。";
                result.Status     = false;
                result.StatusCode = -1;
            }

            return(result);
        }