sql Desactivar / eliminar(para bajas)elcatálogodeUna farmacia
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Desactivar / eliminar(para bajas)elcatálogodeUna farmacia相关的知识,希望对你有一定的参考价值。
-- first get all coupon_ids for which the pharmacy has given price/stock
select cd.coupon_id
from coupon_details cd inner join listing_products_stocks lps using (laboratory_product_id)
where lps.listing_id = 23143
limit 100000;
-- pasar los ids a formato lista y reservar
-- luego eliminar las entradas de listing_products_stocks correspondientes
delete from listing_products_stocks where listing_id = 23143;
-- hacer touch() de cada uno en la consola php de sys1 para que se actualicen precios, listing_id con mejor precio, etc:
-- > php scripts/console production
-- > $coupons = array(26502, ..., 30380);
-- > foreach ($coupons as $coupon) { $c = Doctrine::getTable('Coupons')->find($coupon); $c->touch(); }
-- obtain the brand_id
select * from laboratory_brands where name = 'Sotya';
-- check the affected records
select *
from listing_products_stocks lps
left join laboratory_products lp using (laboratory_product_id)
where lps.listing_id = 29958
and lp.laboratory_brand_id = 210;
-- deactivate the stock for these products
update listing_products_stocks lps
left join laboratory_products lp using (laboratory_product_id)
set lps.status = 2
where lps.listing_id = 29958
and lp.laboratory_brand_id = 210;
-- obtain the ids of the coupons to be touched
select cd.coupon_id
from listing_products_stocks lps
left join laboratory_products lp using (laboratory_product_id)
left join coupon_details cd using (laboratory_product_id)
where lps.listing_id = 29958
and lp.laboratory_brand_id = 210;
-- in the PHP console, use:
$coupons = array(26502, 28768, 26503, 26504, 26505, 26506, 26511, 28778, 26516, 26518, 26519, 26520, 26521, 26525, 26538, 28757, 26539, 28776, 26540, 28761, 26542, 26543, 26547, 26549, 26552, 26553, 26554, 26559, 26560, 26561, 26564, 26565, 26569, 26570, 26572, 26573, 26574, 26575, 28777, 26576, 26577, 26578, 28752, 26582, 26584, 26585, 28775, 26590, 26592, 26595, 28763, 26596, 26598, 26599, 26601, 26602, 26603, 26604, 28774, 26607, 26608, 26610, 26611, 26612, 26613, 26614, 26615, 26622, 26623, 26624, 26629, 26632, 26633, 26641, 26642, 26643, 26644, 28762, 26646, 26648, 26649, 26650, 26651, 26652, 26653, 26654, 26655, 28764, 26656, 28769, 26666, 26667, 28760, 26668, 26670, 26676, 26680, 26682, 26685, 26689, 26690, 26691, 26692, 26697, 28759, 26706, 26707, 26708, 26709, 26710, 26711, 26712, 26714, 26715, 26725, 26728, 26729, 26730, 26731, 26732, 30377, 30380);
foreach ($coupons as $coupon) { $c = Doctrine::getTable('Coupons')->find($coupon); $c->touch(); }
-- 1. set as out-of-stock listing_products_stocks for given coupons and pharmacies with unlimited stock
update listing_products_stocks lps
left join coupon_details cd using (laboratory_product_id)
set lps.status = 4 # LISTING_PRODUCT_STATUS_OUT_OF_STOCK
lps.updated_at = NOW()
where lps.stock_type = 1 # LISTING_PRODUCT_STOCK_TYPE_UNLIMITED
and cd.coupon_id in (8579, 8583, 8655, 8776, 8820, 8846, 8931, 9029, 9184, 9185, 9210, 9276, 9289, 9326, 9406, 9477, 10857, 10925, 10927, 11012, 11018, 11362, 11368, 11413, 11414, 11693, 12004, 12267, 12415, 12623, 13124, 13142, 13209, 13217, 13218, 13346, 13428, 13446, 13486, 13506, 13529, 13702, 13793, 13863, 13877, 13931, 13940, 13955, 13971, 14086, 14098, 14190, 14228, 14295, 14307, 14453, 14503, 14516, 14998, 15148, 15305, 15333, 15540, 15694, 16073, 16181, 16324, 16547, 16598, 16602, 16613, 16664, 16687, 16730, 16735, 16812, 16825, 17099, 17106, 17131, 17305, 17317, 17323, 17590, 17643, 17720, 17749, 17776, 17874, 17894, 17897, 17982, 18014, 18047, 18048, 18078, 18085, 18120, 18152, 18273, 18317, 18409, 18411, 18692, 18970, 18988, 18990, 19091, 19222, 19227, 19229, 19243, 19348, 19395, 19458, 19627, 19694, 20099, 20105, 20170, 20217, 20671, 20744, 20806, 20835, 20864, 21167, 21175, 21233, 21369, 21674, 22106, 22114, 22535, 22551, 22557, 22865, 22866, 23060, 23164, 23167, 23337, 23410, 23522, 23663, 23664, 23714, 23759, 24018, 24044, 24093, 24182, 8094, 25867, 24699, 8170, 27769, 18307, 16032, 11537, 13735, 20467, 18599, 18854, 10886, 19083, 8512, 8820, 8819, 9326, 19215, 13506, 24092, 19728, 24491, 24199, 9735, 9077, 10558, 20046, 18373, 8774, 11537, 15401, 18855, 12053, 14026, 13347, 18894, 19082, 13023, 12342, 11537, 8819, 21371, 8819, 17499, 9589, 24880, 16613, 9326, 18471, 16613, 25672, 13347, 9326);
-- 2. touch the coupons. using the PHP console in sys1:
php scripts/console production
> $coupons = array(8579, 8583, 8655, 8776, 8820, 8846, 8931, 9029, 9184, 9185, 9210, 9276, 9289, 9326, 9406, 9477, 10857, 10925, 10927, 11012, 11018, 11362, 11368, 11413, 11414, 11693, 12004, 12267, 12415, 12623, 13124, 13142, 13209, 13217, 13218, 13346, 13428, 13446, 13486, 13506, 13529, 13702, 13793, 13863, 13877, 13931, 13940, 13955, 13971, 14086, 14098, 14190, 14228, 14295, 14307, 14453, 14503, 14516, 14998, 15148, 15305, 15333, 15540, 15694, 16073, 16181, 16324, 16547, 16598, 16602, 16613, 16664, 16687, 16730, 16735, 16812, 16825, 17099, 17106, 17131, 17305, 17317, 17323, 17590, 17643, 17720, 17749, 17776, 17874, 17894, 17897, 17982, 18014, 18047, 18048, 18078, 18085, 18120, 18152, 18273, 18317, 18409, 18411, 18692, 18970, 18988, 18990, 19091, 19222, 19227, 19229, 19243, 19348, 19395, 19458, 19627, 19694, 20099, 20105, 20170, 20217, 20671, 20744, 20806, 20835, 20864, 21167, 21175, 21233, 21369, 21674, 22106, 22114, 22535, 22551, 22557, 22865, 22866, 23060, 23164, 23167, 23337, 23410, 23522, 23663, 23664, 23714, 23759, 24018, 24044, 24093, 24182, 8094, 25867, 24699, 8170, 27769, 18307, 16032, 11537, 13735, 20467, 18599, 18854, 10886, 19083, 8512, 8820, 8819, 9326, 19215, 13506, 24092, 19728, 24491, 24199, 9735, 9077, 10558, 20046, 18373, 8774, 11537, 15401, 18855, 12053, 14026, 13347, 18894, 19082, 13023, 12342, 11537, 8819, 21371, 8819, 17499, 9589, 24880, 16613, 9326, 18471, 16613, 25672, 13347, 9326);
> foreach ($coupons as $coupon) {
$c = Doctrine::getTable('Coupons')->find($coupon);
$c->touch();
}
>
-- 3. set coupons as expired for coupons that have no pharmacy selling the product left
-- This might not be necessary
update coupons
set coupon_state_id = 2
where coupon_state_id = 6
and coupon_id in (8579, 8583, 8655, 8776, 8820, 8846, 8931, 9029, 9184, 9185, 9210, 9276, 9289, 9326, 9406, 9477, 10857, 10925, 10927, 11012, 11018, 11362, 11368, 11413, 11414, 11693, 12004, 12267, 12415, 12623, 13124, 13142, 13209, 13217, 13218, 13346, 13428, 13446, 13486, 13506, 13529, 13702, 13793, 13863, 13877, 13931, 13940, 13955, 13971, 14086, 14098, 14190, 14228, 14295, 14307, 14453, 14503, 14516, 14998, 15148, 15305, 15333, 15540, 15694, 16073, 16181, 16324, 16547, 16598, 16602, 16613, 16664, 16687, 16730, 16735, 16812, 16825, 17099, 17106, 17131, 17305, 17317, 17323, 17590, 17643, 17720, 17749, 17776, 17874, 17894, 17897, 17982, 18014, 18047, 18048, 18078, 18085, 18120, 18152, 18273, 18317, 18409, 18411, 18692, 18970, 18988, 18990, 19091, 19222, 19227, 19229, 19243, 19348, 19395, 19458, 19627, 19694, 20099, 20105, 20170, 20217, 20671, 20744, 20806, 20835, 20864, 21167, 21175, 21233, 21369, 21674, 22106, 22114, 22535, 22551, 22557, 22865, 22866, 23060, 23164, 23167, 23337, 23410, 23522, 23663, 23664, 23714, 23759, 24018, 24044, 24093, 24182, 8094, 25867, 24699, 8170, 27769, 18307, 16032, 11537, 13735, 20467, 18599, 18854, 10886, 19083, 8512, 8820, 8819, 9326, 19215, 13506, 24092, 19728, 24491, 24199, 9735, 9077, 10558, 20046, 18373, 8774, 11537, 15401, 18855, 12053, 14026, 13347, 18894, 19082, 13023, 12342, 11537, 8819, 21371, 8819, 17499, 9589, 24880, 16613, 9326, 18471, 16613, 25672, 13347, 9326);
-- disable catalog
update listing_products_stocks
set status = 2, updated_at = NOW()
where listing_id = 26451 and status = 1;
-- verify
select lps.laboratory_product_id, lps.listing_id, lps.status
from listing_products_stocks lps
where lps.listing_id = 26451 and lps.status = 1;
-- as last step, we should touch all coupons affected, in sys1
php scripts/utils/capitan/touch_coupons.php production 26451
以上是关于sql Desactivar / eliminar(para bajas)elcatálogodeUna farmacia的主要内容,如果未能解决你的问题,请参考以下文章
sql 查询para poder eliminar el contenido de una tabla especifica
php Desactivar boton de compra Woocommerce
php Desactivar comentarios en los adjuntos de WordPress