Example #1
0
        /// <summary>
        /// 刪除供應商商品數據
        /// </summary>
        /// <returns></returns>
        public bool DeleteVendorProductTemp(int writerId, int combo_type, string product_Id)
        {
            try
            {
                ArrayList sqls = new ArrayList();
                sqls.Add(DeleteProductTemp(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id }));

                ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                sqls.Add(proItemTempMgr.DeleteVendorSql(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id }));

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

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

                ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                sqls.Add(proSpecTempMgr.TempDeleteByVendor(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id }));

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

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

                ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr("");
                sqls.Add(itemPriceMgr.DeleteByVendor(product_Id.ToString(), combo_type, writerId));

                PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
                sqls.Add(priceMasterTempMgr.DeleteByVendor(new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type }));

                ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr("");
                sqls.Add(proComboTempMgr.TempDeleteByVendor(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id }));

                MySqlDao mySqlDao = new MySqlDao(connStr);
                return mySqlDao.ExcuteSqls(sqls);
            }
            catch (Exception ex)
            {
                throw new Exception("ProductTempMg.DeleteTemp-->" + ex.Message, ex);
            }
        }
Example #2
0
        public int Vendor_TempMove2Pro(int writerId, int combo_type, string product_Id, ProductTemp pt)
        {
            ArrayList sqls = new ArrayList();
            int product_id = 0;
            ProductTempMgr proTempMgr = new ProductTempMgr("");
            ProductTemp proTemp = new ProductTemp { Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 2 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09
            string movePro = proTempMgr.Vendor_MoveProduct(proTemp);
            sqls.Add(proTempMgr.Vendor_Delete(proTemp));

            ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr("");
            ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proNoticeSetTempMgr.Vendor_MoveNotice(proNoticeSetTemp));
            sqls.Add(proNoticeSetTempMgr.Vendor_Delete(proNoticeSetTemp));

            ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr("");
            ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Combo_Type = combo_type, product_id = product_Id };
            sqls.Add(proTagSetTempMgr.Vendor_MoveTag(proTagSetTemp));
            sqls.Add(proTagSetTempMgr.Vendor_Delete(proTagSetTemp));

            ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr("");
            ProductPictureTemp proPictureTemp = new ProductPictureTemp { combo_type = combo_type, product_id = product_Id };
            sqls.Add(proPicTempMgr.Vendor_MoveToProductPicture(proPictureTemp));
            sqls.Add(proPicTempMgr.Vendor_Delete(proPictureTemp));

            ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr("");
            ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Combo_Type = combo_type, Product_Id = product_Id.ToString() };
            sqls.Add(proCateSetTempMgr.Vendor_TempMoveCategory(proCategorySetTemp));
            sqls.Add(proCateSetTempMgr.Vendor_TempDelete(proCategorySetTemp));

            //product_status_history.type  1,申請審核 2,核可 3,駁回 4,下架 5,新建商品 6,上架 7,系統移轉建立 8,取消送審       parametertype='verify_operate_type'
            //product_status_history.product_status 0,新建立商品 1,申請審核 2,審核通過 5,上架 6,下架 20,供應商新建商品       parametertype='product_status'
            ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr("");
            sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 20, user_id = Convert.ToUInt32(pt.Writer_Id), type = 5 }));//供應商新建立商品
            sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 2 }));          //管理員核可

            ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr("");
            sqls.Add(itemTempPriceMgr.Vendor_Delete(product_Id, combo_type, 0));

            PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
            PriceMasterTemp priceMasterTemp = new PriceMasterTemp { product_id = product_Id, combo_type = combo_type };
            sqls.Add(priceMasterTempMgr.Vendor_Delete(priceMasterTemp));

            //判斷是單一商品還是組合商品
            if (combo_type == 1)
            {//單一商品
                IProductItemImplDao piDao = new ProductItemDao(connectionStr);
                ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr("");
                ProductItemTemp proItemTemp = new ProductItemTemp { Product_Id = product_Id };
                string selItem = proItemTempMgr.VendorQuerySql(proItemTemp);
                string moveItem = proItemTempMgr.VendorMoveProductItem(proItemTemp);//方法修改了writerId
                sqls.Add(proItemTempMgr.DeleteVendorSql(proItemTemp));

                ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr("");
                ProductSpecTemp proSpecTemp = new ProductSpecTemp { product_id = product_Id };
                sqls.Add(proSpecTempMgr.VendorTempMoveSpec(proSpecTemp));
                sqls.Add(proSpecTempMgr.VendorTempDelete(proSpecTemp));

                string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp);

                ItemPriceMgr itemPriceMgr = new ItemPriceMgr("");
                string itemPrice = itemPriceMgr.SaveFromItem(pt.Writer_Id, pt.Product_Id);
                // add 處理price_mater_temp and product_combo_temp
                sqls.Add(proTempMgr.VendorEditCM(proTemp));

                product_id = _productDao.TempMove2Pro(movePro, "", moveItem, "", selItem, priceMaster, itemPrice, sqls);
                if (product_id > 0)
                {
                    piDao.UpdateErpId(product_id.ToString());
                }
                return product_id;
            }
            else
            {//組合商品
                ProductComboTempMgr pcTempMgr = new ProductComboTempMgr("");
                ProductComboTemp proComboTemp = new ProductComboTemp { Parent_Id = product_Id };
                sqls.Add(pcTempMgr.Vendor_TempMoveCombo(proComboTemp));
                sqls.Add(pcTempMgr.TempDeleteByVendor(proComboTemp));
                string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp);
                string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp);

                ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                string itemPrice = itemPriceTempMgr.VendorMove2ItemPrice();
                sqls.Add(itemPriceTempMgr.Vendor_Delete(product_Id, combo_type, 0));

                return _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls);
            }
            //記錄的sql語句
            //insert into product(product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,user_id,show_listprice,expect_msg,create_channel ) select 15164 as product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,'0' as product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,1411033321 as product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,writer_id,show_listprice,expect_msg,create_channel from product_temp where 1=1  and combo_type=2 and create_channel=2 and product_id='T578';
            //select price_master_id,product_id,child_id from price_master_temp where 1=1 and combo_type=2 and product_id='T578';
            //insert into price_master(`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`,`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`) 
            //select 15164 as product_id,site_id,user_level,user_id,product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,15164 as child_id,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master_temp where 1=1 and combo_type=2 and product_id='T578';select @@identity;
            //insert into item_price(`price_master_id`,`item_id`,`item_money`,`item_cost`,`event_money`,`event_cost`) select 5699 as price_master_id,item_id,item_money,item_cost,event_money,event_cost from item_price_temp where price_master_id=1751
            //set sql_safe_updates = 0;update price_master set child_id=15164 where price_master_id=5699; set sql_safe_updates = 1;

            //set sql_safe_updates = 0;delete from product_temp where product_id='T578';set sql_safe_updates = 1
            //insert into product_notice_set(product_id,notice_id) select 15164 as product_id,notice_id from product_notice_set_temp where 1=1  and combo_type = 2 and product_id='T578';
            //set sql_safe_updates=0;delete from product_notice_set_temp where product_id='T578';set sql_safe_updates=1;
            //insert into product_tag_set(`product_id`,`tag_id`) select 15164 as product_id,tag_id from product_tag_set_temp where 1=1 and combo_type=2 and product_id='T578';
            //set sql_safe_updates=0;delete from product_tag_set_temp where product_id='T578';set sql_safe_updates=1;
            //insert into product_picture(product_id,image_filename,image_sort,image_state,image_createdate) select 15164 as product_id,image_filename,image_sort,image_state,image_createdate from product_picture_temp where 1=1 and product_id='T578' and combo_type=2;
            //set sql_safe_updates=0; delete from product_picture_temp where  product_id='T578';set sql_safe_updates = 1;
            //insert into product_category_set(product_id,category_id,brand_id) select 15164 as product_id,category_id,brand_id from product_category_set_temp where 1=1 and product_id='T578' and combo_type = 2
            //set sql_safe_updates = 0; delete from product_category_set_temp where 1=1 and combo_type = 2 and product_id='T578';set sql_safe_updates = 1;
            //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,0,now(),5,20,'');set sql_safe_updates = 1;
            //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,122,now(),2,0,'');set sql_safe_updates = 1;
            //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1;
            //set sql_safe_updates = 0;delete from price_master_temp where 1=1 and product_id='T578' and combo_type=2;set sql_safe_updates = 1;
            //insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select 15164 as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1  and parent_id='T578';
            //set sql_safe_updates = 0; delete from product_combo_temp where writer_id = 0 and parent_id='T578'; set sql_safe_updates= 1;
            //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1;

            //SELECT * from product where product_id='15164'
        }