request->get(); $id = $get['id'] ?? 0; $name = $get['name'] ?? ''; $xj = XjClass::getById($id, true); if (empty($xj) || $xj->mainId != $this->mainId) { util::fail('修改失败'); } $xj->name = $name; $xj->save(); util::complete('修改成功'); } //取出所有小菊 ssh 20210904 public function actionGetAllXj() { $where = []; $where['shopId'] = $this->shopId; $where['status'] = 1; $list = XjClass::getShopXj($this->shopId); util::success(['list' => $list]); } //取出商家上架的小菊 ssh 20210904 public function actionGetSjXj() { $get = Yii::$app->request->get(); $itemId = $get['itemId'] ?? 0; $product = ItemClass::getById($itemId, true); if (empty($product)) { util::fail('没有花材信息'); } if ($product->mainId != $this->mainId) { util::fail('不是您的花材'); } $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0, 'status' => 1], null, '*'); if (!empty($list)) { foreach ($list as $key => $val) { $shortCover = $val['cover'] ?? ''; $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130"; $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700"; $list[$key]['cover'] = $cover; $list[$key]['bigCover'] = $bigCover; $list[$key]['shortCover'] = $shortCover; } } util::success(['list' => $list]); } //取出商家所有小菊 ssh 20210904 public function actionGetFilterXj() { $get = Yii::$app->request->get(); $itemId = $get['itemId'] ?? 0; $product = ItemClass::getById($itemId, true); if ($product->mainId != $this->mainId) { util::fail('不是您的花材'); } $list = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 0], null, '*'); if (!empty($list)) { foreach ($list as $key => $val) { $shortCover = $val['cover'] ?? ''; $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130"; $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700"; $list[$key]['cover'] = $cover; $list[$key]['bigCover'] = $bigCover; $list[$key]['shortCover'] = $shortCover; } } util::success(['list' => $list]); } //保存所有数量 ssh 20221030 public function actionSaveAllNum() { $post = Yii::$app->request->post(); $itemId = $post['itemId'] ?? 0; $product = ItemClass::getById($itemId, true); if ($product->mainId != $this->mainId) { util::fail('不是您的花材'); } $data = $post['data'] ?? ''; $arr = json_decode($data, true); if (empty($arr)) { util::fail('没有找到花材列表'); } foreach ($arr as $item) { $id = $item['id'] ?? 0; $stock = $item['stock'] ?? -1; $xj = XjClass::getById($id, true); if (empty($xj)) { continue; } if ($xj->itemId != $itemId) { continue; } $xj->stock = $stock; //有库存则上架,没库存则下架 $status = $stock == 0 ? 2 : 1; $xj->status = $status; $xj->save(); } util::complete('保存成功'); } //新增小菊 lqh 2021.12.8 public function actionBatchAdd() { $post = Yii::$app->request->post(); $itemId = $post['itemId'] ?? 0; $product = ItemClass::getById($itemId, true); if ($product->mainId != $this->mainId) { util::fail('不是您的花材'); } $xjData = $post['xjData'] ?? ''; if (empty($xjData)) { util::fail('请上传图片'); } $arr = json_decode($xjData, true); if (is_array($arr) == false) { util::fail('请上传图片...'); } XjClass::batchAddXj($arr, $this->shop, $product); util::complete('添加成功'); } //删除选项 ssh 20230728 public function actionDelItem() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $xj = XjClass::getById($id, true); if (empty($xj) || $xj->mainId != $this->mainId) { util::fail('删除失败'); } $xj->delStatus = 1; $xj->status = 2; $xj->save(); $itemId = $xj->itemId ?? 0; $delList = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 1], null, '*', null, true); //超过2个月,多颜色订单就不能售后,超过3个月多颜色的花材就要删除掉,多处要同步修改,关键词 xj_global_change ssh 20251230 if(!empty($delList)){ $threeMonthsAgo = time() - (90 * 24 * 60 * 60); // 3个月前的时间戳 foreach ($delList as $item) { $updateTime = strtotime($item->updateTime); // 将时间转换为时间戳 // 判断 updateTime 是否超过 3 个月 if ($updateTime < $threeMonthsAgo) { //$item->delete(); } } } util::complete(); } //清除全部小菊 lqh 2021.12.8 public function actionClearAll() { $get = Yii::$app->request->get(); $itemId = $get['itemId'] ?? 0; $product = ItemClass::getById($itemId, true); if ($product->mainId != $this->mainId) { util::fail('不是您的花材'); } XjClass::updateByCondition(['itemId' => $itemId], ['status' => 2, 'delStatus' => 1]); $delList = XjClass::getAllByCondition(['itemId' => $itemId, 'delStatus' => 1], null, '*', null, true); //超过2个月,多颜色订单就不能售后,超过3个月多颜色的花材就要删除掉,多处要同步修改,关键词 xj_global_change ssh 20251230 if(!empty($delList)){ $threeMonthsAgo = time() - (90 * 24 * 60 * 60); // 3个月前的时间戳 foreach ($delList as $item) { $updateTime = strtotime($item->updateTime); // 将时间转换为时间戳 // 判断 updateTime 是否超过 3 个月 if ($updateTime < $threeMonthsAgo) { //$item->delete(); } } } util::complete('已删除'); } }