| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\jobs;
- use yii\base\BaseObject;
- use yii\queue\JobInterface;
- use app\models\Goods;
- use app\models\MdGoods;
- use app\models\Md;
- /**
- * 用于后台审核完门店后,批量将门店商品下架
- */
- class BatchDownGoodsJob extends BaseObject implements JobInterface
- {
- public array $ids;
- public int $store_id;
- public function execute($queue)
- {
- $goods = Goods::find()->select('id, attr, virtual_sales, price, goods_num')->where([
- 'store_id' => $this->store_id,
- 'is_delete' => 0,
- ])->asArray()->all();
- foreach ($this->ids as $id) {
- $md = Md::findOne($id);
- if (!$md) {
- continue;
- }
- $delivery_type = $md->self_delivery_type;
- foreach ($goods as $value) {
- $md_goods = MdGoods::findOne([
- 'md_id' => $id,
- 'goods_id' => $value['id']
- ]);
- if (!$md_goods) {
- $md_goods = new MdGoods();
- $md_goods->md_id = $id;
- $md_goods->goods_id = $value['id'];
- }
- $md_goods->status = 0;
- $md_goods->virtual_sales = $value['virtual_sales'];
- $md_goods->attr = $value['attr'];
- $md_goods->goods_num = $value['goods_num'];
- $md_goods->price = $value['price'];
- $md_goods->delivery_type = $delivery_type;
- $md_goods->save();
- }
- }
- }
- }
|