alias('pbpl') ->leftJoin(['pbp' => ProductBatchProcess::tableName()], 'pbp.id=pbpl.product_batch_process_id') ->leftJoin(['u' => User::tableName()], 'u.id=pbp.process_user_id') ->leftJoin(['su' => SaasUser::tableName()],'su.mobile=u.binding') ->leftJoin(['pb' => ProductBatch::tableName()], 'pb.id=pbp.product_batch_id') ->leftJoin(['p' => Product::tableName()], 'p.id=pb.product_id') ->leftJoin(['g' => Goods::tableName()], 'g.id=pb.goods_id') ->where([ 'pbpl.is_delete' => 0, 'pb.is_delete' => 0, 'pb.store_id' => get_store_id() ])->select(['pbpl.*', 'pbp.process_name', 'pb.batch_number', 'pb.batch_name', 'p.product_name', 'g.name as goods_name', 'su.name']); if (!empty($product_batch_id)) { $query->andWhere(['=', 'pbp.product_batch_id', $product_batch_id]); } if (!empty($product_batch_process_id)) { $query->andWhere(['=', 'pbpl.product_batch_process_id', $product_batch_process_id]); } if (!empty($search_product_name_key)) { $query->andWhere(['like', 'p.product_name', trim($search_product_name_key)]); } if (!empty($search_batch_name_key)) { $query->andWhere(['like', 'pb.batch_name', trim($search_batch_name_key)]); } if (!empty($search_batch_number_key)) { $query->andWhere(['like', 'pb.batch_number', trim($search_batch_number_key)]); } if (!empty($search_goods_name_key)) { $query->andWhere(['like', 'g.name', trim($search_goods_name_key)]); } if (!empty($search_process_user_name_key)) { $query->andWhere(['like', 'su.name', trim($search_process_user_name_key)]); } if ($search_state != -1) { $query->andWhere(['pbpl.state' => $search_state]); } if ($start_time) { $query->andWhere(['>=', 'pb.created_at', strtotime($start_time)]); } if ($end_time) { $query->andWhere(['<=', 'pb.created_at', strtotime($end_time)]); } $list = pagination_make($query, true, 'id desc'); $list= $list['list']; foreach ($list as $k => $v) { $log_sheet_list = ProductBatchProcessLogSheet::find()->where(['store_id' => $v['store_id'], 'process_log_id' => $v['id']])->asArray()->all(); foreach ($log_sheet_list as $kk => $vv) { $log_sheet_list[$kk]['value'] = ($vv['type'] == 'checkbox' || $vv['type'] == 'uploadImg' || $vv['type'] == 'uploadVideo') ? json_decode($vv['value'], true) : $vv['value']; } $list[$k]['log_sheet_list'] =$log_sheet_list; } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list, 'pageNo' => $list['pageNo'], 'totalCount' => $list['totalCount'], ], ]; } public function actionProductBatchProcessLogDel() { $id = get_params('id'); $product_batch_process_log = ProductBatchProcessLog::findOne($id); $product_batch_process_log->is_delete = 1; if ($product_batch_process_log->save()) { return [ 'code' => 0, 'msg' => '删除成功' ]; }else { return [ 'code' => 1, 'msg' => $product_batch_process_log->getErrors(), ]; } } /** * 批量操作 * @return \yii\web\Response */ public function actionProductBatchProcessLogOperate() { $id = post_params('id'); $type = post_params('type'); $status = post_params('status'); if (empty($id) || !is_array($id)) { return [ 'code' => 1, 'msg' => '参数有误' ]; } if (!in_array($status, [0, 1])) { return [ 'code' => 1, 'msg' => '状态参数有误' ]; } if ($type == 'open' || $type == 'disabled') { ProductBatchProcessLog::updateAll(['is_show' => $status], ['in', 'id', $id]); } if ($type == 'delete') { $res= ProductBatchProcessLog::updateAll(['is_delete' => $status], ['in', 'id', $id]); } return [ 'code' => 0, 'msg' => '更新成功' ]; } }