Esempio n. 1
0
        public bool VendorCopyProduct(int writerId, int combo_type, string old_product_Id, ref string product_id, string product_Ipfrom)
        {
            int Vendor_rid = 0;
            try
            {
                List<ProductTemp> copynumber = _pTempDao.GetProTempByVendor(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Create_Channel = 2, Temp_Status = 13 });
                if (copynumber.Count != 0)
                {
                    foreach (var item in copynumber)
                    {
                        DeleteVendorProductTemp(writerId, combo_type, item.Product_Id);
                    }
                }

                ArrayList sqls = new ArrayList();
                Vendor_rid = VendorSaveFromPro(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = old_product_Id, Product_Ipfrom = product_Ipfrom, Product_Createdate = uint.Parse(Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()) });
                product_id = "T" + Vendor_rid;
                ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
                sqls.Add(proNoticeSetTempMgr.VendorSaveFromProNotice(new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_id }, old_product_Id));

                ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
                sqls.Add(proTagSetTempMgr.VendorSaveFromTag(new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_id }, old_product_Id));

                ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
                sqls.Add(proPicTempMgr.VendorSaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_id }, old_product_Id));

                ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
                sqls.Add(proCateSetTempMgr.VendorSaveFromCategorySet(new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_id }, old_product_Id));

                PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
                ArrayList specs = new ArrayList();
                if (combo_type == 1)//單一商品
                {
                    sqls.Add(priceMasterTempMgr.VendorSaveFromPriceMaster(new PriceMasterTemp { writer_Id = writerId, product_id = product_id, combo_type = combo_type }, old_product_Id));
                     
                    ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                    sqls.Add(proItemTempMgr.VendorSaveFromProItem(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_id }, old_product_Id));

                    //因為複製的是臨時表所以換成productspectemp
                    ProductSpecTempMgr ProSpecTemp = new ProductSpecTempMgr(connStr);
                    //查詢出要複製的商品裡面的規格是否為空
                    List<ProductSpecTemp> proSpecs = ProSpecTemp.VendorQuery(new ProductSpecTemp { product_id = old_product_Id });
                    //ProductSpecMgr proSpecMgr = new ProductSpecMgr(connStr);
                    if (proSpecs != null)
                    {
                        ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(connStr);
                        StringBuilder str;
                        foreach (var item in proSpecs)
                        {
                            str = new StringBuilder();
                            str.Append(proSpecTempMgr.VendorSaveFromSpec(new ProductSpecTemp { Writer_Id = writerId, product_id = product_id, spec_id = item.spec_id }, old_product_Id));
                          
                            str.Append(proItemTempMgr.VendorUpdateCopySpecId(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_id, Spec_Id_1 = item.spec_id, Spec_Id_2 = item.spec_id }));
                            specs.Add(str.ToString());
                        }
                    }
                    return _pTempDao.VendorCopyProduct(sqls, specs, null, null, null);
                }
                else
                {
                    PriceMasterMgr priceMasterMgr = new PriceMasterMgr("");
                    string selMaster = priceMasterMgr.VendorSelectChild(new PriceMasterTemp { product_id = old_product_Id });
                    string moveMaster = priceMasterTempMgr.VendorSaveFromPriceMaster(new PriceMasterTemp { combo_type = combo_type, product_id = product_id, writer_Id = writerId }, old_product_Id);

                    ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                    string movePrice = itemPriceTempMgr.SaveFromItemPriceByMasterId();
                    ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr("");
                    sqls.Add(proComboTempMgr.VendorSaveFromCombo(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_id }, old_product_Id));
                    return _pTempDao.VendorCopyProduct(sqls, specs, selMaster, moveMaster, movePrice);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ProductTempMgr.VendorCopyProduct-->" + ex.Message, ex);
            }
        }
Esempio n. 2
0
        public bool CopyProduct(int writerId, int combo_type, string product_Id)
        {
            try
            {
                if (DeleteTemp(writerId, combo_type, product_Id)) 
                {
                    ArrayList sqls = new ArrayList();
                    var prodTemp = new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 1 };
                    sqls.Add(SaveFromPro(prodTemp));

                    //add by xiangwang0413w 2014/11/06
                    ProductDeliverySetTempMgr proDelSetTempMgr = new ProductDeliverySetTempMgr("");
                    sqls.Add(proDelSetTempMgr.SaveFromProDeliverySet(new ProductDeliverySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_id = int.Parse(product_Id) }));

                    ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
                    sqls.Add(proNoticeSetTempMgr.SaveFromProNotice(new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }));

                    ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
                    sqls.Add(proTagSetTempMgr.SaveFromTag(new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }));

                    ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
                    sqls.Add(proPicTempMgr.SaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id },1));//複製商品說明圖
                    sqls.Add(proPicTempMgr.SaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id }, 2));//複製手機app圖

                    ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
                    sqls.Add(proCateSetTempMgr.SaveFromCategorySet(new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id }));

                    PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");

                    ArrayList specs = new ArrayList();
                    if (combo_type == 1)//單一商品
                    {
                        sqls.Add(priceMasterTempMgr.SaveFromPriceMaster(new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type }));
                        //add by dongya 2015/08/25 添加信息到商品推薦臨時表  用來複製商品 
                        RecommendedProductAttributeMgr recommendAttributeMgr = new RecommendedProductAttributeMgr("");
                        sqls.Add(recommendAttributeMgr.SaveRecommendedProductAttributSet(new RecommendedRroductAttributeTemp{write_id = writerId, product_id = UInt32.Parse(product_Id),combo_type=combo_type}));
                        ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                        var prodItemTemp = new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id };

                        sqls.Add(proItemTempMgr.SaveFromProItem(prodItemTemp));

                        ProductSpecMgr proSpecMgr = new ProductSpecMgr(connStr);
                        List<ProductSpec> proSpecs = proSpecMgr.Query(new ProductSpec { product_id = uint.Parse(product_Id) });
                        if (proSpecs != null)
                        {
                            ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                            StringBuilder str;
                            foreach (var item in proSpecs)
                            {
                                sqls.Add(proSpecTempMgr.SaveFromSpec(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id, spec_id = item.spec_id }));

                                str = new StringBuilder();
                                str.Append(proSpecTempMgr.UpdateCopySpecId(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id, spec_id = item.spec_id }));
                                str.Append(proItemTempMgr.UpdateCopySpecId(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id, Spec_Id_1 = item.spec_id, Spec_Id_2 = item.spec_id }));
                                specs.Add(str.ToString());
                            }
                        }
                        return _pTempDao.CopyProduct(sqls, specs, null, null, null);
                    }
                    else
                    {
                        PriceMasterMgr priceMasterMgr = new PriceMasterMgr("");
                        string selMaster = priceMasterMgr.SelectChild(new PriceMaster { product_id = uint.Parse(product_Id) });

                        string moveMaster = priceMasterTempMgr.SaveFromPriceMasterByMasterId(new PriceMasterTemp { combo_type = combo_type, writer_Id = writerId });

                        ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                        string movePrice = itemPriceTempMgr.SaveFromItemPriceByMasterId();

                        //add by dongya 2015/08/25 添加信息到商品推薦臨時表  用來複製商品 
                        RecommendedProductAttributeMgr recommendAttributeMgr = new RecommendedProductAttributeMgr("");
                        sqls.Add(recommendAttributeMgr.SaveRecommendedProductAttributSet(new RecommendedRroductAttributeTemp { write_id = writerId, product_id = UInt32.Parse(product_Id),combo_type=combo_type }));
                        ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr("");
                        sqls.Add(proComboTempMgr.SaveFromCombo(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id }));

                        return _pTempDao.CopyProduct(sqls, specs, selMaster, moveMaster, movePrice);
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                throw new Exception("ProductTempMgr.CopyProduct-->" + ex.Message, ex);
            }
        }